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 /* SMBIOS spec version implemented */
12 #define SMBIOS_MAJOR_VER 3
13 #define SMBIOS_MINOR_VER 0
15 /* SMBIOS structure types */
17 SMBIOS_BIOS_INFORMATION = 0,
18 SMBIOS_SYSTEM_INFORMATION = 1,
19 SMBIOS_BOARD_INFORMATION = 2,
20 SMBIOS_SYSTEM_ENCLOSURE = 3,
21 SMBIOS_PROCESSOR_INFORMATION = 4,
22 SMBIOS_CACHE_INFORMATION = 7,
23 SMBIOS_SYSTEM_SLOTS = 9,
24 SMBIOS_PHYS_MEMORY_ARRAY = 16,
25 SMBIOS_MEMORY_DEVICE = 17,
26 SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS = 19,
27 SMBIOS_SYSTEM_BOOT_INFORMATION = 32,
28 SMBIOS_END_OF_TABLE = 127
31 #define SMBIOS_INTERMEDIATE_OFFSET 16
32 #define SMBIOS_STRUCT_EOS_BYTES 2
34 struct __packed smbios_entry {
43 u8 intermediate_anchor[5];
44 u8 intermediate_checksum;
45 u16 struct_table_length;
46 u32 struct_table_address;
51 /* BIOS characteristics */
52 #define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
53 #define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11)
54 #define BIOS_CHARACTERISTICS_SELECTABLE_BOOT (1 << 16)
56 #define BIOS_CHARACTERISTICS_EXT1_ACPI (1 << 0)
57 #define BIOS_CHARACTERISTICS_EXT1_UEFI (1 << 3)
58 #define BIOS_CHARACTERISTICS_EXT2_TARGET (1 << 2)
60 struct __packed smbios_type0 {
66 u16 bios_start_segment;
69 u64 bios_characteristics;
70 u8 bios_characteristics_ext1;
71 u8 bios_characteristics_ext2;
72 u8 bios_major_release;
73 u8 bios_minor_release;
76 char eos[SMBIOS_STRUCT_EOS_BYTES];
79 struct __packed smbios_type1 {
91 char eos[SMBIOS_STRUCT_EOS_BYTES];
94 #define SMBIOS_BOARD_FEATURE_HOSTING (1 << 0)
95 #define SMBIOS_BOARD_MOTHERBOARD 10
97 struct __packed smbios_type2 {
110 char eos[SMBIOS_STRUCT_EOS_BYTES];
113 #define SMBIOS_ENCLOSURE_DESKTOP 3
114 #define SMBIOS_STATE_SAFE 3
115 #define SMBIOS_SECURITY_NONE 3
117 struct __packed smbios_type3 {
127 u8 power_supply_state;
132 u8 number_of_power_cords;
134 u8 element_record_length;
135 char eos[SMBIOS_STRUCT_EOS_BYTES];
138 #define SMBIOS_PROCESSOR_TYPE_CENTRAL 3
139 #define SMBIOS_PROCESSOR_STATUS_ENABLED 1
140 #define SMBIOS_PROCESSOR_UPGRADE_NONE 6
142 #define SMBIOS_PROCESSOR_FAMILY_OTHER 1
143 #define SMBIOS_PROCESSOR_FAMILY_UNKNOWN 2
145 struct __packed smbios_type4 {
149 u8 socket_designation;
152 u8 processor_manufacturer;
154 u8 processor_version;
160 u8 processor_upgrade;
170 u16 processor_characteristics;
171 u16 processor_family2;
175 char eos[SMBIOS_STRUCT_EOS_BYTES];
178 struct __packed smbios_type32 {
184 u8 eos[SMBIOS_STRUCT_EOS_BYTES];
187 struct __packed smbios_type127 {
191 u8 eos[SMBIOS_STRUCT_EOS_BYTES];
194 struct __packed smbios_header {
201 * fill_smbios_header() - Fill the header of an SMBIOS table
203 * This fills the header of an SMBIOS table structure.
205 * @table: start address of the structure
206 * @type: the type of structure
207 * @length: the length of the formatted area of the structure
208 * @handle: the structure's handle, a unique 16-bit number
210 static inline void fill_smbios_header(void *table, int type,
211 int length, int handle)
213 struct smbios_header *header = table;
216 header->length = length - SMBIOS_STRUCT_EOS_BYTES;
217 header->handle = handle;
221 * Function prototype to write a specific type of SMBIOS structure
223 * @addr: start address to write the structure
224 * @handle: the structure's handle, a unique 16-bit number
225 * @return: size of the structure
227 typedef int (*smbios_write_type)(ulong *addr, int handle);
230 * write_smbios_table() - Write SMBIOS table
232 * This writes SMBIOS table at a given address.
234 * @addr: start address to write SMBIOS table. If this is not
235 * 16-byte-aligned then it will be aligned before the table is written
236 * @return: end address of SMBIOS table (and start address for next entry)
238 ulong write_smbios_table(ulong addr);
240 #endif /* _SMBIOS_H_ */