| 36 | | * Fix return value in dmi_port_type and dmi_port_connector_type |
|---|
| 37 | | * |
|---|
| 38 | | * Licensed under the GNU Public license. If you want to use it in with |
|---|
| 39 | | * another license just ask. |
|---|
| | 36 | * Fix return value of dmi_port_type and dmi_port_connector_type |
|---|
| | 37 | * |
|---|
| | 38 | * 23-August-2002 Alan Cox <alan@redhat.com> |
|---|
| | 39 | * Make the code pass -Wall -pedantic by fixing a few harmless sign of |
|---|
| | 40 | * pointer mismatches |
|---|
| | 41 | * Correct main prototype |
|---|
| | 42 | * Check for compilers with wrong type sizes |
|---|
| | 43 | * |
|---|
| | 44 | * 17-Sep-2002 Larry Lile <llile@dreamworks.com> |
|---|
| | 45 | * Type 16 & 17 structures displayed per SMBIOS 2.3.1 spec |
|---|
| | 46 | * |
|---|
| | 47 | * 20-September-2002 Dave Johnson <ddj@cascv.brown.edu> |
|---|
| | 48 | * Fix comparisons in dmi_bus_name |
|---|
| | 49 | * Fix comparison in dmi_processor_type |
|---|
| | 50 | * Fix bitmasking in dmi_onboard_type |
|---|
| | 51 | * Fix return value of dmi_temp_loc |
|---|
| | 52 | * |
|---|
| | 53 | * 28-September-2002 Jean Delvare <khali@linux-fr.org> |
|---|
| | 54 | * Fix missing coma in dmi_bus_name |
|---|
| | 55 | * Remove unwanted bitmaskings in dmi_mgmt_dev_type, dmi_mgmt_addr_type, |
|---|
| | 56 | * dmi_fan_type, dmi_volt_loc, dmi_temp_loc and dmi_status |
|---|
| | 57 | * Fix DMI table read bug ("dmi: read: Success") |
|---|
| | 58 | * Make the code pass -W again |
|---|
| | 59 | * Fix return value of dmi_card_size |
|---|
| | 60 | * |
|---|
| | 61 | * 05-October-2002 Jean Delvare <khali@linux-fr.org> |
|---|
| | 62 | * More ACPI decoded |
|---|
| | 63 | * More PNP decoded |
|---|
| | 64 | * More SYSID decoded |
|---|
| | 65 | * PCI Interrupt Routing decoded |
|---|
| | 66 | * BIOS32 Service Directory decoded |
|---|
| | 67 | * Sony system detection (unconfirmed) |
|---|
| | 68 | * Checksums verified whenever possible |
|---|
| | 69 | * Better checks on file read and close |
|---|
| | 70 | * Define VERSION and display version at beginning |
|---|
| | 71 | * More secure decoding (won't run off the table in any case) |
|---|
| | 72 | * Do not try to decode more structures than announced |
|---|
| | 73 | * Fix an off-by-one error that caused the last address being |
|---|
| | 74 | * scanned to be 0x100000, not 0xFFFF0 as it should |
|---|
| | 75 | * |
|---|
| | 76 | * 10-October-2002 Jean Delvare <khali@linux-fr.org> |
|---|
| | 77 | * Remove extra semicolon at the end of dmi_memory_array_use |
|---|
| | 78 | * Fix compilation warnings |
|---|
| | 79 | * Add missing backslash in DMI case 37 |
|---|
| | 80 | * Fix BIOS ROM size (DMI case 0) |
|---|
| | 81 | * |
|---|
| | 82 | * 12-October-2002 Jean Delvare <khali@linux-fr.org> |
|---|
| | 83 | * Fix maximum cache size and installed size being inverted |
|---|
| | 84 | * Fix typos in port types |
|---|
| | 85 | * |
|---|
| | 86 | * 14-October-2002 Jean Delvare <khali@linux-fr.org> |
|---|
| | 87 | * Fix typo in dmi_memory_array_location |
|---|
| | 88 | * Replace Kbyte by kB in DMI case 16 |
|---|
| | 89 | * Add DDR entry in dmi_memory_device_type |
|---|
| | 90 | * Fix extra s in SYSIS |
|---|
| | 91 | * |
|---|
| | 92 | * 15-October-2002 Jean Delvare <khali@linux-fr.org> |
|---|
| | 93 | * Fix bad index in DMI case 27 (cooling device) |
|---|
| | 94 | * |
|---|
| | 95 | * Licensed under the GNU Public license. If you want to use it in with |
|---|
| | 96 | * another license just ask. |
|---|
| | 97 | * |
|---|
| | 98 | * This program is free software; you can redistribute it and/or modify |
|---|
| | 99 | * it under the terms of the GNU General Public License as published by |
|---|
| | 100 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| | 101 | * (at your option) any later version. |
|---|
| | 102 | * |
|---|
| | 103 | * This program is distributed in the hope that it will be useful, |
|---|
| | 104 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| | 105 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| | 106 | * GNU General Public License for more details. |
|---|
| | 107 | * |
|---|
| | 108 | * You should have received a copy of the GNU General Public License |
|---|
| | 109 | * along with this program; if not, write to the Free Software |
|---|
| | 110 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| | 111 | * |
|---|
| | 112 | * For the avoidance of doubt the "preferred form" of this code is one which |
|---|
| | 113 | * is in an open unpatent encumbered format. Where cryptographic key signing |
|---|
| | 114 | * forms part of the process of creating an executable the information |
|---|
| | 115 | * including keys needed to generate an equivalently functional executable |
|---|
| | 116 | * are deemed to be part of the source code. |
|---|
| | 117 | * [In the light of TCPA and Palladium the author urges |
|---|
| | 118 | * other open source authors to add such a clarification] |
|---|
| | 421 | static const char *dmi_memory_array_location(u8 num) |
|---|
| | 422 | { |
|---|
| | 423 | static const char *memory_array_location[]={ |
|---|
| | 424 | "", |
|---|
| | 425 | "Other", |
|---|
| | 426 | "Unknown", |
|---|
| | 427 | "System board or motherboard", |
|---|
| | 428 | "ISA add-on card", |
|---|
| | 429 | "EISA add-on card", |
|---|
| | 430 | "PCI add-on card", |
|---|
| | 431 | "MCA add-on card", |
|---|
| | 432 | "PCMCIA add-on card", |
|---|
| | 433 | "Proprietary add-on card", |
|---|
| | 434 | "NuBus", |
|---|
| | 435 | }; |
|---|
| | 436 | static const char *jp_memory_array_location[]={ |
|---|
| | 437 | "PC-98/C20 add-on card", |
|---|
| | 438 | "PC-98/C24 add-on card", |
|---|
| | 439 | "PC-98/E add-on card", |
|---|
| | 440 | "PC-98/Local bus add-on card", |
|---|
| | 441 | }; |
|---|
| | 442 | if(num<=0x0A) |
|---|
| | 443 | return memory_array_location[num]; |
|---|
| | 444 | if(num>=0xA0 && num<0xA3) |
|---|
| | 445 | return jp_memory_array_location[num]; |
|---|
| | 446 | return ""; |
|---|
| | 447 | } |
|---|
| | 448 | |
|---|
| | 449 | static const char *dmi_memory_array_use(u8 num) |
|---|
| | 450 | { |
|---|
| | 451 | static const char *memory_array_use[]={ |
|---|
| | 452 | "", |
|---|
| | 453 | "Other", |
|---|
| | 454 | "Unknown", |
|---|
| | 455 | "System memory", |
|---|
| | 456 | "Video memory", |
|---|
| | 457 | "Flash memory", |
|---|
| | 458 | "Non-volatile RAM", |
|---|
| | 459 | "Cache memory", |
|---|
| | 460 | }; |
|---|
| | 461 | if (num > 0x07) |
|---|
| | 462 | return ""; |
|---|
| | 463 | return memory_array_use[num]; |
|---|
| | 464 | } |
|---|
| | 465 | |
|---|
| | 466 | static const char *dmi_memory_array_error_correction_type(u8 num) |
|---|
| | 467 | { |
|---|
| | 468 | static const char *memory_array_error_correction_type[]={ |
|---|
| | 469 | "", |
|---|
| | 470 | "Other", |
|---|
| | 471 | "Unknown", |
|---|
| | 472 | "None", |
|---|
| | 473 | "Parity", |
|---|
| | 474 | "Single-bit ECC", |
|---|
| | 475 | "Multi-bit ECC", |
|---|
| | 476 | "CRC", |
|---|
| | 477 | }; |
|---|
| | 478 | if (num > 0x07) |
|---|
| | 479 | return ""; |
|---|
| | 480 | return memory_array_error_correction_type[num]; |
|---|
| | 481 | } |
|---|
| | 482 | |
|---|
| | 483 | static const char *dmi_memory_device_form_factor(u8 num) |
|---|
| | 484 | { |
|---|
| | 485 | static const char *memory_device_form_factor[]={ |
|---|
| | 486 | "", |
|---|
| | 487 | "Other", |
|---|
| | 488 | "Unknown", |
|---|
| | 489 | "SIMM", |
|---|
| | 490 | "SIP", |
|---|
| | 491 | "Chip", |
|---|
| | 492 | "DIP", |
|---|
| | 493 | "ZIP", |
|---|
| | 494 | "Proprietary Card", |
|---|
| | 495 | "DIMM", |
|---|
| | 496 | "TSOP", |
|---|
| | 497 | "Row of chips", |
|---|
| | 498 | "RIMM", |
|---|
| | 499 | "SODIMM", |
|---|
| | 500 | "SRIMM", |
|---|
| | 501 | }; |
|---|
| | 502 | if (num > 0x0E) |
|---|
| | 503 | return ""; |
|---|
| | 504 | return memory_device_form_factor[num]; |
|---|
| | 505 | } |
|---|
| | 506 | |
|---|
| | 507 | static const char *dmi_memory_device_type(u8 num) |
|---|
| | 508 | { |
|---|
| | 509 | static const char *memory_device_type[]={ |
|---|
| | 510 | "", |
|---|
| | 511 | "Other", |
|---|
| | 512 | "Unknown", |
|---|
| | 513 | "DRAM", |
|---|
| | 514 | "EDRAM", |
|---|
| | 515 | "VRAM", |
|---|
| | 516 | "SRAM", |
|---|
| | 517 | "RAM", |
|---|
| | 518 | "ROM", |
|---|
| | 519 | "FLASH", |
|---|
| | 520 | "EEPROM", |
|---|
| | 521 | "FEPROM", |
|---|
| | 522 | "EPROM", |
|---|
| | 523 | "CDRAM", |
|---|
| | 524 | "3DRAM", |
|---|
| | 525 | "SDRAM", |
|---|
| | 526 | "SGRAM", |
|---|
| | 527 | "RDRAM", |
|---|
| | 528 | "DDR" |
|---|
| | 529 | }; |
|---|
| | 530 | if (num > 0x12) |
|---|
| | 531 | return ""; |
|---|
| | 532 | return memory_device_type[num]; |
|---|
| | 533 | } |
|---|
| | 534 | |
|---|
| | 535 | static void dmi_memory_device_detail(u8 v) |
|---|
| | 536 | { |
|---|
| | 537 | printf("\t\tType Detail: "); |
|---|
| | 538 | if (v&(1<<1)) |
|---|
| | 539 | printf("Other "); |
|---|
| | 540 | if (v&(1<<2)) |
|---|
| | 541 | printf("Unknown "); |
|---|
| | 542 | if (v&(1<<3)) |
|---|
| | 543 | printf("Fast-paged "); |
|---|
| | 544 | if (v&(1<<4)) |
|---|
| | 545 | printf("Static column "); |
|---|
| | 546 | if (v&(1<<5)) |
|---|
| | 547 | printf("Pseudo-static "); |
|---|
| | 548 | if (v&(1<<6)) |
|---|
| | 549 | printf("RAMBUS "); |
|---|
| | 550 | if (v&(1<<7)) |
|---|
| | 551 | printf("Synchronous "); |
|---|
| | 552 | if (v&(1<<8)) |
|---|
| | 553 | printf("CMOS "); |
|---|
| | 554 | if (v&(1<<9)) |
|---|
| | 555 | printf("EDO "); |
|---|
| | 556 | if (v&(1<<10)) |
|---|
| | 557 | printf("Window DRAM "); |
|---|
| | 558 | if (v&(1<<11)) |
|---|
| | 559 | printf("Cache DRAM "); |
|---|
| | 560 | if (v&(1<<12)) |
|---|
| | 561 | printf("Non-volatile "); |
|---|
| | 562 | printf("\n"); |
|---|
| | 563 | } |
|---|
| | 1225 | printf("\t\tArray Handle: 0x%04X\n", data[5]<<8|data[4]); |
|---|
| | 1226 | printf("\t\tError Information Handle: "); |
|---|
| | 1227 | u = data[7]<<8|data[6]; |
|---|
| | 1228 | if (u == 0xffff) { |
|---|
| | 1229 | printf("None\n"); |
|---|
| | 1230 | } else if (u == 0xfffe) { |
|---|
| | 1231 | printf("Not Provided\n"); |
|---|
| | 1232 | } else { |
|---|
| | 1233 | printf("0x%04X\n", u); |
|---|
| | 1234 | } |
|---|
| | 1235 | u = data[9]<<8|data[8]; |
|---|
| | 1236 | printf("\t\tTotal Width: "); |
|---|
| | 1237 | if (u == 0xffff) |
|---|
| | 1238 | printf("Unknown\n"); |
|---|
| | 1239 | else |
|---|
| | 1240 | printf("%u bits\n", u); |
|---|
| | 1241 | u = data[11]<<8|data[10]; |
|---|
| | 1242 | printf("\t\tData Width: "); |
|---|
| | 1243 | if (u == 0xffff) |
|---|
| | 1244 | printf("Unknown\n"); |
|---|
| | 1245 | else |
|---|
| | 1246 | printf("%u bits\n", u); |
|---|
| | 1247 | u = data[13]<<8|data[12]; |
|---|
| | 1248 | printf("\t\tSize: "); |
|---|
| | 1249 | if (u == 0xffff) |
|---|
| | 1250 | printf("Unknown\n"); |
|---|
| | 1251 | else |
|---|
| | 1252 | printf("%u %sbyte\n", (u&0x7fff), (u&0x8000) ? "K" : "M"); |
|---|
| | 1253 | printf("\t\tForm Factor: %s\n", |
|---|
| | 1254 | dmi_memory_device_form_factor(data[14])); |
|---|
| | 1255 | if (data[15] != 0) { |
|---|
| | 1256 | printf("\t\tSet: "); |
|---|
| | 1257 | if (data[15] == 0xff) |
|---|
| | 1258 | printf("Unknown\n"); |
|---|
| | 1259 | else |
|---|
| | 1260 | printf("0x%02X\n", data[15]); |
|---|
| | 1261 | } |
|---|
| | 1262 | printf("\t\tLocator: %s\n", |
|---|
| | 1263 | dmi_string(dm, data[16])); |
|---|
| | 1264 | printf("\t\tBank Locator: %s\n", |
|---|
| | 1265 | dmi_string(dm, data[17])); |
|---|
| | 1266 | printf("\t\tType: %s\n", |
|---|
| | 1267 | dmi_memory_device_type(data[18])); |
|---|
| | 1268 | u = data[20]<<8|data[19]; |
|---|
| | 1269 | if (u&0x1ffe) |
|---|
| | 1270 | dmi_memory_device_detail(u); |
|---|
| | 1271 | if (dm->length > 21) { |
|---|
| | 1272 | u = data[22]<<8|data[21]; |
|---|
| | 1273 | printf("\t\tSpeed: "); |
|---|
| | 1274 | if (u == 0) |
|---|
| | 1275 | printf("Unknown\n"); |
|---|
| | 1276 | else |
|---|
| | 1277 | printf("%u MHz (%.1f ns)\n", u, (1000.0/u)); |
|---|
| | 1278 | } |
|---|
| | 1279 | if (dm->length > 23) |
|---|
| | 1280 | printf("\t\tManufacturer: %s\n", |
|---|
| | 1281 | dmi_string(dm, data[23])); |
|---|
| | 1282 | if (dm->length > 24) |
|---|
| | 1283 | printf("\t\tSerial Number: %s\n", |
|---|
| | 1284 | dmi_string(dm, data[24])); |
|---|
| | 1285 | if (dm->length > 25) |
|---|
| | 1286 | printf("\t\tAsset Tag: %s\n", |
|---|
| | 1287 | dmi_string(dm, data[25])); |
|---|
| | 1288 | if (dm->length > 26) |
|---|
| | 1289 | printf("\t\tPart Number: %s\n", |
|---|
| | 1290 | dmi_string(dm, data[26])); |
|---|
| 1189 | | printf("SYSID present.\n"); |
|---|
| 1190 | | else if(memcmp(buf, "_DMI_", 5)==0) |
|---|
| | 1582 | { |
|---|
| | 1583 | /* complete buffer, compute checksum */ |
|---|
| | 1584 | read(fd, buf+16, 16); /* arbitrary, at least 1 */ |
|---|
| | 1585 | if(*(u16 *)(buf+8)<=32 && checksum(buf, *(u16 *)(buf+8))) |
|---|
| | 1586 | { |
|---|
| | 1587 | fp+=16; |
|---|
| | 1588 | printf("SYSID present.\n"); |
|---|
| | 1589 | printf("\tRevision: %u\n", |
|---|
| | 1590 | buf[16]); |
|---|
| | 1591 | printf("%d structure%s.\n", |
|---|
| | 1592 | *(u16 *)(buf+14), *(u16 *)(buf+14)>1?"s":""); |
|---|
| | 1593 | printf("SYSID table at 0x%08X.\n", |
|---|
| | 1594 | *(u32 *)(buf+10)); |
|---|
| | 1595 | } |
|---|
| | 1596 | else |
|---|
| | 1597 | lseek(fd, -16, SEEK_CUR); |
|---|
| | 1598 | } |
|---|
| | 1599 | else if(memcmp(buf, "_DMI_", 5)==0 && checksum(buf, 15)) |
|---|
| 1208 | | printf("PNP BIOS present.\n"); |
|---|
| | 1618 | { |
|---|
| | 1619 | /* complete buffer, compute checksum */ |
|---|
| | 1620 | read(fd, buf+16, 32); /* arbitrary, at least 1 */ |
|---|
| | 1621 | if(buf[5]<=48 && checksum(buf, buf[5])) |
|---|
| | 1622 | { |
|---|
| | 1623 | fp+=32; |
|---|
| | 1624 | printf("PNP %u.%u present.\n", |
|---|
| | 1625 | buf[4]>>4, buf[4]&0x0F); |
|---|
| | 1626 | printf("\tEvent Notification: %s\n", |
|---|
| | 1627 | pnp_event_notification((*(u16 *)(buf+6))&0x03)); |
|---|
| | 1628 | if(((*(u16 *)(buf+6))&0x03)==1) |
|---|
| | 1629 | printf("\tEvent Notification Flag Address: 0x%08X\n", |
|---|
| | 1630 | *(u32 *)(buf+9)); |
|---|
| | 1631 | printf("\tReal Mode Code Address: %04X:%04X\n", |
|---|
| | 1632 | *(u16 *)(buf+0x0F), *(u16 *)(buf+0x0D)); |
|---|
| | 1633 | printf("\tReal Mode Data Address: %04X:0000\n", |
|---|
| | 1634 | *(u16 *)(buf+0x1B)); |
|---|
| | 1635 | printf("\tProtected Mode Code Address: 0x%08X\n", |
|---|
| | 1636 | *(u32 *)(buf+0x13)+*(u16 *)(buf+0x11)); |
|---|
| | 1637 | printf("\tProtected Mode Data Address: 0x%08X\n", |
|---|
| | 1638 | *(u32 *)(buf+0x1D)); |
|---|
| | 1639 | if(*(u32 *)(buf+0x17)!=0) |
|---|
| | 1640 | printf("\tOEM Device Identifier: 0x%08X\n", |
|---|
| | 1641 | *(u32 *)(buf+0x17)); |
|---|
| | 1642 | } |
|---|
| | 1643 | else |
|---|
| | 1644 | lseek(fd, -32, SEEK_CUR); |
|---|
| | 1645 | } |
|---|
| | 1665 | else if(memcmp(buf, "$SNY", 4)==0) |
|---|
| | 1666 | { |
|---|
| | 1667 | /* complete buffer, compute checksum */ |
|---|
| | 1668 | read(fd, buf+16, 16); |
|---|
| | 1669 | if(buf[5]<=32 && checksum(buf, buf[5])) |
|---|
| | 1670 | { |
|---|
| | 1671 | fp+=16; |
|---|
| | 1672 | printf("Sony system detected (?).\n"); |
|---|
| | 1673 | } |
|---|
| | 1674 | else |
|---|
| | 1675 | lseek(fd, -16, SEEK_CUR); |
|---|
| | 1676 | } |
|---|
| | 1677 | else if(memcmp(buf, "_32_", 4)==0) |
|---|
| | 1678 | { |
|---|
| | 1679 | /* complete buffer, reposition file, compute checksum */ |
|---|
| | 1680 | read(fd, buf+16, 32); |
|---|
| | 1681 | lseek(fd, -32, SEEK_CUR); |
|---|
| | 1682 | if(buf[9]>=1 && buf[9]<=3 && checksum(buf, buf[9]<<4)) |
|---|
| | 1683 | { |
|---|
| | 1684 | printf("BIOS32 Service Directory present.\n"); |
|---|
| | 1685 | printf("\tCalling Interface Address: 0x%08X\n", |
|---|
| | 1686 | *(u32 *)(buf+4)); |
|---|
| | 1687 | lseek(fd, (buf[9]-1)<<4, SEEK_CUR); |
|---|
| | 1688 | fp+=(buf[9]-1)<<4; |
|---|
| | 1689 | } |
|---|
| | 1690 | } |
|---|
| | 1691 | else if(memcmp(buf, "$PIR", 4)==0) |
|---|
| | 1692 | { |
|---|
| | 1693 | /* complete buffer, reposition file */ |
|---|
| | 1694 | read(fd, buf+16, 16); |
|---|
| | 1695 | lseek(fd, -16, SEEK_CUR); |
|---|
| | 1696 | if(buf[5]!=0 && buf[30]==0) |
|---|
| | 1697 | { |
|---|
| | 1698 | printf("PCI Interrupt Routing %u.%u present.\n", |
|---|
| | 1699 | buf[5], buf[4]); |
|---|
| | 1700 | printf("\tTable Size: %u bytes\n", |
|---|
| | 1701 | *(u16 *)(buf+6)); |
|---|
| | 1702 | printf("\tRouter ID: %02x:%02x.%1x\n", |
|---|
| | 1703 | buf[8], buf[9]>>3, buf[9]&0x07); |
|---|
| | 1704 | printf("\tExclusive IRQs:"); |
|---|
| | 1705 | pir_exclusive_irqs(*(u16 *)(buf+10)); |
|---|
| | 1706 | printf("\n"); |
|---|
| | 1707 | if(*(u32 *)(buf+12)!=0) |
|---|
| | 1708 | printf("\tCompatible Router: %04x:%04x\n", |
|---|
| | 1709 | *(u16 *)(buf+12), *(u16 *)(buf+14)); |
|---|
| | 1710 | if(*(u32 *)(buf+16)!=0) |
|---|
| | 1711 | printf("\tMiniport Data: 0x%08X\n", |
|---|
| | 1712 | &n |
|---|