1 /* SPDX-License-Identifier: GPL-2.0+ */
5 * Adapted from coreboot src/include/smbios.h
11 #include <linux/types.h>
13 /* SMBIOS spec version implemented */
14 #define SMBIOS_MAJOR_VER 3
15 #define SMBIOS_MINOR_VER 7
18 SMBIOS_STR_MAX = 64, /* Maximum length allowed for a string */
21 /* SMBIOS structure types */
23 SMBIOS_BIOS_INFORMATION = 0,
24 SMBIOS_SYSTEM_INFORMATION = 1,
25 SMBIOS_BOARD_INFORMATION = 2,
26 SMBIOS_SYSTEM_ENCLOSURE = 3,
27 SMBIOS_PROCESSOR_INFORMATION = 4,
28 SMBIOS_CACHE_INFORMATION = 7,
29 SMBIOS_SYSTEM_SLOTS = 9,
30 SMBIOS_PHYS_MEMORY_ARRAY = 16,
31 SMBIOS_MEMORY_DEVICE = 17,
32 SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS = 19,
33 SMBIOS_SYSTEM_BOOT_INFORMATION = 32,
34 SMBIOS_END_OF_TABLE = 127
37 #define SMBIOS_INTERMEDIATE_OFFSET 16
38 #define SMBIOS_STRUCT_EOS_BYTES 2
40 struct __packed smbios_entry {
49 u8 intermediate_anchor[5];
50 u8 intermediate_checksum;
51 u16 struct_table_length;
52 u32 struct_table_address;
58 * struct smbios3_entry - SMBIOS 3.0 (64-bit) Entry Point structure
60 struct __packed smbios3_entry {
61 /** @anchor: anchor string */
63 /** @checksum: checksum of the entry point structure */
65 /** @length: length of the entry point structure */
67 /** @major_ver: major version of the SMBIOS specification */
69 /** @minor_ver: minor version of the SMBIOS specification */
71 /** @docrev: revision of the SMBIOS specification */
73 /** @entry_point_rev: revision of the entry point structure */
75 /** @reserved: reserved */
77 /** maximum size of SMBIOS table */
78 u32 table_maximum_size;
79 /** @struct_table_address: 64-bit physical starting address */
80 u64 struct_table_address;
83 /* BIOS characteristics */
84 #define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
85 #define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11)
86 #define BIOS_CHARACTERISTICS_SELECTABLE_BOOT (1 << 16)
88 #define BIOS_CHARACTERISTICS_EXT1_ACPI (1 << 0)
89 #define BIOS_CHARACTERISTICS_EXT2_UEFI (1 << 3)
90 #define BIOS_CHARACTERISTICS_EXT2_TARGET (1 << 2)
92 struct __packed smbios_type0 {
98 u16 bios_start_segment;
101 u64 bios_characteristics;
102 u8 bios_characteristics_ext1;
103 u8 bios_characteristics_ext2;
104 u8 bios_major_release;
105 u8 bios_minor_release;
108 char eos[SMBIOS_STRUCT_EOS_BYTES];
112 * enum smbios_wakeup_type - wake-up type
114 * These constants are used for the Wake-Up Type field in the SMBIOS
115 * System Information (Type 1) structure.
117 enum smbios_wakeup_type {
118 /** @SMBIOS_WAKEUP_TYPE_RESERVED: Reserved */
119 SMBIOS_WAKEUP_TYPE_RESERVED,
120 /** @SMBIOS_WAKEUP_TYPE_OTHER: Other */
121 SMBIOS_WAKEUP_TYPE_OTHER,
122 /** @SMBIOS_WAKEUP_TYPE_UNKNOWN: Unknown */
123 SMBIOS_WAKEUP_TYPE_UNKNOWN,
124 /** @SMBIOS_WAKEUP_TYPE_APM_TIMER: APM Timer */
125 SMBIOS_WAKEUP_TYPE_APM_TIMER,
126 /** @SMBIOS_WAKEUP_TYPE_MODEM_RING: Modem Ring */
127 SMBIOS_WAKEUP_TYPE_MODEM_RING,
128 /** @SMBIOS_WAKEUP_TYPE_LAN_REMOTE: LAN Remote */
129 SMBIOS_WAKEUP_TYPE_LAN_REMOTE,
130 /** @SMBIOS_WAKEUP_TYPE_POWER_SWITCH: Power Switch */
131 SMBIOS_WAKEUP_TYPE_POWER_SWITCH,
132 /** @SMBIOS_WAKEUP_TYPE_PCI_PME: PCI PME# */
133 SMBIOS_WAKEUP_TYPE_PCI_PME,
134 /** @SMBIOS_WAKEUP_TYPE_AC_POWER_RESTORED: AC Power Restored */
135 SMBIOS_WAKEUP_TYPE_AC_POWER_RESTORED,
138 struct __packed smbios_type1 {
150 char eos[SMBIOS_STRUCT_EOS_BYTES];
153 #define SMBIOS_BOARD_FEATURE_HOSTING (1 << 0)
154 #define SMBIOS_BOARD_MOTHERBOARD 10
156 struct __packed smbios_type2 {
169 u8 number_contained_objects;
170 char eos[SMBIOS_STRUCT_EOS_BYTES];
173 #define SMBIOS_ENCLOSURE_DESKTOP 3
174 #define SMBIOS_STATE_SAFE 3
175 #define SMBIOS_SECURITY_NONE 3
177 struct __packed smbios_type3 {
187 u8 power_supply_state;
192 u8 number_of_power_cords;
194 u8 element_record_length;
195 char eos[SMBIOS_STRUCT_EOS_BYTES];
198 #define SMBIOS_PROCESSOR_TYPE_CENTRAL 3
199 #define SMBIOS_PROCESSOR_STATUS_ENABLED 1
200 #define SMBIOS_PROCESSOR_UPGRADE_NONE 6
202 #define SMBIOS_PROCESSOR_FAMILY_OTHER 1
203 #define SMBIOS_PROCESSOR_FAMILY_UNKNOWN 2
205 struct __packed smbios_type4 {
209 u8 socket_designation;
212 u8 processor_manufacturer;
214 u8 processor_version;
220 u8 processor_upgrade;
230 u16 processor_characteristics;
231 u16 processor_family2;
235 char eos[SMBIOS_STRUCT_EOS_BYTES];
238 struct __packed smbios_type32 {
244 char eos[SMBIOS_STRUCT_EOS_BYTES];
247 struct __packed smbios_type127 {
251 char eos[SMBIOS_STRUCT_EOS_BYTES];
254 struct __packed smbios_header {
261 * fill_smbios_header() - Fill the header of an SMBIOS table
263 * This fills the header of an SMBIOS table structure.
265 * @table: start address of the structure
266 * @type: the type of structure
267 * @length: the length of the formatted area of the structure
268 * @handle: the structure's handle, a unique 16-bit number
270 static inline void fill_smbios_header(void *table, int type,
271 int length, int handle)
273 struct smbios_header *header = table;
276 header->length = length - SMBIOS_STRUCT_EOS_BYTES;
277 header->handle = handle;
281 * write_smbios_table() - Write SMBIOS table
283 * This writes SMBIOS table at a given address.
285 * @addr: start address to write SMBIOS table, 16-byte-alignment
286 * recommended. Note that while the SMBIOS tables themself have no alignment
287 * requirement, some systems may requires alignment. For example x86 systems
288 * which put tables at f0000 require 16-byte alignment
290 * Return: end address of SMBIOS table (and start address for next entry)
291 * or NULL in case of an error
293 ulong write_smbios_table(ulong addr);
296 * smbios_entry() - Get a valid struct smbios_entry pointer
298 * @address: address where smbios tables is located
299 * @size: size of smbios table
300 * @return: NULL or a valid pointer to a struct smbios_entry
302 const struct smbios_entry *smbios_entry(u64 address, u32 size);
305 * smbios_header() - Search for SMBIOS header type
307 * @entry: pointer to a struct smbios_entry
309 * @return: NULL or a valid pointer to a struct smbios_header
311 const struct smbios_header *smbios_header(const struct smbios_entry *entry, int type);
314 * smbios_string() - Return string from SMBIOS
316 * @header: pointer to struct smbios_header
317 * @index: string index
318 * @return: NULL or a valid char pointer
320 char *smbios_string(const struct smbios_header *header, int index);
323 * smbios_update_version() - Update the version string
325 * This can be called after the SMBIOS tables are written (e.g. after the U-Boot
326 * main loop has started) to update the BIOS version string (SMBIOS table 0).
328 * @version: New version string to use
329 * Return: 0 if OK, -ENOENT if no version string was previously written,
330 * -ENOSPC if the new string is too large to fit
332 int smbios_update_version(const char *version);
335 * smbios_update_version_full() - Update the version string
337 * This can be called after the SMBIOS tables are written (e.g. after the U-Boot
338 * main loop has started) to update the BIOS version string (SMBIOS table 0).
339 * It scans for the correct place to put the version, so does not need U-Boot
340 * to have actually written the tables itself (e.g. if a previous bootloader
343 * @smbios_tab: Start of SMBIOS tables
344 * @version: New version string to use
345 * Return: 0 if OK, -ENOENT if no version string was previously written,
346 * -ENOSPC if the new string is too large to fit
348 int smbios_update_version_full(void *smbios_tab, const char *version);
351 * smbios_prepare_measurement() - Update smbios table for the measurement
353 * TCG specification requires to measure static configuration information.
354 * This function clear the device dependent parameters such as
355 * serial number for the measurement.
357 * @entry: pointer to a struct smbios3_entry
358 * @header: pointer to a struct smbios_header
360 void smbios_prepare_measurement(const struct smbios3_entry *entry,
361 struct smbios_header *header);
363 #endif /* _SMBIOS_H_ */