追踨法蘭克

2015年8月8日 星期六

SMBIOS (System Management BIOS)

SMBIOS (System Management BIOS) 是一個標準 由 DMTF所開發,這個標準的目的是允許作業系統去獲取電腦的資訊。
在設定SMBIOS方面,我們會在Memory的某個地方建立一個Table. 經由解析這個Table,它是可以存取電腦資訊和電腦屬性。

SMBIOS 在 BIOS 會設定之,在POST 階段於各硬體Module 會依據不同的type 存於Memory 中。

SMBIOS Entry Point Table的位置




SMBIOS Entry Point Table的位置在Memory 0xF0000 和 0xFFFFF, 且必需為16-byte boundary,去搜尋其表格的開始於特定的位置,是需要在Memory搜尋字串"_SM_", 且核對結構的checksum.

如何存取SMBIOS 以下程式


    char *mem = (unsigned char *) 0xF0000;
    int length, i;
    unsigned char checksum;
    while ((unsigned int) mem < 0x100000) {
        if (mem[0] == '_' && mem[1] == 'S' && mem[2] == 'M' && mem[3] == '_') {
            length = mem[5];
            checksum = 0;
            for(i = 0; i < length; i++) {
                checksum += mem[i];
            }
            if(checksum == 0) break;
        }
        mem += 16;
    }

解析其Entry Point Table

 其Entry point table 有以下的結構:

 struct SMBIOSEntryPoint {
  char EntryPointString[4];    //This is _SM_
  uchar Checksum;              //This value summed with all the values of the table, should be 0 (overflow)
  uchar Length;                //Length of the Entry Point Table. Since version 2.1 of SMBIOS, this is 0x1F
  uchar MajorVersion;          //Major Version of SMBIOS
  uchar MinorVersion;          //Minor Version of SMBIOS
  ushort MaxStructureSize;     //Maximum size of a SMBIOS Structure (we will se later)
  uchar EntryPointRevision;    //...
  char FormattedArea[5];       //...
  char EntryPointString2[5];   //This is _DMI_
  uchar Checksum2;             //Checksum for values from EntryPointString2 to the end of table
  ushort TableLength;          //Length of the Table containing all the structures
  uint TableAddress;      //Address of the Table
  ushort NumberOfStructures;   //Number of structures in the table
  uchar BCDRevision;           //Unused
 };

Header Types

 struct SMBIOSHeader {
  uchar Type;
  uchar Length;
  ushort Handle;
 };

CodeDescription
0BIOS Information
1System Information
2Mainboard Information
3Enclosure/Chasis Information
4Processor Information
7Cache Information
9System Slots Information
16Physical Memory Array
17Memory Device Information
19Memory Mapped Device Mapped Address's
32System Boot Information

4 則留言:

  1. How to get the SMBIOS under UEFI mode?

    回覆刪除
  2. 可以在SystemTable->ConfigurationTable 下 搜尋SMBIOS_TABLE_GUID
    {0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d}

    回覆刪除
  3. 不是 {F2FD1544-9794-4A2C-992E-762 E5BBCF20E394} 嗎

    回覆刪除
  4. 您好有一些問題想請問
    如果在這裡寫一些重要資訊ex:uuid ,這一塊記憶體是否有可能會遺失?
    他是否是吃主板上那顆電源的電池來維持記憶體內容?
    感謝!

    回覆刪除