blob: 96d9bea44206fd4bf88951d37f2e39982cd89fdf [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);
Kyösti Mälkkic5b758b2016-05-30 16:52:31 +030038const char *smbios_mainboard_sku(void);
Vladimir Serbinenkoa71bdc32014-08-30 00:35:39 +020039u8 smbios_mainboard_enclosure_type(void);
Kane Chen51bdc472014-09-08 18:40:30 -070040#ifdef CONFIG_MAINBOARD_FAMILY
41const char *smbios_mainboard_family(void);
42#endif
Christian Gmeinerac3aa092012-07-25 13:42:40 +020043
Sven Schnelle164bcfd2011-08-14 20:56:34 +020044#define BIOS_CHARACTERISTICS_PCI_SUPPORTED (1 << 7)
45#define BIOS_CHARACTERISTICS_PC_CARD (1 << 8)
46#define BIOS_CHARACTERISTICS_PNP (1 << 9)
47#define BIOS_CHARACTERISTICS_APM (1 << 10)
48#define BIOS_CHARACTERISTICS_UPGRADEABLE (1 << 11)
49#define BIOS_CHARACTERISTICS_SHADOW (1 << 12)
50#define BIOS_CHARACTERISTICS_BOOT_FROM_CD (1 << 15)
51#define BIOS_CHARACTERISTICS_SELECTABLE_BOOT (1 << 16)
52#define BIOS_CHARACTERISTICS_BIOS_SOCKETED (1 << 17)
53
54#define BIOS_EXT1_CHARACTERISTICS_ACPI (1 << 0)
55#define BIOS_EXT2_CHARACTERISTICS_TARGET (1 << 2)
56
Timothy Pearson821217b2015-03-27 22:47:25 -050057#define BIOS_MEMORY_ECC_SINGLE_BIT_CORRECTING (1 << 3)
58#define BIOS_MEMORY_ECC_DOUBLE_BIT_CORRECTING (1 << 4)
59#define BIOS_MEMORY_ECC_SCRUBBING (1 << 5)
60
61#define MEMORY_TYPE_DETAIL_OTHER (1 << 1)
62#define MEMORY_TYPE_DETAIL_UNKNOWN (1 << 2)
63#define MEMORY_TYPE_DETAIL_FAST_PAGED (1 << 3)
64#define MEMORY_TYPE_DETAIL_STATIC_COLUMN (1 << 4)
65#define MEMORY_TYPE_DETAIL_PSEUDO_STATIC (1 << 5)
66#define MEMORY_TYPE_DETAIL_RAMBUS (1 << 6)
67#define MEMORY_TYPE_DETAIL_SYNCHRONOUS (1 << 7)
68#define MEMORY_TYPE_DETAIL_CMOS (1 << 8)
69#define MEMORY_TYPE_DETAIL_EDO (1 << 9)
70#define MEMORY_TYPE_DETAIL_WINDOW_DRAM (1 << 10)
71#define MEMORY_TYPE_DETAIL_CACHE_DRAM (1 << 11)
72#define MEMORY_TYPE_DETAIL_NON_VOLATILE (1 << 12)
73#define MEMORY_TYPE_DETAIL_REGISTERED (1 << 13)
74#define MEMORY_TYPE_DETAIL_UNBUFFERED (1 << 14)
75
Kane Chen33faac62014-07-27 12:54:44 -070076typedef enum {
Lee Leahy0be6d932015-06-26 11:15:42 -070077 MEMORY_BUS_WIDTH_8 = 0,
78 MEMORY_BUS_WIDTH_16 = 1,
79 MEMORY_BUS_WIDTH_32 = 2,
80 MEMORY_BUS_WIDTH_64 = 3,
81 MEMORY_BUS_WIDTH_128 = 4,
82 MEMORY_BUS_WIDTH_256 = 5,
83 MEMORY_BUS_WIDTH_512 = 6,
84 MEMORY_BUS_WIDTH_1024 = 7,
85 MEMORY_BUS_WIDTH_MAX = 7,
86} smbios_memory_bus_width;
87
88typedef enum {
89 MEMORY_DEVICE_OTHER = 0x01,
90 MEMORY_DEVICE_UNKNOWN = 0x02,
91 MEMORY_DEVICE_DRAM = 0x03,
92 MEMORY_DEVICE_EDRAM = 0x04,
93 MEMORY_DEVICE_VRAM = 0x05,
94 MEMORY_DEVICE_SRAM = 0x06,
95 MEMORY_DEVICE_RAM = 0x07,
96 MEMORY_DEVICE_ROM = 0x08,
97 MEMORY_DEVICE_FLASH = 0x09,
98 MEMORY_DEVICE_EEPROM = 0x0A,
99 MEMORY_DEVICE_FEPROM = 0x0B,
100 MEMORY_DEVICE_EPROM = 0x0C,
101 MEMORY_DEVICE_CDRAM = 0x0D,
102 MEMORY_DEVICE_3DRAM = 0x0E,
103 MEMORY_DEVICE_SDRAM = 0x0F,
104 MEMORY_DEVICE_SGRAM = 0x10,
105 MEMORY_DEVICE_RDRAM = 0x11,
106 MEMORY_DEVICE_DDR = 0x12,
107 MEMORY_DEVICE_DDR2 = 0x13,
108 MEMORY_DEVICE_DDR2_FB_DIMM = 0x14,
109 MEMORY_DEVICE_DDR3 = 0x18,
110 MEMORY_DEVICE_DBD2 = 0x19,
111 MEMORY_DEVICE_DDR4 = 0x1A,
112 MEMORY_DEVICE_LPDDR = 0x1B,
113 MEMORY_DEVICE_LPDDR2 = 0x1C,
114 MEMORY_DEVICE_LPDDR3 = 0x1D,
115 MEMORY_DEVICE_LPDDR4 = 0x1E,
116} smbios_memory_device_type;
117
118typedef enum {
Kane Chen33faac62014-07-27 12:54:44 -0700119 MEMORY_FORMFACTOR_OTHER = 0x01,
120 MEMORY_FORMFACTOR_UNKNOWN = 0x02,
121 MEMORY_FORMFACTOR_SIMM = 0x03,
122 MEMORY_FORMFACTOR_SIP = 0x04,
123 MEMORY_FORMFACTOR_CHIP = 0x05,
124 MEMORY_FORMFACTOR_DIP = 0x06,
125 MEMORY_FORMFACTOR_ZIP = 0x07,
126 MEMORY_FORMFACTOR_PROPRIETARY_CARD = 0x08,
127 MEMORY_FORMFACTOR_DIMM = 0x09,
128 MEMORY_FORMFACTOR_TSOP = 0x0a,
129 MEMORY_FORMFACTOR_ROC = 0x0b,
130 MEMORY_FORMFACTOR_RIMM = 0x0c,
131 MEMORY_FORMFACTOR_SODIMM = 0x0d,
132 MEMORY_FORMFACTOR_SRIMM = 0x0e,
133 MEMORY_FORMFACTOR_FBDIMM = 0x0f,
134} smbios_memory_form_factor;
135
Timothy Pearson821217b2015-03-27 22:47:25 -0500136typedef enum {
137 MEMORY_TYPE_OTHER = 0x01,
138 MEMORY_TYPE_UNKNOWN = 0x02,
139 MEMORY_TYPE_DRAM = 0x03,
140 MEMORY_TYPE_EDRAM = 0x04,
141 MEMORY_TYPE_VRAM = 0x05,
142 MEMORY_TYPE_SRAM = 0x06,
143 MEMORY_TYPE_RAM = 0x07,
144 MEMORY_TYPE_ROM = 0x08,
145 MEMORY_TYPE_FLASH = 0x09,
146 MEMORY_TYPE_EEPROM = 0x0a,
147 MEMORY_TYPE_FEPROM = 0x0b,
148 MEMORY_TYPE_EPROM = 0x0c,
149 MEMORY_TYPE_CDRAM = 0x0d,
150 MEMORY_TYPE_3DRAM = 0x0e,
151 MEMORY_TYPE_SDRAM = 0x0f,
152 MEMORY_TYPE_SGRAM = 0x10,
153 MEMORY_TYPE_RDRAM = 0x11,
154 MEMORY_TYPE_DDR = 0x12,
155 MEMORY_TYPE_DDR2 = 0x13,
156 MEMORY_TYPE_DDR2_FBDIMM = 0x14,
157 MEMORY_TYPE_DDR3 = 0x18,
158 MEMORY_TYPE_FBD2 = 0x19,
159} smbios_memory_type;
160
161typedef enum {
162 MEMORY_ARRAY_LOCATION_OTHER = 0x01,
163 MEMORY_ARRAY_LOCATION_UNKNOWN = 0x02,
164 MEMORY_ARRAY_LOCATION_SYSTEM_BOARD = 0x03,
165 MEMORY_ARRAY_LOCATION_ISA_ADD_ON = 0x04,
166 MEMORY_ARRAY_LOCATION_EISA_ADD_ON = 0x05,
167 MEMORY_ARRAY_LOCATION_PCI_ADD_ON = 0x06,
168 MEMORY_ARRAY_LOCATION_MCA_ADD_ON = 0x07,
169 MEMORY_ARRAY_LOCATION_PCMCIA_ADD_ON = 0x08,
170 MEMORY_ARRAY_LOCATION_PROPRIETARY_ADD_ON = 0x09,
171 MEMORY_ARRAY_LOCATION_NUBUS = 0x0a,
172 MEMORY_ARRAY_LOCATION_PC_98_C20_ADD_ON = 0xa0,
173 MEMORY_ARRAY_LOCATION_PC_98_C24_ADD_ON = 0xa1,
174 MEMORY_ARRAY_LOCATION_PC_98_E_ADD_ON = 0xa2,
175 MEMORY_ARRAY_LOCATION_PC_98_LOCAL_BUS_ADD_ON = 0xa3,
176} smbios_memory_array_location;
177
178typedef enum {
179 MEMORY_ARRAY_USE_OTHER = 0x01,
180 MEMORY_ARRAY_USE_UNKNOWN = 0x02,
181 MEMORY_ARRAY_USE_SYSTEM = 0x03,
182 MEMORY_ARRAY_USE_VIDEO = 0x04,
183 MEMORY_ARRAY_USE_FLASH = 0x05,
184 MEMORY_ARRAY_USE_NVRAM = 0x06,
185 MEMORY_ARRAY_USE_CACHE = 0x07,
186} smbios_memory_array_use;
187
188typedef enum {
189 MEMORY_ARRAY_ECC_OTHER = 0x01,
190 MEMORY_ARRAY_ECC_UNKNOWN = 0x02,
191 MEMORY_ARRAY_ECC_NONE = 0x03,
192 MEMORY_ARRAY_ECC_PARITY = 0x04,
193 MEMORY_ARRAY_ECC_SINGLE_BIT = 0x05,
194 MEMORY_ARRAY_ECC_MULTI_BIT = 0x06,
195 MEMORY_ARRAY_ECC_CRC = 0x07,
196} smbios_memory_array_ecc;
197
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200198#define SMBIOS_STATE_SAFE 3
199typedef enum {
Elyes HAOUASa0fed372016-09-16 20:17:40 +0200200 SMBIOS_BIOS_INFORMATION = 0,
201 SMBIOS_SYSTEM_INFORMATION = 1,
202 SMBIOS_BOARD_INFORMATION = 2,
203 SMBIOS_SYSTEM_ENCLOSURE = 3,
204 SMBIOS_PROCESSOR_INFORMATION = 4,
205 SMBIOS_CACHE_INFORMATION = 7,
206 SMBIOS_SYSTEM_SLOTS = 9,
207 SMBIOS_OEM_STRINGS = 11,
208 SMBIOS_EVENT_LOG = 15,
209 SMBIOS_PHYS_MEMORY_ARRAY = 16,
210 SMBIOS_MEMORY_DEVICE = 17,
211 SMBIOS_MEMORY_ARRAY_MAPPED_ADDRESS = 19,
212 SMBIOS_SYSTEM_BOOT_INFORMATION = 32,
213 SMBIOS_ONBOARD_DEVICES_EXTENDED_INFORMATION = 41,
214 SMBIOS_END_OF_TABLE = 127,
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200215} smbios_struct_type_t;
216
217struct smbios_entry {
218 u8 anchor[4];
219 u8 checksum;
220 u8 length;
221 u8 major_version;
222 u8 minor_version;
223 u16 max_struct_size;
224 u8 entry_point_rev;
225 u8 formwatted_area[5];
226 u8 intermediate_anchor_string[5];
227 u8 intermediate_checksum;
228 u16 struct_table_length;
229 u32 struct_table_address;
230 u16 struct_count;
231 u8 smbios_bcd_revision;
232} __attribute__((packed));
233
234struct smbios_type0 {
235 u8 type;
236 u8 length;
237 u16 handle;
238 u8 vendor;
239 u8 bios_version;
240 u16 bios_start_segment;
241 u8 bios_release_date;
242 u8 bios_rom_size;
243 u64 bios_characteristics;
244 u8 bios_characteristics_ext1;
245 u8 bios_characteristics_ext2;
246 u8 system_bios_major_release;
247 u8 system_bios_minor_release;
248 u8 ec_major_release;
249 u8 ec_minor_release;
250 char eos[2];
251} __attribute__((packed));
252
253struct smbios_type1 {
254 u8 type;
255 u8 length;
256 u16 handle;
257 u8 manufacturer;
258 u8 product_name;
259 u8 version;
260 u8 serial_number;
261 u8 uuid[16];
262 u8 wakeup_type;
263 u8 sku;
264 u8 family;
265 char eos[2];
266} __attribute__((packed));
267
Vladimir Serbinenko47089f22014-03-02 19:14:44 +0100268struct smbios_type2 {
269 u8 type;
270 u8 length;
271 u16 handle;
272 u8 manufacturer;
273 u8 product_name;
274 u8 version;
275 u8 serial_number;
276 char eos[2];
277} __attribute__((packed));
278
Lee Leahy6625ecc2017-03-07 15:11:07 -0800279enum {
Vladimir Serbinenko71c0bf62014-08-27 23:23:14 +0200280 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;
Matt DeVillier4863cc42016-09-01 00:55:40 -0500302 u8 sku_number;
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200303 char eos[2];
304} __attribute__((packed));
305
306struct smbios_type4 {
307 u8 type;
308 u8 length;
309 u16 handle;
310 u8 socket_designation;
311 u8 processor_type;
312 u8 processor_family;
313 u8 processor_manufacturer;
314 u32 processor_id[2];
315 u8 processor_version;
316 u8 voltage;
317 u16 external_clock;
318 u16 max_speed;
319 u16 current_speed;
320 u8 status;
321 u8 processor_upgrade;
322 u16 l1_cache_handle;
323 u16 l2_cache_handle;
324 u16 l3_cache_handle;
325 u8 serial_number;
326 u8 asset_tag;
327 u8 part_number;
328 u8 core_count;
329 u8 core_enabled;
330 u8 thread_count;
331 u16 processor_characteristics;
332 u16 processor_family2;
333 char eos[2];
334} __attribute__((packed));
335
Peter Stugec392b642013-07-06 19:51:12 +0200336struct smbios_type11 {
337 u8 type;
338 u8 length;
339 u16 handle;
340 u8 count;
341 char eos[2];
342} __attribute__((packed));
343
Duncan Laurie472ec9c2012-06-23 16:13:42 -0700344struct smbios_type15 {
345 u8 type;
346 u8 length;
347 u16 handle;
348 u16 area_length;
349 u16 header_offset;
350 u16 data_offset;
351 u8 access_method;
352 u8 log_status;
353 u32 change_token;
354 u32 address;
355 u8 header_format;
356 u8 log_type_descriptors;
357 u8 log_type_descriptor_length;
358 char eos[2];
359} __attribute__((packed));
360
361enum {
362 SMBIOS_EVENTLOG_ACCESS_METHOD_IO8 = 0,
363 SMBIOS_EVENTLOG_ACCESS_METHOD_IO8X2,
364 SMBIOS_EVENTLOG_ACCESS_METHOD_IO16,
365 SMBIOS_EVENTLOG_ACCESS_METHOD_MMIO32,
366 SMBIOS_EVENTLOG_ACCESS_METHOD_GPNV,
367};
368
369enum {
370 SMBIOS_EVENTLOG_STATUS_VALID = 1, /* Bit 0 */
371 SMBIOS_EVENTLOG_STATUS_FULL = 2, /* Bit 1 */
372};
373
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200374struct smbios_type16 {
375 u8 type;
376 u8 length;
377 u16 handle;
378 u8 location;
379 u8 use;
380 u8 memory_error_correction;
381 u32 maximum_capacity;
382 u16 memory_error_information_handle;
383 u16 number_of_memory_devices;
384 u64 extended_maximum_capacity;
385 char eos[2];
386} __attribute__((packed));
387
388struct smbios_type17 {
389 u8 type;
390 u8 length;
391 u16 handle;
392 u16 phys_memory_array_handle;
393 u16 memory_error_information_handle;
394 u16 total_width;
395 u16 data_width;
396 u16 size;
397 u8 form_factor;
398 u8 device_set;
399 u8 device_locator;
400 u8 bank_locator;
401 u8 memory_type;
402 u16 type_detail;
403 u16 speed;
404 u8 manufacturer;
405 u8 serial_number;
406 u8 asset_tag;
407 u8 part_number;
408 u8 attributes;
Timothy Pearson964aa832015-09-05 19:00:34 -0500409 u32 extended_size;
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200410 u16 clock_speed;
Timothy Pearson964aa832015-09-05 19:00:34 -0500411 u16 minimum_voltage;
412 u16 maximum_voltage;
413 u16 configured_voltage;
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200414 char eos[2];
415} __attribute__((packed));
416
417struct smbios_type32 {
418 u8 type;
419 u8 length;
420 u16 handle;
421 u8 reserved[6];
422 u8 boot_status;
423 u8 eos[2];
424} __attribute__((packed));
425
Sven Schnelle6d038762012-07-09 08:52:53 +0200426struct smbios_type38 {
427 u8 type;
428 u8 length;
429 u16 handle;
430 u8 interface_type;
431 u8 ipmi_rev;
432 u8 i2c_slave_addr;
433 u8 nv_storage_addr;
434 u64 base_address;
435 u8 base_address_modifier;
436 u8 irq;
437} __attribute__((packed));
438
Stefan Reinauer3d7c6772012-04-02 13:30:10 -0700439typedef enum {
440 SMBIOS_DEVICE_TYPE_OTHER = 0x01,
441 SMBIOS_DEVICE_TYPE_UNKNOWN,
442 SMBIOS_DEVICE_TYPE_VIDEO,
443 SMBIOS_DEVICE_TYPE_SCSI,
444 SMBIOS_DEVICE_TYPE_ETHERNET,
445 SMBIOS_DEVICE_TYPE_TOKEN_RING,
446 SMBIOS_DEVICE_TYPE_SOUND,
447 SMBIOS_DEVICE_TYPE_PATA,
448 SMBIOS_DEVICE_TYPE_SATA,
449 SMBIOS_DEVICE_TYPE_SAS,
450} smbios_onboard_device_type;
451
452struct smbios_type41 {
453 u8 type;
454 u8 length;
455 u16 handle;
456 u8 reference_designation;
457 u8 device_type: 7;
458 u8 device_status: 1;
459 u8 device_type_instance;
460 u16 segment_group_number;
461 u8 bus_number;
462 u8 function_number: 3;
463 u8 device_number: 5;
464 char eos[2];
465} __attribute__((packed));
466
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200467struct smbios_type127 {
468 u8 type;
469 u8 length;
470 u16 handle;
471 u8 eos[2];
472} __attribute__((packed));
473
Timothy Pearson4785f2a2015-03-27 23:05:36 -0500474void smbios_fill_dimm_manufacturer_from_id(uint16_t mod_id, struct smbios_type17 *t);
475
Sven Schnelle164bcfd2011-08-14 20:56:34 +0200476#endif