2 * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
4 * Adapted from coreboot src/include/smbios.h
6 * SPDX-License-Identifier: GPL-2.0+
12 /* SMBIOS spec version implemented */
13 #define SMBIOS_MAJOR_VER 3
14 #define SMBIOS_MINOR_VER 0
16 /* SMBIOS structure types */
18 SMBIOS_BIOS_INFORMATION = 0,
19 SMBIOS_SYSTEM_INFORMATION = 1,
20 SMBIOS_BOARD_INFORMATION = 2,
21 SMBIOS_SYSTEM_ENCLOSURE = 3,
22 SMBIOS_PROCESSOR_INFORMATION = 4,
23 SMBIOS_CACHE_INFORMATION = 7,
24 SMBIOS_SYSTEM_SLOTS = 9,
25 SMBIOS_PHYS_MEMORY_ARRAY = 16,
26 SMBIOS_MEMORY_DEVICE = 17,
27 SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS = 19,
28 SMBIOS_SYSTEM_BOOT_INFORMATION = 32,
29 SMBIOS_END_OF_TABLE = 127
32 #define SMBIOS_INTERMEDIATE_OFFSET 16
33 #define SMBIOS_STRUCT_EOS_BYTES 2
35 struct __packed smbios_entry {
44 u8 intermediate_anchor[5];
45 u8 intermediate_checksum;
46 u16 struct_table_length;
47 u32 struct_table_address;
52 /* BIOS characteristics */
53 #define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
54 #define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11)
55 #define BIOS_CHARACTERISTICS_SELECTABLE_BOOT (1 << 16)
57 #define BIOS_CHARACTERISTICS_EXT1_ACPI (1 << 0)
58 #define BIOS_CHARACTERISTICS_EXT1_UEFI (1 << 3)
59 #define BIOS_CHARACTERISTICS_EXT2_TARGET (1 << 2)
61 struct __packed smbios_type0 {
67 u16 bios_start_segment;
70 u64 bios_characteristics;
71 u8 bios_characteristics_ext1;
72 u8 bios_characteristics_ext2;
73 u8 bios_major_release;
74 u8 bios_minor_release;
77 char eos[SMBIOS_STRUCT_EOS_BYTES];
80 struct __packed smbios_type1 {
92 char eos[SMBIOS_STRUCT_EOS_BYTES];
95 #define SMBIOS_BOARD_FEATURE_HOSTING (1 << 0)
96 #define SMBIOS_BOARD_MOTHERBOARD 10
98 struct __packed smbios_type2 {
111 char eos[SMBIOS_STRUCT_EOS_BYTES];
114 #define SMBIOS_ENCLOSURE_DESKTOP 3
115 #define SMBIOS_STATE_SAFE 3
116 #define SMBIOS_SECURITY_NONE 3
118 struct __packed smbios_type3 {
128 u8 power_supply_state;
133 u8 number_of_power_cords;
135 u8 element_record_length;
136 char eos[SMBIOS_STRUCT_EOS_BYTES];
139 #define SMBIOS_PROCESSOR_TYPE_CENTRAL 3
140 #define SMBIOS_PROCESSOR_STATUS_ENABLED 1
141 #define SMBIOS_PROCESSOR_UPGRADE_NONE 6
143 #define SMBIOS_PROCESSOR_FAMILY_OTHER 1
144 #define SMBIOS_PROCESSOR_FAMILY_UNKNOWN 2
146 struct __packed smbios_type4 {
150 u8 socket_designation;
153 u8 processor_manufacturer;
155 u8 processor_version;
161 u8 processor_upgrade;
171 u16 processor_characteristics;
172 u16 processor_family2;
176 char eos[SMBIOS_STRUCT_EOS_BYTES];
179 struct __packed smbios_type32 {
185 u8 eos[SMBIOS_STRUCT_EOS_BYTES];
188 struct __packed smbios_type127 {
192 u8 eos[SMBIOS_STRUCT_EOS_BYTES];
195 struct __packed smbios_header {
202 * fill_smbios_header() - Fill the header of an SMBIOS table
204 * This fills the header of an SMBIOS table structure.
206 * @table: start address of the structure
207 * @type: the type of structure
208 * @length: the length of the formatted area of the structure
209 * @handle: the structure's handle, a unique 16-bit number
211 static inline void fill_smbios_header(void *table, int type,
212 int length, int handle)
214 struct smbios_header *header = table;
217 header->length = length - SMBIOS_STRUCT_EOS_BYTES;
218 header->handle = handle;
222 * Function prototype to write a specific type of SMBIOS structure
224 * @addr: start address to write the structure
225 * @handle: the structure's handle, a unique 16-bit number
226 * @return: size of the structure
228 typedef int (*smbios_write_type)(uintptr_t *addr, int handle);
231 * write_smbios_table() - Write SMBIOS table
233 * This writes SMBIOS table at a given address.
235 * @addr: start address to write SMBIOS table
236 * @return: end address of SMBIOS table
238 uintptr_t write_smbios_table(uintptr_t addr);
240 #endif /* _SMBIOS_H_ */