summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTom Rini <[email protected]>2025-01-14 14:29:49 -0600
committerTom Rini <[email protected]>2025-01-14 14:29:49 -0600
commit079214e4beea2deac88f3ceaeda56b6914190aec (patch)
treee668614c5186bea838fd4dea79d9d4744effc14f /include
parente17be5a07ad6947c13c39936be812a65e694ecee (diff)
parent0af16b35561f09e529f3ced1b1f738858ec462fb (diff)
Merge patch series "SMBIOS improvements"
Raymond Mao <[email protected]> says: Motivations for changes: Current SMBIOS library and command-line tool is not fully matching with the requirements: 1. Missing support for other mandatory types (#7, #9, #16, #17, #19). 2. Only a few platforms support SMBIOS node from the device tree. 3. Values of some fields are hardcoded in the library other than fetching from the device hardware. 4. Embedded data with dynamic length is not supported (E.g. Contained Object Handles in Type #2 and Contained Elements in Type #3) Changes: 1. Refactor the SMBIOS library and command-line tool to better align with the SMBIOS spec. 2. Create an arch-specific driver for all aarch64-based platforms to fetch SMBIOS private data from the device hardware (processor and cache). 3. Create a sysinfo driver to poppulate platform SMBIOS private data. 4. Add generic SMBIOS DTS file for arm64 platforms for those common strings and values which cannot be retrieved from the system registers. Vendors can create their own SMBIOS node using this as an example. For those boards without SMBIOS nodes, this DTS file can be included to have a generic SMBIOS information of the system. 5. Add support for Type #7 (Cache Information) and link its handles to Type #4. 6. To minimize size-growth for those platforms which have not sufficient ROM spaces or the platforms which don't need detailed SMBIOS information, new added fields are only being built when kconfig GENERATE_SMBIOS_TABLE_VERBOSE is selected. Once this patch is acceptted, subsequent patch sets will add other missing types (#9, #16, #17, #19). Tests: To test this with QEMU arm64, please follow the guide on dt_qemu.rst to get a merged DT to run with. ``` qemu-system-aarch64 -machine virt -machine dumpdtb=qemu.dtb cat <(dtc -I dtb qemu.dtb) <(dtc -I dtb ./dts/dt.dtb | grep -v /dts-v1/) \ | dtc - -o merged.dtb qemu-system-aarch64 -machine virt -nographic -bios u-boot.bin \ -dtb merged.dtb ``` Link: https://lore.kernel.org/r/[email protected]
Diffstat (limited to 'include')
-rw-r--r--include/smbios.h158
-rw-r--r--include/smbios_def.h194
-rw-r--r--include/smbios_plat.h79
-rw-r--r--include/sysinfo.h125
4 files changed, 487 insertions, 69 deletions
diff --git a/include/smbios.h b/include/smbios.h
index 00119d7a60c..b5fed57aba2 100644
--- a/include/smbios.h
+++ b/include/smbios.h
@@ -9,6 +9,7 @@
#define _SMBIOS_H_
#include <linux/types.h>
+#include <smbios_def.h>
/* SMBIOS spec version implemented */
#define SMBIOS_MAJOR_VER 3
@@ -37,6 +38,11 @@ enum {
#define SMBIOS_INTERMEDIATE_OFFSET 16
#define SMBIOS_STRUCT_EOS_BYTES 2
+struct str_lookup_table {
+ u16 idx;
+ const char *str;
+};
+
struct __packed smbios_entry {
u8 anchor[4];
u8 checksum;
@@ -80,19 +86,14 @@ struct __packed smbios3_entry {
u64 struct_table_address;
};
-/* BIOS characteristics */
-#define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
-#define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11)
-#define BIOS_CHARACTERISTICS_SELECTABLE_BOOT (1 << 16)
-
-#define BIOS_CHARACTERISTICS_EXT1_ACPI (1 << 0)
-#define BIOS_CHARACTERISTICS_EXT2_UEFI (1 << 3)
-#define BIOS_CHARACTERISTICS_EXT2_TARGET (1 << 2)
-
-struct __packed smbios_type0 {
+struct __packed smbios_header {
u8 type;
u8 length;
u16 handle;
+};
+
+struct __packed smbios_type0 {
+ struct smbios_header hdr;
u8 vendor;
u8 bios_ver;
u16 bios_start_segment;
@@ -109,37 +110,12 @@ struct __packed smbios_type0 {
char eos[SMBIOS_STRUCT_EOS_BYTES];
};
-/**
- * enum smbios_wakeup_type - wake-up type
- *
- * These constants are used for the Wake-Up Type field in the SMBIOS
- * System Information (Type 1) structure.
- */
-enum smbios_wakeup_type {
- /** @SMBIOS_WAKEUP_TYPE_RESERVED: Reserved */
- SMBIOS_WAKEUP_TYPE_RESERVED,
- /** @SMBIOS_WAKEUP_TYPE_OTHER: Other */
- SMBIOS_WAKEUP_TYPE_OTHER,
- /** @SMBIOS_WAKEUP_TYPE_UNKNOWN: Unknown */
- SMBIOS_WAKEUP_TYPE_UNKNOWN,
- /** @SMBIOS_WAKEUP_TYPE_APM_TIMER: APM Timer */
- SMBIOS_WAKEUP_TYPE_APM_TIMER,
- /** @SMBIOS_WAKEUP_TYPE_MODEM_RING: Modem Ring */
- SMBIOS_WAKEUP_TYPE_MODEM_RING,
- /** @SMBIOS_WAKEUP_TYPE_LAN_REMOTE: LAN Remote */
- SMBIOS_WAKEUP_TYPE_LAN_REMOTE,
- /** @SMBIOS_WAKEUP_TYPE_POWER_SWITCH: Power Switch */
- SMBIOS_WAKEUP_TYPE_POWER_SWITCH,
- /** @SMBIOS_WAKEUP_TYPE_PCI_PME: PCI PME# */
- SMBIOS_WAKEUP_TYPE_PCI_PME,
- /** @SMBIOS_WAKEUP_TYPE_AC_POWER_RESTORED: AC Power Restored */
- SMBIOS_WAKEUP_TYPE_AC_POWER_RESTORED,
-};
+#define SMBIOS_TYPE1_LENGTH_V20 0x08
+#define SMBIOS_TYPE1_LENGTH_V21 0x19
+#define SMBIOS_TYPE1_LENGTH_V24 0x1b
struct __packed smbios_type1 {
- u8 type;
- u8 length;
- u16 handle;
+ struct smbios_header hdr;
u8 manufacturer;
u8 product_name;
u8 version;
@@ -151,13 +127,10 @@ struct __packed smbios_type1 {
char eos[SMBIOS_STRUCT_EOS_BYTES];
};
-#define SMBIOS_BOARD_FEATURE_HOSTING (1 << 0)
-#define SMBIOS_BOARD_MOTHERBOARD 10
+#define SMBIOS_TYPE2_CON_OBJ_HANDLE_SIZE sizeof(u16)
struct __packed smbios_type2 {
- u8 type;
- u8 length;
- u16 handle;
+ struct smbios_header hdr;
u8 manufacturer;
u8 product_name;
u8 version;
@@ -168,17 +141,15 @@ struct __packed smbios_type2 {
u16 chassis_handle;
u8 board_type;
u8 number_contained_objects;
+ /*
+ * Dynamic bytes will be inserted here to store the objects.
+ * length is equal to 'number_contained_objects'.
+ */
char eos[SMBIOS_STRUCT_EOS_BYTES];
};
-#define SMBIOS_ENCLOSURE_DESKTOP 3
-#define SMBIOS_STATE_SAFE 3
-#define SMBIOS_SECURITY_NONE 3
-
struct __packed smbios_type3 {
- u8 type;
- u8 length;
- u16 handle;
+ struct smbios_header hdr;
u8 manufacturer;
u8 chassis_type;
u8 version;
@@ -193,21 +164,17 @@ struct __packed smbios_type3 {
u8 number_of_power_cords;
u8 element_count;
u8 element_record_length;
+ /*
+ * Dynamic bytes will be inserted here to store the elements.
+ * length is equal to 'element_record_length' * 'element_record_length'
+ */
+ u8 sku_number;
char eos[SMBIOS_STRUCT_EOS_BYTES];
};
-#define SMBIOS_PROCESSOR_TYPE_CENTRAL 3
-#define SMBIOS_PROCESSOR_STATUS_ENABLED 1
-#define SMBIOS_PROCESSOR_UPGRADE_NONE 6
-
-#define SMBIOS_PROCESSOR_FAMILY_OTHER 1
-#define SMBIOS_PROCESSOR_FAMILY_UNKNOWN 2
-
struct __packed smbios_type4 {
- u8 type;
- u8 length;
- u16 handle;
- u8 socket_designation;
+ struct smbios_header hdr;
+ u8 socket_design;
u8 processor_type;
u8 processor_family;
u8 processor_manufacturer;
@@ -233,6 +200,67 @@ struct __packed smbios_type4 {
u16 core_count2;
u16 core_enabled2;
u16 thread_count2;
+ u16 thread_enabled;
+ char eos[SMBIOS_STRUCT_EOS_BYTES];
+};
+
+union cache_config {
+ struct {
+ u16 level:3;
+ u16 bsocketed:1;
+ u16 rsvd0:1;
+ u16 locate:2;
+ u16 benabled:1;
+ u16 opmode:2;
+ u16 rsvd1:6;
+ } fields;
+ u16 data;
+};
+
+union cache_size_word {
+ struct {
+ u16 size:15;
+ u16 granu:1;
+ } fields;
+ u16 data;
+};
+
+union cache_size_dword {
+ struct {
+ u32 size:31;
+ u32 granu:1;
+ } fields;
+ u32 data;
+};
+
+union cache_sram_type {
+ struct {
+ u16 other:1;
+ u16 unknown:1;
+ u16 nonburst:1;
+ u16 burst:1;
+ u16 plburst:1;
+ u16 sync:1;
+ u16 async:1;
+ u16 rsvd:9;
+ } fields;
+ u16 data;
+};
+
+struct __packed smbios_type7 {
+ struct smbios_header hdr;
+ u8 socket_design;
+ union cache_config config;
+ union cache_size_word max_size;
+ union cache_size_word inst_size;
+ union cache_sram_type supp_sram_type;
+ union cache_sram_type curr_sram_type;
+ u8 speed;
+ u8 err_corr_type;
+ u8 sys_cache_type;
+ u8 associativity;
+ union cache_size_dword max_size2;
+ union cache_size_dword inst_size2;
char eos[SMBIOS_STRUCT_EOS_BYTES];
};
@@ -252,12 +280,6 @@ struct __packed smbios_type127 {
char eos[SMBIOS_STRUCT_EOS_BYTES];
};
-struct __packed smbios_header {
- u8 type;
- u8 length;
- u16 handle;
-};
-
/**
* fill_smbios_header() - Fill the header of an SMBIOS table
*
diff --git a/include/smbios_def.h b/include/smbios_def.h
new file mode 100644
index 00000000000..81c5781217f
--- /dev/null
+++ b/include/smbios_def.h
@@ -0,0 +1,194 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2024 Linaro Limited
+ * Author: Raymond Mao <[email protected]>
+ */
+
+#ifndef _SMBIOS_DEF_H_
+#define _SMBIOS_DEF_H_
+
+/*
+ * BIOS characteristics
+ */
+
+#define BIOS_CHARACTERISTICS_PCI_SUPPORTED 0x80 /* BIT(7) */
+#define BIOS_CHARACTERISTICS_UPGRADEABLE 0x800 /* BIT(11) */
+#define BIOS_CHARACTERISTICS_SELECTABLE_BOOT 0x10000 /* BIT(16) */
+
+#define BIOS_CHARACTERISTICS_EXT1_ACPI 1 /* BIT(0) */
+#define BIOS_CHARACTERISTICS_EXT2_UEFI 8 /* BIT(3) */
+#define BIOS_CHARACTERISTICS_EXT2_TARGET 4 /* BIT(2) */
+
+/*
+ * System Information
+ */
+
+#define SMBIOS_WAKEUP_TYPE_RESERVED 0
+#define SMBIOS_WAKEUP_TYPE_OTHER 1
+#define SMBIOS_WAKEUP_TYPE_UNKNOWN 2
+#define SMBIOS_WAKEUP_TYPE_APM_TIMER 3
+#define SMBIOS_WAKEUP_TYPE_MODEM_RING 4
+#define SMBIOS_WAKEUP_TYPE_LAN_REMOTE 5
+#define SMBIOS_WAKEUP_TYPE_POWER_SWITCH 6
+#define SMBIOS_WAKEUP_TYPE_PCI_PME 7
+#define SMBIOS_WAKEUP_TYPE_AC_POWER_RESTORED 8
+
+/*
+ * Baseboard Information
+ */
+
+#define SMBIOS_BOARD_FEAT_HOST_BOARD 1 /* BIT(0) */
+#define SMBIOS_BOARD_FEAT_REQ_AUX 2 /* BIT(1) */
+#define SMBIOS_BOARD_FEAT_REMOVABLE 4 /* BIT(2) */
+#define SMBIOS_BOARD_FEAT_REPLACEABLE 8 /* BIT(3) */
+#define SMBIOS_BOARD_FEAT_HOT_SWAPPABLE 16 /* BIT(4) */
+
+#define SMBIOS_BOARD_TYPE_UNKNOWN 1
+#define SMBIOS_BOARD_TYPE_OTHER 2
+#define SMBIOS_BOARD_TYPE_SERVER_BLADE 3
+#define SMBIOS_BOARD_TYPE_CON_SWITCH 4
+#define SMBIOS_BOARD_TYPE_SM_MODULE 5
+#define SMBIOS_BOARD_TYPE_PROCESSOR_MODULE 6
+#define SMBIOS_BOARD_TYPE_IO_MODULE 7
+#define SMBIOS_BOARD_TYPE_MEM_MODULE 8
+#define SMBIOS_BOARD_TYPE_DAUGHTER_BOARD 9
+#define SMBIOS_BOARD_TYPE_MOTHERBOARD 10
+#define SMBIOS_BOARD_TYPE_PROC_MEM_MODULE 11
+#define SMBIOS_BOARD_TYPE_PROC_IO_MODULE 12
+#define SMBIOS_BOARD_TYPE_INTERCON 13
+
+/*
+ * System Enclosure or Chassis
+ */
+#define SMBIOS_ENCLOSURE_UNKNOWN 2
+#define SMBIOS_ENCLOSURE_DESKTOP 3
+
+#define SMBIOS_STATE_OTHER 1
+#define SMBIOS_STATE_UNKNOWN 2
+#define SMBIOS_STATE_SAFE 3
+#define SMBIOS_STATE_WARNING 4
+#define SMBIOS_STATE_CRITICAL 5
+#define SMBIOS_STATE_NONRECOVERABLE 6
+
+#define SMBIOS_SECURITY_OTHER 1
+#define SMBIOS_SECURITY_UNKNOWN 2
+#define SMBIOS_SECURITY_NONE 3
+#define SMBIOS_SECURITY_EXTINT_LOCK 4
+#define SMBIOS_SECURITY_EXTINT_EN 5
+
+#define SMBIOS_ENCLOSURE_OEM_UND 0
+#define SMBIOS_ENCLOSURE_HEIGHT_UND 0
+#define SMBIOS_POWCORD_NUM_UND 0
+#define SMBIOS_ELEMENT_TYPE_SELECT 0x80 /* BIT(7) */
+
+/*
+ * Processor Information
+ */
+
+#define SMBIOS_PROCESSOR_TYPE_OTHER 1
+#define SMBIOS_PROCESSOR_TYPE_UNKNOWN 2
+#define SMBIOS_PROCESSOR_TYPE_CENTRAL 3
+#define SMBIOS_PROCESSOR_TYPE_MATH 4
+#define SMBIOS_PROCESSOR_TYPE_DSP 5
+#define SMBIOS_PROCESSOR_TYPE_VIDEO 6
+
+#define SMBIOS_PROCESSOR_STATUS_UNKNOWN 0
+#define SMBIOS_PROCESSOR_STATUS_ENABLED 1
+#define SMBIOS_PROCESSOR_STATUS_DISABLED_USER 2
+#define SMBIOS_PROCESSOR_STATUS_DISABLED_BIOS 3
+#define SMBIOS_PROCESSOR_STATUS_IDLE 4
+#define SMBIOS_PROCESSOR_STATUS_OTHER 7
+
+#define SMBIOS_PROCESSOR_UPGRADE_OTHER 1
+#define SMBIOS_PROCESSOR_UPGRADE_UNKNOWN 2
+#define SMBIOS_PROCESSOR_UPGRADE_NONE 6
+
+#define SMBIOS_PROCESSOR_FAMILY_OTHER 1
+#define SMBIOS_PROCESSOR_FAMILY_UNKNOWN 2
+#define SMBIOS_PROCESSOR_FAMILY_RSVD 255
+#define SMBIOS_PROCESSOR_FAMILY_ARMV7 256
+#define SMBIOS_PROCESSOR_FAMILY_ARMV8 257
+#define SMBIOS_PROCESSOR_FAMILY_RV32 512
+#define SMBIOS_PROCESSOR_FAMILY_RV64 513
+
+#define SMBIOS_PROCESSOR_FAMILY_EXT 0xfe
+
+/* Processor Characteristics */
+#define SMBIOS_PROCESSOR_RSVD 1 /* BIT(0) */
+#define SMBIOS_PROCESSOR_UND 2 /* BIT(1) */
+#define SMBIOS_PROCESSOR_64BIT 4 /* BIT(2) */
+#define SMBIOS_PROCESSOR_MULTICORE 8 /* BIT(3) */
+#define SMBIOS_PROCESSOR_HWTHREAD 16 /* BIT(4) */
+#define SMBIOS_PROCESSOR_EXEC_PROT 32 /* BIT(5) */
+#define SMBIOS_PROCESSOR_ENH_VIRT 64 /* BIT(6) */
+#define SMBIOS_PROCESSOR_POW_CON 0x80 /* BIT(7) */
+#define SMBIOS_PROCESSOR_128BIT 0x100 /* BIT(8) */
+#define SMBIOS_PROCESSOR_ARM64_SOCID 0x200 /* BIT(9) */
+
+/*
+ * Cache Information
+ */
+
+#define SMBIOS_CACHE_SIZE_EXT_KB (2047 * 1024) /* 2047 MiB */
+#define SMBIOS_CACHE_HANDLE_NONE 0xffff
+
+/* System Cache Type */
+#define SMBIOS_CACHE_SYSCACHE_TYPE_OTHER 1
+#define SMBIOS_CACHE_SYSCACHE_TYPE_UNKNOWN 2
+#define SMBIOS_CACHE_SYSCACHE_TYPE_INST 3
+#define SMBIOS_CACHE_SYSCACHE_TYPE_DATA 4
+#define SMBIOS_CACHE_SYSCACHE_TYPE_UNIFIED 5
+
+/* Cache Speed */
+#define SMBIOS_CACHE_SPEED_UNKNOWN 0
+
+/* SRAM Type */
+#define SMBIOS_CACHE_SRAM_TYPE_UNKNOWN 2 /* BIT(1) */
+
+/* Error Correction Type */
+#define SMBIOS_CACHE_ERRCORR_OTHER 1
+#define SMBIOS_CACHE_ERRCORR_UNKNOWN 2
+#define SMBIOS_CACHE_ERRCORR_NONE 3
+#define SMBIOS_CACHE_ERRCORR_PARITY 4
+#define SMBIOS_CACHE_ERRCORR_SBITECC 5
+#define SMBIOS_CACHE_ERRCORR_MBITECC 6
+
+/* Cache Configuration */
+#define SMBIOS_CACHE_LEVEL_1 0
+#define SMBIOS_CACHE_LEVEL_2 1
+#define SMBIOS_CACHE_LEVEL_3 2
+#define SMBIOS_CACHE_LEVEL_4 3
+#define SMBIOS_CACHE_LEVEL_5 4
+#define SMBIOS_CACHE_LEVEL_6 5
+#define SMBIOS_CACHE_LEVEL_7 6
+#define SMBIOS_CACHE_LEVEL_8 7
+#define SMBIOS_CACHE_SOCKETED 8 /* BIT(3) */
+#define SMBIOS_CACHE_LOCATE_EXTERNAL 32 /* BIT(5) */
+#define SMBIOS_CACHE_LOCATE_RESERVED 64 /* BIT(6) */
+#define SMBIOS_CACHE_LOCATE_UNKNOWN 96 /* (BIT(5) | BIT(6)) */
+#define SMBIOS_CACHE_ENABLED 0x80 /* BIT(7) */
+#define SMBIOS_CACHE_OP_WB 0x100 /* BIT(8), Write Back */
+#define SMBIOS_CACHE_OP_VAR 0x200 /* BIT(9), Varies with Memory Address */
+#define SMBIOS_CACHE_OP_UND 0x300 /* (BIT(8) | BIT(9)), Unknown*/
+
+/* Cache Granularity */
+#define SMBIOS_CACHE_GRANU_1K 0
+#define SMBIOS_CACHE_GRANU_64K 1
+
+/* Cache Associativity */
+#define SMBIOS_CACHE_ASSOC_OTHER 1
+#define SMBIOS_CACHE_ASSOC_UNKNOWN 2
+#define SMBIOS_CACHE_ASSOC_DMAPPED 3
+#define SMBIOS_CACHE_ASSOC_2WAY 4
+#define SMBIOS_CACHE_ASSOC_4WAY 5
+#define SMBIOS_CACHE_ASSOC_FULLY 6
+#define SMBIOS_CACHE_ASSOC_8WAY 7
+#define SMBIOS_CACHE_ASSOC_16WAY 8
+#define SMBIOS_CACHE_ASSOC_12WAY 9
+#define SMBIOS_CACHE_ASSOC_24WAY 10
+#define SMBIOS_CACHE_ASSOC_32WAY 11
+#define SMBIOS_CACHE_ASSOC_48WAY 12
+#define SMBIOS_CACHE_ASSOC_64WAY 13
+#define SMBIOS_CACHE_ASSOC_20WAY 14
+
+#endif /* _SMBIOS_DEF_H_ */
diff --git a/include/smbios_plat.h b/include/smbios_plat.h
new file mode 100644
index 00000000000..70089d5a2ba
--- /dev/null
+++ b/include/smbios_plat.h
@@ -0,0 +1,79 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * Copyright (c) 2024 Linaro Limited
+ * Author: Raymond Mao <[email protected]>
+ */
+#ifndef __SMBIOS_PLAT_H
+#define __SMBIOS_PLAT_H
+
+#include <smbios.h>
+
+struct cache_info {
+ union cache_config config;
+ union cache_sram_type supp_sram_type;
+ union cache_sram_type curr_sram_type;
+ u32 line_size;
+ u32 associativity;
+ u32 max_size;
+ u32 inst_size;
+ u8 cache_type;
+ u8 speed;
+ u8 err_corr_type;
+ char *socket_design;
+};
+
+struct processor_info {
+ u32 id[2];
+ u16 ext_clock;
+ u16 max_speed;
+ u16 curr_speed;
+ u16 characteristics;
+ u16 family2;
+ u16 core_count2;
+ u16 core_enabled2;
+ u16 thread_count2;
+ u16 thread_enabled;
+ u8 type;
+ u8 family;
+ u8 voltage;
+ u8 status;
+ u8 upgrade;
+ u8 core_count;
+ u8 core_enabled;
+ u8 thread_count;
+ char *socket_design;
+ char *manufacturer;
+ char *version;
+ char *sn;
+ char *asset_tag;
+ char *pn;
+};
+
+struct sysinfo_plat {
+ struct processor_info *processor;
+ struct cache_info *cache;
+ /* add other sysinfo structure here */
+};
+
+#if defined CONFIG_SYSINFO_SMBIOS
+int sysinfo_get_cache_info(u8 level, struct cache_info *cache_info);
+void sysinfo_cache_info_default(struct cache_info *ci);
+int sysinfo_get_processor_info(struct processor_info *pinfo);
+#else
+static inline int sysinfo_get_cache_info(u8 level,
+ struct cache_info *cache_info)
+{
+ return -ENOSYS;
+}
+
+static inline void sysinfo_cache_info_default(struct cache_info *ci)
+{
+}
+
+static inline int sysinfo_get_processor_info(struct processor_info *pinfo)
+{
+ return -ENOSYS;
+}
+#endif
+
+#endif /* __SMBIOS_PLAT_H */
diff --git a/include/sysinfo.h b/include/sysinfo.h
index 027a463dc33..ba2ac273e8e 100644
--- a/include/sysinfo.h
+++ b/include/sysinfo.h
@@ -11,6 +11,8 @@
struct udevice;
+#define SYSINFO_CACHE_LVL_MAX 3
+
/*
* This uclass encapsulates hardware methods to gather information about a
* sysinfo or a specific device such as hard-wired GPIOs on GPIO expanders,
@@ -42,18 +44,109 @@ struct udevice;
enum sysinfo_id {
SYSID_NONE,
- /* For SMBIOS tables */
+ /* BIOS Information (Type 0) */
+ SYSID_SM_BIOS_VENDOR,
+ SYSID_SM_BIOS_VER,
+ SYSID_SM_BIOS_REL_DATE,
+
+ /* System Information (Type 1) */
SYSID_SM_SYSTEM_MANUFACTURER,
SYSID_SM_SYSTEM_PRODUCT,
SYSID_SM_SYSTEM_VERSION,
SYSID_SM_SYSTEM_SERIAL,
+ SYSID_SM_SYSTEM_WAKEUP,
SYSID_SM_SYSTEM_SKU,
SYSID_SM_SYSTEM_FAMILY,
+
+ /* Baseboard (or Module) Information (Type 2) */
SYSID_SM_BASEBOARD_MANUFACTURER,
SYSID_SM_BASEBOARD_PRODUCT,
SYSID_SM_BASEBOARD_VERSION,
SYSID_SM_BASEBOARD_SERIAL,
SYSID_SM_BASEBOARD_ASSET_TAG,
+ SYSID_SM_BASEBOARD_FEATURE,
+ SYSID_SM_BASEBOARD_CHASSIS_LOCAT,
+ SYSID_SM_BASEBOARD_TYPE,
+ SYSID_SM_BASEBOARD_OBJS_NUM,
+ SYSID_SM_BASEBOARD_OBJS_HANDLE,
+
+ /* System Enclosure or Chassis (Type 3) */
+ SYSID_SM_ENCLOSURE_MANUFACTURER,
+ SYSID_SM_ENCLOSURE_VERSION,
+ SYSID_SM_ENCLOSURE_SERIAL,
+ SYSID_SM_ENCLOSURE_ASSET_TAG,
+ SYSID_SM_ENCLOSURE_TYPE,
+ SYSID_SM_ENCLOSURE_BOOTUP,
+ SYSID_SM_ENCLOSURE_POW,
+ SYSID_SM_ENCLOSURE_THERMAL,
+ SYSID_SM_ENCLOSURE_SECURITY,
+ SYSID_SM_ENCLOSURE_OEM,
+ SYSID_SM_ENCLOSURE_HEIGHT,
+ SYSID_SM_ENCLOSURE_POWCORE_NUM,
+ SYSID_SM_ENCLOSURE_ELEMENT_CNT,
+ SYSID_SM_ENCLOSURE_ELEMENT_LEN,
+ SYSID_SM_ENCLOSURE_ELEMENTS,
+ SYSID_SM_ENCLOSURE_SKU,
+
+ /* Processor Information (Type 4) */
+ SYSID_SM_PROCESSOR_SOCKET,
+ SYSID_SM_PROCESSOR_TYPE,
+ SYSID_SM_PROCESSOR_MANUFACT,
+ SYSID_SM_PROCESSOR_ID,
+ SYSID_SM_PROCESSOR_VERSION,
+ SYSID_SM_PROCESSOR_VOLTAGE,
+ SYSID_SM_PROCESSOR_EXT_CLOCK,
+ SYSID_SM_PROCESSOR_MAX_SPEED,
+ SYSID_SM_PROCESSOR_CUR_SPEED,
+ SYSID_SM_PROCESSOR_STATUS,
+ SYSID_SM_PROCESSOR_UPGRADE,
+ SYSID_SM_PROCESSOR_SN,
+ SYSID_SM_PROCESSOR_ASSET_TAG,
+ SYSID_SM_PROCESSOR_PN,
+ SYSID_SM_PROCESSOR_CORE_CNT,
+ SYSID_SM_PROCESSOR_CORE_EN,
+ SYSID_SM_PROCESSOR_THREAD_CNT,
+ SYSID_SM_PROCESSOR_CHARA,
+ SYSID_SM_PROCESSOR_FAMILY,
+ SYSID_SM_PROCESSOR_FAMILY2,
+ SYSID_SM_PROCESSOR_CORE_CNT2,
+ SYSID_SM_PROCESSOR_CORE_EN2,
+ SYSID_SM_PROCESSOR_THREAD_CNT2,
+ SYSID_SM_PROCESSOR_THREAD_EN,
+
+ /*
+ * Cache Information (Type 7)
+ * Each of the id should reserve space for up to
+ * SYSINFO_CACHE_LVL_MAX levels of cache
+ */
+ SYSID_SM_CACHE_LEVEL,
+ SYSID_SM_CACHE_HANDLE,
+ SYSID_SM_CACHE_INFO_START,
+ SYSID_SM_CACHE_SOCKET = SYSID_SM_CACHE_INFO_START,
+ SYSID_SM_CACHE_CONFIG =
+ SYSID_SM_CACHE_SOCKET + SYSINFO_CACHE_LVL_MAX,
+ SYSID_SM_CACHE_MAX_SIZE =
+ SYSID_SM_CACHE_CONFIG + SYSINFO_CACHE_LVL_MAX,
+ SYSID_SM_CACHE_INST_SIZE =
+ SYSID_SM_CACHE_MAX_SIZE + SYSINFO_CACHE_LVL_MAX,
+ SYSID_SM_CACHE_SUPSRAM_TYPE =
+ SYSID_SM_CACHE_INST_SIZE + SYSINFO_CACHE_LVL_MAX,
+ SYSID_SM_CACHE_CURSRAM_TYPE =
+ SYSID_SM_CACHE_SUPSRAM_TYPE + SYSINFO_CACHE_LVL_MAX,
+ SYSID_SM_CACHE_SPEED =
+ SYSID_SM_CACHE_CURSRAM_TYPE + SYSINFO_CACHE_LVL_MAX,
+ SYSID_SM_CACHE_ERRCOR_TYPE =
+ SYSID_SM_CACHE_SPEED + SYSINFO_CACHE_LVL_MAX,
+ SYSID_SM_CACHE_SCACHE_TYPE =
+ SYSID_SM_CACHE_ERRCOR_TYPE + SYSINFO_CACHE_LVL_MAX,
+ SYSID_SM_CACHE_ASSOC =
+ SYSID_SM_CACHE_SCACHE_TYPE + SYSINFO_CACHE_LVL_MAX,
+ SYSID_SM_CACHE_MAX_SIZE2 =
+ SYSID_SM_CACHE_ASSOC + SYSINFO_CACHE_LVL_MAX,
+ SYSID_SM_CACHE_INST_SIZE2 =
+ SYSID_SM_CACHE_MAX_SIZE2 + SYSINFO_CACHE_LVL_MAX,
+ SYSID_SM_CACHE_INFO_END =
+ SYSID_SM_CACHE_INST_SIZE2 + SYSINFO_CACHE_LVL_MAX - 1,
/* For show_board_info() */
SYSID_BOARD_MODEL,
@@ -116,6 +209,18 @@ struct sysinfo_ops {
int (*get_str)(struct udevice *dev, int id, size_t size, char *val);
/**
+ * get_data() - Read a specific string data value that describes the
+ * hardware setup.
+ * @dev: The sysinfo instance to gather the data.
+ * @id: A unique identifier for the data area to be get.
+ * @data: Pointer to the address of the data area.
+ * @size: Pointer to the size of the data area.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+ int (*get_data)(struct udevice *dev, int id, void **data, size_t *size);
+
+ /**
* get_fit_loadable - Get the name of an image to load from FIT
* This function can be used to provide the image names based on runtime
* detection. A classic use-case would when DTBOs are used to describe
@@ -187,6 +292,18 @@ int sysinfo_get_int(struct udevice *dev, int id, int *val);
int sysinfo_get_str(struct udevice *dev, int id, size_t size, char *val);
/**
+ * sysinfo_get_data() - Get a data area from the platform.
+ * @dev: The sysinfo instance to gather the data.
+ * @id: A unique identifier for the data area to be get.
+ * @data: Pointer to the address of the data area.
+ * @size: Pointer to the size of the data area.
+ *
+ * Return: 0 if OK, -EPERM if called before sysinfo_detect(), else -ve on
+ * error.
+ */
+int sysinfo_get_data(struct udevice *dev, int id, void **data, size_t *size);
+
+/**
* sysinfo_get() - Return the sysinfo device for the sysinfo in question.
* @devp: Pointer to structure to receive the sysinfo device.
*
@@ -241,6 +358,12 @@ static inline int sysinfo_get_str(struct udevice *dev, int id, size_t size,
return -ENOSYS;
}
+static inline int sysinfo_get_data(struct udevice *dev, int id, void **data,
+ size_t *size)
+{
+ return -ENOSYS;
+}
+
static inline int sysinfo_get(struct udevice **devp)
{
return -ENOSYS;