Commit Graph

17 Commits

Author SHA1 Message Date
Simon Glass
4e842608d6 smbios: Update smbios_get_header() to return a void *
Since each table starts with a header, it isn't very useful to have a
separate pointer for the (generic) header and another for the whole
table. Also, casting is a bit of a pain.

Update smbios_get_header() so that it returns a const void * so that it
is possible to directly assign it to the appropriate SMBIOS table's
pointer.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-04 07:08:24 -06:00
Simon Glass
deb404a6be smbios: Correct logic in smbios_get_header()
This function skips over every second table. Fix it by dropping the
extra iterator update.

Signed-off-by: Simon Glass <sjg@chromium.org>
Fixes: a68c0625aa ("smbios: coreboot: Update smbios_get_header() to..")
2025-09-04 07:08:24 -06:00
Simon Glass
a68c0625aa smbios: coreboot: Update smbios_get_header() to use smbios_info
Use the smbios_info struct in this function, so it can deal with any
version of SMBIOS table.

Also update smbios_update_version_full() to work the same way.

Drop find_next_header() which is now unused.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-18 14:00:19 -06:00
Simon Glass
8de843271f smbios: Pass smbios_info to smbios_next_table()
At present smbios_next_table() does not support SMBIOS v2 tables. Pass
in the info struct so that it can check for the end of the tables.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-18 14:00:19 -06:00
Simon Glass
40453163c8 smbios: Create a function to locate the tables
The code in the smbios command is a nice implementation of finding the
tables. It supports both SMBIOS2 and SMBIOS3, which smbios-parser.c does
not.

Move this code over to the library, creating a struct to hold the
result.

Series-changes: 2
- Fix the return values on error

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-18 14:00:17 -06:00
Simon Glass
0ee25282d8 smbios: Move some parsing code to smbios-parser.c
The 'smbios' command has some parsing code, as does the SMBIOS parser
in the lib/ directory. Start to unify these by moving over a few
functions.

Require CONFIG_SMBIOS_PARSER to be enabled when using the command.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-18 13:56:05 -06:00
Simon Glass
843c10a93e smbios: Rename smbios_header()
This function has the same name as the struct, which is confusing.
Rename it to smbios_get_header() and update the function comment a
little.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-08-18 13:56:05 -06:00
Heinrich Schuchardt
406c410ef7 smbios: correctly name Structure Table Maximum Size field
In the SMBIOS 3 entry point the Structure Table Maximum Size field was
incorrectly named max_struct_size. A Maximum Structure Size field only
exists in the SMBIOS 2.1 entry point and has a different meaning.

Call the Structure Table Length field table_maximum_size.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-02-02 19:57:45 +01:00
Heinrich Schuchardt
85e490b22e lib: smbios_entr() use logical or for booleans
As a matter of programming style use logical or to combine two boolean
results.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-02-02 19:55:29 +01:00
Masahisa Kojima
2497f6a84c efi_loader: migrate SMBIOS 3.0 entry point structure for measurement
Current U-Boot only supports the SMBIOS 3.0 entry point structure.
TCG2 measurement code should migrate to SMBIOS 3.0 entry
point structure.

efi_selftest tcg2 test also needs to be updated, and expected
PCR[1] result is changed since guid for SMBIOS EFI system table
uses different guid SMBIOS3_TABLE_GUID instead of SMBIOS_TABLE_GUID.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-26 14:16:17 +01:00
Heinrich Schuchardt
ddcfb9ede8 lib: smbios: remove redundant next_header()
next_header() and get_next_header() only differ in how the const attribute
is used. One function taking a const parameter and returning a non-const is
good enough.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-16 17:05:29 -05:00
Heinrich Schuchardt
efe441a0a3 smbios: smbios.h should not import ofnode.h
The smbios.h include does not use any definitions from ofnode.h.
So don't include it.

As DECLARE_GLOBAL_DATA_PTR is no longer defined via dm/of.h we need to
add it to efi_smbios.c.

Add now missing includes to smbios-parser.c.

Remove a superfluous check comparing the sizes of the SMBIOS 2.1 and SMBIOS
3.0 anchors.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2024-01-09 10:09:15 +01:00
Heinrich Schuchardt
dc2fe5d84e lib: smbios: verify_checksum() is duplicate
The function verify_checksum() duplicates what table_compute_checksum()
does. Replace it. table_compute_checksum() is always compiled.

Fixes: 415eab0655 ("smbios: add parsing API")
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-01-09 10:09:09 +01:00
Tom Rini
467382ca03 lib: Remove <common.h> inclusion from these files
After some header file cleanups to add missing include files, remove
common.h from all files in the lib directory. This primarily means just
dropping the line but in a few cases we need to add in other header
files now.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
2023-12-21 08:54:37 -05:00
Masahisa Kojima
3d49ee8510 efi_loader: add SMBIOS table measurement
TCG PC Client Platform Firmware Profile Specification
requires to measure the SMBIOS table that contains static
configuration information (e.g. Platform Manufacturer
Enterprise Number assigned by IANA, platform model number,
Vendor and Device IDs for each SMBIOS table).

The device- and environment-dependent information such as
serial number is cleared to zero or space character for
the measurement.

Existing smbios_string() function returns pointer to the string
with const qualifier, but exisintg use case is updating version
string and const qualifier must be removed.
This commit removes const qualifier from smbios_string()
return value and reuses to clear the strings for the measurement.

This commit also fixes the following compiler warning:

lib/smbios-parser.c:59:39: warning: cast to pointer from integer of
different size [-Wint-to-pointer-cast]
  const struct smbios_header *header = (struct smbios_header *)entry->struct_table_address;

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
2021-10-26 17:58:14 +02:00
Simon Glass
272e62cb83 smbios: Allow writing to the coreboot version string
When U-Boot is booted from coreboot the SMBIOS tables are written by
coreboot, not U-Boot. The existing method of updating the BIOS version
string does not work in that case, since gd->smbios_version is only set
when U-Boot writes the tables.

Add a new function which allows the version to be updated by parsing the
tables and writing the string in the correct place. Since coreboot
provides a pointer to the SMBIOS tables in its sysinfo structure, this
makes it easy to do the update.

Signed-off-by: Simon Glass <sjg@chromium.org>
2021-03-27 13:59:37 +13:00
Christian Gmeiner
415eab0655 smbios: add parsing API
Add a very simple API to be able to access SMBIOS strings
like vendor, model and bios version.

Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
2020-11-05 14:58:45 +08:00