1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
5 * Adapted from coreboot src/include/smbios.h
11 #include <dm/ofnode.h>
13 /* SMBIOS spec version implemented */
14 #define SMBIOS_MAJOR_VER 3
15 #define SMBIOS_MINOR_VER 0
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 */
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
];
111 struct __packed smbios_type1
{
123 char eos
[SMBIOS_STRUCT_EOS_BYTES
];
126 #define SMBIOS_BOARD_FEATURE_HOSTING (1 << 0)
127 #define SMBIOS_BOARD_MOTHERBOARD 10
129 struct __packed smbios_type2
{
142 char eos
[SMBIOS_STRUCT_EOS_BYTES
];
145 #define SMBIOS_ENCLOSURE_DESKTOP 3
146 #define SMBIOS_STATE_SAFE 3
147 #define SMBIOS_SECURITY_NONE 3
149 struct __packed smbios_type3
{
159 u8 power_supply_state
;
164 u8 number_of_power_cords
;
166 u8 element_record_length
;
167 char eos
[SMBIOS_STRUCT_EOS_BYTES
];
170 #define SMBIOS_PROCESSOR_TYPE_CENTRAL 3
171 #define SMBIOS_PROCESSOR_STATUS_ENABLED 1
172 #define SMBIOS_PROCESSOR_UPGRADE_NONE 6
174 #define SMBIOS_PROCESSOR_FAMILY_OTHER 1
175 #define SMBIOS_PROCESSOR_FAMILY_UNKNOWN 2
177 struct __packed smbios_type4
{
181 u8 socket_designation
;
184 u8 processor_manufacturer
;
186 u8 processor_version
;
192 u8 processor_upgrade
;
202 u16 processor_characteristics
;
203 u16 processor_family2
;
207 char eos
[SMBIOS_STRUCT_EOS_BYTES
];
210 struct __packed smbios_type32
{
216 char eos
[SMBIOS_STRUCT_EOS_BYTES
];
219 struct __packed smbios_type127
{
223 char eos
[SMBIOS_STRUCT_EOS_BYTES
];
226 struct __packed smbios_header
{
233 * fill_smbios_header() - Fill the header of an SMBIOS table
235 * This fills the header of an SMBIOS table structure.
237 * @table: start address of the structure
238 * @type: the type of structure
239 * @length: the length of the formatted area of the structure
240 * @handle: the structure's handle, a unique 16-bit number
242 static inline void fill_smbios_header(void *table
, int type
,
243 int length
, int handle
)
245 struct smbios_header
*header
= table
;
248 header
->length
= length
- SMBIOS_STRUCT_EOS_BYTES
;
249 header
->handle
= handle
;
253 * write_smbios_table() - Write SMBIOS table
255 * This writes SMBIOS table at a given address.
257 * @addr: start address to write SMBIOS table. If this is not
258 * 16-byte-aligned then it will be aligned before the table is
260 * Return: end address of SMBIOS table (and start address for next entry)
261 * or NULL in case of an error
264 ulong
write_smbios_table(ulong addr
);
267 * smbios_entry() - Get a valid struct smbios_entry pointer
269 * @address: address where smbios tables is located
270 * @size: size of smbios table
271 * @return: NULL or a valid pointer to a struct smbios_entry
273 const struct smbios_entry
*smbios_entry(u64 address
, u32 size
);
276 * smbios_header() - Search for SMBIOS header type
278 * @entry: pointer to a struct smbios_entry
280 * @return: NULL or a valid pointer to a struct smbios_header
282 const struct smbios_header
*smbios_header(const struct smbios_entry
*entry
, int type
);
285 * smbios_string() - Return string from SMBIOS
287 * @header: pointer to struct smbios_header
288 * @index: string index
289 * @return: NULL or a valid char pointer
291 char *smbios_string(const struct smbios_header
*header
, int index
);
294 * smbios_update_version() - Update the version string
296 * This can be called after the SMBIOS tables are written (e.g. after the U-Boot
297 * main loop has started) to update the BIOS version string (SMBIOS table 0).
299 * @version: New version string to use
300 * Return: 0 if OK, -ENOENT if no version string was previously written,
301 * -ENOSPC if the new string is too large to fit
303 int smbios_update_version(const char *version
);
306 * smbios_update_version_full() - Update the version string
308 * This can be called after the SMBIOS tables are written (e.g. after the U-Boot
309 * main loop has started) to update the BIOS version string (SMBIOS table 0).
310 * It scans for the correct place to put the version, so does not need U-Boot
311 * to have actually written the tables itself (e.g. if a previous bootloader
314 * @smbios_tab: Start of SMBIOS tables
315 * @version: New version string to use
316 * Return: 0 if OK, -ENOENT if no version string was previously written,
317 * -ENOSPC if the new string is too large to fit
319 int smbios_update_version_full(void *smbios_tab
, const char *version
);
322 * smbios_prepare_measurement() - Update smbios table for the measurement
324 * TCG specification requires to measure static configuration information.
325 * This function clear the device dependent parameters such as
326 * serial number for the measurement.
328 * @entry: pointer to a struct smbios_entry
329 * @header: pointer to a struct smbios_header
331 void smbios_prepare_measurement(const struct smbios_entry
*entry
,
332 struct smbios_header
*header
);
334 #endif /* _SMBIOS_H_ */