Skip to contentSkip to conversation

smbios: add parsing API

PATCH Superseded Christian Gmeiner 2 participants 6 messages Oct 7, 2020 – Nov 3, 2020 Library code

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 smbios: add parsing API

Add an very simple API to be able to access SMBIOS strings like vendor, model and bios version.

---
 include/smbios.h    | 27 +++++++++++++
 lib/Kconfig         |  6 +++
 lib/Makefile        |  1 +
 lib/smbios-parser.c | 96 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 130 insertions(+)
 create mode 100644 lib/smbios-parser.c
include/smbios.h +27 -0
index 97b9ddce23..ed60c00fae 100644
@@ -237,4 +237,31 @@ typedef int (*smbios_write_type)(ulong *addr, int handle);
  */
 ulong write_smbios_table(ulong addr);
 
+/**
+ * smbios_entry() - Get a vaild struct smbios_entry pointer
+ *
+ * @address:   address where smbios tables is located
+ * @size:      size of smbios table
+ * @return:    NULL or a valid pointer to a struct smbios_entry
+ */
+const struct smbios_entry *smbios_entry(u64 address, u32 size);
+
+/**
+ * smbios_header() - Search for SMBIOS header type
+ *
+ * @entry:     pointer to a struct smbios_entry
+ * @type:      SMBIOS type
+ * @return:    NULL or a valid pointer to a struct smbios_header
+ */
+const struct smbios_header *smbios_header(const struct smbios_entry *entry, int type);
+
+/**
+ * smbios_string() - Return string from SMBIOS
+ *
+ * @header:    pointer to struct smbios_header
+ * @index:     string index
+ * @return:    NULL or a valid const char pointer
+ */
+const char *smbios_string(const struct smbios_header *header, int index);
+
 #endif /* _SMBIOS_H_ */
lib/Kconfig +6 -0
index 8efb154f73..c92131b7bc 100644
@@ -667,6 +667,12 @@ config OID_REGISTRY
 	help
 	  Enable fast lookup object identifier registry.
 
+config SMBIOS_PARSER
+	bool "SMBIOS parser"
+	default n
+	help
+	  A simple parser for SMBIOS data.
+
 source lib/efi/Kconfig
 source lib/efi_loader/Kconfig
 source lib/optee/Kconfig
lib/Makefile +1 -0
index 0cd7bea282..0383fddf2c 100644
@@ -37,6 +37,7 @@ obj-$(CONFIG_FIT) += fdtdec_common.o
 obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
 obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
 obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o
+obj-$(CONFIG_SMBIOS_PARSER) += smbios-parser.o
 obj-$(CONFIG_IMAGE_SPARSE) += image-sparse.o
 obj-y += ldiv.o
 obj-$(CONFIG_XXHASH) += xxhash.o
lib/smbios-parser.c new file +96 -0

96 lines not on this page · raw message

Signature · 1 line
2.28.0
#1 lore raw

PATCH v2 1/2 smbios: add parsing API

ping and a short question: would it make more sense to put the parsing code into smbios.c and unconditionally compile it?

Am Mi., 7. Okt. 2020 um 14:33 Uhr schrieb Christian Gmeiner <[email protected]>:

Quoted 183 lines

Add an very simple API to be able to access SMBIOS strings like vendor, model and bios version.

---
 include/smbios.h    | 27 +++++++++++++
 lib/Kconfig         |  6 +++
 lib/Makefile        |  1 +
 lib/smbios-parser.c | 96 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 130 insertions(+)
 create mode 100644 lib/smbios-parser.c
include/smbios.h +27 -0
index 97b9ddce23..ed60c00fae 100644
@@ -237,4 +237,31 @@ typedef int (*smbios_write_type)(ulong *addr, int handle);
  */
 ulong write_smbios_table(ulong addr);
 
