00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #define LIBSMBIOS_SOURCE
00020 #include "smbios/ISmbios.h"
00021 #include "smbios/IToken.h"
00022
00023 #include "smbios/SystemInfo.h"
00024 #include "smbios/IMemory.h"
00025 #include "smbios/SmbiosDefs.h"
00026 #include "ExceptionImpl.h"
00027
00028 #include "SystemDetect.h"
00029
00030
00031 #include "DellMagic.h"
00032
00033
00034 #include "smbios/message.h"
00035
00036 using namespace smbios;
00037 using namespace cmos;
00038 using namespace std;
00039
00040
00041 extern smbios::Exception<smbios::IException> SysInfoException;
00042
00043
00044
00045
00046
00047
00048
00049 bool couldBeDiamond ()
00050 {
00051 bool couldBeDiamond = false;
00052
00053 if(SMBIOSGetDellSystemId() == SYSTEM_ID_DIAMOND )
00054 couldBeDiamond=true;
00055
00056 return couldBeDiamond;
00057 }
00058
00059
00060 bool couldBeBayonet ()
00061 {
00062
00063 bool couldBeBayonet = false;
00064
00065 smbios::ISmbiosTable *table =
00066 smbios::SmbiosFactory::getFactory()->getSingleton();
00067
00068
00069 smbios::ISmbiosTable::iterator item ;
00070
00071 if (0 == table)
00072 throw InternalErrorImpl();
00073
00074
00075 for( item = (*table)[OEM_Strings] ; item != table->end(); ++item)
00076 {
00077 const char *str = item->getStringByStringNumber (OEM_String_Field_Number);
00078 if ((0 != str) && (0 == strncmp (str, Bayonet_Detect_String, strlen(Bayonet_Detect_String))))
00079 couldBeBayonet = true;
00080 }
00081
00082
00083
00084 return couldBeBayonet;
00085 }
00086
00087 static bool isStdDellBiosSystem ()
00088 {
00089
00090 bool dellSystem = false;
00091
00092 char OEMString[5] = { 0, };
00093
00094 memory::IMemory *mem =
00095 memory::MemoryFactory::getFactory()->getSingleton();
00096
00097 mem->fillBuffer( reinterpret_cast<u8 *>(OEMString), OEM_String_Location, 4 );
00098
00099 if (0 == strncmp (OEMString, OEM_Dell_String, 5))
00100 dellSystem = true;
00101
00102
00103 return dellSystem;
00104 }
00105
00106
00107
00108
00109
00110
00111
00112 struct SystemDetectionFunction
00113 {
00114 bool (*f_ptr)();
00115 }
00116 DellDetectionFunctions[] = {
00117 {&isStdDellBiosSystem,},
00118 {&couldBeBayonet,},
00119 {&couldBeDiamond,},
00120 };
00121
00122
00123
00124
00125
00126
00127 int SMBIOSIsDellSystem ()
00128 {
00129 bool isDell = false;
00130 int retval = 0;
00131
00132
00133
00134
00135
00136
00137
00138
00139 int numEntries =
00140 sizeof (DellDetectionFunctions) /
00141 sizeof (DellDetectionFunctions[0]);
00142
00143 for (int i = 0; i < numEntries; ++i)
00144 {
00145 try
00146 {
00147 isDell = DellDetectionFunctions[i].f_ptr ();
00148 }
00149 catch(const smbios::IException &e)
00150 {
00151 SysInfoException.setMessageString(e.what());
00152 }
00153 catch(...)
00154 {
00155 SysInfoException.setMessageString( _("Unknown internal error occurred") );
00156 }
00157
00158 if (isDell)
00159 break;
00160 }
00161
00162
00163 if(isDell)
00164 {
00165 retval = 1;
00166 }
00167 else
00168 {
00169 retval = 0;
00170 }
00171
00172 return retval;
00173 }
00174
00175