| 1 | /* |
|---|
| 2 | * DMI decode rev 1.2 |
|---|
| 3 | * |
|---|
| 4 | * (C) 2000,2001 Alan Cox <alan@redhat.com> |
|---|
| 5 | * |
|---|
| 6 | * 2-July-2001 Matt Domsch <Matt_Domsch@dell.com> |
|---|
| 7 | * Additional structures displayed per SMBIOS 2.3.1 spec |
|---|
| 8 | * |
|---|
| 9 | * Licensed under the GNU Public license. If you want to use it in with |
|---|
| 10 | * another license just ask. |
|---|
| 11 | */ |
|---|
| 12 | |
|---|
| 13 | #include <stdio.h> |
|---|
| 14 | #include <unistd.h> |
|---|
| 15 | #include <fcntl.h> |
|---|
| 16 | #include <string.h> |
|---|
| 17 | #include <stdlib.h> |
|---|
| 18 | |
|---|
| 19 | typedef unsigned char u8; |
|---|
| 20 | typedef unsigned short u16; |
|---|
| 21 | typedef unsigned int u32; |
|---|
| 22 | |
|---|
| 23 | static void |
|---|
| 24 | dump_raw_data(void *data, unsigned int length) |
|---|
| 25 | { |
|---|
| 26 | unsigned char buffer1[80], buffer2[80], *b1, *b2, c; |
|---|
| 27 | unsigned char *p = data; |
|---|
| 28 | unsigned long column=0; |
|---|
| 29 | unsigned int length_printed = 0; |
|---|
| 30 | const unsigned char maxcolumn = 16; |
|---|
| 31 | while (length_printed < length) { |
|---|
| 32 | b1 = buffer1; |
|---|
| 33 | b2 = buffer2; |
|---|
| 34 | for (column = 0; |
|---|
| 35 | column < maxcolumn && length_printed < length; |
|---|
| 36 | column ++) { |
|---|
| 37 | b1 += sprintf(b1, "%02x ",(unsigned int) *p); |
|---|
| 38 | if (*p < 32 || *p > 126) c = '.'; |
|---|
| 39 | else c = *p; |
|---|
| 40 | b2 += sprintf(b2, "%c", c); |
|---|
| 41 | p++; |
|---|
| 42 | length_printed++; |
|---|
| 43 | } |
|---|
| 44 | /* pad out the line */ |
|---|
| 45 | for (; column < maxcolumn; column++) |
|---|
| 46 | { |
|---|
| 47 | b1 += sprintf(b1, " "); |
|---|
| 48 | b2 += sprintf(b2, " "); |
|---|
| 49 | } |
|---|
| 50 | |
|---|
| 51 | printf("%s\t%s\n", buffer1, buffer2); |
|---|
| 52 | } |
|---|
| 53 | } |
|---|
| 54 | |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | struct dmi_header |
|---|
| 58 | { |
|---|
| 59 | u8 type; |
|---|
| 60 | u8 length; |
|---|
| 61 | u16 handle; |
|---|
| 62 | }; |
|---|
| 63 | |
|---|
| 64 | static char *dmi_string(struct dmi_header *dm, u8 s) |
|---|
| 65 | { |
|---|
| 66 | u8 *bp=(u8 *)dm; |
|---|
| 67 | if (!s) return NULL; |
|---|
| 68 | |
|---|
| 69 | bp+=dm->length; |
|---|
| 70 | while(s>1) |
|---|
| 71 | { |
|---|
| 72 | bp+=strlen(bp); |
|---|
| 73 | bp++; |
|---|
| 74 | s--; |
|---|
| 75 | } |
|---|
| 76 | return bp; |
|---|
| 77 | } |
|---|
| 78 | |
|---|
| 79 | static void dmi_decode_ram(u8 data) |
|---|
| 80 | { |
|---|
| 81 | if(data&(1<<0)) |
|---|
| 82 | printf("OTHER "); |
|---|
| 83 | if(data&(1<<1)) |
|---|
| 84 | printf("UNKNOWN "); |
|---|
| 85 | if(data&(1<<2)) |
|---|
| 86 | printf("STANDARD "); |
|---|
| 87 | if(data&(1<<3)) |
|---|
| 88 | printf("FPM "); |
|---|
| 89 | if(data&(1<<4)) |
|---|
| 90 | printf("EDO "); |
|---|
| 91 | if(data&(1<<5)) |
|---|
| 92 | printf("PARITY "); |
|---|
| 93 | if(data&(1<<6)) |
|---|
| 94 | printf("ECC "); |
|---|
| 95 | if(data&(1<<7)) |
|---|
| 96 | printf("SIMM "); |
|---|
| 97 | if(data&(1<<8)) |
|---|
| 98 | printf("DIMM "); |
|---|
| 99 | if(data&(1<<9)) |
|---|
| 100 | printf("Burst EDO "); |
|---|
| 101 | if(data&(1<<10)) |
|---|
| 102 | printf("SDRAM "); |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | static void dmi_cache_size(u16 n) |
|---|
| 106 | { |
|---|
| 107 | if(n&(1<<15)) |
|---|
| 108 | printf("%dK\n", (n&0x7FFF)*64); |
|---|
| 109 | else |
|---|
| 110 | printf("%dK\n", n&0x7FFF); |
|---|
| 111 | } |
|---|
| 112 | |
|---|
| 113 | static void dmi_decode_cache(u16 c) |
|---|
| 114 | { |
|---|
| 115 | if(c&(1<<0)) |
|---|
| 116 | printf("Other "); |
|---|
| 117 | if(c&(1<<1)) |
|---|
| 118 | printf("Unknown "); |
|---|
| 119 | if(c&(1<<2)) |
|---|
| 120 | printf("Non-burst "); |
|---|
| 121 | if(c&(1<<3)) |
|---|
| 122 | printf("Burst "); |
|---|
| 123 | if(c&(1<<4)) |
|---|
| 124 | printf("Pipeline burst "); |
|---|
| 125 | if(c&(1<<5)) |
|---|
| 126 | printf("Synchronous "); |
|---|
| 127 | if(c&(1<<6)) |
|---|
| 128 | printf("Asynchronous "); |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | static char *dmi_bus_name(u8 num) |
|---|
| 132 | { |
|---|
| 133 | static char *bus[]={ |
|---|
| 134 | "", |
|---|
| 135 | "", |
|---|
| 136 | "", |
|---|
| 137 | "ISA ", |
|---|
| 138 | "MCA ", |
|---|
| 139 | "EISA ", |
|---|
| 140 | "PCI ", |
|---|
| 141 | "PCMCIA " |
|---|
| 142 | "VLB ", |
|---|
| 143 | "Proprietary ", |
|---|
| 144 | "CPU Slot ", |
|---|
| 145 | "Proprietary RAM ", |
|---|
| 146 | "I/O Riser ", |
|---|
| 147 | "NUBUS ", |
|---|
| 148 | "PCI-66 ", |
|---|
| 149 | "AGP ", |
|---|
| 150 | "AGP 2x ", |
|---|
| 151 | "AGP 4x " |
|---|
| 152 | }; |
|---|
| 153 | static char *jpbus[]={ |
|---|
| 154 | "PC98/C20", |
|---|
| 155 | "PC98/C24", |
|---|
| 156 | "PC98/E", |
|---|
| 157 | "PC98/LocalBus", |
|---|
| 158 | "PC98/Card" |
|---|
| 159 | }; |
|---|
| 160 | |
|---|
| 161 | if(num<=0x12) |
|---|
| 162 | return bus[num]; |
|---|
| 163 | if(num>=0xA0 && num<0xA5) |
|---|
| 164 | return jpbus[num]; |
|---|
| 165 | return ""; |
|---|
| 166 | } |
|---|
| 167 | |
|---|
| 168 | static char *dmi_bus_width(u8 code) |
|---|
| 169 | { |
|---|
| 170 | static char *width[]={ |
|---|
| 171 | "", |
|---|
| 172 | "", |
|---|
| 173 | "", |
|---|
| 174 | "8bit ", |
|---|
| 175 | "16bit ", |
|---|
| 176 | "32bit ", |
|---|
| 177 | "64bit ", |
|---|
| 178 | "128bit " |
|---|
| 179 | }; |
|---|
| 180 | if(code>7) |
|---|
| 181 | return ""; |
|---|
| 182 | return width[code]; |
|---|
| 183 | } |
|---|
| 184 | |
|---|
| 185 | static char *dmi_card_size(u8 v) |
|---|
| 186 | { |
|---|
| 187 | if(v==2) |
|---|
| 188 | return("Short "); |
|---|
| 189 | if(v==3) |
|---|
| 190 | return("Long "); |
|---|
| 191 | return ""; |
|---|
| 192 | } |
|---|
| 193 | |
|---|
| 194 | static void dmi_card_props(u8 v) |
|---|
| 195 | { |
|---|
| 196 | printf("\t\tSlot Features: "); |
|---|
| 197 | if(v&(1<<1)) |
|---|
| 198 | printf("5v "); |
|---|
| 199 | if(v&(1<<2)) |
|---|
| 200 | printf("3.3v "); |
|---|
| 201 | if(v&(1<<3)) |
|---|
| 202 | printf("Shared "); |
|---|
| 203 | if(v&(1<<4)) |
|---|
| 204 | printf("PCCard16 "); |
|---|
| 205 | if(v&(1<<5)) |
|---|
| 206 | printf("CardBus "); |
|---|
| 207 | if(v&(1<<6)) |
|---|
| 208 | printf("Zoom-Video "); |
|---|
| 209 | if(v&(1<<7)) |
|---|
| 210 | printf("ModemRingResume "); |
|---|
| 211 | printf("\n"); |
|---|
| 212 | } |
|---|
| 213 | |
|---|
| 214 | static char *dmi_chassis_type(u8 code) |
|---|
| 215 | { |
|---|
| 216 | static char *chassis_type[]={ |
|---|
| 217 | "", |
|---|
| 218 | "Other", |
|---|
| 219 | "Unknown", |
|---|
| 220 | "Desktop", |
|---|
| 221 | "Low Profile Desktop", |
|---|
| 222 | "Pizza Box", |
|---|
| 223 | "Mini Tower", |
|---|
| 224 | "Tower", |
|---|
| 225 | "Portable", |
|---|
| 226 | "Laptop", |
|---|
| 227 | "Notebook", |
|---|
| 228 | "Hand Held", |
|---|
| 229 | "Docking Station", |
|---|
| 230 | "All in One", |
|---|
| 231 | "Sub Notebook", |
|---|
| 232 | "Space-saving", |
|---|
| 233 | "Lunch Box", |
|---|
| 234 | "Main Server Chassis", |
|---|
| 235 | "Expansion Chassis", |
|---|
| 236 | "SubChassis", |
|---|
| 237 | "Bus Expansion Chassis", |
|---|
| 238 | "Peripheral Chassis", |
|---|
| 239 | "RAID Chassis", |
|---|
| 240 | "Rack Mount Chassis", |
|---|
| 241 | "Sealed-case PC", |
|---|
| 242 | }; |
|---|
| 243 | code &= ~0x80; |
|---|
| 244 | |
|---|
| 245 | if(code>0x18) |
|---|
| 246 | return ""; |
|---|
| 247 | return chassis_type[code]; |
|---|
| 248 | |
|---|
| 249 | } |
|---|
| 250 | |
|---|
| 251 | static char *dmi_port_connector_type(u8 code) |
|---|
| 252 | { |
|---|
| 253 | static char *connector_type[]={ |
|---|
| 254 | "None", |
|---|
| 255 | "Centronics", |
|---|
| 256 | "Mini Centronics", |
|---|
| 257 | "Proprietary", |
|---|
| 258 | "DB-25 pin male", |
|---|
| 259 | "DB-25 pin female", |
|---|
| 260 | "DB-15 pin male", |
|---|
| 261 | "DB-15 pin female", |
|---|
| 262 | "DB-9 pin male", |
|---|
| 263 | "DB-9 pin female", |
|---|
| 264 | "RJ-11", |
|---|
| 265 | "RJ-45", |
|---|
| 266 | "50 Pin MiniSCSI", |
|---|
| 267 | "Mini-DIN", |
|---|
| 268 | "Micro-DIN", |
|---|
| 269 | "PS/2", |
|---|
| 270 | "Infrared", |
|---|
| 271 | "HP-HIL", |
|---|
| 272 | "Access Bus (USB)", |
|---|
| 273 | "SSA SCSI", |
|---|
| 274 | "Circular DIN-8 male", |
|---|
| 275 | "Circular DIN-8 female", |
|---|
| 276 | "On Board IDE", |
|---|
| 277 | "On Board Floppy", |
|---|
| 278 | "9 Pin Dual Inline (pin 10 cut)", |
|---|
| 279 | "25 Pin Dual Inline (pin 26 cut)", |
|---|
| 280 | "50 Pin Dual Inline", |
|---|
| 281 | "68 Pin Dual Inline", |
|---|
| 282 | "On Board Sound Input from CD-ROM", |
|---|
| 283 | "Mini-Centronics Type-14", |
|---|
| 284 | "Mini-Centronics Type-26", |
|---|
| 285 | "Mini-jack (headphones)", |
|---|
| 286 | "BNC", |
|---|
| 287 | "1394", |
|---|
| 288 | "PC-98", |
|---|
| 289 | "PC-98Hireso", |
|---|
| 290 | "PC-H98", |
|---|
| 291 | "PC-98Note", |
|---|
| 292 | "PC98Full", |
|---|
| 293 | }; |
|---|
| 294 | |
|---|
| 295 | if(code == 0xFF) |
|---|
| 296 | return "Other"; |
|---|
| 297 | |
|---|
| 298 | if (code > 0xA4) |
|---|
| 299 | return ""; |
|---|
| 300 | return connector_type[code]; |
|---|
| 301 | |
|---|
| 302 | } |
|---|
| 303 | |
|---|
| 304 | static char *dmi_port_type(u8 code) |
|---|
| 305 | { |
|---|
| 306 | static char *port_type[]={ |
|---|
| 307 | "None", |
|---|
| 308 | "Parallel Port XT/AT Compatible", |
|---|
| 309 | "Parallel Port PS/2", |
|---|
| 310 | "Parallel Port ECP", |
|---|
| 311 | "Parallel Port EPP", |
|---|
| 312 | "Parallel Port ECP/EPP", |
|---|
| 313 | "Serial Port XT/AT Compatible", |
|---|
| 314 | "Serial Port 16450 Compatible", |
|---|
| 315 | "Serial Port 16650 Compatible", |
|---|
| 316 | "Serial Port 16650A Compatible", |
|---|
| 317 | "SCSI Port", |
|---|
| 318 | "MIDI Port", |
|---|
| 319 | "Joy Stick Port", |
|---|
| 320 | "Keyboard Port", |
|---|
| 321 | "Mouse Port", |
|---|
| 322 | "SSA SCSI", |
|---|
| 323 | "USB", |
|---|
| 324 | "FireWire (IEEE P1394)", |
|---|
| 325 | "PCMCIA Type I", |
|---|
| 326 | "PCMCIA Type II", |
|---|
| 327 | "PCMCIA Type III", |
|---|
| 328 | "Cardbus", |
|---|
| 329 | "Access Bus Port", |
|---|
| 330 | "SCSI II", |
|---|
| 331 | "SCSI Wide", |
|---|
| 332 | "PC-98", |
|---|
| 333 | "PC-98-Hireso", |
|---|
| 334 | "PC-H98", |
|---|
| 335 | "Video Port", |
|---|
| 336 | "Audio Port", |
|---|
| 337 | "Modem Port", |
|---|
| 338 | "Network Port", |
|---|
| 339 | "8251 Compatible", |
|---|
| 340 | "8251 FIFO Compatible", |
|---|
| 341 | }; |
|---|
| 342 | |
|---|
| 343 | if(code == 0xFF) |
|---|
| 344 | return "Other"; |
|---|
| 345 | |
|---|
| 346 | if (code > 0xA1) |
|---|
| 347 | return ""; |
|---|
| 348 | return port_type[code]; |
|---|
| 349 | |
|---|
| 350 | } |
|---|
| 351 | |
|---|
| 352 | static char *dmi_processor_type(u8 code) |
|---|
| 353 | { |
|---|
| 354 | static char *processor_type[]={ |
|---|
| 355 | "", |
|---|
| 356 | "Other", |
|---|
| 357 | "Unknown", |
|---|
| 358 | "Central Processor", |
|---|
| 359 | "Math Processor", |
|---|
| 360 | "DSP Processor", |
|---|
| 361 | "Video Processor" |
|---|
| 362 | }; |
|---|
| 363 | |
|---|
| 364 | if(code == 0xFF) |
|---|
| 365 | return "Other"; |
|---|
| 366 | |
|---|
| 367 | if (code > 0xA1) |
|---|
| 368 | return ""; |
|---|
| 369 | return processor_type[code]; |
|---|
| 370 | } |
|---|
| 371 | |
|---|
| 372 | static char *dmi_processor_family(u8 code) |
|---|
| 373 | { |
|---|
| 374 | static char *processor_family[]={ |
|---|
| 375 | "", |
|---|
| 376 | "Other", |
|---|
| 377 | "Unknown", |
|---|
| 378 | "8086", |
|---|
| 379 | "80286", |
|---|
| 380 | "Intel386 processor", |
|---|
| 381 | "Intel486 processor", |
|---|
| 382 | "8087", |
|---|
| 383 | "80287", |
|---|
| 384 | "80387", |
|---|
| 385 | "80487", |
|---|
| 386 | "Pentium processor Family", |
|---|
| 387 | "Pentium Pro processor", |
|---|
| 388 | "Pentium II processor", |
|---|
| 389 | "Pentium processor with MMX technology", |
|---|
| 390 | "Celeron processor", |
|---|
| 391 | "Pentium II Xeon processor", |
|---|
| 392 | "Pentium III processor", |
|---|
| 393 | "M1 Family", |
|---|
| 394 | "M1","M1","M1","M1","M1","M1", /* 13h - 18h */ |
|---|
| 395 | "K5 Family", |
|---|
| 396 | "K5","K5","K5","K5","K5","K5", /* 1Ah - 1Fh */ |
|---|
| 397 | "Power PC Family", |
|---|
| 398 | "Power PC 601", |
|---|
| 399 | "Power PC 603", |
|---|
| 400 | "Power PC 603+", |
|---|
| 401 | "Power PC 604", |
|---|
| 402 | }; |
|---|
| 403 | |
|---|
| 404 | if(code == 0xFF) |
|---|
| 405 | return "Other"; |
|---|
| 406 | |
|---|
| 407 | if (code > 0x24) |
|---|
| 408 | return ""; |
|---|
| 409 | return processor_family[code]; |
|---|
| 410 | } |
|---|
| 411 | |
|---|
| 412 | static char *dmi_onboard_type(u8 code) |
|---|
| 413 | { |
|---|
| 414 | static char *onboard_type[]={ |
|---|
| 415 | "", |
|---|
| 416 | "Other", |
|---|
| 417 | "Unknown", |
|---|
| 418 | "Video", |
|---|
| 419 | "SCSI Controller", |
|---|
| 420 | "Ethernet", |
|---|
| 421 | "Token Ring", |
|---|
| 422 | "Sound", |
|---|
| 423 | }; |
|---|
| 424 | code &= 0x80; |
|---|
| 425 | if (code > 7) |
|---|
| 426 | return ""; |
|---|
| 427 | return onboard_type[code]; |
|---|
| 428 | } |
|---|
| 429 | |
|---|
| 430 | |
|---|
| 431 | static void dmi_table(int fd, u32 base, int len, int num) |
|---|
| 432 | { |
|---|
| 433 | char *buf=malloc(len); |
|---|
| 434 | struct dmi_header *dm; |
|---|
| 435 | u8 *data; |
|---|
| 436 | int i=0; |
|---|
| 437 | |
|---|
| 438 | if(lseek(fd, (long)base, 0)==-1) |
|---|
| 439 | { |
|---|
| 440 | perror("dmi: lseek"); |
|---|
| 441 | return; |
|---|
| 442 | } |
|---|
| 443 | if(read(fd, buf, len)!=len) |
|---|
| 444 | { |
|---|
| 445 | perror("dmi: read"); |
|---|
| 446 | return; |
|---|
| 447 | } |
|---|
| 448 | data = buf; |
|---|
| 449 | while(i<num) |
|---|
| 450 | { |
|---|
| 451 | u32 u; |
|---|
| 452 | u32 u2; |
|---|
| 453 | dm=(struct dmi_header *)data; |
|---|
| 454 | printf("Handle 0x%04X\n\tDMI type %d, %d bytes.\n", |
|---|
| 455 | dm->handle, |
|---|
| 456 | dm->type, dm->length); |
|---|
| 457 | |
|---|
| 458 | switch(dm->type) |
|---|
| 459 | { |
|---|
| 460 | case 0: |
|---|
| 461 | printf("\tBIOS Information Block\n"); |
|---|
| 462 | printf("\t\tVendor: %s\n", |
|---|
| 463 | dmi_string(dm, data[4])); |
|---|
| 464 | printf("\t\tVersion: %s\n", |
|---|
| 465 | dmi_string(dm, data[5])); |
|---|
| 466 | printf("\t\tRelease: %s\n", |
|---|
| 467 | dmi_string(dm, data[8])); |
|---|
| 468 | printf("\t\tBIOS base: 0x%04X0\n", |
|---|
| 469 | data[7]<<8|data[6]); |
|---|
| 470 | printf("\t\tROM size: %dK\n", |
|---|
| 471 | 64*data[9]); |
|---|
| 472 | printf("\t\tCapabilities:\n"); |
|---|
| 473 | u=data[13]<<24|data[12]<<16|data[11]<<8|data[10]; |
|---|
| 474 | u2=data[17]<<24|data[16]<<16|data[15]<<8|data[14]; |
|---|
| 475 | printf("\t\t\tFlags: 0x%08X%08X\n", |
|---|
| 476 | u2,u); |
|---|
| 477 | break; |
|---|
| 478 | |
|---|
| 479 | case 1: |
|---|
| 480 | printf("\tSystem Information Block\n"); |
|---|
| 481 | printf("\t\tVendor: %s\n", |
|---|
| 482 | dmi_string(dm, data[4])); |
|---|
| 483 | printf("\t\tProduct: %s\n", |
|---|
| 484 | dmi_string(dm, data[5])); |
|---|
| 485 | printf("\t\tVersion: %s\n", |
|---|
| 486 | dmi_string(dm, data[6])); |
|---|
| 487 | printf("\t\tSerial Number: %s\n", |
|---|
| 488 | dmi_string(dm, data[7])); |
|---|
| 489 | break; |
|---|
| 490 | |
|---|
| 491 | case 2: |
|---|
| 492 | printf("\tBoard Information Block\n"); |
|---|
| 493 | printf("\t\tVendor: %s\n", |
|---|
| 494 | dmi_string(dm, data[4])); |
|---|
| 495 | printf("\t\tProduct: %s\n", |
|---|
| 496 | dmi_string(dm, data[5])); |
|---|
| 497 | printf("\t\tVersion: %s\n", |
|---|
| 498 | dmi_string(dm, data[6])); |
|---|
| 499 | printf("\t\tSerial Number: %s\n", |
|---|
| 500 | dmi_string(dm, data[7])); |
|---|
| 501 | break; |
|---|
| 502 | |
|---|
| 503 | case 3: |
|---|
| 504 | printf("\tChassis Information Block\n"); |
|---|
| 505 | printf("\t\tVendor: %s\n", |
|---|
| 506 | dmi_string(dm, data[4])); |
|---|
| 507 | printf("\t\tChassis Type: %s\n", |
|---|
| 508 | dmi_chassis_type(data[5])); |
|---|
| 509 | if (data[5] & 0x80) |
|---|
| 510 | printf("\t\t\tLock present\n"); |
|---|
| 511 | printf("\t\tVersion: %s\n", |
|---|
| 512 | dmi_string(dm, data[6])); |
|---|
| 513 | printf("\t\tSerial Number: %s\n", |
|---|
| 514 | dmi_string(dm, data[7])); |
|---|
| 515 | printf("\t\tAsset Tag: %s\n", |
|---|
| 516 | dmi_string(dm, data[8])); |
|---|
| 517 | break; |
|---|
| 518 | |
|---|
| 519 | case 4: |
|---|
| 520 | printf("\tProcessor\n"); |
|---|
| 521 | printf("\t\tSocket Designation: %s\n", |
|---|
| 522 | dmi_string(dm, data[4])); |
|---|
| 523 | printf("\t\tProcessor Type: %s\n", |
|---|
| 524 | dmi_processor_type(data[5])); |
|---|
| 525 | printf("\t\tProcessor Family: %s\n", |
|---|
| 526 | dmi_processor_family(data[6])); |
|---|
| 527 | printf("\t\tProcessor Manufacturer: %s\n", |
|---|
| 528 | dmi_string(dm, data[7])); |
|---|
| 529 | printf("\t\tProcessor Version: %s\n", |
|---|
| 530 | dmi_string(dm, data[0x10])); |
|---|
| 531 | if (dm->length <= 0x20) break; |
|---|
| 532 | printf("\t\tSerial Number: %s\n", |
|---|
| 533 | dmi_string(dm, data[0x20])); |
|---|
| 534 | printf("\t\tAsset Tag: %s\n", |
|---|
| 535 | dmi_string(dm, data[0x21])); |
|---|
| 536 | printf("\t\tVendor Part Number: %s\n", |
|---|
| 537 | dmi_string(dm, data[0x22])); |
|---|
| 538 | break; |
|---|
| 539 | |
|---|
| 540 | case 5: |
|---|
| 541 | printf("\tMemory Controller\n"); |
|---|
| 542 | break; |
|---|
| 543 | |
|---|
| 544 | case 6: |
|---|
| 545 | printf("\tMemory Bank\n"); |
|---|
| 546 | printf("\t\tSocket: %s\n", dmi_string(dm, data[4])); |
|---|
| 547 | if(data[5]!=0xFF) |
|---|
| 548 | { |
|---|
| 549 | printf("\t\tBanks: "); |
|---|
| 550 | if((data[5]&0xF0)!=0xF0) |
|---|
| 551 | printf("%d ", |
|---|
| 552 | data[5]>>4); |
|---|
| 553 | if((data[5]&0x0F)!=0x0F) |
|---|
| 554 | printf("%d", |
|---|
| 555 | data[5]&0x0F); |
|---|
| 556 | printf("\n"); |
|---|
| 557 | } |
|---|
| 558 | if(data[6]) |
|---|
| 559 | printf("\t\tSpeed: %dnS\n", data[6]); |
|---|
| 560 | printf("\t\tType: "); |
|---|
| 561 | dmi_decode_ram(data[7]); |
|---|
| 562 | printf("\n"); |
|---|
| 563 | printf("\t\tInstalled Size: "); |
|---|
| 564 | switch(data[9]&0x7F) |
|---|
| 565 | { |
|---|
| 566 | case 0x7D: |
|---|
| 567 | printf("Unknown");break; |
|---|
| 568 | case 0x7E: |
|---|
| 569 | printf("Disabled");break; |
|---|
| 570 | case 0x7F: |
|---|
| 571 | printf("Not Installed");break; |
|---|
| 572 | default: |
|---|
| 573 | printf("%dMbyte", |
|---|
| 574 | (1<<(data[9]&0x7F))); |
|---|
| 575 | } |
|---|
| 576 | if(data[9]&0x80) |
|---|
| 577 | printf(" (Double sided)"); |
|---|
| 578 | printf("\n"); |
|---|
| 579 | printf("\t\tEnabled Size: "); |
|---|
| 580 | switch(data[10]&0x7F) |
|---|
| 581 | { |
|---|
| 582 | case 0x7D: |
|---|
| 583 | printf("Unknown");break; |
|---|
| 584 | case 0x7E: |
|---|
| 585 | printf("Disabled");break; |
|---|
| 586 | case 0x7F: |
|---|
| 587 | printf("Not Installed");break; |
|---|
| 588 | default: |
|---|
| 589 | printf("%dMbyte", |
|---|
| 590 | (1<<(data[10]&0x7F))); |
|---|
| 591 | } |
|---|
| 592 | if(data[10]&0x80) |
|---|
| 593 | printf(" (Double sided)"); |
|---|
| 594 | printf("\n"); |
|---|
| 595 | if((data[11]&4)==0) |
|---|
| 596 | { |
|---|
| 597 | if(data[11]&(1<<0)) |
|---|
| 598 | printf("\t\t*** BANK HAS UNCORRECTABLE ERRORS (BIOS DISABLED)\n"); |
|---|
| 599 | if(data[11]&(1<<1)) |
|---|
| 600 | printf("\t\t*** BANK LOGGED CORRECTABLE ERRORS AT BOOT\n"); |
|---|
| 601 | } |
|---|
| 602 | break; |
|---|
| 603 | case 7: |
|---|
| 604 | { |
|---|
| 605 | static char *types[4]={ |
|---|
| 606 | "Internal ", "External ", |
|---|
| 607 | "", ""}; |
|---|
| 608 | static char *modes[4]={ |
|---|
| 609 | "write-through", |
|---|
| 610 | "write-back", |
|---|
| 611 | "",""}; |
|---|
| 612 | |
|---|
| 613 | printf("\tCache\n"); |
|---|
| 614 | printf("\t\tSocket: %s\n", |
|---|
| 615 | dmi_string(dm, data[4])); |
|---|
| 616 | u=data[6]<<8|data[5]; |
|---|
| 617 | printf("\t\tL%d %s%sCache: ", |
|---|
| 618 | 1+(u&7), (u&(1<<3))?"socketed ":"", |
|---|
| 619 | types[(u>>5)&3]); |
|---|
| 620 | if(u&(1<<7)) |
|---|
| 621 | printf("%s\n", |
|---|
| 622 | modes[(u>>8)&3]); |
|---|
| 623 | else |
|---|
| 624 | printf("disabled\n"); |
|---|
| 625 | printf("\t\tL%d Cache Size: ", 1+(u&7)); |
|---|
| 626 | dmi_cache_size(data[7]|data[8]<<8); |
|---|
| 627 | printf("\t\tL%d Cache Maximum: ", 1+(u&7)); |
|---|
| 628 | dmi_cache_size(data[9]|data[10]<<8); |
|---|
| 629 | printf("\t\tL%d Cache Type: ", 1+(u&7)); |
|---|
| 630 | dmi_decode_cache(data[13]); |
|---|
| 631 | printf("\n"); |
|---|
| 632 | } |
|---|
| 633 | break; |
|---|
| 634 | |
|---|
| 635 | case 8: |
|---|
| 636 | printf("\tPort Connector\n"); |
|---|
| 637 | printf("\t\tInternal Designator: %s\n", |
|---|
| 638 | dmi_string(dm, data[4])); |
|---|
| 639 | printf("\t\tInternal Connector Type: %s\n", |
|---|
| 640 | dmi_port_connector_type(data[5])); |
|---|
| 641 | printf("\t\tExternal Designator: %s\n", |
|---|
| 642 | dmi_string(dm, data[6])); |
|---|
| 643 | printf("\t\tExternal Connector Type: %s\n", |
|---|
| 644 | dmi_port_connector_type(data[7])); |
|---|
| 645 | printf("\t\tPort Type: %s\n", |
|---|
| 646 | dmi_port_type(data[8])); |
|---|
| 647 | break; |
|---|
| 648 | |
|---|
| 649 | |
|---|
| 650 | |
|---|
| 651 | case 9: |
|---|
| 652 | printf("\tCard Slot\n"); |
|---|
| 653 | printf("\t\tSlot: %s\n", |
|---|
| 654 | dmi_string(dm, data[4])); |
|---|
| 655 | printf("\t\tType: %s%s%s\n", |
|---|
| 656 | dmi_bus_width(data[6]), |
|---|
| 657 | dmi_card_size(data[8]), |
|---|
| 658 | dmi_bus_name(data[5])); |
|---|
| 659 | if(data[7]==3) |
|---|
| 660 | printf("\t\tStatus: Available.\n"); |
|---|
| 661 | if(data[7]==4) |
|---|
| 662 | printf("\t\tStatus: In use.\n"); |
|---|
| 663 | if(data[11]&0xFE) |
|---|
| 664 | dmi_card_props(data[11]); |
|---|
| 665 | break; |
|---|
| 666 | |
|---|
| 667 | case 10: |
|---|
| 668 | printf("\tOn Board Devices Information\n"); |
|---|
| 669 | for (u=0; u<((dm->length - 4)/2); u++) { |
|---|
| 670 | printf("\t\tDescription: %s : %s\n", |
|---|
| 671 | dmi_string(dm, data[5+(2*u)]), |
|---|
| 672 | (data[4+(2*u)]) & 0x80 ? |
|---|
| 673 | "Enabled" : "Disabled"); |
|---|
| 674 | printf("\t\tType: %s\n", |
|---|
| 675 | dmi_onboard_type(data[4+(2*u)])); |
|---|
| 676 | |
|---|
| 677 | } |
|---|
| 678 | |
|---|
| 679 | break; |
|---|
| 680 | |
|---|
| 681 | |
|---|
| 682 | case 11: |
|---|
| 683 | printf("\tOEM Data\n"); |
|---|
| 684 | for(u=1;u<=data[4];u++) |
|---|
| 685 | printf("\t\t%s\n", dmi_string(dm,u)); |
|---|
| 686 | break; |
|---|
| 687 | case 12: |
|---|
| 688 | printf("\tConfiguration Information\n"); |
|---|
| 689 | for(u=1;u<=data[4];u++) |
|---|
| 690 | printf("\t\t%s\n", dmi_string(dm,u)); |
|---|
| 691 | break; |
|---|
| 692 | |
|---|
| 693 | case 13: |
|---|
| 694 | printf("\tBIOS Language Information\n"); |
|---|
| 695 | break; |
|---|
| 696 | |
|---|
| 697 | case 14: |
|---|
| 698 | printf("\tGroup Associations\n"); |
|---|
| 699 | for (u=0; u<(dm->length - 5)/3 ; u++) { |
|---|
| 700 | printf("\t\tGroup Name: %s\n", |
|---|
| 701 | dmi_string(dm,data[4])); |
|---|
| 702 | printf("\t\t\tType: 0x%02x\n", *(data+5+(u*3))); |
|---|
| 703 | printf("\t\t\tHandle: 0x%04x\n", |
|---|
| 704 | *(u16*)(data+6+(u*3))); |
|---|
| 705 | } |
|---|
| 706 | break; |
|---|
| 707 | |
|---|
| 708 | |
|---|
| 709 | case 15: |
|---|
| 710 | printf("\tEvent Log\n"); |
|---|
| 711 | printf("\t\tLog Area: %d bytes.\n", |
|---|
| 712 | data[5]<<8|data[4]); |
|---|
| 713 | printf("\t\tLog Header At: %d.\n", |
|---|
| 714 | data[7]<<8|data[6]); |
|---|
| 715 | printf("\t\tLog Data At: %d.\n", |
|---|
| 716 | data[9]<<8|data[8]); |
|---|
| 717 | printf("\t\tLog Type: %d.\n", |
|---|
| 718 | data[10]); |
|---|
| 719 | if(data[11]&(1<<0)) |
|---|
| 720 | printf("\t\tLog Valid: Yes.\n"); |
|---|
| 721 | if(data[11]&(1<<1)) |
|---|
| 722 | printf("\t\t**Log Is Full**.\n"); |
|---|
| 723 | break; |
|---|
| 724 | |
|---|
| 725 | case 16: |
|---|
| 726 | printf("\tPhysical Memory Array\n"); |
|---|
| 727 | break; |
|---|
| 728 | case 17: |
|---|
| 729 | printf("\tMemory Device\n"); |
|---|
| 730 | break; |
|---|
| 731 | case 18: |
|---|
| 732 | printf("\t32-bit Memory Error Information\n"); |
|---|
| 733 | break; |
|---|
| 734 | case 19: |
|---|
| 735 | printf("\tMemory Array Mapped Address\n"); |
|---|
| 736 | break; |
|---|
| 737 | case 20: |
|---|
| 738 | printf("\tMemory Device Mapped Address\n"); |
|---|
| 739 | break; |
|---|
| 740 | case 24: |
|---|
| 741 | printf("\tHardware Security\n"); |
|---|
| 742 | break; |
|---|
| 743 | case 25: |
|---|
| 744 | printf("\tSystem Power Controls\n"); |
|---|
| 745 | break; |
|---|
| 746 | case 32: |
|---|
| 747 | printf("\tSystem Boot Information\n"); |
|---|
| 748 | break; |
|---|
| 749 | case 126: |
|---|
| 750 | printf("\tInactive\n"); |
|---|
| 751 | break; |
|---|
| 752 | |
|---|
| 753 | case 127: |
|---|
| 754 | printf("\tEnd-of-Table\n"); |
|---|
| 755 | break; |
|---|
| 756 | |
|---|
| 757 | default: |
|---|
| 758 | if (dm->length > 4) |
|---|
| 759 | dump_raw_data(data+4, dm->length-4); |
|---|
| 760 | break; |
|---|
| 761 | |
|---|
| 762 | |
|---|
| 763 | |
|---|
| 764 | } |
|---|
| 765 | data+=dm->length; |
|---|
| 766 | while(*data || data[1]) |
|---|
| 767 | data++; |
|---|
| 768 | data+=2; |
|---|
| 769 | i++; |
|---|
| 770 | } |
|---|
| 771 | free(buf); |
|---|
| 772 | } |
|---|
| 773 | |
|---|
| 774 | |
|---|
| 775 | char key[8]={'R','S','D',' ','P','T','R',' '}; |
|---|
| 776 | |
|---|
| 777 | char zot[16]; |
|---|
| 778 | |
|---|
| 779 | int main(int argc, char *argv[]) |
|---|
| 780 | { |
|---|
| 781 | unsigned char buf[20]; |
|---|
| 782 | int fd=open("/dev/mem", O_RDONLY); |
|---|
| 783 | long fp=0xE0000L; |
|---|
| 784 | if(fd==-1) |
|---|
| 785 | { |
|---|
| 786 | perror("/dev/mem"); |
|---|
| 787 | exit(1); |
|---|
| 788 | } |
|---|
| 789 | if(lseek(fd,fp,0)==-1) |
|---|
| 790 | { |
|---|
| 791 | perror("seek"); |
|---|
| 792 | exit(1); |
|---|
| 793 | } |
|---|
| 794 | |
|---|
| 795 | |
|---|
| 796 | fp -= 16; |
|---|
| 797 | |
|---|
| 798 | while( fp < 0xFFFFF) |
|---|
| 799 | { |
|---|
| 800 | fp+=16; |
|---|
| 801 | if(read(fd, buf, 16)!=16) |
|---|
| 802 | perror("read"); |
|---|
| 803 | // if(memcmp(buf, zot, 16)==0) |
|---|
| 804 | // printf("*"); |
|---|
| 805 | if(memcmp(buf, "_SM_", 4)==0) { |
|---|
| 806 | printf("SMBIOS %d.%d present.\n", buf[6], buf[7]); |
|---|
| 807 | } |
|---|
| 808 | |
|---|
| 809 | if(memcmp(buf, "_SYSID_", 7)==0) |
|---|
| 810 | printf("SYSID present.\n"); |
|---|
| 811 | if(memcmp(buf, "_DMI_", 5)==0) |
|---|
| 812 | { |
|---|
| 813 | u16 num=buf[13]<<8|buf[12]; |
|---|
| 814 | u16 len=buf[7]<<8|buf[6]; |
|---|
| 815 | u32 base=buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8]; |
|---|
| 816 | |
|---|
| 817 | printf("DMI %d.%d present.\n", |
|---|
| 818 | buf[14]>>4, buf[14]&0x0F); |
|---|
| 819 | printf("%d structures occupying %d bytes.\n", |
|---|
| 820 | buf[13]<<8|buf[12], |
|---|
| 821 | buf[7]<<8|buf[6]); |
|---|
| 822 | printf("DMI table at 0x%08X.\n", |
|---|
| 823 | buf[11]<<24|buf[10]<<16|buf[9]<<8|buf[8]); |
|---|
| 824 | dmi_table(fd, base,len, num); |
|---|
| 825 | } |
|---|
| 826 | if(memcmp(buf, "$PnP", 4)==0) |
|---|
| 827 | printf("PNP BIOS present.\n"); |
|---|
| 828 | if(memcmp(buf, key, 8)==0) |
|---|
| 829 | { |
|---|
| 830 | int a; |
|---|
| 831 | unsigned char sum=0; |
|---|
| 832 | unsigned int i=0, checksum=0; |
|---|
| 833 | printf("RSD PTR found at 0x%lX\n", fp); |
|---|
| 834 | for (i=0; i<20; i++) checksum += buf[i]; |
|---|
| 835 | if (checksum != 0) { |
|---|
| 836 | printf("checksum failed.\n"); |
|---|
| 837 | } |
|---|
| 838 | |
|---|
| 839 | if(buf[15]!=0) |
|---|
| 840 | { |
|---|
| 841 | printf("Reserved check failed.\n"); |
|---|
| 842 | } |
|---|
| 843 | printf("OEM "); |
|---|
| 844 | fwrite(buf+9, 6, 1, stdout); |
|---|
| 845 | printf("\n"); |
|---|
| 846 | read(fd,buf+16,4); |
|---|
| 847 | lseek(fd, -4, 1); |
|---|
| 848 | for(a=0;a<20;a++) |
|---|
| 849 | sum+=buf[a]; |
|---|
| 850 | if(sum!=0) |
|---|
| 851 | printf("Bad checksum.\n"); |
|---|
| 852 | } |
|---|
| 853 | } |
|---|
| 854 | close(fd); |
|---|
| 855 | return 0; |
|---|
| 856 | } |
|---|