+/**
+ * smbios_entry() - Get a vaild struct smbios_entry pointer
+ *
+ * @address:   address where smbios tables is located
+ * @size:      size of smbios table
+ * @return:    NULL or a valid pointer to a struct smbios_entry
+ */
+const struct smbios_entry *smbios_entry(u64 address, u32 size);
+
+/**
+ * smbios_header() - Search for SMBIOS header type
+ *
+ * @entry:     pointer to a struct smbios_entry
+ * @type:      SMBIOS type
+ * @return:    NULL or a valid pointer to a struct smbios_header
+ */
+const struct smbios_header *smbios_header(const struct smbios_entry *entry, int type);
+
+/**
+ * smbios_string() - Return string from SMBIOS
+ *
+ * @header:    pointer to struct smbios_header
+ * @index:     string index
+ * @return:    NULL or a valid const char pointer
+ */
+const char *smbios_string(const struct smbios_header *header, int index);
+
 #endif /* _SMBIOS_H_ */
lib/Kconfig +6 -0
index 8efb154f73..c92131b7bc 100644
@@ -667,6 +667,12 @@ config OID_REGISTRY
        help
          Enable fast lookup object identifier registry.
 
+config SMBIOS_PARSER
+       bool "SMBIOS parser"
+       default n
+       help
+         A simple parser for SMBIOS data.
+
 source lib/efi/Kconfig
 source lib/efi_loader/Kconfig
 source lib/optee/Kconfig
lib/Makefile +1 -0
index 0cd7bea282..0383fddf2c 100644
@@ -37,6 +37,7 @@ obj-$(CONFIG_FIT) += fdtdec_common.o
 obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
 obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
 obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o
+obj-$(CONFIG_SMBIOS_PARSER) += smbios-parser.o
 obj-$(CONFIG_IMAGE_SPARSE) += image-sparse.o
 obj-y += ldiv.o
 obj-$(CONFIG_XXHASH) += xxhash.o
lib/smbios-parser.c new file +96 -1
new file mode 100644
index 0000000000..b89f988ef9
@@ -0,0 +1,96 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020, Bachmann electronic GmbH
+ */
+
+#include <common.h>
+#include <smbios.h>
+
+static inline int verify_checksum(const struct smbios_entry *e)
+{
+       /*
+        * Checksums for SMBIOS tables are calculated to have a value, so that
+        * the sum over all bytes yields zero (using unsigned 8 bit arithmetic).
+        */
+       u8 *byte = (u8 *)e;
+       u8 sum = 0;
+
+       for (int i = 0; i < e->length; i++)
+               sum += byte[i];
+
+       return sum;
+}
+
+const struct smbios_entry *smbios_entry(u64 address, u32 size)
+{
+       const struct smbios_entry *entry = (struct smbios_entry *)(uintptr_t)address;
+
+       if (!address | !size)
+               return NULL;
+
+       if (memcmp(entry->anchor, "_SM_", 4))
+               return NULL;
+
+       if (verify_checksum(entry))
+               return NULL;
+
+       return entry;
+}
+
+static const struct smbios_header *next_header(const struct smbios_header *curr)
+{
+       u8 *pos = ((u8 *)curr) + curr->length;
+
+       /* search for _double_ NULL bytes */
+       while (!((*pos == 0) && (*(pos + 1) == 0)))
+               pos++;
+
+       /* step behind the double NULL bytes */
+       pos += 2;
+
+       return (struct smbios_header *)pos;
+}
+
+const struct smbios_header *smbios_header(const struct smbios_entry *entry, int type)
+{
+       const unsigned int num_header = entry->struct_count;
+       const struct smbios_header *header = (struct smbios_header *)entry->struct_table_address;
+
+       for (unsigned int i = 0; i < num_header; i++) {
+               if (header->type == type)
+                       return header;
+
+               header = next_header(header);
+       }
+
+       return NULL;
+}
+
+static const char *string_from_smbios_table(const struct smbios_header *header,
+                                           int idx)
+{
+       unsigned int i = 1;
+       u8 *pos;
+
+       if (!header)
+               return NULL;
+
+       pos = ((u8 *)header) + header->length;
+
+       while (i < idx) {
+               if (*pos == 0x0)
+                       i++;
+
+               pos++;
+       }
+
+       return (const char *)pos;
+}
+
+const char *smbios_string(const struct smbios_header *header, int index)
+{
+       if (!header)
+               return NULL;
+
+       return string_from_smbios_table(header, index);
+}
--

