Nicholas Sudsgaard has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/85393?usp=email )
Change subject: src/lib/smbios.c: Add portable battery structure ......................................................................
src/lib/smbios.c: Add portable battery structure
Reference: 7.23 Portable Battery (Type 22), System Management BIOS (SMBIOS) Reference Specification, Version 3.2.0.
TEST=Generated correct entry in SMBIOS table.
Change-Id: Ia03be6b94b76c02a234af180e32e4dc0f52c6be8 Signed-off-by: Nicholas Sudsgaard devel+coreboot@nsudsgaard.com --- M src/include/smbios.h M src/lib/smbios.c 2 files changed, 77 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/93/85393/1
diff --git a/src/include/smbios.h b/src/include/smbios.h index fd44e09..43072c65 100644 --- a/src/include/smbios.h +++ b/src/include/smbios.h @@ -43,6 +43,16 @@ int smbios_write_type41(unsigned long *current, int *handle, const char *name, u8 instance, u16 segment_group, u8 bus, u8 device, u8 function, u8 device_type); +enum smbios_battery_chemistry; +int smbios_write_type22(unsigned long *current, int *handle, + const char *location, const char *manufacturer, + const char *date, const char *serial_number, + const char *name, enum smbios_battery_chemistry chemistry, + u16 design_capacity, u16 design_voltage, + const char *sbds_version, u8 max_error, + u16 sbds_serial_number, u16 sbds_date, + const char *sbds_chemistry, u8 design_capacity_multiplier, + u32 oem_specific); enum smbios_temp_location; enum smbios_temp_status; int smbios_write_type28(unsigned long *current, int *handle, @@ -279,6 +289,7 @@ SMBIOS_MEMORY_DEVICE = 17, SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS = 19, SMBIOS_MEMORY_DEVICE_MAPPED_ADDRESS = 20, + SMBIOS_PORTABLE_BATTERY = 22, SMBIOS_TEMPERATURE_PROBE = 28, SMBIOS_SYSTEM_BOOT_INFORMATION = 32, SMBIOS_IPMI_DEVICE_INFORMATION = 38, @@ -1077,6 +1088,37 @@ SMBIOS_TEMP_LOCATION_ADDCARD, };
+struct smbios_type22 { + struct smbios_header header; + u8 location; + u8 manufacturer; + u8 date; + u8 serial_number; + u8 name; + u8 chemistry; + u16 design_capacity; + u16 design_voltage; + u8 sbds_version; + u8 max_error; + u16 sbds_serial_number; + u16 sbds_date; + u8 sbds_chemistry; + u8 design_capacity_multiplier; + u32 oem_specific; + u8 eos[2]; +} __packed; + +enum smbios_battery_chemistry { + SMBIOS_BATTERY_CHEMISTRY_OTHER = 0x01, + SMBIOS_BATTERY_CHEMISTRY_UNKNOWN = 0x02, + SMBIOS_BATTERY_CHEMISTRY_LEAD_ACID = 0x03, + SMBIOS_BATTERY_CHEMISTRY_NICKEL_CADMIUM = 0x04, + SMBIOS_BATTERY_CHEMISTRY_NICKEL_METAL_HYDRIDE = 0x05, + SMBIOS_BATTERY_CHEMISTRY_LITHIUM_ION = 0x06, + SMBIOS_BATTERY_CHEMISTRY_ZINC_AIR = 0x07, + SMBIOS_BATTERY_CHEMISTRY_LITHIUM_POLYMER = 0x08, +}; + struct smbios_type28 { struct smbios_header header; u8 description; diff --git a/src/lib/smbios.c b/src/lib/smbios.c index 9cee637..bd93619 100644 --- a/src/lib/smbios.c +++ b/src/lib/smbios.c @@ -868,6 +868,41 @@ return totallen; }
+int smbios_write_type22(unsigned long *current, int *handle, + const char *location, const char *manufacturer, + const char *date, const char *serial_number, + const char *name, enum smbios_battery_chemistry chemistry, + u16 design_capacity, u16 design_voltage, + const char *sbds_version, u8 max_error, + u16 sbds_serial_number, u16 sbds_date, + const char *sbds_chemistry, u8 design_capacity_multiplier, + u32 oem_specific) +{ + struct smbios_type22 *t = smbios_carve_table(*current, SMBIOS_PORTABLE_BATTERY, + sizeof(*t), *handle); + + t->location = smbios_add_string(t->eos, location); + t->manufacturer = smbios_add_string(t->eos, manufacturer); + t->date = smbios_add_string(t->eos, date); + t->serial_number = smbios_add_string(t->eos, serial_number); + t->name = smbios_add_string(t->eos, name); + t->chemistry = chemistry; + t->design_capacity = design_capacity; + t->design_voltage = design_voltage; + t->sbds_version = smbios_add_string(t->eos, sbds_version); + t->max_error = max_error; + t->sbds_serial_number = sbds_serial_number; + t->sbds_date = sbds_date; + t->sbds_chemistry = smbios_add_string(t->eos, sbds_chemistry); + t->design_capacity_multiplier = design_capacity_multiplier; + t->oem_specific = oem_specific; + + const int len = smbios_full_table_len(&t->header, t->eos); + *current += len; + *handle += 1; + return len; +} + int smbios_write_type28(unsigned long *current, int *handle, const char *name, const enum smbios_temp_location location,