1 /* ----------------------------------------------------------------------- *
3 * Copyright 2006 Erwan Velu - All Rights Reserved
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without
8 * restriction, including without limitation the rights to use,
9 * copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom
11 * the Software is furnished to do so, subject to the following
14 * The above copyright notice and this permission notice shall
15 * be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * OTHER DEALINGS IN THE SOFTWARE.
26 * -----------------------------------------------------------------------
33 const char *out_of_spec
= "<OUT OF SPEC>";
34 const char *bad_index
= "<BAD INDEX>";
41 * 3.3.11 On Board Devices Information (Type 10)
44 static const char *dmi_on_board_devices_type(uint8_t code
)
47 static const char *type
[] = {
57 "SAS Controller" /* 0x0A */
60 if (code
>= 0x01 && code
<= 0x0A)
61 return type
[code
- 0x01];
65 static void dmi_on_board_devices(struct dmi_header
*h
, s_dmi
* dmi
)
67 uint8_t *p
= h
->data
+ 4;
68 uint8_t count
= (h
->length
- 0x04) / 2;
74 sizeof dmi
->base_board
.devices_information
/
75 sizeof *dmi
->base_board
.devices_information
; i
++) {
76 strncpy(dmi
->base_board
.devices_information
[i
].type
,
77 dmi_on_board_devices_type(p
[2 * i
] & 0x7F),
78 sizeof dmi
->base_board
.devices_information
[i
].type
);
79 dmi
->base_board
.devices_information
[i
].status
= p
[2 * i
] & 0x80;
80 strncpy(dmi
->base_board
.devices_information
[i
].description
,
81 dmi_string(h
, p
[2 * i
+ 1]),
82 sizeof dmi
->base_board
.devices_information
[i
].description
);
87 * 3.3.24 System Reset (Type 23)
90 static const char *dmi_system_reset_boot_option(uint8_t code
)
92 static const char *option
[] = {
93 "Operating System", /* 0x1 */
95 "Do Not Reboot" /* 0x3 */
99 return option
[code
- 0x1];
103 static void dmi_system_reset_count(uint16_t code
, char *array
)
106 strncpy(array
, "Unknown", sizeof array
);
108 snprintf(array
, sizeof array
, "%u", code
);
111 static void dmi_system_reset_timer(uint16_t code
, char *array
)
114 strncpy(array
, "Unknown", sizeof array
);
116 snprintf(array
, sizeof array
, "%u min", code
);
120 * 3.3.25 Hardware Security (Type 24)
123 static const char *dmi_hardware_security_status(uint8_t code
)
125 static const char *status
[] = {
126 "Disabled", /* 0x00 */
136 * 3.3.12 OEM Strings (Type 11)
139 static void dmi_oem_strings(struct dmi_header
*h
, const char *prefix
,
142 uint8_t *p
= h
->data
+ 4;
143 uint8_t count
= p
[0x00];
146 for (i
= 1; i
<= count
; i
++)
147 snprintf(dmi
->oem_strings
, OEM_STRINGS_SIZE
, "%s %s %s\n",
148 dmi
->oem_strings
, prefix
, dmi_string(h
, i
));
152 * 3.3.13 System Configuration Options (Type 12)
154 static void dmi_system_configuration_options(struct dmi_header
*h
,
155 const char *prefix
, s_dmi
* dmi
)
157 uint8_t *p
= h
->data
+ 4;
158 uint8_t count
= p
[0x00];
161 for (i
= 1; i
<= count
; i
++)
162 snprintf(dmi
->system
.configuration_options
,
163 SYSTEM_CONFIGURATION_OPTIONS_SIZE
, "%s %s %s\n",
164 dmi
->system
.configuration_options
, prefix
, dmi_string(h
, i
));
167 static void dmi_system_boot_status(uint8_t code
, char *array
)
169 static const char *status
[] = {
170 "No errors detected", /* 0 */
172 "Operating system failed to load",
173 "Firmware-detected hardware failure",
174 "Operating system-detected hardware failure",
175 "User-requested boot",
176 "System security violation",
177 "Previously-requested image",
178 "System watchdog timer expired" /* 8 */
182 strncpy(array
, status
[code
], SYSTEM_BOOT_STATUS_SIZE
);
183 if (code
>= 128 && code
<= 191)
184 strncpy(array
, "OEM-specific", SYSTEM_BOOT_STATUS_SIZE
);
186 strncpy(array
, "Product-specific", SYSTEM_BOOT_STATUS_SIZE
);
189 void dmi_bios_runtime_size(uint32_t code
, s_dmi
* dmi
)
191 if (code
& 0x000003FF) {
192 dmi
->bios
.runtime_size
= code
;
193 strcpy(dmi
->bios
.runtime_size_unit
, "bytes");
195 dmi
->bios
.runtime_size
= code
>> 10;
196 strcpy(dmi
->bios
.runtime_size_unit
, "KB");
201 void dmi_bios_characteristics(uint64_t code
, s_dmi
* dmi
)
205 * This isn't very clear what this bit is supposed to mean
208 if (code
&& (1 << 3)) {
209 ((bool *) (&dmi
->bios
.characteristics
))[0] = true;
213 for (i
= 4; i
<= 31; i
++)
216 ((bool *) (&dmi
->bios
.characteristics
))[i
- 3] = true;
219 void dmi_bios_characteristics_x1(uint8_t code
, s_dmi
* dmi
)
223 for (i
= 0; i
<= 7; i
++)
225 ((bool *) (&dmi
->bios
.characteristics_x1
))[i
] = true;
228 void dmi_bios_characteristics_x2(uint8_t code
, s_dmi
* dmi
)
232 for (i
= 0; i
<= 2; i
++)
234 ((bool *) (&dmi
->bios
.characteristics_x2
))[i
] = true;
237 void dmi_system_uuid(uint8_t * p
, s_dmi
* dmi
)
239 int only0xFF
= 1, only0x00
= 1;
242 for (i
= 0; i
< 16 && (only0x00
|| only0xFF
); i
++) {
250 sprintf(dmi
->system
.uuid
, "Not Present");
254 sprintf(dmi
->system
.uuid
, "Not Settable");
258 sprintf(dmi
->system
.uuid
,
259 "%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
260 p
[0], p
[1], p
[2], p
[3], p
[4], p
[5], p
[6], p
[7], p
[8], p
[9], p
[10],
261 p
[11], p
[12], p
[13], p
[14], p
[15]);
264 void dmi_system_wake_up_type(uint8_t code
, s_dmi
* dmi
)
267 static const char *type
[] = {
268 "Reserved", /* 0x00 */
276 "AC Power Restored" /* 0x08 */
280 strcpy(dmi
->system
.wakeup_type
, type
[code
]);
282 strcpy(dmi
->system
.wakeup_type
, out_of_spec
);
287 static void dmi_base_board_features(uint8_t code
, s_dmi
* dmi
)
289 if ((code
& 0x1F) != 0) {
292 for (i
= 0; i
<= 4; i
++)
294 ((bool *) (&dmi
->base_board
.features
))[i
] = true;
298 static void dmi_processor_voltage(uint8_t code
, s_dmi
* dmi
)
301 static const uint16_t voltage
[] = {
309 dmi
->processor
.voltage_mv
= (code
& 0x7f) * 100;
311 for (i
= 0; i
<= 2; i
++)
313 dmi
->processor
.voltage_mv
= voltage
[i
];
317 static void dmi_processor_id(uint8_t type
, uint8_t * p
, const char *version
,
321 * Extra flags are now returned in the ECX register when one calls
322 * the CPUID instruction. Their meaning is explained in table 6, but
323 * DMI doesn't support this yet.
329 * This might help learn about new processors supporting the
330 * CPUID instruction or another form of identification.
332 sprintf(dmi
->processor
.id
, "ID: %02X %02X %02X %02X %02X %02X %02X %02X\n",
333 p
[0], p
[1], p
[2], p
[3], p
[4], p
[5], p
[6], p
[7]);
335 if (type
== 0x05) { /* 80386 */
336 uint16_t dx
= WORD(p
);
338 * 80386 have a different signature.
340 dmi
->processor
.signature
.type
= (dx
>> 12);
341 dmi
->processor
.signature
.family
= ((dx
>> 8) & 0xF);
342 dmi
->processor
.signature
.stepping
= (dx
>> 4) & 0xF;
343 dmi
->processor
.signature
.minor_stepping
= (dx
& 0xF);
346 if (type
== 0x06) { /* 80486 */
347 uint16_t dx
= WORD(p
);
349 * Not all 80486 CPU support the CPUID instruction, we have to find
350 * wether the one we have here does or not. Note that this trick
351 * works only because we know that 80486 must be little-endian.
353 if ((dx
& 0x0F00) == 0x0400
354 && ((dx
& 0x00F0) == 0x0040 || (dx
& 0x00F0) >= 0x0070)
355 && ((dx
& 0x000F) >= 0x0003))
358 dmi
->processor
.signature
.type
= ((dx
>> 12) & 0x3);
359 dmi
->processor
.signature
.family
= ((dx
>> 8) & 0xF);
360 dmi
->processor
.signature
.model
= ((dx
>> 4) & 0xF);
361 dmi
->processor
.signature
.stepping
= (dx
& 0xF);
364 } else if ((type
>= 0x0B && type
<= 0x13) /* Intel, Cyrix */
365 ||(type
>= 0xB0 && type
<= 0xB3) /* Intel */
366 ||type
== 0xB5 /* Intel */
367 || type
== 0xB9) /* Intel */
369 else if ((type
>= 0x18 && type
<= 0x1D) /* AMD */
370 ||type
== 0x1F /* AMD */
371 || (type
>= 0xB6 && type
<= 0xB7) /* AMD */
372 ||(type
>= 0x83 && type
<= 0x85)) /* AMD */
374 else if (type
== 0x01 || type
== 0x02) {
376 * Some X86-class CPU have family "Other" or "Unknown". In this case,
377 * we use the version string to determine if they are known to
378 * support the CPUID instruction.
380 if (strncmp(version
, "Pentium III MMX", 15) == 0)
382 else if (strncmp(version
, "AMD Athlon(TM)", 14) == 0
383 || strncmp(version
, "AMD Opteron(tm)", 15) == 0)
387 } else /* not X86-class */
394 dmi
->processor
.signature
.type
= ((eax
>> 12) & 0x3);
395 dmi
->processor
.signature
.family
=
396 (((eax
>> 16) & 0xFF0) + ((eax
>> 8) & 0x00F));
397 dmi
->processor
.signature
.model
=
398 (((eax
>> 12) & 0xF0) + ((eax
>> 4) & 0x0F));
399 dmi
->processor
.signature
.stepping
= (eax
& 0xF);
402 dmi
->processor
.signature
.family
=
403 (((eax
>> 8) & 0xF) == 0xF ? (eax
>> 20) & 0xFF : (eax
>> 8) & 0xF);
404 dmi
->processor
.signature
.model
=
405 (((eax
>> 4) & 0xF) == 0xF ? (eax
>> 16) & 0xF : (eax
>> 4) & 0xF);
406 dmi
->processor
.signature
.stepping
= (eax
& 0xF);
411 if ((edx
& 0x3FF7FDFF) != 0) {
413 for (i
= 0; i
<= 31; i
++)
414 if (cpu_flags_strings
[i
] != NULL
&& edx
& (1 << i
))
415 ((bool *) (&dmi
->processor
.cpu_flags
))[i
] = true;
419 void to_dmi_header(struct dmi_header
*h
, uint8_t * data
)
423 h
->handle
= WORD(data
+ 2);
427 const char *dmi_string(struct dmi_header
*dm
, uint8_t s
)
429 char *bp
= (char *)dm
->data
;
433 return "Not Specified";
436 while (s
> 1 && *bp
) {
445 /* ASCII filtering */
447 for (i
= 0; i
< len
; i
++)
448 if (bp
[i
] < 32 || bp
[i
] == 127)
454 int checksum(uint8_t * buf
, int len
)
459 for (a
= 0; a
< len
; a
++)
464 static int smbios_decode(s_dmi
* dmi
, uint8_t * buf
)
467 dmi
->dmitable
.ver
= (buf
[0x06] << 8) + buf
[0x07];
468 /* Some BIOS report weird SMBIOS version, fix that up */
469 switch (dmi
->dmitable
.ver
) {
471 dmi
->dmitable
.ver
= 0x0203;
474 dmi
->dmitable
.ver
= 0x0206;
477 dmi
->dmitable
.major_version
= dmi
->dmitable
.ver
>> 8;
478 dmi
->dmitable
.minor_version
= dmi
->dmitable
.ver
& 0xFF;
480 return DMI_TABLE_PRESENT
;
483 static int legacy_decode(s_dmi
* dmi
, uint8_t * buf
)
485 dmi
->dmitable
.num
= buf
[13] << 8 | buf
[12];
486 dmi
->dmitable
.len
= buf
[7] << 8 | buf
[6];
487 dmi
->dmitable
.base
= buf
[11] << 24 | buf
[10] << 16 | buf
[9] << 8 | buf
[8];
489 /* Version already found? */
490 if (dmi
->dmitable
.ver
> 0)
491 return DMI_TABLE_PRESENT
;
493 dmi
->dmitable
.ver
= (buf
[0x06] << 8) + buf
[0x07];
496 * DMI version 0.0 means that the real version is taken from
497 * the SMBIOS version, which we don't know at this point.
500 dmi
->dmitable
.major_version
= buf
[14] >> 4;
501 dmi
->dmitable
.minor_version
= buf
[14] & 0x0F;
503 dmi
->dmitable
.major_version
= 0;
504 dmi
->dmitable
.minor_version
= 0;
506 return DMI_TABLE_PRESENT
;
509 int dmi_iterate(s_dmi
* dmi
)
514 /* Cleaning structures */
515 memset(&dmi
->base_board
, 0, sizeof(s_base_board
));
516 memset(&dmi
->battery
, 0, sizeof(s_battery
));
517 memset(&dmi
->bios
, 0, sizeof(s_bios
));
518 memset(&dmi
->chassis
, 0, sizeof(s_chassis
));
519 for (int i
= 0; i
< MAX_DMI_MEMORY_ITEMS
; i
++)
520 memset(&dmi
->memory
[i
], 0, sizeof(s_memory
));
521 memset(&dmi
->processor
, 0, sizeof(s_processor
));
522 memset(&dmi
->system
, 0, sizeof(s_system
));
524 /* Until we found this elements in the dmitable, we consider them as not filled */
525 dmi
->base_board
.filled
= false;
526 dmi
->battery
.filled
= false;
527 dmi
->bios
.filled
= false;
528 dmi
->chassis
.filled
= false;
529 for (int i
= 0; i
< MAX_DMI_MEMORY_ITEMS
; i
++)
530 dmi
->memory
[i
].filled
= false;
531 dmi
->processor
.filled
= false;
532 dmi
->system
.filled
= false;
534 p
= (uint8_t *) 0xF0000; /* The start address to look at the dmi table */
535 /* The anchor-string is 16-bytes aligned */
536 for (q
= p
; q
< p
+ 0x10000; q
+= 16) {
537 /* To validate the presence of SMBIOS:
538 * + the overall checksum must be correct
539 * + the intermediate anchor-string must be _DMI_
540 * + the intermediate checksum must be correct
542 if (memcmp(q
, "_SM_", 4) == 0 &&
543 checksum(q
, q
[0x05]) &&
544 memcmp(q
+ 0x10, "_DMI_", 5) == 0 && checksum(q
+ 0x10, 0x0F)) {
545 /* Do not return, legacy_decode will need to be called
546 * on the intermediate structure to get the table length
549 smbios_decode(dmi
, q
);
550 } else if (memcmp(q
, "_DMI_", 5) == 0 && checksum(q
, 0x0F)) {
552 legacy_decode(dmi
, q
);
557 return DMI_TABLE_PRESENT
;
559 dmi
->dmitable
.base
= 0;
560 dmi
->dmitable
.num
= 0;
561 dmi
->dmitable
.ver
= 0;
562 dmi
->dmitable
.len
= 0;
566 void dmi_decode(struct dmi_header
*h
, uint16_t ver
, s_dmi
* dmi
)
568 uint8_t *data
= h
->data
;
571 * Note: DMI types 37, 38 and 39 are untested
574 case 0: /* 3.3.1 BIOS Information */
575 if (h
->length
< 0x12)
577 dmi
->bios
.filled
= true;
578 strcpy(dmi
->bios
.vendor
, dmi_string(h
, data
[0x04]));
579 strcpy(dmi
->bios
.version
, dmi_string(h
, data
[0x05]));
580 strcpy(dmi
->bios
.release_date
, dmi_string(h
, data
[0x08]));
581 dmi
->bios
.address
= WORD(data
+ 0x06);
582 dmi_bios_runtime_size((0x10000 - WORD(data
+ 0x06)) << 4, dmi
);
583 dmi
->bios
.rom_size
= (data
[0x09] + 1) << 6;
584 strcpy(dmi
->bios
.rom_size_unit
, "kB");
585 dmi_bios_characteristics(QWORD(data
+ 0x0A), dmi
);
587 if (h
->length
< 0x13)
589 dmi_bios_characteristics_x1(data
[0x12], dmi
);
590 if (h
->length
< 0x14)
592 dmi_bios_characteristics_x2(data
[0x13], dmi
);
593 if (h
->length
< 0x18)
595 if (data
[0x14] != 0xFF && data
[0x15] != 0xFF)
596 sprintf(dmi
->bios
.bios_revision
, "%u.%u", data
[0x14], data
[0x15]);
597 if (data
[0x16] != 0xFF && data
[0x17] != 0xFF)
598 sprintf(dmi
->bios
.firmware_revision
, "%u.%u",
599 data
[0x16], data
[0x17]);
601 case 1: /* 3.3.2 System Information */
602 if (h
->length
< 0x08)
604 dmi
->system
.filled
= true;
605 strcpy(dmi
->system
.manufacturer
, dmi_string(h
, data
[0x04]));
606 strcpy(dmi
->system
.product_name
, dmi_string(h
, data
[0x05]));
607 strcpy(dmi
->system
.version
, dmi_string(h
, data
[0x06]));
608 strcpy(dmi
->system
.serial
, dmi_string(h
, data
[0x07]));
609 if (h
->length
< 0x19)
611 dmi_system_uuid(data
+ 0x08, dmi
);
612 dmi_system_wake_up_type(data
[0x18], dmi
);
613 if (h
->length
< 0x1B)
615 strcpy(dmi
->system
.sku_number
, dmi_string(h
, data
[0x19]));
616 strcpy(dmi
->system
.family
, dmi_string(h
, data
[0x1A]));
619 case 2: /* 3.3.3 Base Board Information */
620 if (h
->length
< 0x08)
622 dmi
->base_board
.filled
= true;
623 strcpy(dmi
->base_board
.manufacturer
, dmi_string(h
, data
[0x04]));
624 strcpy(dmi
->base_board
.product_name
, dmi_string(h
, data
[0x05]));
625 strcpy(dmi
->base_board
.version
, dmi_string(h
, data
[0x06]));
626 strcpy(dmi
->base_board
.serial
, dmi_string(h
, data
[0x07]));
627 if (h
->length
< 0x0F)
629 strcpy(dmi
->base_board
.asset_tag
, dmi_string(h
, data
[0x08]));
630 dmi_base_board_features(data
[0x09], dmi
);
631 strcpy(dmi
->base_board
.location
, dmi_string(h
, data
[0x0A]));
632 strcpy(dmi
->base_board
.type
, dmi_string(h
, data
[0x0D]));
633 if (h
->length
< 0x0F + data
[0x0E] * sizeof(uint16_t))
636 case 3: /* 3.3.4 Chassis Information */
637 if (h
->length
< 0x09)
639 dmi
->chassis
.filled
= true;
640 strcpy(dmi
->chassis
.manufacturer
, dmi_string(h
, data
[0x04]));
641 strcpy(dmi
->chassis
.type
, dmi_chassis_type(data
[0x05] & 0x7F));
642 strcpy(dmi
->chassis
.lock
, dmi_chassis_lock(data
[0x05] >> 7));
643 strcpy(dmi
->chassis
.version
, dmi_string(h
, data
[0x06]));
644 strcpy(dmi
->chassis
.serial
, dmi_string(h
, data
[0x07]));
645 strcpy(dmi
->chassis
.asset_tag
, dmi_string(h
, data
[0x08]));
646 if (h
->length
< 0x0D)
648 strcpy(dmi
->chassis
.boot_up_state
, dmi_chassis_state(data
[0x09]));
649 strcpy(dmi
->chassis
.power_supply_state
, dmi_chassis_state(data
[0x0A]));
650 strcpy(dmi
->chassis
.thermal_state
, dmi_chassis_state(data
[0x0B]));
651 strcpy(dmi
->chassis
.security_status
,
652 dmi_chassis_security_status(data
[0x0C]));
653 if (h
->length
< 0x11)
655 sprintf(dmi
->chassis
.oem_information
, "0x%08X", DWORD(data
+ 0x0D));
656 if (h
->length
< 0x15)
658 dmi
->chassis
.height
= data
[0x11];
659 dmi
->chassis
.nb_power_cords
= data
[0x12];
662 case 4: /* 3.3.5 Processor Information */
663 if (h
->length
< 0x1A)
665 dmi
->processor
.filled
= true;
666 strcpy(dmi
->processor
.socket_designation
, dmi_string(h
, data
[0x04]));
667 strcpy(dmi
->processor
.type
, dmi_processor_type(data
[0x05]));
668 strcpy(dmi
->processor
.manufacturer
, dmi_string(h
, data
[0x07]));
669 strcpy(dmi
->processor
.family
,
670 dmi_processor_family(data
[0x06], dmi
->processor
.manufacturer
));
671 dmi_processor_id(data
[0x06], data
+ 8, dmi_string(h
, data
[0x10]), dmi
);
672 strcpy(dmi
->processor
.version
, dmi_string(h
, data
[0x10]));
673 dmi_processor_voltage(data
[0x11], dmi
);
674 dmi
->processor
.external_clock
= WORD(data
+ 0x12);
675 dmi
->processor
.max_speed
= WORD(data
+ 0x14);
676 dmi
->processor
.current_speed
= WORD(data
+ 0x16);
677 if (data
[0x18] & (1 << 6))
678 strcpy(dmi
->processor
.status
,
679 dmi_processor_status(data
[0x18] & 0x07));
681 sprintf(dmi
->processor
.status
, "Unpopulated");
682 strcpy(dmi
->processor
.upgrade
, dmi_processor_upgrade(data
[0x19]));
683 if (h
->length
< 0x20)
685 dmi_processor_cache(WORD(data
+ 0x1A), "L1", ver
,
686 dmi
->processor
.cache1
);
687 dmi_processor_cache(WORD(data
+ 0x1C), "L2", ver
,
688 dmi
->processor
.cache2
);
689 dmi_processor_cache(WORD(data
+ 0x1E), "L3", ver
,
690 dmi
->processor
.cache3
);
691 if (h
->length
< 0x23)
693 strcpy(dmi
->processor
.serial
, dmi_string(h
, data
[0x20]));
694 strcpy(dmi
->processor
.asset_tag
, dmi_string(h
, data
[0x21]));
695 strcpy(dmi
->processor
.part_number
, dmi_string(h
, data
[0x22]));
697 case 6: /* 3.3.7 Memory Module Information */
698 if (h
->length
< 0x0C)
700 dmi
->memory_module_count
++;
701 s_memory_module
*module
=
702 &dmi
->memory_module
[dmi
->memory_module_count
- 1];
703 dmi
->memory_module
[dmi
->memory_module_count
- 1].filled
= true;
704 strncpy(module
->socket_designation
, dmi_string(h
, data
[0x04]),
705 sizeof(module
->socket_designation
));
706 dmi_memory_module_connections(data
[0x05], module
->bank_connections
);
707 dmi_memory_module_speed(data
[0x06], module
->speed
);
708 dmi_memory_module_types(WORD(data
+ 0x07), " ", module
->type
);
709 dmi_memory_module_size(data
[0x09], module
->installed_size
);
710 dmi_memory_module_size(data
[0x0A], module
->enabled_size
);
711 dmi_memory_module_error(data
[0x0B], "\t\t", module
->error_status
);
713 case 7: /* 3.3.8 Cache Information */
714 if (h
->length
< 0x0F)
717 if (dmi
->cache_count
> MAX_DMI_CACHE_ITEMS
)
719 strcpy(dmi
->cache
[dmi
->cache_count
- 1].socket_designation
,
720 dmi_string(h
, data
[0x04]));
721 sprintf(dmi
->cache
[dmi
->cache_count
- 1].configuration
,
723 WORD(data
+ 0x05) & 0x0080 ? "Enabled" : "Disabled",
724 WORD(data
+ 0x05) & 0x0008 ? "Socketed" : "Not Socketed",
725 (WORD(data
+ 0x05) & 0x0007) + 1);
726 strcpy(dmi
->cache
[dmi
->cache_count
- 1].mode
,
727 dmi_cache_mode((WORD(data
+ 0x05) >> 8) & 0x0003));
728 strcpy(dmi
->cache
[dmi
->cache_count
- 1].location
,
729 dmi_cache_location((WORD(data
+ 0x05) >> 5) & 0x0003));
730 dmi
->cache
[dmi
->cache_count
- 1].installed_size
=
731 dmi_cache_size(WORD(data
+ 0x09));
732 dmi
->cache
[dmi
->cache_count
- 1].max_size
=
733 dmi_cache_size(WORD(data
+ 0x07));
734 dmi_cache_types(WORD(data
+ 0x0B), " ",
735 dmi
->cache
[dmi
->cache_count
- 1].supported_sram_types
);
736 dmi_cache_types(WORD(data
+ 0x0D), " ",
737 dmi
->cache
[dmi
->cache_count
- 1].installed_sram_types
);
738 if (h
->length
< 0x13)
740 dmi
->cache
[dmi
->cache_count
- 1].speed
= data
[0x0F]; /* ns */
741 strcpy(dmi
->cache
[dmi
->cache_count
- 1].error_correction_type
,
742 dmi_cache_ec_type(data
[0x10]));
743 strcpy(dmi
->cache
[dmi
->cache_count
- 1].system_type
,
744 dmi_cache_type(data
[0x11]));
745 strcpy(dmi
->cache
[dmi
->cache_count
- 1].associativity
,
746 dmi_cache_associativity(data
[0x12]));
748 case 10: /* 3.3.11 On Board Devices Information */
749 dmi_on_board_devices(h
, dmi
);
751 case 11: /* 3.3.12 OEM Strings */
752 if (h
->length
< 0x05)
754 dmi_oem_strings(h
, "\t", dmi
);
756 case 12: /* 3.3.13 System Configuration Options */
757 if (h
->length
< 0x05)
759 dmi_system_configuration_options(h
, "\t", dmi
);
761 case 17: /* 3.3.18 Memory Device */
762 if (h
->length
< 0x15)
765 if (dmi
->memory_count
> MAX_DMI_MEMORY_ITEMS
)
767 s_memory
*mem
= &dmi
->memory
[dmi
->memory_count
- 1];
768 dmi
->memory
[dmi
->memory_count
- 1].filled
= true;
769 dmi_memory_array_error_handle(WORD(data
+ 0x06), mem
->error
);
770 dmi_memory_device_width(WORD(data
+ 0x08), mem
->total_width
);
771 dmi_memory_device_width(WORD(data
+ 0x0A), mem
->data_width
);
772 dmi_memory_device_size(WORD(data
+ 0x0C), mem
->size
);
773 strcpy(mem
->form_factor
, dmi_memory_device_form_factor(data
[0x0E]));
774 dmi_memory_device_set(data
[0x0F], mem
->device_set
);
775 strcpy(mem
->device_locator
, dmi_string(h
, data
[0x10]));
776 strcpy(mem
->bank_locator
, dmi_string(h
, data
[0x11]));
777 strcpy(mem
->type
, dmi_memory_device_type(data
[0x12]));
778 dmi_memory_device_type_detail(WORD(data
+ 0x13), mem
->type_detail
);
779 if (h
->length
< 0x17)
781 dmi_memory_device_speed(WORD(data
+ 0x15), mem
->speed
);
782 if (h
->length
< 0x1B)
784 strcpy(mem
->manufacturer
, dmi_string(h
, data
[0x17]));
785 strcpy(mem
->serial
, dmi_string(h
, data
[0x18]));
786 strcpy(mem
->asset_tag
, dmi_string(h
, data
[0x19]));
787 strcpy(mem
->part_number
, dmi_string(h
, data
[0x1A]));
789 case 22: /* 3.3.23 Portable Battery */
790 if (h
->length
< 0x10)
792 dmi
->battery
.filled
= true;
793 strcpy(dmi
->battery
.location
, dmi_string(h
, data
[0x04]));
794 strcpy(dmi
->battery
.manufacturer
, dmi_string(h
, data
[0x05]));
796 if (data
[0x06] || h
->length
< 0x1A)
797 strcpy(dmi
->battery
.manufacture_date
, dmi_string(h
, data
[0x06]));
799 if (data
[0x07] || h
->length
< 0x1A)
800 strcpy(dmi
->battery
.serial
, dmi_string(h
, data
[0x07]));
802 strcpy(dmi
->battery
.name
, dmi_string(h
, data
[0x08]));
804 if (data
[0x09] != 0x02 || h
->length
< 0x1A)
805 strcpy(dmi
->battery
.chemistry
, dmi_battery_chemistry(data
[0x09]));
807 if (h
->length
< 0x1A)
808 dmi_battery_capacity(WORD(data
+ 0x0A), 1,
809 dmi
->battery
.design_capacity
);
811 dmi_battery_capacity(WORD(data
+ 0x0A), data
[0x15],
812 dmi
->battery
.design_capacity
);
813 dmi_battery_voltage(WORD(data
+ 0x0C), dmi
->battery
.design_voltage
);
814 strcpy(dmi
->battery
.sbds
, dmi_string(h
, data
[0x0E]));
815 dmi_battery_maximum_error(data
[0x0F], dmi
->battery
.maximum_error
);
816 if (h
->length
< 0x1A)
819 sprintf(dmi
->battery
.sbds_serial
, "%04X", WORD(data
+ 0x10));
822 sprintf(dmi
->battery
.sbds_manufacture_date
, "%u-%02u-%02u",
823 1980 + (WORD(data
+ 0x12) >> 9),
824 (WORD(data
+ 0x12) >> 5) & 0x0F, WORD(data
+ 0x12) & 0x1F);
825 if (data
[0x09] == 0x02)
826 strcpy(dmi
->battery
.sbds_chemistry
, dmi_string(h
, data
[0x14]));
828 // sprintf(dmi->battery.oem_info,"0x%08X",DWORD(h, data+0x16));
830 case 23: /* 3.3.24 System Reset */
831 if (h
->length
< 0x0D)
833 dmi
->system
.system_reset
.filled
= true;
834 dmi
->system
.system_reset
.status
= data
[0x04] & (1 << 0);
835 dmi
->system
.system_reset
.watchdog
= data
[0x04] & (1 << 5);
836 if (!(data
[0x04] & (1 << 5)))
838 strncpy(dmi
->system
.system_reset
.boot_option
,
839 dmi_system_reset_boot_option((data
[0x04] >> 1) & 0x3),
840 sizeof dmi
->system
.system_reset
.boot_option
);
841 strncpy(dmi
->system
.system_reset
.boot_option_on_limit
,
842 dmi_system_reset_boot_option((data
[0x04] >> 3) & 0x3),
843 sizeof dmi
->system
.system_reset
.boot_option_on_limit
);
844 dmi_system_reset_count(WORD(data
+ 0x05),
845 dmi
->system
.system_reset
.reset_count
);
846 dmi_system_reset_count(WORD(data
+ 0x07),
847 dmi
->system
.system_reset
.reset_limit
);
848 dmi_system_reset_timer(WORD(data
+ 0x09),
849 dmi
->system
.system_reset
.timer_interval
);
850 dmi_system_reset_timer(WORD(data
+ 0x0B),
851 dmi
->system
.system_reset
.timeout
);
853 case 24: /* 3.3.25 Hardware Security */
854 if (h
->length
< 0x05)
856 dmi
->hardware_security
.filled
= true;
857 strncpy(dmi
->hardware_security
.power_on_passwd_status
,
858 dmi_hardware_security_status(data
[0x04] >> 6),
859 sizeof dmi
->hardware_security
.power_on_passwd_status
);
860 strncpy(dmi
->hardware_security
.keyboard_passwd_status
,
861 dmi_hardware_security_status((data
[0x04] >> 4) & 0x3),
862 sizeof dmi
->hardware_security
.keyboard_passwd_status
);
863 strncpy(dmi
->hardware_security
.administrator_passwd_status
,
864 dmi_hardware_security_status((data
[0x04] >> 2) & 0x3),
865 sizeof dmi
->hardware_security
.administrator_passwd_status
);
866 strncpy(dmi
->hardware_security
.front_panel_reset_status
,
867 dmi_hardware_security_status(data
[0x04] & 0x3),
868 sizeof dmi
->hardware_security
.front_panel_reset_status
);
870 case 32: /* 3.3.33 System Boot Information */
871 if (h
->length
< 0x0B)
873 dmi_system_boot_status(data
[0x0A], dmi
->system
.system_boot_status
);
874 case 38: /* 3.3.39 IPMI Device Information */
875 if (h
->length
< 0x10)
877 dmi
->ipmi
.filled
= true;
878 snprintf(dmi
->ipmi
.interface_type
, sizeof(dmi
->ipmi
.interface_type
),
879 "%s", dmi_ipmi_interface_type(data
[0x04]));
880 dmi
->ipmi
.major_specification_version
= data
[0x05] >> 4;
881 dmi
->ipmi
.minor_specification_version
= data
[0x05] & 0x0F;
882 dmi
->ipmi
.I2C_slave_address
= data
[0x06] >> 1;
883 if (data
[0x07] != 0xFF)
884 dmi
->ipmi
.nv_address
= data
[0x07];
886 dmi
->ipmi
.nv_address
= 0; /* Not Present */
887 dmi_ipmi_base_address(data
[0x04], data
+ 0x08, &dmi
->ipmi
);
888 if (h
->length
< 0x12)
890 if (data
[0x11] != 0x00) {
891 dmi
->ipmi
.irq
= data
[0x11];
897 void parse_dmitable(s_dmi
* dmi
)
900 uint8_t *data
= NULL
;
901 uint8_t buf
[dmi
->dmitable
.len
];
903 memcpy(buf
, (int *)dmi
->dmitable
.base
, sizeof(uint8_t) * dmi
->dmitable
.len
);
905 dmi
->memory_count
= 0;
906 while (i
< dmi
->dmitable
.num
&& data
+ 4 <= buf
+ dmi
->dmitable
.len
) { /* 4 is the length of an SMBIOS structure header */
909 to_dmi_header(&h
, data
);
912 * If a short entry is found (less than 4 bytes), not only it
913 * is invalid, but we cannot reliably locate the next entry.
914 * Better stop at this point, and let the user know his/her
918 printf("Invalid entry length (%u). DMI table is broken! Stop.\n\n",
919 (unsigned int)h
.length
);
923 /* loo for the next handle */
924 next
= data
+ h
.length
;
925 while (next
- buf
+ 1 < dmi
->dmitable
.len
926 && (next
[0] != 0 || next
[1] != 0))
929 if (next
- buf
<= dmi
->dmitable
.len
) {
930 dmi_decode(&h
, dmi
->dmitable
.ver
, dmi
);