smbios on 9G

Michael_E_Brown@Dell.com Michael_E_Brown at Dell.com
Tue Jul 12 07:57:22 CDT 2005


There are two modes of access to the smbios tables. One looks like this:
	smbios::ISmbiosTable::iterator item = (*table)[0x00]; // example
item lookup
	item->getU8(0x08); // example pulling BYTE at offset 0x08

The other looks like this:
	smbios::ISmbiosTable::iterator item = (*table)["BIOS Information
Structure"]
	item->getU8("BIOS Major Version"); // example looking up offset
in XML and returning it

The first (numerical) requires only libsmbios.so. The second requires
libsmbiosxml.so. The second will take the strings you give it and look
them up in XML to find the appropriate offsets and table types. 

On Windows, I have not yet at this time exported the classes for use
from a DLL, so smbios.lib must be statically linked with your app. If
there is demand (and patches... ;-) for it, I will export the class
based C++ interface for use from the DLL. At the moment, only the C
interface is exported for use from the DLL. Linux does not have the
access restrictions of Windows, so the C++ API is usable on Linux
without statically linking.

Please look at the two webpage references below because they go through
a bit of this.
--
Michael


> -----Original Message-----
> From: libsmbios-devel-bounces at lists.us.dell.com 
> [mailto:libsmbios-devel-bounces at lists.us.dell.com] On Behalf 
> Of Srikrishna_S at dell.com
> Sent: Tuesday, July 12, 2005 7:47 AM
> To: Brown, Michael E
> Cc: libsmbios-devel at lists.us.dell.com
> Subject: RE: smbios on 9G
> 
> 
> Thanx Mike...I did go through the SmbiosTable today...will 
> let you know how it goes and yes, I'll document the 
> procedure/code samples I used and pass it onto you..
> 
> One more question, I will be able to read tables using just 
> libsmbios.so/dll (got from "make minimal") right, or will I 
> need the xml components too? I have some size restrictions 
> for OL-DLite which I'll have to stick to...
> 
> Regards 
> 
> Srikrishna S 
> DELL Product Group-Enterprise. 
> Direct : 91-80-51177193 
> 
> 
> 
> >  -----Original Message-----
> > From: 	Brown, Michael E  
> > Sent:	Tuesday, July 12, 2005 6:10 PM
> > To:	S, Srikrishna
> > Cc:	libsmbios-devel at lists.us.dell.com
> > Subject:	RE: smbios on 9G
> > 
> > The second code example shows how to get specific structures and 
> > entries in the structure. The API for arbitrarily parsing specific 
> > smbios items and getting data out of them is C++.
> > 
> > Start at the following pages in the doxygen docs: 
> > 
> <http://linux.dell.com/libsmbios/main/classsmbios_1_1ISmbiosTable.html
> > >
> > 
> <http://linux.dell.com/libsmbios/main/classsmbios_1_1ISmbiosItem.html>
> > 
> > Annoted code example:
> > 
> > 		// The following two lines get access to the 
> SmbiosTable object. 
> > Gets a reference
> > 		// to an already intialized object, or 
> initializes a new one if none 
> > exist.
> > 		// table == 0 on error.
> > 		    smbios::ISmbiosTable *table = 0;
> > 		    table = 
> smbios::SmbiosFactory::getFactory()->getSingleton();
> > 
> > 		// The following lines will iterate over each smbios
> > table item matching the given type.
> > 		    smbios::ISmbiosTable::iterator item;
> > 		    for(item = (*table)[0x00] ; item != table->end();
> > ++item) // 0x00 == BIOS structure
> > 						// substitute the
> > numeric type to access any other structure
> > 		    {
> > 		        const char *str = item->getString(0x08);  //
> > gets a string that is pointed to by hex offset 0x08 
> > 		        u8 byte         = item->getU8(0x09);      //
> > gets a byte value at offset 0x09
> > 		        u16 word        = item->getU16(0x0A);     //
> > gets a word value at offset 0x10
> > 				// ... Same thing works for U32 and U64
> > 		    }
> > 
> > There is quite a lot of code you can use as an example 
> already in the
> > tree:
> > 	test harness code under cppunit/interface/testSmbiosXml.cpp
> > 	sample binaries under bins/*.cpp
> > 
> > 	If you want to write up a short tutorial, I would be 
> happy to add it 
> > to the documentation website.
> > --
> > Michael
> > 
> > 	 -----Original Message-----
> > 	From: 	S, Srikrishna  
> > 	Sent:	Monday, July 11, 2005 11:43 PM
> > 	To:	Brown, Michael E
> > 	Cc:	libsmbios-devel at lists.us.dell.com
> > 	Subject:	RE: smbios on 9G
> > 
> > 
> > 	Thanx Mike...I agree that we should be using libsmbios for this.
> > 
> > 	We are using libsmbios in OL-D already but not in all 
> modules, I'm 
> > planning to make this change of using libsmbios in all modules for 
> > Endeavor...
> > 
> > 	I'm interested in getting information about CMOS, serial 
> > port,parallel port,memory dimms and other devices from 
> various table 
> > entries in smbios....
> > 
> > 	I'm currently investigating on how to read table entries using 
> > libsmbios, any pointers to this will be appreciated...thanx!
> > 
> > 
> > 
> > 	Regards
> > 
> > 	Srikrishna S 
> > 	DELL Product Group-Enterprise. 
> > 	Direct : 91-80-51177193
> > 
> > 
> > 
> > 		 -----Original Message-----
> > 		From: 	Brown, Michael E  
> > 		Sent:	Monday, July 11, 2005 8:37 PM
> > 		To:	S, Srikrishna
> > 		Cc:	'libsmbios-devel at lists.us.dell.com'
> > 		Subject:	RE: smbios on 9G
> > 
> > 		Srikrishna,
> > 			The code that you sent to me uses
> > fseek()/fgetc() on a file handle opened to /dev/mem. This will not 
> > work if you are trying to read /dev/mem > 1MB on RHEL3 or higher. I 
> > would strongly suggest that you subscribe to the mailing list here: 
> > 
> <<http://lists.us.dell.com/mailman/listinfo/libsmbios-devel>> and use 
> > libsmbios in your project instead of open coding this. I 
> have cc'd the 
> > mailing list on this email because I think the code 
> examples below may 
> > be useful to other people.
> > 
> > 			The reason that libsmbios was created was to
> > subsume all instances where some internal Dell group had hand-coded 
> > blocks of code to pull information from the smbios tables. 
> That way, 
> > all the bugfixes and maintenance could happen in one spot. 
> Libsmbios 
> > works on 9G on RHEL4. It appears to me that the only thing that the 
> > attached code is doing is getting the BIOS version and 
> release date, 
> > is that correct? If so, you can trivially re-write this using 
> > libsmbios, or use the already existing getSystemId 
> executable, which 
> > provides this info.
> > 
> > 		First, this is the existing getSystemId executable:
> > 
> > 		[root at argon libsmbios]# ./bins/output/getSystemId
> > 		Libsmbios:    0.7.0_beta4
> > 		System ID:    0x0121
> > 		Service Tag:  1LWBP21
> > 		Product Name: PowerEdge 2650
> > 		BIOS Version:  A10
> > 		Vendor:       Dell Computer Corporation
> > 		Is Dell:      1
> > 		[root at argon libsmbios]#
> > 
> > 		If you do not want to use the precooked 
> executable, the following is 
> > C code using libsmbios to get the BIOS version:
> > 
> > 			    #include "smbios/SystemInfo.h"
> > 			      // ...
> > 			    const char *biosVer   = 0;
> > 			    biosVer   = SMBIOSGetBiosVersion();
> > 			    if(biosVer == 0)
> > 			    {
> > 			        printf("Error getting the bios version,
> > error: %s\n", SMBIOSGetSysInfoErrorString());
> > 			    }
> > 			    else
> > 			    {
> > 			        printf("BIOS Version:  %s\n", biosVer);
> > 			    }
> > 			    SMBIOSFreeMemory(biosVer);
> > 			       // ...
> > 
> > 		I see that the attached code also gets the date string.
> > The following is C++ code that will get this information using 
> > libsmbios (as there is no pre-cooked function for this):
> > 
> > 			#include "smbios/ISmbios.h"
> > 
> > 			// allocates a string on behalf of caller.
> > 			// caller must free string with delete()
> > 			char *getBiosDate()
> > 			{
> > 			    smbios::ISmbiosTable *table = 0;
> > 			    table = 
> smbios::SmbiosFactory::getFactory()->getSingleton();
> > 
> > 			    if (0 == table)
> > 			    {
> > 			        throw InternalErrorImpl();
> > 			    }
> > 
> > 			    const char *tempval = 0;
> > 			    smbios::ISmbiosTable::iterator item;
> > 			    for(item = (*table)[0x00] ; item !=
> > table->end(); ++item) // 0x00 == BIOS structure
> > 			    {
> > 			        tempval = item->getString(0x08);  //
> > offset 0x08 is release date pointer
> > 			    }
> > 
> > 			    if(!tempval)
> > 			    {
> > 			        throw exception();
> > 			    }
> > 
> > 			    // copy return value into a dynamically
> > allocated string.
> > 			    int slen = strlen(tempval);
> > 			    char *retval = new char[slen + 1];
> > 			    strncpy(retval,tempval,slen);
> > 			    retval[slen] = '\0';
> > 
> > 			    return retval;
> > 			}
> > 			
> > 			As I hope is obvious looking at the sample code
> > above, using the libsmbios API is much easier than open-coding your 
> > own block to get this info.
> > 		--
> > 		Michael
> > 
> > 			 -----Original Message-----
> > 			From: 	S, Srikrishna  
> > 			Sent:	Monday, July 11, 2005 6:37 AM
> > 			To:	Brown, Michael E
> > 			Subject:	smbios on 9G
> > 
> > 
> > 			Hi Mike,
> > 
> > 			 I'm using a small test program to get some
> > smbios table information from a Montreol - 9G- machine 
> running RHEL 4.
> > 			The search for "_SM_" pattern is failing and is
> > crossing the search boundary, since there are no proper checks for 
> > this overflow the rest of the conditions (of tables ending 
> etc.) are 
> > never met and hence the program gets into an infinite loop.
> > 
> > 			I can see from the libsmbios code that a similar
> > search is being done in SmbiosTable.cpp, I wanted to know if you or 
> > anybody else using libsmbios have come across an issue like this on 
> > any 9G systems? I'm using the latest bios version available on 
> > Montreol.
> > 
> > 			Any help/pointers in this regard is greatly
> > appreciated..
> > 
> > 			I'm attaching the test program for your
> > reference.
> > 
> > 			 << File: new.c >>
> > 
> > 			Regards
> > 
> > 			Srikrishna S 
> > 			DELL Product Group-Enterprise. 
> > 			Direct : 91-80-51177193
> > 
> > 
> > 
> 
> _______________________________________________
> libsmbios-devel mailing list
> libsmbios-devel at lists.us.dell.com 
> http://lists.us.dell.com/mailman/listinfo/libsmbios-devel
> 



More information about the libsmbios-devel mailing list