2.28.0

Signature · 5 lines
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info/privacypolicy
#2 lore raw

PATCH v2 1/2 smbios: add parsing API

Quoted 3 lines · Christian Gmeiner

ping and a short question: would it make more sense to put the parsing code into smbios.c and unconditionally compile it?

I think it's fine to leave this as a separte module.

But nits below:

Quoted 5 lines

Am Mi., 7. Okt. 2020 um 14:33 Uhr schrieb Christian Gmeiner <[email protected]>:

Quoted 2 lines

Add an very simple API to be able to access SMBIOS strings

an -> a

Quoted 19 lines
Quoted 19 lines

like vendor, model and bios version.

---
 include/smbios.h    | 27 +++++++++++++
 lib/Kconfig         |  6 +++
 lib/Makefile        |  1 +
 lib/smbios-parser.c | 96 +++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 130 insertions(+)
 create mode 100644 lib/smbios-parser.c
include/smbios.h +0 -0
index 97b9ddce23..ed60c00fae 100644
@@ -237,4 +237,31 @@ typedef int (*smbios_write_type)(ulong *addr, int handle);
  */
 ulong write_smbios_table(ulong addr);
 
Quoted 2 lines

include/smbios.h typedef int (*smbios_write_type)(ulong *addr, int handle); · line 241

Quoted 2 lines
include/smbios.h +2 -0
+/**
+ * smbios_entry() - Get a vaild struct smbios_entry pointer

typo: valid

Quoted 34 lines
Quoted 34 lines
include/smbios.h +25 -0
+ *
+ * @address:   address where smbios tables is located
+ * @size:      size of smbios table
+ * @return:    NULL or a valid pointer to a struct smbios_entry
+ */
+const struct smbios_entry *smbios_entry(u64 address, u32 size);
+
+/**
+ * smbios_header() - Search for SMBIOS header type
+ *
+ * @entry:     pointer to a struct smbios_entry
+ * @type:      SMBIOS type
+ * @return:    NULL or a valid pointer to a struct smbios_header
+ */
+const struct smbios_header *smbios_header(const struct smbios_entry *entry, int type);
+
+/**
+ * smbios_string() - Return string from SMBIOS
+ *
+ * @header:    pointer to struct smbios_header
+ * @index:     string index
+ * @return:    NULL or a valid const char pointer
+ */
+const char *smbios_string(const struct smbios_header *header, int index);
+
 #endif /* _SMBIOS_H_ */
lib/Kconfig +0 -0
index 8efb154f73..c92131b7bc 100644
@@ -667,6 +667,12 @@ config OID_REGISTRY
        help
          Enable fast lookup object identifier registry.
 
Quoted 3 lines

lib/Kconfig config OID_REGISTRY · line 672

Quoted 3 lines
lib/Kconfig +3 -0
+config SMBIOS_PARSER
+       bool "SMBIOS parser"
+       default n

nits: remove default n, because it is Kconfig default

Quoted 114 lines
Quoted 114 lines
lib/Kconfig +3 -0
+       help
+         A simple parser for SMBIOS data.
+
 source lib/efi/Kconfig
 source lib/efi_loader/Kconfig
 source lib/optee/Kconfig
lib/Makefile +1 -0
index 0cd7bea282..0383fddf2c 100644
@@ -37,6 +37,7 @@ obj-$(CONFIG_FIT) += fdtdec_common.o
 obj-$(CONFIG_TEST_FDTDEC) += fdtdec_test.o
 obj-$(CONFIG_GZIP_COMPRESSED) += gzip.o
 obj-$(CONFIG_GENERATE_SMBIOS_TABLE) += smbios.o
