- Timestamp:
- 11/01/09 02:45:30 (3 years ago)
- Children:
- 2df3ca15dc0c07d30f29f98e442f10bf8ac2f7e7
- Parents:
- a1d88954b2913bb6b992077accad6b23c6767abe
- git-committer:
- Pierre-Alexandre Meyer <pierre@mouraf.org> / 2009-10-31T19:45:30Z-0700
- Files:
-
- 1 modified
-
com32/gpllib/dmi/dmi.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
com32/gpllib/dmi/dmi.c
ra1d889 rdee3fa 445 445 } 446 446 447 int dmi_checksum(uint8_t * buf, int len)447 int checksum(uint8_t * buf, int len) 448 448 { 449 449 uint8_t sum = 0; … … 482 482 buf[11] << 24 | buf[10] << 16 | buf[9] << 8 | buf[8]; 483 483 484 /* Version already found? */ 484 485 if (dmi->dmitable.ver>0) return DMI_TABLE_PRESENT; 485 486 … … 491 492 */ 492 493 if (buf[14] != 0) { 493 dmi->dmitable.major_version = buf[14] >> 4;494 dmi->dmitable.minor_version = buf[14] & 0x0F;494 dmi->dmitable.major_version = buf[14] >> 4; 495 dmi->dmitable.minor_version = buf[14] & 0x0F; 495 496 } else { 496 dmi->dmitable.major_version = 0;497 dmi->dmitable.minor_version = 0;497 dmi->dmitable.major_version = 0; 498 dmi->dmitable.minor_version = 0; 498 499 } 499 500 return DMI_TABLE_PRESENT; … … 503 504 int dmi_iterate(s_dmi * dmi) 504 505 { 505 uint8_t buf[DMI_BUFFER_SIZE];506 char *p, *q;506 uint8_t *p, *q; 507 int found = 0; 507 508 508 509 /* Cleaning structures */ … … 526 527 dmi->system.filled = false; 527 528 528 p = (char *)0xF0000; /* The start address to look at the dmi table */ 529 p = (uint8_t *)0xF0000; /* The start address to look at the dmi table */ 530 /* The anchor-string is 16-bytes aligned */ 529 531 for (q = p; q < p + 0x10000; q += 16) { 530 memcpy(buf, q, 15); 531 if (memcmp(buf, "_SM_", 4) == 0) { 532 smbios_decode(dmi,buf); 533 } 534 if (memcmp(buf, "_DMI_", 5) == 0 && dmi_checksum(buf,sizeof(buf))) { 535 return legacy_decode(dmi,buf); 536 } 537 } 532 /* To validate the presence of SMBIOS: 533 * + the overall checksum must be correct 534 * + the intermediate anchor-string must be _DMI_ 535 * + the intermediate checksum must be correct 536 */ 537 if (memcmp(q, "_SM_", 4) == 0 && 538 checksum(q, q[0x05]) && 539 memcmp(q + 0x10, "_DMI_", 5)==0 && 540 checksum(q + 0x10, 0x0F)) { 541 /* Do not return, legacy_decode will need to be called 542 * on the intermediate structure to get the table length 543 * and address 544 */ 545 smbios_decode(dmi, q); 546 } else if (memcmp(q, "_DMI_", 5) == 0 && checksum(q, 0x0F)) { 547 found = 1; 548 legacy_decode(dmi, q); 549 } 550 } 551 552 if (found) 553 return DMI_TABLE_PRESENT; 554 538 555 dmi->dmitable.base = 0; 539 556 dmi->dmitable.num = 0;
