Generic hardware access library
/home/cschwick/hal/generic/include/hal/HardwareDevice.hh
Go to the documentation of this file.
00001 #ifndef __HardwareDevice
00002 #define __HardwareDevice
00003 
00004 #include <string>
00005 #include <iostream>
00006 
00007 #include "hal/IllegalOperationException.hh"
00008 #include "hal/NoSuchItemException.hh"
00009 #include "hal/VerifyException.hh"
00010 #include "hal/UnsupportedException.hh"
00011 #include "hal/GeneralHardwareAddress.hh"
00012 #include "hal/AddressTableInterface.hh"
00013 #include "hal/AddressTableItem.hh"
00014 #include "hal/HardwareDeviceInterface.hh"
00015 #include "hal/MaskBoundaryException.hh"
00016 #include "hal/linux/StopWatch.hh"
00017 #include "hal/AddressOutOfLimitsException.hh"
00018 
00019 namespace HAL {
00020 
00046 class HardwareDevice : public HardwareDeviceInterface {
00047 
00048 public:
00055   HardwareDevice( AddressTableInterface & AddressTable );
00056 
00057   virtual ~HardwareDevice();
00058 
00059   void unmaskedWrite( std::string item, 
00060                       uint32_t data, 
00061                       HalVerifyOption verifyFlag = HAL_NO_VERIFY,
00062                       uint32_t offset = 0 ) const
00063     throw (NoSuchItemException, 
00064            IllegalOperationException, 
00065            BusAdapterException,
00066            VerifyException,
00067            AddressOutOfLimitsException);
00068 
00069   void write( std::string item, 
00070               uint32_t data, 
00071               HalVerifyOption verifyFlag = HAL_NO_VERIFY,
00072               uint32_t offset = 0 ) const
00073     throw (NoSuchItemException,
00074            BusAdapterException,
00075            IllegalOperationException, 
00076            VerifyException,
00077            MaskBoundaryException,
00078            AddressOutOfLimitsException);
00079 
00080   void writePulse( std::string item, 
00081                    uint32_t offset = 0 ) const
00082     throw (NoSuchItemException, 
00083            BusAdapterException,
00084            IllegalOperationException,
00085            AddressOutOfLimitsException);
00086 
00087   void readPulse( std::string item, 
00088                   uint32_t offset = 0 ) const
00089     throw (NoSuchItemException,
00090            BusAdapterException,
00091            IllegalOperationException,
00092            AddressOutOfLimitsException);
00093 
00094   void unmaskedRead( std::string item, 
00095                      uint32_t* result, 
00096                      uint32_t offset = 0 ) const
00097     throw (NoSuchItemException,
00098            BusAdapterException,
00099            IllegalOperationException,
00100            AddressOutOfLimitsException);
00101 
00102   void read( std::string item, 
00103              uint32_t* result, 
00104              uint32_t offset = 0 ) const
00105     throw (NoSuchItemException,
00106            BusAdapterException,
00107            IllegalOperationException,
00108            MaskBoundaryException,
00109            AddressOutOfLimitsException );
00110 
00111   bool check( std::string item,
00112               uint32_t expected,
00113               std::string faultMessage = "",
00114               uint32_t offset = 0,
00115               std::ostream& os = std::cout ) const
00116     throw( NoSuchItemException,
00117            IllegalOperationException,
00118            BusAdapterException,
00119            AddressOutOfLimitsException);
00120 
00121   void setBit( std::string item, 
00122                HalVerifyOption verifyFlag = HAL_NO_VERIFY,
00123                uint32_t offset = 0 ) const
00124     throw (NoSuchItemException, 
00125            IllegalOperationException, 
00126            BusAdapterException,
00127            VerifyException,
00128            AddressOutOfLimitsException);
00129 
00130   void resetBit( std::string item, 
00131                  HalVerifyOption verifyFlag = HAL_NO_VERIFY,
00132                  uint32_t offset = 0 ) const
00133     throw (NoSuchItemException, 
00134            IllegalOperationException, 
00135            BusAdapterException,
00136            VerifyException,
00137            AddressOutOfLimitsException);
00138 
00139   bool isSet( std::string item, 
00140               uint32_t offset = 0 ) const 
00141     throw (NoSuchItemException,
00142            BusAdapterException,
00143            IllegalOperationException,
00144            AddressOutOfLimitsException);
00145 
00146   void writeBlock( std::string startItem, 
00147                    uint32_t length,
00148                    char *buffer,
00149                    HalVerifyOption verifyFlag = HAL_NO_VERIFY,
00150                    HalAddressIncrement addressBehaviour = HAL_DO_INCREMENT,
00151                    uint32_t offset = 0 ) const
00152     throw ( NoSuchItemException,
00153             IllegalValueException, 
00154             UnsupportedException, 
00155             VerifyException,
00156             BusAdapterException,
00157             IllegalOperationException,
00158             AddressOutOfLimitsException );
00159 
00160   void readBlock( std::string startItem, 
00161                   uint32_t length,
00162                   char *buffer,
00163                   HalAddressIncrement addressBehaviour = HAL_DO_INCREMENT,
00164                   uint32_t offset = 0 ) const
00165     throw ( NoSuchItemException,
00166             IllegalValueException, 
00167             UnsupportedException,
00168             BusAdapterException,
00169             IllegalOperationException,
00170             AddressOutOfLimitsException );
00171 
00172   void pollItem( std::string item,
00173                  uint32_t referenceValue,
00174                  uint32_t timeout,
00175                  uint32_t *result,
00176                  HalPollMethod pollMethod = HAL_POLL_UNTIL_EQUAL,
00177                  uint32_t offset = 0 ) const
00178     throw ( NoSuchItemException,
00179             IllegalOperationException,
00180             BusAdapterException,
00181             MaskBoundaryException,
00182             TimeoutException,
00183             AddressOutOfLimitsException );
00184 
00185   const AddressTableInterface&  getAddressTableInterface() const; 
00186 
00187   void printAddressTable() const;
00188 
00189 
00202   virtual void hardwareRead( const GeneralHardwareAddress& address, 
00203                              uint32_t* result,
00204                              uint32_t offset = 0 ) const
00205     throw (IllegalValueException,
00206            BusAdapterException) = 0;
00207 
00208 
00221   virtual void hardwareWrite( const GeneralHardwareAddress& address, 
00222                               uint32_t data,
00223                               uint32_t offset = 0 ) const
00224     throw (IllegalValueException,
00225            BusAdapterException) = 0;
00226 
00239   virtual void hardwareReadBlock( const GeneralHardwareAddress& address,
00240                                   uint32_t length,
00241                                   char *buffer,
00242                                   HalAddressIncrement addressBehaviour = HAL_DO_INCREMENT,
00243                                   uint32_t offset = 0 ) const
00244     throw (IllegalValueException, 
00245            UnsupportedException,
00246            IllegalOperationException,
00247            BusAdapterException) = 0;
00248 
00261   virtual void hardwareWriteBlock( const GeneralHardwareAddress& address,
00262                                    uint32_t length,
00263                                    char *buffer,
00264                                    HalAddressIncrement addressBehaviour = HAL_DO_INCREMENT,
00265                                    uint32_t offset = 0 ) const
00266     throw (IllegalValueException, 
00267            UnsupportedException, 
00268            IllegalOperationException,
00269            BusAdapterException) = 0;
00270 
00271 private:
00272   void verify( uint32_t readBack,
00273                uint32_t data,
00274                std::string methodName ) const
00275     throw( VerifyException );
00276   
00277   void writeAddressItem( const AddressTableItem& addressItem,
00278                          uint32_t data,
00279                          uint32_t offset,
00280                          HalVerifyOption verify) const
00281     throw( MaskBoundaryException,
00282            IllegalValueException,
00283            BusAdapterException,
00284            VerifyException,
00285            AddressOutOfLimitsException );
00286 
00287   AddressTableInterface& addressTable;
00288 };
00289 
00290 } /* namespace HAL */
00291 
00292 #endif /* __HardwareDevice */