libsmbios_c library
|
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 RBU_H 00020 #define RBU_H 00021 00022 // compat header should always be first header, if system headers included 00023 #include "smbios/compat.h" 00024 00025 #include <string> 00026 00027 // types.h should be first user-defined header. 00028 #include "smbios/types.h" 00029 #include "smbios/IFactory.h" 00030 #include "smbios/IException.h" 00031 00032 // abi_prefix should be last header included before declarations 00033 #include "smbios/config/abi_prefix.hpp" 00034 00035 00036 namespace rbu 00037 { 00038 DECLARE_EXCEPTION( RbuException ); 00039 DECLARE_EXCEPTION_EX( RbuNotSupported, rbu, RbuException ); 00040 DECLARE_EXCEPTION_EX( InvalidHdrFile, rbu, RbuException ); 00041 DECLARE_EXCEPTION_EX( UnsupportedSystemForHdrFile, rbu, RbuException ); 00042 DECLARE_EXCEPTION_EX( HdrFileIOError, rbu, RbuException ); 00043 DECLARE_EXCEPTION_EX( RbuDriverIOError, rbu, RbuException ); 00044 00045 typedef enum { pt_any, pt_mono, pt_packet, pt_init } packet_type; 00046 // rbu_linux_v0: Linux 2.4 00047 // rbu_linux_v1: 2.6 dkms 00048 // rbu_linux_v2: 2.6.14+ 00049 typedef enum { rbu_unsupported, rbu_linux_v0, rbu_linux_v1, rbu_linux_v2 } driver_type; 00050 00051 const int SYSID_OVERRIDE = 1; 00052 const int BIOSVER_OVERRIDE = 2; 00053 00054 // forward decls 00055 class IRbuHdr; 00056 00058 00072 class RbuFactory : public virtual factory::IFactory 00073 { 00074 public: 00076 00086 static RbuFactory *getFactory(); 00087 virtual ~RbuFactory() throw(); 00088 00090 00099 virtual IRbuHdr *makeNew(std::string filename) = 0; 00100 protected: 00102 RbuFactory(); 00103 }; 00104 00105 00107 class IRbuHdr 00108 { 00109 public: 00110 // CONSTRUCTORS, DESTRUCTOR, and ASSIGNMENT 00111 IRbuHdr(); 00112 // Interface class: no default or copy constructor 00113 virtual ~IRbuHdr (); 00114 00116 //output table information. 00120 virtual std::ostream & streamify(std::ostream & cout ) const = 0; 00121 00122 virtual std::string getBiosVersion() const = 0; 00123 virtual void getHdrVersion(unsigned int &major, unsigned int &minor) const = 0; 00124 virtual const u32 *getSystemIdList() const = 0; 00125 virtual void doUpdate() const = 0; 00126 virtual FILE *getFh() const = 0; 00127 00128 private: 00129 explicit IRbuHdr(const IRbuHdr &); 00130 void operator =( const IRbuHdr & ); 00131 }; 00132 00133 std::ostream & operator << (std::ostream & cout, const IRbuHdr & item); 00134 00136 00138 void cancelDellBiosUpdate(); 00139 00141 00143 bool checkSystemId(const IRbuHdr &hdr, u16 sysId ); 00144 00146 00148 void dellBiosUpdate(const IRbuHdr &hdr, packet_type force_type); 00149 00151 00153 int compareBiosVersion(std::string ver1, std::string ver2); 00154 00155 } 00156 00157 // always should be last thing in header file 00158 #include "smbios/config/abi_suffix.hpp" 00159 00160 #endif /* RBU_H */