Library of Bus-Adapters
|
A dummy PCIBusAdapter in order to work without hardware. More...
#include <PCIDummyBusAdapter.hh>
Public Types | |
enum | VerboseMode { VERBOSE_OFF, VERBOSE_ON } |
This enumerator is used in the constructor. More... | |
enum | MemoryMode { MEMORY_MAP_OFF, MEMORY_MAP_ON } |
This enumerator is used in the constructor. More... | |
Public Member Functions | |
PCIDummyBusAdapter (enum VerboseMode verbose=VERBOSE_ON, enum MemoryMode memoryMode=MEMORY_MAP_ON, std::ostream &os=std::cout) | |
The constructor takes two arguments: | |
virtual | ~PCIDummyBusAdapter () |
There is nothing to do in the desctructor. | |
void | findDeviceByVendor (uint32_t vendorID, uint32_t deviceID, uint32_t index, const PCIAddressTable &pciAddressTable, PCIDeviceIdentifier **deviceIdentifierPtr, std::vector< uint32_t > &barRegisters, bool swapFlag=false) throw () |
If the PCIDummyBusAdapter was created with the memoryMode option set to true, the call scans the PCIAddressTable in order to find out how much memory has to be reserved for the dummy Hardware device. | |
void | findDeviceByBus (uint32_t busID, uint32_t slotID, uint32_t functionID, const PCIAddressTable &pciAddressTable, PCIDeviceIdentifier **deviceIdentifierPtr, std::vector< uint32_t > &barRegisters, bool swapFlag=false) throw () |
void | closeDevice (PCIDeviceIdentifier *deviceIdentifier) throw () |
Here the memory regions which might have beeen reserved in the openDevice call, are deleted. | |
void | write (PCIDeviceIdentifier &device, uint32_t address, uint32_t data) throw () |
void | read (PCIDeviceIdentifier &DeviceIdentifier, uint32_t address, uint32_t *result) throw () |
void | configWrite (PCIDeviceIdentifier &device, uint32_t address, uint32_t data) throw ( ) |
void | configRead (PCIDeviceIdentifier &device, uint32_t address, uint32_t *result) throw ( ) |
void | writeBlock (PCIDeviceIdentifier &deviceIdentifierPtr, uint32_t startAddress, uint32_t length, char *buffer, HalAddressIncrement addressBehaviour=HAL_DO_INCREMENT) throw () |
void | readBlock (PCIDeviceIdentifier &deviceIdentifierPtr, uint32_t startAddress, uint32_t length, char *buffer, HalAddressIncrement addressBehaviour=HAL_DO_INCREMENT) throw () |
Private Member Functions | |
void | findDevice (const PCIAddressTable &pciAddressTable, PCIDeviceIdentifier **deviceIdentifierPtr, std::vector< uint32_t > &barRegisters, bool swapFlag) throw () |
uint32_t | getBARIntervall (const std::vector< uint32_t > &maxAddresses) |
Private Attributes | |
uint32_t | deviceNumberCounter |
enum VerboseMode | verbose |
enum MemoryMode | memoryMode |
std::ostream & | os_ |
A dummy PCIBusAdapter in order to work without hardware.
This BusAdapter merely serves to let you test you software without actually having hardware connected to your computer. All actions which in real life would result in read or write operations will be reported on the standard output.
Definition at line 31 of file PCIDummyBusAdapter.hh.
This enumerator is used in the constructor.
It switches the memory-mapping behaviour of the BusAdapter on or off. If switched on every address-space corresponding to a specific BAR or to the configuration space is mapped into the local memory of the host. It is then used to perform read and write operations into the mapped memory. This allows to play in a more realistic way with the device. See VerboseMode comments for a note on how to use this enumerator.
Definition at line 63 of file PCIDummyBusAdapter.hh.
This enumerator is used in the constructor.
It switches the versbose behaviour of the BusAdapter on or off. Note that the enumerator is a member of the class PCIDummyBusAdapter. So it must be used. This means that a Scope identifier is needed when calling the constructor of the class. A valid example would be:
PCIDummyBusAdapter myBa( PCIDummyBusAdapter::VERBOSE_ON, PCIDummyBusAdapter::MEMORY_MAP_OFF );
The enumerators have been put into the class in order not to contaminate the global namesapce with objects merely used for debugging purposes.
Definition at line 50 of file PCIDummyBusAdapter.hh.
HAL::PCIDummyBusAdapter::PCIDummyBusAdapter | ( | enum VerboseMode | verbose = VERBOSE_ON , |
enum MemoryMode | memoryMode = MEMORY_MAP_ON , |
||
std::ostream & | os = std::cout |
||
) |
The constructor takes two arguments:
verbose | allows you to monitor all data transfers: If set to true every action is reported on the standard output. |
memoryMode | allows you to create memory regions which fake the hardware device. For every openDevice call a memory region is created into which or from which data is transfered. With this you can write and read back data from you dummy-device. The size of the mapped region depend on the PCIAddressTable given to the openDevice call. |
Definition at line 5 of file PCIDummyBusAdapter.cc.
HAL::PCIDummyBusAdapter::~PCIDummyBusAdapter | ( | ) | [virtual] |
There is nothing to do in the desctructor.
Definition at line 18 of file PCIDummyBusAdapter.cc.
void HAL::PCIDummyBusAdapter::closeDevice | ( | PCIDeviceIdentifier * | deviceIdentifier | ) | throw () |
Here the memory regions which might have beeen reserved in the openDevice call, are deleted.
Definition at line 151 of file PCIDummyBusAdapter.cc.
void HAL::PCIDummyBusAdapter::configRead | ( | PCIDeviceIdentifier & | device, |
uint32_t | address, | ||
uint32_t * | result | ||
) | throw ( ) |
Definition at line 226 of file PCIDummyBusAdapter.cc.
void HAL::PCIDummyBusAdapter::configWrite | ( | PCIDeviceIdentifier & | device, |
uint32_t | address, | ||
uint32_t | data | ||
) | throw ( ) |
Definition at line 204 of file PCIDummyBusAdapter.cc.
void HAL::PCIDummyBusAdapter::findDevice | ( | const PCIAddressTable & | pciAddressTable, |
PCIDeviceIdentifier ** | deviceIdentifierPtr, | ||
std::vector< uint32_t > & | barRegisters, | ||
bool | swapFlag | ||
) | throw () [private] |
Definition at line 71 of file PCIDummyBusAdapter.cc.
void HAL::PCIDummyBusAdapter::findDeviceByBus | ( | uint32_t | busID, |
uint32_t | slotID, | ||
uint32_t | functionID, | ||
const PCIAddressTable & | pciAddressTable, | ||
PCIDeviceIdentifier ** | deviceIdentifierPtr, | ||
std::vector< uint32_t > & | barRegisters, | ||
bool | swapFlag = false |
||
) | throw () |
Definition at line 46 of file PCIDummyBusAdapter.cc.
void HAL::PCIDummyBusAdapter::findDeviceByVendor | ( | uint32_t | vendorID, |
uint32_t | deviceID, | ||
uint32_t | index, | ||
const PCIAddressTable & | pciAddressTable, | ||
PCIDeviceIdentifier ** | deviceIdentifierPtr, | ||
std::vector< uint32_t > & | barRegisters, | ||
bool | swapFlag = false |
||
) | throw () |
If the PCIDummyBusAdapter was created with the memoryMode option set to true, the call scans the PCIAddressTable in order to find out how much memory has to be reserved for the dummy Hardware device.
The pointers to this memory is then contained in the deviceIdentifier. For each BAR used in the pciAddressTable a separate memory region is created. Similarly if there are items of the configuration space in the pciAddressTable, a separate memory region is created.
Definition at line 22 of file PCIDummyBusAdapter.cc.
uint32_t HAL::PCIDummyBusAdapter::getBARIntervall | ( | const std::vector< uint32_t > & | maxAddresses | ) | [private] |
Definition at line 320 of file PCIDummyBusAdapter.cc.
void HAL::PCIDummyBusAdapter::read | ( | PCIDeviceIdentifier & | DeviceIdentifier, |
uint32_t | address, | ||
uint32_t * | result | ||
) | throw () |
Definition at line 160 of file PCIDummyBusAdapter.cc.
void HAL::PCIDummyBusAdapter::readBlock | ( | PCIDeviceIdentifier & | deviceIdentifierPtr, |
uint32_t | startAddress, | ||
uint32_t | length, | ||
char * | buffer, | ||
HalAddressIncrement | addressBehaviour = HAL_DO_INCREMENT |
||
) | throw () |
Definition at line 248 of file PCIDummyBusAdapter.cc.
void HAL::PCIDummyBusAdapter::write | ( | PCIDeviceIdentifier & | device, |
uint32_t | address, | ||
uint32_t | data | ||
) | throw () |
Definition at line 182 of file PCIDummyBusAdapter.cc.
void HAL::PCIDummyBusAdapter::writeBlock | ( | PCIDeviceIdentifier & | deviceIdentifierPtr, |
uint32_t | startAddress, | ||
uint32_t | length, | ||
char * | buffer, | ||
HalAddressIncrement | addressBehaviour = HAL_DO_INCREMENT |
||
) | throw () |
Definition at line 284 of file PCIDummyBusAdapter.cc.
uint32_t HAL::PCIDummyBusAdapter::deviceNumberCounter [private] |
Definition at line 168 of file PCIDummyBusAdapter.hh.
enum MemoryMode HAL::PCIDummyBusAdapter::memoryMode [private] |
Definition at line 170 of file PCIDummyBusAdapter.hh.
std::ostream& HAL::PCIDummyBusAdapter::os_ [private] |
Definition at line 171 of file PCIDummyBusAdapter.hh.
enum VerboseMode HAL::PCIDummyBusAdapter::verbose [private] |
Definition at line 169 of file PCIDummyBusAdapter.hh.