From 4ecfa82ab00e6a153cc428889fac87572ebeb6dd Mon Sep 17 00:00:00 2001 From: hadaq Date: Wed, 16 Oct 2002 11:38:49 +0000 Subject: [PATCH] Moved Interrupt handling from hwrich.c to hwrace -- mm --- hadaq/hwrace.c | 21 +++++++++++++++------ hadaq/hwrace.h | 3 +++ hadaq/hwrich.c | 21 +-------------------- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/hadaq/hwrace.c b/hadaq/hwrace.c index 58507e6..dcecb95 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.22 2002-10-16 08:09:40 hadaq Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrace.c,v 6.23 2002-10-16 11:38:49 hadaq Exp $"; #define _POSIX_C_SOURCE 199309L @@ -26,8 +26,8 @@ static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hada int conHwRace(HwRace *my, const char *name, const Param *param) { unsigned long cardBase; + unsigned long statusId; int paramWasFound; - int i; assert(my != NULL); @@ -35,16 +35,23 @@ int conHwRace(HwRace *my, const char *name, const Param *param) Param_getInt(param, my->name, "cardbase", ¶mWasFound, &cardBase); if (!paramWasFound) { - syslog(LOG_WARNING, - "Parameter %s(%s) not found, default = 0", my->name, "cardbase"); - cardBase = 0; + syslog(LOG_ERR, "Parameter %s(cardbase) not found", my->name); + return -1; } my->rc = malloc(sizeof(Rc)); - if (0 > conRc(my->rc, "rc", cardBase)) { syslog(LOG_ERR, "%s:%d:%s", __FILE__, __LINE__, strerror(errno)); return -1; } + + Param_getInt(param, my->name, "status_id", ¶mWasFound, &statusId); + if (!paramWasFound) { + syslog(LOG_ERR, "Parameter %s(status_id) not found", my->name); + return -1; + } + my->lInt = malloc(sizeof(LInt)); + conLInt(my->lInt, statusId); + my->currAddr = 0x7fffffff; my->endOfData = 0; @@ -53,6 +60,8 @@ int conHwRace(HwRace *my, const char *name, const Param *param) void desHwRace(HwRace *my) { + desLInt(my->lInt); + free(my->lInt); desRc(my->rc); free(my->rc); } diff --git a/hadaq/hwrace.h b/hadaq/hwrace.h index b68c566..551e668 100644 --- a/hadaq/hwrace.h +++ b/hadaq/hwrace.h @@ -11,6 +11,7 @@ typedef struct HwRaceS { char name[12]; Rc *rc; LVme_L *buf; + LInt *lInt; int currAddr; int endOfData; } @@ -38,6 +39,8 @@ static int HwRace_isBufRequested(HwRace *my) } static void HwRace_getEndOfData(HwRace *my) { + LInt_wait(my->lInt); + syslog(LOG_DEBUG, "%s: irq received", my->name); my->endOfData = Rc_getPages(my->rc) * RCPAGESIZE; } diff --git a/hadaq/hwrich.c b/hadaq/hwrich.c index bf5bbe5..ab783b1 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.28 2002-10-16 08:09:40 hadaq Exp $"; +static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/Attic/hwrich.c,v 6.29 2002-10-16 11:38:49 hadaq Exp $"; #define _POSIX_C_SOURCE 199309L #include @@ -19,7 +19,6 @@ struct HardwareS { size_t maxSubEvtSize; int nRaces; HwRace **race; - LInt **lInt; }; #include "hardware.h" @@ -65,27 +64,16 @@ Hardware *newHardware(const char *subsystem) } my = malloc(sizeof(Hardware)); my->race = malloc(nCards * sizeof(HwRace *)); - my->lInt = malloc(nCards * sizeof(LInt)); my->maxSubEvtSize = SubEvt_hdrSize() + (nCards * 2500 * sizeof(uint32_t)); my->nRaces = nCards; for (i = 0; i < my->nRaces; i++) { - unsigned long statusId; - int paramWasFound; - my->race[i] = malloc(sizeof(HwRace)); if (0 > conHwRace(my->race[i], cards[i], param)) { syslog(LOG_ERR, "Construction of card %s failed:%s", cards[i], strerror(errno)); return NULL; } - my->lInt[i] = malloc(sizeof(LInt)); - Param_getInt(param, my->race[i]->name, "status_id", ¶mWasFound, &statusId); - if (!paramWasFound) { - syslog(LOG_ERR, "Parameter %s(status_id) not found", my->race[i]->name); - return NULL; - } - conLInt(my->lInt[i], statusId); } desParam(param); @@ -97,12 +85,9 @@ void deleteHardware(Hardware *my) int i; for (i = 0; i < my->nRaces; i++) { - desLInt(my->lInt[i]); - free(my->lInt[i]); desHwRace(my->race[i]); free(my->race[i]); } - free(my->lInt); free(my->race); free(my); } @@ -122,11 +107,7 @@ void Hardware_waitForTrigger(Hardware *my, void *subEvt) for (i = 0; i < my->nRaces; i++) { if (HwRace_isBufRequested(my->race[i])) { - LInt_wait(my->lInt[i]); HwRace_getEndOfData(my->race[i]); -#ifndef NDEBUG - syslog(LOG_DEBUG, "%d irq received", i); -#endif } } } -- 2.43.0