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
17 /* SMBIOS structure types */
19 SMBIOS_BIOS_INFORMATION = 0,
20 SMBIOS_SYSTEM_INFORMATION = 1,
21 SMBIOS_BOARD_INFORMATION = 2,
22 SMBIOS_SYSTEM_ENCLOSURE = 3,
23 SMBIOS_PROCESSOR_INFORMATION = 4,
24 SMBIOS_CACHE_INFORMATION = 7,
25 SMBIOS_SYSTEM_SLOTS = 9,
26 SMBIOS_PHYS_MEMORY_ARRAY = 16,
27 SMBIOS_MEMORY_DEVICE = 17,
28 SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS = 19,
29 SMBIOS_SYSTEM_BOOT_INFORMATION = 32,
30 SMBIOS_END_OF_TABLE = 127
33 #define SMBIOS_INTERMEDIATE_OFFSET 16
34 #define SMBIOS_STRUCT_EOS_BYTES 2
36 struct __packed smbios_entry {
45 u8 intermediate_anchor[5];
46 u8 intermediate_checksum;
47 u16 struct_table_length;
48 u32 struct_table_address;
53 /* BIOS characteristics */
54 #define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
55 #define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11)
56 #define BIOS_CHARACTERISTICS_SELECTABLE_BOOT (1 << 16)
58 #define BIOS_CHARACTERISTICS_EXT1_ACPI (1 << 0)
59 #define BIOS_CHARACTERISTICS_EXT1_UEFI (1 << 3)
60 #define BIOS_CHARACTERISTICS_EXT2_TARGET (1 << 2)
62 struct __packed smbios_type0 {
68 u16 bios_start_segment;
71 u64 bios_characteristics;
72 u8 bios_characteristics_ext1;
73 u8 bios_characteristics_ext2;
74 u8 bios_major_release;
75 u8 bios_minor_release;
78 char eos[SMBIOS_STRUCT_EOS_BYTES];
81 struct __packed smbios_type1 {
93 char eos[SMBIOS_STRUCT_EOS_BYTES];
96 #define SMBIOS_BOARD_FEATURE_HOSTING (1 << 0)
97 #define SMBIOS_BOARD_MOTHERBOARD 10
99 struct __packed smbios_type2 {
112 char eos[SMBIOS_STRUCT_EOS_BYTES];
115 #define SMBIOS_ENCLOSURE_DESKTOP 3
116 #define SMBIOS_STATE_SAFE 3
117 #define SMBIOS_SECURITY_NONE 3
119 struct __packed smbios_type3 {
129 u8 power_supply_state;
134 u8 number_of_power_cords;
136 u8 element_record_length;
137 char eos[SMBIOS_STRUCT_EOS_BYTES];
140 #define SMBIOS_PROCESSOR_TYPE_CENTRAL 3
141 #define SMBIOS_PROCESSOR_STATUS_ENABLED 1
142 #define SMBIOS_PROCESSOR_UPGRADE_NONE 6
144 #define SMBIOS_PROCESSOR_FAMILY_OTHER 1
145 #define SMBIOS_PROCESSOR_FAMILY_UNKNOWN 2
147 struct __packed smbios_type4 {
151 u8 socket_designation;
154 u8 processor_manufacturer;
156 u8 processor_version;
162 u8 processor_upgrade;
172 u16 processor_characteristics;
173 u16 processor_family2;
177 char eos[SMBIOS_STRUCT_EOS_BYTES];
180 struct __packed smbios_type32 {
186 char eos[SMBIOS_STRUCT_EOS_BYTES];
189 struct __packed smbios_type127 {
193 char eos[SMBIOS_STRUCT_EOS_BYTES];
196 struct __packed smbios_header {
203 * fill_smbios_header() - Fill the header of an SMBIOS table
205 * This fills the header of an SMBIOS table structure.
207 * @table: start address of the structure
208 * @type: the type of structure
209 * @length: the length of the formatted area of the structure
210 * @handle: the structure's handle, a unique 16-bit number
212 static inline void fill_smbios_header(void *table, int type,
213 int length, int handle)
215 struct smbios_header *header = table;
218 header->length = length - SMBIOS_STRUCT_EOS_BYTES;
219 header->handle = handle;
223 * write_smbios_table() - Write SMBIOS table
225 * This writes SMBIOS table at a given address.
227 * @addr: start address to write SMBIOS table. If this is not
228 * 16-byte-aligned then it will be aligned before the table is written
229 * @return: end address of SMBIOS table (and start address for next entry)
231 ulong write_smbios_table(ulong addr);
234 * smbios_entry() - Get a valid struct smbios_entry pointer
236 * @address: address where smbios tables is located
237 * @size: size of smbios table
238 * @return: NULL or a valid pointer to a struct smbios_entry
240 const struct smbios_entry *smbios_entry(u64 address, u32 size);
243 * smbios_header() - Search for SMBIOS header type
245 * @entry: pointer to a struct smbios_entry
247 * @return: NULL or a valid pointer to a struct smbios_header
249 const struct smbios_header *smbios_header(const struct smbios_entry *entry, int type);
252 * smbios_string() - Return string from SMBIOS
254 * @header: pointer to struct smbios_header
255 * @index: string index
256 * @return: NULL or a valid const char pointer
258 const char *smbios_string(const struct smbios_header *header, int index);
260 #endif /* _SMBIOS_H_ */