ISmi.h

Go to the documentation of this file.
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 SMIINTERFACE_H
00020 #define SMIINTERFACE_H
00021 
00022 // compat header should always be first header, if system headers included
00023 #include "smbios/compat.h"
00024 
00025 // types.h should be first user-defined header.
00026 #include "smbios/types.h"
00027 
00028 #include "smbios/IFactory.h"
00029 #include "smbios/IException.h"
00030 
00031 // abi_prefix should be last header included before declarations
00032 #include "smbios/config/abi_prefix.hpp"
00033 
00034 namespace smi
00035 {
00037 
00039     // Exceptions
00040     DECLARE_EXCEPTION( SmiException );
00041     DECLARE_EXCEPTION_EX( InvalidSmiMode, smi, SmiException );
00042     DECLARE_EXCEPTION_EX( ParameterError, smi, SmiException );
00043     DECLARE_EXCEPTION_EX( UnhandledSmi, smi, SmiException );
00044     DECLARE_EXCEPTION_EX( UnsupportedSmi, smi, SmiException );
00045     DECLARE_EXCEPTION_EX( SmiExecutedWithError, smi, SmiException );
00046     DECLARE_EXCEPTION_EX( PasswordVerificationFailed, smi, SmiException );
00047 
00048     // forward declarations.
00049     class ISmi;
00050 
00051     // NOTE: does not hand out singletons
00052     class SmiFactory : public virtual factory::IFactory
00053     {
00054     public:
00055         enum { RAW_SMI, DELL_CALLING_INTERFACE_SMI, };
00056     
00057         static SmiFactory *getFactory();
00058         virtual ~SmiFactory() throw();
00059         virtual std::auto_ptr<ISmi> makeNew(u8 type) = 0; // not for use
00060     protected:
00061         SmiFactory();
00062     };
00063 
00064     class ISmi  
00065     {
00066     public:
00067         explicit ISmi();
00068         // compiler-generated copy and operator = are good for now, I think.
00069 
00070         virtual void execute() = 0;
00071         virtual u8 *getBufferPtr() = 0;
00072         virtual void setBufferSize(size_t newSize) = 0;
00073         virtual void setCommandIOMagic( u16 address, u8 code ) = 0;
00074 
00075         virtual ~ISmi();
00076     };
00077 
00078     class IDellCallingInterfaceSmi  : virtual public ISmi
00079     {
00080     public:
00081         explicit IDellCallingInterfaceSmi();
00082         // compiler-generated copy and operator = are good for now, I think.
00083 
00084         virtual void setClass( u16 newClass ) = 0;
00085         virtual void setSelect( u16 newSelect ) = 0;
00086         virtual void setArg( u8 argNumber, u32 argValue ) = 0;
00087         virtual u32  getRes( u8 resNumber ) const = 0;
00088         virtual void setArgAsPhysicalAddress( u8 argNumber, u32 bufferOffset ) = 0;
00089 
00090         virtual ~IDellCallingInterfaceSmi();
00091     };
00092 
00093     // non-member helper functions
00094     // These encapsulate some common calling-interface SMI functions
00095     //
00096     void doSimpleCallingInterfaceSmi(u16 smiClass, u16 select, const u32 args[4], u32 res[4]);
00097     std::auto_ptr<smi::IDellCallingInterfaceSmi> setupCallingInterfaceSmi(u16 smiClass, u16 select, const u32 args[4]);
00098     u32 getAuthenticationKey(const std::string &password);
00099 
00100     enum password_format_enum { PW_FORMAT_UNKNOWN, PW_FORMAT_SCAN_CODE, PW_FORMAT_ASCII };
00101     password_format_enum getPasswordFormat();
00102 
00103     std::string getServiceTag();
00104     void setServiceTag(const std::string &password, const std::string &newTag);
00105     std::string getAssetTag();
00106     void setAssetTag(const std::string &password, const std::string &newTag);
00107     
00108     u32 readNVStorage         (u32 location, u32 *minValue, u32 *maxValue);
00109     u32 readBatteryModeSetting(u32 location, u32 *minValue, u32 *maxValue);
00110     u32 readACModeSetting     (u32 location, u32 *minValue, u32 *maxValue);
00111     u32 readSystemStatus(u32 *failingSensorHandle);
00112 
00113     u32 writeNVStorage         (const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue);
00114     u32 writeBatteryModeSetting(const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue);
00115     u32 writeACModeSetting     (const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue);
00116 
00117     void getDisplayType(u32 &type, u32 &resolution, u32 &memSizeX256kb);
00118     void getPanelResolution(u32 &horiz, u32 &vert);
00119     void getActiveDisplays(u32 &bits);
00120     void setActiveDisplays(u32 &bits);
00121 
00122     void getPropertyOwnershipTag(char *tagBuf, size_t size);
00123     void setPropertyOwnershipTag(const std::string password, const char *newTag, size_t size);
00124 }
00125 
00126 // always should be last thing in header file
00127 #include "smbios/config/abi_suffix.hpp"
00128 
00129 #endif  /* SMIINTERFACE_H */

Generated on Tue Jan 17 02:59:07 2006 for SMBIOS Library by  doxygen 1.4.6