summaryrefslogtreecommitdiffstats
path: root/src/drivers/elog
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2021-06-28 17:18:06 +0200
committerPatrick Georgi <pgeorgi@google.com>2021-07-01 07:37:21 +0000
commitd62a5012d6e5904279eb56507bc2a021d2acce77 (patch)
tree2b8a4eb40ed8842ca8f237501182a3684931ac2a /src/drivers/elog
parentca01baa065e25242945bdfa8631694a6e903f17f (diff)
downloadcoreboot-d62a5012d6e5904279eb56507bc2a021d2acce77.tar.gz
coreboot-d62a5012d6e5904279eb56507bc2a021d2acce77.tar.bz2
coreboot-d62a5012d6e5904279eb56507bc2a021d2acce77.zip
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/elog')
-rw-r--r--src/drivers/elog/elog.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c
index 6e31686fe52e..48b9dc365fe6 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;
}