20 #define LIBSMBIOS_SOURCE
32 using namespace smbiosLowlevel;
35 #if defined(DEBUG_SMBIOS_STRATEGY)
36 # define DCOUT(line) do { cout << line; } while(0)
37 # define DCERR(line) do { cerr << line; } while(0)
39 # define DCOUT(line) do {} while(0)
40 # define DCERR(line) do {} while(0)
50 ParseExceptionImpl &parseException
60 const u8 *ptr =
reinterpret_cast<const u8*
>(tempTEP);
63 for(
unsigned int i = 0; i <
sizeof(*tempTEP); ++i )
66 checksum = (checksum + ptr[i]) & 0xFF;
71 DCERR(
"_DMI_ anchor: " << tempTEP->anchor[0] << tempTEP->anchor[1] << tempTEP->anchor[2] << tempTEP->anchor[3] << tempTEP->anchor[4] << tempTEP->anchor[5] << endl);
72 if(memcmp(tempTEP->anchor,
"_DMI_",5)!=0)
74 oss <<
_(
"Intermediate anchor string does not match. anchor string: %(dmi_anchor)s") << endl;
78 DCERR(
"_DMI_ checksum: " << (
int)checksum << endl);
81 oss <<
_(
"Checksum check for table entry point should be zero. checksum: %(dmi_checksum)i ") << endl;
85 parseException.setParameter(
"dmi_anchor", reinterpret_cast<const char *>(tempTEP->anchor));
86 parseException.setParameter(
"dmi_checksum", static_cast<int>(checksum));
98 ParseExceptionImpl &parseException
124 const u8 *ptr =
reinterpret_cast<const u8*
>(tempTEP);
127 for(
unsigned int i = 0; (i < static_cast<unsigned int>(tempTEP->
eps_length)) && (i <
sizeof(*tempTEP)); ++i )
130 checksum = (checksum + ptr[i]) & 0xFF;
134 oss <<
_(
"validation of table entry point failed") << endl;
138 DCERR(
"strict table checking: " << strict << endl);
141 DCERR(
"_SM_ checksum: " << (
int)checksum << endl);
145 oss <<
_(
"Checksum check for table entry point should be zero. checksum: %(checksum)i ") << endl;
152 oss <<
_(
"Major version of table entry point should be 2: %(major_version)i") << endl;
160 oss <<
_(
"Entry Point Length field is at least 0x1f : %(eps_length)i") << endl;
164 parseException.setParameter(
"checksum", static_cast<int>(checksum));
165 parseException.setParameter(
"major_version", static_cast<int>(tempTEP->
major_ver));
166 parseException.setParameter(
"eps_length", static_cast<int>(tempTEP->
eps_length));
167 parseException.setMessageString(oss.str());
182 DCERR(
"trying SmbiosMemoryStrategy" << endl);
183 getSmbiosTableHeader(table_header, strict);
186 getSmbiosTableBuf(smbiosBuffer, *table_header);
190 catch(
const exception &e)
193 DCERR(
"got Exception: " << e.what() << endl);
196 DCERR(
" ret for SmbiosMemoryStrategy is: " << ret << endl);
211 if( 0 != *smbiosBuffer )
213 memset (const_cast<u8 *>(*smbiosBuffer), 0,
sizeof (**smbiosBuffer));
214 delete []
const_cast<u8 *
>(*smbiosBuffer);
220 delete [] newSmbiosBuffer;
225 *smbiosBuffer =
reinterpret_cast<const u8 *
>(newSmbiosBuffer);
234 unsigned long fp = E_BLOCK_START;
238 ParseExceptionImpl parseException;
241 DCERR(
"SmbiosMemoryStrategy::getSmbiosTableHeader() using hardcoded offset: " << hex << offset << endl);
242 parseException.setMessageString(
_(
"SMBIOS Header not found at offset: %(offsetValue)i"));
243 parseException.setParameter(
"offsetValue",offset);
247 DCERR(
"SmbiosMemoryStrategy::getSmbiosTableHeader() Memory scan for smbios table." << endl);
248 parseException.setMessageString(
_(
"SMBIOS Header not found in search."));
259 memset(&tempTEP, 0,
sizeof(tempTEP));
260 while ( (fp +
sizeof(tempTEP)) < F_BLOCK_END)
263 reinterpret_cast<u8 *>(&tempTEP),
270 if (memcmp (&tempTEP,
"_DMI_", 5) == 0)
272 DCERR(
"Found _DMI_ anchor. Trying to parse legacy DMI structure." << endl);
280 DCERR(
"Found valid _DMI_ entry point at offset: " << fp << endl);
287 if (offset || (memcmp (&tempTEP,
"_SM_", 4) == 0))
292 DCERR(
"Found _SM_ anchor or using hardcoded offset. Trying to parse Smbios Entry Point." << endl);
295 DCERR(
"Found valid _SM_ entry point at offset: " << fp << endl);
308 throw parseException;
318 if ((fp +
sizeof(tempTEP)) >= F_BLOCK_END)
319 throw parseException;
323 memcpy( const_cast<smbios_table_entry_point *>(table_header), &tempTEP,
sizeof(*table_header) );