Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages

DummyVmeInterface.cxx

00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 // 20/02/2002  V 1.0 PM - First implementation
00009 // 19/02/2004  V 1.2 PM - Safe single word R/W methods added            
00010 //
00011 
00012 #include <signal.h>
00013 #include <sys/types.h>
00014 
00015 #include "DummyVmeInterface.h"
00016 
00017 using namespace SctPixelRod;
00018 
00019 unsigned char  DummyVmeInterface::m_softVectMask;             
00020 long DummyVmeInterface::m_interruptData = 0;
00021 DummyVmeInterface *DummyVmeInterface::m_if = NULL;
00022 std::vector<VmeInterruptHandler *>  DummyVmeInterface::m_hardIH;   
00023 std::vector<VmeInterruptHandler *>  DummyVmeInterface::m_softIH[32];  
00024                                                         
00025 void DummyVmeInterface::m_interruptHandler(int signum) {
00026   static int is, smask;
00027   static unsigned int i;
00028 
00029   // Execute hard handlers
00030   m_softVectMask = 0;
00031   m_if->m_interruptData = 0;
00032   for (i=0; i<m_hardIH.size(); i++) {
00033     if (m_hardIH[i]->getActive()) {
00034       m_hardIH[i]->interruptHandler(0, 0, 0);
00035     }
00036   }
00037 
00038   // Execute soft handlers
00039   smask = m_softVectMask;
00040   for (is=0; is<32; is++) {
00041     if ((smask & (1 << is)) != 0) { 
00042       for (i=0; i<m_softIH[is].size(); i++) {
00043         if (m_softIH[is][i]->getActive()) {
00044           m_softIH[is][i]->interruptHandler(0, is, 0);
00045     }
00046       }
00047     }
00048   }
00049 }
00050 
00051 DummyVmeInterface::DummyVmeInterface() {
00052   int ret;
00053   // Install the global interrupt handler
00054   struct sigaction sa;
00055   sigemptyset(&sa.sa_mask); 
00056   sa.sa_flags = 0;
00057   sa.sa_handler = m_interruptHandler; 
00058   ret = sigaction(SIGRTMAX-1, &sa, NULL);
00059   // Pepare the mask for blocking interrupt handlers
00060   sigemptyset(&m_sigMask);
00061   sigaddset(&m_sigMask, SIGRTMAX-1);
00062   // Set the pointer to this object
00063   m_if = this;
00064 };
00065 
00066 DummyVmeInterface::~DummyVmeInterface() {
00067 };
00068 
00069 void DummyVmeInterface::declareInterruptHandler(VmeInterruptHandler &handler) {
00070   unsigned char softvec = handler.getInterruptSoftVect();
00071   if (softvec == 0) {   
00072     // Hard IH definition
00073     unsigned int i;
00074     for (i=0; i<m_hardIH.size(); i++) {
00075       if (&handler == m_hardIH[i]) return;
00076     }
00077     m_hardIH.push_back(&handler);
00078   } else if (softvec > 0 && softvec <= 32) {
00079     // Soft IH definition
00080     unsigned int i;
00081     for (i=0; i<m_softIH[softvec-1].size(); i++) {
00082       if (&handler == m_softIH[softvec-1][i]) return;
00083     }
00084     m_softIH[softvec-1].push_back(&handler);
00085   }
00086 }
00087 
00088 void DummyVmeInterface::removeInterruptHandler(VmeInterruptHandler &handler) {
00089   char softvec = handler.getInterruptSoftVect();
00090   std::vector<VmeInterruptHandler *>::iterator i;
00091   if (softvec == 0) {   
00092     // Basic IH cancellation
00093     for (i=m_hardIH.begin(); i != m_hardIH.end(); i++) {
00094       if (&handler == *i) {
00095         m_hardIH.erase(i);
00096         break;
00097       }
00098     }
00099   } else if (softvec > 0 && softvec <= 32) {
00100     // Slave IH cancellation
00101     for (i=m_softIH[softvec-1].begin(); i != m_softIH[softvec-1].end(); i++) {
00102       if (&handler == *i) {
00103         m_softIH[softvec-1].erase(i);
00104         return;
00105       }
00106     }
00107   }  
00108 }
00109 
00110 void DummyVmeInterface::cleanInterruptHandlers() {
00111 }
00112 
00113 void DummyVmeInterface::blockInterruptNotification() {
00114   sigprocmask(SIG_BLOCK, &m_sigMask, NULL);
00115 } 
00116 
00117 void DummyVmeInterface::resumeInterruptNotification() {
00118   sigprocmask(SIG_UNBLOCK, &m_sigMask, NULL);
00119 }
00120 
00121 unsigned char DummyVmeInterface::read8  (const unsigned long handle, const unsigned long offset) {
00122   return 0;
00123 }  
00124 
00125 unsigned char DummyVmeInterface::readS8  (const unsigned long handle, const unsigned long offset) {
00126   return 0;
00127 }  
00128 
00129 unsigned short DummyVmeInterface::read16 (const unsigned long handle, const unsigned long offset) {
00130   return 0;
00131 }
00132 
00133 unsigned short DummyVmeInterface::readS16 (const unsigned long handle, const unsigned long offset) {
00134   return 0;
00135 }
00136 
00137 unsigned long DummyVmeInterface::read32 (const unsigned long handle, const unsigned long offset) {
00138   return 0;
00139 }
00140 
00141 unsigned long DummyVmeInterface::readS32 (const unsigned long handle, const unsigned long offset) {
00142   return 0;
00143 }
00144 
00145 void DummyVmeInterface::write8 (const unsigned long handle, const unsigned long offset, const unsigned char value) {
00146 }  
00147 
00148 void DummyVmeInterface::writeS8 (const unsigned long handle, const unsigned long offset, const unsigned char value) {
00149 }  
00150 
00151 void DummyVmeInterface::write16(const unsigned long handle, const unsigned long offset, const unsigned short value) {
00152 }    
00153 
00154 void DummyVmeInterface::writeS16(const unsigned long handle, const unsigned long offset, const unsigned short value) {
00155 }    
00156 
00157 void DummyVmeInterface::write32(const unsigned long handle, const unsigned long offset, const unsigned long value) {
00158 }   
00159 
00160 void DummyVmeInterface::writeS32(const unsigned long handle, const unsigned long offset, const unsigned long value) {
00161 }   
00162 
00163 void DummyVmeInterface::blockRead32 (VmePort &port, const unsigned long offset, unsigned long *buf, const long len) {
00164 } 
00165 
00166 void DummyVmeInterface::blockRead64 (VmePort &port, const unsigned long offset, unsigned long *buf, const long len) {
00167 }
00168 
00169 void DummyVmeInterface::blockWrite32(VmePort &port, const unsigned long offset, const unsigned long *buf, const long len) {
00170 }  
00171 
00172 void DummyVmeInterface::blockWrite64(VmePort &port, const unsigned long offset, const unsigned long *buf, const long len) {
00173 }   
00174 
00175 unsigned long DummyVmeInterface::registerPort(VmePort &port) {
00176   unsigned int ip;
00177  
00178   for (ip=0; ip<m_ports.size(); ip++) {
00179     if (m_ports[ip] == NULL) {
00180       m_ports[ip] = &port;
00181       return ip;
00182     }
00183   }
00184   m_ports.push_back(&port);
00185   return m_ports.size()-1;
00186 }         
00187 
00188 void DummyVmeInterface::deletePort(VmePort &port) {
00189   unsigned int ip;
00190 
00191   for (ip=0; ip<m_ports.size(); ip++) {
00192     if (m_ports[ip] == &port) {
00193       m_ports[ip] = NULL;
00194     }
00195   }
00196 }
00197 
00198 void *DummyVmeInterface::getPortMap(const unsigned long handle) {
00199   return NULL;
00200 }
00201   
00202 void DummyVmeInterface::busErrorReport() { 
00203 }
00204 
00205 void DummyVmeInterface::busErrorReport(const unsigned long handle) {
00206 }
00207 
00208 void DummyVmeInterface::busErrorReport(VmePort &port) {
00209 }
00210 
00211 std::string DummyVmeInterface::getErrorMessage(const long errcod) {
00212   return "";
00213 }
00214 
00215 long DummyVmeInterface::getBusErrors() {
00216   return 0;
00217 }

Generated on Thu Dec 22 20:17:00 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5