blob: 004bcc6166c33e09fc74380356832025af646643 [file] [log] [blame]
Timothy Pearson821217b2015-03-27 22:47:25 -05001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
5 * Copyright (C) various authors, the coreboot project
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Timothy Pearson821217b2015-03-27 22:47:25 -050015 */
16
Sven Schnelle164bcfd2011-08-14 20:56:34 +020017#ifndef SMBIOS_H
18#define SMBIOS_H
19
20#include <types.h>
21
22unsigned long smbios_write_tables(unsigned long start);
23int smbios_add_string(char *start, const char *str);
24int smbios_string_table_len(char *start);
25
Duncan Laurie21a78702013-05-23 14:17:05 -070026/* Used by mainboard to add an on-board device */
27int smbios_write_type41(unsigned long *current, int *handle,
28 const char *name, u8 instance, u16 segment,
29 u8 bus, u8 device, u8 function);
30
Gerd Hoffmann06262742013-11-13 13:37:23 +010031const char *smbios_mainboard_manufacturer(void);
32const char *smbios_mainboard_product_name(void);
Duncan Laurie21a78702013-05-23 14:17:05 -070033
Christian Gmeinerac3aa092012-07-25 13:42:40 +020034const char *smbios_mainboard_serial_number(void);
35const char *smbios_mainboard_version(void);
Gerd Hoffmann06262742013-11-13 13:37:23 +010036void smbios_mainboard_set_uuid(u8 *uuid);
Vladimir Serbinenko63acd222014-06-01 00:26:48 +020037const char *smbios_mainboard_bios_version(void);
Vladimir Serbinenkoa71bdc32014-08-30 00:35:39 +020038u8 smbios_mainboard_enclosure_type(void);
Kane Chen51bdc472014-09-08 18:40:30 -070039#ifdef CONFIG_MAINBOARD_FAMILY
40const char *smbios_mainboard_family(void);
41#endif
Christian Gmeinerac3aa092012-07-25 13:42:40 +020042
Sven Schnelle164bcfd2011-08-14 20:56:34 +020043#define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
44#define BIOS_CHARACTERISTICS_PC_CARD (1 << 8)
45#define BIOS_CHARACTERISTICS_PNP (1 << 9)
46#define BIOS_CHARACTERISTICS_APM (1 << 10)
47#define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11)
48#define BIOS_CHARACTERISTICS_SHADOW (1 << 12)
49#define BIOS_CHARACTERISTICS_BOOT_FROM_CD (1 << 15)
50#define BIOS_CHARACTERISTICS_SELECTABLE_BOOT (1 << 16)
51#define BIOS_CHARACTERISTICS_BIOS_SOCKETED (1 << 17)
52
53#define BIOS_EXT1_CHARACTERISTICS_ACPI (1 << 0)
54#define BIOS_EXT2_CHARACTERISTICS_TARGET (1 << 2)
55
Timothy Pearson821217b2015-03-27 22:47:25 -050056#define BIOS_MEMORY_ECC_SINGLE_BIT_CORRECTING (1 << 3)
57#define BIOS_MEMORY_ECC_DOUBLE_BIT_CORRECTING (1 << 4)
58#define BIOS_MEMORY_ECC_SCRUBBING (1 << 5)
59
60#define MEMORY_TYPE_DETAIL_OTHER (1 << 1)
61#define MEMORY_TYPE_DETAIL_UNKNOWN (1 << 2)
62#define MEMORY_TYPE_DETAIL_FAST_PAGED (1 << 3)
63#define MEMORY_TYPE_DETAIL_STATIC_COLUMN (1 << 4)
64#define MEMORY_TYPE_DETAIL_PSEUDO_STATIC (1 << 5)
65#define MEMORY_TYPE_DETAIL_RAMBUS (1 << 6)
66#define MEMORY_TYPE_DETAIL_SYNCHRONOUS (1 << 7)
67#define MEMORY_TYPE_DETAIL_CMOS (1 << 8)
68#define MEMORY_TYPE_DETAIL_EDO (1 << 9)
69#define MEMORY_TYPE_DETAIL_WINDOW_DRAM (1 << 10)
70#define MEMORY_TYPE_DETAIL_CACHE_DRAM (1 << 11)
71#define MEMORY_TYPE_DETAIL_NON_VOLATILE (1 << 12)
72#define MEMORY_TYPE_DETAIL_REGISTERED (1 << 13)
73#define MEMORY_TYPE_DETAIL_UNBUFFERED (1 << 14)
74
Kane Chen33faac62014-07-27 12:54:44 -070075typedef enum {
Lee Leahy0be6d932015-06-26 11:15:42 -070076 MEMORY_BUS_WIDTH_8 = 0,
77 MEMORY_BUS_WIDTH_16 = 1,
78 MEMORY_BUS_WIDTH_32 = 2,
79 MEMORY_BUS_WIDTH_64 = 3,
80 MEMORY_BUS_WIDTH_128 = 4,
81 MEMORY_BUS_WIDTH_256 = 5,
82 MEMORY_BUS_WIDTH_512 = 6,
83 MEMORY_BUS_WIDTH_1024 = 7,
84 MEMORY_BUS_WIDTH_MAX = 7,
85} smbios_memory_bus_width;
86
87typedef enum {
88 MEMORY_DEVICE_OTHER = 0x01,
89 MEMORY_DEVICE_UNKNOWN = 0x02,
90 MEMORY_DEVICE_DRAM = 0x03,
91 MEMORY_DEVICE_EDRAM = 0x04,
92 MEMORY_DEVICE_VRAM = 0x05,
93 MEMORY_DEVICE_SRAM = 0x06,
94 MEMORY_DEVICE_RAM = 0x07,
95 MEMORY_DEVICE_ROM = 0x08,
96 MEMORY_DEVICE_FLASH = 0x09,
97 MEMORY_DEVICE_EEPROM = 0x0A,
98 MEMORY_DEVICE_FEPROM = 0x0B,
99 MEMORY_DEVICE_EPROM = 0x0C,
100 MEMORY_DEVICE_CDRAM = 0x0D,
101 MEMORY_DEVICE_3DRAM = 0x0E,
102 MEMORY_DEVICE_SDRAM = 0x0F,
103 MEMORY_DEVICE_SGRAM = 0x10,
104 MEMORY_DEVICE_RDRAM = 0x11,
105 MEMORY_DEVICE_DDR = 0x12,
106 MEMORY_DEVICE_DDR2 = 0x13,
107 MEMORY_DEVICE_DDR2_FB_DIMM = 0x14,
108 MEMORY_DEVICE_DDR3 = 0x18,
109 MEMORY_DEVICE_DBD2 = 0x19,
110 MEMORY_DEVICE_DDR4 = 0x1A,
111 MEMORY_DEVICE_LPDDR = 0x1B,
112 MEMORY_DEVICE_LPDDR2 = 0x1C,
113 MEMORY_DEVICE_LPDDR3 = 0x1D,
114 MEMORY_DEVICE_LPDDR4 = 0x1E,
115} smbios_memory_device_type;
116
117typedef enum {
Kane Chen33faac62014-07-27 12:54:44 -0700118 MEMORY_FORMFACTOR_OTHER = 0x01,
119 MEMORY_FORMFACTOR_UNKNOWN = 0x02,
120 MEMORY_FORMFACTOR_SIMM = 0x03,
121 MEMORY_FORMFACTOR_SIP = 0x04,
122 MEMORY_FORMFACTOR_CHIP = 0x05,
123 MEMORY_FORMFACTOR_DIP = 0x06,
124 MEMORY_FORMFACTOR_ZIP = 0x07,
125 MEMORY_FORMFACTOR_PROPRIETARY_CARD = 0x08,
126 MEMORY_FORMFACTOR_DIMM = 0x09,
127 MEMORY_FORMFACTOR_TSOP = 0x0a,
128 MEMORY_FORMFACTOR_ROC = 0x0b,
129 MEMORY_FORMFACTOR_RIMM = 0x0c,
130 MEMORY_FORMFACTOR_SODIMM = 0x0d,
131 MEMORY_FORMFACTOR_SRIMM = 0x0e,
132 MEMORY_FORMFACTOR_FBDIMM = 0x0f,
133} smbios_memory_form_factor;
134
Timothy Pearson821217b2015-03-27 22:47:25 -0500135typedef enum {
136 MEMORY_TYPE_OTHER = 0x01,
137 MEMORY_TYPE_UNKNOWN = 0x02,
138 MEMORY_TYPE_DRAM = 0x03,
139 MEMORY_TYPE_EDRAM = 0x04,
140 MEMORY_TYPE_VRAM = 0x05,
141 MEMORY_TYPE_SRAM = 0x06,
142 MEMORY_TYPE_RAM = 0x07,
143 MEMORY_TYPE_ROM = 0x08,
144 MEMORY_TYPE_FLASH = 0x09,
145 MEMORY_TYPE_EEPROM = 0x0a,
146 MEMORY_TYPE_FEPROM = 0x0b,
147 MEMORY_TYPE_EPROM = 0x0c,
148 MEMORY_TYPE_CDRAM = 0x0d,
149 MEMORY_TYPE_3DRAM = 0x0e,
150 MEMORY_TYPE_SDRAM = 0x0f,
151 MEMORY_TYPE_SGRAM = 0x10,
152 MEMORY_TYPE_RDRAM = 0x11,
153 MEMORY_TYPE_DDR = 0x12,
154 MEMORY_TYPE_DDR2 = 0x13,
155 MEMORY_TYPE_DDR2_FBDIMM = 0x14,
156 MEMORY_TYPE_DDR3 = 0x18,
157 MEMORY_TYPE_FBD2 = 0x19,
158} smbios_memory_type;
159
160typedef enum {
161 MEMORY_ARRAY_LOCATION_OTHER = 0x01,
162 MEMORY_ARRAY_LOCATION_UNKNOWN = 0x02,
163 MEMORY_ARRAY_LOCATION_SYSTEM_BOARD = 0x03,
164 MEMORY_ARRAY_LOCATION_ISA_ADD_ON = 0x04,
165 MEMORY_ARRAY_LOCATION_EISA_ADD_ON = 0x05,
166 MEMORY_ARRAY_LOCATION_PCI_ADD_ON = 0x06,
167 MEMORY_ARRAY_LOCATION_MCA_ADD_ON = 0x07,
168 MEMORY_ARRAY_LOCATION_PCMCIA_ADD_ON = 0x08,
169 MEMORY_ARRAY_LOCATION_PROPRIETARY_ADD_ON = 0x09,
170 MEMORY_ARRAY_LOCATION_NUBUS = 0x0a,
171 MEMORY_ARRAY_LOCATION_PC_98_C20_ADD_ON = 0xa0,
172 MEMORY_ARRAY_LOCATION_PC_98_C24_ADD_ON = 0xa1,
173 MEMORY_ARRAY_LOCATION_PC_98_E_ADD_ON = 0xa2,
174 MEMORY_ARRAY_LOCATION_PC_98_LOCAL_BUS_ADD_ON = 0xa3,
175} smbios_memory_array_location;
176
177typedef enum {
178 MEMORY_ARRAY_USE_OTHER = 0x01,
179 MEMORY_ARRAY_USE_UNKNOWN = 0x02,
180 MEMORY_ARRAY_USE_SYSTEM = 0x03,
181 MEMORY_ARRAY_USE_VIDEO = 0x04,
182 MEMORY_ARRAY_USE_FLASH = 0x05,
183 MEMORY_ARRAY_USE_NVRAM = 0x06,
184 MEMORY_ARRAY_USE_CACHE = 0x07,
185} smbios_memory_array_use;
186
187typedef enum {
188 MEMORY_ARRAY_ECC_OTHER = 0x01,
189 MEMORY_ARRAY_ECC_UNKNOWN = 0x02,
190 MEMORY_ARRAY_ECC_NONE = 0x03,
191 MEMORY_ARRAY_ECC_PARITY = 0x04,
192 MEMORY_ARRAY_ECC_SINGLE_BIT = 0x05,
193 MEMORY_ARRAY_ECC_MULTI_BIT = 0x06,
194 MEMORY_ARRAY_ECC_CRC = 0x07,
195} smbios_memory_array_ecc;
196
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200197#define SMBIOS_STATE_SAFE 3
198typedef enum {
199 SMBIOS_BIOS_INFORMATION=0,
200 SMBIOS_SYSTEM_INFORMATION=1,
Vladimir Serbinenko47089f22014-03-02 19:14:44 +0100201 SMBIOS_BOARD_INFORMATION=2,
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200202 SMBIOS_SYSTEM_ENCLOSURE=3,
203 SMBIOS_PROCESSOR_INFORMATION=4,
204 SMBIOS_CACHE_INFORMATION=7,
205 SMBIOS_SYSTEM_SLOTS=9,
Peter Stugec392b642013-07-06 19:51:12 +0200206 SMBIOS_OEM_STRINGS=11,
Duncan Laurie472ec9c2012-06-23 16:13:42 -0700207 SMBIOS_EVENT_LOG=15,
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200208 SMBIOS_PHYS_MEMORY_ARRAY=16,
209 SMBIOS_MEMORY_DEVICE=17,
210 SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS=19,
211 SMBIOS_SYSTEM_BOOT_INFORMATION=32,
Stefan Reinauer3d7c6772012-04-02 13:30:10 -0700212 SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION=41,
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200213 SMBIOS_END_OF_TABLE=127,
214} smbios_struct_type_t;
215
216struct smbios_entry {
217 u8 anchor[4];
218 u8 checksum;
219 u8 length;
220 u8 major_version;
221 u8 minor_version;
222 u16 max_struct_size;
223 u8 entry_point_rev;
224 u8 formwatted_area[5];
225 u8 intermediate_anchor_string[5];
226 u8 intermediate_checksum;
227 u16 struct_table_length;
228 u32 struct_table_address;
229 u16 struct_count;
230 u8 smbios_bcd_revision;
231} __attribute__((packed));
232
233struct smbios_type0 {
234 u8 type;
235 u8 length;
236 u16 handle;
237 u8 vendor;
238 u8 bios_version;
239 u16 bios_start_segment;
240 u8 bios_release_date;
241 u8 bios_rom_size;
242 u64 bios_characteristics;
243 u8 bios_characteristics_ext1;
244 u8 bios_characteristics_ext2;
245 u8 system_bios_major_release;
246 u8 system_bios_minor_release;
247 u8 ec_major_release;
248 u8 ec_minor_release;
249 char eos[2];
250} __attribute__((packed));
251
252struct smbios_type1 {
253 u8 type;
254 u8 length;
255 u16 handle;
256 u8 manufacturer;
257 u8 product_name;
258 u8 version;
259 u8 serial_number;
260 u8 uuid[16];
261 u8 wakeup_type;
262 u8 sku;
263 u8 family;
264 char eos[2];
265} __attribute__((packed));
266
Vladimir Serbinenko47089f22014-03-02 19:14:44 +0100267struct smbios_type2 {
268 u8 type;
269 u8 length;
270 u16 handle;
271 u8 manufacturer;
272 u8 product_name;
273 u8 version;
274 u8 serial_number;
275 char eos[2];
276} __attribute__((packed));
277
Vladimir Serbinenko71c0bf62014-08-27 23:23:14 +0200278enum
279{
280 SMBIOS_ENCLOSURE_DESKTOP = 3,
281 SMBIOS_ENCLOSURE_NOTEBOOK = 9,
282};
283
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200284struct smbios_type3 {
285 u8 type;
286 u8 length;
287 u16 handle;
288 u8 manufacturer;
289 u8 _type;
290 u8 version;
291 u8 serial_number;
292 u8 asset_tag_number;
293 u8 bootup_state;
294 u8 power_supply_state;
295 u8 thermal_state;
296 u8 security_status;
297 u32 oem_defined;
298 u8 height;
299 u8 number_of_power_cords;
300 u8 element_count;
301 u8 element_record_length;
302 char eos[2];
303} __attribute__((packed));
304
305struct smbios_type4 {
306 u8 type;
307 u8 length;
308 u16 handle;
309 u8 socket_designation;
310 u8 processor_type;
311 u8 processor_family;
312 u8 processor_manufacturer;
313 u32 processor_id[2];
314 u8 processor_version;
315 u8 voltage;
316 u16 external_clock;
317 u16 max_speed;
318 u16 current_speed;
319 u8 status;
320 u8 processor_upgrade;
321 u16 l1_cache_handle;
322 u16 l2_cache_handle;
323 u16 l3_cache_handle;
324 u8 serial_number;
325 u8 asset_tag;
326 u8 part_number;
327 u8 core_count;
328 u8 core_enabled;
329 u8 thread_count;
330 u16 processor_characteristics;
331 u16 processor_family2;
332 char eos[2];
333} __attribute__((packed));
334
Peter Stugec392b642013-07-06 19:51:12 +0200335struct smbios_type11 {
336 u8 type;
337 u8 length;
338 u16 handle;
339 u8 count;
340 char eos[2];
341} __attribute__((packed));
342
Duncan Laurie472ec9c2012-06-23 16:13:42 -0700343struct smbios_type15 {
344 u8 type;
345 u8 length;
346 u16 handle;
347 u16 area_length;
348 u16 header_offset;
349 u16 data_offset;
350 u8 access_method;
351 u8 log_status;
352 u32 change_token;
353 u32 address;
354 u8 header_format;
355 u8 log_type_descriptors;
356 u8 log_type_descriptor_length;
357 char eos[2];
358} __attribute__((packed));
359
360enum {
361 SMBIOS_EVENTLOG_ACCESS_METHOD_IO8 = 0,
362 SMBIOS_EVENTLOG_ACCESS_METHOD_IO8X2,
363 SMBIOS_EVENTLOG_ACCESS_METHOD_IO16,
364 SMBIOS_EVENTLOG_ACCESS_METHOD_MMIO32,
365 SMBIOS_EVENTLOG_ACCESS_METHOD_GPNV,
366};
367
368enum {
369 SMBIOS_EVENTLOG_STATUS_VALID = 1, /* Bit 0 */
370 SMBIOS_EVENTLOG_STATUS_FULL = 2, /* Bit 1 */
371};
372
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200373struct smbios_type16 {
374 u8 type;
375 u8 length;
376 u16 handle;
377 u8 location;
378 u8 use;
379 u8 memory_error_correction;
380 u32 maximum_capacity;
381 u16 memory_error_information_handle;
382 u16 number_of_memory_devices;
383 u64 extended_maximum_capacity;
384 char eos[2];
385} __attribute__((packed));
386
387struct smbios_type17 {
388 u8 type;
389 u8 length;
390 u16 handle;
391 u16 phys_memory_array_handle;
392 u16 memory_error_information_handle;
393 u16 total_width;
394 u16 data_width;
395 u16 size;
396 u8 form_factor;
397 u8 device_set;
398 u8 device_locator;
399 u8 bank_locator;
400 u8 memory_type;
401 u16 type_detail;
402 u16 speed;
403 u8 manufacturer;
404 u8 serial_number;
405 u8 asset_tag;
406 u8 part_number;
407 u8 attributes;
Timothy Pearson964aa832015-09-05 19:00:34 -0500408 u32 extended_size;
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200409 u16 clock_speed;
Timothy Pearson964aa832015-09-05 19:00:34 -0500410 u16 minimum_voltage;
411 u16 maximum_voltage;
412 u16 configured_voltage;
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200413 char eos[2];
414} __attribute__((packed));
415
416struct smbios_type32 {
417 u8 type;
418 u8 length;
419 u16 handle;
420 u8 reserved[6];
421 u8 boot_status;
422 u8 eos[2];
423} __attribute__((packed));
424
Sven Schnelle6d038762012-07-09 08:52:53 +0200425struct smbios_type38 {
426 u8 type;
427 u8 length;
428 u16 handle;
429 u8 interface_type;
430 u8 ipmi_rev;
431 u8 i2c_slave_addr;
432 u8 nv_storage_addr;
433 u64 base_address;
434 u8 base_address_modifier;
435 u8 irq;
436} __attribute__((packed));
437
Stefan Reinauer3d7c6772012-04-02 13:30:10 -0700438typedef enum {
439 SMBIOS_DEVICE_TYPE_OTHER = 0x01,
440 SMBIOS_DEVICE_TYPE_UNKNOWN,
441 SMBIOS_DEVICE_TYPE_VIDEO,
442 SMBIOS_DEVICE_TYPE_SCSI,
443 SMBIOS_DEVICE_TYPE_ETHERNET,
444 SMBIOS_DEVICE_TYPE_TOKEN_RING,
445 SMBIOS_DEVICE_TYPE_SOUND,
446 SMBIOS_DEVICE_TYPE_PATA,
447 SMBIOS_DEVICE_TYPE_SATA,
448 SMBIOS_DEVICE_TYPE_SAS,
449} smbios_onboard_device_type;
450
451struct smbios_type41 {
452 u8 type;
453 u8 length;
454 u16 handle;
455 u8 reference_designation;
456 u8 device_type: 7;
457 u8 device_status: 1;
458 u8 device_type_instance;
459 u16 segment_group_number;
460 u8 bus_number;
461 u8 function_number: 3;
462 u8 device_number: 5;
463 char eos[2];
464} __attribute__((packed));
465
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200466struct smbios_type127 {
467 u8 type;
468 u8 length;
469 u16 handle;
470 u8 eos[2];
471} __attribute__((packed));
472
Timothy Pearson4785f2a2015-03-27 23:05:36 -0500473void smbios_fill_dimm_manufacturer_from_id(uint16_t mod_id, struct smbios_type17 *t);
474
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200475#endif