diff options
author | Angel Pons <th3fanbus@gmail.com> | 2021-06-28 17:18:06 +0200 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2021-07-01 07:37:21 +0000 |
commit | d62a5012d6e5904279eb56507bc2a021d2acce77 (patch) | |
tree | 2b8a4eb40ed8842ca8f237501182a3684931ac2a /src/drivers | |
parent | ca01baa065e25242945bdfa8631694a6e903f17f (diff) |
SMBIOS: Introduce `smbios_carve_table` function
Factor out some boilerplate code into a helper `smbios_carve_table`
function, which zeroes out the table memory and fills in the header
fields common to all tables.
Change-Id: Iece2f64f9151d3c79813f6264dfb3a92d98c2035
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/55907
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Reviewed-by: Michał Żygowski <michal.zygowski@3mdeb.com>
Diffstat (limited to 'src/drivers')
-rw-r--r-- | src/drivers/elog/elog.c | 10 | ||||
-rw-r--r-- | src/drivers/wifi/generic/smbios.c | 10 |
2 files changed, 7 insertions, 13 deletions
diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c index 6e31686fe5..48b9dc365f 100644 --- a/src/drivers/elog/elog.c +++ b/src/drivers/elog/elog.c @@ -593,8 +593,6 @@ static inline u8 *elog_flash_offset_to_address(void) */ int elog_smbios_write_type15(unsigned long *current, int handle) { - struct smbios_type15 *t = (struct smbios_type15 *)*current; - int len = sizeof(*t); uintptr_t log_address; size_t elog_size = region_device_sz(&elog_state.nv_dev); @@ -614,10 +612,9 @@ int elog_smbios_write_type15(unsigned long *current, int handle) return 0; } - memset(t, 0, len); - t->type = SMBIOS_EVENT_LOG; - t->length = len - 2; - t->handle = handle; + struct smbios_type15 *t = smbios_carve_table(*current, SMBIOS_EVENT_LOG, + sizeof(*t), handle); + t->area_length = elog_size - 1; t->header_offset = 0; t->data_offset = sizeof(struct elog_header); @@ -629,6 +626,7 @@ int elog_smbios_write_type15(unsigned long *current, int handle) t->log_type_descriptors = 0; t->log_type_descriptor_length = 2; + const int len = sizeof(*t); *current += len; return len; } diff --git a/src/drivers/wifi/generic/smbios.c b/src/drivers/wifi/generic/smbios.c index 96b11d3051..e8936be386 100644 --- a/src/drivers/wifi/generic/smbios.c +++ b/src/drivers/wifi/generic/smbios.c @@ -22,17 +22,13 @@ static int smbios_write_intel_wifi(struct device *dev, int *handle, unsigned lon u8 eos[2]; } __packed; - struct smbios_type_intel_wifi *t = (struct smbios_type_intel_wifi *)*current; - int len = sizeof(*t); + struct smbios_type_intel_wifi *t = smbios_carve_table(*current, 0x85, + sizeof(*t), *handle); - memset(t, 0, sizeof(*t)); - t->type = 0x85; - t->length = len - 2; - t->handle = *handle; /* Intel wifi driver expects this string to be in the table 0x85. */ t->str = smbios_add_string(t->eos, "KHOIHGIUCCHHII"); - len = t->length + smbios_string_table_len(t->eos); + const int len = t->length + smbios_string_table_len(t->eos); *current += len; *handle += 1; return len; |