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