Library of Bus-Adapters
HAL::PCIDummyBusAdapter Class Reference

A dummy PCIBusAdapter in order to work without hardware. More...

#include <PCIDummyBusAdapter.hh>

List of all members.

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_

Detailed Description

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.

See also:
BusAdapterInterface
Author:
Christoph Schwick
Revision:
1.1
Date:
2007/03/06 09:54:25

Definition at line 31 of file PCIDummyBusAdapter.hh.


Member Enumeration Documentation

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.

Enumerator:
MEMORY_MAP_OFF 
MEMORY_MAP_ON 

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.

Enumerator:
VERBOSE_OFF 
VERBOSE_ON 

Definition at line 50 of file PCIDummyBusAdapter.hh.


Constructor & Destructor Documentation

HAL::PCIDummyBusAdapter::PCIDummyBusAdapter ( enum VerboseMode  verbose = VERBOSE_ON,
enum MemoryMode  memoryMode = MEMORY_MAP_ON,
std::ostream &  os = std::cout 
)

The constructor takes two arguments:

Parameters:
verboseallows you to monitor all data transfers: If set to true every action is reported on the standard output.
memoryModeallows 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.

There is nothing to do in the desctructor.

Definition at line 18 of file PCIDummyBusAdapter.cc.


Member Function Documentation

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.


Member Data Documentation

Definition at line 168 of file PCIDummyBusAdapter.hh.

Definition at line 170 of file PCIDummyBusAdapter.hh.

std::ostream& HAL::PCIDummyBusAdapter::os_ [private]

Definition at line 171 of file PCIDummyBusAdapter.hh.

Definition at line 169 of file PCIDummyBusAdapter.hh.


The documentation for this class was generated from the following files: