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
;
57 /* BIOS characteristics */
58 #define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
59 #define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11)
60 #define BIOS_CHARACTERISTICS_SELECTABLE_BOOT (1 << 16)
62 #define BIOS_CHARACTERISTICS_EXT1_ACPI (1 << 0)
63 #define BIOS_CHARACTERISTICS_EXT1_UEFI (1 << 3)
64 #define BIOS_CHARACTERISTICS_EXT2_TARGET (1 << 2)
66 struct __packed smbios_type0
{
72 u16 bios_start_segment
;
75 u64 bios_characteristics
;
76 u8 bios_characteristics_ext1
;
77 u8 bios_characteristics_ext2
;
78 u8 bios_major_release
;
79 u8 bios_minor_release
;
82 char eos
[SMBIOS_STRUCT_EOS_BYTES
];
85 struct __packed smbios_type1
{
97 char eos
[SMBIOS_STRUCT_EOS_BYTES
];
100 #define SMBIOS_BOARD_FEATURE_HOSTING (1 << 0)
101 #define SMBIOS_BOARD_MOTHERBOARD 10
103 struct __packed smbios_type2
{
116 char eos
[SMBIOS_STRUCT_EOS_BYTES
];
119 #define SMBIOS_ENCLOSURE_DESKTOP 3
120 #define SMBIOS_STATE_SAFE 3
121 #define SMBIOS_SECURITY_NONE 3
123 struct __packed smbios_type3
{
133 u8 power_supply_state
;
138 u8 number_of_power_cords
;
140 u8 element_record_length
;
141 char eos
[SMBIOS_STRUCT_EOS_BYTES
];
144 #define SMBIOS_PROCESSOR_TYPE_CENTRAL 3
145 #define SMBIOS_PROCESSOR_STATUS_ENABLED 1
146 #define SMBIOS_PROCESSOR_UPGRADE_NONE 6
148 #define SMBIOS_PROCESSOR_FAMILY_OTHER 1
149 #define SMBIOS_PROCESSOR_FAMILY_UNKNOWN 2
151 struct __packed smbios_type4
{
155 u8 socket_designation
;
158 u8 processor_manufacturer
;
160 u8 processor_version
;
166 u8 processor_upgrade
;
176 u16 processor_characteristics
;
177 u16 processor_family2
;
181 char eos
[SMBIOS_STRUCT_EOS_BYTES
];
184 struct __packed smbios_type32
{
190 char eos
[SMBIOS_STRUCT_EOS_BYTES
];
193 struct __packed smbios_type127
{
197 char eos
[SMBIOS_STRUCT_EOS_BYTES
];
200 struct __packed smbios_header
{
207 * fill_smbios_header() - Fill the header of an SMBIOS table
209 * This fills the header of an SMBIOS table structure.
211 * @table: start address of the structure
212 * @type: the type of structure
213 * @length: the length of the formatted area of the structure
214 * @handle: the structure's handle, a unique 16-bit number
216 static inline void fill_smbios_header(void *table
, int type
,
217 int length
, int handle
)
219 struct smbios_header
*header
= table
;
222 header
->length
= length
- SMBIOS_STRUCT_EOS_BYTES
;
223 header
->handle
= handle
;
227 * write_smbios_table() - Write SMBIOS table
229 * This writes SMBIOS table at a given address.
231 * @addr: start address to write SMBIOS table. If this is not
232 * 16-byte-aligned then it will be aligned before the table is written
233 * @return: end address of SMBIOS table (and start address for next entry)
235 ulong
write_smbios_table(ulong addr
);
238 * smbios_entry() - Get a valid struct smbios_entry pointer
240 * @address: address where smbios tables is located
241 * @size: size of smbios table
242 * @return: NULL or a valid pointer to a struct smbios_entry
244 const struct smbios_entry
*smbios_entry(u64 address
, u32 size
);
247 * smbios_header() - Search for SMBIOS header type
249 * @entry: pointer to a struct smbios_entry
251 * @return: NULL or a valid pointer to a struct smbios_header
253 const struct smbios_header
*smbios_header(const struct smbios_entry
*entry
, int type
);
256 * smbios_string() - Return string from SMBIOS
258 * @header: pointer to struct smbios_header
259 * @index: string index
260 * @return: NULL or a valid const char pointer
262 const char *smbios_string(const struct smbios_header
*header
, int index
);
265 * smbios_update_version() - Update the version string
267 * This can be called after the SMBIOS tables are written (e.g. after the U-Boot
268 * main loop has started) to update the BIOS version string (SMBIOS table 0).
270 * @version: New version string to use
271 * @return 0 if OK, -ENOENT if no version string was previously written,
272 * -ENOSPC if the new string is too large to fit
274 int smbios_update_version(const char *version
);
277 * smbios_update_version_full() - Update the version string
279 * This can be called after the SMBIOS tables are written (e.g. after the U-Boot
280 * main loop has started) to update the BIOS version string (SMBIOS table 0).
281 * It scans for the correct place to put the version, so does not need U-Boot
282 * to have actually written the tables itself (e.g. if a previous bootloader
285 * @smbios_tab: Start of SMBIOS tables
286 * @version: New version string to use
287 * @return 0 if OK, -ENOENT if no version string was previously written,
288 * -ENOSPC if the new string is too large to fit
290 int smbios_update_version_full(void *smbios_tab
, const char *version
);
292 #endif /* _SMBIOS_H_ */