Generic hardware access library
|
00001 #include "hal/VMEConfigurationSpaceDevice.hh" 00002 #include <sstream> 00003 00004 HAL::VMEConfigurationSpaceDevice::VMEConfigurationSpaceDevice( HAL::VMEAddressTable & vmeAddressTable, 00005 HAL::VMEBusAdapterInterface & vmeBusAdapter ) 00006 : HAL::VMEDevice( vmeAddressTable, vmeBusAdapter, 0x00 ) { 00007 } 00008 00009 // nothing to be done here. 00010 HAL::VMEConfigurationSpaceDevice::~VMEConfigurationSpaceDevice() { 00011 } 00012 00013 00014 void 00015 HAL::VMEConfigurationSpaceDevice::hardwareRead( const HAL::GeneralHardwareAddress& vmeAddress, 00016 uint32_t* result, 00017 uint32_t offset ) const 00018 throw ( HAL::BusAdapterException ) { 00019 00020 uint32_t myresult = 0; 00021 uint32_t newByte; 00022 for ( uint32_t i = 0; i < vmeAddress.getDataWidth(); i++ ) { 00023 vmeBusAdapter.read( deviceIdentifierPtr, 00024 vmeAddress.getAddress() + offset, 00025 0x2fUL, 1UL, &newByte ); 00026 newByte &= 0xff; 00027 offset += 4; 00028 myresult = ((myresult << 8) & 0xffffff00) + newByte; 00029 } 00030 *result = myresult; 00031 } 00032 00033 void 00034 HAL::VMEConfigurationSpaceDevice::hardwareWrite( const HAL::GeneralHardwareAddress& vmeAddress, 00035 uint32_t data, 00036 uint32_t offset ) const 00037 throw ( HAL::BusAdapterException ) { 00038 00039 uint32_t newByte; 00040 for ( int i = (vmeAddress.getDataWidth() - 1); i >= 0; i-- ) { 00041 newByte = (data >> (i*8)) & 0xff; 00042 vmeBusAdapter.write( deviceIdentifierPtr, 00043 vmeAddress.getAddress() + offset, 00044 0x2fUL, 1UL, newByte ); 00045 offset += 4; 00046 } 00047 } 00048 00049 void 00050 HAL::VMEConfigurationSpaceDevice::hardwareReadBlock( const HAL::GeneralHardwareAddress& address, 00051 uint32_t length, 00052 char *buffer, 00053 HalAddressIncrement addressBehaviour, 00054 uint32_t offset ) const 00055 throw (HAL::UnsupportedException) { 00056 std::stringstream text; 00057 text << "Block transfers are not supported for VME64(x) configuration space\n" 00058 << " (HAL::VMEConfigurationSpaceDevice::hardwareReadBlock)" << std::ends; 00059 throw( HAL::UnsupportedException( text.str(), __FILE__, __LINE__, __FUNCTION__ ) ); 00060 } 00061 00062 void 00063 HAL::VMEConfigurationSpaceDevice::hardwareWriteBlock( const HAL::GeneralHardwareAddress& address, 00064 uint32_t length, 00065 char *buffer, 00066 HalAddressIncrement addressBehaviour, 00067 uint32_t offset) const 00068 throw (HAL::UnsupportedException) { 00069 std::stringstream text; 00070 text << "Block transfers are not supported for VME64(x) configuration space\n" 00071 << " (HAL::VMEConfigurationSpaceDevice::hardwareReadBlock)" << std::ends; 00072 throw( HAL::UnsupportedException( text.str(), __FILE__, __LINE__, __FUNCTION__ ) ); 00073 }