Library of Bus-Adapters
/home/cschwick/hal/busAdapter/dummy/include/hal/PCIDummyBusAdapter.hh
Go to the documentation of this file.
00001 #ifndef __PCIDummyBusAdapter
00002 #define __PCIDummyBusAdapter
00003 
00004 #include <vector>
00005 #include <iostream>
00006 
00007 #include "hal/PCIBusAdapterInterface.hh"
00008 #include "hal/PCIDummyDeviceIdentifier.hh"
00009 
00010 namespace HAL {
00011 
00031 class PCIDummyBusAdapter : public PCIBusAdapterInterface {
00032 
00033 public:
00034 
00050   enum VerboseMode { VERBOSE_OFF, VERBOSE_ON };
00051 
00063   enum MemoryMode  { MEMORY_MAP_OFF, MEMORY_MAP_ON };
00064 
00078   PCIDummyBusAdapter( enum VerboseMode verbose    = VERBOSE_ON,
00079                       enum MemoryMode  memoryMode = MEMORY_MAP_ON,
00080                       std::ostream& os = std::cout );
00081 
00085   virtual ~PCIDummyBusAdapter();
00086 
00087 
00098   void findDeviceByVendor( uint32_t vendorID, 
00099                            uint32_t deviceID,
00100                            uint32_t index,
00101                            const PCIAddressTable& pciAddressTable,
00102                            PCIDeviceIdentifier** deviceIdentifierPtr,
00103                            std::vector<uint32_t>& barRegisters,
00104                            bool swapFlag = false ) 
00105     throw();
00106   
00107   void findDeviceByBus( uint32_t busID, 
00108                         uint32_t slotID,
00109                         uint32_t functionID,
00110                         const PCIAddressTable& pciAddressTable,
00111                         PCIDeviceIdentifier** deviceIdentifierPtr,
00112                         std::vector<uint32_t>& barRegisters,
00113                         bool swapFlag = false )
00114     throw();
00115 
00120   void closeDevice( PCIDeviceIdentifier* deviceIdentifier )
00121     throw();
00122   
00123   void write( PCIDeviceIdentifier& device,
00124               uint32_t address,
00125               uint32_t data)
00126     throw();
00127   
00128   void read( PCIDeviceIdentifier& DeviceIdentifier,
00129              uint32_t address,
00130              uint32_t* result)
00131     throw();
00132 
00133   void configWrite( PCIDeviceIdentifier& device, 
00134                     uint32_t address, 
00135                     uint32_t data ) 
00136     throw( ) ;
00137 
00138   void configRead( PCIDeviceIdentifier& device,
00139                    uint32_t address, 
00140                    uint32_t* result )
00141     throw( );
00142 
00143   void writeBlock( PCIDeviceIdentifier& deviceIdentifierPtr,
00144                    uint32_t startAddress,
00145                    uint32_t length,      // in bytes
00146                    char *buffer,
00147                    HalAddressIncrement addressBehaviour = HAL_DO_INCREMENT )
00148     throw();
00149   
00150   void readBlock( PCIDeviceIdentifier& deviceIdentifierPtr,
00151                   uint32_t startAddress,
00152                   uint32_t length,      // in bytes
00153                   char *buffer,
00154                   HalAddressIncrement addressBehaviour = HAL_DO_INCREMENT )
00155     throw();
00156 
00157 private:
00158   // helpers:
00159   void findDevice( const PCIAddressTable& pciAddressTable,
00160                    PCIDeviceIdentifier** deviceIdentifierPtr,
00161                    std::vector<uint32_t>& barRegisters,
00162                    bool swapFlag )
00163     throw();
00164 
00165   uint32_t getBARIntervall( const std::vector<uint32_t>& maxAddresses);
00166 
00167 private:
00168   uint32_t deviceNumberCounter;
00169   enum VerboseMode verbose;
00170   enum MemoryMode  memoryMode;
00171   std::ostream& os_;
00172 };
00173 
00174 } /* namespace HAL */
00175 
00176 #endif /* __PCIDummyBusAdapter */