#include <ISmbios.h>
Inheritance diagram for ISmbiosItem:
Public Types | |
enum | { FIELD_LEN_BYTE = 1, FIELD_LEN_WORD = 2, FIELD_LEN_DWORD = 4, FIELD_LEN_QWORD = 8 } |
Public Member Functions | |
virtual | ~ISmbiosItem () |
ISmbiosItem () | |
virtual std::auto_ptr< const ISmbiosItem > | clone () const =0 |
virtual std::auto_ptr< ISmbiosItem > | clone ()=0 |
virtual std::ostream & | streamify (std::ostream &cout) const =0 |
virtual u8 | getType () const =0 |
virtual u8 | getLength () const =0 |
virtual u16 | getHandle () const =0 |
virtual u8 | getU8 (unsigned int offset) const =0 |
virtual u16 | getU16 (unsigned int offset) const =0 |
virtual u32 | getU32 (unsigned int offset) const =0 |
virtual u64 | getU64 (unsigned int offset) const =0 |
virtual u8 | getU8 (const std::string field) const =0 |
virtual u16 | getU16 (const std::string field) const =0 |
virtual u32 | getU32 (const std::string field) const =0 |
virtual u64 | getU64 (const std::string field) const =0 |
virtual const char * | getString (unsigned int header_offset) const =0 |
virtual const char * | getString (const std::string field) const =0 |
virtual u32 | getBitfield (unsigned int offset, unsigned int fieldLen, unsigned int lsb, unsigned int msb=0) const =0 |
virtual u32 | getBitfield (const std::string field, const std::string bitField) const =0 |
virtual const u8 * | getBufferCopy (size_t &length) const =0 |
virtual const size_t | getBufferSize () const =0 |
Returns the buffer size of the item. | |
virtual const char * | getStringByStringNumber (u8) const =0 |
Theory of Operation
The ISmbiosItem class models access to individual items in the SMBIOS table. It does this by providing a set of accessor functions that allow structured data to be pulled out of the item.
There are two modes of operation, depending on how the ISmbiosTable is set up. First, normal mode allows clients to access any information in the Item by offset and length. This access mode imposes no checks or typing requirements on the data being accessed aside from bounds checking that no buffer overruns occur. The drawback of this mode is that the client code must always know the exact data length and offset of any data that they want to extract.
The next mode of operation is XML enhanced operation. In this mode, the client can pass in strings representing what data is requested. The item will use an XML file to look up the exact offset of this data using the string passed as a referenced. Then the item returns the data to the client. The advantage of this access mode is that data is strongly typed, and the client is prevented from invalid access modes. For example, they may not access half of a u16 data item using the getU8() function call.
Class Hierarchy
The class heirarchy for ISmbiosItem is simple. The abstract interface class is ISmbiosItem. The full implementation of normal-mode access is in SmbiosItem, and the XML enhanced mode access is implemented in SmbiosItemXml (formerly SmbiosItemAccess).
Implementation
The SmbiosItem is implemented with its own data buffer for item data. This is reasonable as the max size for any single item is 256 bytes of data. Upon construction, the Item copies the relevant item data out of the containing table and from then maintains its own memory buffer.
Lifetime and Ownership
The SmbiosItem is destroyed when the containing table is destroyed. There is no method to allow the table to release an item. The copy constructor is purposefully made 'private' to the Item to disallow third parties from taking bad references to individual items.
Definition at line 275 of file ISmbios.h.
|
|
|
Destructor Definition at line 36 of file SmbiosItem.cpp. |
|
Definition at line 39 of file SmbiosItem.cpp. |
|
Implemented in SmbiosItem. |
|
Implemented in SmbiosItem. |
|
Returns the bitfield denoted by bitField. Caller must be aware of the size of the bitfield. Bitfield will be returned in the lowest bits of the u32 return value.
Implemented in SmbiosItem, and SmbiosItemXml. |
|
Returns the bitfield specified by the offset into the item.
<FIELD offset="12h" name="BIOS Characteristics Extension Byte 1" length="BYTE" usage="BITFIELD"> <MAPPING> <BITS lsb="0" name="ACPI supported"/> <BITS lsb="1" name="USB Legacy is supported"/> <BITS lsb="2" name="AGP is supported"/> <BITS lsb="3" name="I20 boot is supported"/> <BITS lsb="4" name="LS-120 boot is supported"/> <BITS lsb="5" name="ATAPI ZIP Drive boot is supported"/> <BITS lsb="6" name="1394 boot is supported"/> <BITS lsb="7" name="Smart Battery is supported"/> </MAPPING> </FIELD> In this example, a call to getBitfield with an lsb of 2 and no msb would return the value of the "AGP is supported" bit as the lowest bit of the u32 return value. Implemented in SmbiosItem. |
|
Implemented in SmbiosItem. |
|
Returns the buffer size of the item.
Implemented in SmbiosItem. |
|
Returns the Handle field of the SMBIOS Item. This field is standard for all SMBIOS tables and is defined in the SMBIOS standard.
Implemented in SmbiosItem. |
|
Returns the Length field of the SMBIOS Item. This field is standard for all SMBIOS tables and is defined in the SMBIOS standard.
Implemented in SmbiosItem. |
|
XML Enhanced access to string fields. Returns the string for the field field. Field must be of length "BYTE" and of usage "STRING". Type is checked against XML file. Other than that, this method is identical to getString(unsigned int):
Implemented in SmbiosItem, and SmbiosItemXml. |
|
Returns the string at header_offset. Offset is given as the field value for that particular string. The string should almost always be retrieved with the getString(const std::string field) method instead.
Implemented in SmbiosItem. Referenced by smbios::printStructureField(). |
|
Not likely to be useful to regular client code. It is public mainly to help in writing Unit Tests. Clients should normally use getString(). Implemented in SmbiosItem. |
|
Returns the Type field of the SMBIOS Item. This field is standard for all SMBIOS tables and is defined in the SMBIOS standard.
Implemented in SmbiosItem. Referenced by SmbiosWorkaroundTable::fixupItem(), and testSmbiosXml::testItemIdentity(). |
|
Returns a byte field from the Item. This function takes a string that represents a FIELD element from the smbios XML definition. The implementation will look up the offset in XML and call getU8( int ) with the correct offset. The implementation will also validate in the XML that the FIELD is actually of length U8, and will throw an exception if the data field is the wrong length Sample XML: <STRUCTURE type="2" description="Base Board Information"> <FIELD offset="0h" name="Type" length="BYTE" usage="STRUCTURE_TYPE"/> <FIELD offset="1h" name="Length" length="BYTE" usage="SIZE"/> <FIELD offset="2h" name="Handle" length="WORD" usage="HANDLE"/> <FIELD offset="4h" name="Manufacturer" length="BYTE" usage="STRING"/> <FIELD offset="5h" name="Product" length="BYTE" usage="STRING"/> <FIELD offset="6h" name="Version" length="BYTE" usage="STRING"/> <FIELD offset="7h" name="Serial Number" length="BYTE" usage="STRING"/> </STRUCTURE>
Implemented in SmbiosItem, and SmbiosItemXml. |
|
Set of accessor functions: getU8(), getU16(), getU32(), and getU64() Returns a (byte|word|dword|qword) field from the Item. The offset specified is an int representing the a valid offset within the table. Method will return a u8/u16/u32/u64 (depending on function called). These methods all check the offset parameter for out of bounds conditions. They will throw exceptions on attempts to access data outside the length of the present item.
Implemented in SmbiosItem. Referenced by smbios::compareU16(). |
|
Returns a byte field from the Item. This function takes a string that represents a FIELD element from the smbios XML definition. The implementation will look up the offset in XML and call getU8( int ) with the correct offset. The implementation will also validate in the XML that the FIELD is actually of length U8, and will throw an exception if the data field is the wrong length Sample XML: <STRUCTURE type="2" description="Base Board Information"> <FIELD offset="0h" name="Type" length="BYTE" usage="STRUCTURE_TYPE"/> <FIELD offset="1h" name="Length" length="BYTE" usage="SIZE"/> <FIELD offset="2h" name="Handle" length="WORD" usage="HANDLE"/> <FIELD offset="4h" name="Manufacturer" length="BYTE" usage="STRING"/> <FIELD offset="5h" name="Product" length="BYTE" usage="STRING"/> <FIELD offset="6h" name="Version" length="BYTE" usage="STRING"/> <FIELD offset="7h" name="Serial Number" length="BYTE" usage="STRING"/> </STRUCTURE>
Implemented in SmbiosItem, and SmbiosItemXml. |
|
Set of accessor functions: getU8(), getU16(), getU32(), and getU64() Returns a (byte|word|dword|qword) field from the Item. The offset specified is an int representing the a valid offset within the table. Method will return a u8/u16/u32/u64 (depending on function called). These methods all check the offset parameter for out of bounds conditions. They will throw exceptions on attempts to access data outside the length of the present item.
Implemented in SmbiosItem. Referenced by smbios::compareU32(). |
|
Returns a byte field from the Item. This function takes a string that represents a FIELD element from the smbios XML definition. The implementation will look up the offset in XML and call getU8( int ) with the correct offset. The implementation will also validate in the XML that the FIELD is actually of length U8, and will throw an exception if the data field is the wrong length Sample XML: <STRUCTURE type="2" description="Base Board Information"> <FIELD offset="0h" name="Type" length="BYTE" usage="STRUCTURE_TYPE"/> <FIELD offset="1h" name="Length" length="BYTE" usage="SIZE"/> <FIELD offset="2h" name="Handle" length="WORD" usage="HANDLE"/> <FIELD offset="4h" name="Manufacturer" length="BYTE" usage="STRING"/> <FIELD offset="5h" name="Product" length="BYTE" usage="STRING"/> <FIELD offset="6h" name="Version" length="BYTE" usage="STRING"/> <FIELD offset="7h" name="Serial Number" length="BYTE" usage="STRING"/> </STRUCTURE>
Implemented in SmbiosItem, and SmbiosItemXml. |
|
Set of accessor functions: getU8(), getU16(), getU32(), and getU64() Returns a (byte|word|dword|qword) field from the Item. The offset specified is an int representing the a valid offset within the table. Method will return a u8/u16/u32/u64 (depending on function called). These methods all check the offset parameter for out of bounds conditions. They will throw exceptions on attempts to access data outside the length of the present item.
Implemented in SmbiosItem. Referenced by smbios::compareU64(). |
|
Returns a byte field from the Item. This function takes a string that represents a FIELD element from the smbios XML definition. The implementation will look up the offset in XML and call getU8( int ) with the correct offset. The implementation will also validate in the XML that the FIELD is actually of length U8, and will throw an exception if the data field is the wrong length Sample XML: <STRUCTURE type="2" description="Base Board Information"> <FIELD offset="0h" name="Type" length="BYTE" usage="STRUCTURE_TYPE"/> <FIELD offset="1h" name="Length" length="BYTE" usage="SIZE"/> <FIELD offset="2h" name="Handle" length="WORD" usage="HANDLE"/> <FIELD offset="4h" name="Manufacturer" length="BYTE" usage="STRING"/> <FIELD offset="5h" name="Product" length="BYTE" usage="STRING"/> <FIELD offset="6h" name="Version" length="BYTE" usage="STRING"/> <FIELD offset="7h" name="Serial Number" length="BYTE" usage="STRING"/> </STRUCTURE>
Implemented in SmbiosItem, and SmbiosItemXml. |
|
Set of accessor functions: getU8(), getU16(), getU32(), and getU64() Returns a (byte|word|dword|qword) field from the Item. The offset specified is an int representing the a valid offset within the table. Method will return a u8/u16/u32/u64 (depending on function called). These methods all check the offset parameter for out of bounds conditions. They will throw exceptions on attempts to access data outside the length of the present item.
Implemented in SmbiosItem. Referenced by smbios::compareU8(), smbios::getData(), rbu::getSupportedPacketType(), smbios::isBitSet(), and smbios::printStructureField(). |
|
Used by 'stdostream &smbios::operator <<( std::ostream &, ISmbiosItem&)' to print out the item info. Not particularly useful for clients. Use operator<< instead. Implemented in SmbiosItem, and SmbiosItemXml. Referenced by smbios::operator<<(). |