1
2
3
4
5
6
7
8#ifndef _SMBIOS_H_
9#define _SMBIOS_H_
10
11#include <dm/ofnode.h>
12
13
14#define SMBIOS_MAJOR_VER 3
15#define SMBIOS_MINOR_VER 0
16
17enum {
18 SMBIOS_STR_MAX = 64,
19};
20
21
22enum {
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
35};
36
37#define SMBIOS_INTERMEDIATE_OFFSET 16
38#define SMBIOS_STRUCT_EOS_BYTES 2
39
40struct __packed smbios_entry {
41 u8 anchor[4];
42 u8 checksum;
43 u8 length;
44 u8 major_ver;
45 u8 minor_ver;
46 u16 max_struct_size;
47 u8 entry_point_rev;
48 u8 formatted_area[5];
49 u8 intermediate_anchor[5];
50 u8 intermediate_checksum;
51 u16 struct_table_length;
52 u32 struct_table_address;
53 u16 struct_count;
54 u8 bcd_rev;
55};
56
57
58#define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
59#define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11)
60#define BIOS_CHARACTERISTICS_SELECTABLE_BOOT (1 << 16)
61
62#define BIOS_CHARACTERISTICS_EXT1_ACPI (1 << 0)
63#define BIOS_CHARACTERISTICS_EXT2_UEFI (1 << 3)
64#define BIOS_CHARACTERISTICS_EXT2_TARGET (1 << 2)
65
66struct __packed smbios_type0 {
67 u8 type;
68 u8 length;
69 u16 handle;
70 u8 vendor;
71 u8 bios_ver;
72 u16 bios_start_segment;
73 u8 bios_release_date;
74 u8 bios_rom_size;
75 u64 bios_characteristics;
76 u8 bios_characteristics_ext1;
77 u8 bios_characteristics_ext2;
78 u8 bios_major_release;
79 u8 bios_minor_release;
80 u8 ec_major_release;
81 u8 ec_minor_release;
82 char eos[SMBIOS_STRUCT_EOS_BYTES];
83};
84
85struct __packed smbios_type1 {
86 u8 type;
87 u8 length;
88 u16 handle;
89 u8 manufacturer;
90 u8 product_name;
91 u8 version;
92 u8 serial_number;
93 u8 uuid[16];
94 u8 wakeup_type;
95 u8 sku_number;
96 u8 family;
97 char eos[SMBIOS_STRUCT_EOS_BYTES];
98};
99
100#define SMBIOS_BOARD_FEATURE_HOSTING (1 << 0)
101#define SMBIOS_BOARD_MOTHERBOARD 10
102
103struct __packed smbios_type2 {
104 u8 type;
105 u8 length;
106 u16 handle;
107 u8 manufacturer;
108 u8 product_name;
109 u8 version;
110 u8 serial_number;
111 u8 asset_tag_number;
112 u8 feature_flags;
113 u8 chassis_location;
114 u16 chassis_handle;
115 u8 board_type;
116 char eos[SMBIOS_STRUCT_EOS_BYTES];
117};
118
119#define SMBIOS_ENCLOSURE_DESKTOP 3
120#define SMBIOS_STATE_SAFE 3
121#define SMBIOS_SECURITY_NONE 3
122
123struct __packed smbios_type3 {
124 u8 type;
125 u8 length;
126 u16 handle;
127 u8 manufacturer;
128 u8 chassis_type;
129 u8 version;
130 u8 serial_number;
131 u8 asset_tag_number;
132 u8 bootup_state;
133 u8 power_supply_state;
134 u8 thermal_state;
135 u8 security_status;
136 u32 oem_defined;
137 u8 height;
138 u8 number_of_power_cords;
139 u8 element_count;
140 u8 element_record_length;
141 char eos[SMBIOS_STRUCT_EOS_BYTES];
142};
143
144#define SMBIOS_PROCESSOR_TYPE_CENTRAL 3
145#define SMBIOS_PROCESSOR_STATUS_ENABLED 1
146#define SMBIOS_PROCESSOR_UPGRADE_NONE 6
147
148#define SMBIOS_PROCESSOR_FAMILY_OTHER 1
149#define SMBIOS_PROCESSOR_FAMILY_UNKNOWN 2
150
151struct __packed smbios_type4 {
152 u8 type;
153 u8 length;
154 u16 handle;
155 u8 socket_designation;
156 u8 processor_type;
157 u8 processor_family;
158 u8 processor_manufacturer;
159 u32 processor_id[2];
160 u8 processor_version;
161 u8 voltage;
162 u16 external_clock;
163 u16 max_speed;
164 u16 current_speed;
165 u8 status;
166 u8 processor_upgrade;
167 u16 l1_cache_handle;
168 u16 l2_cache_handle;
169 u16 l3_cache_handle;
170 u8 serial_number;
171 u8 asset_tag;
172 u8 part_number;
173 u8 core_count;
174 u8 core_enabled;
175 u8 thread_count;
176 u16 processor_characteristics;
177 u16 processor_family2;
178 u16 core_count2;
179 u16 core_enabled2;
180 u16 thread_count2;
181 char eos[SMBIOS_STRUCT_EOS_BYTES];
182};
183
184struct __packed smbios_type32 {
185 u8 type;
186 u8 length;
187 u16 handle;
188 u8 reserved[6];
189 u8 boot_status;
190 char eos[SMBIOS_STRUCT_EOS_BYTES];
191};
192
193struct __packed smbios_type127 {
194 u8 type;
195 u8 length;
196 u16 handle;
197 char eos[SMBIOS_STRUCT_EOS_BYTES];
198};
199
200struct __packed smbios_header {
201 u8 type;
202 u8 length;
203 u16 handle;
204};
205
206
207
208
209
210
211
212
213
214
215
216static inline void fill_smbios_header(void *table, int type,
217 int length, int handle)
218{
219 struct smbios_header *header = table;
220
221 header->type = type;
222 header->length = length - SMBIOS_STRUCT_EOS_BYTES;
223 header->handle = handle;
224}
225
226
227
228
229
230
231
232
233
234
235
236
237
238ulong write_smbios_table(ulong addr);
239
240
241
242
243
244
245
246
247const struct smbios_entry *smbios_entry(u64 address, u32 size);
248
249
250
251
252
253
254
255
256const struct smbios_header *smbios_header(const struct smbios_entry *entry, int type);
257
258
259
260
261
262
263
264
265char *smbios_string(const struct smbios_header *header, int index);
266
267
268
269
270
271
272
273
274
275
276
277int smbios_update_version(const char *version);
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293int smbios_update_version_full(void *smbios_tab, const char *version);
294
295
296
297
298
299
300
301
302
303
304
305void smbios_prepare_measurement(const struct smbios_entry *entry,
306 struct smbios_header *header);
307
308#endif
309