Repository navigation
CBiosTable
Home › All Categories › sys/win › sys/win/dmi › CBiosTable
Loads the SMBIOS firmware tables and reads the strings and numbers of one structure.
The firmware describes the hardware as a run of SMBIOS structures, each with a type number: 0 for the BIOS, 1 for the system, 2 for the motherboard, 3 for the chassis, 4 for a processor, 17 for a memory device, and so on. A structure is a formatted area of fields at fixed offsets followed by its strings. A field that holds text holds a string number (1 for the first string after the formatted area, 2 for the second, 0 for none), and GetString follows it to the text.
A CBiosTable is created for one type. The constructor copies the whole SMBIOS table from
Windows and keeps a pointer to the first structure of that type; the getters read fields of
that structure by their offset in the SMBIOS specification.
The table of common fields below lists the offsets most programs need.
What to keep in mind:
- Missing is quiet. When Windows cannot supply the table or the firmware has no structure of the type, every getter returns 0 or an empty string. GetTable returns 0 then; test it to tell "no structure" from "a field that is 0".
-
The first structure only. A machine with two processors or four memory modules has two or
four structures of that type;
CBiosTablereads the first. -
Offsets are not checked by the number getters. A field added by a later version of the
specification is past the end of an older firmware's structure, and reading it returns
whatever follows. Compare the offset with
GetTable()->Lengthfirst when the field is from SMBIOS 2.4 or later. GetString does check. -
GetByteis signed. A byte of&h80or more comes back negative from GetByte: 255 is −1. Use GetUByte for values up to 255. -
Strings keep their padding. Some firmware pads a string with spaces, the processor name
most often;
trimit.
The object frees the copy of the table when it goes out of scope. A temporary such as
CBiosTable( 0 ).GetString( &h04 ) loads the whole table for one field; to read several fields
of a type, keep one object.
#import "sys/win"
#import "sys/win/dmi"
using win, dmiReads the first processor and the chassis:
#import "sys/win"
#import "sys/win/dmi"
using win, dmi
dim cpu as CBiosTable = 4
if cpu.GetTable() = 0 then
print "this firmware has no processor information"
else
print "socket: "; cpu.GetString( &h04 )
print "maker: "; cpu.GetString( &h07 )
print "model: "; trim( cpu.GetString( &h10 ) )
print "cores: "; cpu.GetUByte( &h23 ); ", threads:"; cpu.GetUByte( &h25 )
print "max speed:"; cpu.GetWord( &h14 ); " MHz"
print "id: "; hex( cpu.GetQWord( &h08 ), 16 )
end if
dim chassis as CBiosTable = 3
print "chassis type:"; chassis.GetUByte( &h05, &h7F )On one desktop it prints:
socket: AM5
maker: Advanced Micro Devices, Inc.
model: AMD Ryzen 9 7950X3D 16-Core Processor
cores: 16, threads:32
max speed:5750 MHz
id: 178BFBFF00A60F12
chassis type:3
Chassis type 3 is a desktop; the specification lists the others (9 a laptop, 10 a notebook, 17 a main server chassis …).
| Member | Does |
|---|---|
| Constructor | Loads the SMBIOS table and finds the first structure of a type. |
| Destructor | Frees the copy of the table. |
| GetTable | Returns a pointer to the structure found, or 0. |
| FindTable | Finds the first structure of another type in the same table. |
| GetString | Returns the text of a string field. |
| GetByte | Returns a byte field, signed, optionally masked. |
| GetUByte | Returns a byte field, unsigned, optionally masked. |
| GetWord | Returns a 16-bit field. |
| GetDWord | Returns a 32-bit field. |
| GetQWord | Returns a 64-bit field. |
Offsets are hexadecimal, as in the specification; the version is the first SMBIOS version that has the field.
| Type | Offset | Field | Read with | Version |
|---|---|---|---|---|
| 0 BIOS | &h04 |
Vendor | GetString |
2.0 |
| 0 | &h05 |
Version | GetString |
2.0 |
| 0 | &h08 |
Release date, mm/dd/yyyy
|
GetString |
2.0 |
| 0 | &h09 |
ROM size, (n + 1) × 64 KB; &hFF means see &h18
|
GetUByte |
2.0 |
| 0 | &h0A |
Characteristics, bit flags | GetQWord |
2.0 |
| 0 |
&h12, &h13
|
Characteristics extension bytes | GetUByte |
2.4 |
| 0 | &h18 |
Extended ROM size: bits 0–13 the size, bits 14–15 the unit (0 MB, 1 GB) | GetWord |
3.1 |
| 1 System | &h04 |
Manufacturer | GetString |
2.0 |
| 1 | &h05 |
Product name | GetString |
2.0 |
| 1 | &h06 |
Version | GetString |
2.0 |
| 1 | &h07 |
Serial number | GetString |
2.0 |
| 1 | &h08 |
UUID, 16 bytes; see SMBIOS_GetSystemUUID | — | 2.1 |
| 1 | &h18 |
Wake-up type | GetUByte |
2.1 |
| 1 | &h19 |
SKU number | GetString |
2.4 |
| 1 | &h1A |
Family | GetString |
2.4 |
| 2 Baseboard | &h04 |
Manufacturer | GetString |
— |
| 2 | &h05 |
Product | GetString |
— |
| 2 | &h06 |
Version | GetString |
— |
| 2 | &h07 |
Serial number | GetString |
— |
| 2 | &h08 |
Asset tag | GetString |
— |
| 3 Chassis | &h04 |
Manufacturer | GetString |
2.0 |
| 3 | &h05 |
Type in bits 0–6 (mask &h7F), a lock in bit 7 (mask &h80) |
GetUByte |
2.0 |
| 3 | &h06 |
Version | GetString |
2.0 |
| 3 | &h07 |
Serial number | GetString |
2.0 |
| 3 | &h08 |
Asset tag | GetString |
2.0 |
| 4 Processor | &h04 |
Socket | GetString |
2.0 |
| 4 | &h05 |
Processor type | GetUByte |
2.0 |
| 4 | &h06 |
Family | GetUByte |
2.0 |
| 4 | &h07 |
Manufacturer | GetString |
2.0 |
| 4 | &h08 |
Processor ID, 8 bytes (what CPUID reports) |
GetQWord |
2.0 |
| 4 | &h10 |
Version, the processor's name | GetString |
2.0 |
| 4 | &h12 |
External clock, MHz | GetWord |
2.0 |
| 4 | &h14 |
Maximum speed, MHz | GetWord |
2.0 |
| 4 | &h16 |
Current speed, MHz | GetWord |
2.0 |
| 4 | &h20 |
Serial number | GetString |
2.3 |
| 4 | &h21 |
Asset tag | GetString |
2.3 |
| 4 | &h22 |
Part number | GetString |
2.3 |
| 4 | &h23 |
Core count | GetUByte |
2.5 |
| 4 | &h25 |
Thread count | GetUByte |
2.5 |
| 17 Memory device | &h10 |
Device locator, the slot's label | GetString |
2.1 |
| 17 | &h11 |
Bank locator | GetString |
2.1 |
| 17 | &h17 |
Manufacturer | GetString |
2.3 |
| 17 | &h18 |
Serial number | GetString |
2.3 |
| 17 | &h19 |
Asset tag | GetString |
2.3 |
| 17 | &h1A |
Part number | GetString |
2.3 |
The bits of the BIOS characteristics are listed on the firmware functions page.
constructor( byval wantedType as byte )Copies the SMBIOS table with GetSystemFirmwareTable (provider RSMB) and finds the first
structure of type wantedType. If the table cannot be read or has no structure of that type,
the object is empty: GetTable returns 0 and every getter 0 or "".
| Parameter | Meaning |
|---|---|
wantedType |
The SMBIOS structure type, 0 to 127. |
Example
dim bios as CBiosTable = 0
print bios.GetString( &h04 )
print CBiosTable( 1 ).GetString( &h05 ) ' a temporary, for one fieldMicrosoft Learn: GetSystemFirmwareTable
destructorFrees the copy of the SMBIOS table. A pointer returned by GetTable points into it and is not valid afterwards.
function GetTable() as RawSMBIOSTable ptrReturns a pointer to the structure found: its header gives the type, the length of the formatted area and the handle, and the fields follow it.
Returns the pointer, or 0 if no structure was found.
Example
dim mem as CBiosTable = 17
dim p as RawSMBIOSTable ptr = mem.GetTable()
if p then print "memory device structure,"; p->Length; " bytes, handle"; p->Handlefunction FindTable( byval wantedType as byte ) as booleanFinds the first structure of another type in the table the object already holds, and makes it the one the getters read. The constructor calls it; call it to read several types from one copy of the table.
| Parameter | Meaning |
|---|---|
wantedType |
The SMBIOS structure type. |
Returns true if a structure of that type was found. On false the getters keep reading
the structure found before.
Example
dim t as CBiosTable = 0
print "BIOS: "; t.GetString( &h04 )
if t.FindTable( 2 ) then print "board: "; t.GetString( &h05 )function GetString( byval offset as long ) as stringReads the string number stored in the byte at offset and returns that string from the
structure's string area.
| Parameter | Meaning |
|---|---|
offset |
The offset of a string field in the formatted area. |
Returns the text as the firmware stored it, or "" if there is no structure, the offset is past the formatted area, or the field's string number is 0.
Example
print "serial number: "; CBiosTable( 1 ).GetString( &h07 )function GetByte( byval offset as long ) as byte
function GetByte( byval offset as long, byval bitAnd as byte ) as byteReturns the byte at offset, as a signed byte: values from &h80 up come back negative. With
bitAnd the byte is masked with it first.
| Parameter | Meaning |
|---|---|
offset |
The offset of the field. |
bitAnd |
A mask to and the byte with. |
Returns the byte, or 0 if there is no structure.
Example
if CBiosTable( 3 ).GetByte( &h05, &h80 ) then print "the chassis has a lock"function GetUByte( byval offset as long ) as ubyte
function GetUByte( byval offset as long, byval bitAnd as byte ) as ubyteReturns the byte at offset as an unsigned value from 0 to 255. With bitAnd the byte is
masked with it first.
| Parameter | Meaning |
|---|---|
offset |
The offset of the field. |
bitAnd |
A mask to and the byte with. |
Returns the byte, or 0 if there is no structure.
Example
print "processor family:"; CBiosTable( 4 ).GetUByte( &h06 )
print "chassis type:"; CBiosTable( 3 ).GetUByte( &h05, &h7F )function GetWord( byval offset as long ) as WORDReturns the 16-bit field at offset.
| Parameter | Meaning |
|---|---|
offset |
The offset of the field. |
Returns the value, or 0 if there is no structure.
Example
print "current speed:"; CBiosTable( 4 ).GetWord( &h16 ); " MHz"function GetDWord( byval offset as long ) as DWORDReturns the 32-bit field at offset.
| Parameter | Meaning |
|---|---|
offset |
The offset of the field. |
Returns the value, or 0 if there is no structure.
Example
' memory device, SMBIOS 2.7+: the extended size in MB, when the size field at &h0C is &h7FFF
dim mem as CBiosTable = 17
if mem.GetWord( &h0C ) = &h7FFF then print mem.GetDWord( &h1C ); " MB"function GetQWord( byval offset as long ) as ulongintReturns the 64-bit field at offset, read as eight bytes, lowest first.
| Parameter | Meaning |
|---|---|
offset |
The offset of the field. |
Returns the value, or 0 if there is no structure.
Example
print "processor id: "; hex( CBiosTable( 4 ).GetQWord( &h08 ), 16 )- Firmware functions: the BIOS fields as functions, and the structures
- SMBIOS specification (DMTF)
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Android (experimental)
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Move Semantics
- Match
- Lambdas
- Block Strings
- String Interpolation
- Partial Types
- String Slices
- Array Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Time Zones
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Hardware
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- tiko test
- tiko doc
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing