From bd674da4796d153745429a7a1e9bd9e2d0b9f5de Mon Sep 17 00:00:00 2001 From: muench Date: Thu, 11 May 2000 10:52:08 +0000 Subject: [PATCH] Development during Module7 tests spring 00 --- hadaq/hadaq_init.tcl | 4 +- hadaq/hwrace.c | 54 +++++++-- hadaq/hwrace.h | 1 + hadaq/hwrich.c | 4 +- hadaq/param.tcl | 5 +- hadaq/rc.h | 261 +++++++++++++++++++++++++++++-------------- 6 files changed, 232 insertions(+), 97 deletions(-) diff --git a/hadaq/hadaq_init.tcl b/hadaq/hadaq_init.tcl index 8ad00ff..13edd37 100644 --- a/hadaq/hadaq_init.tcl +++ b/hadaq/hadaq_init.tcl @@ -9,8 +9,8 @@ foreach i [agent cat] { puts $host set hostType [ exec rsh $host uname ] - if {[string match "LynxOS" $hostType] || [string match "Linux" $hostType]} { - set psCmd {ps ax | awk '{ print $1, $NF }'} + if {[string match "LynxOS" $hostType]} { + set psCmd {ps -ax | awk '{ print $1, $NF }'} } else { set psCmd {export UNIX95=XPG4; ps -e -o pid -o comm} } diff --git a/hadaq/hwrace.c b/hadaq/hwrace.c index 54a5a21..ab6bdd7 100644 --- a/hadaq/hwrace.c +++ b/hadaq/hwrace.c @@ -1,4 +1,4 @@ -static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrace.c,v 6.3 2000-02-03 10:32:40 muench Stab $"; +static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrace.c,v 6.4 2000-05-11 10:52:09 muench Exp $"; #define _POSIX_C_SOURCE 199309L #include @@ -22,23 +22,26 @@ static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/had static int bankRequested(HwRace *my) { - return Rc_readPages(my->rc) >> 14 & 1; + return my->bankRequested; } static int bankConfirmed(HwRace *my) { - return Rc_readPages(my->rc) >> 15 & 1; + return Rc_bankConfirmed(my->rc); } static int endOfData(HwRace *my) { - return (Rc_readPages(my->rc) & 0x1ff) * RCPAGESIZE; + return Rc_getPages(my->rc) * RCPAGESIZE; } static void standbyMode(HwRace *my) { Rc_clrStop(my->rc); Rc_clrReset(my->rc); + Rc_Cycle(my->rc); Rc_Cycle(my->rc); Rc_Cycle(my->rc); + Rc_Cycle(my->rc); Rc_Cycle(my->rc); Rc_Cycle(my->rc); + Rc_Cycle(my->rc); Rc_Cycle(my->rc); Rc_Cycle(my->rc); Rc_setReset(my->rc); } @@ -47,7 +50,7 @@ static void acquireMode(HwRace *my) Rc_ClrCtrs(my->rc); Rc_writeStatusid(my->rc, 0x55); Rc_setMemfull(my->rc, 0x1f4); - Rc_setMsel(my->rc); + /* Rc_setMsel(my->rc); */ /* Rc_writeMskreg(my->rc, 0xff); */ Rc_clrMsel(my->rc); Rc_setStop(my->rc); @@ -74,6 +77,7 @@ int conHwRace(HwRace *my, const char *name, const Param *param) standbyMode(my); acquireMode(my); + my->bankRequested = Rc_bankRequested(my->rc); return 0; } @@ -87,13 +91,42 @@ void desHwRace(HwRace *my) void HwRace_requestBuffer(HwRace *my) { my->currAddr = 0; + + my->bankRequested = my->bankRequested == 1 ? 0 : 1; + Rc_setSwrq(my->rc); + Rc_clrSwrq(my->rc); +/* Fix to use only one bank of two + * Events in the "bad" bank are skipped without + * being readout. + */ +#if 0 + my->currAddr = 0; + if((bankRequested(my) == 1)&&(bankConfirmed(my) == 1)) + { + Rc_setSwrq(my->rc); + Rc_clrSwrq(my->rc); + while(bankConfirmed(my) == 1) + { + struct timespec tS, *t = &tS; + t->tv_sec = 0; + t->tv_nsec = 020000000; + nanosleep(t, NULL); + } + } Rc_setSwrq(my->rc); Rc_clrSwrq(my->rc); +#endif } int HwRace_isBusy(HwRace *my) { - return bankRequested(my) != bankConfirmed(my); + int br, bc; + + br = bankRequested(my); + bc = bankConfirmed(my); + + msglog(LOG_DEBUG, "bankRequested %d, bankConfirmed %d\n", br, bc); + return br != bc; } int HwRace_isEmpty(HwRace *my) @@ -125,7 +158,14 @@ int HwRace_readSubEvt(HwRace *my, void *subEvt) for (firstAddr = my->currAddr; my->currAddr - firstAddr < size; my->currAddr += 4) { *data++ = Rc_readMem(my->rc, my->currAddr); } - +/* Just for testing the banks + * id is changed to show the bank where the subevent was + * read from. + * WON'T WORK WITH ANALYSIS SOFTWARE ANY MORE + */ +#if 0 + SubEvt_setId(subEvt, bankConfirmed(my)); +#endif /* normal extension of trigger tag */ SubEvt_setTrigNr(subEvt, my->trigNr << 8 | SubEvt_trigNr(subEvt)); my->trigNr++; diff --git a/hadaq/hwrace.h b/hadaq/hwrace.h index cb328ee..3818ea5 100644 --- a/hadaq/hwrace.h +++ b/hadaq/hwrace.h @@ -10,6 +10,7 @@ typedef struct HwRaceS { char name[16]; Rc *rc; LVme_L *buf; + int bankRequested; int currAddr; int trigNr; } HwRace; diff --git a/hadaq/hwrich.c b/hadaq/hwrich.c index 227b595..795999e 100644 --- a/hadaq/hwrich.c +++ b/hadaq/hwrich.c @@ -1,4 +1,4 @@ -static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrich.c,v 6.4 2000-02-03 18:02:46 muench Stab $"; +static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrich.c,v 6.5 2000-05-11 10:52:09 muench Exp $"; #define _POSIX_C_SOURCE 199309L #include @@ -8,7 +8,7 @@ static char rcsId[] = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/had #include #include -#define SYNCHRONOUS +#undef SYNCHRONOUS #ifdef SYNCHRONOUS #include diff --git a/hadaq/param.tcl b/hadaq/param.tcl index b6c0483..f28a9a4 100644 --- a/hadaq/param.tcl +++ b/hadaq/param.tcl @@ -1,6 +1,9 @@ set soft(size) 1024 -set dtu(cardbase) 0x44500000 +set dtu(cardbase) 0x44100000 + +set race0(cardbase) 0x00000000 +set race1(cardbase) 0x10000000 set tip0(cardbase) 0x10000000 set mu(cardbase) 0xd0000000 diff --git a/hadaq/rc.h b/hadaq/rc.h index 03653c1..7fa83ea 100644 --- a/hadaq/rc.h +++ b/hadaq/rc.h @@ -9,8 +9,8 @@ typedef struct RcS { } Rc; /********************************** - * INTERFACE2 Xilinx part * - * based on ver10rev1, 07.05.1999 * + * INTERFACE3 Xilinx part * + * based on ver3rev1, Feb. 2000 * **********************************/ enum Rc_regions { @@ -32,8 +32,14 @@ static const ptrdiff_t trgCtr = regRegion + 0x008; static const ptrdiff_t prdoutCtr = regRegion + 0x00a; static const ptrdiff_t ardoutCtr = regRegion + 0x00c; static const ptrdiff_t adelCtr = regRegion + 0x00e; -static const ptrdiff_t lcdReg = regRegion + 0x010; -static const ptrdiff_t lcdPad = regRegion + 0x012; +static const ptrdiff_t tagReg = regRegion + 0x010; +static const ptrdiff_t lcReg = regRegion + 0x012; +/* static const ptrdiff_t unused1 = regRegion + 0x014; */ +/* static const ptrdiff_t unused2 = regRegion + 0x016; */ +/* static const ptrdiff_t unused3 = regRegion + 0x018; */ +/* static const ptrdiff_t unused4 = regRegion + 0x01a; */ +static const ptrdiff_t giopReg = regRegion + 0x01c; +static const ptrdiff_t giopPad = regRegion + 0x01e; /* CTRL register definitions */ static unsigned short Rc_getCtrlReg(Rc * my) { return LVme_getW(my->lvme, ctrlReg); } @@ -95,14 +101,16 @@ static int Rc_padStop(Rc * my) { return LVme_tstBitW(my->lvme, ctrlPad, 13); } /* Magic numbers */ static const int PRDOUT = 0x00; /* Pattern readout (daisy chain) */ -static const int PDEL = 0x01; /* Pattern delete (buslike) */ +static const int TEST = 0x01; /* Test Mode activation (buslike) */ static const int ARDOUT = 0x02; /* Analog readout (daisy chain) */ static const int ADEL = 0x03; /* Analog delete (buslike) */ static const int RFIFO = 0x04; /* Reset FIFO (buslike) */ static const int RDAISY = 0x05; /* Reset daisy chain (buslike) */ static const int WCFG = 0x06; /* Write configuration (daisy chain) */ static const int RCFG = 0x07; /* Read configuration (daisy chain) */ -static const int NOP = 0x0F; /* No OPeration - do nothing */ +static const int NOP = 0x0F; /* No OPeration - do nothing */ + +/* Test mode is available only in the GUF (Grand Unified Frontend) */ static void Rc_setFc(Rc * my, int fc) { @@ -244,70 +252,44 @@ static void Rc_ClrCtrs(Rc * my) Rc_clrRctr(my); } -/* LCD register definitions */ +/* TAG register definitions */ +/* This register contains the last distributed SubEventTag */ -/* Magic numbers */ -static const int CLR_DISPLAY = 0x01; /* clears display, sets cursor home, unshifts */ -static const int CRSR_HOME = 0x02; /* sets cursor home, unshifts */ -static const int CRSR_LEFT = 0x10; /* move cursor one char left */ -static const int CRSR_RIGHT = 0x14; /* move cursor one char right */ -static const int DISP_LEFT = 0x18; /* shifts whole display one char left */ -static const int DISP_RIGHT = 0x1c; /* shifts whole display one char right */ -static const int CRSR_ON = 0x0a; /* display cursor */ -static const int BLINK_ON = 0x09; /* blinks cursor */ -static const int DISP_ON = 0x0c; /* set display on */ -static const int DISP_CTRL = 0x08; /* magic byte for CRSR_ON, BLINK_ON, DISP_ON */ +static unsigned short Rc_getTagReg(Rc * my) { return LVme_getW(my->lvme, tagReg); } -/* Do not use this function alone */ -static int Rc_readInstrLCD(Rc * my) -{ - LVme_setW(my->lvme, lcdReg, 0x01FF); - LVme_setBitW(my->lvme, lcdReg, 10); - LVme_clrBitW(my->lvme, lcdReg, 10); - return LVme_getW(my->lvme, lcdPad); -} -static void Rc_waitBusyLCD(Rc * my) -{ - while((Rc_readInstrLCD(my) & 0x80) >> 7) - { - /* Delay loop -> something useful to put in here ? */ - } -} -static void Rc_writeDataLCD(Rc * my, int data) -{ - unsigned short realData = 0x0000; - realData = 0x0200 | data; - Rc_waitBusyLCD(my); - LVme_setW(my->lvme, lcdReg, realData); - LVme_setBitW(my->lvme, lcdReg, 10); - LVme_clrBitW(my->lvme, lcdReg, 10); -} -static void Rc_writeInstrLCD(Rc * my, int instr) +/* LC register definitions */ +/* This register contains information on the last command delivered by the DTU_RICH as well */ +/* as the acknowledge of the RC99 hardware. By this register, a DTU_RICH lockup due to a */ +/* missing acknowledge of the RC99 hardware can be easily detected. */ + +/* Do not use this function alone ! */ +static unsigned short Rc_getLcReg(Rc * my) { return LVme_getW(my->lvme, lcReg); } + +static unsigned short Rc_getLcStatus(Rc * my) { - unsigned short realInstr = 0x0000; - realInstr = 0x0000 | instr; - Rc_waitBusyLCD(my); - LVme_setW(my->lvme, lcdReg, realInstr); - LVme_setBitW(my->lvme, lcdReg, 10); - LVme_clrBitW(my->lvme, lcdReg, 10); + unsigned short LcStatus = 0x0000; + return LcStatus = (Rc_getLcReg(my) & 0x001f); } -static void Rc_initLCD(Rc * my) + +/* GIOP register definitions */ +/* This register allows access to five free Xilinx pins equipped with a solder pad. */ +/* By default, these pads are unconnected and can be used for test purposes. */ + +/* Do not use these functions alone ! */ +static unsigned short Rc_getgiopReg(Rc * my) { return LVme_getW(my->lvme, giopReg); } +static unsigned short Rc_getgiopPad(Rc * my) { return LVme_getW(my->lvme, giopPad); } + +static unsigned short Rc_getInterfaceVersion(Rc * my) { - /* Function Set: 8bit, 2lines, 5x7 font */ - LVme_setW(my->lvme, lcdReg, 0x0038); - LVme_setBitW(my->lvme, lcdReg, 10); - LVme_clrBitW(my->lvme, lcdReg, 10); - /* Wait more than 4.1ms */ - usleep(5000); - /* Display ON/OFF control */ - Rc_writeInstrLCD(my, 0x0e); - /* Entry mode set */ - Rc_writeInstrLCD(my, 0x06); + short giopPadValue; + giopPadValue = (0xFF00 & Rc_getgiopPad(my)) >> 8; + return giopPadValue; } + /********************************* - * MEMORY2 Xilinx part * - * based on ver16rev1 07.05.1999 * + * MEMORY3 Xilinx part * + * based on ver7rev2 Feb. 2000 * *********************************/ /* Offsets for MEMORY2 registers */ @@ -319,6 +301,14 @@ static const ptrdiff_t sedec_high = regRegion + 0x108; static const ptrdiff_t sedec_low = regRegion + 0x10a; static const ptrdiff_t seid_high = regRegion + 0x10c; static const ptrdiff_t seid_low = regRegion + 0x10e; +static const ptrdiff_t versionMem = regRegion + 0x110; +static const ptrdiff_t swCtr = regRegion + 0x112; +static const ptrdiff_t codeMem = regRegion + 0x114; +/* static const ptrdiff_t unused3 = regRegion + 0x116; */ +/* static const ptrdiff_t unused4 = regRegion + 0x118; */ +/* static const ptrdiff_t unused5 = regRegion + 0x11a; */ +/* static const ptrdiff_t unused6 = regRegion + 0x11c; */ +/* static const ptrdiff_t unused7 = regRegion + 0x11e; */ /* STATUSID register */ static unsigned int Rc_readStatusid(Rc * my) @@ -330,9 +320,9 @@ static unsigned int Rc_readStatusid(Rc * my) static void Rc_writeStatusid(Rc * my, unsigned char value) { unsigned short savedStatusId; - savedStatusId = LVme_getW(my->lvme, statusid); /* StatusID Register retten */ - savedStatusId = ( savedStatusId & 0xFF00 ) | ( value & 0x00FF ); /* Neue ID auf low byte einblenden */ - LVme_setW(my->lvme, statusid, savedStatusId); /* neues Register zurueckschreiben */ + savedStatusId = LVme_getW(my->lvme, statusid); + savedStatusId = ( savedStatusId & 0xFF00 ) | ( value & 0x00FF ); + LVme_setW(my->lvme, statusid, savedStatusId); } static unsigned short Rc_getStatusID(Rc * my) { @@ -400,6 +390,13 @@ static unsigned short Rc_readPages(Rc * my) { return LVme_getW(my->lvme, pages); } +static unsigned short Rc_getPages(Rc *my) +{ + unsigned short realPages = 0x0000; + realPages = Rc_readPages(my); /* read PAGES content */ + realPages = realPages & 0x07ff; /* mask the number out */ + return realPages; /* return value */ +} static void Rc_waitSwitchcomplete(Rc * my) { unsigned short realPages = 0x0000; @@ -407,15 +404,40 @@ static void Rc_waitSwitchcomplete(Rc * my) realPages = realPages & 0xc000; /* oberste zwei Bits anschauen */ while((realPages != 0x0000) || (realPages != 0xc000)) /* Schleife, bis beide Bits gleich */ { - realPages = (Rc_readPages(my) & 0xc000); /* immer wieder reingucken */ + realPages = (Rc_readPages(my) & 0xc000); /* immer wieder reingucken */ } } +static int Rc_bankRequested(Rc * my) +{ + unsigned short realPages = 0x0000; + realPages = Rc_readPages(my); + realPages = ((realPages & 0x4000) >> 14); + return (int) realPages; +} +static int Rc_bankConfirmed(Rc * my) +{ + unsigned short realPages = 0x0000; + realPages = Rc_readPages(my); + realPages = ((realPages & 0x8000) >> 15); + return (int) realPages; +} +static int Rc_SwitchStatus(Rc * my) +{ + unsigned short realPages = 0x0000; + realPages = Rc_readPages(my); + realPages = ((realPages & 0xc0000) >> 14); + return (int) realPages; + /* 0x03: Bank A requested and activated + 0x02: Bank B requested, request still pending + 0x01: Bank A requested, request still pending + 0x00: Bank B requested and activated */ +} static int Rc_testMemfull(Rc * my) { unsigned short realPages = 0x0000; realPages = Rc_readPages(my); realPages = (realPages & 0x2000) >> 13; - return realPages; + return (int) realPages; } /* SEDEC_HIGH register */ @@ -458,6 +480,41 @@ static void Rc_writeSeid_low(Rc * my, unsigned short value) LVme_setW(my->lvme, seid_low, value); } +/* VERSIONMEM register */ +static unsigned short Rc_readVersionMem(Rc * my) +{ + return LVme_getW(my->lvme, versionMem); +} + +/* SWCTR register */ +static unsigned short Rc_readSwCtr(Rc * my) +{ + return LVme_getW(my->lvme, swCtr); +} + +/* CODEMEM register */ +static void Rc_HallOfMemory(Rc *my) +{ + int i = 0; + char low, high; + unsigned short word; + char fame[256]; + + LVme_setW(my->lvme, codeMem, 0xc0de); + + do + { + word = LVme_getW(my->lvme, codeMem); + low = word & 0xff; + high = (word >> 8) & 0xff; + fame[i++] = high; + fame[i++] = low; + + } + while(high != 0 || low != 0); + printf(fame); +} + /*********************** * TIMING2 Xilinx part * * based on verXrevY * @@ -468,7 +525,8 @@ static void Rc_writeSeid_low(Rc * my, unsigned short value) /* Offsets for TIMING2 registers */ static const ptrdiff_t evtgReg = busRegion + 0x100; static const ptrdiff_t errReg = busRegion + 0x102; -static const ptrdiff_t mskReg = busRegion + 0x104; +static const ptrdiff_t mskReg = busRegion + 0x104; +static const ptrdiff_t stwReg = busRegion + 0x106; /* EVTG-Register read/write (16bit wide) */ static unsigned short Rc_readEvtgreg(Rc * my) @@ -504,6 +562,19 @@ static void Rc_writeMskreg(Rc * my, int value) LVme_setW(my->lvme, mskReg, realValue); } +/* STW-Register read/write (8bit wide) */ +static int Rc_readStwreg(Rc * my) +{ + return LVme_getW(my->lvme, stwReg); +} +static void Rc_writeStwreg(Rc * my, int value) +{ + unsigned short realValue = 0x0000; + realValue = 0x0000 | value; + LVme_setW(my->lvme, stwReg, realValue); +} + + /**************** * Port XC part * ****************/ @@ -523,6 +594,22 @@ static unsigned short Rc_getPctrl(Rc * my, int port) return LVme_getW(my->lvme, (port * portOffset + Pcontrol)); } +/* ENXCFG bit: enable configuration of frontend FPGAs */ +static void Rc_setXcfg(Rc * my, int port) +{ + LVme_setBitW(my->lvme, port * portOffset + Pcontrol, 0); +} + +static void Rc_clrXcfg(Rc * my, int port) +{ + LVme_clrBitW(my->lvme, port * portOffset + Pcontrol, 0); +} + +static int Rc_getXcfg(Rc * my, int port) +{ + return LVme_tstBitW(my->lvme, port * portOffset + Pcontrol, 0); +} + /*************** * Memory part * @@ -541,24 +628,24 @@ static void Rc_writeMem(Rc * my, unsigned long offsetValue, unsigned long value) static void Rc_clearMem(Rc * my) { long i; - const long RC_MEMSIZE = 0x80000; - const long CLEARVALUE = 0x00000000; - for(i = 0; i < RC_MEMSIZE; i = i + 0x04) + const long memSize = 0x80000; + const long clearValue = 0x00000000; + for(i = 0; i < memSize; i = i + 0x04) { - Rc_writeMem(my, i, CLEARVALUE); + Rc_writeMem(my, i, clearValue); } } static long Rc_testMem(Rc * my) { long i; - const long RC_MEMSIZE = 0x80000; - const long CLEARVALUE = 0x00000000; + const long memSize = 0x80000; + const long clearValue = 0x00000000; unsigned long different = 0x00000000; unsigned long memValue = 0x00000000; - for(i = 0; i < RC_MEMSIZE; i = i + 0x04) + for(i = 0; i < memSize; i = i + 0x04) { memValue = Rc_readMem(my, i); - if(memValue != CLEARVALUE) + if(memValue != clearValue) { different++; printf("A: 0x%08x: 0x%08x\n", i, memValue); @@ -589,29 +676,29 @@ static void Rc_writeDpr(Rc * my, unsigned long offsetValue, unsigned short value static void Rc_clearDpr(Rc * my) { unsigned short i; - const unsigned short DPRSIZE = 0x8000; - const unsigned short CLEARVALUE = 0x0000; - for(i = 0; i < DPRSIZE; i = i + 0x04) + const unsigned short dprSize = 0x8000; + const unsigned short clearValue = 0x0000; + for(i = 0; i < dprSize; i = i + 0x04) { if (i % 256 == 0) { printf("."); } - Rc_writeDpr(my, i, CLEARVALUE); + Rc_writeDpr(my, i, clearValue); } printf("\n"); } static unsigned short Rc_testDpr(Rc * my) { unsigned short i; - const unsigned short DPRSIZE = 0x8000; - const unsigned short CLEARVALUE = 0x0000; + const unsigned short dprSize = 0x8000; + const unsigned short clearValue = 0x0000; unsigned short different = 0x0000; unsigned short memValue = 0x0000; - for(i = 0; i < DPRSIZE; i = i + 0x04) + for(i = 0; i < dprSize; i = i + 0x04) { memValue = Rc_readDpr(my, i); - if(memValue != CLEARVALUE) + if(memValue != clearValue) { different++; printf(" -> A: 0x%08x: 0x%04x\n", i, memValue); @@ -640,5 +727,9 @@ void desRc(Rc *my); -/* This is a comment */ +/* This is a comment */ + + + #endif + -- 2.43.0