Library of Bus-Adapters
/home/cschwick/hal/busAdapter/dummy/src/common/VME64xDummyBusAdapter.cc
Go to the documentation of this file.
00001 #include "hal/VME64xDummyBusAdapter.hh"
00002 #include <iomanip>
00003 #include <fstream>
00004 #include <string.h>
00005 
00006 // dirty but ok...:
00007 typedef unsigned short U16;
00008 typedef uint32_t U32;
00009 
00010 HAL::VME64xDummyBusAdapter::VME64xDummyBusAdapter( std::string configSpaceDefinitionFile,
00011                                                    enum VerboseMode verbose, 
00012                                                    enum MemoryMode  memoryMode,
00013                                                    std::ostream& os )
00014     throw ( IllegalValueException,
00015             NoSuchFileException )
00016     : os_(os) {
00017     deviceNumberCounter = 0;
00018     this->verbose = verbose;
00019     this->memoryMode = memoryMode;
00020     os_  << "VME64xDummyBusAdapter : constructor has been called :\n" 
00021          << "                     The \"verbose\" flag is set to " << (int)verbose << "\n"
00022          << "                     The \"memoryMode\" flag is set to " << (int)memoryMode  
00023          << std::endl;
00024 
00025     for( int i = 0; i <= ( VME64x_AMNESIA_SLOT > MAX_NUMBER_OF_SLOTS ? VME64x_AMNESIA_SLOT : MAX_NUMBER_OF_SLOTS); i++ ) {
00026         configSpaceVector_.push_back( (std::map< uint32_t, uint32_t >*) 0 );
00027     }
00028 
00029 
00030     const int MaxLength=1024;
00031     char buffer[MaxLength];
00032     std::ifstream FileStream( configSpaceDefinitionFile.c_str() );
00033     if ( FileStream.fail() ) {
00034         std::string text = "Cannot open file : " + configSpaceDefinitionFile + "    (HAL::VME64xDummyBusAdapter::VME64xDummyBusAdapter)";
00035         throw (NoSuchFileException( text, __FILE__, __LINE__, __FUNCTION__ ));
00036     }
00037 
00038     // prepare the loop over all lines of the ascii file:
00039     uint32_t slotId;
00040     std::string fileName;
00041     while ( ! FileStream.eof() ) {
00042         FileStream.getline(buffer, MaxLength);
00043         if ( FileStream.eof() ) break;
00044         //skip all white space at beginning of buffer:
00045         int ic = 0;
00046         while ( buffer[ic] == ' ' ||
00047                 buffer[ic] == '\t' ) {
00048             ic++;
00049         }
00050         if (buffer[ic] == '#') continue; // a comment
00051         if (buffer[ic] == '\n') continue; // should never happen since \n is not extracted with getline
00052         if (buffer[ic] == 0x00) continue;
00053 
00054         std::istringstream Line(buffer);    
00055         Line >> std::dec >> slotId;
00056         Line >> fileName;
00057 
00058         if ( slotId >= MAX_NUMBER_OF_SLOTS && slotId != VME64x_AMNESIA_SLOT ) {
00059             std::stringstream text;
00060             text << "Illegal slot number : " << slotId
00061                  << "\n    (HAL::VME64xDummyBusAdapter::VME64xDummyBusAdapter)" << std::ends;
00062             throw( IllegalValueException( text.str(), __FILE__, __LINE__, __FUNCTION__ ) );
00063         }
00064     
00065         HAL::ConfigurationSpaceFileReader reader( fileName );
00066         std::map<uint32_t, uint32_t>* mapPtr = reader.getDataMapPtr();
00067         configSpaceVector_[ slotId ] = mapPtr;
00068     }
00069     FileStream.close();
00070 }
00071 
00072 HAL::VME64xDummyBusAdapter::~VME64xDummyBusAdapter() {
00073     for( int i = 0; i < MAX_NUMBER_OF_SLOTS; i++ ) {
00074         if( configSpaceVector_[i] ) {
00075             delete configSpaceVector_[i];
00076         }
00077     }
00078     if ( configSpaceVector_[VME64x_AMNESIA_SLOT] ) {
00079         os_ << "deleting Amnesia " <<std::dec <<  VME64x_AMNESIA_SLOT<< std::endl;
00080         os_ << std::hex << configSpaceVector_[VME64x_AMNESIA_SLOT] << std::endl;
00081         delete configSpaceVector_[VME64x_AMNESIA_SLOT];
00082     }
00083 }
00084 
00085 void
00086 HAL::VME64xDummyBusAdapter::openDevice( const VMEAddressTable& vmeAddressTable,
00087                                         uint32_t vmeBaseaddress,
00088                                         DeviceIdentifier** deviceIdentifierPtr,
00089                                         uint32_t* baseAddressPtr,
00090                                         bool doSwapping ) 
00091     throw() {
00092     std::vector<char *> memoryRegions(NUMBER_OF_VME64XFUNCTIONS);
00093     for ( int i=0; i<NUMBER_OF_VME64XFUNCTIONS; i++ ) memoryRegions.push_back( (char*) 0 );
00094 
00095     uint32_t ic;
00096     os_  << "VME64xDummyBusAdapter : opening Device number "<< deviceNumberCounter 
00097          << " with baseAddress : " 
00098          << std::hex << std::setw(8) << std::setfill('0') << vmeBaseaddress
00099          << "\n                     memory-mapping-mode : "
00100          << (int)this->memoryMode 
00101          << std::endl;
00102 
00103     std::vector<uint32_t> minAddresses(NUMBER_OF_VME64XFUNCTIONS); 
00104     std::vector<uint32_t> maxAddresses(NUMBER_OF_VME64XFUNCTIONS);
00105     std::vector<uint32_t> baseAddresses(NUMBER_OF_VME64XFUNCTIONS);
00106     std::vector<uint32_t> mapSizes(NUMBER_OF_VME64XFUNCTIONS); 
00107 
00108     for ( int i=0; i<NUMBER_OF_VME64XFUNCTIONS; i++ ) {
00109       minAddresses[i] = 0;
00110       maxAddresses[i] = 0;
00111       baseAddresses[i] = 0;
00112       mapSizes[i] = 0;
00113     }
00114 
00115     // If memory mapping is on we have to do some mapping into the memory of the PC.
00116     // The size of pointers in the PC is in general not equal to the size of vme addresses.
00117     // Therefore we need to maintain this mapping in the deviceIdentifier and hidden from 
00118     // the rest of the HAL operations. 
00119     if ( memoryMode == MEMORY_MAP_ON ) {
00120 
00121         vmeAddressTable.getAddressBoundaries( minAddresses, maxAddresses );
00122 
00123         *baseAddressPtr = vmeBaseaddress;
00124 
00125         uint32_t nbytes = maxAddresses[0] + 1;
00126 
00127         memoryRegions[0] = new char[ nbytes ];
00128         baseAddresses[0] = vmeBaseaddress;
00129         mapSizes[0]      = nbytes;
00130 
00131         for (ic=0; ic<=nbytes; ic++) memoryRegions[0][ic] = (char)0x00;
00132 
00133         
00134         os_  << "                     mapped the address space to memory address " 
00135              << std::hex << (memoryRegions[0]) 
00136              << "\n                     reserved 0x" << std::hex << nbytes 
00137              << " (dec: " << std::dec << nbytes << " )" 
00138              << " bytes for memory mapped operation" << std::endl; 
00139     } else {
00140         *baseAddressPtr = vmeBaseaddress;
00141     }
00142 
00143     *deviceIdentifierPtr = new HAL::VMEDummyDeviceIdentifier( deviceNumberCounter,
00144                                                               memoryRegions,
00145                                                               baseAddresses,
00146                                                               mapSizes,
00147                                                               doSwapping);
00148     deviceNumberCounter++;
00149 }
00150 
00151 // the call for VME64x modules
00152 void
00153 HAL::VME64xDummyBusAdapter::openDevice( const VMEAddressTable& vmeAddressTable,
00154                                         std::vector<uint32_t> vmeBaseaddresses,
00155                                         DeviceIdentifier** deviceIdentifierPtr,
00156                                         std::vector<uint32_t>* baseAddressPtr,
00157                                         bool doSwapping ) 
00158     throw() {
00159     std::vector<char *> memoryRegions(NUMBER_OF_VME64XFUNCTIONS);
00160     for ( int i=0; i<NUMBER_OF_VME64XFUNCTIONS; i++ ) memoryRegions.push_back( (char*) 0 );
00161 
00162     uint32_t ic;
00163     os_  << "VME64xDummyBusAdapter : opening VME64x Device number "<< deviceNumberCounter 
00164          << "\n                     memory-mapping-mode : "
00165          << (int)this->memoryMode 
00166          << std::endl;
00167   
00168     std::vector<uint32_t> minAddresses(NUMBER_OF_VME64XFUNCTIONS); 
00169     std::vector<uint32_t> maxAddresses(NUMBER_OF_VME64XFUNCTIONS);
00170     std::vector<uint32_t> baseAddresses(NUMBER_OF_VME64XFUNCTIONS);
00171     std::vector<uint32_t> mapSizes(NUMBER_OF_VME64XFUNCTIONS);
00172 
00173     for ( int i=0; i<NUMBER_OF_VME64XFUNCTIONS; i++ ) {
00174       minAddresses[i] = 0;
00175       maxAddresses[i] = 0;
00176       baseAddresses[i] = 0;
00177       mapSizes[i] = 0;
00178     }
00179   
00180     if ( memoryMode == MEMORY_MAP_ON ) {
00181 
00182         vmeAddressTable.getAddressBoundaries( minAddresses, maxAddresses );
00183 
00184         for ( int ifunc=0; ifunc<NUMBER_OF_VME64XFUNCTIONS; ifunc++ ) {
00185 
00186             if ( maxAddresses[ifunc] > 0 ) {
00187 
00188                 (*baseAddressPtr)[ifunc] = vmeBaseaddresses[ifunc];
00189                 
00190                 uint32_t nbytes = maxAddresses[ifunc] + 1;
00191                 
00192                 memoryRegions[ifunc] = new char[ nbytes ];
00193                 baseAddresses[ifunc] = vmeBaseaddresses[ifunc];
00194                 mapSizes[ifunc]      = nbytes;
00195 
00196                 for (ic=0; ic<=maxAddresses[ifunc]; ic++) memoryRegions[ifunc][ic] = (char)0x00;
00197 
00198                 os_  << "                     mapped the address space of function" << ifunc 
00199                      << " to memory address " << std::hex << memoryRegions[ifunc] 
00200                      << "\n                     reserved 0x" << std::hex << nbytes
00201                      << " (dec: " << std::dec << nbytes << " )" 
00202                      << " bytes for memory mapped operation" << std::endl;
00203             } 
00204         }
00205 
00206     } else {
00207 
00208         for ( int ifunc=0; ifunc<NUMBER_OF_VME64XFUNCTIONS; ifunc++ ) {
00209             (*baseAddressPtr)[ifunc] = vmeBaseaddresses[ifunc];
00210 
00211         }
00212     }
00213   
00214     *deviceIdentifierPtr = new HAL::VMEDummyDeviceIdentifier( deviceNumberCounter,
00215                                                               memoryRegions,
00216                                                               baseAddresses,
00217                                                               mapSizes,
00218                                                               doSwapping );
00219     deviceNumberCounter++;
00220 }
00221 
00222 void
00223 HAL::VME64xDummyBusAdapter::closeDevice( DeviceIdentifier* vmeDevice ) 
00224     throw() {
00225     os_  << "VME64xDummyBusAdapter : closing Device => " << vmeDevice->printString() << std::endl;
00226     delete( vmeDevice );
00227 }
00228 
00229 void HAL::VME64xDummyBusAdapter::checkConfigAccess(uint32_t address, 
00230                                                    uint32_t dataWidth, 
00231                                                    uint32_t slotId, 
00232                                                    uint32_t byte )
00233     throw (BusAdapterException) {
00234     if ( ! configSpaceVector_[slotId] ) {
00235         std::stringstream text;
00236         text << "No module in slot number " << std::dec << slotId
00237              << "\n    (HAL::VME64xDummyBusAdapter::read)" << std::ends;
00238         throw( BusAdapterException( text.str(), __FILE__, __LINE__, __FUNCTION__ ) );
00239     }
00240     if ( ((( 1 << (dataWidth - 1)) - 1) & byte) != 0 ) {
00241         std::stringstream text;
00242         text << "ERROR: try to do an unaligned access:\n"
00243              << "    address : " << std::hex << address 
00244              << "  datawidth : " << std::dec << dataWidth
00245              << "       slot : " << std::dec << slotId
00246              << "\n    (HAL::VME64xDummyBusAdapter::read)" << std::ends;
00247         throw( BusAdapterException( text.str(), __FILE__, __LINE__, __FUNCTION__ ) );
00248     }
00249   
00250 }
00251 
00252 void
00253 HAL::VME64xDummyBusAdapter::read( DeviceIdentifier* vmeDevice, 
00254                                   uint32_t address,
00255                                   uint32_t addressModifier,
00256                                   uint32_t dataWidth,
00257                                   uint32_t *resultPtr ) 
00258     throw(BusAdapterException) {
00259 
00260     if ( addressModifier == 0x2f ) {
00261         uint32_t slotId = (address/VME64X_CONFIGURATIONSPACE_SIZE);
00262         uint32_t mapAddress = (~0x3)&(address % VME64X_CONFIGURATIONSPACE_SIZE);
00263         int byte = 0x3 & address;
00264         checkConfigAccess( mapAddress, dataWidth, slotId, byte); // simulate a busadapterexception if no config space in slot
00265         uint32_t readData;
00266         if ( (*configSpaceVector_[slotId]).find(mapAddress) != (*configSpaceVector_[slotId]).end() ) {
00267             readData = (*configSpaceVector_[slotId])[mapAddress];
00268         } else { 
00269             readData = 0;
00270         }
00271         uint32_t result = readData >> (8*byte);
00272         if ( dataWidth == 1 ) {
00273             result = result & 0xff;
00274         } else if( dataWidth == 2 ) {
00275             result = result & 0xffff;
00276         } else if( dataWidth == 3 ) {
00277             result = result & 0xffffff;
00278         }
00279 
00280         *resultPtr = result;
00281 
00282         // normal access
00283 
00284     } else {
00285         *resultPtr = 0;
00286         if ( memoryMode == MEMORY_MAP_ON ) {
00287 
00288             char *memoryAddress = dynamic_cast<HAL::VMEDummyDeviceIdentifier*>(vmeDevice)->remap( address );
00289 
00290             memcpy( resultPtr, memoryAddress, dataWidth);
00291 
00292             bool doSwapping = dynamic_cast<HAL::VMEDummyDeviceIdentifier*>(vmeDevice)->doSwapping();
00293             
00294             if ( dataWidth > 1 && doSwapping ) {
00295                 *resultPtr = doSwap( *resultPtr, dataWidth );
00296             }
00297 
00298         }
00299     }
00300 
00301     if ( verbose == VERBOSE_ON ) {
00302         os_  << std::endl;
00303         os_  << "VME64xDummyBusAdapter : read from Device number " << vmeDevice->printString() << std::endl;
00304         os_  << "                     address : " << std::hex << std::setw(8) << std::setfill('0') << address << std::endl;
00305         os_  << "                          AM :       " << std::hex << std::setw(2) << std::setfill('0') << addressModifier << std::endl;
00306         os_  << "                   dataWidth : " << std::dec << std::setw(8) << std::setfill(' ') << dataWidth << std::endl;
00307         os_  << "                   returning : 0x" << std::hex << std::setw(8) << std::setfill('0') << *resultPtr 
00308              << " (dec) " << std::dec << *resultPtr << std::endl;
00309         os_  << std::endl;
00310     }
00311 }
00312 
00313 void
00314 HAL::VME64xDummyBusAdapter::write( DeviceIdentifier* vmeDevice, 
00315                               uint32_t address, 
00316                               uint32_t addressModifier,
00317                               uint32_t dataWidth,
00318                               uint32_t data) 
00319     throw(BusAdapterException) {
00320 
00321     bool doSwapping = dynamic_cast<HAL::VMEDummyDeviceIdentifier*>(vmeDevice)->doSwapping();
00322     
00323     if ( dataWidth > 1 && doSwapping && addressModifier != 0x2f ) {
00324         data = doSwap( data, dataWidth );
00325     }
00326     
00327     if ( verbose == VERBOSE_ON ) {
00328         os_  << std::endl;
00329         os_  << "VME64xDummyBusAdapter : write to Device number " << vmeDevice->printString() << std::endl;
00330         os_  << "                     address : " << std::hex << std::setw(8) << std::setfill('0') << address << std::endl;
00331         os_  << "                          AM :       " << std::hex << std::setw(2) << std::setfill(' ') << addressModifier << std::endl;
00332         os_  << "                   dataWidth : " << std::dec << std::setw(8) << std::setfill(' ') << dataWidth << std::endl;
00333         os_  << "                   dataValue : 0x" << std::hex << std::setw(8) << std::setfill('0') << data 
00334              << " (dec) " << std::dec << data << std::endl;
00335         os_  << std::endl;
00336     }
00337 
00338     if ( addressModifier == 0x2f ) {
00339         uint32_t slotId = (address/VME64X_CONFIGURATIONSPACE_SIZE);
00340         int byte = 0x3 & address;
00341         uint32_t mapAddress = (~0x3)&(address % VME64X_CONFIGURATIONSPACE_SIZE);
00342         checkConfigAccess( mapAddress, dataWidth, slotId, byte); 
00343         uint32_t writeData = data << (8*byte);
00344     
00345         (*(configSpaceVector_[slotId]))[mapAddress] = writeData;
00346     } else if ( memoryMode == MEMORY_MAP_ON ) {
00347 
00348        char *memoryAddress = dynamic_cast<HAL::VMEDummyDeviceIdentifier*>(vmeDevice)->remap( address );
00349        memcpy( memoryAddress, &data, dataWidth);
00350 
00351     }
00352   
00353 }
00354 
00355 void
00356 HAL::VME64xDummyBusAdapter::resetBus( ) 
00357     throw() {
00358     if ( verbose == VERBOSE_ON ) {
00359         os_  << std::endl;
00360         os_  << "VME64xDummyBusAdapter : resetting bus" << std::endl;
00361         os_  << std::endl;
00362     }
00363 }
00364 
00365 void
00366 HAL::VME64xDummyBusAdapter::readBlock( DeviceIdentifier *vmeDevice,
00367                                   uint32_t startAddress,
00368                                   uint32_t length,      // in bytes
00369                                   uint32_t addressModifier,
00370                                   uint32_t dataWidth,
00371                                   char *buffer,
00372                                   HalAddressIncrement addressBehaviour ) 
00373     throw() {
00374 
00375     if ( memoryMode == MEMORY_MAP_ON ) {
00376         char *memoryAddress = dynamic_cast<HAL::VMEDummyDeviceIdentifier*>(vmeDevice)->remap( startAddress );
00377         if ( addressBehaviour == HAL_DO_INCREMENT ) {
00378             memcpy( buffer, memoryAddress, length);
00379         } else {
00380             os_  << "HAL::VME64xDummyBusAdapter::readBlock : No Fifo functionality in VME64xDummyBusAdapter. Doing nothing!" << std::endl;
00381         }
00382         // check if data needs to be swapped and swap it
00383         bool doSwapping = dynamic_cast<HAL::VMEDummyDeviceIdentifier*>(vmeDevice)->doSwapping();
00384         
00385         if ( dataWidth > 1 && doSwapping ) {
00386             if ( dataWidth == 2 ) {
00387                 for ( U16* ptr = (U16*)buffer;  (uint8_t*)ptr <  (uint8_t*)buffer + length; ptr++ ) {
00388                     *ptr = doSwap( *ptr, dataWidth );
00389                 }
00390             } else if ( dataWidth == 4 ) {
00391                 for ( U32* ptr = (U32*)buffer;  (uint8_t*)ptr <  (uint8_t*)buffer + length; ptr++ ) {
00392                     *ptr = doSwap( *ptr, dataWidth );
00393                 }
00394             } else {
00395                 os_ << "HAL Software bug: dataWidth " << std::dec << dataWidth << "is illegal!" << std::endl;
00396             }
00397         }
00398 
00399     }
00400 
00401     if( verbose == VERBOSE_ON ) {
00402         os_  << std::endl;
00403         os_  << "VME64xDummyBusAdapter : readBlock from Device \n                     " << vmeDevice->printString() << std::endl;
00404         os_  << "                startaddress (hex) : " << std::hex << std::setw(8) << std::setfill('0') << startAddress << std::endl;
00405         os_  << "                      length (hex) : " << std::hex << std::setw(8) << std::setfill('0') << length << std::endl;
00406         os_  << "                          AM (hex) :       " << std::hex << std::setw(2) << std::setfill('0') << addressModifier << std::endl;
00407         os_  << "                         dataWidth : " << std::dec << std::setw(8) << std::setfill(' ') << dataWidth << std::endl;
00408         os_  << "                  addressBehaviour : ";
00409         if ( addressBehaviour == HAL_DO_INCREMENT ) {
00410             os_  << "HAL_DO_INCREMENT" << std::endl;
00411         } else if ( addressBehaviour == HAL_NO_INCREMENT ) {
00412             os_  << "HAL_NO_INCREMENT" << std::endl;
00413         } else { // should never happen
00414             os_  << "XXXXX this should never happen XXXXXXX" << std::endl;
00415         }
00416         os_  << "       pointer to readbuffer (hex) : " << std::hex << std::setw(8) << std::setfill('0') << buffer << std::endl;
00417         os_  << std::endl;
00418     }
00419 }
00420   
00421 void
00422 HAL::VME64xDummyBusAdapter::writeBlock( DeviceIdentifier* vmeDevice,
00423                                         uint32_t startAddress,
00424                                         uint32_t length,      // in bytes
00425                                         uint32_t addressModifier,
00426                                         uint32_t dataWidth,
00427                                         char *buffer,
00428                                         HalAddressIncrement addressBehaviour ) 
00429     throw() {
00430   
00431 
00432     if ( memoryMode == MEMORY_MAP_ON ) {
00433 
00434         // check if data needs to be swapped and swap it
00435         bool doSwapping = dynamic_cast<HAL::VMEDummyDeviceIdentifier*>(vmeDevice)->doSwapping();
00436         char* buffercpy = new char[length];
00437         memcpy( buffercpy, buffer, length );
00438 
00439         if ( dataWidth > 1 && doSwapping ) {
00440             if ( dataWidth == 2 ) {
00441                 for ( U16* ptr = (U16*)buffercpy; (uint8_t*) ptr < (uint8_t*) buffercpy + length; ptr++ ) {
00442                     *ptr = doSwap( *ptr, dataWidth );
00443                 }
00444             } else if ( dataWidth == 4 ) {
00445                 for ( U32* ptr = (U32*)buffercpy; (uint8_t*) ptr < (uint8_t*) buffercpy + length; ptr++ ) {
00446                     *ptr = doSwap( *ptr, dataWidth );
00447                 }
00448             } else {
00449                 os_ << "HAL Software bug: dataWidth " << std::dec << dataWidth << "is illegal!" << std::endl;
00450             }
00451         }
00452         
00453         char *memoryAddress = dynamic_cast<HAL::VMEDummyDeviceIdentifier*>(vmeDevice)->remap( startAddress );
00454 
00455         if ( addressBehaviour == HAL_DO_INCREMENT ) {
00456             memcpy( memoryAddress, buffercpy, length);
00457         } else {
00458             os_  << "HAL::VME64xDummyBusAdapter::writeBlock : No Fifo functionality in VME64xDummyBusAdapter. Doing nothing!" << std::endl;
00459         }
00460 
00461         delete buffercpy;
00462 
00463     }
00464 
00465     if ( verbose == VERBOSE_ON ) {
00466         os_  << std::endl;
00467         os_  << "VME64xDummyBusAdapter : writeBlock to Device \n                     " << vmeDevice->printString() << std::endl;
00468         os_  << "                startaddress (hex) : " << std::hex << std::setw(8) << std::setfill('0') << startAddress << std::endl;
00469         os_  << "                      length (hex) : " << std::hex << std::setw(8) << std::setfill('0') << length << std::endl;
00470         os_  << "                          AM (hex) :       " << std::hex << std::setw(2) <<std:: setfill('0') << addressModifier << std::endl;
00471         os_  << "                         dataWidth : " << std::dec << std::setw(8) << std::setfill(' ') << dataWidth << std::endl;
00472         os_  << "                  addressBehaviour : ";
00473         if ( addressBehaviour == HAL_DO_INCREMENT ) {
00474             os_  << "HAL_DO_INCREMENT" << std::endl;
00475         } else if ( addressBehaviour == HAL_NO_INCREMENT ) {
00476             os_  << "HAL_NO_INCREMENT" << std::endl;
00477         } else { // should never happen
00478             os_  << "XXXXXX this should never happen XXXXXX" << std::endl;
00479         }
00480         os_  << "     pointer to sourcebuffer (hex) : " << std::hex << std::setw(8) << std::setfill('0') << buffer << std::endl;
00481         os_  << std::endl;
00482     }
00483 }
00484 
00485 uint32_t HAL::VME64xDummyBusAdapter::doSwap( uint32_t data, uint32_t dataWidth ) const {
00486     uint32_t result = 0;
00487     if ( dataWidth == 2 ) {
00488         result = ((data & 0xff) << 8) +
00489             ((data & 0xff00) >> 8);
00490 
00491     } else if ( dataWidth == 4 ) {
00492         result = ((data & 0xff) << 24) +
00493             ((data & 0xff00) << 8 ) +
00494             ((data & 0xff0000) >> 8) +
00495             ((data & 0xff000000) >> 24);
00496     } else {
00497         os_ << "HAL Software bug: dataWidth " << std::dec << dataWidth << "is illegal!" << std::endl;
00498     }  
00499     return result;
00500 }