[coreboot-gerrit] Patch set updated for coreboot: smbios: Calculate SMBIOS Max Struct size
Ben Frisch (bfrisch@gmail.com)
gerrit at coreboot.org
Wed Jun 24 06:20:10 CEST 2015
Ben Frisch (bfrisch at gmail.com) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10163
-gerrit
commit d2561d45b6bcce19f07fd00190234da90eb2d7c7
Author: Ben Frisch <bfrisch at gmail.com>
Date: Sat May 9 19:52:18 2015 -0500
smbios: Calculate SMBIOS Max Struct size
The SMBIOS Specification 2.3 and up defines Maximum Structure Size
as the "Size of the largest SMBIOS structure, in bytes, and encompasses
the structure’s formatted area and text strings." The hardcoded size
is too small to accurately represent the maximum SMBIOS structure sizes.
While the field is not used by Linux it is used by some RTOS
implementations, eg. VxWorks.
TEST=Booted Linux and ran github.com/bfrisch/dmidecode which verified
the maximum structure size on Minnowboard Max.
Change-Id: I98087975c53a02857742dea283f4e303485b2ffe
Signed-off-by: Ben Frisch <bfrisch at gmail.com>
---
src/arch/x86/boot/smbios.c | 28 +++++++++++++++-------------
src/include/smbios.h | 2 ++
2 files changed, 17 insertions(+), 13 deletions(-)
diff --git a/src/arch/x86/boot/smbios.c b/src/arch/x86/boot/smbios.c
index 1dbe32d..2f7cc5a 100644
--- a/src/arch/x86/boot/smbios.c
+++ b/src/arch/x86/boot/smbios.c
@@ -533,7 +533,9 @@ unsigned long smbios_write_tables(unsigned long current)
{
struct smbios_entry *se;
unsigned long tables;
- int len, handle = 0;
+ int len = 0;
+ int max_struct_size = 0;
+ int handle = 0;
current = ALIGN(current, 16);
printk(BIOS_DEBUG, "%s: %08lx\n", __func__, current);
@@ -543,28 +545,28 @@ unsigned long smbios_write_tables(unsigned long current)
current = ALIGN(current, 16);
tables = current;
- len = smbios_write_type0(¤t, handle++);
- len += smbios_write_type1(¤t, handle++);
- len += smbios_write_type2(¤t, handle++);
- len += smbios_write_type3(¤t, handle++);
- len += smbios_write_type4(¤t, handle++);
- len += smbios_write_type11(¤t, &handle);
+ update_max(len, max_struct_size, smbios_write_type0(¤t, handle++));
+ update_max(len, max_struct_size, smbios_write_type1(¤t, handle++));
+ update_max(len, max_struct_size, smbios_write_type2(¤t, handle++));
+ update_max(len, max_struct_size, smbios_write_type3(¤t, handle++));
+ update_max(len, max_struct_size, smbios_write_type4(¤t, handle++));
+ update_max(len, max_struct_size, smbios_write_type11(¤t, &handle));
#if CONFIG_ELOG
- len += elog_smbios_write_type15(¤t, handle++);
+ update_max(len, max_struct_size, smbios_write_type15(¤t, &handle));
#endif
- len += smbios_write_type17(¤t, &handle);
- len += smbios_write_type32(¤t, handle++);
+ update_max(len, max_struct_size, smbios_write_type17(¤t, &handle));
+ update_max(len, max_struct_size, smbios_write_type32(¤t, handle++));
- len += smbios_walk_device_tree(all_devices, &handle, ¤t);
+ update_max(len, max_struct_size, smbios_walk_device_tree(all_devices, &handle, ¤t));
- len += smbios_write_type127(¤t, handle++);
+ update_max(len, max_struct_size, smbios_write_type127(¤t, handle++));
memset(se, 0, sizeof(struct smbios_entry));
memcpy(se->anchor, "_SM_", 4);
se->length = sizeof(struct smbios_entry);
se->major_version = 2;
se->minor_version = 7;
- se->max_struct_size = 24;
+ se->max_struct_size = max_struct_size;
se->struct_count = handle;
memcpy(se->intermediate_anchor_string, "_DMI_", 5);
diff --git a/src/include/smbios.h b/src/include/smbios.h
index 66d2b2f..b37f131 100644
--- a/src/include/smbios.h
+++ b/src/include/smbios.h
@@ -44,6 +44,8 @@ u8 smbios_mainboard_enclosure_type(void);
const char *smbios_mainboard_family(void);
#endif
+#define update_max(len, max_len, stmt) do { int tmp = stmt; max_len = MAX(max_len, tmp); len += tmp; } while(0)
+
#define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
#define BIOS_CHARACTERISTICS_PC_CARD (1 << 8)
#define BIOS_CHARACTERISTICS_PNP (1 << 9)
More information about the coreboot-gerrit
mailing list