System Management BIOS: Difference between revisions

From OSDev.wiki
Jump to navigation Jump to search
[unchecked revision][unchecked revision]
Content added Content deleted
m (System Managenent BIOS moved to System Management BIOS: Spelling Error in title)
(Some grammer fixes and some rewording)
Line 1: Line 1:
System Management [[BIOS]] (SMBIOS) is a standard developed by [http://dmft.org DMFT].
System Management [[BIOS]] (SMBIOS) is a standard developed by [http://dmft.org DMFT].
This standard consist in give informations about the system to the OS.
The purpose of this standard is to allow the operating system to retrieve information about the PC.


On booting, the SMBIOS, puts a table somewhere in the memory. By reading this table we can know all the component of the computer, your OS is running on.
On booting the SMBIOS will put a table somewhere in memory. By parsing this table it is possible to access information about the computer and its capabilities.


== Locating the SMBIOS Entry Point Table ==
The SMBIOS Entry Point Table is somewhere between the addresses 0xF0000 and 0xFFFFF. You can find it by looking for the string "_SM_" in that piece of memory.


The SMBIOS Entry Point Table is located somewhere between the addresses 0xF0000 and 0xFFFFF. To find the specific location of the start of the table it is necessary to search that region of memory for the string "_SM_".
I use this:

One example of how this can be done is demonstrated in the below code.
char *mem = (char *) 0xF0000;
char *mem = (char *) 0xF0000;
while ((Bit32u) mem < 0x100000) {
while ((Bit32u) mem < 0x100000) {
Line 21: Line 23:
}
}


To read the Entry Point Table, I use a structure like this:
== Parsing the Entry Point Table ==

The entry point table has the following structure
struct SMBIOSEntryPoint {
struct SMBIOSEntryPoint {
char EntryPointString[4]; //This is _SM_
char EntryPointString[4]; //This is _SM_
Line 39: Line 43:
};
};


TableAddress contains the address of the Table wich contain all the structures with the infos of the pc.
TableAddress contains the address of the table that contains all the structures with information about the PC.
From [TableAddress] to [TableAddress + TableLength], there are all data.
All of the structures are located from [TableAddress] to [TableAddress + TableLength].
The structures are located directly adjacent to each other in memory, with a new structure beginning as soon as another one ends.
At the end of one structure, another starts.
Each structure is composed of a header, a structure specific table, string table
Each structure is composed of a header, a structure specific table, and a string table.

The header is:
The format of the header is as follows.
struct SMBIOSHeader {
struct SMBIOSHeader {
uchar Type;
uchar Type;
Line 50: Line 55:
};
};


So at TableAddress you find a SMBIOSHeader Struct.
Located at TableAddress is a SMBIOS header.
Type indicates wich element are you seeing (0 = BIOS, 1 = System, 2 = Chassis, 3 = Processors, ...)
The value of Type indicates what element the structure contains information about. (0 = BIOS, 1 = System, 2 = Chassis, 3 = Processors, ...)
Length indicates the size of header + data table. The strings are not included in the count.
Length indicates the size of header + data table. The strings are not included in the length.


At the end of the header, you can find the data table. At the end of that table (Address + Length), the strings section starts. Each string is NULL terminated and is limited of 64 characters.
Immediately after the end of the header is the data. At the end of the data table (Address + Length), the strings section starts. Each string is NULL terminated and is limited to 64 characters.


eg: the BIOS Struct (Type 0) is like this:
eg: the BIOS Struct (Type 0) is like this:
Line 75: Line 80:
db 0 ; End of structure
db 0 ; End of structure


At the end of the bios table, another table will start.
At the end of the BIOS table, another table will start.
The last structure has type 127.
The last structure has type 127.



Revision as of 22:28, 6 March 2008

System Management BIOS (SMBIOS) is a standard developed by DMFT. The purpose of this standard is to allow the operating system to retrieve information about the PC.

On booting the SMBIOS will put a table somewhere in memory. By parsing this table it is possible to access information about the computer and its capabilities.

Locating the SMBIOS Entry Point Table

The SMBIOS Entry Point Table is located somewhere between the addresses 0xF0000 and 0xFFFFF. To find the specific location of the start of the table it is necessary to search that region of memory for the string "_SM_".

One example of how this can be done is demonstrated in the below code.

char *mem = (char *) 0xF0000;
while ((Bit32u) mem < 0x100000) {
	if (mem[0] == '_' && mem[1] == 'S' && mem[2] == 'M' && mem[3] == '_') {
		break;
	}
	mem++;
}

Now mem contains the address of the Entry Point Table. Some old systems may not have the SMBIOS. So...

if ((unsigned int) mem == 0x100000) {
	panic("No SMBIOS found!");
}

Parsing the Entry Point Table

The entry point table has the following structure

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
};

TableAddress contains the address of the table that contains all the structures with information about the PC. All of the structures are located from [TableAddress] to [TableAddress + TableLength]. The structures are located directly adjacent to each other in memory, with a new structure beginning as soon as another one ends. Each structure is composed of a header, a structure specific table, and a string table.

The format of the header is as follows.

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

Located at TableAddress is a SMBIOS header. The value of Type indicates what element the structure contains information about. (0 = BIOS, 1 = System, 2 = Chassis, 3 = Processors, ...) Length indicates the size of header + data table. The strings are not included in the length.

Immediately after the end of the header is the data. At the end of the data table (Address + Length), the strings section starts. Each string is NULL terminated and is limited to 64 characters.

eg: the BIOS Struct (Type 0) is like this:

db 0 ; Indicates BIOS Structure Type            |
db 13h ; Length of information in bytes         | HEADER
dw ? ; Reserved for handle                      |
db 01h ; String 1 is the Vendor Name            |
db 02h ; String 2 is the BIOS version           |
dw 0E800h ; BIOS Starting Address               |
db 03h ; String 3 is the BIOS Build Date        | DATA
db 1 ; Size of BIOS ROM is 128K (64K * (1 + 1)) |
dq BIOS_Char ; BIOS Characteristics             |
db 0 ; BIOS Characteristics Extension Byte 1    |
db ‘System BIOS Vendor Name’,0 ;                |
db ‘4.04’,0 ;                                   | STRINGS
db ‘00/00/0000’,0 ;                             |
db 0 ; End of structure

At the end of the BIOS table, another table will start. The last structure has type 127.

External links