From d62a5012d6e5904279eb56507bc2a021d2acce77 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Mon, 28 Jun 2021 17:18:06 +0200 Subject: SMBIOS: Introduce `smbios_carve_table` function MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/55907 Tested-by: build bot (Jenkins) Reviewed-by: Tim Wawrzynczak Reviewed-by: Michał Żygowski --- src/drivers/elog/elog.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/drivers/elog/elog.c') 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; } -- cgit v1.2.3