Library of Bus-Adapters
|
00001 #ifndef __PCILinuxBusAdapter 00002 #define __PCILinuxBusAdapter 00003 00004 #include <vector> 00005 #include "hal/HardwareDeviceInterface.hh" 00006 #include "hal/PCIBusAdapterInterface.hh" 00007 #include "hal/PCILinuxDeviceIdentifier.hh" 00008 #include "hal/NoSuchDeviceException.hh" 00009 #include "hal/BusAdapterException.hh" 00010 #include "hal/UnsupportedException.hh" 00011 #include "xpci/Bus.h" 00012 #include "xpci/Address.h" 00013 #include "byteswap.h" 00014 00015 namespace HAL { 00016 00039 class PCILinuxBusAdapter : public PCIBusAdapterInterface { 00040 public: 00041 00042 PCILinuxBusAdapter() throw (HAL::BusAdapterException); 00043 00044 virtual ~PCILinuxBusAdapter(); 00045 00058 void findDeviceByVendor( uint32_t vendorID, 00059 uint32_t deviceID, 00060 uint32_t index, 00061 const PCIAddressTable& pciAddressTable, 00062 PCIDeviceIdentifier** deviceIdentifierPtr, 00063 std::vector<uint32_t>& barRegisters, 00064 bool swapFlag = false ) 00065 throw( BusAdapterException, 00066 NoSuchDeviceException ); 00067 00080 void findDeviceByBus( uint32_t busID, 00081 uint32_t slotID, 00082 uint32_t functionID, 00083 const PCIAddressTable& pciAddressTable, 00084 PCIDeviceIdentifier** deviceIdentifierPtr, 00085 std::vector<uint32_t>& barRegisters, 00086 bool swapFlag = false ) 00087 throw( BusAdapterException, 00088 NoSuchDeviceException ); 00089 00094 void closeDevice( PCIDeviceIdentifier* deviceIdentifier ) 00095 throw(); 00096 00097 void write( PCIDeviceIdentifier& device, 00098 uint32_t address, 00099 uint32_t data) 00100 throw( BusAdapterException ); 00101 00102 void read( PCIDeviceIdentifier& device, 00103 uint32_t address, 00104 uint32_t* result) 00105 throw( BusAdapterException ); 00106 00107 void configWrite( PCIDeviceIdentifier& device, 00108 uint32_t address, 00109 uint32_t data ) 00110 throw( BusAdapterException ); 00111 00112 void configRead( PCIDeviceIdentifier& device, 00113 uint32_t address, 00114 uint32_t* result ) 00115 throw( BusAdapterException ); 00116 00117 void writeBlock( PCIDeviceIdentifier& device, 00118 uint32_t startAddress, 00119 uint32_t length, 00120 char *buffer, 00121 HalAddressIncrement addressBehaviour = HAL_DO_INCREMENT ) 00122 throw( BusAdapterException ); 00123 00124 void readBlock( PCIDeviceIdentifier& device, 00125 uint32_t startAddress, 00126 uint32_t length, 00127 char *buffer, 00128 HalAddressIncrement addressBehaviour = HAL_DO_INCREMENT ) 00129 throw( BusAdapterException ); 00130 00131 private: 00135 void findDevice( xpci::Address& deviceConfigAddress, 00136 const PCIAddressTable& pciAddressTable, 00137 PCIDeviceIdentifier** deviceIdentifierPtr, 00138 std::vector<uint32_t>& barRegisters, 00139 bool swapFlag = false ) 00140 throw( BusAdapterException, 00141 NoSuchDeviceException ); 00142 00143 xpci::Bus pciBus_; 00144 }; 00145 00146 } /* namespace HAL */ 00147 00148 #endif /* __PCILinuxBusAdapter */