39 virtual std::string
daeDevice()
const = 0;
42 template <
class DAECardPolicy>
80 void printRegister(
const char* name,
unsigned long address, std::ostream& os,
bool print_bits_set =
false);
83 static unsigned long makeAddress(
int position,
unsigned long address)
85 return DAECardPolicy::makeAddress(position, address);
97 static const char*
yesNoStr(
bool b) {
return (b ?
"yes" :
"no"); }
105 template <
typename T>
111 template <
typename T>
118 n = (len > chunk_len ? chunk_len : len);
119 stat =
readMemory(address, buffer, n, props, status);
120 address +=
sizeof(T) * n;
127 template <
typename T>
134 if (read_check_mask == 0)
139 T* read_buffer =
new T[len];
140 std::list<int> failed_elements;
142 stat =
m_vme->
readBlock(address, read_buffer, len, props, status);
145 if ( (buffer[i] & read_check_mask) != (read_buffer[i] & read_check_mask) )
147 failed_elements.push_back(i);
150 if (failed_elements.size() == 0)
152 delete[] read_buffer;
155 status.
addInfoVa(
FAC_DAE,
"DAE2Card::writeMemory: %d errors - retrying write of %d words to 0x%x (BT=%s,LE=%s,check_mask=0x%llx)",
156 failed_elements.size(), len, address,
yesNoStr(block_transfer),
yesNoStr(little_endian), read_check_mask);
158 std::list<int>::const_iterator iter = failed_elements.begin();
159 while(iter != failed_elements.end())
162 stat =
m_vme->
writeBlock(address + 4 * i, buffer + i, 1, props, status);
163 stat =
m_vme->
readBlock(address + 4 * i, read_buffer + i, 1, props, status);
164 if ( (buffer[i] & read_check_mask) == (read_buffer[i] & read_check_mask) )
170 status.
addInfoVa(
FAC_DAE,
"DAE2Card::writeMemory: retry failed to address 0x%x (write=0x%x, read=0x%x, mask=0x%llx)", address + 4 * i, buffer[i], read_buffer[i], read_check_mask);
174 delete[] read_buffer;
178 template <
typename T>
181 int l, buflen = 64*1024;
182 T* buffer =
new T[buflen];
183 memset(buffer, 0, buflen*
sizeof(T));
186 l = (len > buflen ? buflen : len);
187 writeMemory(start, buffer, l, read_check_mask, props, status);
188 start +=
sizeof(T) * l;
199 template <
class DAECardPolicy>
202 *value = (((*value) << 24) & 0xff000000) |
203 (((*value) << 8) & 0x00ff0000) |
204 (((*value) >> 8) & 0x0000ff00) |
205 (((*value) >> 24) & 0x000000ff);
208 template <
class DAECardPolicy>
211 *value = (((*value) & 0xff) << 8) | ((*value) >> 8);
214 template <
class DAECardPolicy>
uint32_t TransferProps
combination of TransferProp values
int enable(bool choice, isisU32_t mask, DAEstatus &status, bool little_endian=false)
DAE2Register(MyDAE2Card *card, isisU32_t address)
int readMemoryChunked(unsigned long address, T *buffer, int len, int chunk_len, ISISVME::TransferProps props, DAEstatus &status)
virtual int readBlock(unsigned long address, isisU32_t *data, long nitems, TransferProps props, DAEstatus &status)=0
void reverseEndian(isisU32_t *value)
virtual unsigned long makeAddress(unsigned long address)
int readRegister(const unused_t &address, isisU32_t *value, DAEstatus &status, bool little_endian=false, bool retry=true)
std::string getFirmwareVersionAsString(DAEstatus &status)
int setRegisterBits(unsigned long address, isisU32_t mask, bool preserve, DAEstatus &status, bool little_endian=false)
virtual int writeBlock(unsigned long address, isisU32_t *data, long nitems, TransferProps props, DAEstatus &status)=0
virtual std::string daeDevice() const =0
static CardType getCardType(int position, ISISVME *vme, DAEstatus &dstatus)
int setAndClearRegisterBits(const unused_t &address, isisU32_t mask, bool preserve, DAEstatus &status, bool little_endian=false)
bool registerBitsSet(unsigned long address, isisU32_t mask, DAEstatus &status, bool little_endian=false)
int clearRegisterBits(unsigned long address, isisU32_t mask, DAEstatus &status, bool little_endian=false)
virtual void printStatus(std::ostream &os, DAEstatus &dstatus)
std::string loggingPrefix() const
DAE2Card(int position, ISISVME *vme, DAEstatus &status)
int readMemory(unsigned long address, typename T *buffer, int len, ISISVME::TransferProps props, DAEstatus &status)
virtual int position() const =0
int setBits(isisU32_t mask, bool preserve, DAEstatus &status, bool little_endian=false)
isisU32_t read(DAEstatus &status, bool little_endian=false, bool retry=true)
int writeRegister(unsigned long address, isisU32_t value, DAEstatus &status, bool little_endian=false)
static bool isCardPresent(int position, ISISVME *vme, DAEstatus &status)
int readRegister(unsigned long address, isisU32_t *value, DAEstatus &status, bool little_endian=false, bool retry=true)
int setAndClearRegisterBits(unsigned long address, isisU32_t mask, bool preserve, DAEstatus &status, bool little_endian=false)
int clearBits(isisU32_t mask, DAEstatus &status, bool little_endian=false)
int writeRegister16(const unused_t &address, isisU16_t value, DAEstatus &status, bool little_endian=false)
std::string daeDevice() const
int changeRegisterBits(unsigned long address, isisU32_t mask, bool set, bool check, DAEstatus &status, bool little_endian=false)
static unsigned long makeAddress(int position, unsigned long address)
int writeMemory(unsigned long address, T *buffer, int len, uint64_t read_check_mask, ISISVME::TransferProps props, DAEstatus &status)
int writeRegister16(unsigned long address, isisU16_t value, DAEstatus &status, bool little_endian=false)
static int getFirmwareVersion(int position, ISISVME *vme, firmware_version *fw, DAEstatus &status)
int writeRegister32As16(unsigned long address0, unsigned long address1, isisU32_t value, DAEstatus &status, bool little_endian=false)
int readRegister16As32(unsigned long address0, unsigned long address1, isisU32_t *value, DAEstatus &status, bool little_endian=false)
virtual int resetCardState(DAEstatus &status)=0
static const char * yesNoStr(bool b)
int addInfoVa(int facility, const char *format,...)
int writeRegister(const unused_t &address, isisU32_t value, DAEstatus &status, bool little_endian=false)
DAE2Card< DAECardPolicy > MyDAE2Card
bool registerBitsClear(unsigned long address, isisU32_t mask, DAEstatus &status, bool little_endian=false)
int zeroMemory(unsigned long start, int len, uint64_t read_check_mask, ISISVME::TransferProps props, DAEstatus &status)
void printRegister(const char *name, unsigned long address, std::ostream &os, bool print_bits_set=false)