libsmbios_c library
ISmi.h
Go to the documentation of this file.
1 // vim:expandtab:autoindent:tabstop=4:shiftwidth=4:filetype=c:
2 /*
3  * Copyright (C) 2005 Dell Inc.
4  * by Michael Brown <Michael_E_Brown@dell.com>
5  * Licensed under the Open Software License version 2.1
6  *
7  * Alternatively, you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published
9  * by the Free Software Foundation; either version 2 of the License,
10  * or (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful, but
13  * WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15  * See the GNU General Public License for more details.
16  */
17 
18 
19 #ifndef SMIINTERFACE_H
20 #define SMIINTERFACE_H
21 
22 // compat header should always be first header, if system headers included
23 #include "smbios/compat.h"
24 
25 #include <iostream>
26 #include <memory>
27 
28 // types.h should be first user-defined header.
29 #include "smbios/types.h"
30 
31 #include "smbios/IFactory.h"
32 #include "smbios/IException.h"
33 
34 // abi_prefix should be last header included before declarations
36 
37 namespace smi
38 {
40 
42  // Exceptions
43  DECLARE_EXCEPTION( SmiException );
44  DECLARE_EXCEPTION_EX( InvalidSmiMode, smi, SmiException );
45  DECLARE_EXCEPTION_EX( ParameterError, smi, SmiException );
46  DECLARE_EXCEPTION_EX( UnhandledSmi, smi, SmiException );
47  DECLARE_EXCEPTION_EX( UnsupportedSmi, smi, SmiException );
48  DECLARE_EXCEPTION_EX( SmiExecutedWithError, smi, SmiException );
49  DECLARE_EXCEPTION_EX( PasswordVerificationFailed, smi, SmiException );
50  DECLARE_EXCEPTION_EX( ConfigError, smi, SmiException );
51 
53  {
54  public:
55  virtual ~IDellCallingInterfaceSmi();
56  // compiler-generated copy and operator = are good for now, I think.
57 
58  virtual void setClass( u16 newClass ) = 0;
59  virtual void setSelect( u16 newSelect ) = 0;
60  virtual void setArg( u8 argNumber, u32 argValue ) = 0;
61  virtual u32 getRes( u8 resNumber ) const = 0;
62  virtual void setArgAsPhysicalAddress( u8 argNumber, u32 bufferOffset ) = 0;
63  virtual void setBufferSize(size_t size) = 0;
64  virtual void setBufferContents(const u8 *, size_t size) = 0;
65  virtual const u8 *getBufferPtr() = 0;
66 
67  virtual void execute() = 0;
68 
69  protected:
70  explicit IDellCallingInterfaceSmi();
71  };
72 
73  // NOTE: does not hand out singletons
74  class SmiFactory : public virtual factory::IFactory
75  {
76  public:
78 
79  static SmiFactory *getFactory();
80  virtual ~SmiFactory() throw();
81  virtual std::auto_ptr<IDellCallingInterfaceSmi> makeNew(u8 type) = 0; // not for use
82  protected:
83  SmiFactory();
84  };
85 
86  enum {cbARG1 = 0, cbARG2 = 1, cbARG3 = 2, cbARG4 = 3};
87  enum {cbRES1 = 0, cbRES2 = 1, cbRES3 = 2, cbRES4 = 3};
88 
89  // non-member helper functions
90  // These encapsulate some common calling-interface SMI functions
91  //
92  void doSimpleCallingInterfaceSmi(u16 smiClass, u16 select, const u32 args[4], u32 res[4]);
93  std::auto_ptr<smi::IDellCallingInterfaceSmi> setupCallingInterfaceSmi(u16 smiClass, u16 select, const u32 args[4]);
94  u32 getAuthenticationKey(const std::string &password);
95 
98 
99 #if 0
100  // not yet implemented
101  std::string getServiceTag();
102  void setServiceTag(const std::string &password, const std::string &newTag);
103  std::string getAssetTag();
104  void setAssetTag(const std::string &password, const std::string &newTag);
105 #endif
106 
107  bool getPasswordStatus(u16 which);
108 
109  u32 readNVStorage (u32 location, u32 *minValue, u32 *maxValue);
110  u32 readBatteryModeSetting(u32 location, u32 *minValue, u32 *maxValue);
111  u32 readACModeSetting (u32 location, u32 *minValue, u32 *maxValue);
112  u32 readSystemStatus(u32 *failingSensorHandle);
113 
114  u32 writeNVStorage (const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue);
115  u32 writeBatteryModeSetting(const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue);
116  u32 writeACModeSetting (const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue);
117 
118  void getDisplayType(u32 &type, u32 &resolution, u32 &memSizeX256kb);
119  void getPanelResolution(u32 &horiz, u32 &vert);
120  void getActiveDisplays(u32 &bits);
121  void setActiveDisplays(u32 &bits);
122 
123  void getPropertyOwnershipTag(char *tagBuf, size_t size);
124  void setPropertyOwnershipTag(const std::string password, const char *newTag, size_t size);
125 
126  // newer interface
127  extern const int Bluetooth_Devices_Disable; // docs appear to be wrong. They say 0x0152, but this looks backwards from reality
128  extern const int Bluetooth_Devices_Enable; // docs appear to be wrong. They say 0x0153, but this looks backwards from reality
129  extern const int Cellular_Radio_Disable;
130  extern const int Cellular_Radio_Enable;
131  extern const int WiFi_Locator_Disable;
132  extern const int WiFi_Locator_Enable;
133  extern const int Wireless_LAN_Disable;
134  extern const int Wireless_LAN_Enable;
141 
142  // old interface
143  extern const int Radio_Transmission_Enable;
144  extern const int Radio_Transmission_Disable;
145  extern const int Wireless_Device_Disable;
146  extern const int Wireless_Device_App_Control;
147  extern const int Wireless_Device_App_Or_Hotkey_Control;
148 
150  void wirelessRadioControl(bool enable, bool boot, bool runtime, int enable_token, int disable_token, int radioNum, std::string password);
151 
153  void wirelessSwitchControl(bool enable, bool boot, bool runtime, int enable_token, int disable_token, int switchNum, std::string password);
154 
156  radioStatusCode wirelessRadioStatus(radioNum which, std::ostream &cout=std::cout, u32 defRes2=0);
157 }
158 
159 // always should be last thing in header file
161 
162 #endif /* SMIINTERFACE_H */
Definition: ISmi.h:87
void wirelessSwitchControl(bool enable, bool boot, bool runtime, int enable_token, int disable_token, int switchNum, std::string password)
u32 readNVStorage(u32 location, u32 *minValue, u32 *maxValue)
radioNum
Definition: ISmi.h:149
const int Bluetooth_Devices_Disable
Definition: ISmi.h:155
const int Radio_Transmission_Disable
Definition: ISmi.h:149
u32 writeNVStorage(const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue)
Definition: ISmi.h:149
const int Cellular_Radio_Disable
virtual void setArgAsPhysicalAddress(u8 argNumber, u32 bufferOffset)=0
Definition: ISmi.h:87
virtual const u8 * getBufferPtr()=0
void wirelessRadioControl(bool enable, bool boot, bool runtime, int enable_token, int disable_token, int radioNum, std::string password)
void getActiveDisplays(u32 &bits)
const int Wireless_LAN_Enable
Definition: ISmi.h:155
void doSimpleCallingInterfaceSmi(u16 smiClass, u16 select, const u32 args[4], u32 res[4])
password_format_enum getPasswordFormat()
Definition: ISmi.h:155
virtual void setSelect(u16 newSelect)=0
virtual u32 getRes(u8 resNumber) const =0
virtual void setBufferContents(const u8 *, size_t size)=0
Definition: ISmi.h:96
password_format_enum
Definition: ISmi.h:96
u32 writeBatteryModeSetting(const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue)
void setPropertyOwnershipTag(const std::string password, const char *newTag, size_t size)
Definition: ISmi.h:96
const int Radio_Transmission_Enable
static SmiFactory * getFactory()
const int Wireless_Switch_Cellular_Control_Disable
Definition: ISmi.h:152
virtual ~SmiFactory()
const int Wireless_Device_Disable
DECLARE_EXCEPTION(SmiException)
Abstract base class for the smi read write operations.
Definition: ISmi.h:152
radioStatusCode
Definition: ISmi.h:155
void getPropertyOwnershipTag(char *tagBuf, size_t size)
Definition: ISmi.h:96
void getDisplayType(u32 &type, u32 &resolution, u32 &memSizeX256kb)
virtual void setClass(u16 newClass)=0
const int Bluetooth_Devices_Enable
const int Wireless_Switch_Cellular_Control_Enable
std::auto_ptr< smi::IDellCallingInterfaceSmi > setupCallingInterfaceSmi(u16 smiClass, u16 select, const u32 args[4])
virtual std::auto_ptr< IDellCallingInterfaceSmi > makeNew(u8 type)=0
bool getPasswordStatus(u16 which)
u32 getAuthenticationKey(const std::string &password)
const int Wireless_Switch_Wireless_LAN_Control_Enable
const int Wireless_LAN_Disable
void setActiveDisplays(u32 &bits)
Definition: ISmi.h:155
virtual void setArg(u8 argNumber, u32 argValue)=0
const int WiFi_Locator_Enable
unsigned int u32
Definition: types.h:35
Definition: ISmi.h:74
u32 writeACModeSetting(const std::string &password, u32 location, u32 value, u32 *minValue, u32 *maxValue)
Definition: ISmi.h:155
Definition: ISmi.h:87
Definition: ISmi.h:152
void getPanelResolution(u32 &horiz, u32 &vert)
const int Wireless_Device_App_Control
Definition: ISmi.h:86
unsigned short u16
Definition: types.h:31
Definition: ISmi.h:86
const int WiFi_Locator_Disable
u32 readBatteryModeSetting(u32 location, u32 *minValue, u32 *maxValue)
unsigned char u8
Definition: types.h:27
Definition: ISmi.h:87
Definition: ISmi.h:152
u32 readSystemStatus(u32 *failingSensorHandle)
const int Wireless_Switch_Wireless_LAN_Control_Disable
const int Cellular_Radio_Enable
Base class for all Abstract Factories.
Definition: IFactory.h:39
const int Wireless_Device_App_Or_Hotkey_Control
radioStatusCode wirelessRadioStatus(radioNum which, std::ostream &cout=std::cout, u32 defRes2=0)
u32 readACModeSetting(u32 location, u32 *minValue, u32 *maxValue)
DECLARE_EXCEPTION_EX(InvalidSmiMode, smi, SmiException)
const int Wireless_Switch_Bluetooth_Control_Disable
Definition: ISmi.h:86
Definition: ISmi.h:86
Definition: ISmi.h:52
const int Wireless_Switch_Bluetooth_Control_Enable
virtual void setBufferSize(size_t size)=0
Definition: ISmi.h:149