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>
This commit is contained in:
Angel Pons
2021-06-28 17:18:06 +02:00
committed by Patrick Georgi
parent ca01baa065
commit d62a5012d6
8 changed files with 94 additions and 178 deletions

View File

@@ -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;
}