Generic hardware access library
/home/cschwick/hal/generic/include/hal/PCIDevice.hh
Go to the documentation of this file.
00001 #ifndef __PCIDevice
00002 #define __PCIDevice
00003 
00004 #include <string>
00005 #include <vector>
00006 
00007 #include "hal/IllegalValueException.hh"
00008 #include "hal/PCIAddressTable.hh"
00009 #include "hal/HardwareDevice.hh"
00010 #include "hal/PCIDeviceIdentifier.hh"
00011 #include "hal/PCIBusAdapterInterface.hh"
00012 
00013 namespace HAL {
00014 
00038 class PCIDevice : public HardwareDevice {
00039 
00040 public:
00041 
00042   typedef struct PCILocationIdentifier_s {
00043     uint32_t busID;
00044     uint32_t slotID;
00045     uint32_t functionID;
00046   } PCILocationIdentifier;
00047       
00075   PCIDevice( PCIAddressTable & addressTable,
00076              PCIBusAdapterInterface & pciBusAdapter,
00077              uint32_t vendorID,
00078              uint32_t deviceID,
00079              uint32_t index,
00080              bool swapFlag = false);
00081 
00095   PCIDevice( PCIAddressTable & addressTable,
00096              PCIBusAdapterInterface & pciBusAdapter,
00097              uint32_t vendorID,
00098              uint32_t deviceID,
00099              uint32_t index,
00100              std::vector<uint32_t>& baseAddresses,
00101              uint32_t command );
00102 
00103 
00128   PCIDevice( PCIAddressTable & addressTable,
00129              PCIBusAdapterInterface & pciBusAdapter,
00130              const PCILocationIdentifier& location,
00131              bool swapFlag );
00132 
00133   virtual ~PCIDevice();
00134 
00142   void hardwareWrite( const GeneralHardwareAddress& pciAddress, 
00143                       uint32_t data,
00144                       uint32_t offset = 0 ) const
00145     throw (IllegalValueException,
00146            BusAdapterException);
00154   void hardwareRead( const GeneralHardwareAddress& pciAddress, 
00155                      uint32_t* result,
00156                      uint32_t offset = 0 ) const
00157     throw (IllegalValueException,
00158            BusAdapterException);
00159 
00175   void memoryWrite( uint32_t address,
00176                     uint32_t barId,
00177                     uint32_t data ) const
00178     throw (IllegalValueException,
00179            BusAdapterException);
00180   
00195   void memoryRead( uint32_t address,
00196                    uint32_t barId,
00197                    uint32_t* result ) const
00198     throw (IllegalValueException,
00199            BusAdapterException);
00200 
00214   void configWrite( uint32_t address,
00215                     uint32_t data ) const
00216     throw (BusAdapterException);
00217   
00231   void configRead( uint32_t address,
00232                    uint32_t* result ) const
00233     throw (BusAdapterException);
00234 
00235 
00263   void hardwareReadBlock( const GeneralHardwareAddress& pciAddress, 
00264                           uint32_t length,
00265                           char *buffer,
00266                           HalAddressIncrement addressBehaviour = HAL_DO_INCREMENT,
00267                           uint32_t offset = 0) const
00268     throw (IllegalValueException, 
00269            UnsupportedException, 
00270            IllegalOperationException,
00271            BusAdapterException);
00272 
00299   void hardwareWriteBlock( const GeneralHardwareAddress& pciAddress, 
00300                            uint32_t length,
00301                            char *buffer,
00302                            HalAddressIncrement addressBehaviour = HAL_DO_INCREMENT,
00303                            uint32_t offset = 0) const
00304     throw (IllegalValueException, 
00305            UnsupportedException, 
00306            IllegalOperationException,
00307            BusAdapterException);
00308 
00313   uint32_t getItemAddress( std::string ) const
00314     throw ( NoSuchItemException,
00315             IllegalOperationException );
00316 
00322   uint32_t getPCIBusAddress( uint32_t iBar )
00323     throw (BusAdapterException);
00324 
00325 
00326 
00327 private:
00328   PCIAddressTable& pciAddressTable;
00329   PCIBusAdapterInterface& pciBusAdapter;
00330   PCIDeviceIdentifier* deviceIdentifierPtr;
00331   std::vector<uint32_t> baseRegisters;
00332 };
00333 
00334 } /* namespace HAL */
00335 
00336 #endif /* __PCIDevice */
00337 
00338