+obj-$(CONFIG_SMBIOS_PARSER) += smbios-parser.o
 obj-$(CONFIG_IMAGE_SPARSE) += image-sparse.o
 obj-y += ldiv.o
 obj-$(CONFIG_XXHASH) += xxhash.o
lib/smbios-parser.c new file +90 -0
new file mode 100644
index 0000000000..b89f988ef9
@@ -0,0 +1,96 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020, Bachmann electronic GmbH
+ */
+
+#include <common.h>
+#include <smbios.h>
+
+static inline int verify_checksum(const struct smbios_entry *e)
+{
+       /*
+        * Checksums for SMBIOS tables are calculated to have a value, so that
+        * the sum over all bytes yields zero (using unsigned 8 bit arithmetic).
+        */
+       u8 *byte = (u8 *)e;
+       u8 sum = 0;
+
+       for (int i = 0; i < e->length; i++)
+               sum += byte[i];
+
+       return sum;
+}
+
+const struct smbios_entry *smbios_entry(u64 address, u32 size)
+{
+       const struct smbios_entry *entry = (struct smbios_entry *)(uintptr_t)address;
+
+       if (!address | !size)
+               return NULL;
+
+       if (memcmp(entry->anchor, "_SM_", 4))
+               return NULL;
+
+       if (verify_checksum(entry))
+               return NULL;
+
+       return entry;
+}
+
+static const struct smbios_header *next_header(const struct smbios_header *curr)
+{
+       u8 *pos = ((u8 *)curr) + curr->length;
+
+       /* search for _double_ NULL bytes */
+       while (!((*pos == 0) && (*(pos + 1) == 0)))
+               pos++;
+
+       /* step behind the double NULL bytes */
+       pos += 2;
+
+       return (struct smbios_header *)pos;
+}
+
+const struct smbios_header *smbios_header(const struct smbios_entry *entry, int type)
+{
+       const unsigned int num_header = entry->struct_count;
+       const struct smbios_header *header = (struct smbios_header *)entry->struct_table_address;
+
+       for (unsigned int i = 0; i < num_header; i++) {
+               if (header->type == type)
+                       return header;
+
+               header = next_header(header);
+       }
+
+       return NULL;
+}
+
+static const char *string_from_smbios_table(const struct smbios_header *header,
+                                           int idx)
+{
+       unsigned int i = 1;
+       u8 *pos;
+
+       if (!header)
+               return NULL;
+
+       pos = ((u8 *)header) + header->length;
+
+       while (i < idx) {
+               if (*pos == 0x0)
+                       i++;
+
+               pos++;
+       }
+
+       return (const char *)pos;
+}
+
+const char *smbios_string(const struct smbios_header *header, int index)
Quoted 8 lines
Quoted 8 lines
lib/smbios-parser.c new file +6 -1
+{
+       if (!header)
+               return NULL;
+
+       return string_from_smbios_table(header, index);
+}
--

2.28.0

Regards,
Bin

#3 lore raw

PATCH v2 2/2 coreboot: make use of smbios parser

In reply to Christian Gmeiner

If u-boot gets used as coreboot payload it might be nice to get vendor, model and bios version from smbios. I am not sure about the output of all the read information.

With qemu target for coreboot this could look this:

CBFS: Found @ offset 14f40 size 3b188
Checking segment from ROM address 0xffc15178
Checking segment from ROM address 0xffc15194
Loading segment from ROM address 0xffc15178
code (compression=1)
New segment dstaddr 0x01110000 memsize 0x889ef srcaddr 0xffc151b0 filesize 0x3b150
Loading Segment: addr: 0x01110000 memsz: 0x00000000000889ef filesz: 0x000000000003b150 using LZMA
Loading segment from ROM address 0xffc15194
Entry Point 0x01110000
BS: BS_PAYLOAD_LOAD run times (exec / console): 77 / 1 ms
Jumping to boot code at 0x01110000(0x07fa7000)

U-Boot 2020.10-00536-g5dcf7cc590-dirty (Oct 07 2020 - 14:21:51 +0200)

