-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwtip.c,v 1.23 2002-05-25 09:22:06 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwtip.c,v 1.24 2002-05-27 21:22:15 hadaq Exp $";
#include <assert.h>
#include <string.h>
#include <allParam.h>
-#include "tof_defs.h"
#include "hwtip.h"
static int ourVmeAccessOK;
nanosleep(t, NULL);
}
-#if 0
-static LVme_L berrGetL(LVme * my, unsigned long offset)
-{
- volatile LVme_L retVal;
- static LVme_L oldWord = 0xffffffff;
- static LVme_L oldOff = 0xffffffff;
-
- do {
- ourVmeAccessOK = 1;
- retVal = LVme_getL(my, offset);
- retVal = LVme_getL(my, offset);
- retVal = LVme_getL(my, offset);
- retVal = LVme_getL(my, offset);
- retVal = LVme_getL(my, offset);
- retVal = LVme_getL(my, offset);
- retVal = LVme_getL(my, offset);
- retVal = LVme_getL(my, offset);
- retVal = LVme_getL(my, offset);
- retVal = LVme_getL(my, offset);
-
- } while (!ourVmeAccessOK);
-
-#if 0
- if (oldOff != offset && oldWord == retVal) {
- syslog(LOG_ERR, "word twice: 0x%08x on 0x%08x", retVal, offset);
- }
- oldOff = offset;
- oldWord = retVal;
-#endif
-
- return retVal;
-}
-
-static void berrSetL(LVme * my, unsigned long offset, LVme_L v)
-{
-
- do {
- ourVmeAccessOK = 1;
- LVme_setL(my, offset, v);
- LVme_setL(my, offset, v);
- LVme_setL(my, offset, v);
- LVme_setL(my, offset, v);
- LVme_setL(my, offset, v);
- LVme_setL(my, offset, v);
- LVme_setL(my, offset, v);
- LVme_setL(my, offset, v);
- LVme_setL(my, offset, v);
- LVme_setL(my, offset, v);
- } while (!ourVmeAccessOK);
-}
-#endif
-
-static int bankRequested(HwTip * my)
-{
- uint16_t val;
-
- val = my->bankRequested;
- return val;
-}
-
-
-static int endOfData(HwTip * my)
-{
- return LVme_getL(my->lvme, my->fifo) + my->fifo;
-}
#define TIP_BUFSIZE 0x40000
int conHwTip(HwTip * my, const char *name, const Param *param)
return -1;
}
- my->currAddr = 0xffffffff; /* start at the end */
+ my->currAddr = 0x7fffffff; /* start at the end */
my->bankRequested = 1; /* of the empty bank */
- my->pipeFull = _LVL2_PIPE2_FULL;
+ my->endOfData = 0;
my->daqRq = _LVL2_PIPE2_RQ;
my->daqGr = _LVL2_PIPE2_GR;
my->fifo = MEMBASE + TIP_BUFSIZE;
}
if (my->bankRequested == 0) {
my->bankRequested = 1;
- my->pipeFull = _LVL2_PIPE2_FULL;
my->daqRq = _LVL2_PIPE2_RQ;
my->daqGr = _LVL2_PIPE2_GR;
my->fifo = MEMBASE + TIP_BUFSIZE;
} else {
my->bankRequested = 0;
- my->pipeFull = _LVL2_PIPE1_FULL;
my->daqRq = _LVL2_PIPE1_RQ;
my->daqGr = _LVL2_PIPE1_GR;
my->fifo = MEMBASE;
my->currAddr = my->fifo + 0x4;
}
-int HwTip_isBusy(HwTip * my)
-{
- return !LVme_tstBitL(my->lvme, CONFIG1BASE + CFG_MASTER_STATUS, my->daqGr);
-}
-
-int HwTip_isEmpty(HwTip * my)
-{
- return my->currAddr >= endOfData(my);
-}
-
-#define TIP_NODATASIZE 20
+#define TIP_NODATASIZE 20 /* header + some tag word */
int HwTip_readSubEvt(HwTip * my, void *subEvt)
{
uint32_t *data = (uint32_t *) subEvt;
int currAddr = my->currAddr;
size_t size;
- size = LVme_getL(my->lvme, my->currAddr);
+ size = LVme_getL(my->lvme, currAddr);
lastAddr = currAddr + size;
my->currAddr = lastAddr;
+
if (size > TIP_BUFSIZE) {
- syslog(LOG_ERR, "found size: %.8x , address: %.8x, too long, fatal! ", size, my->currAddr);
+ syslog(LOG_ERR, "found size: %.8x , address: %.8x, too long, fatal! ", size, currAddr);
return -1;
}
+
if( size <= TIP_NODATASIZE ) return 1;
/* copy one sub evt from RC to memory */
*data++ = size;
+
while ((currAddr+=4) < lastAddr) {
*data++ = LVme_getL(my->lvme, currAddr);
}