Library of Bus-Adapters
/home/cschwick/hal/busAdapter/dummy/include/hal/VME64xDummyBusAdapter.hh
Go to the documentation of this file.
00001 #ifndef __VME64xDummyBusAdapter
00002 #define __VME64xDummyBusAdapter
00003 
00004 #include <iostream>
00005 #include <string>
00006 #include <sstream>
00007 #include <vector>
00008 #include <map>
00009 #include "hal/NoSuchFileException.hh"
00010 #include "hal/VMEBusAdapterInterface.hh"
00011 #include "hal/VMEDummyDeviceIdentifier.hh"
00012 #include "hal/ConfigurationSpaceFileReader.hh"
00013 
00014 namespace HAL {
00015 
00052 class VME64xDummyBusAdapter : public VMEBusAdapterInterface {
00053 
00054 public:
00055 
00071   enum VerboseMode { VERBOSE_OFF, VERBOSE_ON };
00072 
00084   enum MemoryMode  { MEMORY_MAP_OFF, MEMORY_MAP_ON };
00085 
00114   VME64xDummyBusAdapter( std::string configSpaceDefinitionFile,
00115                          enum VerboseMode verbose    = VERBOSE_ON,
00116                          enum MemoryMode  memoryMode = MEMORY_MAP_ON,
00117                          std::ostream& os = std::cout )
00118     throw (IllegalValueException,
00119            NoSuchFileException);
00123   virtual ~VME64xDummyBusAdapter();
00124 
00125 
00133   void openDevice( const VMEAddressTable& VMEAddressTable,
00134                    uint32_t vmeBaseaddress,
00135                    DeviceIdentifier** deviceIdentifierPtr,
00136                    uint32_t* baseAddressPtr,
00137                    bool doSwapping )
00138     throw();
00139 
00146   void openDevice( const VMEAddressTable& vmeAddressTable,
00147                    std::vector<uint32_t> vmeBaseaddresses,
00148                    DeviceIdentifier** deviceIdentifierPtr,
00149                    std::vector<uint32_t>* baseAddressPtr,
00150                    bool doSwapping ) 
00151     throw();
00156   void closeDevice( DeviceIdentifier* deviceIdentifier )
00157     throw();
00158   
00159   void write( DeviceIdentifier* deviceIdentifier,
00160               uint32_t address,
00161               uint32_t addressModifier,
00162               uint32_t dataWidth,
00163               uint32_t data)
00164     throw(BusAdapterException);
00165   
00166   void read( DeviceIdentifier* DeviceIdentifier,
00167              uint32_t address,
00168              uint32_t addressModifier,
00169              uint32_t dataWidth,
00170              uint32_t* result)
00171     throw(BusAdapterException);
00172 
00173   void writeBlock( DeviceIdentifier* deviceIdentifierPtr,
00174                    uint32_t startAddress,
00175                    uint32_t length,      // in bytes
00176                    uint32_t addressModifier,
00177                    uint32_t dataWidth,
00178                    char *buffer,
00179                    HalAddressIncrement addressBehaviour = HAL_DO_INCREMENT )
00180     throw();
00181   
00182   void readBlock( DeviceIdentifier* deviceIdentifierPtr,
00183                   uint32_t startAddress,
00184                   uint32_t length,      // in bytes
00185                   uint32_t addressModifier,
00186                   uint32_t dataWidth,
00187                   char *buffer,
00188                   HalAddressIncrement addressBehaviour = HAL_DO_INCREMENT )
00189     throw();
00190 
00191   void resetBus( )
00192     throw();
00193   
00194 private:
00195 
00196     uint32_t doSwap( uint32_t data, uint32_t dataWidth ) const;
00197 
00198   void checkConfigAccess(uint32_t address, uint32_t dataWidth, 
00199                        uint32_t slotId, uint32_t byte )
00200   throw (BusAdapterException);
00201 
00202   std::ostream& os_;
00203   uint32_t deviceNumberCounter;
00204   enum VerboseMode verbose;
00205   enum MemoryMode  memoryMode;
00206   std::vector< std::map<uint32_t, uint32_t>* > configSpaceVector_;
00207 };
00208 
00209 } /* namespace HAL */
00210 
00211 #endif /* __VME64xDummyBusAdapter */