CPU: x86_64, vendor AMD, device 663h
DRAM: 127.1 MiB
MMC:
Video: No video mode configured in coreboot!
Video: No video mode configured in coreboot!
Vendor: QEMU
Model: Standard PC (i440FX + PIIX, 1996)
Bios Version: 4.12-3152-g326a499f6f-dirty
Net: e1000: 52:54:00:12:34:56

       eth0: e1000#0

No working controllers found
Finalizing coreboot
Hit any key to stop autoboot: 0

---
 board/coreboot/coreboot/coreboot.c | 45 ++++++++++++++++++++++++++++++
 configs/coreboot_defconfig         |  1 +
 2 files changed, 46 insertions(+)
board/coreboot/coreboot/coreboot.c +45 -0
index b791b82ef4..afb457212a 100644
@@ -4,7 +4,9 @@
  */
 
 #include <common.h>
+#include <asm/arch/sysinfo.h>
 #include <init.h>
+#include <smbios.h>
 
 int board_early_init_r(void)
 {
@@ -16,3 +18,46 @@ int board_early_init_r(void)
 
 	return 0;
 }
+
+#ifdef CONFIG_SMBIOS_PARSER
+int show_board_info(void)
+{
+	const struct smbios_entry *smbios = smbios_entry(lib_sysinfo.smbios_start, lib_sysinfo.smbios_size);
+
+	if (!smbios)
+		goto fallback;
+
+	const struct smbios_header *bios = smbios_header(smbios, SMBIOS_BIOS_INFORMATION);
+	const struct smbios_header *system = smbios_header(smbios, SMBIOS_SYSTEM_INFORMATION);
+	const struct smbios_type0 *t0 = (struct smbios_type0 *)bios;
+	const struct smbios_type1 *t1 = (struct smbios_type1 *)system;
+
+	if (!t0 || !t1)
+		goto fallback;
+
+	const char *bios_ver = smbios_string(bios, t0->bios_ver);
+	const char *model = smbios_string(system, t1->product_name);
+	const char *manufacturer = smbios_string(system, t1->manufacturer);
+
+	if (!model || !manufacturer || !bios_ver)
+		goto fallback;
+
+	printf("Vendor: %s\n", manufacturer);
+	printf("Model: %s\n", model);
+	printf("Bios Version: %s\n", bios_ver);
+
+	return 0;
+
+fallback:
+#ifdef CONFIG_OF_CONTROL
+	DECLARE_GLOBAL_DATA_PTR;
+
+	model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
+
+	if (model)
+		printf("Model: %s\n", model);
+#endif
+
+	return checkboard();
+}
+#endif
configs/coreboot_defconfig +1 -0
index 3249b2fb2f..501a20e790 100644
@@ -43,3 +43,4 @@ CONFIG_SOUND=y
 CONFIG_SOUND_I8254=y
 CONFIG_CONSOLE_SCROLL_LINES=5
 # CONFIG_GZIP is not set
+CONFIG_SMBIOS_PARSER=y
Signature · 1 line
2.28.0
#4 lore raw

PATCH v2 2/2 coreboot: make use of smbios parser

ping

Am Mi., 7. Okt. 2020 um 14:33 Uhr schrieb Christian Gmeiner <[email protected]>:

Quoted 115 lines

If u-boot gets used as coreboot payload it might be nice to get vendor, model and bios version from smbios. I am not sure about the output of all the read information.

With qemu target for coreboot this could look this:

CBFS: Found @ offset 14f40 size 3b188
Checking segment from ROM address 0xffc15178
Checking segment from ROM address 0xffc15194
Loading segment from ROM address 0xffc15178
code (compression=1)
New segment dstaddr 0x01110000 memsize 0x889ef srcaddr 0xffc151b0 filesize 0x3b150
Loading Segment: addr: 0x01110000 memsz: 0x00000000000889ef filesz: 0x000000000003b150 using LZMA
Loading segment from ROM address 0xffc15194
Entry Point 0x01110000
BS: BS_PAYLOAD_LOAD run times (exec / console): 77 / 1 ms
Jumping to boot code at 0x01110000(0x07fa7000)

