00001 // vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c: 00002 /* 00003 * Copyright (C) 2005 Dell Inc. 00004 * by Michael Brown <Michael_E_Brown@dell.com> 00005 * Licensed under the Open Software License version 2.1 00006 * 00007 * Alternatively, you can redistribute it and/or modify 00008 * it under the terms of the GNU General Public License as published 00009 * by the Free Software Foundation; either version 2 of the License, 00010 * or (at your option) any later version. 00011 00012 * This program is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00015 * See the GNU General Public License for more details. 00016 */ 00017 00018 // 00019 #ifndef ISMBIOSWORKAROUND_H_ 00020 #define ISMBIOSWORKAROUND_H_ 00021 00022 // types.h should be first user-defined header. 00023 #include "smbios/types.h" 00024 #include "smbios/ISmbios.h" 00025 #include "FactoryImpl2.h" 00026 00027 namespace smbios 00028 { 00029 00030 // forward decls 00031 class SmbiosWorkaroundTable; 00032 struct Workaround; 00033 00052 class SmbiosWorkaroundFactory : public factory::TFactory<factory::IFactory> 00053 { 00054 public: 00056 SmbiosWorkaroundFactory() {}; 00057 00059 00065 static factory::TFactory<smbios::SmbiosWorkaroundFactory> *getFactory(); 00066 virtual ~SmbiosWorkaroundFactory() throw(); 00067 00069 00076 virtual SmbiosWorkaroundTable *makeNew( const ISmbiosTable *table ); 00077 00078 protected: 00079 static SmbiosWorkaroundTable *_tableInstance; 00080 }; 00081 00082 class SmbiosWorkaroundTable 00083 { 00084 public: 00085 SmbiosWorkaroundTable( const ISmbiosTable * table, const Workaround **initWorkarounds); 00086 virtual ~SmbiosWorkaroundTable(); 00087 void fixupItem( const ISmbiosItem *item, u8 *buffer, size_t bufsize ) const; 00088 00089 private: 00090 SmbiosWorkaroundTable(); //< not implmented (or legal) 00091 void operator =( const SmbiosWorkaroundTable & ); //< not implmented (or legal) 00092 00093 int systemId; 00094 std::string biosVersion; 00095 const Workaround **workaroundsForThisSystem; 00096 }; 00097 00098 enum { TYPE_U8=1, TYPE_U16=2, TYPE_U32=4, TYPE_U64=8 } ; 00099 00100 struct SystemAffected 00101 { 00102 int systemId; 00103 const char * biosMinVersion; 00104 const char * biosMaxVersion; 00105 }; 00106 00107 // give data[8] at the beginning to provide the most flexibility for 00108 // people trying to initialize static members. 00109 union datatron 00110 { 00111 u8 data[8]; // can only initialize the first member of a union (ansi) 00112 u64 dataU64; 00113 u32 dataU32; 00114 u16 dataU16; 00115 u8 dataU8; 00116 }; 00117 00118 struct WorkaroundSmbiosItem 00119 { 00120 int type; 00121 unsigned int fieldOffset; 00122 int fieldDataType; 00123 datatron data; 00124 }; 00125 00126 struct Workaround 00127 { 00128 const char *name; 00129 const WorkaroundSmbiosItem *symptoms; 00130 const WorkaroundSmbiosItem *fixups; 00131 }; 00132 00133 struct SystemWorkaround 00134 { 00135 const SystemAffected *system; 00136 const Workaround **workarounds; 00137 }; 00138 00139 } 00140 00141 #endif /* ISMBIOSWORKAROUND_H_ */