xref: /openbmc/u-boot/include/smbios.h (revision 2399e401)
1 /*
2  * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
3  *
4  * Adapted from coreboot src/include/smbios.h
5  *
6  * SPDX-License-Identifier:	GPL-2.0+
7  */
8 
9 #ifndef _SMBIOS_H_
10 #define _SMBIOS_H_
11 
12 /* SMBIOS spec version implemented */
13 #define SMBIOS_MAJOR_VER	3
14 #define SMBIOS_MINOR_VER	0
15 
16 /* SMBIOS structure types */
17 enum {
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
30 };
31 
32 #define SMBIOS_INTERMEDIATE_OFFSET	16
33 #define SMBIOS_STRUCT_EOS_BYTES		2
34 
35 struct __packed smbios_entry {
36 	u8 anchor[4];
37 	u8 checksum;
38 	u8 length;
39 	u8 major_ver;
40 	u8 minor_ver;
41 	u16 max_struct_size;
42 	u8 entry_point_rev;
43 	u8 formatted_area[5];
44 	u8 intermediate_anchor[5];
45 	u8 intermediate_checksum;
46 	u16 struct_table_length;
47 	u32 struct_table_address;
48 	u16 struct_count;
49 	u8 bcd_rev;
50 };
51 
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)
56 
57 #define BIOS_CHARACTERISTICS_EXT1_ACPI		(1 << 0)
58 #define BIOS_CHARACTERISTICS_EXT1_UEFI		(1 << 3)
59 #define BIOS_CHARACTERISTICS_EXT2_TARGET	(1 << 2)
60 
61 struct __packed smbios_type0 {
62 	u8 type;
63 	u8 length;
64 	u16 handle;
65 	u8 vendor;
66 	u8 bios_ver;
67 	u16 bios_start_segment;
68 	u8 bios_release_date;
69 	u8 bios_rom_size;
70 	u64 bios_characteristics;
71 	u8 bios_characteristics_ext1;
72 	u8 bios_characteristics_ext2;
73 	u8 bios_major_release;
74 	u8 bios_minor_release;
75 	u8 ec_major_release;
76 	u8 ec_minor_release;
77 	char eos[SMBIOS_STRUCT_EOS_BYTES];
78 };
79 
80 struct __packed smbios_type1 {
81 	u8 type;
82 	u8 length;
83 	u16 handle;
84 	u8 manufacturer;
85 	u8 product_name;
86 	u8 version;
87 	u8 serial_number;
88 	u8 uuid[16];
89 	u8 wakeup_type;
90 	u8 sku_number;
91 	u8 family;
92 	char eos[SMBIOS_STRUCT_EOS_BYTES];
93 };
94 
95 #define SMBIOS_BOARD_FEATURE_HOSTING	(1 << 0)
96 #define SMBIOS_BOARD_MOTHERBOARD	10
97 
98 struct __packed smbios_type2 {
99 	u8 type;
100 	u8 length;
101 	u16 handle;
102 	u8 manufacturer;
103 	u8 product_name;
104 	u8 version;
105 	u8 serial_number;
106 	u8 asset_tag_number;
107 	u8 feature_flags;
108 	u8 chassis_location;
109 	u16 chassis_handle;
110 	u8 board_type;
111 	char eos[SMBIOS_STRUCT_EOS_BYTES];
112 };
113 
114 #define SMBIOS_ENCLOSURE_DESKTOP	3
115 #define SMBIOS_STATE_SAFE		3
116 #define SMBIOS_SECURITY_NONE		3
117 
118 struct __packed smbios_type3 {
119 	u8 type;
120 	u8 length;
121 	u16 handle;
122 	u8 manufacturer;
123 	u8 chassis_type;
124 	u8 version;
125 	u8 serial_number;
126 	u8 asset_tag_number;
127 	u8 bootup_state;
128 	u8 power_supply_state;
129 	u8 thermal_state;
130 	u8 security_status;
131 	u32 oem_defined;
132 	u8 height;
133 	u8 number_of_power_cords;
134 	u8 element_count;
135 	u8 element_record_length;
136 	char eos[SMBIOS_STRUCT_EOS_BYTES];
137 };
138 
139 #define SMBIOS_PROCESSOR_TYPE_CENTRAL	3
140 #define SMBIOS_PROCESSOR_STATUS_ENABLED	1
141 #define SMBIOS_PROCESSOR_UPGRADE_NONE	6
142 
143 #define SMBIOS_PROCESSOR_FAMILY_OTHER	1
144 #define SMBIOS_PROCESSOR_FAMILY_UNKNOWN	2
145 
146 struct __packed smbios_type4 {
147 	u8 type;
148 	u8 length;
149 	u16 handle;
150 	u8 socket_designation;
151 	u8 processor_type;
152 	u8 processor_family;
153 	u8 processor_manufacturer;
154 	u32 processor_id[2];
155 	u8 processor_version;
156 	u8 voltage;
157 	u16 external_clock;
158 	u16 max_speed;
159 	u16 current_speed;
160 	u8 status;
161 	u8 processor_upgrade;
162 	u16 l1_cache_handle;
163 	u16 l2_cache_handle;
164 	u16 l3_cache_handle;
165 	u8 serial_number;
166 	u8 asset_tag;
167 	u8 part_number;
168 	u8 core_count;
169 	u8 core_enabled;
170 	u8 thread_count;
171 	u16 processor_characteristics;
172 	u16 processor_family2;
173 	u16 core_count2;
174 	u16 core_enabled2;
175 	u16 thread_count2;
176 	char eos[SMBIOS_STRUCT_EOS_BYTES];
177 };
178 
179 struct __packed smbios_type32 {
180 	u8 type;
181 	u8 length;
182 	u16 handle;
183 	u8 reserved[6];
184 	u8 boot_status;
185 	u8 eos[SMBIOS_STRUCT_EOS_BYTES];
186 };
187 
188 struct __packed smbios_type127 {
189 	u8 type;
190 	u8 length;
191 	u16 handle;
192 	u8 eos[SMBIOS_STRUCT_EOS_BYTES];
193 };
194 
195 struct __packed smbios_header {
196 	u8 type;
197 	u8 length;
198 	u16 handle;
199 };
200 
201 /**
202  * fill_smbios_header() - Fill the header of an SMBIOS table
203  *
204  * This fills the header of an SMBIOS table structure.
205  *
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
210  */
211 static inline void fill_smbios_header(void *table, int type,
212 				      int length, int handle)
213 {
214 	struct smbios_header *header = table;
215 
216 	header->type = type;
217 	header->length = length - SMBIOS_STRUCT_EOS_BYTES;
218 	header->handle = handle;
219 }
220 
221 /**
222  * Function prototype to write a specific type of SMBIOS structure
223  *
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
227  */
228 typedef int (*smbios_write_type)(ulong *addr, int handle);
229 
230 /**
231  * write_smbios_table() - Write SMBIOS table
232  *
233  * This writes SMBIOS table at a given address.
234  *
235  * @addr:	start address to write SMBIOS table
236  * @return:	end address of SMBIOS table
237  */
238 ulong write_smbios_table(ulong addr);
239 
240 #endif /* _SMBIOS_H_ */
241