U-Boot 2020.10-00536-g5dcf7cc590-dirty (Oct 07 2020 - 14:21:51 +0200)

CPU: x86_64, vendor AMD, device 663h
DRAM: 127.1 MiB
MMC:
Video: No video mode configured in coreboot!
Video: No video mode configured in coreboot!
Vendor: QEMU
Model: Standard PC (i440FX + PIIX, 1996)
Bios Version: 4.12-3152-g326a499f6f-dirty
Net: e1000: 52:54:00:12:34:56

       eth0: e1000#0

No working controllers found
Finalizing coreboot
Hit any key to stop autoboot: 0

---
 board/coreboot/coreboot/coreboot.c | 45 ++++++++++++++++++++++++++++++
 configs/coreboot_defconfig         |  1 +
 2 files changed, 46 insertions(+)
board/coreboot/coreboot/coreboot.c +45 -0
index b791b82ef4..afb457212a 100644
@@ -4,7 +4,9 @@
  */
 
 #include <common.h>
+#include <asm/arch/sysinfo.h>
 #include <init.h>
+#include <smbios.h>
 
 int board_early_init_r(void)
 {
@@ -16,3 +18,46 @@ int board_early_init_r(void)
 
        return 0;
 }
+
+#ifdef CONFIG_SMBIOS_PARSER
+int show_board_info(void)
+{
+       const struct smbios_entry *smbios = smbios_entry(lib_sysinfo.smbios_start, lib_sysinfo.smbios_size);
+
+       if (!smbios)
+               goto fallback;
+
+       const struct smbios_header *bios = smbios_header(smbios, SMBIOS_BIOS_INFORMATION);
+       const struct smbios_header *system = smbios_header(smbios, SMBIOS_SYSTEM_INFORMATION);
+       const struct smbios_type0 *t0 = (struct smbios_type0 *)bios;
+       const struct smbios_type1 *t1 = (struct smbios_type1 *)system;
+
+       if (!t0 || !t1)
+               goto fallback;
+
+       const char *bios_ver = smbios_string(bios, t0->bios_ver);
+       const char *model = smbios_string(system, t1->product_name);
+       const char *manufacturer = smbios_string(system, t1->manufacturer);
+
+       if (!model || !manufacturer || !bios_ver)
+               goto fallback;
+
+       printf("Vendor: %s\n", manufacturer);
+       printf("Model: %s\n", model);
+       printf("Bios Version: %s\n", bios_ver);
+
+       return 0;
+
+fallback:
+#ifdef CONFIG_OF_CONTROL
+       DECLARE_GLOBAL_DATA_PTR;
+
+       model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
+
+       if (model)
+               printf("Model: %s\n", model);
+#endif
+
+       return checkboard();
+}
+#endif
configs/coreboot_defconfig +1 -1
index 3249b2fb2f..501a20e790 100644
@@ -43,3 +43,4 @@ CONFIG_SOUND=y
 CONFIG_SOUND_I8254=y
 CONFIG_CONSOLE_SCROLL_LINES=5
 # CONFIG_GZIP is not set
+CONFIG_SMBIOS_PARSER=y
--

2.28.0

Signature · 5 lines
greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info/privacypolicy
#5 lore raw

PATCH v2 2/2 coreboot: make use of smbios parser

In reply to Christian Gmeiner
Quoted 77 lines · Christian Gmeiner

If u-boot gets used as coreboot payload it might be nice to get vendor, model and bios version from smbios. I am not sure about the output of all the read information.

With qemu target for coreboot this could look this:

CBFS: Found @ offset 14f40 size 3b188
Checking segment from ROM address 0xffc15178
Checking segment from ROM address 0xffc15194
Loading segment from ROM address 0xffc15178
code (compression=1)
New segment dstaddr 0x01110000 memsize 0x889ef srcaddr 0xffc151b0 filesize 0x3b150
Loading Segment: addr: 0x01110000 memsz: 0x00000000000889ef filesz: 0x000000000003b150 using LZMA
Loading segment from ROM address 0xffc15194
Entry Point 0x01110000
BS: BS_PAYLOAD_LOAD run times (exec / console): 77 / 1 ms
Jumping to boot code at 0x01110000(0x07fa7000)

