diff --git a/src/db/callback.c b/src/db/callback.c index 0fa6c6033..f13f71629 100644 --- a/src/db/callback.c +++ b/src/db/callback.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -43,14 +44,14 @@ #include #include +#define QUEUESIZE 1000 static SEM_ID callbackSem[NUM_CALLBACK_PRIORITIES]; +static RING_ID callbackQ[NUM_CALLBACK_PRIORITIES]; static int callbackTaskId[NUM_CALLBACK_PRIORITIES]; volatile int callbackRestart=FALSE; -static volatile CALLBACK *head[NUM_CALLBACK_PRIORITIES]; -static volatile CALLBACK *tail[NUM_CALLBACK_PRIORITIES]; /* forward references */ -void wdCallback(); /*callback from taskwd*/ +void wdCallback(long); /*callback from taskwd*/ void start(); /*start or restart a callbackTask*/ /*public routines */ @@ -66,41 +67,50 @@ long callbackInit() /* Routine which places requests into callback queue*/ /* This routine can be called from interrupt routine*/ -long callbackRequest(struct callback *pcallback) +void callbackRequest(CALLBACK *pcallback) { int priority = pcallback->priority; int lockKey; + int nput; + static int status; if(priority<0 || priority>(NUM_CALLBACK_PRIORITIES)) { logMsg("callbackRequest called with invalid priority"); - return(-1); + return; } lockKey = intLock(); - pcallback->next = NULL; - tail[priority]->next = pcallback; - if(head[priority]==NULL) head[priority] = pcallback; + nput = rngBufPut(callbackQ[priority],(void *)&pcallback,sizeof(pcallback)); intUnlock(lockKey); - if(semGive(callbackSem[priority])!=OK) + if(nput!=sizeof(pcallback)) logMsg("callbackRequest ring buffer full"); + if((status=semGive(callbackSem[priority]))!=OK) { +/*semGive randomly returns garbage value*/ +/* logMsg("semGive returned error in callbackRequest\n"); - return(0); +logMsg("status=%d\n",status); +*/ + } + return; } /* General purpose callback task */ -static void callbackTask(int priority) +/*static*/ + void callbackTask(int priority) { - volatile CALLBACK *pcallback,*next; - int lockKey; + volatile CALLBACK *pcallback; + int nget; while(TRUE) { /* wait for somebody to wake us up */ - if(semTake(callbackSem[priority],WAIT_FOREVER)!=OK ) - logMsg("semTake returned error in callbackRequest\n"); - - while(TRUE) { - lockKey = intLock(); - if((pcallback=head[priority])==NULL) break; - if((head[priority]=pcallback->next)==NULL) tail[priority]=NULL; - intUnlock(lockKey); + if(semTake(callbackSem[priority],WAIT_FOREVER)!=OK ){ + errMessage(0,"semTake returned error in callbackTask\n"); + taskSuspend(0); + } + while(rngNBytes(callbackQ[priority])>=sizeof(pcallback)) { + nget = rngBufGet(callbackQ[priority],(void *)&pcallback,sizeof(pcallback)); + if(nget!=sizeof(pcallback)) { + errMessage(0,"rngBufGet failed in callbackTask"); + taskSuspend(0); + } (*pcallback->callback)(pcallback); } } @@ -108,21 +118,20 @@ static void callbackTask(int priority) static void start(int ind) { - char name[100]; int priority; - head[ind] = tail[ind] = 0; if((callbackSem[ind] = semBCreate(SEM_Q_FIFO,SEM_EMPTY))==NULL) - logMsg("semBcreate failed while starting a callback task\n"); - sprintf(name,"%s%2.2d",CALLBACK_NAME,ind); + errMessage(0,"semBcreate failed while starting a callback task\n"); if(ind==0) priority = CALLBACK_PRI_LOW; else if(ind==1) priority = CALLBACK_PRI_MEDIUM; else if(ind==2) priority = CALLBACK_PRI_HIGH; else { - logMsg("semBcreate failed while starting a callback task\n"); + errMessage(0,"semBcreate failed while starting a callback task\n"); return; } - callbackTaskId[ind] = taskSpawn(name,priority, + if((callbackQ[ind] = rngCreate(sizeof(CALLBACK *) * QUEUESIZE)) == NULL) + errMessage(0,"rngCreate failed while starting a callback task"); + callbackTaskId[ind] = taskSpawn(CALLBACK_NAME,priority, CALLBACK_OPT,CALLBACK_STACK, (FUNCPTR)callbackTask,ind); if(callbackTaskId[ind]==ERROR) { @@ -138,8 +147,9 @@ static void wdCallback(long ind) taskwdRemove(callbackTaskId[ind]); if(!callbackRestart)return; if(taskDelete(callbackTaskId[ind])!=OK) - logMsg("taskDelete failed while restarting a callback task\n"); - if(semFlush(callbackSem[ind])!=OK) - logMsg("semFlush failed while restarting a callback task\n"); + errMessage(0,"taskDelete failed while restarting a callback task\n"); + if(semDelete(callbackSem[ind])!=OK) + errMessage(0,"semDelete failed while restarting a callback task\n"); + rngDelete(callbackQ[ind]); start(ind); } diff --git a/src/db/dbAccess.c b/src/db/dbAccess.c index 8235ec65b..93d6d9a7e 100644 --- a/src/db/dbAccess.c +++ b/src/db/dbAccess.c @@ -36,6 +36,7 @@ * .06 11-26-91 jba Added return to dbGetLink * Fixed bug in special processing of SPC_MOD (100) * .07 12-02-91 jba Writing to PROC will always force record process + * .08 02-05-92 jba Changed function arguments from paddr to precord */ /* This is a major revision of the original implementation of database access.*/ @@ -43,21 +44,21 @@ /* Global Database Access Routines * * dbScanLock(precord) Lock for scanning records - * caddr_t precord; + * struct dbCommon precord; * returns void * * dbScanUnlock(precord) Unlock for scanning records - * caddr_t precord; + * struct dbCommon precord; * returns void * * dbScanLockInit(nset) Initialize scan lock * int nset; * - * dbScanPassive(paddr) process if record is passively scanned - * struct dbAddr *paddr; pointer to database address structure + * dbScanPassive(precord) process if record is passively scanned + * struct dbCommon precord; * - * dbProcess(paddr) process a database record - * struct dbAddr *paddr; pointer to database address structure + * dbProcess(precord) process a database record + * struct dbCommon precord; * * dbNameToAddr(pname,paddr) Given "pv<.field>" compute dbAddr * char *pname @@ -65,17 +66,17 @@ * * dbGetLink(pdblink,pdest,dbrType,pbuffer,options,nRequest) * struct db_link *pdblink; - * struct dbCommon *pdest; + * struct dbCommon *pdest; * short dbrType; DBR_xxx - * caddr_t pbuffer; addr of returned data + * void pbuffer; addr of returned data * long *options; addr of options * long *nRequest; addr of number of elements * * dbPutLink(pdblink,psource,dbrType,pbuffer,nRequest) * struct db_link *pdblink; - * struct dbCommon *psource; + * struct dbCommon *psource; * short dbrType; DBR_xxx - * caddr_t pbuffer; addr of input data + * void pbuffer; addr of input data * long nRequest; * * dbGetField(paddr,dbrType,pbuffer,options,nRequest,pfl) @@ -102,6 +103,7 @@ #include #include #include +#include #include #include #include @@ -111,6 +113,7 @@ #include #include #include +#include #include #include #include @@ -118,7 +121,6 @@ #include #include #include -#include #include #include @@ -142,8 +144,7 @@ static struct { struct scanLock *pscanLock; /*addr of array of struct scanLock */ } dbScanPvt; -void dbScanLock(precord) - caddr_t precord; +void dbScanLock(struct dbCommon *precord) { struct scanLock *pscanLock; short lset=((struct dbCommon *)precord)->lset - 1; @@ -156,12 +157,11 @@ void dbScanLock(precord) FASTLOCK(&pscanLock->lock); pscanLock->start_time = tickGet(); pscanLock->task_id = taskIdSelf(); - pscanLock->precord = precord; + pscanLock->precord = (void *)precord; return; } -void dbScanUnlock(precord) - caddr_t precord; +void dbScanUnlock(struct dbCommon *precord) { struct scanLock *pscanLock; short lset=((struct dbCommon *)precord)->lset - 1; @@ -177,13 +177,13 @@ void dbScanUnlock(precord) } void dbScanLockInit(nset) - int nset; + int nset; { struct scanLock *pscanLock; int i; dbScanPvt.nset = nset; - pscanLock = (struct scanLock *)calloc((size_t)nset, + pscanLock = calloc((size_t)nset, (size_t)sizeof(struct scanLock)); dbScanPvt.pscanLock = pscanLock; for (i=0; iprecord); - /* if not passive and field not PROC just return success */ - if(precord->scan != 0 && paddr->pfield != (caddr_t)&precord->proc) return(0); + /* if not passive just return success */ + if(precord->scan != 0) return(0); /* return result of process */ - return(dbProcess(paddr)); + return(dbProcess(precord)); } -long dbProcess(paddr) - struct dbAddr *paddr; +long dbProcess(struct dbCommon *precord) { struct rset *prset; - struct dbCommon *precord=(struct dbCommon *)(paddr->precord); unsigned char tpro=precord->tpro; short lset = precord->lset; long status = 0; @@ -244,7 +240,7 @@ long dbProcess(paddr) if(precord->mlis.count==0) goto all_done; db_post_events(precord,&precord->stat,DBE_VALUE); db_post_events(precord,&precord->sevr,DBE_VALUE); - prset=GET_PRSET(paddr->record_type); + prset=(struct rset *)precord->rset; if( prset && prset->get_value ){ (*prset->get_value)(precord,&valueDes); db_post_events(precord,valueDes.pvalue,DBE_VALUE|DBE_ALARM); @@ -259,7 +255,7 @@ long dbProcess(paddr) status = dbGetLink(&precord->sdis.value.db_link,precord, DBR_SHORT,(caddr_t)(&(precord->disa)),&options,&nRequest); - if(!RTN_SUCCESS(status)) recGblDbaddrError(status,paddr,"dbProcess"); + if(!RTN_SUCCESS(status)) recGblRecordError(status,precord,"dbProcess"); } /* if disabled just return success */ if(precord->disa == precord->disv) { @@ -269,9 +265,9 @@ long dbProcess(paddr) } /* locate record processing routine */ - if(!(prset=GET_PRSET(paddr->record_type)) || !(prset->process)) { + if(!(prset=(struct rset *)precord->rset) || !(prset->process)) { precord->pact=1;/*set pact TRUE so error is issued only once*/ - recGblRecSupError(S_db_noRSET,paddr,"dbProcess","process"); + recGblRecSupError(S_db_noRSET,precord,"dbProcess"); status = S_db_noRSET; if(trace && trace_lset==lset) printf("failure: %s\n",precord->name); @@ -281,7 +277,7 @@ long dbProcess(paddr) /* process record */ if(trace && trace_lset==lset) printf("process: %s\n",precord->name); - status = (*prset->process)(paddr); + status = (*prset->process)(precord); all_done: if(set_trace) { @@ -296,8 +292,8 @@ all_done: struct fldDes *pvdGetFld(); long dbNameToAddr(pname,paddr) -char *pname; -struct dbAddr *paddr; + char *pname; + struct dbAddr *paddr; { char *precName; char recName[PVNAME_SZ+1]; @@ -355,7 +351,7 @@ struct dbAddr *paddr; recGblDbaddrError(S_db_notFound,paddr,"dbNameToAddr"); return(S_db_notFound); } - paddr->precord=precord; + paddr->precord=(void *)precord; paddr->pfield=precord+field_offset; /*if special is SPC_DBADDR then call cvt_dbaddr */ @@ -370,65 +366,59 @@ struct dbAddr *paddr; return(status); } -long dbGetLink(pdblink,pdest,dbrType,pbuffer,options,nRequest) - struct db_link *pdblink; - struct dbCommon *pdest; - short dbrType; - caddr_t pbuffer; - long *options; - long *nRequest; +long dbGetLink( + struct db_link *pdblink, + struct dbCommon *pdest, + short dbrType, + void *pbuffer, + long *options, + long *nRequest +) { struct dbAddr *paddr=(struct dbAddr*)(pdblink->pdbAddr); + struct dbCommon *psource=paddr->precord; long status; if(pdblink->process_passive) { - status=dbScanPassive(paddr); + status=dbScanPassive(psource); if(!RTN_SUCCESS(status)) return(status); } - if(pdblink->maximize_sevr) { - struct dbCommon *pfrom=(struct dbCommon*)(paddr->precord); - - if(pfrom->sevr>pdest->nsev) { - pdest->nsev = pfrom->sevr; - pdest->nsta = LINK_ALARM; - } + if(pdblink->maximize_sevr) recGblSetSevr(pdest,LINK_ALARM,psource->sevr); - } status= dbGetField(paddr,dbrType,pbuffer,options,nRequest,NULL); if(status) recGblRecordError(status,pdest,"dbGetLink"); return(status); } -long dbPutLink(pdblink,psource,dbrType,pbuffer,nRequest) - struct db_link *pdblink; - struct dbCommon *psource; - short dbrType; - caddr_t pbuffer; - long nRequest; +long dbPutLink( + struct db_link *pdblink, + struct dbCommon *psource, + short dbrType, + void *pbuffer, + long nRequest +) { struct dbAddr *paddr=(struct dbAddr*)(pdblink->pdbAddr); + struct dbCommon *pdest=paddr->precord; + struct fldDes *pfldDes=(struct fldDes *)(paddr->pfldDes); long status; status=dbPut(paddr,dbrType,pbuffer,nRequest); - if(pdblink->maximize_sevr) { - struct dbCommon *pto=(struct dbCommon*)(paddr->precord); - - if(pto->nsevsevr) { - pto->nsev = psource->sevr; - pto->nsta = LINK_ALARM; - } - } + if(pdblink->maximize_sevr) recGblSetSevr(pdest,LINK_ALARM,psource->sevr); if(!RTN_SUCCESS(status)) return(status); - if(pdblink->process_passive) status=dbScanPassive(paddr); + + if(paddr->pfield==(void *)&pdest->proc) status=dbProcess(pdest); + else if (pfldDes->process_passive) status=dbScanPassive(pdest); if(status) recGblRecordError(status,psource,"dbPutLink"); return(status); } -long dbPutField(paddr,dbrType,pbuffer,nRequest) - struct dbAddr *paddr; - short dbrType; - caddr_t pbuffer; - long nRequest; +long dbPutField( + struct dbAddr *paddr, + short dbrType, + void *pbuffer, + long nRequest +) { long status; struct fldDes *pfldDes=(struct fldDes *)(paddr->pfldDes); @@ -441,15 +431,19 @@ long dbPutField(paddr,dbrType,pbuffer,nRequest) dbScanLock(paddr->precord); status=dbPut(paddr,dbrType,pbuffer,nRequest); if(status) recGblDbaddrError(status,paddr,"dbPutField"); - if(RTN_SUCCESS(status) && pfldDes->process_passive) (void)dbScanPassive(paddr); + if(RTN_SUCCESS(status)){ + if(paddr->pfield==(void *)precord->proc) status=dbProcess(precord); + else if (pfldDes->process_passive) status=dbScanPassive(precord); + } dbScanUnlock(paddr->precord); return(status); } -long dbBufferSize(dbr_type,options,no_elements) - short dbr_type; - long options; - long no_elements; +long dbBufferSize( + short dbr_type, + long options, + long no_elements +) { long nbytes=0; @@ -484,9 +478,9 @@ long dbBufferSize(dbr_type,options,no_elements) * */ static void f_to_str(flt_value,pstr_value,precision) -double flt_value; -char *pstr_value; -int precision; + double flt_value; + char *pstr_value; + int precision; { unsigned short got_one; double place; @@ -566,8 +560,8 @@ int precision; static char digit_to_ascii[10]={'0','1','2','3','4','5','6','7','8','9'}; static void char_to_str(source,pdest) - char source; - char *pdest; + char source; + char *pdest; { unsigned char val,temp; char digit[3]; @@ -2981,14 +2975,16 @@ void get_graphics(); void get_control(); void get_alarm(); -long dbGetField(paddr,dbrType,pbuffer,options,nRequest,pfl) -struct dbAddr *paddr; -short dbrType; -caddr_t pbuffer; -long *options; -long *nRequest; -db_field_log *pfl; +long dbGetField( +struct dbAddr *paddr, +short dbrType, +void *pbuffer, +long *options, +long *nRequest, +void *pflin +) { + db_field_log *pfl= (db_field_log *)pflin; long no_elements=paddr->no_elements; long offset; struct rset *prset; @@ -5801,7 +5797,7 @@ long nRequest; if(special) { if(special<100) { /*global processing*/ if(special==SPC_NOMOD) return(S_db_noMod); - if(special==SPC_SCAN) delete_from_scan_list(paddr); + if(special==SPC_SCAN) scanDelete(precord); } else { if( prset && (pspecial = (prset->special))) { @@ -5835,7 +5831,7 @@ long nRequest; /* check for special processing is required */ if(special) { if(special<100) { /*global processing*/ - if(special==SPC_SCAN) add_to_scan_list(paddr,0xffff); + if(special==SPC_SCAN) scanAdd(precord); } else { status=(*pspecial)(paddr,1); diff --git a/src/db/dbEvent.c b/src/db/dbEvent.c index d53cfe01e..80b6b116b 100644 --- a/src/db/dbEvent.c +++ b/src/db/dbEvent.c @@ -409,7 +409,7 @@ register struct event_block *pevent; /* ptr to event blk (not required) */ pevent->valque = FALSE; LOCKREC(precord); - lstAdd(&precord->mlis, pevent); + lstAdd((LIST*)&precord->mlis,(NODE*) pevent); UNLOCKREC(precord); return OK; @@ -440,9 +440,9 @@ register struct event_block *pevent; LOCKREC(precord); /* dont let a misplaced event corrupt the queue */ - status = lstFind( &precord->mlis, pevent); + status = lstFind((LIST*)&precord->mlis,(NODE*)pevent); if(status!=ERROR) - lstDelete( &precord->mlis, pevent); + lstDelete((LIST*)&precord->mlis,(NODE*)pevent); UNLOCKREC(precord); if(status == ERROR) return ERROR; diff --git a/src/db/dbScan.c b/src/db/dbScan.c index 03340cca1..86bb27498 100644 --- a/src/db/dbScan.c +++ b/src/db/dbScan.c @@ -1,9 +1,11 @@ /* dbScan.c */ /* share/src/db $Id$ */ + /* tasks and subroutines to scan the database */ /* - * Author: Bob Dalesio - * Date: 11-30-88 + * Original Author: Bob Dalesio + * Current Author: Marty Kraimer + * Date: 07/18/91 * * Experimental Physics and Industrial Control System (EPICS) * @@ -28,794 +30,587 @@ * * Modification Log: * ----------------- - * .01 02-24-89 lrd modified for vxWorks 4.0 - * changed spawn to taskSpawn and changed args - * .02 02-24-89 lrd moved task info into task_params.h - * linked to vw for vx include files - * .03 02-28-89 lrd added check in build_scan_lists to verify the - * database section is loaded - * .04 03-14-89 lrd change task id's to int - * .05 03-23-89 lrd add restart logic - * .06 03-27-89 lrd modified to use the dbcommon structure - * deleted subroutine set_alarm - * .07 04-05-89 lrd added flag to signal drivers when we're ready to - * accept events - * .08 05-03-89 lrd removed process mask from dbProcess calls - * .09 05-25-89 lrd added support for the PID record - * .10 06-06-89 lrd added support for the SEL record - * .11 06-28-89 lrd only give undefined event msg on the first - * occurance of the event - keep a list of the - * undefined ones - * .10 07-21-89 lrd added support for the COMPRESS record - * .11 01-25-90 lrd added support for SUB records - * .12 04-05-90 lrd added the callback output task - * .13 05-22-89 mrk periodic scan now scans at correct rate - * .14 08-08-90 lrd removed T_AI from initialization at start up - * only outputs need to be read at initialization - * .15 08-30-90 lrd renamed the interrupt scanner wakeup from - * intr_event_poster to io_scanner_wakeup - * .16 09-14-90 mrk changed for new record/device support - * .17 10-24-90 mrk replaced momentary task by general purpose callback task - * .18 08-30-91 joh updated for V5 vxWorks - * .19 09-30-91 mrk added intLock to callbackRequest - * .20 11-26-91 jba prevented multiple error messages for ioEventTask - * initialized status in add_to_scan_list - * .21 12-02-91 jba Added cmd control to io-interrupt processing - * .22 12-12-91 jba Initialized cmd to 1 in delete_from_scan_list - * jba Placed remove scan tasks before initialize all the fast locks + * .18 07-18-91 mrk major revision + * .19 02-05-92 jba Changed function arguments from paddr to precord */ - -/* - * Code Portions: - * - * periodicScanTask Task which processes the periodic records - * ioEventTask Task which processes records on I/O interrupt - * eventTask Task which processes records on global events - * wdScanTask Task which restarts other tasks when suspended - * callbackTask General purpose callback task - * callbackRequest request callback - * arg - * pointer to arbitrary structure with first element being - * address of callback routine. When called addr of - * structure is passed. - * scan_init Build the scan lists and start the tasks - * remove_scan_tasks Delete scan tasks, free any malloc'd memory - * args - * tasks flags which tasks to remove - * build_scan_lists Looks through database and builds scan lists - * args - * lists flags which lists to build - * intialize_ring_buffers Initializes the ring buffers for the events - * args - * lists flags which ring buffers to initialize - * start_scan_tasks Start the scan tasks - * args - * tasks flags which scan tasks to start - * add_to_scan_list Adds an entry to a scan list - * args - * paddr pointer to this record - * lists which lists to build - * add_to_periodic_list Add an entry to the periodic scan list - * args - * paddr pointer to this record - * phase phase on which this record is scanned - * list_index which periodic list to place this record on - * returns - * 0 successful - * -1 failed - * add_to_io_event_list Add an entry to the I/O event list - * args - * paddr pointer to this record - * phase phase on which this record is scanned - * io_type I/O type of this record - * card_type card type of this records input - * card_number card number of this records input - * returns - * 0 successful - * -1 failed - * add_to_event_list Add an entry to the global event scanner - * args - * paddr pointer to this record - * phase phase on which this record is scanned - * event event on which this record will be scanned - * returns - * 0 successful - * -1 failed - * delete_from_scan_list Delete an entry from a scan list - * args - * paddr pointer to this record - * returns - * 0 successful - * -1 failed - * - * delete_from_periodic_list Delete an entry from the periodic scan list - * args - * paddr pointer to this record - * list_index which periodic list to remove this record from - * returns - * 0 successful - * -1 failed - * delete_from_io_event_list Delete an entry from the I/O event list - * args - * paddr pointer to this record - * phase phase on which this record is scanned - * io_type i/o type of this record - * card_type type of this records io card - * card_number card number of this record - * returns - * 0 successful - * -1 failed - * delete_from_event_list Delete an entry from the global event list - * args - * paddr pointer to this record - * phase phase on which this record is scanned - * event event on which this record is scanned - * returns - * 0 successful - * -1 failed - * get_io_info get io_type,card_type,card_number - * args - * paddr - * &pio_type - * &card_type - * &card_number - * print_lists Prints the periodic scan lists - * print_io_event_lists Print the I/O event lists - * print_event_lists Print the event lists - * - * io_scanner_wakeup Post an I/O event - * args - * io_type io type from which the event has come - * card_type card type from which the event has come - * card_number card number from which the event has come -} - * post_event Post an event - * args - * event event number - */ - + #include +#include #include -#include -#include /* library for semaphore support */ -#include /* library for ring buffer support */ +#include +#include +#include #include -#include #include +#include +#include +#include #include #include #include -#include -#include #include -#include #include - -/* local routines */ -static int add_to_periodic_list(); -static int add_to_io_event_list(); -static int add_to_event_list(); -static int delete_from_periodic_list(); -static int delete_from_io_event_list(); -static int delete_from_event_list(); -static long get_io_info(); - - - -typedef unsigned long TIME; +extern volatile int interruptAccept; -/* number of addr records in each set (malloc'ed at a time) */ -#define NUM_RECS_PER_SET 100 -#define NUM_SETS 4 - -/* db address struct: will contain the scan lists for all tasks */ struct scan_list{ FAST_LOCK lock; - unsigned short scan_type; - unsigned short num_records; - unsigned short num_scan; - unsigned short scan_index; - unsigned short set; - unsigned short index; - unsigned int diagnostic; - struct scan_element *pscan; - struct scan_element *psets[NUM_SETS]; + LIST list; + short modified;/*has list been modified?*/ + long ticks; /*ticks per period for periodic*/ }; -/* scan types */ -/* These must match the GBL_SCAN choices in choiceGbl.ascii */ -/* NOTE NOTE recAi.c and recWaveform.c both use E_IO_INTERRUPT*/ -#define PASSIVE 0 -#define P2SECOND 1 -#define PSECOND 2 -#define PHALFSECOND 3 -#define PFIFTHSECOND 4 -#define PTENTHSECOND 5 -#define E_EXTERNAL 6 -#define E_IO_INTERRUPT 7 - -#define SL2SECOND 0 -#define SLSECOND 1 -#define SLHALFSECOND 2 -#define SLFIFTHSECOND 3 -#define SLTENTHSECOND 4 -#define NUM_LISTS (SLTENTHSECOND+1) - +/*scan_elements are allocated and the address stored in dbCommon.spvt*/ struct scan_element{ - struct dbAddr dbAddr; - short phase; + NODE node; + struct scan_list *pscan_list; + struct dbCommon *precord; }; -#define PERIOD_BASE_RATE 6 /* 60 ticks per second */ +int volatile scanRestart=FALSE; -/* I/O event driven scanner information */ +/* PERIODIC SCANNER */ +static int nPeriodic=0; +static struct scan_list **papPeriodic; /* pointer to array of pointers*/ +static int *periodicTaskId; /*array of integers after allocation*/ -#define IO_EVENT_PRIORITY 99 -#define MAX_IO_EVENTS 10 -#define MAX_IO_EVENT_CHANS 32 -struct io_event_list{ - FAST_LOCK lock; - short defined; - short io_type; - short card_type; - short card_number; - short number_defined; - struct scan_element element[MAX_IO_EVENT_CHANS]; -}; - - -/* Event driven scanner information */ -#define MAX_EVENTS 100 -#define MAX_EVENT_CHANS 10 -struct event_list{ - FAST_LOCK lock; - short defined; - short event_number; - short number_defined; - struct scan_element element[MAX_EVENT_CHANS]; -}; - - - -/* initialization field in database records */ -#define ARCH_INIT 2 /* first archive msg sent */ - - - -#define IO_EVENT 0x01 -#define EVENT 0x02 -#define PERIODIC 0x04 -#define WDSCAN 0x08 -#define CALLBACK 0x10 - -int fd; /* used for the print list diagnostics */ - -/* link to the interrupable table from module_types.h */ -extern short *pinterruptable[]; - -/* PERIODIC SCANNER GLOBALS */ -/* periodic scan lists */ -static struct scan_list lists[NUM_LISTS]; - -/* number of periods in each scan list */ -static short periods_to_complete[] = {20,10,5,2,1}; - -static int periodicScanTaskId = 0; - - -/* I/O EVENT GLOBALS */ -/* I/O event scan list */ -static struct io_event_list io_event_lists[MAX_IO_EVENTS]; -static struct io_event_list io_events_undefined[MAX_IO_EVENTS]; - -/* semaphore on which the I/O scan task waits */ -static SEMAPHORE ioEventSem; - -/* ring buffer into which the drivers place the events which occured */ -static RING_ID ioEventQ; - -static int ioEventTaskId = 0; - - -/* EVENT GLOBALS */ -/* Event scan list */ -static struct event_list event_lists[MAX_EVENTS]; - -/* semaphore on which the I/O scan task waits */ -static SEMAPHORE eventSem; - -/* ring buffer into which the drivers place the events which occured */ +/* EVENT */ +#define MAX_EVENTS 256 +#define EVENT_QUEUE_SIZE 1000 +static struct scan_list *papEvent[MAX_EVENTS];/*array of pointers*/ +static SEM_ID eventSem; static RING_ID eventQ; +static int eventTaskId; -static int eventTaskId = 0; - - -/* WATCHDOG GLOBALS */ -static int wdScanTaskId = 0; -static int wdScanOff = 0; -int wdRestart=0; - - -/* CALLBACK GLOBALS */ -static SEMAPHORE callbackSem; -static RING_ID callbackQ; -static int callbackTaskId = 0; -struct callback { - void (*callback)(); - int priority; - /*remainder is callback dependent*/ +/* IO_EVENT*/ +struct io_scan_list { + CALLBACK callback; + struct scan_list scan_list; + struct io_scan_list *next; }; -/* flag to the drivers that they can start to send events to the event tasks */ -short wakeup_init; +static struct io_scan_list *iosl_head[NUM_CALLBACK_PRIORITIES]={NULL,NULL,NULL}; +/* Private routines */ +void periodicTask(); /*Periodic scan task */ +void initPeriodic(); /*Initialize the periodic variables */ +void spawnPeriodic(); /*Spawn the periodTasks */ +void wdPeriodic(); /*watchdog callback for periodicTasks */ +void eventTask(); /*Periodic scan task */ +void initEvent(); /*Initialize the event variables */ +void spawnEvent(); /*Spawn the eventTask */ +void wdEvent(); /*watchdog callback for eventTask */ +void ioeventCallback(); /*ioevent callback */ +void printList(); /*print a scan list */ + +void scanList(); /*Scan a scan list */ +void buildScanLists(); /*Build scan lists */ +void addToList(); /*add element to a list */ +void deleteFromList(); /*delete element from a list */ -/* - * periodicScanTask - * - * scan all periodic scan lists - */ -periodicScanTask() -{ - long start_time,delay; - register short list,scan; - register struct scan_list *plist; - short disableListScan[NUM_LISTS]; - short periodsComplete[NUM_LISTS]; - int i; - - for(i=0; i < NUM_LISTS; i++){ - periodsComplete[i] = 0; - disableListScan[i] = FALSE; - } - - while(1){ - - /* get the start timex */ - start_time = tickGet(); - - /* do for all records */ - plist = &lists[0]; - for (list = 0; list < NUM_LISTS; list++,plist++){ - if (plist->num_records == 0){ - continue; - } - - /*enable processing list every periods_to_complete*/ - if(periodsComplete[list] >= periods_to_complete[list] ){ - disableListScan[list] = FALSE; - periodsComplete[list] = 0; - } - periodsComplete[list]++; - /*after processing all records in list , wait until enabled*/ - if(disableListScan[list]) continue; - - /* lock the list */ - FASTLOCK(&plist->lock); - - /* process each set in each scan list */ - for (scan=0; scan < plist->num_scan; scan++){ - struct dbAddr *paddr=&plist->pscan->dbAddr; - struct dbCommon *precord= - (struct dbCommon *)(paddr->precord); - - /* process this record */ - dbScanLock(precord); - dbProcess(paddr); - dbScanUnlock(precord); - - /* get the pointer to the next record */ - plist->scan_index++; - plist->index++; - if (plist->scan_index >= plist->num_records){ - /*when all records in list processed*/ - /* disable processing list*/ - plist->index = 0; - plist->set = 0; - plist->scan_index = 0; - plist->pscan = plist->psets[0]; - disableListScan[list] = TRUE; - break; - }else if (plist->index >= NUM_RECS_PER_SET){ - plist->index = 0; - plist->set++; - if (plist->set > NUM_SETS) plist->set = 0; - plist->pscan = plist->psets[plist->set]; - }else{ - plist->pscan++; - } - } - /* unlock it */ - FASTUNLOCK(&plist->lock); - } - - /* sleep until next tenth second */ - delay = 60/10 - (tickGet() - start_time); - if (delay > 0) - taskDelay(delay); - } -} - -/* - * ioEventTask - * - * interrupt event scanner - */ -ioEventTask() -{ - struct intr_event intr_event; - register short event_index; - register short index; - register short found; - register struct io_event_list *pio_event_list; - register struct scan_element *pelement; - register struct intr_event *pintr_event = &intr_event; - - /* forever */ - FOREVER { - /* wait for somebody to wake us up */ -# ifdef V5_vxWorks - semTake(&ioEventSem, WAIT_FOREVER); -# else - semTake(&ioEventSem); -# endif - - /* process requests in the command ring buffer */ - while (rngNBytes(ioEventQ)>=INTR_EVENT_SZ){ - rngBufGet(ioEventQ,pintr_event,INTR_EVENT_SZ); - /* find the event list */ - event_index = 0; - pio_event_list = &io_event_lists[0]; - found = FALSE; - while ((event_index < MAX_IO_EVENTS) && (!found)){ - if ((pio_event_list->defined) - && ((pio_event_list->io_type == pintr_event->io_type) - && (pio_event_list->card_type == pintr_event->card_type) - && (pio_event_list->card_number == pintr_event->card_number))){ - found = TRUE; - }else{ - pio_event_list++; - event_index++; - } - } - if (!found){ - /* only give a message the first time an undefined */ - /* event occurs */ - pio_event_list = &io_events_undefined[0]; - found = FALSE; - event_index=0; - while ((event_index < MAX_IO_EVENTS) && (!found) && (pio_event_list->defined)){ - if ((pio_event_list->io_type == pintr_event->io_type) - && (pio_event_list->card_type == pintr_event->card_type) - && (pio_event_list->card_number == pintr_event->card_number)){ - found = TRUE; - }else{ - pio_event_list++; - event_index++; - } - } - if (!found){ - printf("no event list for iotype: %d card type: %d card number: %d\n", - pintr_event->io_type, - pintr_event->card_type, - pintr_event->card_number); - - /* add this to the list */ - if (pio_event_list->defined == 0){ - pio_event_list->defined = 1; - pio_event_list->io_type = pintr_event->io_type; - pio_event_list->card_type = pintr_event->card_type; - pio_event_list->card_number = pintr_event->card_number; - } - } - continue; - } - - /* process each record in the scan list */ - FASTLOCK(&pio_event_list->lock); /* lock it */ - index = 0; - pelement = &pio_event_list->element[0]; - while (index < pio_event_list->number_defined){ - struct dbAddr *paddr=&pelement->dbAddr; - struct dbCommon *precord= - (struct dbCommon *)(paddr->precord); - - /* process this record */ - dbScanLock(precord); - dbProcess(paddr); - dbScanUnlock(precord); - - pelement++; - index++; - } - FASTUNLOCK(&pio_event_list->lock); /* unlock it */ - } - } -} - -/* - * eventTask - * - * event scanner - */ -eventTask() -{ - short event; - register short event_index; - register short index; - register short found; - register struct event_list *pevent_list; - register struct scan_element *pelement; - - /* forever */ - FOREVER { - /* wait for somebody to wake us up */ -# ifdef V5_vxWorks - semTake(&eventSem, WAIT_FOREVER); -# else - semTake(&eventSem); -# endif - - /* process requests in the command ring buffer */ - while (rngNBytes(eventQ)>=sizeof(short)){ - rngBufGet(eventQ,&event,sizeof(short)); - - /* find the event list */ - event_index = 0; - pevent_list = &event_lists[0]; - found = FALSE; - while ((event_index < MAX_EVENTS) && (!found)){ - if ((pevent_list->defined) - && (pevent_list->event_number == event)){ - found = TRUE; - }else{ - pevent_list++; - event_index++; - } - } - if (!found){ - printf("no event list for event: %d\n",event); - continue; - } - - /* process each record in the scan list */ - FASTLOCK(&pevent_list->lock); /* lock it */ - index = 0; - pelement = &pevent_list->element[0]; - while (index < pevent_list->number_defined){ - struct dbAddr *paddr=&pelement->dbAddr; - struct dbCommon *precord= - (struct dbCommon *)(paddr->precord); - - /* process this record */ - dbScanLock(precord); - dbProcess(paddr); - dbScanUnlock(precord); - - pelement++; - index++; - } - FASTUNLOCK(&pevent_list->lock); /* unlock it */ - } - } -} - -/* - * wdScanTask - * - * watch dog scan task - */ -wdScanTask() -{ - short lists; - - while(1){ - - /* verify the watchdog is desired */ - if (wdScanOff == 0){ - lists = 0; - - /* check the I/O Event Task */ - if (taskIsSuspended(ioEventTaskId)){ - printf("wdScanTask: Restarting ioEventTask\n"); - lists |= IO_EVENT; - } - - /* check the Event Task */ - if (taskIsSuspended(eventTaskId)){ - printf("wdScanTask: Restarting eventTask\n"); - lists |= EVENT; - } - - /* check the Periodic Scan Task */ - if (taskIsSuspended(periodicScanTaskId)){ - printf("wdScanTask: Restarting periodicScanTask\n"); - lists |= PERIODIC; - } - - /* if any are suspended - restart them */ - if (lists && wdRestart){ - /* remove scan tasks */ - remove_scan_tasks(lists); - - /* build the scan lists */ - build_scan_lists(lists); - - /* create event ring buffers */ - initialize_ring_buffers(lists); - - /* Spawn scanner tasks */ - start_scan_tasks(lists); - } - } - - /* sleep awhile */ - taskDelay(WDSCAN_DELAY); - } -} - -/* General purpose callback task */ -callbackTask(){ - struct callback *pcallback; - - FOREVER { - /* wait for somebody to wake us up */ -# ifdef V5_vxWorks - semTake (&callbackSem, WAIT_FOREVER); -# else - semTake (&callbackSem); -# endif - - /* process requests in the command ring buffer */ - while(rngNBytes(callbackQ)>=sizeof(pcallback)) { - rngBufGet(callbackQ,&pcallback,sizeof(pcallback)); - (*pcallback->callback)(pcallback); - } - } -} - -/* Routine which places requests into callback queue*/ -callbackRequest(pcallback) - struct callback *pcallback; -{ - int priority = pcallback->priority; - int lockKey; - int nput; - - /* multiple writers are possible so block interrupts*/ - lockKey = intLock(); - nput = rngBufPut(callbackQ,&pcallback,sizeof(pcallback)); - intUnlock(lockKey); - if(nput!=sizeof(pcallback)) logMsg("callbackRequest ring buffer full"); - semGive(&callbackSem); -} - -/* - * SCAN_INIT - * - * scanner intialization code: - * builds scan lists - * spawns the scan and watchdog tasks - */ -scan_init() +long scanInit() { int i; - /* remove scan tasks */ - remove_scan_tasks(EVENT | IO_EVENT | PERIODIC | CALLBACK); + initPeriodic(); + initEvent(); + scan_init(); /*old IO_EVENT_SCAN*/ + buildScanLists(); + for (i=0;i=MAX_EVENTS) { + logMsg("illegal event passed to post_event\n"); + return; } - for(i=0; iscan; + if(scan==SCAN_PASSIVE) return; + if(scan<0 || scan>= nPeriodic+SCAN_1ST_PERIODIC) { + recGblRecordError(-1,precord,"scanAdd detected illegal SCAN value"); + }else if(scan==SCAN_EVENT) { + unsigned char evnt; + + if(precord->evnt<0 || precord->evnt>=MAX_EVENTS) { + recGblRecordError(S_db_badField,precord,"scanAdd detected illegal EVNT value"); + return; + } + evnt = (signed)precord->evnt; + psl = papEvent[evnt]; + if(psl==NULL) { + psl = calloc(1,sizeof(struct scan_list)); + papEvent[precord->evnt] = psl; + FASTLOCKINIT(&psl->lock); + lstInit(&psl->list); + } + addToList(precord,psl); + } else if(scan==SCAN_IO_EVENT) { + short cmd=0; + struct io_scan_list *piosl; + int priority,dummy1,dummy2; + DEVSUPFUN get_ioint_info=precord->dset->get_ioint_info; + + if(get_ioint_info==NULL) return; + if(get_ioint_info(&cmd,precord,&piosl,&dummy1,&dummy2)) return;/*return if error*/ + if(cmd==-1) { + add_to_scan_list(precord); /*old IO_EVENT_SCAN*/ + } else { + if(piosl==NULL) return; + priority = precord->prio; + if(priority<0 || priority>=NUM_CALLBACK_PRIORITIES) { + recGblRecordError(-1,precord,"scanAdd: illegal prio field"); + return; + } + piosl += priority; /* get piosl for correct priority*/ + addToList(precord,&piosl->scan_list); + } + } else if(scan>=SCAN_1ST_PERIODIC) { + int ind; + + ind = scan - SCAN_1ST_PERIODIC; + psl = papPeriodic[ind]; + addToList(precord,psl); } - for(i=0; iscan; + if(scan==SCAN_PASSIVE) return; + if(scan<0 || scan>= nPeriodic+SCAN_1ST_PERIODIC) { + recGblRecordError(-1,precord,"scanDelete detected illegal SCAN value"); + }else if(scan==SCAN_EVENT) { + unsigned char evnt; - /* delete the ioEventTask if it is running */ - if (tasks & IO_EVENT){ - if (ioEventTaskId) - if (td(ioEventTaskId) != 0) - ioEventTaskId = 0; + if(precord->evnt<0 || precord->evnt>=MAX_EVENTS) { + recGblRecordError(S_db_badField,precord,"scanDelete detected illegal EVNT value"); + return; + } + evnt = (signed)precord->evnt; + psl = papEvent[evnt]; + if(psl==NULL) + recGblRecordError(-1,precord,"scanDelete for bad evnt"); + else + deleteFromList(precord,psl); + } else if(scan==SCAN_IO_EVENT) { + short cmd=1; + struct io_scan_list *piosl; + int priority,dummy1,dummy2; + DEVSUPFUN get_ioint_info=precord->dset->get_ioint_info; - /* initialize the IO event lists */ - fill(io_event_lists,sizeof(struct event_list)*MAX_IO_EVENTS,0); - } - - /* delete the eventTask if it is running */ - if (tasks & EVENT){ - if (eventTaskId) - if (td(eventTaskId) != 0) - eventTaskId = 0; - - /* initialize the event lists */ - fill(event_lists,sizeof(struct event_list)*MAX_EVENTS,0); - } - - /* delete the callbackTask if it is running */ - if (tasks & CALLBACK){ - if (callbackTaskId) - if (td(callbackTaskId) != 0) - callbackTaskId = 0; - } - - /* delete the periodicScanTask if it is running */ - if (tasks & PERIODIC){ - if (periodicScanTaskId){ - if (td(periodicScanTaskId) != 0) - periodicScanTaskId = 0; - for(list_index = 0; list_index < NUM_LISTS; list_index++){ - for (set = 0; set < NUM_SETS; set++){ - if (lists[list_index].psets[set]){ - free(lists[list_index].psets[set]); - } - } - } + if(get_ioint_info==NULL) return; + if(get_ioint_info(&cmd,precord,&piosl,&dummy1,&dummy2)) return;/*return if error*/ + if(cmd==-1) { + delete_from_scan_list(precord); /*old IO_EVENT_SCAN*/ + } else { + priority = precord->prio; + if(priority<0 || priority>=NUM_CALLBACK_PRIORITIES) { + recGblRecordError(-1,precord,"scanDelete: get_ioint_info returned illegal priority"); + return; } + piosl += priority; /*get piosl for correct priority*/ + deleteFromList(precord,&piosl->scan_list); + } + } else if(scan>=SCAN_1ST_PERIODIC) { + int ind; - /* initialize the scan lists */ - fill(lists,sizeof(lists),0); + ind = scan - SCAN_1ST_PERIODIC; + psl = papPeriodic[ind]; + deleteFromList(precord,psl); } - - /* delete the watchdog scan task */ - if (tasks & WDSCAN){ - if (wdScanTaskId){ - if (td(wdScanTaskId) != 0) - wdScanTaskId = 0; - } - } - + return; } -/* - * BUILD_SCAN_LISTS - * - * build the specified scan lists - */ -build_scan_lists(lists) -register short lists; +int scanppl() /*print periodic list*/ { + struct scan_list *psl; + char message[80]; + double period; + int i; + + for (i=0; iticks; + period /= vxTicksPerSecond; + sprintf(message,"Scan Period= %f seconds\n",period); + printList(psl,message); + } + return(0); +} + +int scanpel() /*print event list */ +{ + struct scan_list *psl; + char message[80]; + int i; + + for (i=0; iscan_list,message); + piosl=piosl->next; + } + } + return(0); +} + +void scanIoInit(IOSCANPVT *ppioscanpvt) +{ + struct io_scan_list *piosl; + int priority; + + /* allocate an array of io_scan_lists. One for each priority */ + /* IOSCANPVT will hold the address of this array of structures */ + *ppioscanpvt=calloc(NUM_CALLBACK_PRIORITIES,sizeof(struct io_scan_list)); + for(priority=0, piosl=*ppioscanpvt; + prioritycallback.callback = ioeventCallback; + piosl->callback.priority = priority; + lstInit(&piosl->scan_list.list); + FASTLOCKINIT(&piosl->scan_list.lock); + piosl->next=iosl_head[priority]; + iosl_head[priority]=piosl; + } + +} + + +void scanIoRequest(IOSCANPVT pioscanpvt) +{ + struct io_scan_list *piosl; + int priority; + + if(!interruptAccept) return; + for(priority=0, piosl=pioscanpvt; + priorityscan_list.list)>0) callbackRequest((void *)piosl); + } +} + +static void periodicTask(struct scan_list *psl) +{ + + unsigned long start_time,end_time; + long delay; + struct scan_element *pse,*prev,*next; + + start_time = tickGet(); + while(TRUE) { + if(interruptAccept)scanList(psl); + end_time = tickGet(); + delay = psl->ticks - (end_time - start_time); + if(delay<=0) delay=1; + taskDelay(delay); + start_time = end_time + delay; + } +} + + +static void initPeriodic() +{ + struct { + DBRenumStrs + } scanChoices; + struct scan_list *psl; struct dbAddr dbAddr; /* database address */ + struct recLoc *precLoc; + struct dbCommon *precord=NULL; /* pointer to record */ + long status,nRequest,options; + void *pfl=NULL; + int i,j; + char name[PVNAME_SZ+FLDNAME_SZ+2]; + float temp; + + if(dbRecords==NULL) { + errMessage(S_record_noRecords, "initPeriodic"); + exit(1); + } + /* look for first record */ + for (i=0; inumber; i++) { + if((precLoc=dbRecords->papRecLoc[i])==NULL) continue; + for(j=0, precord=(struct dbCommon*)(precLoc->pFirst); + jno_records; + j++, ((char *)precord) += precLoc->rec_size) { + if(precord->name[0]!=0) goto got_record; + } + } + errMessage(S_record_noRecords,"initPeriodic"); + exit(1); +got_record: + /* get database address of SCAN field */ + name[PVNAME_SZ+1] = 0; + strncpy(name,precord->name,PVNAME_SZ); + strcat(name,".SCAN"); + if ((status=dbNameToAddr(name,&dbAddr)) != 0){ + recGblDbaddrError(status,&dbAddr,"initPeriodic"); + exit(1); + } + options = DBR_ENUM_STRS; + nRequest = 0; + status = dbGetField(&dbAddr,DBR_ENUM,&scanChoices,&options,&nRequest,pfl); + if(status) { + recGblDbaddrError(status,&dbAddr,"initPeriodic"); + exit(1); + } + nPeriodic = scanChoices.no_str - SCAN_1ST_PERIODIC; + papPeriodic = calloc(nPeriodic,sizeof(struct scan_list *)); + if(papPeriodic==NULL) { + errMessage(-1,"initPeriodic calloc failure"); + exit(1); + } + periodicTaskId = calloc(nPeriodic,sizeof(int)); + if(periodicTaskId==NULL) { + errMessage(-1,"initPeriodic calloc failure"); + exit(1); + } + for(i=0; ilock); + lstInit(&psl->list); + sscanf(scanChoices.strs[i+SCAN_1ST_PERIODIC],"%f",&temp); + psl->ticks = temp * vxTicksPerSecond; + } +} + +static void spawnPeriodic(int ind) +{ + struct scan_list *psl; + + psl = papPeriodic[ind]; + periodicTaskId[ind] = taskSpawn(PERIODSCAN_NAME,PERIODSCAN_PRI-ind, + PERIODSCAN_OPT,PERIODSCAN_STACK, + (FUNCPTR )periodicTask,psl); + taskwdInsert(periodicTaskId[ind],wdPeriodic,(void *)(long)ind); +} + +static void wdPeriodic(long ind) +{ + struct scan_list *psl; + + psl = papPeriodic[ind]; + taskwdRemove(periodicTaskId[ind]); + if(!scanRestart)return; + FASTUNLOCK(&psl->lock); + spawnPeriodic(ind); +} + +static void eventTask() +{ + unsigned char event; + struct scan_element *pse,*prev,*next; + struct scan_list *psl; + + while(TRUE) { + if(semTake(eventSem,WAIT_FOREVER)!=OK) + logMsg("semTake returned error in eventTask\n"); + while (rngNBytes(eventQ)>=sizeof(unsigned char)){ + if(rngBufGet(eventQ,(void *)&event,sizeof(unsigned char))!=sizeof(unsigned char)) + logMsg("rngBufGet returned error in eventTask\n"); + if(event<0 || event>MAX_EVENTS-1) { + errMessage(-1,"eventTask received an illegal event"); + continue; + } + if(papEvent[event]==NULL) continue; + psl = papEvent[event]; + if(psl) scanList(psl); + } + } +} + +static void initEvent() +{ + int i; + + for(i=0; ilock); + } + spawnEvent(); +} + +static void ioeventCallback(struct io_scan_list *piosl) +{ + struct scan_list *psl=&piosl->scan_list; + + scanList(psl); +} + + +static void printList(struct scan_list *psl,char *message) +{ + struct scan_element *pse; + + FASTLOCK(&psl->lock); + (void *)pse = lstFirst(&psl->list); + FASTUNLOCK(&psl->lock); + if(pse==NULL) return; + printf("%s\n",message); + while(pse!=NULL) { + printf(" %-28s\n",pse->precord->name); + FASTLOCK(&psl->lock); + if(pse->pscan_list != psl) { + FASTUNLOCK(&psl->lock); + printf("Returning because list changed while processing."); + return; + } + (void *)pse = lstNext((void *)pse); + FASTUNLOCK(&psl->lock); + } +} + +static void scanList(struct scan_list *psl) +{ + /*In reading this code remember that the call to dbProcess can result*/ + /*in the SCAN field being changed in an arbitrary number of records */ + + struct scan_element *pse,*prev,*next; + + FASTLOCK(&psl->lock); + psl->modified = FALSE; + (void *)pse = lstFirst(&psl->list); + prev = NULL; + (void *)next = lstNext((void *)pse); + FASTUNLOCK(&psl->lock); + while(pse!=NULL) { + struct dbCommon *precord = pse->precord; + + dbScanLock(precord); + dbProcess(precord); + dbScanUnlock(precord); + FASTLOCK(&psl->lock); + if(!psl->modified) { + prev = pse; + (void *)pse = lstNext((void *)pse); + if(pse!=NULL) (void *)next = lstNext((void *)pse); + } else if (pse->pscan_list==psl) { + /*This scan element is still in same scan list*/ + prev = pse; + (void *)pse = lstNext((void *)pse); + if(pse!=NULL) (void *)next = lstNext((void *)pse); + psl->modified = FALSE; + } else if (prev!=NULL && prev->pscan_list==psl) { + /*Previous scan element is still in same scan list*/ + (void *)pse = lstNext((void *)prev); + if(pse!=NULL) { + (void *)prev = lstPrevious((void *)pse); + (void *)next = lstNext((void *)pse); + } + psl->modified = FALSE; + } else if (next!=NULL && next->pscan_list==psl) { + /*Next scan element is still in same scan list*/ + pse = next; + (void *)prev = lstPrevious((void *)pse); + (void *)next = lstNext((void *)pse); + psl->modified = FALSE; + } else { + /*Too many changes. Just wait till next period*/ + FASTUNLOCK(&psl->lock); + return; + } + FASTUNLOCK(&psl->lock); + } +} + +static void buildScanLists() +{ struct recLoc *precLoc; struct dbCommon *precord; /* pointer to record */ - long status; int i,j; if(dbRecords==NULL) { errMessage(S_record_noRecords, "Error detected in build_scan_lists"); - exit(0); + exit(1); } /* look through all of the database records and place them on lists */ for (i=0; inumber; i++) { @@ -825,987 +620,60 @@ register short lists; j++, precord = (struct dbCommon *) ((char *)precord + precLoc->rec_size)) { if(precord->name[0]==0) continue; - /* get database address from access routines */ - if ((status=dbNameToAddr(precord->name,&dbAddr)) == 0){ - /* add it to a scan list */ - add_to_scan_list(&dbAddr,lists); - } else { - recGblDbaddrError(status,&dbAddr, - "build_scan_lists"); - } + scanAdd(precord); } } } -/* - * INITIALIZE_RING_BUFFERS - * - * initialize the ring buffers for the event tasks - */ -initialize_ring_buffers(lists) -register short lists; +static void addToList(struct dbCommon *precord,struct scan_list *psl) { - /* create the interrupt event ring buffer and semaphore */ - if (lists & IO_EVENT){ - /* clear it if it is created */ - if (ioEventQ){ - rngFlush(ioEventQ); - /* create it if it does not exist */ - }else if ((ioEventQ = rngCreate(INTR_EVENT_SZ * MAX_EVENTS)) - == (RING_ID)NULL){ - panic ("scan_init: ioEventQ not created\n"); + struct scan_element *pse,*ptemp; + + FASTLOCK(&psl->lock); + pse = (struct scan_element *)(precord->spvt); + if(pse==NULL) { + pse = calloc(1,sizeof(struct scan_element)); + if(pse==NULL) { + recGblRecordError(-1,precord,"addToList calloc error"); + exit(1); } - semInit(&ioEventSem); + precord->spvt = (void *)pse; + (void *)pse->precord = precord; } - - /* create the event ring buffer and semaphore */ - if (lists & EVENT){ - /* clear it if it is created */ - if (eventQ){ - rngFlush(eventQ); - /* create it if it does not exist */ - }else if ((eventQ = rngCreate(sizeof(short) * MAX_EVENTS)) - == (RING_ID)NULL){ - panic ("scan_init: eventQ not created\n"); + pse ->pscan_list = psl; + (void *)ptemp = lstFirst(&psl->list); + while(ptemp!=NULL) { + if(ptemp->precord->phas>precord->phas) { + lstInsert(&psl->list, + lstPrevious((void *)ptemp),(void *)pse); + break; } - semInit(&eventSem); - } - - /* create the callback ring buffer and semaphore */ - if (lists & CALLBACK){ - /* clear it if it is created */ - if (callbackQ){ - rngFlush(callbackQ); - /* create it if it does not exist */ - }else if ((callbackQ = rngCreate(sizeof(struct callback *) * MAX_EVENTS)) - == (RING_ID)NULL){ - panic ("scan_init: callbackQ not created\n"); - } - semInit(&callbackSem); - } -} - -/* - * START_SCAN_TASKS - * - * start the specified scan tasks - * parameters are from task_params.h - */ -start_scan_tasks(tasks) -register short tasks; -{ - if (tasks & IO_EVENT){ - ioEventTaskId = - taskSpawn(IOEVENTSCAN_NAME, - IOEVENTSCAN_PRI, - IOEVENTSCAN_OPT, - IOEVENTSCAN_STACK, - ioEventTask); - } - - if (tasks & EVENT){ - eventTaskId = - taskSpawn(EVENTSCAN_NAME, - EVENTSCAN_PRI, - EVENTSCAN_OPT, - EVENTSCAN_STACK, - eventTask); - } - - if (tasks & PERIODIC){ - periodicScanTaskId = - taskSpawn(PERIODSCAN_NAME, - PERIODSCAN_PRI, - PERIODSCAN_OPT, - PERIODSCAN_STACK, - periodicScanTask); - } - - if (tasks & WDSCAN){ - wdScanTaskId = - taskSpawn(WDSCAN_NAME, - WDSCAN_PRI, - WDSCAN_OPT, - WDSCAN_STACK, - wdScanTask); - } - - if (tasks & CALLBACK){ - callbackTaskId = - taskSpawn(CALLBACK_NAME, - CALLBACK_PRI, - CALLBACK_OPT, - CALLBACK_STACK, - callbackTask); - } -} - -/* - * ADD_TO_SCAN_LIST - * - * add a new record's address to a scan list - */ -add_to_scan_list(paddr,lists) -register struct dbAddr *paddr; -register short lists; -{ - struct dbCommon *precord= (struct dbCommon *)(paddr->precord); - short scan_type; - short phase; - short event; - long status=0; - - /* get the list on which this record belongs */ - scan_type = precord->scan; - phase = precord->phas; - event = precord->evnt; - /* add to the periodic scan or the event list */ - switch (scan_type){ - case (PASSIVE): - break; - case (P2SECOND): - if (lists & PERIODIC) - status = - add_to_periodic_list(paddr,phase,SL2SECOND); - else - return; - break; - - case (PSECOND): - if (lists & PERIODIC) - status = - add_to_periodic_list(paddr,phase,SLSECOND); - else - return; - break; - case (PHALFSECOND): - if (lists & PERIODIC) - status = - add_to_periodic_list(paddr,phase,SLHALFSECOND); - else - return; - break; - case (PFIFTHSECOND): - if (lists & PERIODIC) - status = - add_to_periodic_list(paddr,phase,SLFIFTHSECOND); - else - return; - break; - case (PTENTHSECOND): - if (lists & PERIODIC) - status = - add_to_periodic_list(paddr,phase,SLTENTHSECOND); - else - return; - break; - case (E_IO_INTERRUPT): - if (lists & IO_EVENT) { - short io_type; - short card_type; - short card_number; - short cmd=0; - - status=get_io_info(&cmd,paddr,&io_type, - &card_type,&card_number); - if(status!=0) { - recGblDbaddrError(status,paddr, - "dbScan(get_io_info)"); - return; - } - if(cmd==0) status = add_to_io_event_list(paddr,phase, - io_type,card_type,card_number); - } else return; - break; - case (E_EXTERNAL): - if (lists & EVENT) - status = - add_to_event_list(paddr,phase,event); - else - return; - break; - default: - return; - } - - if (status < 0 && (precord->nsevnsta = SCAN_ALARM; - precord->nsev = MAJOR_ALARM; + (void *)ptemp = lstNext((void *)ptemp); } + if(ptemp==NULL) lstAdd(&psl->list,(void *)pse); + psl->modified = TRUE; + FASTUNLOCK(&psl->lock); return; } - -/* - * ADD_TO_PERIODIC_LIST - * - * add a new record's address to a periodic scan list - */ -static add_to_periodic_list(paddr,phase,list_index) -register struct dbAddr *paddr; -short phase; -short list_index; + +static void deleteFromList(struct dbCommon *precord,struct scan_list *psl) { - register short set,index,found; - register struct scan_element *pspare_element; - register struct scan_element *ptest_element; + struct scan_element *pse; - /* lock the list during modification */ - FASTLOCK(&lists[list_index].lock); /* lock it */ - - /* determine if we need to create a new set on this scan list */ - set = lists[list_index].num_records / NUM_RECS_PER_SET; - if ((lists[list_index].num_records % NUM_RECS_PER_SET) == 0){ - if (set >= NUM_SETS){ - FASTUNLOCK(&lists[list_index].lock); /* unlock it */ - return(-1); - } - if ((lists[list_index].psets[set] = - (struct scan_element *)malloc(NUM_RECS_PER_SET*sizeof(struct scan_element))) == 0){ - FASTUNLOCK(&lists[list_index].lock); /* unlock it */ - return(-1); - } - fill(lists[list_index].psets[set],NUM_RECS_PER_SET*sizeof(struct scan_element),0); + FASTLOCK(&psl->lock); + if(precord->spvt==NULL) { + FASTUNLOCK(&psl->lock); + return; } - - /* pointer to the slot at the end of the scan list */ - index = lists[list_index].num_records % NUM_RECS_PER_SET; - pspare_element = lists[list_index].psets[set]; - pspare_element += index; - - /* pointer to the last used slot in the scan list */ - index--; - if (index < 0){ - index = NUM_RECS_PER_SET - 1; - set--; - ptest_element = lists[list_index].psets[set]; - ptest_element += index; - }else{ - ptest_element = pspare_element - 1; + pse = (struct scan_element *)(precord->spvt); + if(pse==NULL || pse->pscan_list!=psl) { + FASTUNLOCK(&psl->lock); + errMessage(-1,"deleteFromList failed"); + return; } - - /* determine where this record belongs */ - found = FALSE; - while(!found){ - /* beginning of list or test record has higher or equal phase */ - if ((set < 0) || (ptest_element->phase <= phase)){ - /* put the new record into the spare space */ - pspare_element->dbAddr = *paddr; - pspare_element->phase = phase; - found = TRUE; - /* move the tested record into the spare record space */ - }else{ - *pspare_element = *ptest_element; - pspare_element = ptest_element; - } - - /* find the next test element */ - index--; - if (index < 0){ - index = NUM_RECS_PER_SET - 1; - set--; - ptest_element = lists[list_index].psets[set]; - ptest_element += index; - }else{ - ptest_element--; - } - } - - /* adjust the list information */ - lists[list_index].num_records++; - lists[list_index].num_scan = - ((lists[list_index].num_records - 1) / periods_to_complete[list_index]) + 1; - lists[list_index].pscan = lists[list_index].psets[0]; - lists[list_index].scan_index = 0; - lists[list_index].index = 0; - lists[list_index].set = 0; - - /* unlock it */ - FASTUNLOCK(&lists[list_index].lock); - - return(0); -} - -/* - * ADD_TO_IO_EVENT_LIST - * - * add a new record's address to an interrupt event scan list - */ -static add_to_io_event_list(paddr,phase,io_type,card_type,card_number) -register struct dbAddr *paddr; -short phase; -short io_type; -short card_type; -short card_number; -{ - struct io_event_list *pio_event_list; - struct scan_element *pelement; - struct scan_element *pspare; - register short event_index; - register short index; - register short found; - - /* verify this card has an interrupt */ - if (!pinterruptable[io_type][card_type]) - return(-1); - - /* is there a list for this iotype and card type */ - pio_event_list = &io_event_lists[0]; - event_index = 0; - found = FALSE; - while ((event_index < MAX_IO_EVENTS) && (!found)){ - if ((pio_event_list->defined) - && ((pio_event_list->io_type == io_type) - && (pio_event_list->card_type == card_type) - && (pio_event_list->card_number == card_number))){ - found = TRUE; - }else{ - pio_event_list++; - event_index++; - } - - } - - /* look for a spare list */ - if (!found){ - pio_event_list = &io_event_lists[0]; - event_index = 0; - found = FALSE; - while ((event_index < MAX_IO_EVENTS) && (!found)){ - if (!pio_event_list->defined){ - found = TRUE; - }else{ - pio_event_list++; - event_index++; - } - } - if (found){ - pio_event_list->defined = TRUE; - pio_event_list->io_type = io_type; - pio_event_list->card_type = card_type; - pio_event_list->card_number = card_number; - }else{ - return(-1); - } - } - - /* check for available space */ - if (pio_event_list->number_defined >= MAX_IO_EVENT_CHANS){ - return(-1); - } - - /* lock the list during modification */ - FASTLOCK(&pio_event_list->lock); - - /* add this record to the list */ - if (pio_event_list->number_defined == 0){ - pio_event_list->element[0].dbAddr = *paddr; - pio_event_list->element[0].phase = phase; - }else{ - index = pio_event_list->number_defined; - pspare = &pio_event_list->element[index]; - pelement = &pio_event_list->element[index-1]; - while ((pelement->phase > phase) && (index > 0)){ - *pspare = *pelement; - pelement--; - pspare--; - index--; - } - pspare->phase = phase; - pspare->dbAddr = *paddr; - } - pio_event_list->number_defined++; - - /* unlock the list */ - FASTUNLOCK(&pio_event_list->lock); - - return(0); -} - -/* - * ADD_TO_EVENT_LIST - * - * add a new record's address to an event scan list - */ -static add_to_event_list(paddr,phase,event) -register struct dbAddr *paddr; -short phase; -short event; -{ - struct event_list *pevent_list; - struct scan_element *pelement; - struct scan_element *pspare; - register short event_index; - register short index; - register short found; - - /* is there a list for this event */ - pevent_list = &event_lists[0]; - event_index = 0; - found = FALSE; - while ((event_index < MAX_EVENTS) && (!found)){ - if ((pevent_list->defined) - && (pevent_list->event_number == event)){ - found = TRUE; - }else{ - pevent_list++; - event_index++; - } - - } - - /* look for a spare list */ - if (!found){ - pevent_list = &event_lists[0]; - event_index = 0; - found = FALSE; - while ((event_index < MAX_EVENTS) && (!found)){ - if (!pevent_list->defined){ - found = TRUE; - }else{ - pevent_list++; - event_index++; - } - } - if (found){ - pevent_list->defined = TRUE; - pevent_list->event_number = event; - }else{ - return(-1); - } - } - - /* check for available space */ - if (pevent_list->number_defined >= MAX_EVENT_CHANS){ - return(-1); - } - - /* lock the list during modification */ - FASTLOCK(&pevent_list->lock); - - /* add this record to the list */ - if (pevent_list->number_defined == 0){ - pevent_list->element[0].dbAddr = *paddr; - pevent_list->element[0].phase = phase; - }else{ - index = pevent_list->number_defined; - pspare = &pevent_list->element[index]; - pelement = &pevent_list->element[index-1]; - while ((pelement->phase > phase) && (index > 0)){ - *pspare = *pelement; - pelement--; - pspare--; - index--; - } - pspare->phase = phase; - pspare->dbAddr = *paddr; - } - pevent_list->number_defined++; - - /* unlock the list */ - FASTUNLOCK(&pevent_list->lock); - - return(0); -} - -/* - * DELETE_FROM_SCAN_LIST - * - * delete a record's address from a scan list - */ -delete_from_scan_list(paddr) -register struct dbAddr *paddr; -{ - struct dbCommon *precord= (struct dbCommon *)(paddr->precord); - short scan_type; - short phase; - short event; - register short status; - - /* get the list on which this record belongs */ - scan_type = precord->scan; - phase = precord->phas; - event = precord->evnt; - /* add to the periodic scan or the event list */ - switch (scan_type){ - case (PASSIVE): - return(-1); - case (P2SECOND): - return(delete_from_periodic_list(paddr,SL2SECOND)); - case (PSECOND): - return(delete_from_periodic_list(paddr,SLSECOND)); - case (PHALFSECOND): - return(delete_from_periodic_list(paddr,SLHALFSECOND)); - case (PFIFTHSECOND): - return(delete_from_periodic_list(paddr,SLFIFTHSECOND)); - case (PTENTHSECOND): - return(delete_from_periodic_list(paddr,SLTENTHSECOND)); - case (E_IO_INTERRUPT): { - short io_type; - short card_type; - short card_number; - short cmd=1; - - status=get_io_info(&cmd,paddr,&io_type, - &card_type,&card_number); - if(status!=0) { - recGblDbaddrError(status,paddr, - "dbScan(get_io_info)"); - return; - } - if(cmd==0) status=delete_from_io_event_list(paddr,phase,io_type, - card_type,card_number); - return(status); - } - case (E_EXTERNAL): - return(delete_from_event_list(paddr,phase,event)); - default: - return(-1); - } -} - -/* - * DELETE_FROM_PERIODIC_LIST - * - * delete a record's address from a periodic scan list - */ -static delete_from_periodic_list(paddr,list_index) -register struct dbAddr *paddr; -short list_index; -{ - register short set,index,found; - register struct scan_element *pelement; - register struct scan_element *pnext_element=NULL; - short end_of_list; - - /* lock the list during modification */ - FASTLOCK(&lists[list_index].lock); - - /* find this record */ - found = FALSE; - set = 0; - index = 0; - end_of_list = FALSE; - pelement = lists[list_index].psets[set]; - while((!found) && (!end_of_list)){ - if (pelement->dbAddr.precord == paddr->precord){ - found = TRUE; - }else{ - index++; - if (index >= NUM_RECS_PER_SET){ - index = 0; - set++; - pelement = lists[list_index].psets[set]; - if (set >= NUM_SETS) end_of_list = TRUE; - }else{ - pelement++; - } - } - } - if (!found){ - FASTUNLOCK(&lists[list_index].lock); /* unlock it */ - return(-1); - } - - /* move each record in the scan list down */ - while (!end_of_list){ - index++; - if (index >= NUM_RECS_PER_SET){ - index = 0; - set++; - if (set >= NUM_SETS){ - end_of_list = TRUE; - }else{ - pnext_element=lists[list_index].psets[set]; - } - }else{ - pnext_element = pelement + 1; - } - - if (!end_of_list){ - *pelement = *pnext_element; - pelement = pnext_element; - }else{ - fill(pelement,sizeof(struct scan_element),0); - } - } - - /* adjust the list information */ - lists[list_index].num_records--; - lists[list_index].num_scan = - (lists[list_index].num_records/periods_to_complete[list_index])+1; - - /* determine if we need to free the memory for a set */ - if ((lists[list_index].num_records % NUM_RECS_PER_SET) == 0){ - set = lists[list_index].num_records / NUM_RECS_PER_SET; - free(lists[list_index].psets[set]); - lists[list_index].psets[set] = 0; - } - - /* unlock the scan list */ - FASTUNLOCK(&lists[list_index].lock); - - return(0); -} - -/* - * DELETE_FROM_IO_EVENT_LIST - * - * delete a record's address to an interrupt event scan list - */ -static delete_from_io_event_list(paddr,phase,io_type,card_type,card_number) -register struct dbAddr *paddr; -short phase; -short io_type; -short card_type; -short card_number; -{ - struct io_event_list *pio_event_list; - struct scan_element *pelement; - struct scan_element *pnext_element; - register short event_index; - register short index; - register short found; - - /* is there a list for this iotype,card type and card number */ - pio_event_list = &io_event_lists[0]; - event_index = 0; - found = FALSE; - while ((event_index < MAX_IO_EVENTS) && (!found)){ - if ((pio_event_list->defined) - && ((pio_event_list->io_type == io_type) - && (pio_event_list->card_type == card_type) - && (pio_event_list->card_number == card_number))){ - found = TRUE; - }else{ - pio_event_list++; - event_index++; - } - - } - if (!found) return(-1); - - /* lock the list during modification */ - FASTLOCK(&pio_event_list->lock); - - /* find this record in the list */ - index = 0; - pelement = &pio_event_list->element[0]; - found = FALSE; - while ((!found) - && (index < pio_event_list->number_defined)){ - if (pelement->dbAddr.precord == paddr->precord){ - found = TRUE; - }else{ - pelement++; - index++; - } - } - if (!found){ - FASTUNLOCK(&pio_event_list->lock); /* unlock it */ - return(-1); - } - - /* delete this record from the list */ - index++; - pnext_element = &pio_event_list->element[index]; - while (index < pio_event_list->number_defined) { - *pelement = *pnext_element; - pelement++; - pnext_element++; - index++; - } - fill(pelement,sizeof(struct scan_element),0); - pio_event_list->number_defined--; - - /* if this is the last scan element in the list - free it */ - if (pio_event_list->number_defined == 0){ - pio_event_list->defined = FALSE; - pio_event_list->io_type = 0; - pio_event_list->card_type = 0; - pio_event_list->card_number = 0; - } - - /* unlock the list */ - FASTUNLOCK(&pio_event_list->lock); - - return(0); -} - -/* - * DELETE_FROM_EVENT_LIST - * - * delete a record's address to an event scan list - */ -static delete_from_event_list(paddr,phase,event) -register struct dbAddr *paddr; -short phase; -short event; -{ - struct event_list *pevent_list; - struct scan_element *pelement; - struct scan_element *pnext_element; - register short event_index; - register short index; - register short found; - - /* is there a list for this iotype,card type and card number */ - pevent_list = &event_lists[0]; - event_index = 0; - found = FALSE; - while ((event_index < MAX_EVENTS) && (!found)){ - if ((pevent_list->defined) - && (pevent_list->event_number == event)){ - found = TRUE; - }else{ - pevent_list++; - event_index++; - } - - } - if (!found) return(-1); - - /* lock the list during modification */ - FASTLOCK(&pevent_list->lock); - - /* find this record in the list */ - index = 0; - pelement = &pevent_list->element[0]; - found = FALSE; - while ((!found) - && (index < pevent_list->number_defined)){ - if (pelement->dbAddr.precord == paddr->precord){ - found = TRUE; - }else{ - pelement++; - index++; - } - } - if (!found){ - FASTUNLOCK(&pevent_list->lock); /* unlock it */ - return(-1); - } - - /* delete this record from the list */ - index++; - pnext_element = &pevent_list->element[index]; - while (index < pevent_list->number_defined) { - *pelement = *pnext_element; - pelement++; - pnext_element++; - index++; - } - fill(pelement,sizeof(struct scan_element),0); - pevent_list->number_defined--; - - /* if this is the last scan element in the list - free it */ - if (pevent_list->number_defined == 0){ - pevent_list->defined = FALSE; - pevent_list->event_number = 0; - } - - /* unlock the list */ - FASTUNLOCK(&pevent_list->lock); - - return(0); -} - -/* - * GET_IO INFO - * - * get the io_type,card_type, and card_number - */ -static long get_io_info(cmd,paddr,pio_type,pcard_type,pcard_number) -short *cmd; -struct dbAddr *paddr; -short *pio_type; -short *pcard_type; -short *pcard_number; -{ - struct dbCommon *precord=(struct dbCommon *)(paddr->precord); - long status; - - if((precord->dset == NULL) ||(precord->dset->get_ioint_info == NULL )) - return(S_dev_noDevSup); - status=(*precord->dset->get_ioint_info) - (cmd,precord,pio_type,pcard_type,pcard_number); - return(status); -} - -/* - * PRINT_LIST - * - * print the scan lists - */ -print_list() -{ - struct scan_element *pelement; - struct scan_list *plist; - register short set,num_records,index; - short list; - char input[5]; - - fd = STD_IN; - - /* print each scan list */ - printf("\n"); - plist = &lists[0]; - for (list = 0; list < NUM_LISTS; list++,plist++){ - if (plist->num_records == 0){ - printf("list %d is empty\n",list); - continue; - } - if (plist->num_records >= NUM_RECS_PER_SET * NUM_SETS){ - printf("list %d is full\n",list); - }else{ - printf("list %d has %d entries\n",list,plist->num_records); - } - - /* print each set in each scan list */ - num_records = 0; - for (set=0; (setnum_records); set++){ - printf("\tset %d\n",set); - - /* print each element in each set */ - pelement = plist->psets[set]; - for (index=0; (indexnum_records); index++,pelement++){ - num_records++; - if ((pelement->dbAddr.precord[0] >= 'A') && (pelement->dbAddr.precord[0] <= 'z')) - printf("\t\t%s\n",pelement->dbAddr.precord); - else - printf("\t\tnot printable\n"); - } - } - - /* wait for a character to print the next set */ - read(fd,input,1); - } -} - -/* - * PRINT_IO_EVENT_LISTS - * - * print the io event lists - */ -print_io_event_lists() -{ - struct io_event_list *plist; - register short set,num_records,index; - short list; - char input[5]; - struct scan_element *pelement; - - fd = STD_IN; - - /* print each scan list */ - printf("\n"); - plist = &io_event_lists[0]; - for (list = 0; list < MAX_IO_EVENTS; list++,plist++){ - if (plist->defined == 0){ - printf("event list %d is unused\n",list); - continue; - } - if (plist->number_defined >= MAX_IO_EVENT_CHANS){ - printf("event list %d is full\n",list); - printf("\tio type: %d card type: %d card number: %d\n", - plist->io_type,plist->card_type,plist->card_number); - }else{ - printf("event list %d has %d entries\n",list,plist->number_defined); - printf("\tio type: %d card type: %d card number: %d\n", - plist->io_type,plist->card_type,plist->card_number); - } - - /* print each set in each scan list */ - num_records = 0; - pelement = &plist->element[0]; - for (index=0; (indexnumber_defined); index++,pelement++){ - num_records++; - if ((pelement->dbAddr.precord[0] >= 'A') && (pelement->dbAddr.precord[0] <= 'z')) - printf("\t\t%s\n",pelement->dbAddr.precord); - else - printf("\t\tnot printable\n"); - } - - /* wait for a character to print the next set */ - read(fd,input,1); - } -} - -/* - * PRINT_EVENT_LISTS - * - * print the event lists - */ -print_event_lists() -{ - struct event_list *plist; - register short set,num_records,index; - short list; - char input[5]; - struct scan_element *pelement; - - fd = STD_IN; - - /* print each scan list */ - printf("\n"); - plist = &event_lists[0]; - for (list = 0; list < MAX_EVENTS; list++,plist++){ - if (plist->defined == 0){ - printf("event list %d is unused\n",list); - continue; - } - if (plist->number_defined >= MAX_EVENT_CHANS){ - printf("event list %d is full\n",list); - printf("\tevent: %d\n",plist->event_number); - }else{ - printf("event list %d has %d entries\n",list,plist->number_defined); - printf("\tevent: %d\n",plist->event_number); - } - - /* print each set in each scan list */ - num_records = 0; - pelement = &plist->element[0]; - for (index=0; (indexnumber_defined); index++,pelement++){ - num_records++; - if ((pelement->dbAddr.precord[0] >= 'A') && (pelement->dbAddr.precord[0] <= 'z')) - printf("\t\t%s\n",pelement->dbAddr.precord); - else - printf("\t\tnot printable\n"); - } - - /* wait for a character to print the next set */ - read(fd,input,1); - } -} - -/* - * IO_SCANNER_WAKEUP - * - * wake up the I/O interrupt event scanner - */ -io_scanner_wakeup(io_type,card_type,card_number) -short io_type,card_type,card_number; -{ - struct intr_event intr_event; - - if (wakeup_init != 1) return; /* not awake yet */ - intr_event.io_type = io_type; - intr_event.card_type = card_type; - intr_event.card_number = card_number; - - rngBufPut(ioEventQ,&intr_event,INTR_EVENT_SZ); - semGive(&ioEventSem); -} - -/* - * POST_EVENT - * - * wake up the event scanner - */ -post_event(event_number) -short event_number; -{ - if (wakeup_init != 1) return; /* not awake yet */ - /* logMsg("Post Events\n"); */ - rngBufPut(eventQ,&event_number,sizeof(short)); - semGive(&eventSem); + pse->pscan_list = NULL; + lstDelete(&psl->list,(void *)pse); + psl->modified = TRUE; + FASTUNLOCK(&psl->lock); + return; } diff --git a/src/db/dbTest.c b/src/db/dbTest.c index 8b300fcc3..6de750db2 100644 --- a/src/db/dbTest.c +++ b/src/db/dbTest.c @@ -32,6 +32,7 @@ * .01 08-13-91 mrk Added extra NULL arg to dbGetField calls * .02 10-23-91 mrk Changed dbior so it also reports device support * .03 11-26-91 jba Fixed initializations and added hex print to printBuffer + * .04 02-05-92 jba Changed function arguments from paddr to precord */ /* Global Database Test Routines - All can be invoked via vxWorks shell @@ -89,7 +90,6 @@ #include #include #include -#include #define MAXLINE 80 struct msgBuff { /* line output structure */ @@ -308,7 +308,7 @@ long dbtr(pname) /* test record and print*/ printf("record locked\n"); return(1); } - status=dbProcess(&addr); + status=dbProcess(precord); if(!(RTN_SUCCESS(status))) recGblRecSupError(S_db_noSupport,&addr,"dbtr","process"); dbpr(pname,3); diff --git a/src/db/db_access.c b/src/db/db_access.c index 0ff6139a8..e2d758d8d 100644 --- a/src/db/db_access.c +++ b/src/db/db_access.c @@ -31,6 +31,7 @@ * .01 06-25-91 joh inserted the RISC aligned db_access.h structures * .02 08-06-91 mrk Make extra values 0 * .03 08-13-91 mrk Add pfl argument to dbGetField calls + * .04 02-05-92 jba Changed function arguments from paddr to precord */ @@ -43,6 +44,7 @@ #include #include +#include #include #include #include @@ -485,7 +487,7 @@ register struct db_addr *pdb_addr; { long status; - status=dbProcess(pdb_addr); + status=dbProcess((void *)pdb_addr->precord); if(!RTN_SUCCESS(status)) errMessage(status,"db_process failed"); return; } diff --git a/src/db/iocInit.c b/src/db/iocInit.c index 53485bd58..47c6583f2 100644 --- a/src/db/iocInit.c +++ b/src/db/iocInit.c @@ -51,10 +51,14 @@ #include #include +#include #include #include #include #include +#include +#include +#include #include #include #include @@ -63,12 +67,15 @@ #include #include #include -#include #include #include static initialized=FALSE; +/* The following is for use by interrupt routines */ +int interruptAccept=FALSE; +extern short wakeup_init; /*old IO_EVENT_SCAN*/ + /* define forward references*/ extern long sdrLoad(); long initDrvSup(); @@ -89,7 +96,7 @@ char * pResourceFilename; char name[40]; long rtnval; void (*pdbUserExit)(); - UTINY type; + SYM_TYPE type; if(initialized) { logMsg("iocInit can only be called once\n"); @@ -113,6 +120,7 @@ char * pResourceFilename; logMsg("iocInit Failed to Initialize Ioc Log Client \n"); } initialized = TRUE; + taskwdInit(); if(initDrvSup()!=0) logMsg("iocInit: Drivers Failed during Initialization\n"); if(initRecSup()!=0) logMsg("iocInit: Record Support Failed during Initialization\n"); if(initDevSup()!=0) logMsg("iocInit: Device Support Failed during Initialization\n"); @@ -123,13 +131,16 @@ char * pResourceFilename; /* if user exit exists call it */ strcpy(name,"_"); strcat(name,"dbUserExit"); - rtnval = symFindByName(sysSymTbl,name,&pdbUserExit,&type); + rtnval = symFindByName(sysSymTbl,name,(void *)&pdbUserExit,&type); if(rtnval==OK && (type&N_TEXT!=0)) { (*pdbUserExit)(); logMsg("User Exit was called\n"); } + callbackInit(); + scanInit(); + interruptAccept=TRUE; + wakeup_init=TRUE; /*old IO_EVENT_SCAN*/ if(initialProcess()!=0) logMsg("iocInit: initialProcess Failed\n"); - scan_init(); rsrv_init(); logMsg("iocInit: All initialization complete\n"); @@ -141,10 +152,11 @@ static long initDrvSup() /* Locate all driver support entry tables */ char *pname; char name[40]; int i; - UTINY type; + SYM_TYPE type; char message[100]; - long status; - long rtnval=0; + long status=0; + long rtnval; + STATUS vxstatus; if(!drvSup) { status = S_drv_noDrvSup; @@ -155,30 +167,30 @@ static long initDrvSup() /* Locate all driver support entry tables */ if(!(pname = drvSup->drvetName[i])) continue; strcpy(name,"_"); strcat(name,pname); - rtnval = symFindByName(sysSymTbl,name,&(drvSup->papDrvet[i]),&type); - if( rtnval!=OK || ( type&N_TEXT == 0) ) { + vxstatus = symFindByName(sysSymTbl,name,(void *)&(drvSup->papDrvet[i]),&type); + if( vxstatus!=OK || ( type&N_TEXT == 0) ) { strcpy(message,"driver entry table not found for "); strcat(message,pname); status = S_drv_noDrvet; errMessage(status,message); - if(rtnval==OK) rtnval=status; continue; } if(!(drvSup->papDrvet[i]->init)) continue; - status = (*(drvSup->papDrvet[i]->init))(); - if(rtnval==OK) rtnval=status; + rtnval = (*(drvSup->papDrvet[i]->init))(); + if(status==0) status = rtnval; } - return(rtnval); + return(status); } static long initRecSup() { char name[40]; int i; - UTINY type; + SYM_TYPE type; char message[100]; - long status; - long rtnval=0; /*rtnval will be 0 or first error found*/ + long status=0; + long rtnval; + STATUS vxstatus; int nbytes; if(!dbRecType) { @@ -187,7 +199,7 @@ static long initRecSup() return(status); } nbytes = sizeof(struct recSup) + dbRecType->number*sizeof(caddr_t); - recSup = (struct recSup *)calloc(1,nbytes); + recSup = calloc(1,nbytes); recSup->number = dbRecType->number; (long)recSup->papRset = (long)recSup + (long)sizeof(struct recSup); for(i=0; i< (recSup->number); i++) { @@ -195,22 +207,22 @@ static long initRecSup() strcpy(name,"_"); strcat(name,dbRecType->papName[i]); strcat(name,"RSET"); - rtnval = symFindByName(sysSymTbl,name,&(recSup->papRset[i]),&type); - if( rtnval!=OK || ( type&N_TEXT == 0) ) { + vxstatus = symFindByName(sysSymTbl,name, + (void *)(&recSup->papRset[i]),&type); + if( vxstatus!=OK || ( type&N_TEXT == 0) ) { strcpy(message,"record support entry table not found for "); strcat(message,name); status = S_rec_noRSET; errMessage(status,message); - if(rtnval==OK)rtnval=status; continue; } if(!(recSup->papRset[i]->init)) continue; else { - status = (*(recSup->papRset[i]->init))(); - if(rtnval==OK)rtnval=status; + rtnval = (*(recSup->papRset[i]->init))(); + if(status==0) status = rtnval; } } - return(rtnval); + return(status); } static long initDevSup() /* Locate all device support entry tables */ @@ -218,10 +230,11 @@ static long initDevSup() /* Locate all device support entry tables */ char *pname; char name[40]; int i,j; - UTINY type; + SYM_TYPE type; char message[100]; - long status; - long rtnval=0; /*rtnval will be 0 or first error found*/ + long status=0; + long rtnval; + STATUS vxstatus; struct recLoc *precLoc; struct devSup *pdevSup; struct dbCommon *precord; @@ -237,20 +250,19 @@ static long initDevSup() /* Locate all device support entry tables */ if(!(pname = pdevSup->dsetName[j])) continue; strcpy(name,"_"); strcat(name,pname); - rtnval = (long)symFindByName(sysSymTbl,name, - &(pdevSup->papDset[j]),&type); - if( rtnval!=OK || ( type&N_TEXT == 0) ) { + vxstatus = (long)symFindByName(sysSymTbl,name, + (void *)&(pdevSup->papDset[j]),&type); + if( vxstatus!=OK || ( type&N_TEXT == 0) ) { pdevSup->papDset[j]=NULL; strcpy(message,"device support entry table not found for "); strcat(message,pname); status = S_dev_noDSET; errMessage(status,message); - if(rtnval==OK)rtnval=status; continue; } if(!(pdevSup->papDset[j]->init)) continue; - status = (*(pdevSup->papDset[j]->init))(0); - if(rtnval==OK)rtnval=status; + rtnval = (*(pdevSup->papDset[j]->init))(0); + if(status==0) status = rtnval; } /* Now initialize dset for each record */ @@ -265,7 +277,7 @@ static long initDevSup() /* Locate all device support entry tables */ precord->dset=(struct dset *)GET_PDSET(pdevSup,precord->dtyp); } } - return(rtnval); + return(status); } static long finishDevSup() @@ -292,8 +304,8 @@ static long initDatabase() char name[PVNAME_SZ+FLDNAME_SZ+2]; short i,j,k; char message[120]; - long status; - long rtnval=0; /*rtnval will be 0 or first error found*/ + long status=0; + long rtnval; short nset=0; short lookAhead; struct recLoc *precLoc; @@ -318,7 +330,6 @@ static long initDatabase() strcat(message,name); status = S_rec_noRSET; errMessage(status,message); - if(rtnval==OK) rtnval = status; continue; } precTypDes = dbRecDes->papRecTypDes[i]; @@ -328,17 +339,8 @@ static long initDatabase() /* If NAME is null then skip this record*/ if(!(precord->name[0])) continue; - /*initialize fields rset and pdba*/ + /*initialize fields rset*/ (struct rset *)(precord->rset) = prset; - precord->pdba = (struct dbAddr *)calloc(1,sizeof(struct dbAddr)); - strncpy(name,precord->name,PVNAME_SZ); - name[PVNAME_SZ]=0; - strcat(name,".VAL"); - if(dbNameToAddr(name,precord->pdba)) { - status = S_db_notFound; - errMessage(status, - "initDatbase logic error: dbNameToAddr failed"); - } /* initialize mlok and mlis*/ FASTLOCKINIT(&precord->mlok); @@ -366,7 +368,7 @@ static long initDatabase() ((struct dbCommon *)(dbAddr.precord))->lset= -1; plink->type = DB_LINK; plink->value.db_link.pdbAddr = - (caddr_t)calloc(1,sizeof(struct dbAddr)); + calloc(1,sizeof(struct dbAddr)); *((struct dbAddr *)(plink->value.db_link.pdbAddr))=dbAddr; } else { @@ -380,15 +382,14 @@ static long initDatabase() strcat(message," not found"); status = S_db_notFound; errMessage(status,message); - if(rtnval==OK) rtnval=status; } } } /* call record support init_record routine */ if(!(recSup->papRset[i]->init_record)) continue; - status = (*(recSup->papRset[i]->init_record))(precord); - if(rtnval==OK)rtnval=status; + rtnval = (*(recSup->papRset[i]->init_record))(precord); + if(status==0) status = rtnval; } } @@ -410,12 +411,13 @@ static long initDatabase() if(precord->lset > 0) continue; /*already in a lock set */ lookAhead = ( (precord->lset == -1) ? TRUE : FALSE); nset++; - status = addToSet(precord,i,lookAhead,i,j,nset); + rtnval = addToSet(precord,i,lookAhead,i,j,nset); + if(status==0) status=rtnval; if(status) return(status); } } dbScanLockInit(nset); - return(rtnval); + return(status); } static long addToSet(precord,record_type,lookAhead,i,j,lset) @@ -522,7 +524,7 @@ static long initialProcess() /* If NAME is null then skip this record*/ if(!(precord->name[0])) continue; if(!precord->pini) continue; - (void)dbProcess(precord->pdba); + (void)dbProcess(precord); } } return(0); @@ -543,6 +545,7 @@ static long getResources(fname) /* Resource Definition File interpreter */ char *fname; { int fd; + int fd2; int len; int len2; int lineNum = 0; @@ -563,6 +566,28 @@ static long getResources(fname) /* Resource Definition File interpreter */ long n_long; float n_float; double n_double; + if (sdrSum) { + if ((fd2 = open("default.sdrSum", READ, 0x0)) < 0) { + errMessage(0L, "Can't open default.sdrSum file"); + return (-1); + } + fioRdString(fd2, buff, MAX); + close(fd2); + len2 = strlen(sdrSum->allSdrSums); + + if ((strncmp(sdrSum->allSdrSums, buff, len2)) != SAME) { + errMessage(-1L, "WARNING WARNING WARNING WARNING WARNING WARNING WARNING"); + errMessage(-1L, "WARNING WARNING WARNING WARNING WARNING WARNING WARNING"); + errMessage(-1L, "WARNING WARNING WARNING WARNING WARNING WARNING WARNING"); + errMessage(0L, "THIS DATABASE IS OUT_OF_DATE"); + errMessage(-1L, "WARNING WARNING WARNING WARNING WARNING WARNING WARNING"); + errMessage(-1L, "WARNING WARNING WARNING WARNING WARNING WARNING WARNING"); + errMessage(-1L, "WARNING WARNING WARNING WARNING WARNING WARNING WARNING"); + return (-1); + } + } else { + logMsg("Skipping Check for an out-of-date database\n"); + } if (!fname) return (0); if ((fd = open(fname, READ, 0x0)) < 0) { errMessage(0L, "getResources: No such Resource file"); diff --git a/src/db/recGbl.c b/src/db/recGbl.c index 5366c2fc9..65fe5e876 100644 --- a/src/db/recGbl.c +++ b/src/db/recGbl.c @@ -37,11 +37,10 @@ #include #include -#include #include #include #include -#include +#include #include #include diff --git a/src/db/taskwd.c b/src/db/taskwd.c index 93d2defdf..ce7aff7aa 100644 --- a/src/db/taskwd.c +++ b/src/db/taskwd.c @@ -137,7 +137,7 @@ static void taskwdTask() pname = taskName(pt->tid); if(!pt->suspended) { - sprintf(message,"task %d %s suspended",pt->tid,pname); + sprintf(message,"task %x %s suspended",pt->tid,pname); errMessage(-1,message); if(pt->callback) (pt->callback)(pt->arg); } @@ -159,7 +159,7 @@ struct task_list *allocList() if(freeHead) { (void *)pt = (void *)freeHead; freeHead = freeHead->next; - } else pt = calloc(1,sizeof(struct task_list *)); + } else pt = calloc(1,sizeof(struct task_list)); if(pt==NULL) { errMessage(0,"taskwd failed on call to calloc\n"); exit(1); diff --git a/src/dev/devAiDvx2502.c b/src/dev/devAiDvx2502.c index 8ecf2c08e..dfabcfd21 100644 --- a/src/dev/devAiDvx2502.c +++ b/src/dev/devAiDvx2502.c @@ -115,7 +115,7 @@ static long get_ioint_info(cmd,pai,io_type,card_type,card_number) short *card_type; short *card_number; { - *cmd=0; + *cmd=-1; if(pai->inp.type != VME_IO) return(S_dev_badInpType); *io_type = IO_AI; *card_type = DVX2502; diff --git a/src/dev/devAiSoft.c b/src/dev/devAiSoft.c index dd359cbc2..6a5ccf1ab 100644 --- a/src/dev/devAiSoft.c +++ b/src/dev/devAiSoft.c @@ -111,7 +111,7 @@ static long read_ai(pai) case (DB_LINK) : options=0; nRequest=1; - status = dbGetLink(&(pai->inp.value.db_link),pai,DBR_DOUBLE, + status = dbGetLink(&(pai->inp.value.db_link),(struct dbCommon *)pai,DBR_DOUBLE, &(pai->val),&options,&nRequest); if(status!=0) { recGblSetSevr(pai,LINK_ALARM,VALID_ALARM); diff --git a/src/dev/devAiSoftRaw.c b/src/dev/devAiSoftRaw.c index 37ecf2144..df810cbcd 100644 --- a/src/dev/devAiSoftRaw.c +++ b/src/dev/devAiSoftRaw.c @@ -107,7 +107,7 @@ static long read_ai(pai) case (DB_LINK) : options=0; nRequest=1; - status = dbGetLink(&(pai->inp.value.db_link),pai,DBR_LONG, + status = dbGetLink(&(pai->inp.value.db_link),(struct dbCommon *)pai,DBR_LONG, &(pai->rval),&options,&nRequest); if(status!=0) { recGblSetSevr(pai,LINK_ALARM,VALID_ALARM); diff --git a/src/dev/devAiTestAsyn.c b/src/dev/devAiTestAsyn.c index 0402fc515..5bfaf6cf3 100644 --- a/src/dev/devAiTestAsyn.c +++ b/src/dev/devAiTestAsyn.c @@ -30,6 +30,8 @@ * * Modification Log: * ----------------- + * .01 01-08-92 jba Added cast in call to wdStart to avoid compile warning msg + * .02 02-05-92 jba Changed function arguments from paddr to precord * ... */ @@ -39,6 +41,7 @@ #include #include +#include #include #include #include @@ -83,9 +86,9 @@ static void myCallback(pcallback) struct aiRecord *pai=(struct aiRecord *)(pcallback->prec); struct rset *prset=(struct rset *)(pai->rset); - dbScanLock(pai); - (*prset->process)(pai->pdba); - dbScanUnlock(pai); + dbScanLock((struct dbCommon *)pai); + (*prset->process)(pai); + dbScanUnlock((struct dbCommon *)pai); } @@ -135,7 +138,7 @@ static long read_ai(pai) wait_time = (int)(pai->disv * vxTicksPerSecond); if(wait_time<=0) return(0); printf("%s Starting asynchronous processing\n",pai->name); - wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + wdStart(pcallback->wd_id,wait_time,callbackRequest,(int)pcallback); return(1); } default : diff --git a/src/dev/devAiXy566DiL.c b/src/dev/devAiXy566DiL.c index f58070324..7e8007aec 100644 --- a/src/dev/devAiXy566DiL.c +++ b/src/dev/devAiXy566DiL.c @@ -113,7 +113,7 @@ static long get_ioint_info(cmd,pai,io_type,card_type,card_number) short *card_type; short *card_number; { - *cmd=0; + *cmd=-1; if(pai->inp.type != VME_IO) return(S_dev_badInpType); *io_type = IO_AI; *card_type = XY566DIL; diff --git a/src/dev/devAoSoft.c b/src/dev/devAoSoft.c index 7409dc61b..cc305b45e 100644 --- a/src/dev/devAoSoft.c +++ b/src/dev/devAoSoft.c @@ -31,6 +31,7 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set of alarm stat and sevr to macros + * .02 02-05-92 jba Changed function arguments from paddr to precord * ... */ @@ -78,7 +79,7 @@ static long write_ao(pao) case (CONSTANT) : break; case (DB_LINK) : - status = dbPutLink(&pao->out.value.db_link,pao,DBR_DOUBLE, + status = dbPutLink(&pao->out.value.db_link,(struct dbCommon *)pao,DBR_DOUBLE, &pao->oval,1L); if(status!=0) { recGblSetSevr(pao,LINK_ALARM,VALID_ALARM); diff --git a/src/dev/devAoSoftRaw.c b/src/dev/devAoSoftRaw.c index 5ace5de95..a783447c3 100644 --- a/src/dev/devAoSoftRaw.c +++ b/src/dev/devAoSoftRaw.c @@ -77,7 +77,7 @@ static long write_ao(pao) case (CONSTANT) : break; case (DB_LINK) : - status = dbPutLink(&pao->out.value.db_link,pao,DBR_LONG, + status = dbPutLink(&pao->out.value.db_link,(struct dbCommon *)pao,DBR_LONG, &pao->rval,1L); if(status!=0) { recGblSetSevr(pao,LINK_ALARM,VALID_ALARM); diff --git a/src/dev/devAoTestAsyn.c b/src/dev/devAoTestAsyn.c index 11de45dd5..33e4ef75c 100644 --- a/src/dev/devAoTestAsyn.c +++ b/src/dev/devAoTestAsyn.c @@ -31,6 +31,8 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set of alarm stat and sevr to macros + * .02 01-08-92 jba Added cast in call to wdStart to avoid compile warning msg + * .03 02-05-92 jba Changed function arguments from paddr to precord * ... */ @@ -41,6 +43,7 @@ #include #include +#include #include #include #include @@ -82,11 +85,11 @@ static void myCallback(pcallback) struct callback *pcallback; { struct aoRecord *pao=(struct aoRecord *)(pcallback->prec); - struct rset *prset=(struct rset *)(pao->rset); + struct rset *prset=(struct rset *)(pao->rset); - dbScanLock(pao); - (*prset->process)(pao->pdba); - dbScanUnlock(pao); + dbScanLock((struct dbCommon *)pao); + (*prset->process)(pao); + dbScanUnlock((struct dbCommon *)pao); } @@ -134,7 +137,7 @@ static long write_ao(pao) wait_time = (int)(pao->disv * vxTicksPerSecond); if(wait_time<=0) return(0); printf("%s Starting asynchronous processing\n",pao->name); - wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + wdStart(pcallback->wd_id,wait_time,callbackRequest,(int)pcallback); return(1); } default : diff --git a/src/dev/devAoVmiVme4100.c b/src/dev/devAoVmiVme4100.c index 25353cce4..8dda03d86 100644 --- a/src/dev/devAoVmiVme4100.c +++ b/src/dev/devAoVmiVme4100.c @@ -40,11 +40,10 @@ #include #include -#include #include +#include #include #include -#include #include #include #include diff --git a/src/dev/devBiMpv910.c b/src/dev/devBiMpv910.c index 33ecc1196..4d14f7836 100644 --- a/src/dev/devBiMpv910.c +++ b/src/dev/devBiMpv910.c @@ -40,11 +40,10 @@ #include #include -#include #include +#include #include #include -#include #include #include diff --git a/src/dev/devBiSoft.c b/src/dev/devBiSoft.c index 6b700e89c..ced045f81 100644 --- a/src/dev/devBiSoft.c +++ b/src/dev/devBiSoft.c @@ -40,11 +40,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -108,7 +107,7 @@ static long read_bi(pbi) case (DB_LINK) : options=0; nRequest=1; - status = dbGetLink(&(pbi->inp.value.db_link),pbi,DBR_USHORT, + status = dbGetLink(&(pbi->inp.value.db_link),(struct dbCommon *)pbi,DBR_USHORT, &pbi->val,&options,&nRequest); if(status!=0) { recGblSetSevr(pbi,LINK_ALARM,VALID_ALARM); diff --git a/src/dev/devBiSoftRaw.c b/src/dev/devBiSoftRaw.c index b0f731723..355215638 100644 --- a/src/dev/devBiSoftRaw.c +++ b/src/dev/devBiSoftRaw.c @@ -31,6 +31,7 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set of alarm stat and sevr to macros + * .02 02-05-92 jba Changed function arguments from paddr to precord * ... */ @@ -40,11 +41,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -107,7 +107,7 @@ static long read_bi(pbi) case (DB_LINK) : options=0; nRequest=1; - status = dbGetLink(&(pbi->inp.value.db_link),pbi,DBR_ULONG, + status = dbGetLink(&(pbi->inp.value.db_link),(struct dbCommon *)pbi,DBR_ULONG, &pbi->rval,&options,&nRequest); if(status!=0) { recGblSetSevr(pbi,LINK_ALARM,VALID_ALARM); diff --git a/src/dev/devBiTestAsyn.c b/src/dev/devBiTestAsyn.c index 422842d7a..a336fa878 100644 --- a/src/dev/devBiTestAsyn.c +++ b/src/dev/devBiTestAsyn.c @@ -31,6 +31,8 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set of alarm stat and sevr to macros + * .02 01-08-92 jba Added cast in call to wdStart to avoid compile warning msg + * .03 02-05-92 jba Changed function arguments from paddr to precord * ... */ @@ -41,6 +43,7 @@ #include #include +#include #include #include #include @@ -85,9 +88,9 @@ static void myCallback(pcallback) struct biRecord *pbi=(struct biRecord *)(pcallback->prec); struct rset *prset=(struct rset *)(pbi->rset); - dbScanLock(pbi); - (*prset->process)(pbi->pdba); - dbScanUnlock(pbi); + dbScanLock((struct dbCommon *)pbi); + (*prset->process)(pbi); + dbScanUnlock((struct dbCommon *)pbi); } @@ -137,7 +140,7 @@ static long read_bi(pbi) wait_time = (int)(pbi->disv * vxTicksPerSecond); if(wait_time<=0) return(0); printf("%s Starting asynchronous processing\n",pbi->name); - wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + wdStart(pcallback->wd_id,wait_time,callbackRequest,(int)pcallback); return(1); } default : diff --git a/src/dev/devBiXVme210.c b/src/dev/devBiXVme210.c index fbd774d59..f8bb9ad05 100644 --- a/src/dev/devBiXVme210.c +++ b/src/dev/devBiXVme210.c @@ -40,11 +40,10 @@ #include #include -#include #include +#include #include #include -#include #include #include diff --git a/src/dev/devBoMpv902.c b/src/dev/devBoMpv902.c index ab179b125..28d25ca50 100644 --- a/src/dev/devBoMpv902.c +++ b/src/dev/devBoMpv902.c @@ -40,11 +40,10 @@ #include #include -#include #include +#include #include #include -#include #include #include diff --git a/src/dev/devBoSoft.c b/src/dev/devBoSoft.c index 73f5ef6a0..ffb499bef 100644 --- a/src/dev/devBoSoft.c +++ b/src/dev/devBoSoft.c @@ -40,11 +40,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -79,7 +78,7 @@ static long write_bo(pbo) case (CONSTANT) : break; case (DB_LINK) : - status = dbPutLink(&pbo->out.value.db_link,pbo,DBR_USHORT,&pbo->val,1L); + status = dbPutLink(&pbo->out.value.db_link,(struct dbCommon *)pbo,DBR_USHORT,&pbo->val,1L); if(status!=0) { recGblSetSevr(pbo,LINK_ALARM,VALID_ALARM); } diff --git a/src/dev/devBoTestAsyn.c b/src/dev/devBoTestAsyn.c index 30c66854a..11c58c9a3 100644 --- a/src/dev/devBoTestAsyn.c +++ b/src/dev/devBoTestAsyn.c @@ -31,6 +31,8 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set of alarm stat and sevr to macros + * .02 01-08-92 jba Added cast in call to wdStart to avoid compile warning msg + * .03 02-05-92 jba Changed function arguments from paddr to precord * ... */ @@ -42,6 +44,7 @@ #include #include +#include #include #include #include @@ -85,9 +88,9 @@ static void myCallback(pcallback) struct boRecord *pbo=(struct boRecord *)(pcallback->prec); struct rset *prset=(struct rset *)(pbo->rset); - dbScanLock(pbo); - (*prset->process)(pbo->pdba); - dbScanUnlock(pbo); + dbScanLock((struct dbCommon *)pbo); + (*prset->process)(pbo); + dbScanUnlock((struct dbCommon *)pbo); } @@ -135,7 +138,7 @@ static long write_bo(pbo) wait_time = (int)(pbo->disv * vxTicksPerSecond); if(wait_time<=0) return(0); printf("%s Starting asynchronous processing\n",pbo->name); - wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + wdStart(pcallback->wd_id,wait_time,callbackRequest,(int)pcallback); return(1); } default : diff --git a/src/dev/devBoXVme220.c b/src/dev/devBoXVme220.c index 8646f5cb8..93711fadd 100644 --- a/src/dev/devBoXVme220.c +++ b/src/dev/devBoXVme220.c @@ -40,11 +40,10 @@ #include #include -#include #include +#include #include #include -#include #include #include diff --git a/src/dev/devEventSoft.c b/src/dev/devEventSoft.c index 8df425367..e6ad037a0 100644 --- a/src/dev/devEventSoft.c +++ b/src/dev/devEventSoft.c @@ -1,5 +1,5 @@ /* devEventSoft.c */ -/* share/src/dev @(#)devEvent.c 1.1 12/17/91 */ +/* share/src/dev $Id$ */ /* devEventSoft.c - Device Support Routines for Soft Event Input */ /* @@ -38,11 +38,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -76,7 +75,7 @@ static long init_record(pevent) switch (pevent->inp.type) { case (CONSTANT) : if(pevent->inp.value.value!=0.0){ - pevent->enum=pevent->inp.value.value; + pevent->val=pevent->inp.value.value; } pevent->udf= FALSE; break; @@ -108,8 +107,8 @@ static long read_event(pevent) case (DB_LINK) : options=0; nRequest=1; - status = dbGetLink(&(pevent->inp.value.db_link),pevent,DBR_SHORT, - pevent->enum,&options,&nRequest); + status = dbGetLink(&(pevent->inp.value.db_link),(struct dbCommon *)pevent,DBR_USHORT, + &pevent->val,&options,&nRequest); if(status!=0) { recGblSetSevr(pevent,LINK_ALARM,VALID_ALARM); } else pevent->udf = FALSE; diff --git a/src/dev/devEventTestIoEvent.c b/src/dev/devEventTestIoEvent.c index aad8e3c13..e3236ebd7 100644 --- a/src/dev/devEventTestIoEvent.c +++ b/src/dev/devEventTestIoEvent.c @@ -1,11 +1,10 @@ -/* devAiTestAsyn.c */ +/* devEventTestIoEvent.c */ /* share/src/dev $Id$ */ -/* devAiTestAsyn.c - Device Support Routines for testing asynchronous processing*/ +/* devEventTestIoEvent.c - Device Support Routines for ioEvent*/ /* - * Original Author: Bob Dalesio - * Current Author: Marty Kraimer - * Date: 6-1-90 + * Author: Marty Kraimer + * Date: 01/09/92 * * Experimental Physics and Industrial Control System (EPICS) * @@ -30,123 +29,74 @@ * * Modification Log: * ----------------- + * .00 12-13-91 jba Initial definition * ... */ - + #include #include #include #include -#include -#include -#include #include #include +#include #include #include -#include -#include - -/* Create the dset for devAiTestAsyn */ -long init_record(); -long read_ai(); +#include +/* Create the dset for devEventTestIoEvent */ +long init(); +long get_ioint_info(); +long read_event(); struct { long number; DEVSUPFUN report; DEVSUPFUN init; DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; - DEVSUPFUN read_ai; + DEVSUPFUN read_event; DEVSUPFUN special_linconv; -}devAiTestAsyn={ +}devEventTestIoEvent={ 6, NULL, + init, NULL, - init_record, - NULL, - read_ai, + get_ioint_info, + read_event, NULL}; -/* control block for callback*/ -struct callback { - void (*callback)(); - int priority; - struct dbCommon *prec; - WDOG_ID wd_id; -}; +IOSCANPVT ioscanpvt; +WDOG_ID wd_id=NULL; -void callbackRequest(); -static void myCallback(pcallback) - struct callback *pcallback; +static long init() { - struct aiRecord *pai=(struct aiRecord *)(pcallback->prec); - struct rset *prset=(struct rset *)(pai->rset); - - dbScanLock(pai); - (*prset->process)(pai->pdba); - dbScanUnlock(pai); -} - - - -static long init_record(pai) - struct aiRecord *pai; -{ - char message[100]; - struct callback *pcallback; - - /* ai.inp must be a CONSTANT*/ - switch (pai->inp.type) { - case (CONSTANT) : - pcallback = (struct callback *)(calloc(1,sizeof(struct callback))); - pai->dpvt = (caddr_t)pcallback; - pcallback->callback = myCallback; - pcallback->priority = priorityLow; - pcallback->prec = (struct dbCommon *)pai; - pcallback->wd_id = wdCreate(); - pai->val = pai->inp.value.value; - pai->udf = FALSE; - break; - default : - strcpy(message,pai->name); - strcat(message,": devAiTestAsyn (init_record) Illegal INP field"); - errMessage(S_db_badField,message); - return(S_db_badField); - } + scanIoInit(&ioscanpvt); return(0); } - -static long read_ai(pai) - struct aiRecord *pai; -{ - char message[100]; - long status,options,nRequest; - struct callback *pcallback=(struct callback *)(pai->dpvt); - int wait_time; - /* ai.inp must be a CONSTANT*/ - switch (pai->inp.type) { - case (CONSTANT) : - if(pai->pact) { - printf("%s Completed\n",pai->name); - return(2); /* don`t convert*/ - } else { - wait_time = (int)(pai->disv * vxTicksPerSecond); - if(wait_time<=0) return(0); - printf("%s Starting asynchronous processing\n",pai->name); - wdStart(pcallback->wd_id,wait_time,callbackRequest,(int)pcallback); - return(1); - } - default : - if(recGblSetSevr(pai,SOFT_ALARM,VALID_ALARM)){ - if(pai->stat!=SOFT_ALARM) { - strcpy(message,pai->name); - strcat(message,": devAiTestAsyn (read_ai) Illegal INP field"); - errMessage(S_db_badField,message); - } - } - } + +static long get_ioint_info( + int *cmd, + struct eventRecord *pr, + IOSCANPVT *ppvt) +{ + + *ppvt = ioscanpvt; return(0); } + +static long read_event(pevent) + struct eventRecord *pevent; +{ + char message[100]; + int wait_time; + + wait_time = (int)(pevent->proc * vxTicksPerSecond); + if(wait_time<=0) return(0); + pevent->udf = FALSE; + if(wd_id==NULL) wd_id = wdCreate(); + printf("%s Requesting Next ioEnevt\n",pevent->name); + wdStart(wd_id,wait_time,scanIoRequest,(int)ioscanpvt); + return(0); +} diff --git a/src/dev/devHistogramSoft.c b/src/dev/devHistogramSoft.c index c4f9ae863..0a9a5c42f 100644 --- a/src/dev/devHistogramSoft.c +++ b/src/dev/devHistogramSoft.c @@ -107,7 +107,7 @@ static long read_histogram(phistogram) case (DB_LINK) : options=0; nRequest=1; - status = dbGetLink(&(phistogram->svl.value.db_link),phistogram,DBR_DOUBLE, + status = dbGetLink(&(phistogram->svl.value.db_link),(struct dbCommon *)phistogram,DBR_DOUBLE, &(phistogram->sgnl),&options,&nRequest); if(status!=0) { if(phistogram->nsev #include +#include #include #include #include @@ -83,9 +86,9 @@ static void myCallback(pcallback) struct histogramRecord *phistogram=(struct histogramRecord *)(pcallback->prec); struct rset *prset=(struct rset *)(phistogram->rset); - dbScanLock(phistogram); - (*prset->process)(phistogram->pdba); - dbScanUnlock(phistogram); + dbScanLock((struct dbCommon *)phistogram); + (*prset->process)(phistogram); + dbScanUnlock((struct dbCommon *)phistogram); return; } @@ -133,7 +136,7 @@ static long read_histogram(phistogram) wait_time = (int)(phistogram->disv * vxTicksPerSecond); if(wait_time<=0) return(0); printf("%s Starting asynchronous processing\n",phistogram->name); - wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + wdStart(pcallback->wd_id,wait_time,callbackRequest,(int)pcallback); return(1); } default : diff --git a/src/dev/devLiSoft.c b/src/dev/devLiSoft.c index 2d4b7b62b..045247b84 100644 --- a/src/dev/devLiSoft.c +++ b/src/dev/devLiSoft.c @@ -38,11 +38,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -105,7 +104,7 @@ static long read_longin(plongin) case (DB_LINK) : options=0; nRequest=1; - status = dbGetLink(&(plongin->inp.value.db_link),plongin,DBR_LONG, + status = dbGetLink(&(plongin->inp.value.db_link),(struct dbCommon *)plongin,DBR_LONG, &plongin->val,&options,&nRequest); if(status!=0) { recGblSetSevr(plongin,LINK_ALARM,VALID_ALARM); diff --git a/src/dev/devLoSoft.c b/src/dev/devLoSoft.c index 0bb9b0aec..a6d4c0620 100644 --- a/src/dev/devLoSoft.c +++ b/src/dev/devLoSoft.c @@ -37,11 +37,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -75,7 +74,7 @@ static long write_longout(plongout) case (CONSTANT) : break; case (DB_LINK) : - status = dbPutLink(&plongout->out.value.db_link,plongout,DBR_LONG, + status = dbPutLink(&plongout->out.value.db_link,(struct dbCommon *)plongout,DBR_LONG, &plongout->val,1L); if(status!=0) { recGblSetSevr(plongout,LINK_ALARM,VALID_ALARM); diff --git a/src/dev/devMbbiMpv910.c b/src/dev/devMbbiMpv910.c index 2568b93fa..58b450683 100644 --- a/src/dev/devMbbiMpv910.c +++ b/src/dev/devMbbiMpv910.c @@ -41,11 +41,10 @@ #include #include -#include #include +#include #include #include -#include #include #include diff --git a/src/dev/devMbbiSoft.c b/src/dev/devMbbiSoft.c index 052d9708a..ac361e018 100644 --- a/src/dev/devMbbiSoft.c +++ b/src/dev/devMbbiSoft.c @@ -40,11 +40,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -107,7 +106,7 @@ static long read_mbbi(pmbbi) case (DB_LINK) : options=0; nRequest=1; - status = dbGetLink(&(pmbbi->inp.value.db_link),pmbbi,DBR_USHORT, + status = dbGetLink(&(pmbbi->inp.value.db_link),(struct dbCommon *)pmbbi,DBR_USHORT, &(pmbbi->val),&options,&nRequest); if(status!=0) { recGblSetSevr(pmbbi,LINK_ALARM,VALID_ALARM); diff --git a/src/dev/devMbbiSoftRaw.c b/src/dev/devMbbiSoftRaw.c index 4c91898eb..56cb0ff81 100644 --- a/src/dev/devMbbiSoftRaw.c +++ b/src/dev/devMbbiSoftRaw.c @@ -31,6 +31,7 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set of alarm stat and sevr to macros + * .02 02-05-92 jba Changed function arguments from paddr to precord * ... */ @@ -40,11 +41,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -106,7 +106,7 @@ static long read_mbbi(pmbbi) case (DB_LINK) : options=0; nRequest=1; - status = dbGetLink(&(pmbbi->inp.value.db_link),pmbbi,DBR_ULONG, + status = dbGetLink(&(pmbbi->inp.value.db_link),(struct dbCommon *)pmbbi,DBR_ULONG, &(pmbbi->rval),&options,&nRequest); if(status!=0) { recGblSetSevr(pmbbi,LINK_ALARM,VALID_ALARM); diff --git a/src/dev/devMbbiTestAsyn.c b/src/dev/devMbbiTestAsyn.c index 38ffa7421..038b86d9b 100644 --- a/src/dev/devMbbiTestAsyn.c +++ b/src/dev/devMbbiTestAsyn.c @@ -31,6 +31,8 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set of alarm stat and sevr to macros + * .02 01-08-92 jba Added cast in call to wdStart to avoid compile warning msg + * .03 02-05-92 jba Changed function arguments from paddr to precord * ... */ @@ -41,6 +43,7 @@ #include #include +#include #include #include #include @@ -84,9 +87,9 @@ static void myCallback(pcallback) struct mbbiRecord *pmbbi=(struct mbbiRecord *)(pcallback->prec); struct rset *prset=(struct rset *)(pmbbi->rset); - dbScanLock(pmbbi); - (*prset->process)(pmbbi->pdba); - dbScanUnlock(pmbbi); + dbScanLock((struct dbCommon *)pmbbi); + (*prset->process)(pmbbi); + dbScanUnlock((struct dbCommon *)pmbbi); } @@ -136,7 +139,7 @@ static long read_mbbi(pmbbi) wait_time = (int)(pmbbi->disv * vxTicksPerSecond); if(wait_time<=0) return(0); printf("%s Starting asynchronous processing\n",pmbbi->name); - wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + wdStart(pcallback->wd_id,wait_time,callbackRequest,(int)pcallback); return(1); } default : diff --git a/src/dev/devMbbiXVme210.c b/src/dev/devMbbiXVme210.c index faa39caa6..4ca587dd1 100644 --- a/src/dev/devMbbiXVme210.c +++ b/src/dev/devMbbiXVme210.c @@ -41,11 +41,10 @@ #include #include -#include #include +#include #include #include -#include #include #include diff --git a/src/dev/devMbboMpv902.c b/src/dev/devMbboMpv902.c index bffdd0339..3658ab501 100644 --- a/src/dev/devMbboMpv902.c +++ b/src/dev/devMbboMpv902.c @@ -41,11 +41,10 @@ #include #include -#include #include +#include #include #include -#include #include #include diff --git a/src/dev/devMbboSoft.c b/src/dev/devMbboSoft.c index 058451bcb..fad637349 100644 --- a/src/dev/devMbboSoft.c +++ b/src/dev/devMbboSoft.c @@ -40,11 +40,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -81,7 +80,7 @@ static long write_mbbo(pmbbo) case (CONSTANT) : break; case (DB_LINK) : - status = dbPutLink(&pmbbo->out.value.db_link,pmbbo,DBR_USHORT, + status = dbPutLink(&pmbbo->out.value.db_link,(struct dbCommon *)pmbbo,DBR_USHORT, &pmbbo->val,1L); if(status!=0) { recGblSetSevr(pmbbo,LINK_ALARM,VALID_ALARM); diff --git a/src/dev/devMbboTestAsyn.c b/src/dev/devMbboTestAsyn.c index 0e546ba22..6d6ea456a 100644 --- a/src/dev/devMbboTestAsyn.c +++ b/src/dev/devMbboTestAsyn.c @@ -31,6 +31,8 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set of alarm stat and sevr to macros + * .02 01-08-92 jba Added cast in call to wdStart to avoid compile warning msg + * .03 02-05-92 jba Changed function arguments from paddr to precord * ... */ @@ -41,6 +43,7 @@ #include #include +#include #include #include #include @@ -84,9 +87,9 @@ static void myCallback(pcallback) struct mbboRecord *pmbbo=(struct mbboRecord *)(pcallback->prec); struct rset *prset=(struct rset *)(pmbbo->rset); - dbScanLock(pmbbo); - (*prset->process)(pmbbo->pdba); - dbScanUnlock(pmbbo); + dbScanLock((struct dbCommon *)pmbbo); + (*prset->process)(pmbbo); + dbScanUnlock((struct dbCommon *)pmbbo); } @@ -134,7 +137,7 @@ static long write_mbbo(pmbbo) wait_time = (int)(pmbbo->disv * vxTicksPerSecond); if(wait_time<=0) return(0); printf("%s Starting asynchronous processing\n",pmbbo->name); - wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + wdStart(pcallback->wd_id,wait_time,callbackRequest,(int)pcallback); return(1); } default : diff --git a/src/dev/devMbboXVme220.c b/src/dev/devMbboXVme220.c index 6950e772c..be5fe3527 100644 --- a/src/dev/devMbboXVme220.c +++ b/src/dev/devMbboXVme220.c @@ -41,11 +41,10 @@ #include #include -#include #include +#include #include #include -#include #include #include diff --git a/src/dev/devMz8310.c b/src/dev/devMz8310.c index 189aa8eaf..89423486e 100644 --- a/src/dev/devMz8310.c +++ b/src/dev/devMz8310.c @@ -31,40 +31,44 @@ * ----------------- * .01 10-22-91 mrk Initial Implementation * .02 11-26-91 jba Initialized clockDiv to 0 - * .03 11-11-91 jba Moved set of alarm stat and sevr to macros + * .03 12-11-91 jba Moved set of alarm stat and sevr to macros + * .04 01-14-92 mrk Added interrupt support * ... */ - -/* In order to understand the code in the file you must first */ + + +/* In order to understand the code in this file you must first */ /* understand the MIZAR 8310 Users Manual. */ /* You must also understand Chapter 1 of the */ /* the Advanced Micro Devices Am9513 Technical Manual */ - + #include #include #include #include +#include <68k/iv.h> #include -#include #include #include +#include #include #include #include -#include +#include #include #include +#include #include #include #include - /* Create the dsets for devMz8310 */ long report(); long init(); long init_pc(); long init_pd(); long init_pt(); +long get_ioint_info(); long cmd_pc(); long write_pd(); long write_pt(); @@ -76,35 +80,60 @@ typedef struct { DEVSUPFUN init_record; DEVSUPFUN get_ioint_info; DEVSUPFUN write;} MZDSET; -MZDSET devPcMz8310={ 5, report, init, init_pc, NULL, cmd_pc}; -MZDSET devPdMz8310={ 5, NULL, NULL, init_pd, NULL, write_pd}; -MZDSET devPtMz8310={ 5, NULL, NULL, init_pt, NULL, write_pt}; +/*It doesnt matter who honors report or init thus let 1st devSup do it*/ +MZDSET devEventMz8310= { 5, report, init, NULL, get_ioint_info, NULL}; +MZDSET devPcMz8310= { 5, NULL, NULL, init_pc, NULL, cmd_pc}; +MZDSET devPdMz8310= { 5, NULL, NULL, init_pd, NULL, write_pd}; +MZDSET devPtMz8310= { 5, NULL, NULL, init_pt, NULL, write_pt}; +/*forward references */ +void mz8310_int_service(IOSCANPVT); + +volatile int mz8310Debug=0; + +static unsigned short *shortaddr; +/* definitions related to fields of records*/ /* defs for gsrc and csrc fields */ #define INTERNAL 0 #define EXTERNAL 1 #define SOFTWARE 1 - /* defs for counter commands */ #define CTR_READ 0 #define CTR_CLEAR 1 #define CTR_START 2 #define CTR_STOP 3 #define CTR_SETUP 4 - + /* defines specific to mz8310*/ -#define MAXCARDS 4 static unsigned short BASE; +#define MAXCARDS 4 #define CARDSIZE 0x00000100 - +#define NUMINTVEC 4 #define CHIPSIZE 0x20 #define CHANONCHIP 5 #define NCHIP 2 -/*static*/ - unsigned short *shortaddr; -int mz8310Debug=0; +static struct { + unsigned char irq_lev; /*interrupt request level */ + unsigned char vec_addr; /*offset from base register*/ +}mz8310_strap_info[NUMINTVEC] = { + {1,0x41},{3,0x61},{5,0x81},{6,0xA1}}; + +/*keep information needed for reporting*/ +static int ncards=0; +static struct mz8310_info { + short present; + struct { + short connected; + short nrec_using; + IOSCANPVT ioscanpvt; + } int_info[NUMINTVEC]; + struct { + short nrec_using; + } chan_info[NCHIP][CHANONCHIP]; +}mz8310_info[MAXCARDS]; + #define PCMDREG(CARD,CHIP) \ ( (unsigned char *)\ @@ -112,6 +141,14 @@ int mz8310Debug=0; #define PDATAREG(CARD,CHIP) \ ( (unsigned short *)\ ((unsigned char*)shortaddr + BASE + (CARD)*CARDSIZE + (CHIP)*CHIPSIZE)) +#define MZ8310INTVEC(CARD,INTVEC) \ +( (unsigned char) \ + (MZ8310_INT_VEC_BASE + (CARD)*NUMINTVEC + (INTVEC))) +#define PVECREG(CARD,INTVEC) \ +( (unsigned char *)\ + ((unsigned char*)shortaddr + BASE + (CARD)*CARDSIZE + mz8310_strap_info[(INTVEC)].vec_addr)) + +/*definitions for am9513 stc chip */ /* Internal clock rate and rate divisor */ #define INT_CLOCK_RATE 4e6 @@ -145,7 +182,7 @@ int mz8310Debug=0; #define ENAPRE 0xf8 #define DISPRE 0xf9 #define RESET 0xff - + /* Count Source Selection */ #define SRC1 0x0100 #define SRC2 0x0200 @@ -159,19 +196,7 @@ static unsigned short externalCountSource[] = {SRC1,SRC2,SRC3,SRC4,SRC5}; #define F4 0x0e00 #define F5 0x0f00 static unsigned short internalCountSource[] = {F1,F2,F3,F4,F5}; - -/*static*/ - int ncards=0; -/*static*/ - struct mz8310_info { - short present; - struct { - short used; - short type; - } chan_info[NCHIP][CHANONCHIP]; -}mz8310_info[MAXCARDS]; - - + /*The following are used to communicate with the mz8310. */ /*The mz8310 can not keep up when commands are sent as rapidly as possible.*/ @@ -210,11 +235,9 @@ getData(preg,pdata) static long init(after) short after; { - int card,chip,channel; -/*volatile*/ - unsigned char *pcmd; -/*volatile*/ - unsigned short *pdata; + int card,chip,channel,intvec; + volatile unsigned char *pcmd; + volatile unsigned short *pdata; unsigned short data; int dummy; @@ -248,6 +271,12 @@ static long init(after) } } } + /*Initialize I/O scanning for each interrupt vector */ + /*Note that interrupt vectors are not initialized until the */ + /*first record is attached via get_ioint_info. */ + if(mz8310_info[card].present) for(intvec=0; intvec=CHANONCHIP ? 1 : 0); channel = signal - chip*CHANONCHIP; - if((mz8310_info[card].chan_info[chip][channel].used +=1)>1) + if((mz8310_info[card].chan_info[chip][channel].nrec_using +=1)>1) recGblRecordError(S_dev_Conflict,pdbCommon, "devMz8310 (init_record) signal already used"); - mz8310_info[card].chan_info[chip][channel].type = pdbCommon->pdba->record_type; if(nchan==2) { - if((mz8310_info[card].chan_info[chip][channel+1].used +=1)>1) + if((mz8310_info[card].chan_info[chip][channel+1].nrec_using +=1)>1) recGblRecordError(S_dev_Conflict,pdbCommon, "devMz8310 (init_record) signal already used"); - mz8310_info[card].chan_info[chip][channel+1].type - = pdbCommon->pdba->record_type; } return(0); } @@ -362,6 +393,64 @@ static long init_pt(pr) return(0); } +static void mz8310_int_service(IOSCANPVT ioscanpvt) +{ + scanIoRequest(ioscanpvt); +} + +static long get_ioint_info( + short *cmd, + struct eventRecord *pr, + IOSCANPVT *ppvt) +{ + struct vmeio *pvmeio = (struct vmeio *)(&pr->inp.value); + unsigned int card,intvec; + + *ppvt = NULL; /*initialize pvt to null*/ + card = pvmeio->card; + intvec = pvmeio->signal; + if(card>=MAXCARDS){ + recGblRecordError(S_dev_badCard,pr, + "devMz8310 (get_ioint_info) exceeded maximum supported cards"); + return(0); + } + if(intvec>=NUMINTVEC) { + recGblRecordError(S_dev_badSignal,pr, + "devMz8310 (get_ioint_info) Illegal SIGNAL field"); + return(0); + } + if(!mz8310_info[card].present){ + recGblRecordError(S_dev_badCard,pr, + "devMz8310 (get_ioint_info) card not found"); + return(0); + } + *ppvt = mz8310_info[card].int_info[intvec].ioscanpvt; + if(*cmd!=0) { + if(*cmd==1) mz8310_info[card].int_info[intvec].nrec_using -= 1; + return(0); + } + mz8310_info[card].int_info[intvec].nrec_using +=1; + if(!mz8310_info[card].int_info[intvec].connected) { + unsigned char vector; + unsigned char *pvecreg; + + vector=MZ8310INTVEC(card,intvec); + if(intConnect(INUM_TO_IVEC(vector),(FUNCPTR)mz8310_int_service, + (int)mz8310_info[card].int_info[intvec].ioscanpvt)!=OK) { + recGblRecordError(0,pr,"devMz8310 (get_ioint_info) intConnect failed"); + return(0); + } + pvecreg = PVECREG(card,intvec); + if(vxMemProbe(pvecreg,WRITE,sizeof(char),&vector)!=OK) { + recGblRecordError(0,pr,"devMz8310 (get_ioint_info) vxMemProbe failed"); + return(0); + } + sysIntEnable(mz8310_strap_info[intvec].irq_lev); + mz8310_info[card].int_info[intvec].connected = TRUE; + } + return(0); +} + static long cmd_pc(pr) struct pulseCounterRecord *pr; { diff --git a/src/dev/devPtSoft.c b/src/dev/devPtSoft.c index 6bb3d1dd5..c7baa4f46 100644 --- a/src/dev/devPtSoft.c +++ b/src/dev/devPtSoft.c @@ -39,11 +39,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -78,7 +77,7 @@ static long write_pt(ppt) case (CONSTANT) : break; case (DB_LINK) : - status = dbPutLink(&ppt->out.value.db_link,ppt,DBR_SHORT,&ppt->val,1L); + status = dbPutLink(&ppt->out.value.db_link,(struct dbCommon *)ppt,DBR_SHORT,&ppt->val,1L); if(status!=0) { recGblSetSevr(ppt,LINK_ALARM,VALID_ALARM); } else ppt->udf=FALSE; diff --git a/src/dev/devSiSoft.c b/src/dev/devSiSoft.c index c7d07e545..e3e8034fe 100644 --- a/src/dev/devSiSoft.c +++ b/src/dev/devSiSoft.c @@ -38,11 +38,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -109,7 +108,7 @@ static long read_stringin(pstringin) case (DB_LINK) : options=0; nRequest=1; - status = dbGetLink(&(pstringin->inp.value.db_link),pstringin,DBR_STRING, + status = dbGetLink(&(pstringin->inp.value.db_link),(struct dbCommon *)pstringin,DBR_STRING, pstringin->val,&options,&nRequest); if(status!=0) { recGblSetSevr(pstringin,LINK_ALARM,VALID_ALARM); diff --git a/src/dev/devSiTestAsyn.c b/src/dev/devSiTestAsyn.c index 425e04fba..f6f471780 100644 --- a/src/dev/devSiTestAsyn.c +++ b/src/dev/devSiTestAsyn.c @@ -30,6 +30,8 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set of alarm stat and sevr to macros + * .02 01-08-92 jba Added cast in call to wdStart to avoid compile warning msg + * .03 02-05-92 jba Changed function arguments from paddr to precord * ... */ @@ -40,6 +42,7 @@ #include #include +#include #include #include #include @@ -83,9 +86,9 @@ static void myCallback(pcallback) struct stringinRecord *pstringin=(struct stringinRecord *)(pcallback->prec); struct rset *prset=(struct rset *)(pstringin->rset); - dbScanLock(pstringin); - (*prset->process)(pstringin->pdba); - dbScanUnlock(pstringin); + dbScanLock((struct dbCommon *)pstringin); + (*prset->process)(pstringin); + dbScanUnlock((struct dbCommon *)pstringin); } @@ -137,7 +140,7 @@ static long read_stringin(pstringin) wait_time = (int)(pstringin->disv * vxTicksPerSecond); if(wait_time<=0) return(0); printf("%s Starting asynchronous processing\n",pstringin->name); - wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + wdStart(pcallback->wd_id,wait_time,callbackRequest,(int)pcallback); return(1); } default : diff --git a/src/dev/devSoSoft.c b/src/dev/devSoSoft.c index 2f8cf071c..03497f100 100644 --- a/src/dev/devSoSoft.c +++ b/src/dev/devSoSoft.c @@ -37,11 +37,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -75,7 +74,7 @@ static long write_stringout(pstringout) case (CONSTANT) : break; case (DB_LINK) : - status = dbPutLink(&pstringout->out.value.db_link,pstringout,DBR_STRING, + status = dbPutLink(&pstringout->out.value.db_link,(struct dbCommon *)pstringout,DBR_STRING, pstringout->val,1L); if(status!=0) { recGblSetSevr(pstringout,LINK_ALARM,VALID_ALARM); diff --git a/src/dev/devSoTestAsyn.c b/src/dev/devSoTestAsyn.c index 0155697b3..7f8349485 100644 --- a/src/dev/devSoTestAsyn.c +++ b/src/dev/devSoTestAsyn.c @@ -30,6 +30,8 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set of alarm stat and sevr to macros + * .02 01-08-92 jba Added cast in call to wdStart to avoid compile warning msg + * .03 02-05-92 jba Changed function arguments from paddr to precord * ... */ @@ -40,6 +42,7 @@ #include #include +#include #include #include #include @@ -83,9 +86,9 @@ static void myCallback(pcallback) struct stringoutRecord *pstringout=(struct stringoutRecord *)(pcallback->prec); struct rset *prset=(struct rset *)(pstringout->rset); - dbScanLock(pstringout); - (*prset->process)(pstringout->pdba); - dbScanUnlock(pstringout); + dbScanLock((struct dbCommon *)pstringout); + (*prset->process)(pstringout); + dbScanUnlock((struct dbCommon *)pstringout); } @@ -133,7 +136,7 @@ static long write_stringout(pstringout) wait_time = (int)(pstringout->disv * vxTicksPerSecond); if(wait_time<=0) return(0); printf("%s Starting asynchronous processing\n",pstringout->name); - wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + wdStart(pcallback->wd_id,wait_time,callbackRequest,(int)pcallback); return(1); } default : diff --git a/src/dev/devWfJoergerVtr1.c b/src/dev/devWfJoergerVtr1.c index c6dbf70c1..6eb994dae 100644 --- a/src/dev/devWfJoergerVtr1.c +++ b/src/dev/devWfJoergerVtr1.c @@ -33,6 +33,7 @@ * .01 11-11-91 jba Moved set of alarm stat and sevr to macros * .02 12-02-91 jba Added cmd control to io-interrupt processing * .03 12-12-91 jba Set cmd to zero in io-interrupt processing + * .04 02-05-92 jba Changed function arguments from paddr to precord * ... */ @@ -88,7 +89,7 @@ static void myCallback(pcallback,no_read,pdata) long i; if(!pwf->busy) return; - dbScanLock(pwf); + dbScanLock((struct dbCommon *)pwf); pwf->busy = FALSE; if(no_read>pwf->nelm)no_read = pwf->nelm; if(ftvl==DBF_CHAR || ftvl==DBF_UCHAR) { @@ -110,8 +111,8 @@ static void myCallback(pcallback,no_read,pdata) "read_wf - illegal ftvl"); recGblSetSevr(pwf,READ_ALARM,VALID_ALARM); } - (pcallback->process)(&pcallback->dbAddr); - dbScanUnlock(pwf); + (pcallback->process)(pwf); + dbScanUnlock((struct dbCommon *)pwf); } static long get_ioint_info(cmd,pwf,io_type,card_type,card_number) @@ -121,7 +122,7 @@ static long get_ioint_info(cmd,pwf,io_type,card_type,card_number) short *card_type; short *card_number; { - *cmd=0; + *cmd=-1; if(pwf->inp.type != VME_IO) return(S_dev_badInpType); *io_type = IO_WF; *card_type = JGVTR1; diff --git a/src/dev/devWfSoft.c b/src/dev/devWfSoft.c index 55ad95dc9..76a24e013 100644 --- a/src/dev/devWfSoft.c +++ b/src/dev/devWfSoft.c @@ -104,7 +104,7 @@ static long read_wf(pwf) case (DB_LINK) : options=0; nRequest=pwf->nelm; - if(dbGetLink(&(pwf->inp.value.db_link),pwf,pwf->ftvl, + if(dbGetLink(&(pwf->inp.value.db_link),(struct dbCommon *)pwf,pwf->ftvl, pwf->bptr,&options,&nRequest)!=0){ recGblSetSevr(pwf,LINK_ALARM,VALID_ALARM); } diff --git a/src/dev/devWfTestAsyn.c b/src/dev/devWfTestAsyn.c index 8af87fd28..0662284b3 100644 --- a/src/dev/devWfTestAsyn.c +++ b/src/dev/devWfTestAsyn.c @@ -31,6 +31,8 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set of alarm stat and sevr to macros + * .02 01-08-92 jba Added cast in call to wdStart to avoid compile warning msg + * .03 02-05-92 jba Changed function arguments from paddr to precord * ... */ @@ -41,6 +43,7 @@ #include #include +#include #include #include #include @@ -83,9 +86,9 @@ static void myCallback(pcallback) struct waveformRecord *pwf=(struct waveformRecord *)(pcallback->prec); struct rset *prset=(struct rset *)(pwf->rset); - dbScanLock(pwf); - (*prset->process)(pwf->pdba); - dbScanUnlock(pwf); + dbScanLock((struct dbCommon *)pwf); + (*prset->process)(pwf); + dbScanUnlock((struct dbCommon *)pwf); } static long init_record(pwf) struct waveformRecord *pwf; @@ -131,7 +134,7 @@ static long read_wf(pwf) wait_time = (int)(pwf->disv * vxTicksPerSecond); if(wait_time<=0) return(0); printf("%s Starting asynchronous processing\n",pwf->name); - wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + wdStart(pcallback->wd_id,wait_time,callbackRequest,(int)pcallback); return(1); } default : diff --git a/src/dev/devWfXy566Sc.c b/src/dev/devWfXy566Sc.c index c8563426f..fc095085f 100644 --- a/src/dev/devWfXy566Sc.c +++ b/src/dev/devWfXy566Sc.c @@ -31,6 +31,7 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set of alarm stat and sevr to macros + * .02 02-05-92 jba Changed function arguments from paddr to precord * ... */ @@ -84,7 +85,7 @@ static void myCallback(pcallback,no_read,pdata) short ftvl = pwf->ftvl; if(!pwf->busy) return; - dbScanLock(pwf); + dbScanLock((struct dbCommon *)pwf); pwf->busy = FALSE; if(ftvl==DBF_SHORT || ftvl==DBF_USHORT) { bcopy(pdata,pwf->bptr,no_read*2); @@ -94,8 +95,8 @@ static void myCallback(pcallback,no_read,pdata) "read_wf - illegal ftvl"); recGblSetSevr(pwf,READ_ALARM,VALID_ALARM); } - (pcallback->process)(&pcallback->dbAddr); - dbScanUnlock(pwf); + (pcallback->process)(pwf); + dbScanUnlock((struct dbCommon *)pwf); } static long init_record(pwf,process) diff --git a/src/rec/recAi.c b/src/rec/recAi.c index 04c292966..256c4f0fd 100644 --- a/src/rec/recAi.c +++ b/src/rec/recAi.c @@ -57,6 +57,8 @@ * .17 09-18-91 jba fixed bug in break point table conversion * .18 09-30-91 jba Moved break point table conversion to libCom * .19 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .20 12-18-91 jba Changed E_IO_INTERRUPT to SCAN_IO_EVENT + * .21 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -65,12 +67,12 @@ #include #include -#include #include +#include +#include #include #include #include -#include #include #include #include @@ -127,8 +129,6 @@ struct aidset { /* analog input dset */ }; -/*NOTE FOLLOWING IS TAKEN FROM dbScan.c */ -#define E_IO_INTERRUPT 7 /*Following from timing system */ extern unsigned int gts_trigger_counter; @@ -160,10 +160,9 @@ static long init_record(pai) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(pai) + struct aiRecord *pai; { - struct aiRecord *pai=(struct aiRecord *)(paddr->precord); struct aidset *pdset = (struct aidset *)(pai->dset); long status; @@ -174,7 +173,7 @@ static long process(paddr) } /* event throttling */ - if (pai->scan == E_IO_INTERRUPT){ + if (pai->scan == SCAN_IO_EVENT){ if ((pai->evnt != 0) && (gts_trigger_counter != 0)){ if ((gts_trigger_counter % pai->evnt) != 0){ return(0); @@ -196,7 +195,7 @@ static long process(paddr) /* check event list */ monitor(pai); /* process the forward scan link record */ - if (pai->flnk.type==DB_LINK) dbScanPassive(pai->flnk.value.db_link.pdbAddr); + if (pai->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)pai->flnk.value.db_link.pdbAddr)->precord); pai->init=FALSE; pai->pact=FALSE; diff --git a/src/rec/recAo.c b/src/rec/recAo.c index 9bd60895a..a8d703851 100644 --- a/src/rec/recAo.c +++ b/src/rec/recAo.c @@ -52,6 +52,7 @@ * .19 10-10-90 mrk extensible record and device support * .20 09-25-91 jba added breakpoint table conversion * .21 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .22 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -60,12 +61,11 @@ #include #include -#include #include +#include #include #include #include -#include #include #include #include @@ -185,10 +185,9 @@ static long init_record(pao) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(pao) + struct aoRecord *pao; { - struct aoRecord *pao=(struct aoRecord *)(paddr->precord); struct aodset *pdset = (struct aodset *)(pao->dset); long status=0; @@ -215,7 +214,7 @@ static long process(paddr) monitor(pao); /* process the forward scan link record */ - if (pao->flnk.type==DB_LINK) dbScanPassive(pao->flnk.value.db_link.pdbAddr); + if (pao->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)pao->flnk.value.db_link.pdbAddr)->precord); pao->init=FALSE; pao->pact=FALSE; @@ -369,7 +368,7 @@ static int convert(pao) pao->pact = TRUE; /* don't allow dbputs to val field */ pao->val=pao->pval; - status = dbGetLink(&pao->dol.value.db_link,pao,DBR_DOUBLE, + status = dbGetLink(&pao->dol.value.db_link,(struct dbCommon *)pao,DBR_DOUBLE, &value,&options,&nRequest); pao->pact = save_pact; if(status) { diff --git a/src/rec/recBi.c b/src/rec/recBi.c index a5fee29a5..c14bf5b2b 100644 --- a/src/rec/recBi.c +++ b/src/rec/recBi.c @@ -46,6 +46,7 @@ * .12 10-10-90 mrk Made changes for new record and device support * .13 10-24-91 jba Moved comment * .14 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .15 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -55,12 +56,11 @@ #include #include -#include #include +#include #include #include #include -#include #include #include #include @@ -135,10 +135,9 @@ static long init_record(pbi) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(pbi) + struct biRecord *pbi; { - struct biRecord *pbi=(struct biRecord *)(paddr->precord); struct bidset *pdset = (struct bidset *)(pbi->dset); long status; @@ -164,7 +163,7 @@ static long process(paddr) /* check event list */ monitor(pbi); /* process the forward scan link record */ - if (pbi->flnk.type==DB_LINK) dbScanPassive(pbi->flnk.value.db_link.pdbAddr); + if (pbi->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)pbi->flnk.value.db_link.pdbAddr)->precord); pbi->pact=FALSE; return(status); diff --git a/src/rec/recBo.c b/src/rec/recBo.c index a4a887ba8..c0f366e67 100644 --- a/src/rec/recBo.c +++ b/src/rec/recBo.c @@ -52,6 +52,8 @@ * .16 05-02-90 lrd fix initial value set in the DOL field * .17 10-10-90 mrk Changes for record and device support * .18 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .19 01-08-92 jba Added cast in call to wdStart to remove compile warning message + * .20 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -62,12 +64,12 @@ #include #include -#include +#include #include +#include #include #include #include -#include #include #include #include @@ -141,10 +143,10 @@ static void myCallback(pcallback) short value=0; struct boRecord *pbo = (struct boRecord *)(pcallback->dbAddr.precord); - dbScanLock(pbo); + dbScanLock((struct dbCommon *)pbo); pbo->val = 0; - (void)process(&(pcallback->dbAddr)); - dbScanUnlock(pbo); + (void)process(pbo); + dbScanUnlock((struct dbCommon *)pbo); } static long init_record(pbo) @@ -188,10 +190,9 @@ static long init_record(pbo) return(status); } -static long process(paddr) - struct dbAddr *paddr; +static long process(pbo) + struct boRecord *pbo; { - struct boRecord *pbo=(struct boRecord *)(paddr->precord); struct bodset *pdset = (struct bodset *)(pbo->dset); long status=0; int wait_time; @@ -208,7 +209,7 @@ static long process(paddr) unsigned short val; pbo->pact = TRUE; - status = dbGetLink(&pbo->dol.value.db_link,pbo, + status = dbGetLink(&pbo->dol.value.db_link,(struct dbCommon *)pbo, DBR_USHORT,&val,&options,&nRequest); pbo->pact = FALSE; if(status==0){ @@ -236,14 +237,14 @@ static long process(paddr) pcallback = (struct callback *)(pbo->dpvt); if(pcallback->wd_id==NULL) pcallback->wd_id = wdCreate(); - wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + wdStart(pcallback->wd_id,wait_time,callbackRequest,(int)pcallback); } /* check for alarms */ alarm(pbo); /* check event list */ monitor(pbo); /* process the forward scan link record */ - if (pbo->flnk.type==DB_LINK) dbScanPassive(pbo->flnk.value.db_link.pdbAddr); + if (pbo->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)pbo->flnk.value.db_link.pdbAddr)->precord); pbo->pact=FALSE; return(status); diff --git a/src/rec/recCalc.c b/src/rec/recCalc.c index 7ae002539..3bbe4dd6a 100644 --- a/src/rec/recCalc.c +++ b/src/rec/recCalc.c @@ -59,6 +59,7 @@ * Note that all calc specific details moved * to libCalc * .19 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .20 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -67,11 +68,10 @@ #include #include -#include #include +#include #include #include -#include #include #include #include @@ -143,10 +143,9 @@ static long init_record(pcalc) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(pcalc) + struct calcRecord *pcalc; { - struct calcRecord *pcalc=(struct calcRecord *)(paddr->precord); pcalc->pact = TRUE; if(fetch_values(pcalc)==0) { @@ -160,7 +159,7 @@ static long process(paddr) /* check event list */ monitor(pcalc); /* process the forward scan link record */ - if (pcalc->flnk.type==DB_LINK) dbScanPassive(pcalc->flnk.value.db_link.pdbAddr); + if (pcalc->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)pcalc->flnk.value.db_link.pdbAddr)->precord); pcalc->pact = FALSE; return(0); } @@ -364,7 +363,7 @@ struct calcRecord *pcalc; if(plink->type!=DB_LINK) continue; options=0; nRequest=1; - status = dbGetLink(&plink->value.db_link,pcalc,DBR_DOUBLE, + status = dbGetLink(&plink->value.db_link,(struct dbCommon *)pcalc,DBR_DOUBLE, pvalue,&options,&nRequest); if(status!=0) { recGblSetSevr(pcalc,LINK_ALARM,VALID_ALARM); diff --git a/src/rec/recCompress.c b/src/rec/recCompress.c index 8a72715e7..facfe006f 100644 --- a/src/rec/recCompress.c +++ b/src/rec/recCompress.c @@ -49,6 +49,7 @@ * value was not initialized * .10 10-11-90 mrk Made changes for new record support * .11 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .12 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -58,11 +59,10 @@ #include #include -#include #include +#include #include #include -#include #include #include #include @@ -139,11 +139,10 @@ static long init_record(pcompress) } -static long process(paddr) - struct dbAddr *paddr; +static long process(pcompress) + struct compressRecord *pcompress; { - struct compressRecord *pcompress=(struct compressRecord *)(paddr->precord); - long status=0; + long status=0; pcompress->pact = TRUE; @@ -159,8 +158,8 @@ static long process(paddr) long no_elements=pdbAddr->no_elements; int alg=pcompress->alg; - if(dbGetLink(&pcompress->inp.value.db_link,pcompress,DBR_DOUBLE,pcompress->wptr, - &options,&no_elements)!=0){ + if(dbGetLink(&pcompress->inp.value.db_link,(struct dbCommon *)pcompress, + DBR_DOUBLE,pcompress->wptr,&options,&no_elements)!=0){ recGblSetSevr(pcompress,LINK_ALARM,VALID_ALARM); } @@ -182,7 +181,8 @@ static long process(paddr) tsLocalTime(&pcompress->time); monitor(pcompress); /* process the forward scan link record */ - if (pcompress->flnk.type==DB_LINK) dbScanPassive(pcompress->flnk.value.db_link.pdbAddr); + if (pcompress->flnk.type==DB_LINK) + dbScanPassive(((struct dbAddr *)pcompress->flnk.value.db_link.pdbAddr)->precord); } pcompress->pact=FALSE; diff --git a/src/rec/recEvent.c b/src/rec/recEvent.c index c25411ff6..e9ec77719 100644 --- a/src/rec/recEvent.c +++ b/src/rec/recEvent.c @@ -38,12 +38,12 @@ #include #include -#include #include +#include +#include #include #include #include -#include #include #include #include @@ -101,43 +101,27 @@ static long init_record(pevent) struct eventRecord *pevent; { struct eventdset *pdset; - long status; + long status=0; - if(!(pdset = (struct eventdset *)(pevent->dset))) { - recGblRecordError(S_dev_noDSET,pevent,"event: init_record"); - return(S_dev_noDSET); - } - /* must have read_event function defined */ - if( (pdset->number < 5) || (pdset->read_event == NULL) ) { - recGblRecordError(S_dev_missingSup,pevent,"event: init_record"); - return(S_dev_missingSup); - } - if( pdset->init_record ) { - if((status=(*pdset->init_record)(pevent,process))) return(status); - } - return(0); + if( (pdset=(struct eventdset *)(pevent->dset)) && (pdset->init_record) ) + status=(*pdset->init_record)(pevent,process); + return(status); } -static long process(paddr) - struct dbAddr *paddr; +static long process(pevent) + struct eventRecord *pevent; { - struct eventRecord *pevent=(struct eventRecord *)(paddr->precord); struct eventdset *pdset = (struct eventdset *)(pevent->dset); - long status; + long status=0; - if( (pdset==NULL) || (pdset->read_event==NULL) ) { - pevent->pact=TRUE; - recGblRecordError(S_dev_missingSup,pevent,"read_event"); - return(S_dev_missingSup); - } - - status=(*pdset->read_event)(pevent); /* read the new value */ + if((pdset!=NULL) && (pdset->number >= 5) && pdset->read_event ) + status=(*pdset->read_event)(pevent); /* read the new value */ pevent->pact = TRUE; /* status is one if an asynchronous record is being processed*/ if (status==1) return(0); - if(pevent->enum>0) post_event(enum); + if(pevent->val>0) post_event((int)pevent->val); tsLocalTime(&pevent->time); @@ -145,7 +129,7 @@ static long process(paddr) monitor(pevent); /* process the forward scan link record */ - if (pevent->flnk.type==DB_LINK) dbScanPassive(pevent->flnk.value.db_link.pdbAddr); + if (pevent->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)pevent->flnk.value.db_link.pdbAddr)->precord); pevent->pact=FALSE; return(status); @@ -156,9 +140,9 @@ static long get_value(pevent,pvdes) struct eventRecord *pevent; struct valueDes *pvdes; { - pvdes->field_type = DBF_SHORT; + pvdes->field_type = DBF_USHORT; pvdes->no_elements=1; - pvdes->pvalue = (caddr_t)(&pevent->val; + pvdes->pvalue = (caddr_t)(&pevent->val); return(0); } @@ -184,6 +168,6 @@ static void monitor(pevent) db_post_events(pevent,&pevent->sevr,DBE_VALUE); } - db_post_events(pevent,&(pevent->enum,monitor_mask|DBE_VALUE); + db_post_events(pevent,&pevent->val,monitor_mask|DBE_VALUE); return; } diff --git a/src/rec/recFanout.c b/src/rec/recFanout.c index dbf0fee09..95883b3f4 100644 --- a/src/rec/recFanout.c +++ b/src/rec/recFanout.c @@ -1,5 +1,4 @@ -/* recFanout.c */ -/* share/src/rec $Id$ */ +/* recFanout.c */ /* share/src/rec $Id$ */ /* recFanout.c - Record Support Routines for Fanout records */ /* @@ -40,6 +39,8 @@ * .08 09-25-91 jba added input link for seln * .09 09-26-91 jba added select_mask option * .10 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .11 02-05-92 jba Changed function arguments from paddr to precord + * .12 02-05-92 jba Added FWD scan link */ #include @@ -48,11 +49,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -111,10 +111,9 @@ static long init_record(pfanout) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(pfanout) + struct fanoutRecord *pfanout; { - struct fanoutRecord *pfanout=(struct fanoutRecord *)(paddr->precord); short stat,sevr,nsta,nsev; @@ -129,7 +128,7 @@ static long process(paddr) /* fetch link selection */ if(pfanout->sell.type == DB_LINK){ - status=dbGetLink(&(pfanout->sell.value.db_link),pfanout,DBR_USHORT, + status=dbGetLink(&(pfanout->sell.value.db_link),(struct dbCommon *)pfanout,DBR_USHORT, &(pfanout->seln),&options,&nRequest); if(status!=0) { recGblSetSevr(pfanout,LINK_ALARM,VALID_ALARM); @@ -137,12 +136,18 @@ static long process(paddr) } switch (pfanout->selm){ case (SELECT_ALL): - if (pfanout->lnk1.type==DB_LINK) dbScanPassive(pfanout->lnk1.value.db_link.pdbAddr); - if (pfanout->lnk2.type==DB_LINK) dbScanPassive(pfanout->lnk2.value.db_link.pdbAddr); - if (pfanout->lnk3.type==DB_LINK) dbScanPassive(pfanout->lnk3.value.db_link.pdbAddr); - if (pfanout->lnk4.type==DB_LINK) dbScanPassive(pfanout->lnk4.value.db_link.pdbAddr); - if (pfanout->lnk5.type==DB_LINK) dbScanPassive(pfanout->lnk5.value.db_link.pdbAddr); - if (pfanout->lnk6.type==DB_LINK) dbScanPassive(pfanout->lnk6.value.db_link.pdbAddr); + if (pfanout->lnk1.type==DB_LINK) + dbScanPassive(((struct dbAddr *)pfanout->lnk1.value.db_link.pdbAddr)->precord); + if (pfanout->lnk2.type==DB_LINK) + dbScanPassive(((struct dbAddr *)pfanout->lnk2.value.db_link.pdbAddr)->precord); + if (pfanout->lnk3.type==DB_LINK) + dbScanPassive(((struct dbAddr *)pfanout->lnk3.value.db_link.pdbAddr)->precord); + if (pfanout->lnk4.type==DB_LINK) + dbScanPassive(((struct dbAddr *)pfanout->lnk4.value.db_link.pdbAddr)->precord); + if (pfanout->lnk5.type==DB_LINK) + dbScanPassive(((struct dbAddr *)pfanout->lnk5.value.db_link.pdbAddr)->precord); + if (pfanout->lnk6.type==DB_LINK) + dbScanPassive(((struct dbAddr *)pfanout->lnk6.value.db_link.pdbAddr)->precord); break; case (SELECTED): if(pfanout->seln<0 || pfanout->seln>6) { @@ -154,7 +159,7 @@ static long process(paddr) } plink=&(pfanout->lnk1); plink += (pfanout->seln-1); - dbScanPassive(plink->value.db_link.pdbAddr); + dbScanPassive(((struct dbAddr *)plink->value.db_link.pdbAddr)->precord); break; case (SELECT_MASK): if(pfanout->seln==0) { @@ -167,7 +172,8 @@ static long process(paddr) plink=&(pfanout->lnk1); state=pfanout->seln; for ( i=0; i<6; i++, state>>=1, plink++) { - if(state & 1 && plink->type==DB_LINK) dbScanPassive(plink->value.db_link.pdbAddr); + if(state & 1 && plink->type==DB_LINK) + dbScanPassive(((struct dbAddr *)plink->value.db_link.pdbAddr)->precord); } break; default: @@ -182,6 +188,10 @@ static long process(paddr) db_post_events(pfanout,&pfanout->stat,DBE_VALUE); db_post_events(pfanout,&pfanout->sevr,DBE_VALUE); } + /* process the forward scan link record */ + if (pfanout->flnk.type==DB_LINK) + dbScanPassive(((struct dbAddr *)pfanout->flnk.value.db_link.pdbAddr)->precord); + pfanout->pact=FALSE; return(0); } diff --git a/src/rec/recHistogram.c b/src/rec/recHistogram.c index 0025ae020..3d8934a1b 100644 --- a/src/rec/recHistogram.c +++ b/src/rec/recHistogram.c @@ -30,6 +30,7 @@ * Modification Log: * ----------------- * .01 10-14-91 jba Added dev sup crtl fld and wd timer + * .02 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -42,12 +43,12 @@ #include #include -#include +#include #include +#include #include #include #include -#include #include #include #include @@ -56,7 +57,7 @@ #define report NULL #define initialize NULL long init_record(); -long process(); +static long process(); long special(); long get_value(); long cvt_dbaddr(); @@ -127,17 +128,17 @@ static void wdCallback(pcallback) /* force post events for any count change */ if(phistogram->mcnt>0){ - dbScanLock(phistogram); + dbScanLock((struct dbCommon *)phistogram); tsLocalTime(&phistogram->time); db_post_events(phistogram,&phistogram->bptr,DBE_VALUE); phistogram->mcnt=0; - dbScanUnlock(phistogram); + dbScanUnlock((struct dbCommon *)phistogram); } if(phistogram->sdel>0) { /* start new watchdog timer on monitor */ wait_time = (float)(phistogram->sdel * vxTicksPerSecond); - wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + wdStart(pcallback->wd_id,wait_time,callbackRequest,(int)pcallback); } return; @@ -169,7 +170,7 @@ static long init_record(phistogram) /* start new watchdog timer on monitor */ wait_time = (float)(phistogram->sdel * vxTicksPerSecond); - wdStart(pcallback->wd_id,wait_time,callbackRequest,pcallback); + wdStart(pcallback->wd_id,wait_time,callbackRequest,(int)pcallback); } /* allocate space for histogram array */ @@ -198,10 +199,9 @@ static long init_record(phistogram) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(phistogram) + struct histogramRecord *phistogram; { - struct histogramRecord *phistogram=(struct histogramRecord *)(paddr->precord); struct histogramdset *pdset = (struct histogramdset *)(phistogram->dset); long status; @@ -227,7 +227,7 @@ static long process(paddr) monitor(phistogram); /* process the forward scan link record */ - if (phistogram->flnk.type==DB_LINK) dbScanPassive(phistogram->flnk.value.db_link.pdbAddr); + if (phistogram->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)phistogram->flnk.value.db_link.pdbAddr)->precord); phistogram->pact=FALSE; return(status); diff --git a/src/rec/recLongin.c b/src/rec/recLongin.c index a5148832c..ce7e9468e 100644 --- a/src/rec/recLongin.c +++ b/src/rec/recLongin.c @@ -30,6 +30,7 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .02 02-05-92 jba Changed function arguments from paddr to precord */ @@ -39,12 +40,11 @@ #include #include -#include #include +#include #include #include #include -#include #include #include @@ -120,10 +120,9 @@ static long init_record(plongin) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(plongin) + struct longinRecord *plongin; { - struct longinRecord *plongin=(struct longinRecord *)(paddr->precord); struct longindset *pdset = (struct longindset *)(plongin->dset); long status; @@ -147,7 +146,7 @@ static long process(paddr) monitor(plongin); /* process the forward scan link record */ - if (plongin->flnk.type==DB_LINK) dbScanPassive(plongin->flnk.value.db_link.pdbAddr); + if (plongin->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)plongin->flnk.value.db_link.pdbAddr)->precord); plongin->pact=FALSE; return(status); diff --git a/src/rec/recLongout.c b/src/rec/recLongout.c index f4dd58836..832735ec2 100644 --- a/src/rec/recLongout.c +++ b/src/rec/recLongout.c @@ -30,6 +30,7 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .02 02-05-92 jba Changed function arguments from paddr to precord */ @@ -39,12 +40,11 @@ #include #include -#include #include +#include #include #include #include -#include #include #include @@ -126,10 +126,9 @@ static long init_record(plongout) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(plongout) + struct longoutRecord *plongout; { - struct longoutRecord *plongout=(struct longoutRecord *)(paddr->precord); struct longoutdset *pdset = (struct longoutdset *)(plongout->dset); long status=0; @@ -144,7 +143,7 @@ static long process(paddr) long nRequest=1; plongout->pact = TRUE; - status = dbGetLink(&plongout->dol.value.db_link,plongout, + status = dbGetLink(&plongout->dol.value.db_link,(struct dbCommon *)plongout, DBR_LONG,&plongout->val,&options,&nRequest); plongout->pact = FALSE; if(status!=0){ @@ -169,7 +168,7 @@ static long process(paddr) monitor(plongout); /* process the forward scan link record */ - if (plongout->flnk.type==DB_LINK) dbScanPassive(plongout->flnk.value.db_link.pdbAddr); + if (plongout->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)plongout->flnk.value.db_link.pdbAddr)->precord); plongout->pact=FALSE; return(status); diff --git a/src/rec/recMbbi.c b/src/rec/recMbbi.c index 439074b47..f039f9a4d 100644 --- a/src/rec/recMbbi.c +++ b/src/rec/recMbbi.c @@ -47,6 +47,7 @@ * .12 02-08-90 lrd add Allen-Bradley PLC support * .13 10-31-90 mrk changes for new record and device support * .14 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .15 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -56,12 +57,11 @@ #include #include -#include #include +#include #include #include #include -#include #include #include #include @@ -162,10 +162,9 @@ static long init_record(pmbbi) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(pmbbi) + struct mbbiRecord *pmbbi; { - struct mbbiRecord *pmbbi=(struct mbbiRecord *)(paddr->precord); struct mbbidset *pdset = (struct mbbidset *)(pmbbi->dset); long status; @@ -213,7 +212,7 @@ static long process(paddr) monitor(pmbbi); /* process the forward scan link record */ - if (pmbbi->flnk.type==DB_LINK) dbScanPassive(pmbbi->flnk.value.db_link.pdbAddr); + if (pmbbi->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)pmbbi->flnk.value.db_link.pdbAddr)->precord); pmbbi->pact=FALSE; return(status); diff --git a/src/rec/recMbbo.c b/src/rec/recMbbo.c index c40f2dd53..db791e600 100644 --- a/src/rec/recMbbo.c +++ b/src/rec/recMbbo.c @@ -50,6 +50,7 @@ * .15 04-11-90 lrd make locals static * .16 10-11-90 mrk make changes for new record and device support * .17 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .18 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -59,12 +60,11 @@ #include #include -#include #include +#include #include #include #include -#include #include #include #include @@ -199,10 +199,9 @@ static long init_record(pmbbo) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(pmbbo) + struct mbboRecord *pmbbo; { - struct mbboRecord *pmbbo=(struct mbboRecord *)(paddr->precord); struct mbbodset *pdset = (struct mbbodset *)(pmbbo->dset); long status=0; unsigned short rbv; @@ -221,7 +220,7 @@ static long process(paddr) unsigned short val; pmbbo->pact = TRUE; - status = dbGetLink(&pmbbo->dol.value.db_link,pmbbo,DBR_USHORT, + status = dbGetLink(&pmbbo->dol.value.db_link,(struct dbCommon *)pmbbo,DBR_USHORT, &val,&options,&nRequest); pmbbo->pact = FALSE; if(status==0) { @@ -261,7 +260,7 @@ DONT_WRITE: monitor(pmbbo); /* process the forward scan link record */ if(pmbbo->flnk.type==DB_LINK) - dbScanPassive(pmbbo->flnk.value.db_link.pdbAddr); + dbScanPassive(((struct dbAddr *)pmbbo->flnk.value.db_link.pdbAddr)->precord); pmbbo->pact=FALSE; return(status); } diff --git a/src/rec/recPermissive.c b/src/rec/recPermissive.c index ae2dc19c6..dec95aab2 100644 --- a/src/rec/recPermissive.c +++ b/src/rec/recPermissive.c @@ -32,6 +32,7 @@ * ----------------- * .01 10-10-90 mrk extensible record and device support * .02 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .03 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -39,11 +40,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -88,17 +88,16 @@ struct rset permissiveRSET={ void monitor(); -static long process(paddr) - struct dbAddr *paddr; +static long process(ppermissive) + struct permissiveRecord *ppermissive; { - struct permissiveRecord *ppermissive=(struct permissiveRecord *)(paddr->precord); ppermissive->pact=TRUE; ppermissive->udf=FALSE; tsLocalTime(&ppermissive->time); monitor(ppermissive); if (ppermissive->flnk.type==DB_LINK) - dbScanPassive(ppermissive->flnk.value.db_link.pdbAddr); + dbScanPassive(((struct dbAddr *)ppermissive->flnk.value.db_link.pdbAddr)->precord); ppermissive->pact=FALSE; return(0); } diff --git a/src/rec/recPid.c b/src/rec/recPid.c index 42c577c3c..11261db37 100644 --- a/src/rec/recPid.c +++ b/src/rec/recPid.c @@ -32,6 +32,7 @@ * ----------------- * .01 10-15-90 mrk changes for new record support * .02 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .03 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -42,11 +43,10 @@ unsigned long tickGet(); #include -#include #include +#include #include #include -#include #include #include @@ -106,10 +106,9 @@ static long init_record(ppid) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(ppid) + struct pidRecord *ppid; { - struct pidRecord *ppid=(struct pidRecord *)(paddr->precord); long status; ppid->pact = TRUE; @@ -128,7 +127,7 @@ static long process(paddr) monitor(ppid); /* process the forward scan link record */ - if (ppid->flnk.type==DB_LINK) dbScanPassive(ppid->flnk.value.db_link.pdbAddr); + if (ppid->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)ppid->flnk.value.db_link.pdbAddr)->precord); ppid->pact=FALSE; return(status); @@ -342,7 +341,7 @@ struct pidRecord *ppid; } options=0; nRequest=1; - if(dbGetLink(&(ppid->cvl.value.db_link),ppid,DBR_FLOAT, + if(dbGetLink(&(ppid->cvl.value.db_link),(struct dbCommon *)ppid,DBR_FLOAT, &cval,&options,&nRequest)!=NULL) { recGblSetSevr(ppid,LINK_ALARM,VALID_ALARM); return(0); @@ -351,7 +350,7 @@ struct pidRecord *ppid; if(ppid->stpl.type == DB_LINK && ppid->smsl == CLOSED_LOOP){ options=0; nRequest=1; - if(dbGetLink(&(ppid->stpl.value.db_link),ppid,DBR_FLOAT, + if(dbGetLink(&(ppid->stpl.value.db_link),(struct dbCommon *)ppid,DBR_FLOAT, &(ppid->val),&options,&nRequest)!=NULL) { recGblSetSevr(ppid,LINK_ALARM,VALID_ALARM); return(0); diff --git a/src/rec/recPulseCounter.c b/src/rec/recPulseCounter.c index 64c98a984..74793fe8e 100644 --- a/src/rec/recPulseCounter.c +++ b/src/rec/recPulseCounter.c @@ -30,6 +30,7 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .02 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -38,13 +39,12 @@ #include #include -#include #include +#include #include #include #include #include -#include #include #include @@ -137,10 +137,9 @@ static long init_record(ppc) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(ppc) + struct pulseCounterRecord *ppc; { - struct pulseCounterRecord *ppc=(struct pulseCounterRecord *)(paddr->precord); struct pcdset *pdset = (struct pcdset *)(ppc->dset); long status=0; long options,nRequest; @@ -159,7 +158,7 @@ static long process(paddr) options=0; nRequest=1; ppc->pact = TRUE; - status=dbGetLink(&ppc->sgl.value.db_link,ppc,DBR_SHORT, + status=dbGetLink(&ppc->sgl.value.db_link,(struct dbCommon *)ppc,DBR_SHORT, &ppc->sgv,&options,&nRequest); ppc->pact = FALSE; if(status!=0) { @@ -203,7 +202,7 @@ static long process(paddr) monitor(ppc); /* process the forward scan link record */ - if (ppc->flnk.type==DB_LINK) dbScanPassive(ppc->flnk.value.db_link.pdbAddr); + if (ppc->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)ppc->flnk.value.db_link.pdbAddr)->precord); ppc->pact=FALSE; return(status); diff --git a/src/rec/recPulseDelay.c b/src/rec/recPulseDelay.c index 9e4fad26c..c27ab7a5f 100644 --- a/src/rec/recPulseDelay.c +++ b/src/rec/recPulseDelay.c @@ -30,6 +30,7 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .02 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -38,13 +39,12 @@ #include #include -#include #include +#include #include #include #include #include -#include #include #include @@ -122,10 +122,9 @@ static long init_record(ppd) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(ppd) + struct pulseDelayRecord *ppd; { - struct pulseDelayRecord *ppd=(struct pulseDelayRecord *)(paddr->precord); struct pddset *pdset = (struct pddset *)(ppd->dset); long status=0; long options,nRequest; @@ -151,7 +150,7 @@ static long process(paddr) monitor(ppd); /* process the forward scan link record */ - if (ppd->flnk.type==DB_LINK) dbScanPassive(ppd->flnk.value.db_link.pdbAddr); + if (ppd->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)ppd->flnk.value.db_link.pdbAddr)->precord); ppd->pact=FALSE; return(status); diff --git a/src/rec/recPulseTrain.c b/src/rec/recPulseTrain.c index d54716f2d..0271a2066 100644 --- a/src/rec/recPulseTrain.c +++ b/src/rec/recPulseTrain.c @@ -31,6 +31,7 @@ * ----------------- * .01 10-24-91 jba New device support changes * .02 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .03 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -39,13 +40,12 @@ #include #include -#include #include +#include #include #include #include #include -#include #include #include @@ -138,10 +138,9 @@ static long init_record(ppt) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(ppt) + struct pulseTrainRecord *ppt; { - struct pulseTrainRecord *ppt=(struct pulseTrainRecord *)(paddr->precord); struct ptdset *pdset = (struct ptdset *)(ppt->dset); long status=0; long options,nRequest; @@ -161,7 +160,7 @@ static long process(paddr) options=0; nRequest=1; ppt->pact = TRUE; - status=dbGetLink(&ppt->sgl.value.db_link,ppt,DBR_SHORT, + status=dbGetLink(&ppt->sgl.value.db_link,(struct dbCommon *)ppt,DBR_SHORT, &ppt->sgv,&options,&nRequest); ppt->pact = FALSE; if(status!=0) { @@ -201,7 +200,7 @@ static long process(paddr) monitor(ppt); /* process the forward scan link record */ - if (ppt->flnk.type==DB_LINK) dbScanPassive(ppt->flnk.value.db_link.pdbAddr); + if (ppt->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)ppt->flnk.value.db_link.pdbAddr)->precord); ppt->pact=FALSE; return(status); diff --git a/src/rec/recSel.c b/src/rec/recSel.c index 1d0329309..22bd1bf23 100644 --- a/src/rec/recSel.c +++ b/src/rec/recSel.c @@ -34,6 +34,7 @@ * the previous value * .02 10-12-90 mrk changes for new record support * .03 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .04 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -42,11 +43,10 @@ #include #include -#include #include +#include #include #include -#include #include #include @@ -118,10 +118,9 @@ static long init_record(psel) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(psel) + struct selRecord *psel; { - struct selRecord *psel=(struct selRecord *)(paddr->precord); psel->pact = TRUE; if(fetch_values(psel)==0) { @@ -140,7 +139,7 @@ static long process(paddr) /* process the forward scan link record */ if (psel->flnk.type==DB_LINK) - dbScanPassive(psel->flnk.value.db_link.pdbAddr); + dbScanPassive(((struct dbAddr *)psel->flnk.value.db_link.pdbAddr)->precord); psel->pact=FALSE; return(0); @@ -388,7 +387,7 @@ struct selRecord *psel; if(psel->nvl.type == DB_LINK ){ options=0; nRequest=1; - if(dbGetLink(&(psel->nvl.value.db_link),psel,DBR_USHORT, + if(dbGetLink(&(psel->nvl.value.db_link),(struct dbCommon *)psel,DBR_USHORT, &(psel->seln),&options,&nRequest)!=NULL) { recGblSetSevr(psel,LINK_ALARM,VALID_ALARM); return(-1); @@ -398,7 +397,8 @@ struct selRecord *psel; pvalue += psel->seln; if(plink->type==DB_LINK) { nRequest=1; - status=dbGetLink(&plink->value.db_link,psel,DBR_DOUBLE,pvalue,&options,&nRequest); + status=dbGetLink(&plink->value.db_link,(struct dbCommon *)psel,DBR_DOUBLE, + pvalue,&options,&nRequest); if(status!=0) { recGblSetSevr(psel,LINK_ALARM,VALID_ALARM); return(-1); @@ -410,7 +410,8 @@ struct selRecord *psel; for(i=0; itype==DB_LINK) { nRequest=1; - status = dbGetLink(&plink->value.db_link,psel,DBR_DOUBLE,pvalue,&options,&nRequest); + status = dbGetLink(&plink->value.db_link,(struct dbCommon *)psel,DBR_DOUBLE, + pvalue,&options,&nRequest); if(status!=0) { recGblSetSevr(psel,LINK_ALARM,VALID_ALARM); return(-1); diff --git a/src/rec/recState.c b/src/rec/recState.c index 74f4545e2..e1e5d401c 100644 --- a/src/rec/recState.c +++ b/src/rec/recState.c @@ -32,6 +32,7 @@ * ----------------- * .01 10-10-90 mrk extensible record and device support * .02 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .03 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -39,12 +40,11 @@ #include #include -#include #include +#include #include #include #include -#include #include #include @@ -89,17 +89,16 @@ struct rset stateRSET={ void monitor(); -static long process(paddr) - struct dbAddr *paddr; +static long process(pstate) + struct stateRecord *pstate; { - struct stateRecord *pstate=(struct stateRecord *)(paddr->precord); pstate->udf = FALSE; pstate->pact=TRUE; tsLocalTime(&pstate->time); monitor(pstate); /* process the forward scan link record */ - if (pstate->flnk.type==DB_LINK) dbScanPassive(pstate->flnk.value.db_link.pdbAddr); + if (pstate->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)pstate->flnk.value.db_link.pdbAddr)->precord); pstate->pact=FALSE; return(0); } diff --git a/src/rec/recSteppermotor.c b/src/rec/recSteppermotor.c index 06238fd6a..7bce3795a 100644 --- a/src/rec/recSteppermotor.c +++ b/src/rec/recSteppermotor.c @@ -72,12 +72,11 @@ #include #include -#include #include +#include #include #include #include -#include #include #include #include @@ -158,10 +157,9 @@ static long init_record(psm) } -static long process(paddr) - struct dbAddr *paddr; +static long process(psm) + struct steppermotorRecord *psm; { - struct steppermotorRecord *psm=(struct steppermotorRecord *)(paddr->precord); /* intialize the stepper motor record when the init bit is 0 */ /* the init is set when the readback returns */ @@ -185,7 +183,7 @@ static long process(paddr) monitor(psm); /* process the forward scan link record */ - if (psm->flnk.type==DB_LINK) dbScanPassive(psm->flnk.value.db_link.pdbAddr); + if (psm->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)psm->flnk.value.db_link.pdbAddr)->precord); psm->pact=FALSE; return(0); @@ -367,9 +365,9 @@ psm_data->accel ); */ if(not_init_record) { - dbScanLock(psm); + dbScanLock((struct dbCommon *)psm); if(psm->pact) { - dbScanUnlock(psm); + dbScanUnlock((struct dbCommon *)psm); return; } psm->pact = TRUE; @@ -493,7 +491,7 @@ psm_data->accel } if(not_init_record) { psm->pact = FALSE; - dbScanUnlock(psm); + dbScanUnlock((struct dbCommon *)psm); } return; } @@ -635,7 +633,8 @@ struct steppermotorRecord *psm; long options=0; long nRequest=1; - if(dbGetLink(&(psm->dol.value.db_link),psm,DBR_FLOAT,&(psm->val),&options,&nRequest)){ + if(dbGetLink(&(psm->dol.value.db_link),(struct dbCommon *)psm,DBR_FLOAT, + &(psm->val),&options,&nRequest)){ recGblSetSevr(psm,LINK_ALARM,VALID_ALARM); return; } else psm->udf = FALSE; @@ -737,7 +736,8 @@ struct steppermotorRecord *psm; long options=0; long nRequest=1; - if(dbGetLink(&(psm->dol.value.db_link),psm,DBR_FLOAT,&(psm->val),&options,&nRequest)) { + if(dbGetLink(&(psm->dol.value.db_link),(struct dbCommon *)psm,DBR_FLOAT, + &(psm->val),&options,&nRequest)) { recGblSetSevr(psm,LINK_ALARM,VALID_ALARM); return; } else psm->udf=FALSE; @@ -822,7 +822,8 @@ short moving; reset = psm->init; if (reset == 0) psm->init = 1; - if(dbGetLink(&(psm->rdbl.value.db_link),psm,DBR_FLOAT,&new_pos,&options,&nRequest)){ + if(dbGetLink(&(psm->rdbl.value.db_link),(struct dbCommon *)psm,DBR_FLOAT, + &new_pos,&options,&nRequest)){ recGblSetSevr(psm,READ_ALARM,VALID_ALARM); psm->init = reset; return; diff --git a/src/rec/recStringin.c b/src/rec/recStringin.c index 6d76bd9ca..a4829a176 100644 --- a/src/rec/recStringin.c +++ b/src/rec/recStringin.c @@ -30,6 +30,7 @@ * Modification Log: * ----------------- * .01 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .02 02-05-92 jba Changed function arguments from paddr to precord */ @@ -40,12 +41,11 @@ #include #include -#include #include +#include #include #include #include -#include #include #include @@ -119,10 +119,9 @@ static long init_record(pstringin) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(pstringin) + struct stringinRecord *pstringin; { - struct stringinRecord *pstringin=(struct stringinRecord *)(paddr->precord); struct stringindset *pdset = (struct stringindset *)(pstringin->dset); long status; @@ -144,7 +143,8 @@ static long process(paddr) monitor(pstringin); /* process the forward scan link record */ - if (pstringin->flnk.type==DB_LINK) dbScanPassive(pstringin->flnk.value.db_link.pdbAddr); + if (pstringin->flnk.type==DB_LINK) + dbScanPassive(((struct dbAddr *)pstringin->flnk.value.db_link.pdbAddr)->precord); pstringin->pact=FALSE; return(status); diff --git a/src/rec/recStringout.c b/src/rec/recStringout.c index c4dfbc089..ea466260b 100644 --- a/src/rec/recStringout.c +++ b/src/rec/recStringout.c @@ -31,6 +31,7 @@ * ----------------- * .01 10-24-91 jba Removed unused code * .02 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .03 02-05-92 jba Changed function arguments from paddr to precord */ @@ -41,12 +42,11 @@ #include #include -#include #include +#include #include #include #include -#include #include #include @@ -127,10 +127,9 @@ static long init_record(pstringout) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(pstringout) + struct stringoutRecord *pstringout; { - struct stringoutRecord *pstringout=(struct stringoutRecord *)(paddr->precord); struct stringoutdset *pdset = (struct stringoutdset *)(pstringout->dset); long status=0; @@ -145,7 +144,8 @@ static long process(paddr) long nRequest=1; pstringout->pact = TRUE; - status = dbGetLink(&pstringout->dol.value.db_link,pstringout, + status = dbGetLink(&pstringout->dol.value.db_link, + (struct dbCommon *)pstringout, DBR_STRING,pstringout->val,&options,&nRequest); pstringout->pact = FALSE; if(!status==0){ @@ -168,7 +168,8 @@ static long process(paddr) monitor(pstringout); /* process the forward scan link record */ - if (pstringout->flnk.type==DB_LINK) dbScanPassive(pstringout->flnk.value.db_link.pdbAddr); + if (pstringout->flnk.type==DB_LINK) + dbScanPassive(((struct dbAddr *)pstringout->flnk.value.db_link.pdbAddr)->precord); pstringout->pact=FALSE; return(status); diff --git a/src/rec/recSub.c b/src/rec/recSub.c index bbad24e83..8c0711461 100644 --- a/src/rec/recSub.c +++ b/src/rec/recSub.c @@ -32,6 +32,9 @@ * ----------------- * .01 10-10-90 mrk Made changes for new record support * .02 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .03 01-08-92 jba Added casts in symFindByName to avoid compile warning messages + * .04 02-05-92 jba Changed function arguments from paddr to precord + */ #include @@ -43,11 +46,10 @@ #include /* for N_TEXT */ #include -#include #include +#include #include #include -#include #include #include @@ -120,7 +122,7 @@ static long init_record(psub) strcpy(temp,"_"); } strcat(temp,psub->inam); - ret = symFindByName(sysSymTbl,temp,&psub->sadr,&sub_type); + ret = symFindByName(sysSymTbl,temp,&psub->sadr,(void *)&sub_type); if ((ret !=OK) || ((sub_type & N_TEXT) == 0)){ recGblRecordError(S_db_BadSub,psub,"recSub(init_record)"); return(S_db_BadSub); @@ -137,7 +139,7 @@ static long init_record(psub) strcpy(temp,"_"); } strcat(temp,psub->snam); - ret = symFindByName(sysSymTbl,temp,&psub->sadr,&sub_type); + ret = symFindByName(sysSymTbl,temp,&psub->sadr,(void *)&sub_type); if ((ret < 0) || ((sub_type & N_TEXT) == 0)){ recGblRecordError(S_db_BadSub,psub,"recSub(init_record)"); return(S_db_BadSub); @@ -146,10 +148,9 @@ static long init_record(psub) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(psub) + struct subRecord *psub; { - struct subRecord *psub=(struct subRecord *)(paddr->precord); long status=0; if(!psub->pact){ @@ -166,7 +167,7 @@ static long process(paddr) /* check event list */ monitor(psub); /* process the forward scan link record */ - if (psub->flnk.type==DB_LINK) dbScanPassive(psub->flnk.value.db_link.pdbAddr); + if (psub->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)psub->flnk.value.db_link.pdbAddr)->precord); psub->pact = FALSE; return(0); } @@ -346,7 +347,7 @@ struct subRecord *psub; if(plink->type!=DB_LINK) continue; options=0; nRequest=1; - status=dbGetLink(&plink->value.db_link,psub,DBR_DOUBLE, + status=dbGetLink(&plink->value.db_link,(struct dbCommon *)psub,DBR_DOUBLE, pvalue,&options,&nRequest); if(status!=0) { recGblSetSevr(psub,LINK_ALARM,VALID_ALARM); diff --git a/src/rec/recTimer.c b/src/rec/recTimer.c index 716c39e26..df9dd8894 100644 --- a/src/rec/recTimer.c +++ b/src/rec/recTimer.c @@ -44,6 +44,7 @@ * .11 11-11-91 jba Moved set and reset of alarm stat and sevr to macros * .12 12-02-91 jba Added cmd control to io-interrupt processing * .13 12-12-91 jba Set cmd to zero in io-interrupt processing + * .14 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -52,12 +53,11 @@ #include #include -#include #include +#include #include #include #include -#include #include #include #include @@ -113,7 +113,7 @@ static long get_ioint_info(cmd,ptimer,io_type,card_type,card_number) short *card_type; short *card_number; { - *cmd=0; + *cmd=-1; if(ptimer->out.type != VME_IO) return(S_dev_badInpType); *io_type = IO_TIMER; if(ptimer->dtyp==0) @@ -148,10 +148,9 @@ static long init_record(ptimer) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(ptimer) + struct timerRecord *ptimer; { - struct timerRecord *ptimer=(struct timerRecord *)(paddr->precord); ptimer->pact=TRUE; @@ -163,7 +162,7 @@ static long process(paddr) /* check event list */ monitor(ptimer); /* process the forward scan link record */ - if (ptimer->flnk.type==DB_LINK) dbScanPassive(ptimer->flnk.value.db_link.pdbAddr); + if (ptimer->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)ptimer->flnk.value.db_link.pdbAddr)->precord); ptimer->pact=FALSE; return(0); @@ -281,7 +280,7 @@ struct timerRecord *ptimer; if (ptimer->torg.type == DB_LINK) { options=0; nRequest=1; - status = dbGetLink(&(ptimer->torg.value.db_link),ptimer,DBR_FLOAT, + status = dbGetLink(&(ptimer->torg.value.db_link),(struct dbCommon *)ptimer,DBR_FLOAT, &(ptimer->trdl),&options,&nRequest); if(status!=0){ recGblSetSevr(ptimer,LINK_ALARM,VALID_ALARM); diff --git a/src/rec/recWaveform.c b/src/rec/recWaveform.c index a9a01bd07..ecdf9dbfe 100644 --- a/src/rec/recWaveform.c +++ b/src/rec/recWaveform.c @@ -49,6 +49,8 @@ * value was not initialized * .10 10-11-90 mrk Made changes for new record support * .11 11-11-91 jba Moved set and reset of alarm stat and sevr to macros + * .12 12-18-91 jba Changed E_IO_INTERRUPT to SCAN_IO_EVENT, added dbScan.h + * .13 02-05-92 jba Changed function arguments from paddr to precord */ #include @@ -57,12 +59,12 @@ #include #include -#include #include +#include #include +#include #include #include -#include #include #include @@ -120,8 +122,6 @@ static int sizeofTypes[] = {0,1,1,2,2,4,4,4,8,2}; void monitor(); -/* The following is taken from dbScan.c */ -#define E_IO_INTERRUPT 7 /*Following from timing system */ extern unsigned int gts_trigger_counter; @@ -159,10 +159,9 @@ static long init_record(pwf) return(0); } -static long process(paddr) - struct dbAddr *paddr; +static long process(pwf) + struct waveformRecord *pwf; { - struct waveformRecord *pwf=(struct waveformRecord *)(paddr->precord); struct wfdset *pdset = (struct wfdset *)(pwf->dset); long status; @@ -172,7 +171,7 @@ static long process(paddr) return(S_dev_missingSup); } /* event throttling */ - if (pwf->scan == E_IO_INTERRUPT){ + if (pwf->scan == SCAN_IO_EVENT){ if ((pwf->evnt != 0) && (gts_trigger_counter != 0)){ if ((gts_trigger_counter % pwf->evnt) != 0){ status=(*pdset->read_wf)(pwf); @@ -191,7 +190,7 @@ static long process(paddr) monitor(pwf); /* process the forward scan link record */ - if (pwf->flnk.type==DB_LINK) dbScanPassive(pwf->flnk.value.db_link.pdbAddr); + if (pwf->flnk.type==DB_LINK) dbScanPassive(((struct dbAddr *)pwf->flnk.value.db_link.pdbAddr)->precord); pwf->pact=FALSE; return(0);