00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #define LIBSMBIOS_SOURCE
00020 #include "SmiImpl.h"
00021 #include "FactoryImpl2.h"
00022 #include "TokenImpl.h"
00023
00024
00025 #include "smbios/message.h"
00026
00027 using namespace std;
00028
00029 namespace smi
00030 {
00031 class SmiFactoryImpl : public factory::TFactory<SmiFactory>
00032 {
00033 public:
00034 SmiFactoryImpl() { setParameter("smiFile", ""); };
00035 virtual ~SmiFactoryImpl() throw() {};
00036 virtual std::auto_ptr<IDellCallingInterfaceSmi> makeNew(u8 type);
00037 };
00038
00039
00040 SmiFactory::~SmiFactory() throw()
00041 {}
00042 SmiFactory::SmiFactory()
00043 {}
00044
00045 SmiFactory *SmiFactory::getFactory()
00046 {
00047
00048
00049
00050 return SmiFactoryImpl::getFactory(reinterpret_cast<SmiFactoryImpl *>(0));
00051 }
00052
00053 std::auto_ptr<IDellCallingInterfaceSmi> SmiFactoryImpl::makeNew( u8 type )
00054 {
00055 IDellCallingInterfaceSmi *ret = 0;
00056 SmiStrategy *strategyPtr = 0;
00057
00058 if (mode == AutoDetectMode )
00059 strategyPtr = new SmiArchStrategy();
00060
00061 else if (mode == UnitTestMode)
00062 strategyPtr = new SmiMockStrategy(getParameterString("smiFile"));
00063
00064
00065
00066 u16 cmdIOAddress = 0;
00067 u8 cmdIOCode = 0;
00068 const smbios::ISmbiosTable *table = 0;
00069
00070 switch( type )
00071 {
00072 case DELL_CALLING_INTERFACE_SMI_RAW:
00073 ret = new DellCallingInterfaceSmiImpl(strategyPtr, 0, 0);
00074 break;
00075
00076 case DELL_CALLING_INTERFACE_SMI:
00077
00078 try {
00079 table = smbios::SmbiosFactory::getFactory()->getSingleton();
00080 smbios::ISmbiosTable::const_iterator item = (*table)[0xDA];
00081 cmdIOAddress = getU16_FromItem(*item, 4);
00082 cmdIOCode = getU8_FromItem(*item, 6);
00083 ret = new DellCallingInterfaceSmiImpl(strategyPtr, cmdIOAddress, cmdIOCode);
00084 } catch(...) {
00085 throw SmiExceptionImpl(_("Could not automatically setup up magic io"));
00086 }
00087
00088 break;
00089 default:
00090 throw InvalidSmiModeImpl(_("Unknown smi factory mode requested"));
00091 break;
00092 }
00093
00094 if( ! ret )
00095 throw InvalidSmiModeImpl(_("Could not allocate SMI object"));
00096
00097 std::auto_ptr<IDellCallingInterfaceSmi> foo(ret);
00098 return foo;
00099 }
00100
00101 }