Generic hardware access library
|
00001 #ifndef __VME64xCrate 00002 #define __VME64xCrate 00003 00004 #include <vector> 00005 #include <functional> 00006 00007 #include "hal/VMEDevice.hh" 00008 #include "hal/VMEBusAdapterInterface.hh" 00009 #include "hal/AddressTableContainerInterface.hh" 00010 #include "hal/StaticVMEConfiguration.hh" 00011 #include "hal/ModuleMapperInterface.hh" 00012 #include "hal/VMEConfigurationSpaceHandler.hh" 00013 #include "hal/VMESlot.hh" 00014 #include "hal/HardwareProblemException.hh" 00015 #include "hal/UnsupportedException.hh" 00016 00017 namespace HAL { 00018 00038 class VME64xCrate { 00039 public: 00040 00041 VME64xCrate( VMEBusAdapterInterface& busAdapter, 00042 AddressTableContainerInterface& addressTables, 00043 ModuleMapperInterface& moduleMapper ) 00044 throw( HardwareProblemException, 00045 IllegalValueException, 00046 UnsupportedException ); 00047 00048 00062 VME64xCrate( VMEBusAdapterInterface& busAdapter, 00063 AddressTableContainerInterface& addressTableContainer, 00064 ModuleMapperInterface& moduleMapper, 00065 const StaticVMEConfiguration& staticConfiguration ) 00066 throw( HardwareProblemException, 00067 IllegalValueException, 00068 UnsupportedException ); 00069 00080 VMEDevice* getVMEDevice( uint32_t slotId ) const 00081 throw ( IllegalOperationException, 00082 IllegalValueException, 00083 UnsupportedException, 00084 BusAdapterException, 00085 NoSuchItemException ); 00086 00098 VMESlot* getVMESlot( uint32_t slotId ) const 00099 throw( IllegalValueException ); 00100 00104 void printAddressMap( std::ostream& out ) const; 00105 00106 00107 00108 private: 00113 struct MappedItem { 00114 uint32_t startAddress; 00115 uint32_t endAddress; 00116 uint32_t baseAddress; 00117 uint32_t AM; 00118 VME64xMappedWindow* windowPtr; 00119 bool configured; 00120 }; 00121 00127 class MappedItemSorter { 00128 public: 00129 bool operator()( const struct MappedItem* x, const struct MappedItem* y ) const { 00130 return( x->baseAddress > y->baseAddress ); 00131 } 00132 }; 00133 00138 class WindowSorter { 00139 public: 00140 bool operator() ( const VME64xMappedWindow* x, 00141 const VME64xMappedWindow* y) const { 00142 return ( x->getAddressRank() < y->getAddressRank() ); 00143 } 00144 }; 00145 00149 void configurePlugAndPlay() throw( IllegalValueException, 00150 UnsupportedException ); 00156 void populateWithStaticConfiguration( const StaticVMEConfiguration& staticConfiguration ) 00157 throw( IllegalValueException ); 00158 00165 void populateWithPlugAndPlay() throw( IllegalValueException, 00166 UnsupportedException ); 00167 00174 void getAllWindows(); 00175 00179 void mapCrate(); 00180 00194 void mapWindow( VME64xMappedWindow* windowPtr, 00195 uint32_t maxAddress, 00196 uint32_t baseMin ); 00197 00201 bool isOccupied( uint32_t base, uint32_t space, bool bit33 ); 00202 00209 void makeOccupiedList(); 00210 00214 void enablePlugAndPlayModules() throw ( IllegalOperationException ); 00215 00216 bool mapped_; 00217 VMEBusAdapterInterface& busAdapter_; 00218 AddressTableContainerInterface& addressTableContainer_; 00219 ModuleMapperInterface& moduleMapper_; 00220 VMEConfigurationSpaceHandler vmeConfigSpaceHandler_; 00221 std::vector< VMESlot* > slotPtrVector_; 00222 std::list < struct MappedItem * > occupiedItemList_; 00223 std::list < VME64xMappedWindow * > windowList_; 00224 std::list < const VME64xMappedWindow * > notMappedList_; 00225 }; 00226 00227 } /* namespace HAL */ 00228 00229 #endif /* __VME64xCrate */ 00230