Commit Graph

14 Commits

Author SHA1 Message Date
Simon Glass
b6d164bceb smbios: Provide a sandbox test
Create a sandbox test for the smbios command. This checks that the
expected output is produced.

Drop the unnecessary 0x before each address, since U-Boot uses hex by
default.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
2025-09-04 07:08:24 -06:00
Simon Glass
12f3fc10fd smbios: Add support for showing table types 16 and 19
In some cases it is useful to find out the location of physical memory,
e.g. so that the memory@ nodes can be correctly set up in the
devicetree. Add support for parsing this information from the SMBIOS
tables.

Series-to: concept
Series-cc: heinrich
Series-version: 2
Cover-letter:
smbios: Refactor the smbios command and parser
The 'smbios' command has its own code for parsing SMBIOS tables. There
in also lib/smbios-parser.c which parses tables, although only
version 2.

This series moved parsing to lib/ and rationalises the code a little. It
also adds support for a few more tables.

Finally, a hook is added so operation from coreboot can be tested on
ellesmere.
END

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
Raymond Mao
95a5d2ac37 cmd: update smbios cmd
Update the cmd according to the changes of the smbios library:
1. Refactor smbios cmd print functions to match the content defined
   by the specification.
2. Add new print functions for Type 3, 4 and 7.
3. Remove the fallback string "Not specified" from smbios_get_string,
   as the spec requires a NULL output for those undefined strings.
4. Update the test_cmd_smbios_sandbox pytest expected result to
   align with the smbios library changes and add new pytest
   test_cmd_smbios_sysinfo_verbose to test the verbose smbios
   output.

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
2025-05-16 14:45:23 +02:00
Raymond Mao
777ff6f0a7 smbios: Refactor the smbios headfile
Move the smbios field definitions to a separated simple headfile,
which is a prerequisite to be included by dts files.
Add new definitions for cache information.
This patch also includes a few of code optimizations in smbios.

Signed-off-by: Raymond Mao <raymond.mao@linaro.org>
Acked-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
2025-05-16 14:01:09 +02:00
Heinrich Schuchardt
23109d0575 cmd: smbios: type 1 wake-up time, family
Correct type 1 output

* render wake up time as string
* print family string
* remove duplicate serial number output

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-03-27 09:22:49 +01: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
551bc96be5 cmd: smbios: show correct table size for SMBIOS2.1 entry point
The SMBIOS table size for SMBIOS2.1 entry points is in field 'Structure
Table Length' (offset 0x16) and not in field 'Maximum Structure Size'
(offset 0x08).

Rename the receiving variable max_struct_size to table_maximum_size
to avoid future confusion.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-02-02 19:57:45 +01:00
Heinrich Schuchardt
c11f176ab1 cmd: smbios: replace missing string by 'Not Specified'
A missing string value is indicated by a string index of 0. In this case
print 'Not Specified' like the Linux dmidecode command does.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-02-02 19:56:54 +01:00
Heinrich Schuchardt
e799f8a48d cmd: smbios: add missing colon after UUID
For consistent formatting add a colon ':' after the UUID label.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
2024-02-02 19:56:34 +01:00
Heinrich Schuchardt
7ca4b0ea6a cmd: smbios: always use '0x%04x' for printing handles
Handles are u16 numbers. Consistently use '0x%04x' to print them.

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
2024-02-02 19:55:29 +01:00
Heinrich Schuchardt
9de4ec81c9 cmd: provide command to display SMBIOS information
U-Boot can either generated an SMBIOS table or copy it from a prior boot
stage, e.g. QEMU.

Provide a command to display the SMBIOS information.

Currently only type 1 and 2 are translated to human readable text.
Other types may be added later. Currently only a hexdump and the list of
strings is provided for these.

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-26 14:15:08 +01:00