Generic hardware access library
|
00001 #include "hal/VME64xHardwareAddress.hh" 00002 #include <sstream> 00003 #include <iomanip> 00004 00005 HAL::VME64xHardwareAddress::VME64xHardwareAddress (uint32_t address, 00006 enum AddressSpace addressSpace, 00007 uint32_t mappedWindowId, 00008 uint32_t width ) 00009 throw (HAL::IllegalValueException) 00010 : HAL::GeneralHardwareAddress( address, 0 ) { 00011 00012 addressSpace_ = addressSpace; 00013 00014 if ( mappedWindowId > 7 && addressSpace == (AddressSpace)MEMORY) { 00015 std::stringstream text; 00016 text << "mapped window ID of " << mappedWindowId 00017 << "is illegal for VME64x modules\n (HAL::VME64xHardwareAddress::VME64xHardwareAddress)" 00018 << std::ends; 00019 throw( HAL::IllegalValueException( text.str(), __FILE__, __LINE__, __FUNCTION__ ) ); 00020 } 00021 00022 if ( addressSpace_ == (AddressSpace)CONFIGURATION ) { 00023 addressModifier_ = 0x2f; 00024 dataWidth_ = width; 00025 mapId_ = 0; // not used 00026 } else { 00027 addressModifier_ = 0; 00028 mapId_ = mappedWindowId; 00029 dataWidth_ = 4; //not used 00030 } 00031 } 00032 00033 void HAL::VME64xHardwareAddress::setWindowConfiguration( uint32_t AM, 00034 uint32_t dataWidth ) 00035 throw (HAL::IllegalValueException) { 00036 00037 if ( AM > 255 ) { 00038 std::stringstream text; 00039 text << "AddressModifier of " 00040 << std::hex << AM 00041 << " is illegal in this implementation.\n (HAL::VME64xHardwareAddress::setWindowConfiguration)" 00042 << std::ends; 00043 throw( HAL::IllegalValueException( text.str(), __FILE__, __LINE__, __FUNCTION__ ) ); 00044 } 00045 if ( addressSpace_ == (AddressSpace)CONFIGURATION && AM != 0x2f ) { 00046 std::stringstream text; 00047 text << "AddressModifier of " 00048 << std::hex << AM 00049 << " is illegal for Configuration space items.\n (HAL::VME64xHardwareAddress::setWindowConfiguration)" 00050 << std::ends; 00051 throw( HAL::IllegalValueException( text.str(), __FILE__, __LINE__, __FUNCTION__ ) ); 00052 } 00053 addressModifier_ = AM; 00054 dataWidth_ = dataWidth; 00055 } 00056 00057 uint32_t HAL::VME64xHardwareAddress::getAddressModifier() const 00058 throw () { 00059 return addressModifier_; 00060 } 00061 00062 bool HAL::VME64xHardwareAddress::isIOSpace() const 00063 throw( HAL::IllegalOperationException ) { 00064 std::string text = "There is no IO space in VME64x.\n (HAL::VME64xHardwareAddress::isIOSpace)"; 00065 throw( HAL::IllegalOperationException( text, __FILE__, __LINE__, __FUNCTION__ ) ); 00066 } 00067 00068 std::string HAL::VME64xHardwareAddress::getAddressSpaceString() const { 00069 std::string resultString = "UNDEFINED"; 00070 if (addressSpace_ == (AddressSpace)MEMORY) { 00071 resultString = "memory"; 00072 } else if (addressSpace_ == (AddressSpace)CONFIGURATION) { 00073 resultString = "configuration"; 00074 } 00075 return resultString; 00076 } 00077 00078 void HAL::VME64xHardwareAddress::print( std::ostream& os ) const { 00079 std::string vmeSpaceString = getAddressSpaceString(); 00080 os << std::setw(13) << vmeSpaceString.c_str() << " "; 00081 if ( addressSpace_ == (AddressSpace)MEMORY) { 00082 os << std::setw(1) << std::hex << mapId_ << " "; 00083 } else { 00084 os << " "; 00085 } 00086 os << std::setw(2) << std::hex << std::setfill('0') << addressModifier_ << " " 00087 << std::setw(1) << std::dec << dataWidth_ << " " 00088 << std::setfill('0') << std::setw(8) << std::hex << address_ << " "; 00089 } 00090 00091 HAL::GeneralHardwareAddress* HAL::VME64xHardwareAddress::clone() const { 00092 return new VME64xHardwareAddress( *this ); 00093 }