20 #define LIBSMBIOS_SOURCE
33 #if defined(DEBUG_SMI)
34 # define DCOUT(line) do { cout << line; } while(0)
35 # define DCERR(line) do { cerr << line; } while(0)
37 # define DCOUT(line) do {} while(0)
38 # define DCERR(line) do {} while(0)
42 #define SIZEOF_KERNELBUF (sizeof(kernel_buf) - sizeof(kernel_buf.command_buffer_start))
51 IDellCallingInterfaceSmi::IDellCallingInterfaceSmi()
54 IDellCallingInterfaceSmi::~IDellCallingInterfaceSmi()
57 DellCallingInterfaceSmiImpl::DellCallingInterfaceSmiImpl(
SmiStrategy *initStrategy,
u16 address,
u8 code )
58 : buffer(0), bufferSize(0), smiStrategy(initStrategy)
99 memset(
buffer, 0, newSize);
108 throw SmiExceptionImpl(
"Output buffer not large enough.");
118 size_t baseAddr =
smiStrategy->getPhysicalBufferBaseAddress();
119 for(
int i=0; i<4; i++)
138 throw SmiExceptionImpl(
"Output buffer not large enough.");
141 throw SmiExceptionImpl(
"Output buffer format error.");
144 throw UnhandledSmiImpl(
"Unhandled SMI call.");
147 throw UnsupportedSmiImpl(
"Unsupported SMI call.");
150 throw SmiExecutedWithErrorImpl(
"BIOS returned error for SMI call.");
156 throw ParameterErrorImpl(
"Internal programming error. Argument must be in range 0..3");
176 throw ParameterErrorImpl(
"Internal programming error. Argument must be in range 0..3");
184 throw ParameterErrorImpl(
"Internal programming error. Result request must be in range 0..3");
201 smi->setClass( smiClass );
202 smi->setSelect( select );
203 smi->setArg(0, args[0]);
204 smi->setArg(1, args[1]);
205 smi->setArg(2, args[2]);
206 smi->setArg(3, args[3]);
214 std::auto_ptr<smi::IDellCallingInterfaceSmi> smi(
219 res[0] = smi->getRes(0);
220 res[1] = smi->getRes(1);
221 res[2] = smi->getRes(2);
222 res[3] = smi->getRes(3);
239 if( which != 9 && which != 10 )
240 throw ParameterErrorImpl(
"Internal programming error. Argument must be either 9 or 10.");
244 u32 args[4] = {0,}, res[4] = {0,};
252 if ( (res[1] & 0xFF)==2 || (res[1] & 0xFF)==3 )
255 DCERR(
"getPasswordPropertiesII()" << hex << endl );
256 DCERR(
"res[0]: " << res[0] << endl);
257 DCERR(
"res[1]: " << res[1] << endl);
258 DCERR(
"res[2]: " << res[2] << endl);
259 DCERR(
"res[3]: " << res[3] << endl);
262 maxLen =
static_cast<u8>((res[1] & 0x0000FF00) >> 8);
263 minLen =
static_cast<u8>((res[1] & 0x00FF0000) >> 16);
264 props =
static_cast<u8>((res[1] & 0xFF000000) >> 24);
272 if( which != 9 && which != 10 )
273 throw ParameterErrorImpl(
"Internal programming error. Argument must be either 9 or 10.");
276 u32 args[4] = {0,}, res[4] = {0,};
279 if( (res[0] & 0xFF) == 1 || ( res[0] & 0xFF ) == 3)
283 catch(
const exception &)
295 DCERR(
"getAuthenticationKeyII()" << endl );
298 DCERR(
" trying auth keys" << endl);
301 for(
int i=0; i<2; i++ )
303 DCERR(
" trying class code: " << toCheck[i] << endl);
305 u8 maxLen=0, minLen=0, props=0;
312 catch(
const exception & )
320 DCERR(
"has a password." << hex << endl);
321 DCERR(
" max len: " << (
int)maxLen << endl);
322 DCERR(
" min len: " << (
int)minLen << endl);
323 DCERR(
" props : " << hex << props << endl);
328 smi->setBufferContents(reinterpret_cast<const u8*>(password.c_str()), strnlen(password.c_str(), maxLen));
329 smi->setArgAsPhysicalAddress( 0, 0 );
332 DCERR(
"after verify:"<< endl);
333 DCERR(
"res[0]: " << smi->getRes(0) << endl; );
334 DCERR(
"res[1]: " << smi->getRes(1) << endl; );
335 DCERR(
"res[2]: " << smi->getRes(2) << endl; );
336 DCERR(
"res[3]: " << smi->getRes(3) << endl; );
339 authKey = smi->getRes(1);
341 throw PasswordVerificationFailedImpl(
"BIOS setup password enabled, but given password does not match.");
355 DCERR(
"getAuthenticationKey(" << password <<
")" << endl);
359 DCERR(
" trying auth keys" << endl);
361 for(
int i=0; i<2; i++ )
363 DCERR(
" trying class code: " << toCheck[i] << endl);
366 u32 args[4] = {0,}, res[4] = {0,};
373 catch(
const SmiException &)
385 DCERR(
" password installed" << endl);
387 u32 args[4] = {0}, res[4] = {0,};
388 strncpy(reinterpret_cast<char *>(args), password.c_str(), 2 *
sizeof(
u32));
390 DCERR(
" args are : 0x" << args[0] <<
" 0x" << args[1] <<
" 0x" << args[2] <<
" 0x" << args[3] << endl);
395 DCERR(
" res was : 0x" << res[0] <<
" 0x" << res[1] <<
" 0x" << res[2] <<
" 0x" << res[3] << endl);
399 throw PasswordVerificationFailedImpl(
"BIOS setup password enabled, but given password does not match.");
419 u32 args[4] = {0,}, res[4] = {0,};
424 catch(
const exception &)
429 u32 args[4] = {0,}, res[4] = {0,};
434 catch(
const exception &)
439 u8 maxLen=0, minLen=0, props=0;
446 catch(
const exception &)
451 u8 maxLen=0, minLen=0, props=0;
458 catch(
const exception &)
467 u32 args[4] = {location, 0,}, res[4] = {0,};
478 return readSetting(0, location, minValue, maxValue);
483 return readSetting(1, location, minValue, maxValue);
488 return readSetting(2, location, minValue, maxValue);
502 u32 args[4] = {location, newValue,}, res[4] = {0,};
505 for(
int i=0; i<2; i++)
510 DCERR(
"Try #" << i <<
" for writeSetting()" << endl);
511 DCERR(
" args are : 0x" << args[0] <<
" 0x" << args[1] <<
" 0x" << args[2] <<
" 0x" << args[3] << endl);
513 DCERR(
" res was : 0x" << res[0] <<
" 0x" << res[1] <<
" 0x" << res[2] <<
" 0x" << res[3] << endl);
516 catch(
const SmiExecutedWithError &)
522 DCERR(
"Executed with error, try password..." << endl);
536 return writeSetting(password, 0, location, value, minValue, maxValue);
541 return writeSetting(password, 1, location, value, minValue, maxValue);
546 return writeSetting(password, 2, location, value, minValue, maxValue);
551 u32 args[4] = {0,}, res[4] = {0,};
554 type = (res[1] & 0x00FF);
555 resolution = (res[1] & 0xFF00) >> 8;
556 memSizeX256kb = res[2];
561 u32 args[4] = {0,}, res[4] = {0,};
564 horiz = (res[1] & 0x0000FFFF);
565 vert = (res[1] & 0xFFFF0000) >> 16;
570 u32 args[4] = {0,}, res[4] = {0,};
578 u32 args[4] = {bits, 0,}, res[4] = {0,};
587 smi->setBufferSize(80);
588 smi->setArgAsPhysicalAddress( 0, 0 );
590 strncpy( tagBuf, reinterpret_cast<const char*>(smi->getBufferPtr()), size < 80? size:80);
591 tagBuf[size-1] =
'\0';
598 for(
int i=0; i<2; i++)
604 smi->setBufferSize(120);
605 smi->setBufferContents(reinterpret_cast<const u8*>(newTag), strnlen(newTag, 80));
606 smi->setArgAsPhysicalAddress( 0, 0 );
610 catch(
const SmiExecutedWithError &)
675 throw ConfigErrorImpl(
"boot time config disabled, runtime setting has no effect.");
677 u32 disable = enable ? 0:1;
678 u32 args[4] = {(1 | (
static_cast<u32>(
radioNum)<<8) | ((disable)<<16)), 0, 0, 0};
689 smi->setSelect( 11 );
718 if (whichConfig == 1)
720 else if (whichConfig == 2)
721 oldConfig = ((oldConfig>>8) & 0xFF);
723 u32 newConfig = (oldConfig & ~whichSwitch) | ((enable?1:0) * whichSwitch);
724 smi->setArg(
smi::cbARG1, (0x2 | (whichConfig << 8) | (newConfig << 16)));
728 void wirelessSwitchControl(
bool enable,
bool boot,
bool runtime,
int enable_token,
int disable_token,
int switchNum, std::string password)
730 int intSwitchConfig = 0, intSwitchNum = 0;
750 throw ParameterErrorImpl(
"Invalid switch number passed to wirelessSwitchControl()");
768 u32 args[4] = {0,}, res[4] ={0,};
774 int supported_bit=0, installed_bit=0, disabled_bit=0;
798 cout <<
"Radio Status for " << name <<
":" << endl;
801 cout <<
"\t" << name <<
" supported" << endl;
802 cout <<
"\t" << name <<
" " << ((res[
smi::cbRES2] & (1 << installed_bit)) ?
"installed":
"not installed") << endl;
803 cout <<
"\t" << name <<
" " << ((res[
smi::cbRES2] & (1 << disabled_bit)) ?
"disabled" :
"enabled") << endl;
808 else if (!(res[
smi::cbRES2] & (1 << disabled_bit)))
811 cout <<
"\t" << name <<
" not supported" << endl;
814 cout <<
"\tStatus Code: " << ret << endl;
815 }
catch (smi::UnsupportedSmi &) {