U-Boot 2020.10-00536-g5dcf7cc590-dirty (Oct 07 2020 - 14:21:51 +0200)

CPU: x86_64, vendor AMD, device 663h
DRAM: 127.1 MiB
MMC:
Video: No video mode configured in coreboot!
Video: No video mode configured in coreboot!
Vendor: QEMU
Model: Standard PC (i440FX + PIIX, 1996)
Bios Version: 4.12-3152-g326a499f6f-dirty
Net: e1000: 52:54:00:12:34:56

       eth0: e1000#0

No working controllers found
Finalizing coreboot
Hit any key to stop autoboot: 0

---
 board/coreboot/coreboot/coreboot.c | 45 ++++++++++++++++++++++++++++++
 configs/coreboot_defconfig         |  1 +
 2 files changed, 46 insertions(+)
board/coreboot/coreboot/coreboot.c +19 -0
index b791b82ef4..afb457212a 100644
@@ -4,7 +4,9 @@
  */
 
 #include <common.h>
+#include <asm/arch/sysinfo.h>
 #include <init.h>
+#include <smbios.h>
 
 int board_early_init_r(void)
 {
@@ -16,3 +18,46 @@ int board_early_init_r(void)
 
        return 0;
 }
+
+#ifdef CONFIG_SMBIOS_PARSER
+int show_board_info(void)
+{
+       const struct smbios_entry *smbios = smbios_entry(lib_sysinfo.smbios_start, lib_sysinfo.smbios_size);
+
+       if (!smbios)
+               goto fallback;
+
+       const struct smbios_header *bios = smbios_header(smbios, SMBIOS_BIOS_INFORMATION);
+       const struct smbios_header *system = smbios_header(smbios, SMBIOS_SYSTEM_INFORMATION);
+       const struct smbios_type0 *t0 = (struct smbios_type0 *)bios;
+       const struct smbios_type1 *t1 = (struct smbios_type1 *)system;
+
+       if (!t0 || !t1)
+               goto fallback;
+

board/coreboot/coreboot/coreboot.c int board_early_init_r(void) · line 47

Quoted 10 lines
board/coreboot/coreboot/coreboot.c +10 -0
+       const char *bios_ver = smbios_string(bios, t0->bios_ver);
+       const char *model = smbios_string(system, t1->product_name);
+       const char *manufacturer = smbios_string(system, t1->manufacturer);
+
+       if (!model || !manufacturer || !bios_ver)
+               goto fallback;
+
+       printf("Vendor: %s\n", manufacturer);
+       printf("Model: %s\n", model);
+       printf("Bios Version: %s\n", bios_ver);

nits: Bios -> BIOS

Quoted 21 lines
board/coreboot/coreboot/coreboot.c +16 -0
+
+       return 0;
+
+fallback:
+#ifdef CONFIG_OF_CONTROL
+       DECLARE_GLOBAL_DATA_PTR;
+
+       model = fdt_getprop(gd->fdt_blob, 0, "model", NULL);
+
+       if (model)
+               printf("Model: %s\n", model);
+#endif
+
+       return checkboard();
+}
+#endif
configs/coreboot_defconfig +0 -0
index 3249b2fb2f..501a20e790 100644

configs/coreboot_defconfig CONFIG_SOUND=y · line 46

Quoted 4 lines
configs/coreboot_defconfig +1 -0
@@ -43,3 +43,4 @@ CONFIG_SOUND=y
 CONFIG_SOUND_I8254=y
 CONFIG_CONSOLE_SCROLL_LINES=5
 # CONFIG_GZIP is not set
+CONFIG_SMBIOS_PARSER=y

Please make sure the Kconfig option is inserted in a correct order

Otherwise:

Regards,
Bin