chid: Provide a command to access chid features

Provide a simple command which supports showing the information which
goes into calculating a CHID. The information is obtained entirely from
SMBIOS tables at present.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2025-08-31 14:22:46 -06:00
parent 99b1335957
commit 93f35ef78a
7 changed files with 168 additions and 0 deletions

View File

@@ -280,6 +280,16 @@ config CMD_SMBIOS
help
Display the SMBIOS information.
config CMD_CHID
bool "chid"
depends on CHID
default y
help
Computer Hardware ID (CHID) utilities. This provides commands to
extract hardware identification data from SMBIOS tables according
to the Microsoft CHID specification. This is used by Windows Update
and fwupd for hardware identification and firmware updates.
endmenu
menu "Boot commands"

View File

@@ -46,6 +46,7 @@ obj-$(CONFIG_CMD_CAT) += cat.o
obj-$(CONFIG_CMD_CACHE) += cache.o
obj-$(CONFIG_CMD_CBFS) += cbfs.o
obj-$(CONFIG_CMD_CEDIT) += cedit.o
obj-$(CONFIG_CMD_CHID) += chid.o
obj-$(CONFIG_CMD_CLK) += clk.o
obj-$(CONFIG_CMD_CLS) += cls.o
obj-$(CONFIG_CMD_CONFIG) += config.o

43
cmd/chid.c Normal file
View File

@@ -0,0 +1,43 @@
// SPDX-License-Identifier: GPL-2.0+
/*
* Command for Computer Hardware Identifiers (Windows CHID)
*
* Copyright 2025 Simon Glass <sjg@chromium.org>
*/
#include <chid.h>
#include <command.h>
#include <vsprintf.h>
static int do_chid_show(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
struct chid_data chid;
int ret;
ret = chid_from_smbios(&chid);
if (ret) {
printf("Failed to get CHID data from SMBIOS (err=%dE)\n", ret);
return CMD_RET_FAILURE;
}
printf("Manufacturer: %s\n", chid.manuf);
printf("Family: %s\n", chid.family);
printf("Product Name: %s\n", chid.product_name);
printf("Product SKU: %s\n", chid.product_sku);
printf("Baseboard Manuf: %s\n", chid.board_manuf);
printf("Baseboard Product: %s\n", chid.board_product);
printf("BIOS Vendor: %s\n", chid.bios_vendor);
printf("BIOS Version: %s\n", chid.bios_version);
printf("BIOS Major: %u\n", chid.bios_major);
printf("BIOS Minor: %u\n", chid.bios_minor);
printf("Enclosure Type: %u\n", chid.enclosure_type);
return 0;
}
U_BOOT_LONGHELP(chid,
"show - Show CHID data extracted from SMBIOS");
U_BOOT_CMD_WITH_SUBCMDS(chid, "Computer Hardware ID utilities", chid_help_text,
U_BOOT_SUBCMD_MKENT(show, 1, 1, do_chid_show));