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