Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

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 #include <iostream>
00026 
00027 // types.h should be first user-defined header.
00028 #include "smbios/types.h"
00029 
00030 #include "smbios/IFactory.h"
00031 #include "smbios/IException.h"
00032 
00033 // abi_prefix should be last header included before declarations
00034 #include "smbios/config/abi_prefix.hpp"
00035 
00036 namespace smi
00037 {
00039 
00041     // Exceptions
00042     DECLARE_EXCEPTION( SmiException );
00043     DECLARE_EXCEPTION_EX( InvalidSmiMode, smi, SmiException );
00044     DECLARE_EXCEPTION_EX( ParameterError, smi, SmiException );
00045     DECLARE_EXCEPTION_EX( UnhandledSmi, smi, SmiException );
00046     DECLARE_EXCEPTION_EX( UnsupportedSmi, smi, SmiException );
00047     DECLARE_EXCEPTION_EX( SmiExecutedWithError, smi, SmiException );
00048     DECLARE_EXCEPTION_EX( PasswordVerificationFailed, smi, SmiException );
00049     DECLARE_EXCEPTION_EX( ConfigError, smi, SmiException );
00050 
00051     // forward declarations.
00052     class ISmi;
00053 
00054     // NOTE: does not hand out singletons
00055     class SmiFactory : public virtual factory::IFactory
00056     {
00057     public:
00058         enum { RAW_SMI, DELL_CALLING_INTERFACE_SMI_RAW, DELL_CALLING_INTERFACE_SMI,};
00059     
00060         static SmiFactory *getFactory();
00061         virtual ~SmiFactory() throw();
00062         virtual std::auto_ptr<ISmi> makeNew(u8 type) = 0; // not for use
00063     protected:
00064         SmiFactory();
00065     };
00066 
00067     class ISmi  
00068     {
00069     public:
00070         explicit ISmi();
00071         // compiler-generated copy and operator = are good for now, I think.
00072 
00073         virtual void execute() = 0;
00074         virtual u8 *getBufferPtr() = 0;
00075         virtual void setBufferSize(size_t newSize) = 0;
00076         virtual void setCommandIOMagic( u16 address, u8 code ) = 0;
00077 
00078         virtual ~ISmi();
00079     };
00080 
00081     class IDellCallingInterfaceSmi  : virtual public ISmi
00082     {
00083     public:
00084         explicit IDellCallingInterfaceSmi();
00085         // compiler-generated copy and operator = are good for now, I think.
00086         virtual void setClass( u16 newClass ) = 0;
00087         virtual void setSelect( u16 newSelect ) = 0;
00088         virtual void setArg( u8 argNumber, u32 argValue ) = 0;
00089         virtual u32  getRes( u8 resNumber ) const = 0;
00090         virtual void setArgAsPhysicalAddress( u8 argNumber, u32 bufferOffset ) = 0;
00091 
00092         virtual ~IDellCallingInterfaceSmi();
00093     };
00094 
00095     enum {cbARG1 = 0, cbARG2 = 1, cbARG3 = 2, cbARG4 = 3};
00096     enum {cbRES1 = 0, cbRES2 = 1, cbRES3 = 2, cbRES4 = 3};
00097 
00098     // non-member helper functions
00099     // These encapsulate some common calling-interface SMI functions
00100     //
00101     void doSimpleCallingInterfaceSmi(u16 smiClass, u16 select, const u32 args[4], u32 res[4]);
00102     std::auto_ptr<smi::IDellCallingInterfaceSmi> setupCallingInterfaceSmi(u16 smiClass, u16 select, const u32 args[4]);
00103     u32 getAuthenticationKey(const std::string &password);
00104 
00105     enum password_format_enum { PW_FORMAT_UNKNOWN, PW_FORMAT_SCAN_CODE, PW_FORMAT_ASCII };
00106     password_format_enum getPasswordFormat();
00107 
00108     std::string getServiceTag();
00109     void setServiceTag(const std::string &password, const std::string &newTag);
00110     std::string getAssetTag();
00111     void setAssetTag(const std::string &password, const std::string &newTag);
00112     
00113     u32 readNVStorage         (u32 location, u32 *minValue, u32 *maxValue);
00114     u32 readBatteryModeSetting(u32 location, u32 *minValue, u32 *maxValue);
00115     u32 readACModeSetting     (u32 location, u32 *minValue, u32 *maxValue);
00116     u32 readSystemStatus(u32 *failingSensorHandle);
00117 
00118     u32 writeNVStorage         (const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue);
00119     u32 writeBatteryModeSetting(const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue);
00120     u32 writeACModeSetting     (const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue);
00121 
00122     void getDisplayType(u32 &type, u32 &resolution, u32 &memSizeX256kb);
00123     void getPanelResolution(u32 &horiz, u32 &vert);
00124     void getActiveDisplays(u32 &bits);
00125     void setActiveDisplays(u32 &bits);
00126 
00127     void getPropertyOwnershipTag(char *tagBuf, size_t size);
00128     void setPropertyOwnershipTag(const std::string password, const char *newTag, size_t size);
00129 
00130     // newer interface
00131     extern const int Bluetooth_Devices_Disable;  // docs appear to be wrong. They say 0x0152, but this looks backwards from reality
00132     extern const int Bluetooth_Devices_Enable;  // docs appear to be wrong. They say 0x0153, but this looks backwards from reality
00133     extern const int Cellular_Radio_Disable;
00134     extern const int Cellular_Radio_Enable;
00135     extern const int WiFi_Locator_Disable;
00136     extern const int WiFi_Locator_Enable;
00137     extern const int Wireless_LAN_Disable;
00138     extern const int Wireless_LAN_Enable;
00139     extern const int Wireless_Switch_Bluetooth_Control_Disable;
00140     extern const int Wireless_Switch_Bluetooth_Control_Enable;
00141     extern const int Wireless_Switch_Cellular_Control_Disable;
00142     extern const int Wireless_Switch_Cellular_Control_Enable;
00143     extern const int Wireless_Switch_Wireless_LAN_Control_Disable;
00144     extern const int Wireless_Switch_Wireless_LAN_Control_Enable;
00145 
00146     // old interface
00147     extern const int Radio_Transmission_Enable;
00148     extern const int Radio_Transmission_Disable;
00149     extern const int Wireless_Device_Disable;
00150     extern const int Wireless_Device_App_Control;
00151     extern const int Wireless_Device_App_Or_Hotkey_Control;
00152 
00153     enum radioNum { WLAN_RADIO_NUM=1, BLUETOOTH_RADIO_NUM=2, WWAN_RADIO_NUM=3 };
00154     void wirelessRadioControl(bool enable, bool boot, bool runtime, int enable_token, int disable_token, int radioNum, std::string password);
00155 
00156     enum { WLAN_SWITCH_CTL=1, BLUETOOTH_SWITCH_CTL=2, WWAN_SWITCH_CTL=4, LOCATOR_SWITCH_CTL=5 };
00157     void wirelessSwitchControl(bool enable, bool boot, bool runtime, int enable_token, int disable_token, int switchNum, std::string password);
00158 
00159     enum radioStatusCode { STATUS_ENABLED, STATUS_DISABLED, STATUS_NOT_PRESENT, STATUS_UNSUPPORTED, STATUS_UNKNOWN };
00160     radioStatusCode wirelessRadioStatus(radioNum which, std::ostream &cout=std::cout, u32 defRes2=0);
00161 }
00162 
00163 // always should be last thing in header file
00164 #include "smbios/config/abi_suffix.hpp"
00165 
00166 #endif  /* SMIINTERFACE_H */

Generated on Wed Apr 11 16:25:10 2007 for SMBIOS Library by doxygen 1.3.5