Martin Roth has submitted this change. ( https://review.coreboot.org/c/coreboot/+/67926 )
(
1 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: smbios: Add API to generate SMBIOS type 28 Temperature Probe ......................................................................
smbios: Add API to generate SMBIOS type 28 Temperature Probe
Based on DMTF SMBIOS Specification 3.5.0
Signed-off-by: Erik van den Bogaert ebogaert@eltan.com Change-Id: I710124ca88dac9edb68aab98cf5950aa16c695d3 Reviewed-on: https://review.coreboot.org/c/coreboot/+/67926 Reviewed-by: Frans Hendriks fhendriks@eltan.com Reviewed-by: Angel Pons th3fanbus@gmail.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/arch/x86/smbios.c M src/include/smbios.h 2 files changed, 97 insertions(+), 0 deletions(-)
Approvals: build bot (Jenkins): Verified Frans Hendriks: Looks good to me, approved Angel Pons: Looks good to me, but someone else must approve
diff --git a/src/arch/x86/smbios.c b/src/arch/x86/smbios.c index 0c1a877..2a2a6af 100644 --- a/src/arch/x86/smbios.c +++ b/src/arch/x86/smbios.c @@ -1052,6 +1052,35 @@ return totallen; }
+int smbios_write_type28(unsigned long *current, int *handle, + const char *name, + const enum smbios_temp_location location, + const enum smbios_temp_status status, + u16 max_value, u16 min_value, + u16 resolution, u16 tolerance, + u16 accuracy, + u32 oem, + u16 nominal_value) +{ + struct smbios_type28 *t = smbios_carve_table(*current, SMBIOS_TEMPERATURE_PROBE, + sizeof(*t), *handle); + + t->description = smbios_add_string(t->eos, name ? name : "Temperature"); + t->location_and_status = location | (status << 5); + t->maximum_value = max_value; + t->minimum_value = min_value; + t->resolution = resolution; + t->tolerance = tolerance; + t->accuracy = accuracy; + t->oem_defined = oem; + t->nominal_value = nominal_value; + + const int len = smbios_full_table_len(&t->header, t->eos); + *current += len; + *handle += 1; + return len; +} + static int smbios_write_type32(unsigned long *current, int handle) { struct smbios_type32 *t = smbios_carve_table(*current, SMBIOS_SYSTEM_BOOT_INFORMATION, diff --git a/src/include/smbios.h b/src/include/smbios.h index 9c43843..65522f0 100644 --- a/src/include/smbios.h +++ b/src/include/smbios.h @@ -34,6 +34,17 @@ int smbios_write_type41(unsigned long *current, int *handle, const char *name, u8 instance, u16 segment, u8 bus, u8 device, u8 function, u8 device_type); +enum smbios_temp_location; +enum smbios_temp_status; +int smbios_write_type28(unsigned long *current, int *handle, + const char *name, + const enum smbios_temp_location location, + const enum smbios_temp_status status, + u16 max_value, u16 min_value, + u16 resolution, u16 tolerance, + u16 accuracy, + u32 oem, + u16 nominal_value);
int smbios_write_type43(unsigned long *current, int *handle, const u32 vendor_id, const u8 major_spec_ver, const u8 minor_spec_ver, @@ -255,6 +266,7 @@ SMBIOS_MEMORY_DEVICE = 17, SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS = 19, SMBIOS_MEMORY_DEVICE_MAPPED_ADDRESS = 20, + SMBIOS_TEMPERATURE_PROBE = 28, SMBIOS_SYSTEM_BOOT_INFORMATION = 32, SMBIOS_IPMI_DEVICE_INFORMATION = 38, SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION = 41, @@ -921,6 +933,46 @@ u8 eos[2]; } __packed;
+/* Bit[7..5] = Temp status */ +enum smbios_temp_status { + SMBIOS_TEMP_STATUS_OTHER = 0x01, + SMBIOS_TEMP_STATUS_UNKNOWN, + SMBIOS_TEMP_STATUS_OK, + SMBIOS_TEMP_STATUS_NONCRITICAL, + SMBIOS_TEMP_STATUS_CRITICAL, + SMBIOS_TEMP_STATUS_NONREC, // Non-Recoverable. +}; + +/* Bit[4..0] = Temp location */ +enum smbios_temp_location { + SMBIOS_TEMP_LOCATION_OTHER = 0x01, + SMBIOS_TEMP_LOCATION_UNKNOWN, + SMBIOS_TEMP_LOCATION_PROCESSOR, + SMBIOS_TEMP_LOCATION_DISK, + SMBIOS_TEMP_LOCATION_BAY, // Peripheral Bay. + SMBIOS_TEMP_LOCATION_SMM, // System Management Module. + SMBIOS_TEMP_LOCATION_BOARD, // Motherboard. + SMBIOS_TEMP_LOCATION_MM, // Memory. + SMBIOS_TEMP_LOCATION_PM, // Processor Module. + SMBIOS_TEMP_LOCATION_POW, // Power Unit. + SMBIOS_TEMP_LOCATION_ADDCARD, +}; + +struct smbios_type28 { + struct smbios_header header; + u8 description; + u8 location_and_status; + u16 maximum_value; + u16 minimum_value; + u16 resolution; + u16 tolerance; + u16 accuracy; + u32 oem_defined; + u16 nominal_value; + u8 eos[2]; +} __packed; + + struct smbios_type32 { struct smbios_header header; u8 reserved[6];