From dbfab6b29e44a2f47ccde1baa6e5afd478a0a274 Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Thu, 25 Jan 1996 21:13:33 +0000 Subject: [PATCH] moved includes; .ascii=> .db; path changes --- src/db/Makefile.Vx | 10 +- src/db/all.ascii | 234 ---- src/db/callback.h | 86 ++ src/db/dbAccess.h | 318 +++++ src/db/dbBkpt.h | 105 ++ src/db/{dbCommon.ascii => dbCommon.db} | 0 src/db/dbCommonRecord.ascii | 3 - src/db/dbCommonRecord.db | 3 + src/db/dbConvert.h | 39 + src/db/dbEvent.h | 173 +++ src/db/dbScan.h | 70 + src/db/dbTest.c | 3 + src/db/db_access.c | 2 +- src/db/db_access.h | 1137 +++++++++++++++++ src/db/db_addr.h | 49 + src/db/db_field_log.h | 67 + src/db/devLib.h | 230 ++++ src/db/devSup.h | 66 + src/db/drvSup.h | 52 + src/db/drvTS.h | 266 ++++ src/db/epics.db | 233 ++++ src/db/fast_lock.h | 191 +++ src/db/initHooks.h | 55 + src/db/iocInit.c | 10 +- .../{menuAlarmSevr.ascii => menuAlarmSevr.db} | 0 .../{menuAlarmStat.ascii => menuAlarmStat.db} | 0 src/db/{menuArrType.ascii => menuArrType.db} | 0 .../{menuCompress.ascii => menuCompress.db} | 0 src/db/{menuFtype.ascii => menuFtype.db} | 0 src/db/menuGlobal.ascii | 11 - src/db/menuGlobal.db | 11 + src/db/{menuIvoa.ascii => menuIvoa.db} | 0 src/db/{menuLinr.ascii => menuLinr.db} | 0 src/db/{menuOmsl.ascii => menuOmsl.db} | 0 .../{menuPriority.ascii => menuPriority.db} | 0 src/db/{menuScan.ascii => menuScan.db} | 0 src/db/{menuYesNo.ascii => menuYesNo.db} | 0 src/db/recGbl.c | 8 + src/db/recGbl.h | 107 ++ src/db/recSup.h | 106 ++ src/db/task_params.h | 229 ++++ src/db/taskwd.h | 50 + src/include/devSup.h | 66 + src/include/drvSup.h | 52 + src/include/drvTS.h | 266 ++++ src/include/fast_lock.h | 191 +++ src/vxWorks/db/devLib.h | 230 ++++ src/vxWorks/db/drvTS.h | 266 ++++ src/vxWorks/include/fast_lock.h | 191 +++ 49 files changed, 4925 insertions(+), 261 deletions(-) delete mode 100644 src/db/all.ascii create mode 100644 src/db/callback.h create mode 100644 src/db/dbAccess.h create mode 100644 src/db/dbBkpt.h rename src/db/{dbCommon.ascii => dbCommon.db} (100%) delete mode 100644 src/db/dbCommonRecord.ascii create mode 100644 src/db/dbCommonRecord.db create mode 100644 src/db/dbConvert.h create mode 100644 src/db/dbEvent.h create mode 100644 src/db/dbScan.h create mode 100644 src/db/db_access.h create mode 100644 src/db/db_addr.h create mode 100644 src/db/db_field_log.h create mode 100644 src/db/devLib.h create mode 100644 src/db/devSup.h create mode 100644 src/db/drvSup.h create mode 100644 src/db/drvTS.h create mode 100644 src/db/epics.db create mode 100644 src/db/fast_lock.h create mode 100644 src/db/initHooks.h rename src/db/{menuAlarmSevr.ascii => menuAlarmSevr.db} (100%) rename src/db/{menuAlarmStat.ascii => menuAlarmStat.db} (100%) rename src/db/{menuArrType.ascii => menuArrType.db} (100%) rename src/db/{menuCompress.ascii => menuCompress.db} (100%) rename src/db/{menuFtype.ascii => menuFtype.db} (100%) delete mode 100644 src/db/menuGlobal.ascii create mode 100644 src/db/menuGlobal.db rename src/db/{menuIvoa.ascii => menuIvoa.db} (100%) rename src/db/{menuLinr.ascii => menuLinr.db} (100%) rename src/db/{menuOmsl.ascii => menuOmsl.db} (100%) rename src/db/{menuPriority.ascii => menuPriority.db} (100%) rename src/db/{menuScan.ascii => menuScan.db} (100%) rename src/db/{menuYesNo.ascii => menuYesNo.db} (100%) create mode 100644 src/db/recGbl.h create mode 100644 src/db/recSup.h create mode 100644 src/db/task_params.h create mode 100644 src/db/taskwd.h create mode 100644 src/include/devSup.h create mode 100644 src/include/drvSup.h create mode 100644 src/include/drvTS.h create mode 100644 src/include/fast_lock.h create mode 100644 src/vxWorks/db/devLib.h create mode 100644 src/vxWorks/db/drvTS.h create mode 100644 src/vxWorks/include/fast_lock.h diff --git a/src/db/Makefile.Vx b/src/db/Makefile.Vx index 53cb860e5..f9b81b570 100644 --- a/src/db/Makefile.Vx +++ b/src/db/Makefile.Vx @@ -19,7 +19,7 @@ MENUS += menuYesNo.h RECTYPES += dbCommon.h -ASCII = dbCommonRecord.ascii menuGlobal.ascii all.ascii +DBINSTALL = dbCommonRecord.db menuGlobal.db epics.db SRCS.c = \ ../dbAccess.c\ @@ -68,12 +68,12 @@ LIBNAME = dbLib include $(EPICS)/config/RULES.Vx -dbCommon.h: ../dbCommonRecord.ascii dbCommon.ascii +dbCommon.h: ../dbCommonRecord.db dbCommon.db $(RM) $@ - $(EPICS_BASE)/bin/$(HOST_ARCH)/dbAsciiToRecordtypeH $< + $(EPICS_BASE)/bin/$(HOST_ARCH)/dbToRecordtypeH $< -dbCommon.ascii: ../dbCommon.ascii +dbCommon.db: ../dbCommon.db @test -f $@ || ln -s $< $@ clean:: - @$(RM) dbCommon.ascii rec base + @$(RM) dbCommon.db rec base diff --git a/src/db/all.ascii b/src/db/all.ascii deleted file mode 100644 index 6877a4e79..000000000 --- a/src/db/all.ascii +++ /dev/null @@ -1,234 +0,0 @@ -path "./base/rec" -include "menuGlobal.ascii" -include "menuConvert.ascii" -include "aiRecord.ascii" -#include "aaiRecord.ascii" -include "aoRecord.ascii" -#include "aaoRecord.ascii" -include "biRecord.ascii" -include "boRecord.ascii" -include "calcRecord.ascii" -include "compressRecord.ascii" -include "dfanoutRecord.ascii" -include "egRecord.ascii" -include "egeventRecord.ascii" -include "erRecord.ascii" -include "ereventRecord.ascii" -include "eventRecord.ascii" -include "fanoutRecord.ascii" -include "histogramRecord.ascii" -include "longinRecord.ascii" -include "longoutRecord.ascii" -include "mbbiRecord.ascii" -include "mbbiDirectRecord.ascii" -include "mbboRecord.ascii" -include "mbboDirectRecord.ascii" -include "permissiveRecord.ascii" -include "pidRecord.ascii" -include "pulseCounterRecord.ascii" -include "pulseDelayRecord.ascii" -include "pulseTrainRecord.ascii" -include "scanRecord.ascii" -include "selRecord.ascii" -include "seqRecord.ascii" -include "stateRecord.ascii" -include "steppermotorRecord.ascii" -include "stringinRecord.ascii" -include "stringoutRecord.ascii" -include "subRecord.ascii" -#include "gsubRecord.ascii" -#include "palRecord.ascii" -include "subArrayRecord.ascii" -include "timerRecord.ascii" -include "waitRecord.ascii" -include "waveformRecord.ascii" -device(ai,CONSTANT,devAiSoft,"Soft Channel") -device(ai,CONSTANT,devAiSoftRaw,"Raw Soft Channel") -device(ai,VME_IO,devAiXy566Se,"XYCOM-566 SE Scanned") -device(ai,VME_IO,devAiXy566Di,"XYCOM-566 Dif Scanned") -device(ai,VME_IO,devAiXy566DiL,"XYCOM-566 Dif Latched") -device(ai,VME_IO,devAiDvx2502,"DVX-2502") -device(ai,CONSTANT,devAiTestAsyn,"Test Asyn") -device(ai,CONSTANT,devAiSymb,"vxWorks Variable") -device(ai,AB_IO,devAiAb1771Il,"AB-1771IL-Analog In") -device(ai,AB_IO,devAiAb1771Ife,"AB-1771IFE") -device(ai,AB_IO,devAiAb1771Ixe,"AB-1771IXE-Millivolt In") -device(ai,AB_IO,devAiAb1771IfeSe,"AB-1771IFE-SE") -device(ai,AB_IO,devAiAb1771IfeMa,"AB-1771IFE-4to20MA") -device(ai,AB_IO,devAiAb1771Ife0to5V,"AB-1771IFE-0to5Volt") -device(ai,AB_IO,devAiAb1771IrPlatinum,"AB-1771RTD-Platinum") -device(ai,AB_IO,devAiAb1771IrCopper,"AB-1771RTD-Copper") -#device(ai,CAMAC_IO,devAiCamac,"Camac") -device(ai,VME_IO,devAiAt5Vxi,"VXI-AT5-AI") -#device(ai,GPIB_IO,devAiK486Gpib,"Keithley-486") -#device(ai,VME_IO,devAiKscV215,"KSC-V215") -device(ai,VME_IO,devAiSysmon,"SYSMON") -#device(aai,CAMAC_IO,devAaiCamac,"Camac") -device(ao,CONSTANT,devAoSoft,"Soft Channel") -device(ao,CONSTANT,devAoSoftRaw,"Raw Soft Channel") -device(ao,VME_IO,devAoVmiVme4100,"VMIVME-4100") -device(ao,CONSTANT,devAoTestAsyn,"Test Asyn") -device(ao,CONSTANT,devAoSymb,"vxWorks Variable") -device(ao,AB_IO,devAoAb1771Ofe,"AB-1771OFE") -#device(ao,CAMAC_IO,devAoCamac,"Camac") -device(ao,VME_IO,devAoAt5Vxi,"VXI-AT5-AO") -device(bi,CONSTANT,devBiSoft,"Soft Channel") -device(bi,CONSTANT,devBiSoftRaw,"Raw Soft Channel") -device(bi,VME_IO,devBiMpv910,"MPV-910") -device(bi,VME_IO,devBiXVme210,"XVME-210") -device(bi,CONSTANT,devBiTestAsyn,"Test Asyn") -device(bi,AB_IO,devBiAb,"AB-Binary Input") -device(bi,AB_IO,devBiAb16,"AB-16 bit BI") -device(bi,AB_IO,devBiAb32,"AB-32 bit BI") -#device(bi,CAMAC_IO,devBiCamac,"Camac") -device(bi,VME_IO,devBiAt5Vxi,"VXI-AT5-BI") -#device(bi,VME_IO,devBiXy240,"XYCOM-240") -device(bi,VME_IO,devBiHpe1368a,"VXI-HPE1368-VS") -#device(bi,VME_IO,devBiAt8Fp,"AT8-FP10S") -device(bi,VME_IO,devBiAvme9440,"AVME9440 I") -device(bi,VME_IO,devBiSysmon,"SYSMON") -device(bi,VME_IO,devBiMpc,"MPC") -device(bo,CONSTANT,devBoSoft,"Soft Channel") -device(bo,CONSTANT,devBoSoftRaw,"Raw Soft Channel") -device(bo,VME_IO,devBoMpv902,"MPV-902") -device(bo,VME_IO,devBoXVme220,"XVME-220") -device(bo,CONSTANT,devBoTestAsyn,"Test Asyn") -device(bo,AB_IO,devBoAb,"AB-Binary Output") -device(bo,AB_IO,devBoAb16,"AB-16 bit BO") -device(bo,AB_IO,devBoAb32,"AB-32 bit BO") -#device(bo,CAMAC_IO,devBoCamac,"Camac") -device(bo,VME_IO,devBoAt5Vxi,"VXI-AT5-BO") -#device(bo,GPIB_IO,devBoK486Gpib,"Keithley-486") -#device(bo,VME_IO,devBoXy240,"XYCOM-240") -device(bo,VME_IO,devBoHpe1368a,"VXI-HPE1368-VS") -#device(bo,VME_IO,devBoAt8Fp,"AT8-FP10S") -device(bo,VME_IO,devBoAvme9440,"AVME9440 O") -device(bo,VME_IO,devBoSysmon,"SYSMON") -device(bo,VME_IO,devBoMpc,"MPC") -device(event,CONSTANT,devEventSoft,"Soft Channel") -device(event,VME_IO,devEventMz8310,"Mizar-8310") -device(event,CONSTANT,devEventTestIoEvent,"Test IoEvent") -device(event,VME_IO,devErEpicsEvent,"APS event receiver") -device(histogram,CONSTANT,devHistogramSoft,"Soft Channel") -device(histogram,CONSTANT,devHistogramTestAsyn,"Test Asyn") -device(longin,CONSTANT,devLiSoft,"Soft Channel") -device(longin,CONSTANT,devLiSymb,"vxWorks Variable") -#device(longin,CAMAC_IO,devLiCamac,"Camac") -device(longout,CONSTANT,devLoSoft,"Soft Channel") -device(longout,CONSTANT,devLoSymb,"vxWorks Variable") -#device(longout,CAMAC_IO,devLoCamac,"Camac") -device(mbbi,CONSTANT,devMbbiSoft,"Soft Channel") -device(mbbi,CONSTANT,devMbbiSoftRaw,"Raw Soft Channel") -device(mbbi,VME_IO,devMbbiMpv910,"MPV-910") -device(mbbi,VME_IO,devMbbiXVme210,"XVME-210") -device(mbbi,CONSTANT,devMbbiTestAsyn,"Test Asyn") -device(mbbi,AB_IO,devMbbiAb,"AB-Binary Input") -device(mbbi,AB_IO,devMbbiAb16,"AB-16 bit BI") -device(mbbi,AB_IO,devMbbiAb32,"AB-32 bit BI") -device(mbbi,AB_IO,devMbbiAbAdapterStat,"AB-Adapter Status") -device(mbbi,AB_IO,devMbbiAbCardStat,"AB-Card Status") -#device(mbbi,CAMAC_IO,devMbbiCamac,"Camac") -device(mbbi,VME_IO,devMbbiAt5Vxi,"VXI-AT5-BI") -#device(mbbi,VME_IO,devMbbiXy240,"XYCOM-240") -device(mbbi,VME_IO,devMbbiHpe1368a,"VXI-HPE1368-VS") -#device(mbbi,VME_IO,devMbbiAt8Fp,"AT8-FP10S") -device(mbbi,VME_IO,devMbbiAvme9440,"AVME9440 I") -device(mbbi,VME_IO,devMbbiSysmon,"SYSMON") -device(mbbiDirect,CONSTANT,devMbbiDirectSoft,"Soft Channel") -device(mbbiDirect,CONSTANT,devMbbiDirectSoftRaw,"Raw Soft Channel") -device(mbbiDirect,VME_IO,devMbbiDirectMpv910,"MPV-910") -device(mbbiDirect,VME_IO,devMbbiDirectXVme210,"XVME-210") -device(mbbiDirect,AB_IO,devMbbiDirectAb,"AB-Binary Input") -device(mbbiDirect,AB_IO,devMbbiDirectAb16,"AB-16 bit BI") -device(mbbiDirect,AB_IO,devMbbiDirectAb32,"AB-32 bit BI") -#device(mbbiDirect,CAMAC_IO,devMbbiDirectCamac,"Camac") -device(mbbiDirect,VME_IO,devMbbiDirectAt5Vxi,"VXI-AT5-BI") -device(mbbo,CONSTANT,devMbboSoft,"Soft Channel") -device(mbbo,CONSTANT,devMbboSoftRaw,"Raw Soft Channel") -device(mbbo,VME_IO,devMbboMpv902,"MPV-902") -device(mbbo,VME_IO,devMbboXVme220,"XVME-220") -device(mbbo,CONSTANT,devMbboTestAsyn,"Test Asyn") -device(mbbo,AB_IO,devMbboAb,"AB-Binary Output") -device(mbbo,AB_IO,devMbboAb16,"AB-16 bit BO") -device(mbbo,AB_IO,devMbboAb32,"AB-32 bit BO") -device(mbbo,VME_IO,devMbboAt5Vxi,"VXI-AT5-BO") -#device(mbbo,GPIB_IO,devMbboK486Gpib,"Keithley-486") -#device(mbbo,VME_IO,devMbboXy240,"XYCOM-240") -device(mbbo,VME_IO,devMbboHpe1368a,"VXI-HPE1368-VS") -#device(mbbo,VME_IO,devMbboAt8Fp,"AT8-FP10S") -device(mbbo,VME_IO,devMbboAvme9440,"AVME9440 O") -device(mbbo,VME_IO,devMbboSysmon,"SYSMON") -device(mbboDirect,CONSTANT,devMbboDirectSoft,"Soft Channel") -device(mbboDirect,CONSTANT,devMbboDirectSoftRaw,"Raw Soft Channel") -device(mbboDirect,VME_IO,devMbboDirectMpv902,"MPV-902") -device(mbboDirect,VME_IO,devMbboDirectXVme220,"XVME-220") -device(mbboDirect,AB_IO,devMbboDirectAb,"AB-Binary Output") -device(mbboDirect,AB_IO,devMbboDirectAb16,"AB-16 bit BO") -device(mbboDirect,AB_IO,devMbboDirectAb32,"AB-32 bit BO") -#device(mbboDirect,CAMAC_IO,devMbboDirectCamac,"Camac") -device(mbboDirect,VME_IO,devMbboDirectAt5Vxi,"VXI-AT5-BO") -device(pulseCounter,VME_IO,devPcMz8310,"Mizar-8310") -device(pulseDelay,VME_IO,devPdMz8310,"Mizar-8310") -device(pulseDelay,VXI_IO,devPdVxiTDM,"VXI Time Delay Module") -device(pulseTrain,CONSTANT,devPtSoft,"Soft Channel") -device(pulseTrain,VME_IO,devPtMz8310,"Mizar-8310") -device(steppermotor,VME_IO,devSmCompumotor1830,"Compumotor 1830") -device(steppermotor,VME_IO,devSmOms6Axis,"OMS 6-Axis") -device(stringin,CONSTANT,devSiSoft,"Soft Channel") -device(stringin,CONSTANT,devSiTestAsyn,"Test Asyn") -device(stringin,CONSTANT,devSiSymb,"vxWorks Variable") -device(stringout,CONSTANT,devSoSoft,"Soft Channel") -device(stringout,CONSTANT,devSoTestAsyn,"Test Asyn") -device(stringout,CONSTANT,devSoSymb,"vxWorks Variable") -device(subArray,CONSTANT,devSASoft,"Soft Channel") -device(timer,VME_IO,devTmMizar8310,"Mizar-8310") -device(timer,VME_IO,devTmDg535,"DG 535") -device(timer,VME_IO,devTmAt5Vxi,"VXI-AT5-TIME") -device(waveform,CONSTANT,devWfSoft,"Soft Channel") -device(waveform,VME_IO,devWfXy566Sc,"XYCOM-566 Single Channel") -device(waveform,VME_IO,devWfComet,"Comet Digitizer") -device(waveform,VME_IO,devWfJoergerVtr1,"Joerger Digitizer") -device(waveform,CONSTANT,devWfTestAsyn,"Test Asyn") -device(waveform,VME_IO,devWfDvx2502,"DVX-2502") -device(waveform,VME_IO,devWfPentek4261,"Pentek 4261") -#device(waveform,CAMAC_IO,devWfCamac,"Camac") -#device(waveform,VME_IO,devWfJoergerVtr1,"Joerger-VTR1") -#device(waveform,VME_IO,devWfComet,"Omnibyte-COMET") -device(eg,VME_IO,devEg,"APS event generator G") -device(egevent,VME_IO,devEgEvent,"APS event generator E") -device(er,VME_IO,devEr,"APS event receiver") -device(erevent,VME_IO,devErevent,"APS event receiver") -device(wait,CONSTANT,devWaitIoEvent,"Soft Channel") -#device(ai,INST_IO,devAiCan,"CANbus") -#device(ao,INST_IO,devAoCan,"CANbus") -#device(bi,INST_IO,devBiCan,"CANbus") -#device(bo,INST_IO,devBoCan,"CANbus") -#device(mbbi,INST_IO,devMbbiCan,"CANbus") -#device(mbbo,INST_IO,devMbboCan,"CANbus") -#device(mbbiDirect,INST_IO,devMbbiDirectCan,"CANbus") -#device(mbboDirect,INST_IO,devMbboDirectCan,"CANbus") -driver(drvXy010) -driver(drvVxi) -driver(drvGpib) -driver(drvBitBus) -driver(drvBb910) -driver(drvXy210) -driver(drvBb902) -driver(drvXy220) -driver(drvXy566) -driver(drvDvx) -driver(drvVmi4100) -driver(drvAb) -driver(drvAt5Vxi) -driver(drvCompuSm) -driver(drvOms) -driver(drvMz8310) -driver(drvHpe1368a) -#driver(drvXy240) -#driver(drvKscV215) -#driver(drvComet) -#driver(drvJgvtr1) -#driver(drvFp) -#driver(drvFpm) -#driver(drvIpac) -#driver(drvTip810) diff --git a/src/db/callback.h b/src/db/callback.h new file mode 100644 index 000000000..3d18c5af7 --- /dev/null +++ b/src/db/callback.h @@ -0,0 +1,86 @@ +/* $Id$ */ + +/* includes for general purpose callback tasks */ +/* + * Original Author: Marty Kraimer + * Date: 07-18-91 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 12-12-91 mrk Initial version + * .02 04-05-94 mrk Remove casts on Lvalues (ANSI forbids) + * .02 02-09-95 joh if def'd out typedef CALLBACK for + * windows + */ + + +#ifndef INCcallbackh +#define INCcallbackh 1 + +/* + * WINDOWS also has a "CALLBACK" type def + */ +#ifdef WIN32 +# ifdef CALLBACK +# undef CALLBACK +# endif /*CALLBACK*/ +#endif /*WIN32*/ + +#define NUM_CALLBACK_PRIORITIES 3 +#define priorityLow 0 +#define priorityMedium 1 +#define priorityHigh 2 + +typedef struct callbackPvt { +#ifdef __cplusplus + void (*callback)(struct callbackPvt*); +#else + void (*callback)(); +#endif + int priority; + void *user; /*for use by callback user*/ +}CALLBACK; + +#define callbackSetCallback(PFUN,PCALLBACK)\ +( (PCALLBACK)->callback = (PFUN) ) +#define callbackSetPriority(PRIORITY,PCALLBACK)\ +( (PCALLBACK)->priority = (PRIORITY) ) +#define callbackSetUser(USER,PCALLBACK)\ +( (PCALLBACK)->user = (VOID *)(USER) ) +#define callbackGetUser(USER,PCALLBACK)\ +( (USER) = (void *)((CALLBACK *)(PCALLBACK))->user ) + +#ifdef __STDC__ +long callbackInit(); +void callbackRequest(CALLBACK *); +void callbackRequestProcessCallback(CALLBACK *pCallback, + int Priority, void *pRec); +#else +long callbackInit(); +void callbackRequest(); +void callbackRequestProcessCallback(); +#endif /*__STDC__*/ + + +#endif /*INCcallbackh*/ diff --git a/src/db/dbAccess.h b/src/db/dbAccess.h new file mode 100644 index 000000000..d62068ab7 --- /dev/null +++ b/src/db/dbAccess.h @@ -0,0 +1,318 @@ +/* dbAccess.h */ +/* $Id$ + * + * Original Author: Bob Dalesio + * Current Author: Marty Kraimer + * Date: 6-1-90 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 12-18-91 jba Changed caddr_t to void * + * .02 03-04-92 jba Replaced dbr_value_size with dbrValueSize in dbAccess + * .03 05-28-92 mrk cleanup + * .04 08-19-92 jba added prototypes dbCaAddInlink,dbCaAddOutlink + * .05 08-19-92 jba added prototypes dbCaPutLink,dbCaGetLink + * .06 02-02-94 mrk added definitions for dbPutNotify + * .07 03-18-94 mcn added breakpoint codes, fast link protos + */ + +#ifndef INCdbAccessh +#define INCdbAccessh +#include +#include +#include +#include +#include +#include +#include +#include + +typedef struct dbAddr{ + struct dbCommon *precord;/* address of record */ + void *pfield; /* address of field */ + void *pfldDes; /* address of struct fldDes */ + void *asPvt; /* Access Security Private */ + long no_elements; /* number of elements (arrays) */ + short field_type; /* type of database field */ + short field_size; /* size (bytes) of the field being accessed */ + short special; /* special processing */ + short dbr_field_type; /* field type as seen by database request*/ + /*DBR_STRING,...,DBR_ENUM,DBR_NOACCESS*/ +}DBADDR; + +/*If the following structures changes then db_access.h must also be changed*/ +typedef struct pnRestartNode { + ELLNODE node; + struct putNotify *ppn; + struct putNotify *ppnrestartList; /*ppn with restartList*/ +}PNRESTARTNODE; + + +typedef struct putNotify{ + /*The following members MUST be set by user*/ +#ifdef __STDC__ + void (*userCallback)(struct putNotify *); /*callback provided by user*/ +#else + void (*userCallback)(); /*callback provided by user*/ +#endif + struct dbAddr *paddr; /*dbAddr set by dbNameToAddr*/ + void *pbuffer; /*address of data*/ + long nRequest; /*number of elements to be written*/ + short dbrType; /*database request type*/ + void *usrPvt; /*for private use of user*/ + /*The following is status of request. Set by dbPutNotify*/ + long status; + /*The following are private to database access*/ + CALLBACK callback; + ELLLIST waitList; /*list of records for which to wait*/ + ELLLIST restartList; /*list of PUTNOTIFYs to restart*/ + PNRESTARTNODE restartNode; + short restart; + short callbackState; + void *waitForCallback; +}PUTNOTIFY; + +/* The database field and request types are defined in dbFldTypes.h*/ +/* Data Base Request Options */ +#define DBR_STATUS 0x00000001 +#define DBR_UNITS 0x00000002 +#define DBR_PRECISION 0x00000004 +#define DBR_TIME 0x00000008 +#define DBR_ENUM_STRS 0x00000010 +#define DBR_GR_LONG 0x00000020 +#define DBR_GR_DOUBLE 0x00000040 +#define DBR_CTRL_LONG 0x00000080 +#define DBR_CTRL_DOUBLE 0x00000100 +#define DBR_AL_LONG 0x00000200 +#define DBR_AL_DOUBLE 0x00000400 + +/********************************************************************** + * The next page contains macros for defining requests. + * As an example the following defines a buffer to accept an array + * of 10 float values + DBR_STATUS and DBR_TIME options + * + * struct { + * DBRstatus + * DBRtime + * float value[10] + * } buffer; + * + * IMPORTANT!! The DBRoptions must be given in the order that they + * appear in the Data Base Request Options #defines + * + * The associated dbGetField call is: + * + * long options,number_elements; + * ... + * options = DBR_STATUS|DBR_TIME; + * number_elements = 10; + * rtnval=dbGetField(paddr,DBR_FLOAT,&buffer,&options,&number_elements); + * + * When dbGetField returns: + * rtnval is error status (0 means success) + * options has a bit set for each option that was accepted + * number_elements is actual number of elements obtained + * + * The individual items can be refered to by the expressions:: + * + * buffer.status + * buffer.severity + * buffer.err_status + * buffer.epoch_seconds + * buffer.nano_seconds + * buffer.value[i] + * + * The following is also a valid declaration: + * + * typedef struct { + * DBRstatus + * DBRtime + * float value[10] + * } MYBUFFER; + * + * With this definition you can give definitions such as the following: + * + * MYBUFFER *pbuf1; + * MYBUFFER buf; + *************************************************************************/ + +/* Macros for defining each option */ +#define DBRstatus \ + unsigned short status; /* alarm status */\ + unsigned short severity; /* alarm severity*/\ + unsigned short acks; /* alarm ack severity*/\ + unsigned short ackt; /* Acknowledge transient alarms?*/ +#define DB_UNITS_SIZE 16 +#define DBRunits \ + char units[DB_UNITS_SIZE]; /* units */ +#define DBRprecision \ + long precision; /* number of decimal places*/\ + long field_width; /* field width */ +#define DBRtime \ + TS_STAMP time; /* time stamp*/ +#define DBRenumStrs \ + unsigned long no_str; /* number of strings*/\ + long padenumStrs; /*padding to force 8 byte align*/\ + char strs[DB_MAX_CHOICES][MAX_STRING_SIZE]; /* string values */ +#define DBRgrLong \ + long upper_disp_limit; /*upper limit of graph*/\ + long lower_disp_limit; /*lower limit of graph*/ +#define DBRgrDouble \ + double upper_disp_limit; /*upper limit of graph*/\ + double lower_disp_limit; /*lower limit of graph*/ +#define DBRctrlLong \ + long upper_ctrl_limit; /*upper limit of graph*/\ + long lower_ctrl_limit; /*lower limit of graph*/ +#define DBRctrlDouble \ + double upper_ctrl_limit; /*upper limit of graph*/\ + double lower_ctrl_limit; /*lower limit of graph*/ +#define DBRalLong \ + long upper_alarm_limit;\ + long upper_warning_limit;\ + long lower_warning_limit;\ + long lower_alarm_limit; +#define DBRalDouble \ + double upper_alarm_limit;\ + double upper_warning_limit;\ + double lower_warning_limit;\ + double lower_alarm_limit; + +/* structures for each option type */ +struct dbr_status {DBRstatus}; +struct dbr_units {DBRunits}; +struct dbr_precision {DBRprecision}; +struct dbr_time {DBRtime}; +struct dbr_enumStrs {DBRenumStrs}; +struct dbr_grLong {DBRgrLong}; +struct dbr_grDouble {DBRgrDouble}; +struct dbr_ctrlLong {DBRctrlLong}; +struct dbr_ctrlDouble {DBRctrlDouble}; +struct dbr_alLong {DBRalLong}; +struct dbr_alDouble {DBRalDouble}; +/* sizes for each option structure */ +#define dbr_status_size sizeof(struct dbr_status) +#define dbr_units_size sizeof(struct dbr_units) +#define dbr_precision_size sizeof(struct dbr_precision) +#define dbr_time_size sizeof(struct dbr_time) +#define dbr_enumStrs_size sizeof(struct dbr_enumStrs) +#define dbr_grLong_size sizeof(struct dbr_grLong) +#define dbr_grDouble_size sizeof(struct dbr_grDouble) +#define dbr_ctrlLong_size sizeof(struct dbr_ctrlLong) +#define dbr_ctrlDouble_size sizeof(struct dbr_ctrlDouble) +#define dbr_alLong_size sizeof(struct dbr_alLong) +#define dbr_alDouble_size sizeof(struct dbr_alDouble) + +#ifndef INCerrMdefh +#include +#endif +#define S_db_notFound (M_dbAccess| 1) /*Process Variable Not Found*/ +#define S_db_badDbrtype (M_dbAccess| 3) /*Illegal Database Request Type*/ +#define S_db_noMod (M_dbAccess| 5) /*Attempt to modify noMod field*/ +#define S_db_badLset (M_dbAccess| 7) /*Illegal Lock Set*/ +#define S_db_precision (M_dbAccess| 9) /*get precision failed */ +#define S_db_onlyOne (M_dbAccess|11) /*Only one element allowed*/ +#define S_db_badChoice (M_dbAccess|13) /*Illegal choice*/ +#define S_db_badField (M_dbAccess|15) /*Illegal field value*/ +#define S_db_lsetLogic (M_dbAccess|17) /*Logic error generating lock sets*/ +#define S_db_noRSET (M_dbAccess|31) /*missing record support entry table*/ +#define S_db_noSupport (M_dbAccess|33) /*RSET routine not defined*/ +#define S_db_BadSub (M_dbAccess|35) /*Subroutine not found*/ +/*!!!! Do not change next two lines without changing src/rsrv/server.h!!!!!!!!*/ +#define S_db_Pending (M_dbAccess|37) /*Request is pending*/ +#define S_db_Blocked (M_dbAccess|39) /*Request is Blocked*/ +#define S_db_putDisabled (M_dbAccess|41) /*putFields are disabled*/ +#define S_db_bkptSet (M_dbAccess|53) /*Breakpoint already set*/ +#define S_db_bkptNotSet (M_dbAccess|55) /*No breakpoint set in record*/ +#define S_db_notStopped (M_dbAccess|57) /*Record not stopped*/ +#define S_db_errArg (M_dbAccess|59) /*Error in argument*/ +#define S_db_bkptLogic (M_dbAccess|61) /*Logic error in breakpoint routine*/ +#define S_db_cntSpwn (M_dbAccess|63) /*Cannot spawn dbContTask*/ +#define S_db_cntCont (M_dbAccess|65) /*Cannot resume dbContTask*/ + +/* Global Database Access Routines*/ +#ifdef __STDC__ +struct rset *dbGetRset(struct dbAddr *paddr); +int dbIsValueField(struct dbFldDes *pdbFldDes); +int dbGetFieldIndex(struct dbAddr *paddr); +long dbCommonInit(struct dbCommon *precord, int pass); +void dbScanLock(struct dbCommon *precord); +void dbScanUnlock(struct dbCommon *precord); +void dbScanLockInit(int nset); +long dbScanPassive(struct dbCommon *pfrom,struct dbCommon *pto); +long dbProcess(struct dbCommon *precord); +long dbNameToAddr(char *pname,struct dbAddr *); +long dbGetLink(struct db_link *,struct dbCommon *precord,short dbrType, + void *pbuffer,long *options,long *nRequest); +long dbPutField(struct dbAddr *,short dbrType,void *pbuffer,long nRequest); +long dbPutNotify(PUTNOTIFY *pputnotify); +/*dbNotifyAdd called by dbScanPassive and dbScanLink*/ +void dbNotifyAdd(struct dbCommon *pfrom,struct dbCommon *pto); +void dbNotifyCancel(PUTNOTIFY *pputnotify); +/*dbNotifyCompletion called by recGblFwdLink and dbProcess */ +void dbNotifyCompletion(struct dbCommon *precord); /*called only by recGblFwdLink*/ +long dbPut(struct dbAddr *,short dbrType,void *pbuffer,long nRequest); +long dbGetField(struct dbAddr *,short dbrType,void *pbuffer,long *options,long *nRequest,void *pfl); +long dbGet(struct dbAddr *,short dbrType,void *pbuffer,long *options,long *nRequest,void *pfl); +long dbPutLink(struct db_link *,struct dbCommon *precord,short dbrType, + void *pbuffer,long nRequest); +long dbBufferSize(short dbrType,long options,long nRequest); +long dbValueSize(short dbrType); + +long dbCaAddInlink(struct link *plink,void *pdest_record,char *dest_fieldname); +long dbCaAddOutlink(struct link *plink,void *psource_record,char *source_fieldname); +long dbCaPutLink(struct link *plink,long *poptions,long *pnRequest); +long dbCaGetLink(struct link *plink); +void dbCaLinkInit(int pass); +long dbFastLinkGet(struct link *plink, struct dbCommon *precord, void *pdest); +long dbFastLinkPut(struct link *plink, struct dbCommon *precord, void *psource); +long cvt_uninit(void *from, void *to, struct dbAddr *paddr); +long cvt_dummy(void *from, void *to, struct dbAddr *paddr); +long dbScanLink(struct dbCommon *pfrom, struct dbCommon *pto); +#else +void dbScanLock(); +void dbScanUnlock(); +void dbScanLockInit(); +long dbScanPassive(); +long dbProcess(); +long dbNameToAddr(); +long dbGetLink(); +long dbPutField(); +long dbPut(); +long dbGetField(); +long dbPutLink(); +long dbBufferSize(); +long dbValueSize(); +long dbCaAddInlink(); +long dbCaAddOutlink(); +long dbCaPutLink(); +long dbCaGetLink(); +long dbFastLinkGet(); +long dbFastLinkPut(); +long cvt_uninit(); +long cvt_dummy(); +long dbScanLink(); + +#endif /*__STDC__*/ + +#endif /*INCdbAccessh*/ diff --git a/src/db/dbBkpt.h b/src/db/dbBkpt.h new file mode 100644 index 000000000..89de41e6b --- /dev/null +++ b/src/db/dbBkpt.h @@ -0,0 +1,105 @@ +/* dbBkpt.h */ +/* base/include $Id$ */ +/* + * Author: Matthew Needes + * Date: 8-30-93 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + */ + +#ifndef INCdbBkptsh +#define INCdbBkptsh 1 + +/* Needs to be put into dbTest.h ! */ +long dbpr(char *name, int level); + +/* + * Structure containing a list of set breakpoints + * in a lockset + */ + +struct BP_LIST { + NODE *next_list; + NODE *prev_list; + struct dbCommon *precord; +}; + +/* + * Structure containing queue of entrypoints + * detected for a lockset. + */ +struct EP_LIST { + NODE *next_list; + NODE *prev_list; + struct dbCommon *entrypoint; /* pointer to entry point in lockset */ + unsigned long count; /* number of times record processed */ + unsigned long time; /* time record first logged */ + char sched; /* schedule record for next dbContTask() pass */ +}; + +/* + * Structure for stack of lock sets that + * currently contain breakpoints. (uses lstLib) + */ +struct LS_LIST { + NODE *next_list; + NODE *prev_list; + struct dbCommon *precord;/* points to where execution is currently stopped */ + struct dbCommon *current_ep; /* current entrypoint */ + LIST bp_list; /* list of records containing breakpoints in a lockset */ + LIST ep_queue; /* queue of entrypoints found so far */ + SEM_ID ex_sem; /* semaphore for execution queue */ + int taskid; /* saved taskid for the task in stepping mode */ + int step; /* one if currently "stepping," else zero */ + short l_num; /* lockset number */ +}; + +/* Values for BKPT (breakpoint) field in record */ + +/* 1st bit = 0 if breakpoint is not set, */ +/* 1 if breakpoint set */ +/* 2nd bit = 0 if no printing after processing */ +/* 1 if print after processing set */ + +/* Breakpoint Masks */ +#define BKPT_ON_MASK 0x001 +#define BKPT_OFF_MASK 0x0FE +#define BKPT_PRINT_MASK 0x002 +#define BKPT_PRINT_OFF_MASK 0x0FD + +#define MAX_EP_COUNT 99999 + +long dbb(); +long dbd(); +long dbc(); +long dbs(); +long dbstat(); +long dbtap(); +int dbBkpt(); +void dbPrint(); + +extern long lset_stack_not_empty; + +#endif diff --git a/src/db/dbCommon.ascii b/src/db/dbCommon.db similarity index 100% rename from src/db/dbCommon.ascii rename to src/db/dbCommon.db diff --git a/src/db/dbCommonRecord.ascii b/src/db/dbCommonRecord.ascii deleted file mode 100644 index 7a238fb8f..000000000 --- a/src/db/dbCommonRecord.ascii +++ /dev/null @@ -1,3 +0,0 @@ -recordtype(dbCommon) { - include "dbCommon.ascii" -} diff --git a/src/db/dbCommonRecord.db b/src/db/dbCommonRecord.db new file mode 100644 index 000000000..56e062135 --- /dev/null +++ b/src/db/dbCommonRecord.db @@ -0,0 +1,3 @@ +recordtype(dbCommon) { + include "dbCommon.db" +} diff --git a/src/db/dbConvert.h b/src/db/dbConvert.h new file mode 100644 index 000000000..3a7d8751e --- /dev/null +++ b/src/db/dbConvert.h @@ -0,0 +1,39 @@ +/* dbConvert.h */ +/* + * Author: Marty Kraimer + * Date: 13OCT95 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 13OCT95 mrk Created header file as part of extracting convert from + * dbLink + */ + +#include +extern long (*dbGetConvertRoutine[DBF_DEVICE+1][DBR_ENUM+1]) + (DBADDR *paddr, void *pbuffer,long nRequest, long no_elements, long offset); +extern long (*dbPutConvertRoutine[DBR_ENUM+1][DBF_DEVICE+1]) + (DBADDR *paddr, void *pbuffer,long nRequest, long no_elements, long offset); +extern long (*dbFastGetConvertRoutine[DBF_DEVICE+1][DBR_ENUM+1])(); +extern long (*dbFastPutConvertRoutine[DBR_ENUM+1][DBF_DEVICE+1])(); diff --git a/src/db/dbEvent.h b/src/db/dbEvent.h new file mode 100644 index 000000000..0b871978d --- /dev/null +++ b/src/db/dbEvent.h @@ -0,0 +1,173 @@ +/* $Id$ + * + * Author: Jeff Hill + * Date: 030393 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 021494 joh updated ANSI func proto and added extra labor + * call back + */ + +#ifndef INCLdbEventh +#define INCLdbEventh + +/* + * collides with db_access.h used in the CA client + */ +#ifndef caClient +#include +#endif /*caClient*/ + +#include + +struct event_block{ + ELLNODE node; + struct db_addr *paddr; + void (*user_sub)( + void *user_arg, + struct db_addr *paddr, + int eventsRemaining, + db_field_log *pfl); + void *user_arg; + struct event_que *ev_que; + unsigned char select; + char valque; + unsigned long npend; /* n times this event is on the que */ +}; + +typedef void EVENTFUNC( + void *user_arg, + struct db_addr *paddr, + int eventsRemaining, + db_field_log *pfl); + + +#define EVENTQUESIZE EVENTENTRIES *32 +#define EVENTENTRIES 16 /* the number of que entries for each event */ +#define EVENTQEMPTY ((struct event_block *)NULL) + + +/* + * really a ring buffer + */ +struct event_que{ + struct event_block *evque[EVENTQUESIZE]; + db_field_log valque[EVENTQUESIZE]; + unsigned short putix; + unsigned short getix; + unsigned short quota; /* the number of assigned entries*/ + + /* lock writers to the ring buffer only */ + /* readers must never slow up writers */ + FAST_LOCK writelock; + + struct event_que *nextque; /* in case que quota exceeded */ + struct event_user *evuser; /* event user parent struct */ +}; + +struct event_user{ + int taskid; /* event handler task id */ + + char pendlck; /* Only one task can pend */ + SEM_ID ppendsem; /* Wait while empty */ + SEM_ID pflush_sem; /* wait for flush */ + unsigned char pendexit; /* exit pend task */ + unsigned char extra_labor; /* if set call extra labor func */ + + unsigned short queovr; /* event que overflow count */ + void (*overflow_sub)(/* called when overflow detect */ + void *overflow_arg, unsigned count); + void *overflow_arg; /* parameter to above */ + + void (*extralabor_sub)/* off load to event task */ + (void *extralabor_arg); + void *extralabor_arg;/* parameter to above */ + + struct event_que firstque; /* the first event que */ +}; + +typedef void OVRFFUNC(void *overflow_arg, unsigned count); +typedef void EXTRALABORFUNC(void *extralabor_arg); + +int db_event_list(char *name); +struct event_user *db_init_events(void); +int db_close_events(struct event_user *evuser); +unsigned db_sizeof_event_block(void); + +int db_add_event( +struct event_user *evuser, +struct db_addr *paddr, +EVENTFUNC *user_sub, +void *user_arg, +unsigned int select, +struct event_block *pevent /* ptr to event blk (not required) */ +); + +int db_cancel_event(struct event_block *pevent); + +int db_add_overflow_event( +struct event_user *evuser, +OVRFFUNC *overflow_sub, +void *overflow_arg +); + +int db_add_extra_labor_event( +struct event_user *evuser, +EXTRALABORFUNC *func, +void *arg); + +int db_flush_extra_labor_event( +struct event_user *evuser +); + +int db_post_single_event(struct event_block *pevent); + +int db_post_extra_labor(struct event_user *evuser); + +int db_post_events( +void *precord, +void *pvalue, +unsigned int select +); + +int db_start_events( +struct event_user *evuser, +char *taskname, /* defaulted if NULL */ +void (*init_func)(int), +int init_func_arg, +int priority_offset +); + +int event_task( +struct event_user *evuser, +void (*init_func)(int), +int init_func_arg +); + +int db_event_enable(struct event_block *pevent); +int db_event_disable(struct event_block *pevent); + +#endif /*INCLdbEventh*/ + diff --git a/src/db/dbScan.h b/src/db/dbScan.h new file mode 100644 index 000000000..f645f53bc --- /dev/null +++ b/src/db/dbScan.h @@ -0,0 +1,70 @@ +/* $Id$ + * + * Author: Marty Kraimer + * Date: 07-17-91 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 mm-dd-yy mrk Initial version + */ + +#ifndef INCdbScanh +#define INCdbScanh 1 +#include +#include +#include +/* Note that these must match the first three definitions in choiceGbl.ascii*/ +#define SCAN_PASSIVE 0 +#define SCAN_EVENT 1 +#define SCAN_IO_EVENT 2 +#define SCAN_1ST_PERIODIC 3 + +/*definitions for SCAN_IO_EVENT */ +typedef void * IOSCANPVT; +extern volatile int interruptAccept; + +#ifdef __STDC__ +long scanInit(void); +void post_event(int event); +void scanAdd(struct dbCommon *); +void scanDelete(struct dbCommon *); +void scanOnce(void *precord); +int scanppl(void); /*print periodic lists*/ +int scanpel(void); /*print event lists*/ +int scanpiol(void); /*print io_event list*/ +void scanIoInit(IOSCANPVT *); +void scanIoRequest(IOSCANPVT); + +#else +long scanInit(); +void post_event(); +void scanAdd(); +void scanDelete(); +void scanppl(); +void scanpel(); +void scanpiol(); +void scanIoInit(); +void scanIoRequest(); +#endif /*__STDC__*/ +#endif diff --git a/src/db/dbTest.c b/src/db/dbTest.c index ede8800af..3d65d4fa7 100644 --- a/src/db/dbTest.c +++ b/src/db/dbTest.c @@ -190,17 +190,20 @@ long dbnr(int verbose) DBENTRY *pdbentry=&dbentry; long status; int nrecords; + int total=0; dbInitEntry(pdbbase,pdbentry); status = dbFirstRecdes(pdbentry); if(status) printf("No record description\n"); while(!status) { nrecords = dbGetNRecords(pdbentry); + total += nrecords; if(verbose || nrecords) printf("%.4d %s\n",nrecords,dbGetRecdesName(pdbentry)); status = dbNextRecdes(pdbentry); } dbFinishEntry(pdbentry); + printf("Total Records: %d\n",total); return(0); } diff --git a/src/db/db_access.c b/src/db/db_access.c index 7fabc9908..2a517d458 100644 --- a/src/db/db_access.c +++ b/src/db/db_access.c @@ -572,7 +572,7 @@ void fill(pbuffer,size,fillchar) /* * DB_NAME_TO_ADDR */ -static short mapNewToOld[]={0,4,4,1,2,5,6,2,6,3}; +static short mapNewToOld[]={0,4,4,1,5,5,6,2,6,3}; short db_name_to_addr(pname,paddr) char *pname; diff --git a/src/db/db_access.h b/src/db/db_access.h new file mode 100644 index 000000000..de24ec387 --- /dev/null +++ b/src/db/db_access.h @@ -0,0 +1,1137 @@ +/* base/include/db_access.h */ +/* $Id$ +*/ + +/* + * Author: Bob Dalesio + * Date: 4-4-88 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * + * Modification Log: + * ----------------- + * .01 05-02-88 lrd add control enumeration field, structure & size + * .02 05-12-88 lrd add array structures + * change structure names dbf_ to dbr_ + * add VALID_FIELD_TYPE & INVALID_FIELD_TYPE macros + * add db_access_val union of all access strucures + * add MAX_STRING_SIZE 40 define + * .03 08-08-88 lrd add no_elements to db_addr + * removed DBF_ARRAY and all DBR_ARRAY variations + * made value the last field of each structure + * db_access_val union modified for changes + * dbr_size array modified for changes + * .04 11-29-88 lrd fixed declaration of union db_access_val + * .05 12-17-88 lrd added extra processing field + * .06 01-13-89 lrd added EP_CALC for modifying calculations on-line + * .07 03-12-90 joh added INCLdb_accessh for auto include + * .08 04-06-90 lrd add DBF_CHAR, DBF_LONG, DBF_DOUBLE + * and DBR_TIME + * .09 04-06-90 joh added dbr_size_n(type, count) + * .10 04-06-90 joh changed all dbr_size stuff to unsigned + * .11 04-27-90 rac added date to DBR_TIME structures + * .12 05-02-90 rac changed back to old way of doing sts and gr; + * added dbr and dbf keywords and macros + * .13 08-07-90 rac re-enter various changes since .12; change + * some char structure members to short; change + * time structures once more. + * .14 10-29-90 joh forced size and value size to allocate in + * one module alone. + * .15 10-29-90 joh added the readonly keyword for VAX C after + * failing to find any way to get the CA VMS share + * image to work without polluting the source. + * .16 01-07-91 rac fix a problem with dbf_text_to_type() + * .17 06-03-91 joh SPARC padding. + * .18 06-04-91 joh added VALID_DB_FIELD(x) & INVALID_DB_FIELD(x) + * macros. + * .19 03-01-91 mda integration of ANL/LANL code + * .20 06-25-91 joh added #include db_addr.h + * .21 02-02-94 mrk added PUTNOTIFY + * .22 08-17-94 joh MAX_UNITS_SIZE, MAX_ENUM_STRING_SIZE, + * MAX_ENUM_STATES used to declare the + * character arrays. + * .23 08-17-94 joh dbr_value_class[] definitions, + * .24 08-17-94 joh arch independent types + * .25 03-06-95 joh more arch independent types + * .26 05-17-95 joh conversion between epics core types + * and dbr types + * .27 05-26-95 joh added const + * + * NOTES: + * .01 06-04-91 joh the value must always be the last item + * in the structure so arrays work. + * .02 06-05-91 joh structures are aligned to their largest memeber + * for the SPARC. CA takes care of alignment + * between structures as part of the CA protocol. + */ + +#ifndef INCLdb_accessh +#define INCLdb_accessh + +#include +#include +#include +#include + +/* + *database access address structure + */ +#ifndef INC_db_addrh +#include +#endif + +/*definitions for db_put_notify */ +/*the following structure is identical*/ +/*except for struct dbAddr -> struct db_addr*/ +typedef struct pnRestartNode { + ELLNODE node; + struct putNotify *ppn; + struct putNotify *ppnrestartList; /*ppn with restartList*/ +}PNRESTARTNODE; + +typedef struct putNotify{ + /*The following members MUST be set by user*/ + void (*userCallback)(); /*callback provided by user*/ + struct db_addr *paddr; /*dbAddr set by dbNameToAddr*/ + void *pbuffer; /*address of data*/ + long nRequest; /*number of elements to be written*/ + short dbrType; /*database request type*/ + void *usrPvt; /*for private use of user*/ + /*The following is status of request. Set by dbPutNotify*/ + long status; + /*The following are private to database access*/ + CALLBACK callback; + ELLLIST waitList; /*list of records for which to wait*/ + ELLLIST restartList; /*list of PUTNOTIFYs to restart*/ + PNRESTARTNODE restartNode; /*node of on restartLlist*/ + short restart; + short callbackState; + void *waitForCallback; +}PUTNOTIFY; +/* dbPutNotify can be called after calling dbPutNotifyMapType(ppn,oldtype)*/ +int dbPutNotifyMapType(); + +#define MAX_UNITS_SIZE 8 +#define MAX_ENUM_STRING_SIZE 26 +#define MAX_ENUM_STATES 16 + +/* + * architecture independent types + * + * (so far this is sufficient for all archs we have ported to) + */ +typedef epicsOldString dbr_string_t; +typedef epicsUInt8 dbr_char_t; +typedef epicsInt16 dbr_short_t; +typedef epicsUInt16 dbr_ushort_t; +typedef epicsInt16 dbr_int_t; +typedef epicsUInt16 dbr_enum_t; +typedef epicsInt32 dbr_long_t; +typedef epicsFloat32 dbr_float_t; +typedef epicsFloat64 dbr_double_t; +typedef epicsUInt16 dbr_put_ackt_t; +typedef epicsUInt16 dbr_put_acks_t; + +/* database field types */ +#define DBF_STRING 0 +#define DBF_INT 1 +#define DBF_SHORT 1 +#define DBF_FLOAT 2 +#define DBF_ENUM 3 +#define DBF_CHAR 4 +#define DBF_LONG 5 +#define DBF_DOUBLE 6 +#define DBF_NO_ACCESS 7 +#define LAST_TYPE DBF_DOUBLE +#define VALID_DB_FIELD(x) ((x >= 0) && (x <= LAST_TYPE)) +#define INVALID_DB_FIELD(x) ((x < 0) || (x > LAST_TYPE)) + +/* data request buffer types */ +#define DBR_STRING DBF_STRING +#define DBR_INT DBF_INT +#define DBR_SHORT DBF_INT +#define DBR_FLOAT DBF_FLOAT +#define DBR_ENUM DBF_ENUM +#define DBR_CHAR DBF_CHAR +#define DBR_LONG DBF_LONG +#define DBR_DOUBLE DBF_DOUBLE +#define DBR_STS_STRING 7 +#define DBR_STS_SHORT 8 +#define DBR_STS_INT DBR_STS_SHORT +#define DBR_STS_FLOAT 9 +#define DBR_STS_ENUM 10 +#define DBR_STS_CHAR 11 +#define DBR_STS_LONG 12 +#define DBR_STS_DOUBLE 13 +#define DBR_TIME_STRING 14 +#define DBR_TIME_INT 15 +#define DBR_TIME_SHORT 15 +#define DBR_TIME_FLOAT 16 +#define DBR_TIME_ENUM 17 +#define DBR_TIME_CHAR 18 +#define DBR_TIME_LONG 19 +#define DBR_TIME_DOUBLE 20 +#define DBR_GR_STRING 21 +#define DBR_GR_SHORT 22 +#define DBR_GR_INT DBR_GR_SHORT +#define DBR_GR_FLOAT 23 +#define DBR_GR_ENUM 24 +#define DBR_GR_CHAR 25 +#define DBR_GR_LONG 26 +#define DBR_GR_DOUBLE 27 +#define DBR_CTRL_STRING 28 +#define DBR_CTRL_SHORT 29 +#define DBR_CTRL_INT DBR_CTRL_SHORT +#define DBR_CTRL_FLOAT 30 +#define DBR_CTRL_ENUM 31 +#define DBR_CTRL_CHAR 32 +#define DBR_CTRL_LONG 33 +#define DBR_CTRL_DOUBLE 34 +#define DBR_PUT_ACKT DBR_CTRL_DOUBLE + 1 +#define DBR_PUT_ACKS DBR_PUT_ACKT + 1 +#define DBR_STSACK_STRING DBR_PUT_ACKS + 1 +#define LAST_BUFFER_TYPE DBR_STSACK_STRING +#define VALID_DB_REQ(x) ((x >= 0) && (x <= LAST_BUFFER_TYPE)) +#define INVALID_DB_REQ(x) ((x < 0) || (x > LAST_BUFFER_TYPE)) + +/* + * The enumeration "epicsType" is an index to this array + * of type DBR types. In some cases we select the a + * larger type to avoid loss of information + */ +#ifdef DB_TEXT_GLBLSOURCE +READONLY int epicsTypeToDBR_XXXX [lastEpicsType+1] = { + DBR_SHORT, /* forces conversion fronm uint8 to int16 */ + DBR_CHAR, + DBR_SHORT, + DBR_LONG, /* forces conversion fronm uint16 to int32 */ + DBR_ENUM, + DBR_LONG, + DBR_LONG, /* very large unsigned number will not map */ + DBR_FLOAT, + DBR_DOUBLE, + DBR_STRING, + DBR_STRING +}; +#else +epicsShareExtern READONLY int epicsTypeToDBR_XXXX [lastEpicsType+1]; +#endif + +/* + * The DBR_XXXX types are indicies into this array + */ +#if defined(DB_TEXT_GLBLSOURCE) +READONLY epicsType DBR_XXXXToEpicsType [LAST_BUFFER_TYPE+1] = { + epicsOldStringT, + epicsInt16T, + epicsFloat32T, + epicsEnum16T, + epicsUInt8T, + epicsInt32T, + epicsFloat64T, + + epicsOldStringT, + epicsInt16T, + epicsFloat32T, + epicsEnum16T, + epicsUInt8T, + epicsInt32T, + epicsFloat64T, + + epicsOldStringT, + epicsInt16T, + epicsFloat32T, + epicsEnum16T, + epicsUInt8T, + epicsInt32T, + epicsFloat64T, + + epicsOldStringT, + epicsInt16T, + epicsFloat32T, + epicsEnum16T, + epicsUInt8T, + epicsInt32T, + epicsFloat64T, + + epicsOldStringT, + epicsInt16T, + epicsFloat32T, + epicsEnum16T, + epicsUInt8T, + epicsInt32T, + epicsFloat64T +}; +#else +epicsShareExtern READONLY epicsType DBR_XXXXToEpicsType [LAST_BUFFER_TYPE+1]; +#endif + +/* extra processing flags */ +#define EP_SCAN 0x01 +#define EP_INIT 0x02 +#define EP_CALC 0x03 + +/* values returned for each field type + * DBR_STRING returns a NULL terminated string + * DBR_SHORT returns an unsigned short + * DBR_INT returns an unsigned short + * DBR_FLOAT returns an IEEE floating point value + * DBR_ENUM returns an unsigned short which is the enum item + * DBR_CHAR returns an unsigned char + * DBR_LONG returns an unsigned long + * DBR_DOUBLE returns a double precision floating point number + * DBR_STS_STRING returns a string status structure (dbr_sts_string) + * DBR_STS_SHORT returns a short status structure (dbr_sts_short) + * DBR_STS_INT returns a short status structure (dbr_sts_int) + * DBR_STS_FLOAT returns a float status structure (dbr_sts_float) + * DBR_STS_ENUM returns an enum status structure (dbr_sts_enum) + * DBR_STS_CHAR returns a char status structure (dbr_sts_char) + * DBR_STS_LONG returns a long status structure (dbr_sts_long) + * DBR_STS_DOUBLE returns a double status structure (dbr_sts_double) + * DBR_TIME_STRING returns a string time structure (dbr_time_string) + * DBR_TIME_SHORT returns a short time structure (dbr_time_short) + * DBR_TIME_INT returns a short time structure (dbr_time_short) + * DBR_TIME_FLOAT returns a float time structure (dbr_time_float) + * DBR_TIME_ENUM returns an enum time structure (dbr_time_enum) + * DBR_TIME_CHAR returns a char time structure (dbr_time_char) + * DBR_TIME_LONG returns a long time structure (dbr_time_long) + * DBR_TIME_DOUBLE returns a double time structure (dbr_time_double) + * DBR_GR_STRING returns a graphic string structure (dbr_gr_string) + * DBR_GR_SHORT returns a graphic short structure (dbr_gr_short) + * DBR_GR_INT returns a graphic short structure (dbr_gr_int) + * DBR_GR_FLOAT returns a graphic float structure (dbr_gr_float) + * DBR_GR_ENUM returns a graphic enum structure (dbr_gr_enum) + * DBR_GR_CHAR returns a graphic char structure (dbr_gr_char) + * DBR_GR_LONG returns a graphic long structure (dbr_gr_long) + * DBR_GR_DOUBLE returns a graphic double structure (dbr_gr_double) + * DBR_CTRL_STRING returns a control string structure (dbr_ctrl_int) + * DBR_CTRL_SHORT returns a control short structure (dbr_ctrl_short) + * DBR_CTRL_INT returns a control short structure (dbr_ctrl_int) + * DBR_CTRL_FLOAT returns a control float structure (dbr_ctrl_float) + * DBR_CTRL_ENUM returns a control enum structure (dbr_ctrl_enum) + * DBR_CTRL_CHAR returns a control char structure (dbr_ctrl_char) + * DBR_CTRL_LONG returns a control long structure (dbr_ctrl_long) + * DBR_CTRL_DOUBLE returns a control double structure (dbr_ctrl_double) + */ + + +/* VALUES WITH STATUS STRUCTURES */ + +/* structure for a string status field */ +struct dbr_sts_string{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + dbr_string_t value; /* current value */ +}; + +/* structure for a string status and ack field */ +struct dbr_stsack_string{ + dbr_ushort_t status; /* status of value */ + dbr_ushort_t severity; /* severity of alarm */ + dbr_ushort_t ackt; /* ack transient? */ + dbr_ushort_t acks; /* ack severity */ + dbr_string_t value; /* current value */ +}; +/* structure for an short status field */ +struct dbr_sts_int{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + dbr_short_t value; /* current value */ +}; +struct dbr_sts_short{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + dbr_short_t value; /* current value */ +}; + +/* structure for a float status field */ +struct dbr_sts_float{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + dbr_float_t value; /* current value */ +}; + +/* structure for a enum status field */ +struct dbr_sts_enum{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + dbr_enum_t value; /* current value */ +}; + +/* structure for a char status field */ +struct dbr_sts_char{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + dbr_char_t RISC_pad; /* RISC alignment */ + dbr_char_t value; /* current value */ +}; + +/* structure for a long status field */ +struct dbr_sts_long{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + dbr_long_t value; /* current value */ +}; + +/* structure for a double status field */ +struct dbr_sts_double{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + dbr_long_t RISC_pad; /* RISC alignment */ + dbr_double_t value; /* current value */ +}; + +/* VALUES WITH STATUS AND TIME STRUCTURES */ + +/* structure for a string time field */ +struct dbr_time_string{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + TS_STAMP stamp; /* time stamp */ + dbr_string_t value; /* current value */ +}; + +/* structure for an short time field */ +struct dbr_time_short{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + TS_STAMP stamp; /* time stamp */ + dbr_short_t RISC_pad; /* RISC alignment */ + dbr_short_t value; /* current value */ +}; + +/* structure for a float time field */ +struct dbr_time_float{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + TS_STAMP stamp; /* time stamp */ + dbr_float_t value; /* current value */ +}; + +/* structure for a enum time field */ +struct dbr_time_enum{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + TS_STAMP stamp; /* time stamp */ + dbr_short_t RISC_pad; /* RISC alignment */ + dbr_enum_t value; /* current value */ +}; + +/* structure for a char time field */ +struct dbr_time_char{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + TS_STAMP stamp; /* time stamp */ + dbr_short_t RISC_pad0; /* RISC alignment */ + dbr_char_t RISC_pad1; /* RISC alignment */ + dbr_char_t value; /* current value */ +}; + +/* structure for a long time field */ +struct dbr_time_long{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + TS_STAMP stamp; /* time stamp */ + dbr_long_t value; /* current value */ +}; + +/* structure for a double time field */ +struct dbr_time_double{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + TS_STAMP stamp; /* time stamp */ + dbr_long_t RISC_pad; /* RISC alignment */ + dbr_double_t value; /* current value */ +}; + +/* VALUES WITH STATUS AND GRAPHIC STRUCTURES */ + +/* structure for a graphic string */ + /* not implemented; use struct_dbr_sts_string */ + +/* structure for a graphic short field */ +struct dbr_gr_int{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + char units[MAX_UNITS_SIZE]; /* units of value */ + dbr_short_t upper_disp_limit; /* upper limit of graph */ + dbr_short_t lower_disp_limit; /* lower limit of graph */ + dbr_short_t upper_alarm_limit; + dbr_short_t upper_warning_limit; + dbr_short_t lower_warning_limit; + dbr_short_t lower_alarm_limit; + dbr_short_t value; /* current value */ +}; +struct dbr_gr_short{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + char units[MAX_UNITS_SIZE]; /* units of value */ + dbr_short_t upper_disp_limit; /* upper limit of graph */ + dbr_short_t lower_disp_limit; /* lower limit of graph */ + dbr_short_t upper_alarm_limit; + dbr_short_t upper_warning_limit; + dbr_short_t lower_warning_limit; + dbr_short_t lower_alarm_limit; + dbr_short_t value; /* current value */ +}; + +/* structure for a graphic floating point field */ +struct dbr_gr_float{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + dbr_short_t precision; /* number of decimal places */ + dbr_short_t RISC_pad0; /* RISC alignment */ + char units[MAX_UNITS_SIZE]; /* units of value */ + dbr_float_t upper_disp_limit; /* upper limit of graph */ + dbr_float_t lower_disp_limit; /* lower limit of graph */ + dbr_float_t upper_alarm_limit; + dbr_float_t upper_warning_limit; + dbr_float_t lower_warning_limit; + dbr_float_t lower_alarm_limit; + dbr_float_t value; /* current value */ +}; + +/* structure for a graphic enumeration field */ +struct dbr_gr_enum{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + dbr_short_t no_str; /* number of strings */ + char strs[MAX_ENUM_STATES][MAX_ENUM_STRING_SIZE]; + /* state strings */ + dbr_enum_t value; /* current value */ +}; + +/* structure for a graphic char field */ +struct dbr_gr_char{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + char units[MAX_UNITS_SIZE]; /* units of value */ + dbr_char_t upper_disp_limit; /* upper limit of graph */ + dbr_char_t lower_disp_limit; /* lower limit of graph */ + dbr_char_t upper_alarm_limit; + dbr_char_t upper_warning_limit; + dbr_char_t lower_warning_limit; + dbr_char_t lower_alarm_limit; + dbr_char_t RISC_pad; /* RISC alignment */ + dbr_char_t value; /* current value */ +}; + +/* structure for a graphic long field */ +struct dbr_gr_long{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + char units[MAX_UNITS_SIZE]; /* units of value */ + dbr_long_t upper_disp_limit; /* upper limit of graph */ + dbr_long_t lower_disp_limit; /* lower limit of graph */ + dbr_long_t upper_alarm_limit; + dbr_long_t upper_warning_limit; + dbr_long_t lower_warning_limit; + dbr_long_t lower_alarm_limit; + dbr_long_t value; /* current value */ +}; + +/* structure for a graphic double field */ +struct dbr_gr_double{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + dbr_short_t precision; /* number of decimal places */ + dbr_short_t RISC_pad0; /* RISC alignment */ + char units[MAX_UNITS_SIZE]; /* units of value */ + dbr_double_t upper_disp_limit; /* upper limit of graph */ + dbr_double_t lower_disp_limit; /* lower limit of graph */ + dbr_double_t upper_alarm_limit; + dbr_double_t upper_warning_limit; + dbr_double_t lower_warning_limit; + dbr_double_t lower_alarm_limit; + dbr_double_t value; /* current value */ +}; + +/* VALUES WITH STATUS, GRAPHIC and CONTROL STRUCTURES */ + +/* structure for a control string */ + /* not implemented; use struct_dbr_sts_string */ + +/* structure for a control integer */ +struct dbr_ctrl_int{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + char units[MAX_UNITS_SIZE]; /* units of value */ + dbr_short_t upper_disp_limit; /* upper limit of graph */ + dbr_short_t lower_disp_limit; /* lower limit of graph */ + dbr_short_t upper_alarm_limit; + dbr_short_t upper_warning_limit; + dbr_short_t lower_warning_limit; + dbr_short_t lower_alarm_limit; + dbr_short_t upper_ctrl_limit; /* upper control limit */ + dbr_short_t lower_ctrl_limit; /* lower control limit */ + dbr_short_t value; /* current value */ +}; +struct dbr_ctrl_short{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + char units[MAX_UNITS_SIZE]; /* units of value */ + dbr_short_t upper_disp_limit; /* upper limit of graph */ + dbr_short_t lower_disp_limit; /* lower limit of graph */ + dbr_short_t upper_alarm_limit; + dbr_short_t upper_warning_limit; + dbr_short_t lower_warning_limit; + dbr_short_t lower_alarm_limit; + dbr_short_t upper_ctrl_limit; /* upper control limit */ + dbr_short_t lower_ctrl_limit; /* lower control limit */ + dbr_short_t value; /* current value */ +}; + +/* structure for a control floating point field */ +struct dbr_ctrl_float{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + dbr_short_t precision; /* number of decimal places */ + dbr_short_t RISC_pad; /* RISC alignment */ + char units[MAX_UNITS_SIZE]; /* units of value */ + dbr_float_t upper_disp_limit; /* upper limit of graph */ + dbr_float_t lower_disp_limit; /* lower limit of graph */ + dbr_float_t upper_alarm_limit; + dbr_float_t upper_warning_limit; + dbr_float_t lower_warning_limit; + dbr_float_t lower_alarm_limit; + dbr_float_t upper_ctrl_limit; /* upper control limit */ + dbr_float_t lower_ctrl_limit; /* lower control limit */ + dbr_float_t value; /* current value */ +}; + +/* structure for a control enumeration field */ +struct dbr_ctrl_enum{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + dbr_short_t no_str; /* number of strings */ + char strs[MAX_ENUM_STATES][MAX_ENUM_STRING_SIZE]; + /* state strings */ + dbr_enum_t value; /* current value */ +}; + +/* structure for a control char field */ +struct dbr_ctrl_char{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + char units[MAX_UNITS_SIZE]; /* units of value */ + dbr_char_t upper_disp_limit; /* upper limit of graph */ + dbr_char_t lower_disp_limit; /* lower limit of graph */ + dbr_char_t upper_alarm_limit; + dbr_char_t upper_warning_limit; + dbr_char_t lower_warning_limit; + dbr_char_t lower_alarm_limit; + dbr_char_t upper_ctrl_limit; /* upper control limit */ + dbr_char_t lower_ctrl_limit; /* lower control limit */ + dbr_char_t RISC_pad; /* RISC alignment */ + dbr_char_t value; /* current value */ +}; + +/* structure for a control long field */ +struct dbr_ctrl_long{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + char units[MAX_UNITS_SIZE]; /* units of value */ + dbr_long_t upper_disp_limit; /* upper limit of graph */ + dbr_long_t lower_disp_limit; /* lower limit of graph */ + dbr_long_t upper_alarm_limit; + dbr_long_t upper_warning_limit; + dbr_long_t lower_warning_limit; + dbr_long_t lower_alarm_limit; + dbr_long_t upper_ctrl_limit; /* upper control limit */ + dbr_long_t lower_ctrl_limit; /* lower control limit */ + dbr_long_t value; /* current value */ +}; + +/* structure for a control double field */ +struct dbr_ctrl_double{ + dbr_short_t status; /* status of value */ + dbr_short_t severity; /* severity of alarm */ + dbr_short_t precision; /* number of decimal places */ + dbr_short_t RISC_pad0; /* RISC alignment */ + char units[MAX_UNITS_SIZE]; /* units of value */ + dbr_double_t upper_disp_limit; /* upper limit of graph */ + dbr_double_t lower_disp_limit; /* lower limit of graph */ + dbr_double_t upper_alarm_limit; + dbr_double_t upper_warning_limit; + dbr_double_t lower_warning_limit; + dbr_double_t lower_alarm_limit; + dbr_double_t upper_ctrl_limit; /* upper control limit */ + dbr_double_t lower_ctrl_limit; /* lower control limit */ + dbr_double_t value; /* current value */ +}; + +#define dbr_size_n(TYPE,COUNT)\ +((unsigned)((COUNT)==1?dbr_size[TYPE]:dbr_size[TYPE]+((COUNT)-1)*dbr_value_size[TYPE])) +/* size for each type */ + +#ifndef DB_TEXT_GLBLSOURCE +epicsShareExtern READONLY unsigned short dbr_size[LAST_BUFFER_TYPE+1]; +#else +READONLY unsigned short dbr_size[LAST_BUFFER_TYPE+1] = { + sizeof(dbr_string_t), /* string max size */ + sizeof(dbr_short_t), /* short */ + sizeof(dbr_float_t), /* IEEE Float */ + sizeof(dbr_enum_t), /* item number */ + sizeof(dbr_char_t), /* character */ + sizeof(dbr_long_t), /* long */ + sizeof(dbr_double_t), /* double */ + sizeof(struct dbr_sts_string), /* string field with status */ + sizeof(struct dbr_sts_short), /* short field with status */ + sizeof(struct dbr_sts_float), /* float field with status */ + sizeof(struct dbr_sts_enum), /* item number with status */ + sizeof(struct dbr_sts_char), /* char field with status */ + sizeof(struct dbr_sts_long), /* long field with status */ + sizeof(struct dbr_sts_double), /* double field with time */ + sizeof(struct dbr_time_string), /* string field with time */ + sizeof(struct dbr_time_short), /* short field with time */ + sizeof(struct dbr_time_float), /* float field with time */ + sizeof(struct dbr_time_enum), /* item number with time */ + sizeof(struct dbr_time_char), /* char field with time */ + sizeof(struct dbr_time_long), /* long field with time */ + sizeof(struct dbr_time_double), /* double field with time */ + sizeof(struct dbr_sts_string), /* graphic string info */ + sizeof(struct dbr_gr_short), /* graphic short info */ + sizeof(struct dbr_gr_float), /* graphic float info */ + sizeof(struct dbr_gr_enum), /* graphic item info */ + sizeof(struct dbr_gr_char), /* graphic char info */ + sizeof(struct dbr_gr_long), /* graphic long info */ + sizeof(struct dbr_gr_double), /* graphic double info */ + sizeof(struct dbr_sts_string), /* control string info */ + sizeof(struct dbr_ctrl_short), /* control short info */ + sizeof(struct dbr_ctrl_float), /* control float info */ + sizeof(struct dbr_ctrl_enum), /* control item info */ + sizeof(struct dbr_ctrl_char), /* control char info */ + sizeof(struct dbr_ctrl_long), /* control long info */ + sizeof(struct dbr_ctrl_double), /* control double info */ + sizeof(dbr_put_ackt_t), /* put ackt */ + sizeof(dbr_put_acks_t), /* put acks */ + sizeof(struct dbr_stsack_string),/* string field with status/ack*/ +}; +#endif + +/* size for each type's value */ +#ifndef DB_TEXT_GLBLSOURCE +epicsShareExtern READONLY unsigned short dbr_value_size[LAST_BUFFER_TYPE+1]; +#else +READONLY unsigned short dbr_value_size[LAST_BUFFER_TYPE+1] = { + sizeof(dbr_string_t), /* string max size */ + sizeof(dbr_short_t), /* short */ + sizeof(dbr_float_t), /* IEEE Float */ + sizeof(dbr_enum_t), /* item number */ + sizeof(dbr_char_t), /* character */ + sizeof(dbr_long_t), /* long */ + sizeof(dbr_double_t), /* double */ + sizeof(dbr_string_t), /* string max size */ + sizeof(dbr_short_t), /* short */ + sizeof(dbr_float_t), /* IEEE Float */ + sizeof(dbr_enum_t), /* item number */ + sizeof(dbr_char_t), /* character */ + sizeof(dbr_long_t), /* long */ + sizeof(dbr_double_t), /* double */ + sizeof(dbr_string_t), /* string max size */ + sizeof(dbr_short_t), /* short */ + sizeof(dbr_float_t), /* IEEE Float */ + sizeof(dbr_enum_t), /* item number */ + sizeof(dbr_char_t), /* character */ + sizeof(dbr_long_t), /* long */ + sizeof(dbr_double_t), /* double */ + sizeof(dbr_string_t), /* string max size */ + sizeof(dbr_short_t), /* short */ + sizeof(dbr_float_t), /* IEEE Float */ + sizeof(dbr_enum_t), /* item number */ + sizeof(dbr_char_t), /* character */ + sizeof(dbr_long_t), /* long */ + sizeof(dbr_double_t), /* double */ + sizeof(dbr_string_t), /* string max size */ + sizeof(dbr_short_t), /* short */ + sizeof(dbr_float_t), /* IEEE Float */ + sizeof(dbr_enum_t), /* item number */ + sizeof(dbr_char_t), /* character */ + sizeof(dbr_long_t), /* long */ + sizeof(dbr_double_t), /* double */ + sizeof(dbr_ushort_t), /* put_ackt */ + sizeof(dbr_ushort_t), /* put_acks */ + sizeof(dbr_string_t), /* string max size */ +}; +#endif + + +/* class for each type's value */ +#if 0 +enum dbr_value_class { + dbr_class_int, + dbr_class_float, + dbr_class_string, + dbr_class_max}; +#ifndef DB_TEXT_GLBLSOURCE +epicsShareExtern READONLY enum dbr_value_class dbr_value_class[LAST_BUFFER_TYPE+1]; +#else +READONLY enum dbr_value_class dbr_value_class[LAST_BUFFER_TYPE+1] = { + dbr_class_string, /* string max size */ + dbr_class_int, /* short */ + dbr_class_float, /* IEEE Float */ + dbr_class_int, /* item number */ + dbr_class_int, /* character */ + dbr_class_int, /* long */ + dbr_class_float, /* double */ + + dbr_class_string, /* string max size */ + dbr_class_int, /* short */ + dbr_class_float, /* IEEE Float */ + dbr_class_int, /* item number */ + dbr_class_int, /* character */ + dbr_class_int, /* long */ + dbr_class_float, /* double */ + + dbr_class_string, /* string max size */ + dbr_class_int, /* short */ + dbr_class_float, /* IEEE Float */ + dbr_class_int, /* item number */ + dbr_class_int, /* character */ + dbr_class_int, /* long */ + dbr_class_float, /* double */ + + dbr_class_string, /* string max size */ + dbr_class_int, /* short */ + dbr_class_float, /* IEEE Float */ + dbr_class_int, /* item number */ + dbr_class_int, /* character */ + dbr_class_int, /* long */ + dbr_class_float, /* double */ + + dbr_class_string, /* string max size */ + dbr_class_int, /* short */ + dbr_class_float, /* IEEE Float */ + dbr_class_int, /* item number */ + dbr_class_int, /* character */ + dbr_class_int, /* long */ + dbr_class_float, /* double */ + dbr_class_int, + dbr_class_int, + dbr_class_string, +}; +#endif +#endif + + +/* + * ptr to value given a pointer to the structure and the DBR type + */ +#define dbr_value_ptr(PDBR, DBR_TYPE) \ +((void *)(((char *)PDBR)+dbr_value_offset[DBR_TYPE])) + +/* + * byte offset of member in structure + */ +#define BYTE_OS(STRUCTURE, MEMBER) \ +((int) & (((STRUCTURE *)0) -> MEMBER)) + +/* + * ptr to value given a pointer to the structure and the structure declaration + */ +#define dbr_value_ptr_from_structure(PDBR, STRUCTURE)\ +((void *)(((char *)PDBR)+BYTE_OS(STRUCTURE, value))) + +#ifndef DB_TEXT_GLBLSOURCE +epicsShareExtern READONLY unsigned short dbr_value_offset[LAST_BUFFER_TYPE+1]; +#else +READONLY unsigned short dbr_value_offset[LAST_BUFFER_TYPE+1] = { + 0, /* string */ + 0, /* short */ + 0, /* IEEE Float */ + 0, /* item number */ + 0, /* character */ + 0, /* long */ + 0, /* IEEE double */ + BYTE_OS(struct dbr_sts_string,value[0]),/* string field with status */ + BYTE_OS(struct dbr_sts_short,value), /* short field with status */ + BYTE_OS(struct dbr_sts_float,value), /* float field with status */ + BYTE_OS(struct dbr_sts_enum,value), /* item number with status */ + BYTE_OS(struct dbr_sts_char,value), /* char field with status */ + BYTE_OS(struct dbr_sts_long,value), /* long field with status */ + BYTE_OS(struct dbr_sts_double,value), /* double field with time */ + BYTE_OS(struct dbr_time_string,value[0]),/* string field with time */ + BYTE_OS(struct dbr_time_short,value), /* short field with time */ + BYTE_OS(struct dbr_time_float,value), /* float field with time */ + BYTE_OS(struct dbr_time_enum,value), /* item number with time */ + BYTE_OS(struct dbr_time_char,value), /* char field with time */ + BYTE_OS(struct dbr_time_long,value), /* long field with time */ + BYTE_OS(struct dbr_time_double,value), /* double field with time */ + BYTE_OS(struct dbr_sts_string,value[0]),/* graphic string info */ + BYTE_OS(struct dbr_gr_short,value), /* graphic short info */ + BYTE_OS(struct dbr_gr_float,value), /* graphic float info */ + BYTE_OS(struct dbr_gr_enum,value), /* graphic item info */ + BYTE_OS(struct dbr_gr_char,value), /* graphic char info */ + BYTE_OS(struct dbr_gr_long,value), /* graphic long info */ + BYTE_OS(struct dbr_gr_double,value), /* graphic double info */ + BYTE_OS(struct dbr_sts_string,value[0]),/* control string info */ + BYTE_OS(struct dbr_ctrl_short,value), /* control short info */ + BYTE_OS(struct dbr_ctrl_float,value), /* control float info */ + BYTE_OS(struct dbr_ctrl_enum,value), /* control item info */ + BYTE_OS(struct dbr_ctrl_char,value), /* control char info */ + BYTE_OS(struct dbr_ctrl_long,value), /* control long info */ + BYTE_OS(struct dbr_ctrl_double,value), /* control double info */ + 0, /* put ackt */ + 0, /* put acks */ + BYTE_OS(struct dbr_stsack_string,value[0]),/* string field with status */ +}; +#endif + +/* union for each fetch buffers */ +union db_access_val{ + dbr_string_t strval; /* string max size */ + dbr_short_t shrtval; /* short */ + dbr_short_t intval; /* short */ + dbr_float_t fltval; /* IEEE Float */ + dbr_enum_t enmval; /* item number */ + dbr_char_t charval; /* character */ + dbr_long_t longval; /* long */ + dbr_double_t doubleval; /* double */ + struct dbr_sts_string sstrval; /* string field with status */ + struct dbr_sts_short sshrtval; /* short field with status */ + struct dbr_sts_float sfltval; /* float field with status */ + struct dbr_sts_enum senmval; /* item number with status */ + struct dbr_sts_char schrval; /* char field with status */ + struct dbr_sts_long slngval; /* long field with status */ + struct dbr_sts_double sdblval; /* double field with time */ + struct dbr_time_string tstrval; /* string field with time */ + struct dbr_time_short tshrtval; /* short field with time */ + struct dbr_time_float tfltval; /* float field with time */ + struct dbr_time_enum tenmval; /* item number with time */ + struct dbr_time_char tchrval; /* char field with time */ + struct dbr_time_long tlngval; /* long field with time */ + struct dbr_time_double tdblval; /* double field with time */ + struct dbr_sts_string gstrval; /* graphic string info */ + struct dbr_gr_short gshrtval; /* graphic short info */ + struct dbr_gr_float gfltval; /* graphic float info */ + struct dbr_gr_enum genmval; /* graphic item info */ + struct dbr_gr_char gchrval; /* graphic char info */ + struct dbr_gr_long glngval; /* graphic long info */ + struct dbr_gr_double gdblval; /* graphic double info */ + struct dbr_sts_string cstrval; /* control string info */ + struct dbr_ctrl_short cshrtval; /* control short info */ + struct dbr_ctrl_float cfltval; /* control float info */ + struct dbr_ctrl_enum cenmval; /* control item info */ + struct dbr_ctrl_char cchrval; /* control char info */ + struct dbr_ctrl_long clngval; /* control long info */ + struct dbr_ctrl_double cdblval; /* control double info */ + dbr_put_ackt_t putackt; /* item number */ + dbr_put_acks_t putacks; /* item number */ + struct dbr_sts_string sastrval; /* string field with status */ +}; + +/*---------------------------------------------------------------------------- +* repository for some useful PV database constants and utilities +* +* item dimensions +* db_strval_dim dimension for string values +* db_units_dim dimension for record units text +* db_desc_dim dimension for record description text +* db_name_dim dimension for channel names (record.field\0) +* db_state_dim number of states possible in a state table +* db_state_text_dim dimension for a state text string +* usage: char state_table[db_state_dim][db_state_text_dim] +* +* type checking macros -- return non-zero if condition is true, zero otherwise +* +* int dbf_type_is_valid(type) type is a valid DBF_xxx +* int dbr_type_is_valid(type) type is a valid DBR_xxx +* int dbr_type_is_plain(type) type is a valid plain DBR_xxx +* int dbr_type_is_STS(type) type is a valid DBR_STS_xxx +* int dbr_type_is_TIME(type) type is a valid DBR_TIME_xxx +* int dbr_type_is_GR(type) type is a valid DBR_GR_xxx +* int dbr_type_is_CTRL(type) type is a valid DBR_CTRL_xxx +* int dbr_type_is_STRING(type) type is a valid DBR_STRING_xxx +* int dbr_type_is_SHORT(type) type is a valid DBR_SHORT_xxx +* int dbr_type_is_FLOAT(type) type is a valid DBR_FLOAT_xxx +* int dbr_type_is_ENUM(type) type is a valid DBR_ENUM_xxx +* int dbr_type_is_CHAR(type) type is a valid DBR_CHAR_xxx +* int dbr_type_is_LONG(type) type is a valid DBR_LONG_xxx +* int dbr_type_is_DOUBLE(type) type is a valid DBR_DOUBLE_xxx +* +* type conversion macros +* +* char *dbf_type_to_text(type) returns text matching DBF_xxx +* void dbf_text_to_type(text, type) finds DBF_xxx matching text +* int dbf_type_to_DBR(type) returns DBR_xxx matching DBF_xxx +* int dbf_type_to_DBR_TIME(type) returns DBR_TIME_xxx matching DBF_xxx +* int dbf_type_to_DBR_GR(type) returns DBR_GR_xxx matching DBF_xxx +* int dbf_type_to_DBR_CTRL(type) returns DBR_CTRL_xxx matching DBF_xxx +* char *dbr_type_to_text(type) returns text matching DBR_xxx +* void dbr_text_to_type(text, type) finds DBR_xxx matching text +*---------------------------------------------------------------------------*/ +#define db_strval_dim MAX_STRING_SIZE +#define db_units_dim MAX_UNITS_SIZE +#define db_desc_dim 24 +#define db_name_dim 36 +#define db_state_dim MAX_ENUM_STATES +#define db_state_text_dim MAX_ENUM_STRING_SIZE + +#define dbf_type_is_valid(type) ((type) >= 0 && (type) <= LAST_TYPE) +#define dbr_type_is_valid(type) ((type) >= 0 && (type) <= LAST_BUFFER_TYPE) +#define dbr_type_is_plain(type) \ + ((type) >= DBR_STRING && (type) <= DBR_DOUBLE) +#define dbr_type_is_STS(type) \ + ((type) >= DBR_STS_STRING && (type) <= DBR_STS_DOUBLE) +#define dbr_type_is_TIME(type) \ + ((type) >= DBR_TIME_STRING && (type) <= DBR_TIME_DOUBLE) +#define dbr_type_is_GR(type) \ + ((type) >= DBR_GR_STRING && (type) <= DBR_GR_DOUBLE) +#define dbr_type_is_CTRL(type) \ + ((type) >= DBR_CTRL_STRING && (type) <= DBR_CTRL_DOUBLE) +#define dbr_type_is_STRING(type) \ + ((type) >= 0 && (type) <= LAST_BUFFER_TYPE && \ + (type)%(LAST_TYPE+1) == DBR_STRING) +#define dbr_type_is_SHORT(type) \ + ((type) >= 0 && (type) <= LAST_BUFFER_TYPE && \ + (type)%(LAST_TYPE+1) == DBR_SHORT) +#define dbr_type_is_FLOAT(type) \ + ((type) >= 0 && (type) <= LAST_BUFFER_TYPE && \ + (type)%(LAST_TYPE+1) == DBR_FLOAT) +#define dbr_type_is_ENUM(type) \ + ((type) >= 0 && (type) <= LAST_BUFFER_TYPE && \ + (type)%(LAST_TYPE+1) == DBR_ENUM) +#define dbr_type_is_CHAR(type) \ + ((type) >= 0 && (type) <= LAST_BUFFER_TYPE && \ + (type)%(LAST_TYPE+1) == DBR_CHAR) +#define dbr_type_is_LONG(type) \ + ((type) >= 0 && (type) <= LAST_BUFFER_TYPE && \ + (type)%(LAST_TYPE+1) == DBR_LONG) +#define dbr_type_is_DOUBLE(type) \ + ((type) >= 0 && (type) <= LAST_BUFFER_TYPE && \ + (type)%(LAST_TYPE+1) == DBR_DOUBLE) + +#define dbf_type_to_text(type) \ + ( ((type) >= -1 && (type) <= dbf_text_dim-2) ? \ + dbf_text[(type+1)] : dbf_text_invalid ) + +#define dbf_text_to_type(text, type) \ + for (type=dbf_text_dim-3; type>=0; type--) { \ + if (strcmp(text, dbf_text[type+1]) == 0) \ + break; \ + } + +#define dbr_type_to_text(type) \ + ( ((type) >= 0 && (type) < dbr_text_dim) ? \ + dbr_text[(type)] : dbr_text_invalid ) + +#define dbr_text_to_type(text, type) \ + for (type=dbr_text_dim-1; type>=0; type--) { \ + if (strcmp(text, dbr_text[type]) == 0) \ + break; \ + } + +#define dbf_type_to_DBR(type) \ + (((type) >= 0 && (type) <= dbf_text_dim-3) ? \ + (type) : -1 ) + +#define dbf_type_to_DBR_STS(type) \ + (((type) >= 0 && (type) <= dbf_text_dim-3) ? \ + (type) + (dbf_text_dim-2) : -1 ) + +#define dbf_type_to_DBR_TIME(type) \ + (((type) >= 0 && (type) <= dbf_text_dim-3) ? \ + (type) + 2*(dbf_text_dim-2) : -1 ) + +#define dbf_type_to_DBR_GR(type) \ + (((type) >= 0 && (type) <= dbf_text_dim-3) ? \ + (type) + 3*(dbf_text_dim-2) : -1 ) + +#define dbf_type_to_DBR_CTRL(type) \ + (((type) >= 0 && (type) <= dbf_text_dim-3) ? \ + (type) + 4*(dbf_text_dim-2) : -1 ) + + + +#ifndef DB_TEXT_GLBLSOURCE + epicsShareExtern READONLY char *dbf_text[LAST_TYPE+2], *dbf_text_invalid; + epicsShareExtern READONLY short dbf_text_dim; +#else + READONLY char *dbf_text[] = { + "TYPENOTCONN", + "DBF_STRING", + "DBF_SHORT", + "DBF_FLOAT", + "DBF_ENUM", + "DBF_CHAR", + "DBF_LONG", + "DBF_DOUBLE", + "DBF_NO_ACCESS" + }; + READONLY char *dbf_text_invalid = "DBF_invalid"; + READONLY short dbf_text_dim = (sizeof dbf_text)/(sizeof (char *)); +#endif + +#ifndef DB_TEXT_GLBLSOURCE + epicsShareExtern READONLY char *dbr_text[LAST_BUFFER_TYPE+1], *dbr_text_invalid; + epicsShareExtern READONLY short dbr_text_dim; +#else + READONLY char *dbr_text[LAST_BUFFER_TYPE+1] = { + "DBR_STRING", + "DBR_SHORT", + "DBR_FLOAT", + "DBR_ENUM", + "DBR_CHAR", + "DBR_LONG", + "DBR_DOUBLE", + "DBR_STS_STRING", + "DBR_STS_SHORT", + "DBR_STS_FLOAT", + "DBR_STS_ENUM", + "DBR_STS_CHAR", + "DBR_STS_LONG", + "DBR_STS_DOUBLE", + "DBR_TIME_STRING", + "DBR_TIME_SHORT", + "DBR_TIME_FLOAT", + "DBR_TIME_ENUM", + "DBR_TIME_CHAR", + "DBR_TIME_LONG", + "DBR_TIME_DOUBLE", + "DBR_GR_STRING", + "DBR_GR_SHORT", + "DBR_GR_FLOAT", + "DBR_GR_ENUM", + "DBR_GR_CHAR", + "DBR_GR_LONG", + "DBR_GR_DOUBLE", + "DBR_CTRL_STRING", + "DBR_CTRL_SHORT", + "DBR_CTRL_FLOAT", + "DBR_CTRL_ENUM", + "DBR_CTRL_CHAR", + "DBR_CTRL_LONG", + "DBR_CTRL_DOUBLE", + "DBR_PUT_ACKT", + "DBR_PUT_ACKS", + "DBR_STSACK_STRING", + }; + READONLY char * READONLY dbr_text_invalid = "DBR_invalid"; + READONLY short dbr_text_dim = (sizeof dbr_text)/(sizeof (char *)); +#endif + +short db_name_to_addr(); +short db_put_field(); +short db_get_field(); + +#endif /* INCLdb_accessh */ diff --git a/src/db/db_addr.h b/src/db/db_addr.h new file mode 100644 index 000000000..701d664b0 --- /dev/null +++ b/src/db/db_addr.h @@ -0,0 +1,49 @@ +/* $Id$ + * + * Author: Bob Dalesio + * Date: 4-4-88 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + */ +#ifndef INC_db_addrh +#define INC_db_addrh +/* + *database access address structure + */ +struct db_addr{ + char *precord; /* record number of specified type */ + char *pfield; /* offset from the record origin */ + char *pad0; /* not used by old */ + void *asPvt; /*Access Security Private */ + short pad1; /*not used by old */ + short no_elements; /* number of elements in arrays of data */ + short pad2; /* not used by old */ + short field_size; /* size of the field being accessed */ + /* from database for values of waveforms */ + short special; /* special processing */ + short field_type; /* field type as seen by database request*/ + /*DBR_STRING,...,DBR_ENUM,DBR_NOACCESS*/ +}; +#endif diff --git a/src/db/db_field_log.h b/src/db/db_field_log.h new file mode 100644 index 000000000..877ef82de --- /dev/null +++ b/src/db/db_field_log.h @@ -0,0 +1,67 @@ +/* $Id$ + * Author: Jeffrey O. Hill + * Date: 4-1-89 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * NOTES: + * + * Modification Log: + * ----------------- + */ +#ifndef INCLdb_field_logh +#define INCLdb_field_logh + +/* + * Simple native types (anything which is not a string or an array for + * now) logged by db_post_events() for reliable interprocess communication. + * (for other types they get whatever happens to be there when the lower + * priority task pending on the event queue wakes up). Strings would slow down + * events for more reasonable size values. DB fields of native type string + * will most likely change infrequently. + * + */ +union native_value{ + short dbf_int; + short dbf_short; + float dbf_float; + short dbf_enum; + char dbf_char; + long dbf_long; + double dbf_double; +#ifdef DB_EVENT_LOG_STRINGS + char dbf_string[MAXSTRINGSIZE]; +#endif +}; + +/* + * structure to log the state of a data base field at the time + * an event is triggered. + */ +typedef struct{ + unsigned short stat; /* Alarm Status */ + unsigned short sevr; /* Alarm Severity */ + TS_STAMP time; /* time stamp */ + union native_value field; /* field value */ +}db_field_log; + +#endif /*INCLdb_field_logh*/ diff --git a/src/db/devLib.h b/src/db/devLib.h new file mode 100644 index 000000000..b3f92b4ce --- /dev/null +++ b/src/db/devLib.h @@ -0,0 +1,230 @@ +/* devLib.h */ +/* $Id$ */ + +/* + * Original Author: Marty Kraimer + * Author: Jeff Hill + * Date: 03-10-93 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 03-10-93 joh original + * .02 03-18-93 joh added fundamental address type mapping + * .03 03-23-93 joh changed input parameter to be a fund + * address type in favor of the argument + * that the BSP will be reconfigured + * to use an EPICS standard address + * mode + * .04 05-06-93 joh added new parameter to devDisconnectInterrupt(). + * See comment below. + * .05 05-28-93 joh Added an argument to devRegisterAddress() + * .06 05-28-93 joh Added devAddressMap() + * .07 06-14-93 joh Added devAllocAddress() + * + * Notes: + * ------ + * .01 03-23-93 joh We will only have problems with mod .03 + * above if the CPU maintains the different + * address modes in different address spaces + * and we have a card or a user that insists + * on not using the default address type + * .02 06-14-93 joh needs devAllocInterruptVector() routine + */ + + +#ifndef INCdevLibh +#define INCdevLibh 1 + +#if defined(devLibGlobal) && !defined(INCvmeh) +#include "vme.h" +#endif + +#include + +/* + * epdevAddressType & EPICStovxWorksAddrType + * devLib.c must change in unison + */ +typedef enum { + atVMEA16, + atVMEA24, + atVMEA32, + atLast /* atLast must be the last enum in this list */ + } epicsAddressType; + +#ifdef devLibGlobal +char *epicsAddressTypeName[] + = { + "VME A16", + "VME A24", + "VME A32" + }; +#endif + +/* + * we use a translation between an EPICS encoding + * and a vxWorks encoding here + * to reduce dependency of drivers on vxWorks + * + * we assume that the BSP are configured to use these + * address modes by default + */ +#ifdef devLibGlobal +int EPICStovxWorksAddrType[] + = { + VME_AM_SUP_SHORT_IO, + VME_AM_STD_SUP_DATA, + VME_AM_EXT_SUP_DATA + }; +#endif + +long devAddressMap(void); /* print an address map */ + +long devRegisterAddress( + const char *pOwnerName, + epicsAddressType addrType, + void *baseAddress, + unsigned long size, /* bytes */ + void **pLocalAddress); + +long devUnregisterAddress( + epicsAddressType addrType, + void *baseAddress, + const char *pOwnerName); + +/* + * allocate and register an unoccupied address block + */ +long devAllocAddress( + const char *pOwnerName, + epicsAddressType addrType, + unsigned long size, + unsigned alignment, /*n ls bits zero in addr*/ + void **pLocalAddress); + +/* + * some CPU`s will maintain these in independent spaces + */ +typedef enum {intCPU, intVME, intVXI} epicsInterruptType; +long devConnectInterrupt( + epicsInterruptType intType, + unsigned vectorNumber, + void (*pFunction)(), + void *parameter); + + +/* + * + * The parameter pFunction should be set to the C function pointer that + * was connected. It is used as a key to prevent a driver from accidentally + * removing an interrupt handler that it didn't install + */ +long devDisconnectInterrupt( + epicsInterruptType intType, + unsigned vectorNumber, + void (*pFunction)()); + +long devEnableInterruptLevel( + epicsInterruptType intType, + unsigned level); + +long devDisableInterruptLevel( + epicsInterruptType intType, + unsigned level); + + +/* + * Routines to allocate and free memory in the A24 memory region. + * + */ +void *devLibA24Malloc(size_t); +void *devLibA24Calloc(size_t); +void devLibA24Free(void *pBlock); + +/* + * Normalize a digital value and convert it to type TYPE + * + * Ex: + * float f; + * int d; + * f = devNormalizeDigital(d,12) + * + */ +#define devCreateMask(NBITS) ((1<<(NBITS))-1) +#define devDigToNml(DIGITAL,NBITS) \ + (((double)(DIGITAL))/devCreateMask(NBITS)) +#define devNmlToDig(NORMAL,NBITS) \ + (((long)(NORMAL)) * devCreateMask(NBITS)) + +/* + * + * Alignment mask + * (for use when testing to see if the proper number of least + * significant bits are zero) + * + */ +#define devCreateAlignmentMask(CTYPE)\ +(sizeof(CTYPE)>sizeof(double)?sizeof(double)-1:sizeof(CTYPE)-1) + +/* + * pointer aligned test + * (returns true if the pointer is on the worst case alignemnt + * boundary for its type) + */ +#define devPtrAlignTest(PTR) (!(devCreateAlignmentMask(*PTR)&(long)(PTR))) + +/* + * error codes (and messages) associated with devLib.c + */ +#define S_dev_vectorInUse (M_devLib| 1) /*Interrupt vector in use*/ +#define S_dev_vxWorksVecInstlFail (M_devLib| 2) /*vxWorks interrupt vector install failed*/ +#define S_dev_uknIntType (M_devLib| 3) /*Unrecognized interrupt type*/ +#define S_dev_vectorNotInUse (M_devLib| 4) /*Interrupt vector not in use by caller*/ +#define S_dev_badA16 (M_devLib| 5) /*Invalid VME A16 address*/ +#define S_dev_badA24 (M_devLib| 6) /*Invalid VME A24 address*/ +#define S_dev_badA32 (M_devLib| 7) /*Invalid VME A32 address*/ +#define S_dev_uknAddrType (M_devLib| 8) /*Unrecognized address space type*/ +#define S_dev_addressOverlap (M_devLib| 9) /*Specified device address overlaps another device*/ +#define S_dev_identifyOverlap (M_devLib| 10) /*This device already owns the address range*/ +#define S_dev_vxWorksAddrMapFail (M_devLib| 11) /*vxWorks refused address map*/ +#define S_dev_intDisconnect (M_devLib| 12) /*Interrupt at vector disconnected from an EPICS device*/ +#define S_dev_internal (M_devLib| 13) /*Internal failure*/ +#define S_dev_vxWorksIntEnFail (M_devLib| 14) /*vxWorks interrupt enable failure*/ +#define S_dev_vxWorksIntDissFail (M_devLib| 15) /*vxWorks interrupt disable failure*/ +#define S_dev_noMemory (M_devLib| 16) /*Memory allocation failed*/ +#define S_dev_addressNotFound (M_devLib| 17) /*Specified device address unregistered*/ +#define S_dev_noDevice (M_devLib| 18) /*No device at specified address*/ +#define S_dev_wrongDevice (M_devLib| 19) /*Wrong device type found at specified address*/ +#define S_dev_badSignalNumber (M_devLib| 20) /*Signal number (offset) to large*/ +#define S_dev_badSignalCount (M_devLib| 21) /*Signal count to large*/ +#define S_dev_badRequest (M_devLib| 22) /*Device does not support requested operation*/ +#define S_dev_highValue (M_devLib| 23) /*Parameter to high*/ +#define S_dev_lowValue (M_devLib| 24) /*Parameter to low*/ +#define S_dev_multDevice (M_devLib| 25) /*Specified address is ambiguous (more than one device responds)*/ +#define S_dev_badSelfTest (M_devLib| 26) /*Device self test failed*/ +#define S_dev_badInit (M_devLib| 27) /*Device failed during initialization*/ +#define S_dev_hdwLimit (M_devLib| 28) /*Input exceeds Hardware Limit*/ +#define S_dev_deviceDoesNotFit (M_devLib| 29) /*Unable to locate address space for device*/ +#define S_dev_deviceTMO (M_devLib| 30) /*device timed out*/ +#endif /* devLib.h*/ diff --git a/src/db/devSup.h b/src/db/devSup.h new file mode 100644 index 000000000..b68f96b87 --- /dev/null +++ b/src/db/devSup.h @@ -0,0 +1,66 @@ +/* devSup.h Device Support */ +/* share/epicsH $Id$ */ +/* + * Author: Marty Kraimer + * Date: 6-1-90 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 10-04-91 jba Added error message + * .02 05-18-92 rcz Changed macro "GET_DEVSUP(" to "GET_PDEVSUP(precDevSup," + * .03 05-18-92 rcz Structure devSup changed element name from dsetName to papDsetName + * .04 05-18-92 rcz New database access + */ + +#ifndef INCdevSuph +#define INCdevSuph 1 + +#ifdef __cplusplus +typedef long (*DEVSUPFUN)(void*); /* ptr to device support function*/ +#else +typedef long (*DEVSUPFUN)(); /* ptr to device support function*/ +#endif + +struct dset { /* device support entry table */ + long number; /*number of support routines*/ + DEVSUPFUN report; /*print report*/ + DEVSUPFUN init; /*init support*/ + DEVSUPFUN init_record; /*init support for particular record*/ + DEVSUPFUN get_ioint_info; /* get io interrupt information*/ + /*other functions are record dependent*/ + }; + +#define S_dev_noDevSup (M_devSup| 1) /*SDR_DEVSUP: Device support missing*/ +#define S_dev_noDSET (M_devSup| 3) /*Missing device support entry table*/ +#define S_dev_missingSup (M_devSup| 5) /*Missing device support routine*/ +#define S_dev_badInpType (M_devSup| 7) /*Bad INP link type*/ +#define S_dev_badOutType (M_devSup| 9) /*Bad OUT link type*/ +#define S_dev_badInitRet (M_devSup|11) /*Bad init_rec return value */ +#define S_dev_badBus (M_devSup|13) /*Illegal bus type*/ +#define S_dev_badCard (M_devSup|15) /*Illegal or nonexistant module*/ +#define S_dev_badSignal (M_devSup|17) /*Illegal signal*/ +#define S_dev_NoInit (M_devSup|19) /*No init*/ +#define S_dev_Conflict (M_devSup|21) /*Multiple records accessing same signal*/ + +#endif diff --git a/src/db/drvSup.h b/src/db/drvSup.h new file mode 100644 index 000000000..82e00869a --- /dev/null +++ b/src/db/drvSup.h @@ -0,0 +1,52 @@ +/* drvSup.h Driver Support */ +/* share/epicsH $Id$ */ + +/* + * Author: Marty Kraimer + * Date: 6-1-90 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 05-21-92 rcz changed drvetName to papDrvName + * .02 05-18-92 rcz New database access (removed extern) + */ + +#ifndef INCdrvSuph +#define INCdrvSuph 1 + +typedef long (*DRVSUPFUN) (); /* ptr to driver support function*/ + +struct drvet { /* driver entry table */ + long number; /*number of support routines*/ + DRVSUPFUN report; /*print report*/ + DRVSUPFUN init; /*init support*/ + DRVSUPFUN reboot; /*reboot support*/ + /*other functions are device dependent*/ + }; +#define DRVETNUMBER ( (sizeof(struct drvet) -sizeof(long))/sizeof(DRVSUPFUN) ) + +#define S_drv_noDrvSup (M_drvSup| 1) /*SDR_DRVSUP: Driver support missing*/ +#define S_drv_noDrvet (M_drvSup| 3) /*Missing driver support entry table*/ + +#endif diff --git a/src/db/drvTS.h b/src/db/drvTS.h new file mode 100644 index 000000000..4fc093c3c --- /dev/null +++ b/src/db/drvTS.h @@ -0,0 +1,266 @@ +#ifndef __DRVTS_h__ +#define __DRVTS_h__ + +/* + * $Log$ + * Revision 1.12 1995/08/30 15:39:07 jbk + * Added global variables for force accurate time stamps and direct time. + * + * Revision 1.11 1995/08/18 13:18:13 mrk + * Added function prototypes for ansi c + * + * Revision 1.10 1995/08/17 20:35:52 jbk + * fixed the debug macro to work with -pendantic option (yuck) + * + * Revision 1.9 1995/08/17 19:44:08 jbk + * Added a new utility function to get the first of the year time stamp. + * + * Revision 1.8 1995/08/16 19:04:20 jbk + * corrected vxworks time troubles + * + * Revision 1.7 1995/05/22 15:22:24 jbk + * changes TS_EXTERN thing + * + * Revision 1.6 1995/02/01 15:30:17 winans + * Added a type field to the configure command to disable the use of the event + * system hardware if desired. + * + * Revision 1.5 1994/10/31 20:36:17 jbk + * added new stuff + * + */ + +/************************************************************************** + * + * Author: Jim Kowalkowski + * + * Modification Log: + * ----------------- + * .01 01-06-94 jbk initial version + * + ***********************************************************************/ +/* +***************************************************************** + COPYRIGHT NOTIFICATION +***************************************************************** + +THE FOLLOWING IS A NOTICE OF COPYRIGHT, AVAILABILITY OF THE CODE, +AND DISCLAIMER WHICH MUST BE INCLUDED IN THE PROLOGUE OF THE CODE +AND IN ALL SOURCE LISTINGS OF THE CODE. + +(C) COPYRIGHT 1993 UNIVERSITY OF CHICAGO + +Argonne National Laboratory (ANL), with facilities in the States of +Illinois and Idaho, is owned by the United States Government, and +operated by the University of Chicago under provision of a contract +with the Department of Energy. + +Portions of this material resulted from work developed under a U.S. +Government contract and are subject to the following license: For +a period of five years from March 30, 1993, the Government is +granted for itself and others acting on its behalf a paid-up, +nonexclusive, irrevocable worldwide license in this computer +software to reproduce, prepare derivative works, and perform +publicly and display publicly. With the approval of DOE, this +period may be renewed for two additional five year periods. +Following the expiration of this period or periods, the Government +is granted for itself and others acting on its behalf, a paid-up, +nonexclusive, irrevocable worldwide license in this computer +software to reproduce, prepare derivative works, distribute copies +to the public, perform publicly and display publicly, and to permit +others to do so. + +***************************************************************** + DISCLAIMER +***************************************************************** + +NEITHER THE UNITED STATES GOVERNMENT NOR ANY AGENCY THEREOF, NOR +THE UNIVERSITY OF CHICAGO, NOR ANY OF THEIR EMPLOYEES OR OFFICERS, +MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL +LIABILITY OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR +USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT, OR PROCESS +DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE PRIVATELY +OWNED RIGHTS. + +***************************************************************** +LICENSING INQUIRIES MAY BE DIRECTED TO THE INDUSTRIAL TECHNOLOGY +DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000). +*/ + +#include +#include +#include +#include +#include + +#include + +#ifdef TS_DRIVER +#define TS_EXTERN +#else +#define TS_EXTERN extern +#endif + +#define ER_EVENT_RESET_TICK 0x7d /* Reset the tick counter */ + +#define TS_MAGIC ('T'<<24|'S'<<16|'d'<<8|'r') +#define TS_SLAVE_PORT 18322 +#define TS_MASTER_PORT 18323 +#define TS_RETRY_COUNT 4 +#define TS_TIME_OUT_MS 250 +#define TS_SECS_ASYNC_TRY_MASTER (60*5) /* every five minutes */ +#define TS_SECS_SYNC_TRY_MASTER (60*1) /* every one minute */ + +#define UDP_TIME_PORT 37 +#define UDP_NTP_PORT 123 + +#define TS_BILLION 1000000000 +#define TS_SYNC_RATE_SEC 10 +#define TS_CLOCK_RATE_HZ 1000 +#define TS_TOTAL_EVENTS 128 +#define TS_SEC_IN_DAY (24*60*60) +#define TS_SEC_IN_YEAR (TS_SEC_IN_DAY*365) +#define TS_LEAPS_SINCE_1900 23 +#define TS_1900_TO_EPICS_EPOCH ((TS_SEC_IN_YEAR*90)+(22*TS_SEC_IN_DAY)) +#define TS_1900_TO_VXWORKS_EPOCH ((TS_SEC_IN_YEAR*70)+(17*TS_SEC_IN_DAY)) +#define TS_VXWORKS_TO_EPICS_EPOCH ((TS_SEC_IN_YEAR*20)+(5*TS_SEC_IN_DAY)) + +#define TS_STAMP_SERVER_PRI 70 +#define TS_SYNC_SERVER_PRI 70 +#define TS_SYNC_CLIENT_PRI 70 +#define TS_ASYNC_CLIENT_PRI 70 + +typedef enum { TS_time_request, TS_sync_request, TS_sync_msg } TStype; +typedef enum { TS_master_alive, TS_master_dead } TSstate; +typedef enum { TS_async_none, TS_async_private, + TS_async_ntp, TS_async_time } TStime_protocol; +typedef enum { TS_sync_master, TS_async_master, + TS_sync_slave, TS_async_slave, + TS_direct_master, TS_direct_slave } TStime_type; + +struct TSstampTransStruct { + unsigned long magic; /* identifier */ + TStype type; /* transaction type */ + struct timespec master_time; /* master time stamp - last sync time */ + struct timespec current_time; /* master current time stamp 1990 epoch */ + struct timespec unix_time; /* time using 1900 epoch */ + unsigned long sync_rate; /* master sends sync at this rate */ + unsigned long clock_hz; /* master clock this frequency (tick rate) */ +}; +typedef struct TSstampTransStruct TSstampTrans; + +struct TSinfoStruct { + TSstate state; + TStime_type type; + TStime_protocol async_type; + int ts_sync_valid; + + struct timespec *event_table; /* timestamp table */ + + unsigned long sync_rate; /* master send sync at this rate */ + unsigned long clock_hz; /* master clock is this frequency */ + unsigned long clock_conv; /* conversion factor for tick_rate->ns */ + unsigned long time_out; /* udp packet time-out in milliseconds */ + int master_timing_IOC; /* 1=master, 0=slave */ + int master_port; /* port that master listens on */ + int slave_port; /* port that slave listens on */ + int total_events; /* this is the total event in the event system */ + int sync_event; /* this is the sync event number */ + int has_event_system; /* 1=has event system, 0=no event system */ + int has_direct_time; /* 1=has direct time, 0=no direct time */ + int UserRequestedType; /* let user force the setting of type */ + + SEM_ID sync_occurred; + + struct sockaddr hunt; /* broadcast address info */ + struct sockaddr master; /* socket info for contacting master */ +}; +typedef struct TSinfoStruct TSinfo; + +/* global functions */ +#ifdef __cplusplus +extern "C" { +#endif +TS_EXTERN long TSinit(void); +TS_EXTERN long TSgetTimeStamp(int event_number,struct timespec* sp); +TS_EXTERN long TScurrentTimeStamp(struct timespec* sp); +TS_EXTERN long TSaccurateTimeStamp(struct timespec* sp); +TS_EXTERN long TSgetFirstOfYearVx(struct timespec* sp); +TS_EXTERN void TSconfigure(int master, int sync_rate_sec, int clock_rate_hz, + int master_port, int slave_port, + unsigned long millisecond_request_time_out, int type); + +#ifndef TS_DRIVER +TS_EXTERN TSinfo TSdata; +TS_EXTERN TSdirectTimeVar; /* set to !=0 to indicate direct time available */ +TS_EXTERN TSgoodTimeStamps; /* force best time stamps by setting != 0 */ +#endif + +#ifdef __cplusplus +}; +#endif + +/* NTP information - all this is backwards and documentation only */ +#define VN_SHIFT 2 /* Version - 3 bits */ +#define VN_version 3< +#endif +#ifndef INCLvxLibh +#include +#endif + +/* + * Macro equivalent of vxWorks glue for better performance + */ +#ifdef VRTX_KERNEL +# define semGive(SEMID)\ + { if ((SEMID)->count == 0)vrtxPost (&((SEMID)->count), 1); } + +# define semTake(SEMID)\ + {int dummy; vrtxPend (&((SEMID)->count), 0, &dummy); } +#endif + +typedef struct{ + SEM_ID ppend; /* wait for lock sem */ + unsigned short count; /* cnt of tasks waiting for lock */ + unsigned char lock; /* test and set lock bit */ + char pad; /* structure alignment */ +}FAST_LOCK; + +#define SEM_FAST_LOCK + +#if defined(SEM_FAST_LOCK) /* no lock test */ + +#define FASTLOCKINIT(PFAST_LOCK)\ + (((FAST_LOCK *)(PFAST_LOCK))->ppend = \ + semBCreate(SEM_Q_PRIORITY, SEM_FULL)) +#define FASTLOCKFREE(PFAST_LOCK)\ + semDelete( ((FAST_LOCK *)(PFAST_LOCK))->ppend ) +#define FASTLOCK(PFAST_LOCK)\ + semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend, WAIT_FOREVER); +#define FASTUNLOCK(PFAST_LOCK)\ + semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend); +#define FASTLOCKNOWAIT(PFAST_LOCK) \ + ((semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend,NO_WAIT)==0) ? TRUE : FALSE) +#define FASTLOCKTEST(PFAST_LOCK) \ +(\ + (semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend,NO_WAIT)==0 )\ + ? (semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend),FALSE)\ + : TRUE \ +) + + +#elif defined(TASK_LOCK_FAST_LOCK) + +#define FASTLOCKINIT(PFAST_LOCK)\ + (\ + ((FAST_LOCK *)(PFAST_LOCK))->count =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->lock =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->ppend = \ + semBCreate(SEM_Q_PRIORITY, SEM_EMPTY) \ + ) +#define FASTLOCKFREE(PFAST_LOCK)\ + semDelete( ((FAST_LOCK *)(PFAST_LOCK))->ppend ) + +#define FASTLOCK(PFAST_LOCK)\ + {\ + TASK_LOCK;\ + while( ((FAST_LOCK *)(PFAST_LOCK))->lock ){\ + ((FAST_LOCK *)(PFAST_LOCK))->count++;\ + TASK_UNLOCK;\ + semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend, WAIT_FOREVER);\ + TASK_LOCK;\ + (((FAST_LOCK *)(PFAST_LOCK))->count)--;\ + }\ + ((FAST_LOCK *)(PFAST_LOCK))->lock= TRUE; + TASK_UNLOCK; + } + +#define FASTUNLOCK(PFAST_LOCK)\ + {\ + ((FAST_LOCK *)(PFAST_LOCK))->lock = FALSE;\ + if( ((FAST_LOCK *)(PFAST_LOCK))->count )\ + semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend);\ + }; + +#define FASTLOCKTEST(PFAST_LOCK)\ +( ((FAST_LOCK *)(PFAST_LOCK))->lock ) + +#else /* vxTas() fast lock */ + +/* + * extra paren avoids order of ops problems + * (returns what semBCreate returns on v5 vxWorks) + */ +#define FASTLOCKINIT(PFAST_LOCK)\ + (\ + ((FAST_LOCK *)(PFAST_LOCK))->count =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->lock =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->ppend = \ + semBCreate(SEM_Q_PRIORITY, SEM_EMPTY) \ + ) + +/* + * new requirement with v5 vxWorks + */ +#define FASTLOCKFREE(PFAST_LOCK)\ + semDelete( ((FAST_LOCK *)(PFAST_LOCK))->ppend ) + +#define FASTLOCK(PFAST_LOCK)\ + {\ + ((FAST_LOCK *)(PFAST_LOCK))->count++;\ + while(!vxTas( (char *)&( ((FAST_LOCK *)(PFAST_LOCK))->lock ) ))\ + semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend, WAIT_FOREVER);\ + ( ((FAST_LOCK *)(PFAST_LOCK))->count)--;\ + } + +#define FASTUNLOCK(PFAST_LOCK)\ + {\ + ((FAST_LOCK *)(PFAST_LOCK))->lock = FALSE;\ + if( ((FAST_LOCK *)(PFAST_LOCK))->count )\ + semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend);\ + }; + +#define FASTLOCKNOWAIT(PFAST_LOCK) (vxTas((char *)&(((FAST_LOCK *)(PFAST_LOCK))->lock))) + +#define FASTLOCKTEST(PFAST_LOCK)\ +( ((FAST_LOCK *)(PFAST_LOCK))->lock ) + +#endif + +#endif /* Nothing after this endif */ diff --git a/src/db/initHooks.h b/src/db/initHooks.h new file mode 100644 index 000000000..825d7476d --- /dev/null +++ b/src/db/initHooks.h @@ -0,0 +1,55 @@ +/* share/src/db $Id$ */ +/* + * Author: Marty Kraimer + * Date: 06-01-91 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 09-05-92 rcz initial version + * .02 09-10-92 rcz changed completely + * + */ + + +#ifndef INCinitHooksh +#define INCinitHooksh 1 + +#define INITHOOKatBeginning 0 +#define INITHOOKafterGetResources 1 +#define INITHOOKafterLogInit 2 +#define INITHOOKafterCallbackInit 3 +#define INITHOOKafterCaLinkInit1 4 +#define INITHOOKafterInitDrvSup 5 +#define INITHOOKafterInitRecSup 6 +#define INITHOOKafterInitDevSup 7 +#define INITHOOKafterTS_init 8 +#define INITHOOKafterInitDatabase 9 +#define INITHOOKafterCaLinkInit2 10 +#define INITHOOKafterFinishDevSup 11 +#define INITHOOKafterScanInit 12 +#define INITHOOKafterInterruptAccept 13 +#define INITHOOKafterInitialProcess 14 +#define INITHOOKatEnd 15 + +#endif /*INCinitHooksh*/ diff --git a/src/db/iocInit.c b/src/db/iocInit.c index 007d6582e..446a0971f 100644 --- a/src/db/iocInit.c +++ b/src/db/iocInit.c @@ -142,7 +142,7 @@ int iocInit(char * pResourceFilename) } if (!pdbbase) { - logMsg("iocInit aborting because No database loaded by dbAsciiRead\n", + logMsg("iocInit aborting because No database loaded by dbReadDatabase\n", 0,0,0,0,0,0); return(-1); } @@ -1096,11 +1096,7 @@ LOCAL int getResourceTokenInternal(FILE *fp, char *pToken, unsigned maxToken) return 0; } -int dbLoadAscii(char *filename) +int dbLoadDatabase(char *filename,char *path) { - if(pdbbase) { - epicsPrintf("Ascii file was already loaded\n"); - return(-1); - } - return(dbAsciiRead(&pdbbase,filename)); + return(dbReadDatabase(&pdbbase,filename,path)); } diff --git a/src/db/menuAlarmSevr.ascii b/src/db/menuAlarmSevr.db similarity index 100% rename from src/db/menuAlarmSevr.ascii rename to src/db/menuAlarmSevr.db diff --git a/src/db/menuAlarmStat.ascii b/src/db/menuAlarmStat.db similarity index 100% rename from src/db/menuAlarmStat.ascii rename to src/db/menuAlarmStat.db diff --git a/src/db/menuArrType.ascii b/src/db/menuArrType.db similarity index 100% rename from src/db/menuArrType.ascii rename to src/db/menuArrType.db diff --git a/src/db/menuCompress.ascii b/src/db/menuCompress.db similarity index 100% rename from src/db/menuCompress.ascii rename to src/db/menuCompress.db diff --git a/src/db/menuFtype.ascii b/src/db/menuFtype.db similarity index 100% rename from src/db/menuFtype.ascii rename to src/db/menuFtype.db diff --git a/src/db/menuGlobal.ascii b/src/db/menuGlobal.ascii deleted file mode 100644 index 083349b11..000000000 --- a/src/db/menuGlobal.ascii +++ /dev/null @@ -1,11 +0,0 @@ -include "menuAlarmSevr.ascii" -include "menuAlarmStat.ascii" -include "menuArrType.ascii" -include "menuCompress.ascii" -include "menuFtype.ascii" -include "menuIvoa.ascii" -include "menuLinr.ascii" -include "menuOmsl.ascii" -include "menuPriority.ascii" -include "menuScan.ascii" -include "menuYesNo.ascii" diff --git a/src/db/menuGlobal.db b/src/db/menuGlobal.db new file mode 100644 index 000000000..1327df7a2 --- /dev/null +++ b/src/db/menuGlobal.db @@ -0,0 +1,11 @@ +include "menuAlarmSevr.db" +include "menuAlarmStat.db" +include "menuArrType.db" +include "menuCompress.db" +include "menuFtype.db" +include "menuIvoa.db" +include "menuLinr.db" +include "menuOmsl.db" +include "menuPriority.db" +include "menuScan.db" +include "menuYesNo.db" diff --git a/src/db/menuIvoa.ascii b/src/db/menuIvoa.db similarity index 100% rename from src/db/menuIvoa.ascii rename to src/db/menuIvoa.db diff --git a/src/db/menuLinr.ascii b/src/db/menuLinr.db similarity index 100% rename from src/db/menuLinr.ascii rename to src/db/menuLinr.db diff --git a/src/db/menuOmsl.ascii b/src/db/menuOmsl.db similarity index 100% rename from src/db/menuOmsl.ascii rename to src/db/menuOmsl.db diff --git a/src/db/menuPriority.ascii b/src/db/menuPriority.db similarity index 100% rename from src/db/menuPriority.ascii rename to src/db/menuPriority.db diff --git a/src/db/menuScan.ascii b/src/db/menuScan.db similarity index 100% rename from src/db/menuScan.ascii rename to src/db/menuScan.db diff --git a/src/db/menuYesNo.ascii b/src/db/menuYesNo.db similarity index 100% rename from src/db/menuYesNo.ascii rename to src/db/menuYesNo.db diff --git a/src/db/recGbl.c b/src/db/recGbl.c index 71ce53cff..b8d53915a 100644 --- a/src/db/recGbl.c +++ b/src/db/recGbl.c @@ -383,6 +383,14 @@ static void getMaxRangeValues(field_type,pupper_limit,plower_limit) double *plower_limit; { switch(field_type){ + case(DBF_CHAR): + *pupper_limit = -128.0; + *plower_limit = 127.0; + break; + case(DBF_UCHAR): + *pupper_limit = 255.0; + *plower_limit = 0.0; + break; case(DBF_SHORT): *pupper_limit = (double)SHRT_MAX; *plower_limit = (double)SHRT_MIN; diff --git a/src/db/recGbl.h b/src/db/recGbl.h new file mode 100644 index 000000000..c7a7cfbe5 --- /dev/null +++ b/src/db/recGbl.h @@ -0,0 +1,107 @@ +/* recGbl.h */ +/* Record Global + * Author: Marty Kraimer + * Date: 13Jun95 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 12Jun95 mrk Removed from recSup.h + */ +#ifndef INCrecGblh +#define INCrecGblh 1 + + +#ifdef vxWorks +#ifndef INCdbCommonh +#include +#endif +#endif + +/* + * One ABSOLUTELY must include dbAccess.h before the + * definitions in this file + */ + +#ifndef INCdbAccessh +#include +#endif +#ifndef INCalarmh +#include +#endif +#include + +/************************************************************************* + * The following must match definitions in global menu definitions + *************************************************************************/ + +/* GBL_IVOA */ +#define IVOA_CONTINUE 0 +#define IVOA_NO_OUTPUT 1 +#define IVOA_OUTPUT_IVOV 2 + +/*************************************************************************/ + +#define recGblGetFastLink(PLNK,PREC,PVAL) \ +\ + ((((PLNK)->type == CONSTANT) ||\ + (! (((PLNK)->type == DB_LINK) || ((PLNK)->type == CA_LINK)) ))\ + ? 0\ + : dbFastLinkGet((PLNK),(struct dbCommon *)(PREC),(PVAL))) + + +#define recGblPutFastLink(PLNK,PREC,PVAL) \ +\ + ((((PLNK)->type == CONSTANT) ||\ + (! (((PLNK)->type == DB_LINK) || ((PLNK)->type == CA_LINK)) ))\ + ? 0\ + : dbFastLinkPut((PLNK),(struct dbCommon *)(PREC),(PVAL))) + + +#define recGblSetSevr(PREC,NSTA,NSEV) \ +(\ + ((PREC)->nsev<(NSEV))\ + ? ((PREC)->nsta=(NSTA),(PREC)->nsev=(NSEV),TRUE)\ + : FALSE\ +) + + +/* Global Record Support Routines*/ +void recGblDbaddrError(long status, struct dbAddr *paddr, char *pcaller_name); +void recGblRecordError(long status, void *precord, char *pcaller_name); +void recGblRecSupError(long status, struct dbAddr *paddr, char *pcaller_name, char *psupport_name); +void recGblGetGraphicDouble(struct dbAddr *paddr, struct dbr_grDouble *pgd); +void recGblGetControlDouble(struct dbAddr *paddr, struct dbr_ctrlDouble *pcd); +void recGblGetAlarmDouble(struct dbAddr *paddr, struct dbr_alDouble *pad); +void recGblGetPrec(struct dbAddr *paddr, long *pprecision); +int recGblInitConstantLink(struct link *plink,short dbftype,void *pdest); +long recGblGetLinkValue(struct link *plink,void *precord, + short dbrType,void *pdest,long *poptions,long *pnRequest); +long recGblPutLinkValue(struct link *plink,void *precord, + short dbrType,void *pdest,long *pnRequest); +unsigned short recGblResetAlarms(void *precord); +void recGblFwdLink(void *precord); +void recGblGetTimeStamp(void *precord); +long recGblInitFastInLink(struct link *plink, void *precord, short dbrType, char *fld_name); +long recGblInitFastOutLink(struct link *plink, void *precord, short dbrType, char *fld_name); +#endif /*INCrecGblh*/ diff --git a/src/db/recSup.h b/src/db/recSup.h new file mode 100644 index 000000000..23c16d7dc --- /dev/null +++ b/src/db/recSup.h @@ -0,0 +1,106 @@ +/* recSup.h + * Record Support + * Author: Marty Kraimer + * Date: 6-1-90 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 11-11-91 jba Added include dbCommon.h,recGblSetSevr,recGblResetSevr + * .02 12-18-91 jba Changed caddr_t to void * + * .03 03-04-92 jba Added include for dbAccess.h + * .04 05-18-92 rcz removed extern + * .05 05-18-92 rcz Changed macro "GET_PRSET(" to "GET_PRSET(precSup," + * .06 05-18-92 rcz New database access (removed extern) + * .07 07-16-92 jba Added macro recGblFwdLink + * .08 07-16-92 jba changed VALID_ALARM to INVALID_ALARM + * .09 08-10-92 jba added #defines for SIMM processing + * .10 08-11-92 jba added DB_INTEREST masks + * .11 08-13-92 jba added prototype for recGblGetAlarmDouble, + * .12 08-14-92 jba added prototypes recGblGetLinkValue,recGblPutLinkValue + * .13 09-15-92 jba added vxWorks ifdef + * .14 -7-27-93 mrk remove recGblResetSevr add recGblResetAlarms + * .15 03-18-94 mcn added fast link macros and prototypes + * .16 06-13-95 mrk moved recGbl defs to recGbl.h + */ + +#ifndef INCrecSuph +#define INCrecSuph 1 +#include +typedef long (*RECSUPFUN) (); /* ptr to record support function*/ + +struct rset { /* record support entry table */ + long number; /*number of support routines */ + RECSUPFUN report; /*print report */ + RECSUPFUN init; /*init support */ + RECSUPFUN init_record; /*init record */ + RECSUPFUN process; /*process record */ + RECSUPFUN special; /*special processing */ + RECSUPFUN get_value; /*get value field */ + RECSUPFUN cvt_dbaddr; /*cvt dbAddr */ + RECSUPFUN get_array_info; + RECSUPFUN put_array_info; + RECSUPFUN get_units; + RECSUPFUN get_precision; + RECSUPFUN get_enum_str; /*get string from enum item*/ + RECSUPFUN get_enum_strs; /*get all enum strings */ + RECSUPFUN put_enum_str; /*put string from enum item*/ + RECSUPFUN get_graphic_double; + RECSUPFUN get_control_double; + RECSUPFUN get_alarm_double; + }; +#define RSETNUMBER ( (sizeof(struct rset) - sizeof(long))/sizeof(RECSUPFUN) ) + +#define S_rec_noRSET (M_recSup| 1) /*Missing record support entry table*/ +#define S_rec_noSizeOffset (M_recSup| 2) /*Missing SizeOffset Routine*/ +#define S_rec_outMem (M_recSup| 3) /*Out of Memory*/ + + +/* Definition os structure for routine get_value */ + +struct valueDes { + long field_type; + long no_elements; + void * pvalue; +}; + +/************************************************************************ + * report(FILE fp,void *precord); + * init(); + * init_record(precord,pass); + * process(void *precord); + * special(struct dbAddr *paddr, after); + * get_value(precord,struct valueDes *p); + * cvt_dbaddr(struct dbAddr *paddr); + * get_array_info(paddr,long *no_elements,long *offset); + * put_array_info(paddr,nNew); + * get_units(paddr,char units[8]); + * get_precision(struct dbAddr *paddr,long *precision); + * get_enum_str(paddr,pbuffer); + * get_enum_strs(paddr,struct dbr_enumStrs *p); + * put_enum_str(paddr,pbuffer); + * get_graphic_double(paddr,struct dbr_grDouble *p); + * get_control_double(paddr,struct dbr_ctrlDouble *p); + * get_alarm_double(paddr,struct dbr_ctrlDouble *p); + ***********************************************************************/ +#endif /*INCrecSuph*/ diff --git a/src/db/task_params.h b/src/db/task_params.h new file mode 100644 index 000000000..89f876e75 --- /dev/null +++ b/src/db/task_params.h @@ -0,0 +1,229 @@ +/* task_params.h */ +/* $Id$ */ + +/* Parameters for tasks on IOC */ +/* + * Authors: Andy Kozubal, Jeff Hill, and Bob Dalesio + * Date: 2-24-89 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 07-23-91 ges Add time-stamp task. + * .02 09-12-91 joh stack sizes increased for v5 vxWorks. + * .03 10-24-91 lrd Increased stack sizes for scan tasks + * .04 12-12-91 joh Increased stack size for the + * wfDoneTask + * .05 12-18-91 mrk Added callback task priorities + * Changed def of PERIODSCAN_PRI and SEQUENCER_PRI + * Shortened length of task names + * .06 12-18-91 jba Global change of WDSCAN to TASKWD + * .07 01-21-92 rcz Increased all stack sizes by 1000 for V5 + * .08 01-21-92 jrw added the GPIB & BB driver task info + * .09 01-04-92 jba Added callback task priorities + * .10 03-16-92 jrw added BB rx and tx specific task info + * .11 05-22-92 lrd added the allen-bradley binary input Change of State scanner + * .12 08-26-92 joh added xy 240 stuff + * .13 08-26-92 joh added FP to CA repeater and on line to be safe + * .14 02-16-92 joh removed historical items + * .15 11-19-93 joh moved CA client priority up by one notch + * .16 09-13-93 joh incresed CA on line beacon maximum delay + * to 60 sec + * .17 03-18-94 mcn added entries for breakpoint tasks + * $Log$ + * Revision 1.27 1995/11/29 19:27:59 jhill + * added $Log$ + * + */ + +#ifndef INCtaskLibh +#include +#endif + +#define VXTASKIDSELF 0 + +/* Task Names */ +#define IOEVENTSCAN_NAME "scanIo" +#define EVENTSCAN_NAME "scanEvent" +#define CALLBACK_NAME "callback" +#define SCANONCE_NAME "scanOnce" +#define SMCMD_NAME "smCommand" +#define SMRESP_NAME "smResponse" +#define ABDONE_NAME "abDone" +#define ABSCAN_NAME "abScan" +#define ABCOS_NAME "abBiCosScanner" +#define PERIODSCAN_NAME "scanPeriod" +#define MOMENTARY_NAME "momentary" +#define WFDONE_NAME "wfDone" +#define SEQUENCER_NAME "sequencer" +#define BKPT_CONT_NAME "bkptCont" +#define SCANNER_NAME "scanner" +#define REQ_SRVR_NAME "CA TCP" +#define CA_CLIENT_NAME "CA client" +#define CA_EVENT_NAME "CA event" +#define CAST_SRVR_NAME "CA UDP" +#define CA_REPEATER_NAME "CA repeater" +#define CA_ONLINE_NAME "CA online" +#define TASKWD_NAME "taskwd" +#define SMIOTEST_NAME "smInout" +#define SMROTTEST_NAME "smRotate" +#define EVENT_PEND_NAME "event task" +#define TIMESTAMP_NAME "timeStamp" +#define XY240_NAME "xy 240 scan" +#define GPIBLINK_NAME "gpibLink" +#define BBLINK_NAME "bbLinkTask" +#define BBTXLINK_NAME "bbTx" +#define BBRXLINK_NAME "bbRx" +#define BBWDTASK_NAME "bbwd" +#define DB_CA_INPUT_NAME "dbCaInput" +#define DB_CA_OUTPUT_NAME "dbCaOutput" +#define DB_CA_PROC_ASYNCH_EV_TASK_NAME "process_asynch_events_task" +#define EPICSPRINT_NAME "epicsPrint" +#define LOG_RESTART_NAME "logRestart" + +/* Task priorities */ +#define EPICSPRINT_PRI 70 +#define SCANONCE_PRI 65 /* scan one time */ +/*DO NOT RUN ANY RECORD PROCESSING TASKS AT HIGHER PRIORITY THAN _netTask=50*/ +#define CALLBACK_PRI_LOW 65 /* callback task - generall callback task */ +#define CALLBACK_PRI_MEDIUM 57 /* callback task - generall callback task */ +#define CALLBACK_PRI_HIGH 51 /* callback task - generall callback task */ +#define IOEVENTSCAN_PRI 51 /* I/O Event Scanner - Runs on I/O interrupt */ +#define EVENTSCAN_PRI 52 /* Event Scanner - Runs on a global event */ +#define TIMESTAMP_PRI 32 /* Time-stamp task - interrupt */ +#define SMCMD_PRI 42 /* Stepper Motor Command Task - Waits for cmds */ +#define SMRESP_PRI 43 /* Stepper Motor Resp Task - Waits for resps */ +#define ABCOS_PRI 43 /* Allen-Bradley Binary Input COS io_event wakeup */ +#define ABDONE_PRI 44 /* Allen-Bradley Resp Task - Interrupt Driven */ +#define ABSCAN_PRI 45 /* Allen-Bradley Scan Task - Base Rate .1 secs */ +#define BBLINK_PRI 46 +#define BBWDTASK_PRI 45 /* BitBus watchdog task */ +#define BBRXLINK_PRI 46 /* BitBus link task */ +#define BBTXLINK_PRI 47 /* BitBus link task */ +#define GPIBLINK_PRI 47 /* GPIB link task */ +#define MOMENTARY_PRI 48 /* Momentary output - posted from watchdog */ +#define WFDONE_PRI 49 /* Waveform Task - Base Rate of .1 second */ +#define PERIODSCAN_PRI 59 /* Periodic Scanners - Slowest rate */ +#define SEQUENCER_PRI 70 +#define XY240_PRI 111 /* xy 240 dio scanner */ +#define DB_CA_INPUT_PRI 100 +#define DB_CA_OUTPUT_PRI 100 +#define DB_CA_PROC_ASYNCH_EV_TASK_PRI 100 +#define SCANNER_PRI 150 +#define REQ_SRVR_PRI 181 /* Channel Access TCP request server*/ +#define CA_CLIENT_PRI 180 /* Channel Access clients */ +#define CA_REPEATER_PRI 181 /* Channel Access repeater */ +#define CAST_SRVR_PRI 182 /* Channel Access broadcast server */ +#define CA_ONLINE_PRI 183 /* Channel Access server online notify */ +#define TASKWD_PRI 200 /* Watchdog Scan Task - runs every 6 seconds */ +#define SMIOTEST_PRI 205 /* Stepper Mtr in/out test - runs every .1 sec */ +#define SMROTTEST_PRI 205 /* Stepper Mtr rotate test - runs every .1 sec */ +#define LOG_RESTART_PRI 200 /* Log server connection watch dog */ + +/* Task delay times (seconds) */ +#define TASKWD_DELAY 6 + +/* Task delay times (tics) */ +#define ABSCAN_RATE (sysClkRateGet()/6) +#define SEQUENCER_DELAY (sysClkRateGet()/5) +#define SCANNER_DELAY (sysClkRateGet()/5) +#define CA_ONLINE_DELAY (sysClkRateGet()*15) +#define LOG_RESTART_DELAY (sysClkRateGet()*30) + +/* Task creation options */ +#define EPICSPRINT_OPT VX_FP_TASK +#define IOEVENTSCAN_OPT VX_FP_TASK +#define EVENTSCAN_OPT VX_FP_TASK +#define SCANONCE_OPT VX_FP_TASK +#define CALLBACK_OPT VX_FP_TASK +#define SMCMD_OPT VX_FP_TASK +#define SMRESP_OPT VX_FP_TASK +#define ABDONE_OPT VX_FP_TASK +#define ABCOS_OPT VX_FP_TASK +#define ABSCAN_OPT VX_FP_TASK +#define MOMENTARY_OPT VX_FP_TASK +#define PERIODSCAN_OPT VX_FP_TASK +#define WFDONE_OPT VX_FP_TASK +#define SEQUENCER_OPT VX_FP_TASK | VX_STDIO +#define BKPT_CONT_OPT VX_FP_TASK +#define SCANNER_OPT VX_FP_TASK +#define REQ_SRVR_OPT VX_FP_TASK +#define CAST_SRVR_OPT VX_FP_TASK +#define CA_CLIENT_OPT VX_FP_TASK +#define CA_REPEATER_OPT VX_FP_TASK +#define CA_ONLINE_OPT VX_FP_TASK +#define TASKWD_OPT VX_FP_TASK +#define SMIOTEST_OPT VX_FP_TASK +#define SMROTTEST_OPT VX_FP_TASK +#define EVENT_PEND_OPT VX_FP_TASK +#define TIMESTAMP_OPT VX_FP_TASK +#define GPIBLINK_OPT VX_FP_TASK|VX_STDIO +#define BBLINK_OPT VX_FP_TASK|VX_STDIO +#define BBTXLINK_OPT VX_FP_TASK|VX_STDIO +#define BBRXLINK_OPT VX_FP_TASK|VX_STDIO +#define BBWDTASK_OPT VX_FP_TASK|VX_STDIO +#define DB_CA_INPUT_OPT (VX_FP_TASK | VX_STDIO) +#define DB_CA_OUTPUT_OPT (VX_FP_TASK | VX_STDIO) +#define DB_CA_PROC_ASYNCH_EV_TASK_OPT (VX_FP_TASK | VX_STDIO) +#define XY_240_OPT (0) /* none */ +#define LOG_RESTART_OPT (VX_FP_TASK) + + +/* Task stack sizes */ +#define EPICSPRINT_STACK 4000 +#define EVENTSCAN_STACK 10000 +#define SCANONCE_STACK 10000 +#define CALLBACK_STACK 10000 +#define SMCMD_STACK 3000 +#define SMRESP_STACK 3000 +#define ABCOS_STACK 3000 +#define ABDONE_STACK 3000 +#define ABSCAN_STACK 3000 +#define MOMENTARY_STACK 2000 +#define PERIODSCAN_STACK 10000 +#define WFDONE_STACK 9000 +#define SEQUENCER_STACK 5096 +#define BKPT_CONT_STACK 10000 +#define SCANNER_STACK 3048 +#define RSP_SRVR_STACK 5096 +#define REQ_SRVR_STACK 5096 +#define CAST_SRVR_STACK 5096 +#define CA_CLIENT_STACK 5096 +#define CA_REPEATER_STACK 5096 +#define CA_ONLINE_STACK 3048 +#define TASKWD_STACK 2000 /* moved up by 1000 for v5 vxWorks */ +#define SMIOTEST_STACK 2000 +#define SMROTTEST_STACK 2000 +#define EVENT_PEND_STACK 5096 +#define TIMESTAMP_STACK 4000 +#define GPIBLINK_STACK 5000 +#define BBLINK_STACK 5000 +#define BBRXLINK_STACK 5000 +#define BBTXLINK_STACK 5000 +#define BBWDTASK_STACK 5000 +#define DB_CA_INPUT_STACK 20000 +#define DB_CA_OUTPUT_STACK 20000 +#define DB_CA_PROC_ASYNCH_EV_TASK_STACK 20000 +#define XY_240_STACK 4096 +#define LOG_RESTART_STACK 0x1000 + diff --git a/src/db/taskwd.h b/src/db/taskwd.h new file mode 100644 index 000000000..1f77f302f --- /dev/null +++ b/src/db/taskwd.h @@ -0,0 +1,50 @@ +/* taskwd.h */ +/* share/epicsH/taskwd.h $Id$ */ + +/* includes for general purpose taskwd tasks */ +/* + * Original Author: Marty Kraimer + * Date: 07-18-91 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 12-12-91 mrk Initial version +*/ + +#ifndef INCtaskwdh +#define INCtaskwdh 1 + +#ifdef __STDC__ +void taskwdInit(); +void taskwdInsert(int tid, VOIDFUNCPTR callback,void *arg); +void taskwdAnyInsert(void *userpvt, VOIDFUNCPTR callback,void *arg); +void taskwdRemove(int tid); +void taskwdAnyRemove(void *userpvt); +#else +void taskwdInit(); +void taskwdInsert(); +void taskwdAnyInsert(); +void taskwdAnyRemove(); +#endif /*__STDC__*/ +#endif /*INCtaskwdh*/ diff --git a/src/include/devSup.h b/src/include/devSup.h new file mode 100644 index 000000000..b68f96b87 --- /dev/null +++ b/src/include/devSup.h @@ -0,0 +1,66 @@ +/* devSup.h Device Support */ +/* share/epicsH $Id$ */ +/* + * Author: Marty Kraimer + * Date: 6-1-90 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 10-04-91 jba Added error message + * .02 05-18-92 rcz Changed macro "GET_DEVSUP(" to "GET_PDEVSUP(precDevSup," + * .03 05-18-92 rcz Structure devSup changed element name from dsetName to papDsetName + * .04 05-18-92 rcz New database access + */ + +#ifndef INCdevSuph +#define INCdevSuph 1 + +#ifdef __cplusplus +typedef long (*DEVSUPFUN)(void*); /* ptr to device support function*/ +#else +typedef long (*DEVSUPFUN)(); /* ptr to device support function*/ +#endif + +struct dset { /* device support entry table */ + long number; /*number of support routines*/ + DEVSUPFUN report; /*print report*/ + DEVSUPFUN init; /*init support*/ + DEVSUPFUN init_record; /*init support for particular record*/ + DEVSUPFUN get_ioint_info; /* get io interrupt information*/ + /*other functions are record dependent*/ + }; + +#define S_dev_noDevSup (M_devSup| 1) /*SDR_DEVSUP: Device support missing*/ +#define S_dev_noDSET (M_devSup| 3) /*Missing device support entry table*/ +#define S_dev_missingSup (M_devSup| 5) /*Missing device support routine*/ +#define S_dev_badInpType (M_devSup| 7) /*Bad INP link type*/ +#define S_dev_badOutType (M_devSup| 9) /*Bad OUT link type*/ +#define S_dev_badInitRet (M_devSup|11) /*Bad init_rec return value */ +#define S_dev_badBus (M_devSup|13) /*Illegal bus type*/ +#define S_dev_badCard (M_devSup|15) /*Illegal or nonexistant module*/ +#define S_dev_badSignal (M_devSup|17) /*Illegal signal*/ +#define S_dev_NoInit (M_devSup|19) /*No init*/ +#define S_dev_Conflict (M_devSup|21) /*Multiple records accessing same signal*/ + +#endif diff --git a/src/include/drvSup.h b/src/include/drvSup.h new file mode 100644 index 000000000..82e00869a --- /dev/null +++ b/src/include/drvSup.h @@ -0,0 +1,52 @@ +/* drvSup.h Driver Support */ +/* share/epicsH $Id$ */ + +/* + * Author: Marty Kraimer + * Date: 6-1-90 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 05-21-92 rcz changed drvetName to papDrvName + * .02 05-18-92 rcz New database access (removed extern) + */ + +#ifndef INCdrvSuph +#define INCdrvSuph 1 + +typedef long (*DRVSUPFUN) (); /* ptr to driver support function*/ + +struct drvet { /* driver entry table */ + long number; /*number of support routines*/ + DRVSUPFUN report; /*print report*/ + DRVSUPFUN init; /*init support*/ + DRVSUPFUN reboot; /*reboot support*/ + /*other functions are device dependent*/ + }; +#define DRVETNUMBER ( (sizeof(struct drvet) -sizeof(long))/sizeof(DRVSUPFUN) ) + +#define S_drv_noDrvSup (M_drvSup| 1) /*SDR_DRVSUP: Driver support missing*/ +#define S_drv_noDrvet (M_drvSup| 3) /*Missing driver support entry table*/ + +#endif diff --git a/src/include/drvTS.h b/src/include/drvTS.h new file mode 100644 index 000000000..4fc093c3c --- /dev/null +++ b/src/include/drvTS.h @@ -0,0 +1,266 @@ +#ifndef __DRVTS_h__ +#define __DRVTS_h__ + +/* + * $Log$ + * Revision 1.12 1995/08/30 15:39:07 jbk + * Added global variables for force accurate time stamps and direct time. + * + * Revision 1.11 1995/08/18 13:18:13 mrk + * Added function prototypes for ansi c + * + * Revision 1.10 1995/08/17 20:35:52 jbk + * fixed the debug macro to work with -pendantic option (yuck) + * + * Revision 1.9 1995/08/17 19:44:08 jbk + * Added a new utility function to get the first of the year time stamp. + * + * Revision 1.8 1995/08/16 19:04:20 jbk + * corrected vxworks time troubles + * + * Revision 1.7 1995/05/22 15:22:24 jbk + * changes TS_EXTERN thing + * + * Revision 1.6 1995/02/01 15:30:17 winans + * Added a type field to the configure command to disable the use of the event + * system hardware if desired. + * + * Revision 1.5 1994/10/31 20:36:17 jbk + * added new stuff + * + */ + +/************************************************************************** + * + * Author: Jim Kowalkowski + * + * Modification Log: + * ----------------- + * .01 01-06-94 jbk initial version + * + ***********************************************************************/ +/* +***************************************************************** + COPYRIGHT NOTIFICATION +***************************************************************** + +THE FOLLOWING IS A NOTICE OF COPYRIGHT, AVAILABILITY OF THE CODE, +AND DISCLAIMER WHICH MUST BE INCLUDED IN THE PROLOGUE OF THE CODE +AND IN ALL SOURCE LISTINGS OF THE CODE. + +(C) COPYRIGHT 1993 UNIVERSITY OF CHICAGO + +Argonne National Laboratory (ANL), with facilities in the States of +Illinois and Idaho, is owned by the United States Government, and +operated by the University of Chicago under provision of a contract +with the Department of Energy. + +Portions of this material resulted from work developed under a U.S. +Government contract and are subject to the following license: For +a period of five years from March 30, 1993, the Government is +granted for itself and others acting on its behalf a paid-up, +nonexclusive, irrevocable worldwide license in this computer +software to reproduce, prepare derivative works, and perform +publicly and display publicly. With the approval of DOE, this +period may be renewed for two additional five year periods. +Following the expiration of this period or periods, the Government +is granted for itself and others acting on its behalf, a paid-up, +nonexclusive, irrevocable worldwide license in this computer +software to reproduce, prepare derivative works, distribute copies +to the public, perform publicly and display publicly, and to permit +others to do so. + +***************************************************************** + DISCLAIMER +***************************************************************** + +NEITHER THE UNITED STATES GOVERNMENT NOR ANY AGENCY THEREOF, NOR +THE UNIVERSITY OF CHICAGO, NOR ANY OF THEIR EMPLOYEES OR OFFICERS, +MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL +LIABILITY OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR +USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT, OR PROCESS +DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE PRIVATELY +OWNED RIGHTS. + +***************************************************************** +LICENSING INQUIRIES MAY BE DIRECTED TO THE INDUSTRIAL TECHNOLOGY +DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000). +*/ + +#include +#include +#include +#include +#include + +#include + +#ifdef TS_DRIVER +#define TS_EXTERN +#else +#define TS_EXTERN extern +#endif + +#define ER_EVENT_RESET_TICK 0x7d /* Reset the tick counter */ + +#define TS_MAGIC ('T'<<24|'S'<<16|'d'<<8|'r') +#define TS_SLAVE_PORT 18322 +#define TS_MASTER_PORT 18323 +#define TS_RETRY_COUNT 4 +#define TS_TIME_OUT_MS 250 +#define TS_SECS_ASYNC_TRY_MASTER (60*5) /* every five minutes */ +#define TS_SECS_SYNC_TRY_MASTER (60*1) /* every one minute */ + +#define UDP_TIME_PORT 37 +#define UDP_NTP_PORT 123 + +#define TS_BILLION 1000000000 +#define TS_SYNC_RATE_SEC 10 +#define TS_CLOCK_RATE_HZ 1000 +#define TS_TOTAL_EVENTS 128 +#define TS_SEC_IN_DAY (24*60*60) +#define TS_SEC_IN_YEAR (TS_SEC_IN_DAY*365) +#define TS_LEAPS_SINCE_1900 23 +#define TS_1900_TO_EPICS_EPOCH ((TS_SEC_IN_YEAR*90)+(22*TS_SEC_IN_DAY)) +#define TS_1900_TO_VXWORKS_EPOCH ((TS_SEC_IN_YEAR*70)+(17*TS_SEC_IN_DAY)) +#define TS_VXWORKS_TO_EPICS_EPOCH ((TS_SEC_IN_YEAR*20)+(5*TS_SEC_IN_DAY)) + +#define TS_STAMP_SERVER_PRI 70 +#define TS_SYNC_SERVER_PRI 70 +#define TS_SYNC_CLIENT_PRI 70 +#define TS_ASYNC_CLIENT_PRI 70 + +typedef enum { TS_time_request, TS_sync_request, TS_sync_msg } TStype; +typedef enum { TS_master_alive, TS_master_dead } TSstate; +typedef enum { TS_async_none, TS_async_private, + TS_async_ntp, TS_async_time } TStime_protocol; +typedef enum { TS_sync_master, TS_async_master, + TS_sync_slave, TS_async_slave, + TS_direct_master, TS_direct_slave } TStime_type; + +struct TSstampTransStruct { + unsigned long magic; /* identifier */ + TStype type; /* transaction type */ + struct timespec master_time; /* master time stamp - last sync time */ + struct timespec current_time; /* master current time stamp 1990 epoch */ + struct timespec unix_time; /* time using 1900 epoch */ + unsigned long sync_rate; /* master sends sync at this rate */ + unsigned long clock_hz; /* master clock this frequency (tick rate) */ +}; +typedef struct TSstampTransStruct TSstampTrans; + +struct TSinfoStruct { + TSstate state; + TStime_type type; + TStime_protocol async_type; + int ts_sync_valid; + + struct timespec *event_table; /* timestamp table */ + + unsigned long sync_rate; /* master send sync at this rate */ + unsigned long clock_hz; /* master clock is this frequency */ + unsigned long clock_conv; /* conversion factor for tick_rate->ns */ + unsigned long time_out; /* udp packet time-out in milliseconds */ + int master_timing_IOC; /* 1=master, 0=slave */ + int master_port; /* port that master listens on */ + int slave_port; /* port that slave listens on */ + int total_events; /* this is the total event in the event system */ + int sync_event; /* this is the sync event number */ + int has_event_system; /* 1=has event system, 0=no event system */ + int has_direct_time; /* 1=has direct time, 0=no direct time */ + int UserRequestedType; /* let user force the setting of type */ + + SEM_ID sync_occurred; + + struct sockaddr hunt; /* broadcast address info */ + struct sockaddr master; /* socket info for contacting master */ +}; +typedef struct TSinfoStruct TSinfo; + +/* global functions */ +#ifdef __cplusplus +extern "C" { +#endif +TS_EXTERN long TSinit(void); +TS_EXTERN long TSgetTimeStamp(int event_number,struct timespec* sp); +TS_EXTERN long TScurrentTimeStamp(struct timespec* sp); +TS_EXTERN long TSaccurateTimeStamp(struct timespec* sp); +TS_EXTERN long TSgetFirstOfYearVx(struct timespec* sp); +TS_EXTERN void TSconfigure(int master, int sync_rate_sec, int clock_rate_hz, + int master_port, int slave_port, + unsigned long millisecond_request_time_out, int type); + +#ifndef TS_DRIVER +TS_EXTERN TSinfo TSdata; +TS_EXTERN TSdirectTimeVar; /* set to !=0 to indicate direct time available */ +TS_EXTERN TSgoodTimeStamps; /* force best time stamps by setting != 0 */ +#endif + +#ifdef __cplusplus +}; +#endif + +/* NTP information - all this is backwards and documentation only */ +#define VN_SHIFT 2 /* Version - 3 bits */ +#define VN_version 3< +#endif +#ifndef INCLvxLibh +#include +#endif + +/* + * Macro equivalent of vxWorks glue for better performance + */ +#ifdef VRTX_KERNEL +# define semGive(SEMID)\ + { if ((SEMID)->count == 0)vrtxPost (&((SEMID)->count), 1); } + +# define semTake(SEMID)\ + {int dummy; vrtxPend (&((SEMID)->count), 0, &dummy); } +#endif + +typedef struct{ + SEM_ID ppend; /* wait for lock sem */ + unsigned short count; /* cnt of tasks waiting for lock */ + unsigned char lock; /* test and set lock bit */ + char pad; /* structure alignment */ +}FAST_LOCK; + +#define SEM_FAST_LOCK + +#if defined(SEM_FAST_LOCK) /* no lock test */ + +#define FASTLOCKINIT(PFAST_LOCK)\ + (((FAST_LOCK *)(PFAST_LOCK))->ppend = \ + semBCreate(SEM_Q_PRIORITY, SEM_FULL)) +#define FASTLOCKFREE(PFAST_LOCK)\ + semDelete( ((FAST_LOCK *)(PFAST_LOCK))->ppend ) +#define FASTLOCK(PFAST_LOCK)\ + semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend, WAIT_FOREVER); +#define FASTUNLOCK(PFAST_LOCK)\ + semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend); +#define FASTLOCKNOWAIT(PFAST_LOCK) \ + ((semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend,NO_WAIT)==0) ? TRUE : FALSE) +#define FASTLOCKTEST(PFAST_LOCK) \ +(\ + (semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend,NO_WAIT)==0 )\ + ? (semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend),FALSE)\ + : TRUE \ +) + + +#elif defined(TASK_LOCK_FAST_LOCK) + +#define FASTLOCKINIT(PFAST_LOCK)\ + (\ + ((FAST_LOCK *)(PFAST_LOCK))->count =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->lock =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->ppend = \ + semBCreate(SEM_Q_PRIORITY, SEM_EMPTY) \ + ) +#define FASTLOCKFREE(PFAST_LOCK)\ + semDelete( ((FAST_LOCK *)(PFAST_LOCK))->ppend ) + +#define FASTLOCK(PFAST_LOCK)\ + {\ + TASK_LOCK;\ + while( ((FAST_LOCK *)(PFAST_LOCK))->lock ){\ + ((FAST_LOCK *)(PFAST_LOCK))->count++;\ + TASK_UNLOCK;\ + semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend, WAIT_FOREVER);\ + TASK_LOCK;\ + (((FAST_LOCK *)(PFAST_LOCK))->count)--;\ + }\ + ((FAST_LOCK *)(PFAST_LOCK))->lock= TRUE; + TASK_UNLOCK; + } + +#define FASTUNLOCK(PFAST_LOCK)\ + {\ + ((FAST_LOCK *)(PFAST_LOCK))->lock = FALSE;\ + if( ((FAST_LOCK *)(PFAST_LOCK))->count )\ + semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend);\ + }; + +#define FASTLOCKTEST(PFAST_LOCK)\ +( ((FAST_LOCK *)(PFAST_LOCK))->lock ) + +#else /* vxTas() fast lock */ + +/* + * extra paren avoids order of ops problems + * (returns what semBCreate returns on v5 vxWorks) + */ +#define FASTLOCKINIT(PFAST_LOCK)\ + (\ + ((FAST_LOCK *)(PFAST_LOCK))->count =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->lock =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->ppend = \ + semBCreate(SEM_Q_PRIORITY, SEM_EMPTY) \ + ) + +/* + * new requirement with v5 vxWorks + */ +#define FASTLOCKFREE(PFAST_LOCK)\ + semDelete( ((FAST_LOCK *)(PFAST_LOCK))->ppend ) + +#define FASTLOCK(PFAST_LOCK)\ + {\ + ((FAST_LOCK *)(PFAST_LOCK))->count++;\ + while(!vxTas( (char *)&( ((FAST_LOCK *)(PFAST_LOCK))->lock ) ))\ + semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend, WAIT_FOREVER);\ + ( ((FAST_LOCK *)(PFAST_LOCK))->count)--;\ + } + +#define FASTUNLOCK(PFAST_LOCK)\ + {\ + ((FAST_LOCK *)(PFAST_LOCK))->lock = FALSE;\ + if( ((FAST_LOCK *)(PFAST_LOCK))->count )\ + semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend);\ + }; + +#define FASTLOCKNOWAIT(PFAST_LOCK) (vxTas((char *)&(((FAST_LOCK *)(PFAST_LOCK))->lock))) + +#define FASTLOCKTEST(PFAST_LOCK)\ +( ((FAST_LOCK *)(PFAST_LOCK))->lock ) + +#endif + +#endif /* Nothing after this endif */ diff --git a/src/vxWorks/db/devLib.h b/src/vxWorks/db/devLib.h new file mode 100644 index 000000000..b3f92b4ce --- /dev/null +++ b/src/vxWorks/db/devLib.h @@ -0,0 +1,230 @@ +/* devLib.h */ +/* $Id$ */ + +/* + * Original Author: Marty Kraimer + * Author: Jeff Hill + * Date: 03-10-93 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 03-10-93 joh original + * .02 03-18-93 joh added fundamental address type mapping + * .03 03-23-93 joh changed input parameter to be a fund + * address type in favor of the argument + * that the BSP will be reconfigured + * to use an EPICS standard address + * mode + * .04 05-06-93 joh added new parameter to devDisconnectInterrupt(). + * See comment below. + * .05 05-28-93 joh Added an argument to devRegisterAddress() + * .06 05-28-93 joh Added devAddressMap() + * .07 06-14-93 joh Added devAllocAddress() + * + * Notes: + * ------ + * .01 03-23-93 joh We will only have problems with mod .03 + * above if the CPU maintains the different + * address modes in different address spaces + * and we have a card or a user that insists + * on not using the default address type + * .02 06-14-93 joh needs devAllocInterruptVector() routine + */ + + +#ifndef INCdevLibh +#define INCdevLibh 1 + +#if defined(devLibGlobal) && !defined(INCvmeh) +#include "vme.h" +#endif + +#include + +/* + * epdevAddressType & EPICStovxWorksAddrType + * devLib.c must change in unison + */ +typedef enum { + atVMEA16, + atVMEA24, + atVMEA32, + atLast /* atLast must be the last enum in this list */ + } epicsAddressType; + +#ifdef devLibGlobal +char *epicsAddressTypeName[] + = { + "VME A16", + "VME A24", + "VME A32" + }; +#endif + +/* + * we use a translation between an EPICS encoding + * and a vxWorks encoding here + * to reduce dependency of drivers on vxWorks + * + * we assume that the BSP are configured to use these + * address modes by default + */ +#ifdef devLibGlobal +int EPICStovxWorksAddrType[] + = { + VME_AM_SUP_SHORT_IO, + VME_AM_STD_SUP_DATA, + VME_AM_EXT_SUP_DATA + }; +#endif + +long devAddressMap(void); /* print an address map */ + +long devRegisterAddress( + const char *pOwnerName, + epicsAddressType addrType, + void *baseAddress, + unsigned long size, /* bytes */ + void **pLocalAddress); + +long devUnregisterAddress( + epicsAddressType addrType, + void *baseAddress, + const char *pOwnerName); + +/* + * allocate and register an unoccupied address block + */ +long devAllocAddress( + const char *pOwnerName, + epicsAddressType addrType, + unsigned long size, + unsigned alignment, /*n ls bits zero in addr*/ + void **pLocalAddress); + +/* + * some CPU`s will maintain these in independent spaces + */ +typedef enum {intCPU, intVME, intVXI} epicsInterruptType; +long devConnectInterrupt( + epicsInterruptType intType, + unsigned vectorNumber, + void (*pFunction)(), + void *parameter); + + +/* + * + * The parameter pFunction should be set to the C function pointer that + * was connected. It is used as a key to prevent a driver from accidentally + * removing an interrupt handler that it didn't install + */ +long devDisconnectInterrupt( + epicsInterruptType intType, + unsigned vectorNumber, + void (*pFunction)()); + +long devEnableInterruptLevel( + epicsInterruptType intType, + unsigned level); + +long devDisableInterruptLevel( + epicsInterruptType intType, + unsigned level); + + +/* + * Routines to allocate and free memory in the A24 memory region. + * + */ +void *devLibA24Malloc(size_t); +void *devLibA24Calloc(size_t); +void devLibA24Free(void *pBlock); + +/* + * Normalize a digital value and convert it to type TYPE + * + * Ex: + * float f; + * int d; + * f = devNormalizeDigital(d,12) + * + */ +#define devCreateMask(NBITS) ((1<<(NBITS))-1) +#define devDigToNml(DIGITAL,NBITS) \ + (((double)(DIGITAL))/devCreateMask(NBITS)) +#define devNmlToDig(NORMAL,NBITS) \ + (((long)(NORMAL)) * devCreateMask(NBITS)) + +/* + * + * Alignment mask + * (for use when testing to see if the proper number of least + * significant bits are zero) + * + */ +#define devCreateAlignmentMask(CTYPE)\ +(sizeof(CTYPE)>sizeof(double)?sizeof(double)-1:sizeof(CTYPE)-1) + +/* + * pointer aligned test + * (returns true if the pointer is on the worst case alignemnt + * boundary for its type) + */ +#define devPtrAlignTest(PTR) (!(devCreateAlignmentMask(*PTR)&(long)(PTR))) + +/* + * error codes (and messages) associated with devLib.c + */ +#define S_dev_vectorInUse (M_devLib| 1) /*Interrupt vector in use*/ +#define S_dev_vxWorksVecInstlFail (M_devLib| 2) /*vxWorks interrupt vector install failed*/ +#define S_dev_uknIntType (M_devLib| 3) /*Unrecognized interrupt type*/ +#define S_dev_vectorNotInUse (M_devLib| 4) /*Interrupt vector not in use by caller*/ +#define S_dev_badA16 (M_devLib| 5) /*Invalid VME A16 address*/ +#define S_dev_badA24 (M_devLib| 6) /*Invalid VME A24 address*/ +#define S_dev_badA32 (M_devLib| 7) /*Invalid VME A32 address*/ +#define S_dev_uknAddrType (M_devLib| 8) /*Unrecognized address space type*/ +#define S_dev_addressOverlap (M_devLib| 9) /*Specified device address overlaps another device*/ +#define S_dev_identifyOverlap (M_devLib| 10) /*This device already owns the address range*/ +#define S_dev_vxWorksAddrMapFail (M_devLib| 11) /*vxWorks refused address map*/ +#define S_dev_intDisconnect (M_devLib| 12) /*Interrupt at vector disconnected from an EPICS device*/ +#define S_dev_internal (M_devLib| 13) /*Internal failure*/ +#define S_dev_vxWorksIntEnFail (M_devLib| 14) /*vxWorks interrupt enable failure*/ +#define S_dev_vxWorksIntDissFail (M_devLib| 15) /*vxWorks interrupt disable failure*/ +#define S_dev_noMemory (M_devLib| 16) /*Memory allocation failed*/ +#define S_dev_addressNotFound (M_devLib| 17) /*Specified device address unregistered*/ +#define S_dev_noDevice (M_devLib| 18) /*No device at specified address*/ +#define S_dev_wrongDevice (M_devLib| 19) /*Wrong device type found at specified address*/ +#define S_dev_badSignalNumber (M_devLib| 20) /*Signal number (offset) to large*/ +#define S_dev_badSignalCount (M_devLib| 21) /*Signal count to large*/ +#define S_dev_badRequest (M_devLib| 22) /*Device does not support requested operation*/ +#define S_dev_highValue (M_devLib| 23) /*Parameter to high*/ +#define S_dev_lowValue (M_devLib| 24) /*Parameter to low*/ +#define S_dev_multDevice (M_devLib| 25) /*Specified address is ambiguous (more than one device responds)*/ +#define S_dev_badSelfTest (M_devLib| 26) /*Device self test failed*/ +#define S_dev_badInit (M_devLib| 27) /*Device failed during initialization*/ +#define S_dev_hdwLimit (M_devLib| 28) /*Input exceeds Hardware Limit*/ +#define S_dev_deviceDoesNotFit (M_devLib| 29) /*Unable to locate address space for device*/ +#define S_dev_deviceTMO (M_devLib| 30) /*device timed out*/ +#endif /* devLib.h*/ diff --git a/src/vxWorks/db/drvTS.h b/src/vxWorks/db/drvTS.h new file mode 100644 index 000000000..4fc093c3c --- /dev/null +++ b/src/vxWorks/db/drvTS.h @@ -0,0 +1,266 @@ +#ifndef __DRVTS_h__ +#define __DRVTS_h__ + +/* + * $Log$ + * Revision 1.12 1995/08/30 15:39:07 jbk + * Added global variables for force accurate time stamps and direct time. + * + * Revision 1.11 1995/08/18 13:18:13 mrk + * Added function prototypes for ansi c + * + * Revision 1.10 1995/08/17 20:35:52 jbk + * fixed the debug macro to work with -pendantic option (yuck) + * + * Revision 1.9 1995/08/17 19:44:08 jbk + * Added a new utility function to get the first of the year time stamp. + * + * Revision 1.8 1995/08/16 19:04:20 jbk + * corrected vxworks time troubles + * + * Revision 1.7 1995/05/22 15:22:24 jbk + * changes TS_EXTERN thing + * + * Revision 1.6 1995/02/01 15:30:17 winans + * Added a type field to the configure command to disable the use of the event + * system hardware if desired. + * + * Revision 1.5 1994/10/31 20:36:17 jbk + * added new stuff + * + */ + +/************************************************************************** + * + * Author: Jim Kowalkowski + * + * Modification Log: + * ----------------- + * .01 01-06-94 jbk initial version + * + ***********************************************************************/ +/* +***************************************************************** + COPYRIGHT NOTIFICATION +***************************************************************** + +THE FOLLOWING IS A NOTICE OF COPYRIGHT, AVAILABILITY OF THE CODE, +AND DISCLAIMER WHICH MUST BE INCLUDED IN THE PROLOGUE OF THE CODE +AND IN ALL SOURCE LISTINGS OF THE CODE. + +(C) COPYRIGHT 1993 UNIVERSITY OF CHICAGO + +Argonne National Laboratory (ANL), with facilities in the States of +Illinois and Idaho, is owned by the United States Government, and +operated by the University of Chicago under provision of a contract +with the Department of Energy. + +Portions of this material resulted from work developed under a U.S. +Government contract and are subject to the following license: For +a period of five years from March 30, 1993, the Government is +granted for itself and others acting on its behalf a paid-up, +nonexclusive, irrevocable worldwide license in this computer +software to reproduce, prepare derivative works, and perform +publicly and display publicly. With the approval of DOE, this +period may be renewed for two additional five year periods. +Following the expiration of this period or periods, the Government +is granted for itself and others acting on its behalf, a paid-up, +nonexclusive, irrevocable worldwide license in this computer +software to reproduce, prepare derivative works, distribute copies +to the public, perform publicly and display publicly, and to permit +others to do so. + +***************************************************************** + DISCLAIMER +***************************************************************** + +NEITHER THE UNITED STATES GOVERNMENT NOR ANY AGENCY THEREOF, NOR +THE UNIVERSITY OF CHICAGO, NOR ANY OF THEIR EMPLOYEES OR OFFICERS, +MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL +LIABILITY OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR +USEFULNESS OF ANY INFORMATION, APPARATUS, PRODUCT, OR PROCESS +DISCLOSED, OR REPRESENTS THAT ITS USE WOULD NOT INFRINGE PRIVATELY +OWNED RIGHTS. + +***************************************************************** +LICENSING INQUIRIES MAY BE DIRECTED TO THE INDUSTRIAL TECHNOLOGY +DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000). +*/ + +#include +#include +#include +#include +#include + +#include + +#ifdef TS_DRIVER +#define TS_EXTERN +#else +#define TS_EXTERN extern +#endif + +#define ER_EVENT_RESET_TICK 0x7d /* Reset the tick counter */ + +#define TS_MAGIC ('T'<<24|'S'<<16|'d'<<8|'r') +#define TS_SLAVE_PORT 18322 +#define TS_MASTER_PORT 18323 +#define TS_RETRY_COUNT 4 +#define TS_TIME_OUT_MS 250 +#define TS_SECS_ASYNC_TRY_MASTER (60*5) /* every five minutes */ +#define TS_SECS_SYNC_TRY_MASTER (60*1) /* every one minute */ + +#define UDP_TIME_PORT 37 +#define UDP_NTP_PORT 123 + +#define TS_BILLION 1000000000 +#define TS_SYNC_RATE_SEC 10 +#define TS_CLOCK_RATE_HZ 1000 +#define TS_TOTAL_EVENTS 128 +#define TS_SEC_IN_DAY (24*60*60) +#define TS_SEC_IN_YEAR (TS_SEC_IN_DAY*365) +#define TS_LEAPS_SINCE_1900 23 +#define TS_1900_TO_EPICS_EPOCH ((TS_SEC_IN_YEAR*90)+(22*TS_SEC_IN_DAY)) +#define TS_1900_TO_VXWORKS_EPOCH ((TS_SEC_IN_YEAR*70)+(17*TS_SEC_IN_DAY)) +#define TS_VXWORKS_TO_EPICS_EPOCH ((TS_SEC_IN_YEAR*20)+(5*TS_SEC_IN_DAY)) + +#define TS_STAMP_SERVER_PRI 70 +#define TS_SYNC_SERVER_PRI 70 +#define TS_SYNC_CLIENT_PRI 70 +#define TS_ASYNC_CLIENT_PRI 70 + +typedef enum { TS_time_request, TS_sync_request, TS_sync_msg } TStype; +typedef enum { TS_master_alive, TS_master_dead } TSstate; +typedef enum { TS_async_none, TS_async_private, + TS_async_ntp, TS_async_time } TStime_protocol; +typedef enum { TS_sync_master, TS_async_master, + TS_sync_slave, TS_async_slave, + TS_direct_master, TS_direct_slave } TStime_type; + +struct TSstampTransStruct { + unsigned long magic; /* identifier */ + TStype type; /* transaction type */ + struct timespec master_time; /* master time stamp - last sync time */ + struct timespec current_time; /* master current time stamp 1990 epoch */ + struct timespec unix_time; /* time using 1900 epoch */ + unsigned long sync_rate; /* master sends sync at this rate */ + unsigned long clock_hz; /* master clock this frequency (tick rate) */ +}; +typedef struct TSstampTransStruct TSstampTrans; + +struct TSinfoStruct { + TSstate state; + TStime_type type; + TStime_protocol async_type; + int ts_sync_valid; + + struct timespec *event_table; /* timestamp table */ + + unsigned long sync_rate; /* master send sync at this rate */ + unsigned long clock_hz; /* master clock is this frequency */ + unsigned long clock_conv; /* conversion factor for tick_rate->ns */ + unsigned long time_out; /* udp packet time-out in milliseconds */ + int master_timing_IOC; /* 1=master, 0=slave */ + int master_port; /* port that master listens on */ + int slave_port; /* port that slave listens on */ + int total_events; /* this is the total event in the event system */ + int sync_event; /* this is the sync event number */ + int has_event_system; /* 1=has event system, 0=no event system */ + int has_direct_time; /* 1=has direct time, 0=no direct time */ + int UserRequestedType; /* let user force the setting of type */ + + SEM_ID sync_occurred; + + struct sockaddr hunt; /* broadcast address info */ + struct sockaddr master; /* socket info for contacting master */ +}; +typedef struct TSinfoStruct TSinfo; + +/* global functions */ +#ifdef __cplusplus +extern "C" { +#endif +TS_EXTERN long TSinit(void); +TS_EXTERN long TSgetTimeStamp(int event_number,struct timespec* sp); +TS_EXTERN long TScurrentTimeStamp(struct timespec* sp); +TS_EXTERN long TSaccurateTimeStamp(struct timespec* sp); +TS_EXTERN long TSgetFirstOfYearVx(struct timespec* sp); +TS_EXTERN void TSconfigure(int master, int sync_rate_sec, int clock_rate_hz, + int master_port, int slave_port, + unsigned long millisecond_request_time_out, int type); + +#ifndef TS_DRIVER +TS_EXTERN TSinfo TSdata; +TS_EXTERN TSdirectTimeVar; /* set to !=0 to indicate direct time available */ +TS_EXTERN TSgoodTimeStamps; /* force best time stamps by setting != 0 */ +#endif + +#ifdef __cplusplus +}; +#endif + +/* NTP information - all this is backwards and documentation only */ +#define VN_SHIFT 2 /* Version - 3 bits */ +#define VN_version 3< +#endif +#ifndef INCLvxLibh +#include +#endif + +/* + * Macro equivalent of vxWorks glue for better performance + */ +#ifdef VRTX_KERNEL +# define semGive(SEMID)\ + { if ((SEMID)->count == 0)vrtxPost (&((SEMID)->count), 1); } + +# define semTake(SEMID)\ + {int dummy; vrtxPend (&((SEMID)->count), 0, &dummy); } +#endif + +typedef struct{ + SEM_ID ppend; /* wait for lock sem */ + unsigned short count; /* cnt of tasks waiting for lock */ + unsigned char lock; /* test and set lock bit */ + char pad; /* structure alignment */ +}FAST_LOCK; + +#define SEM_FAST_LOCK + +#if defined(SEM_FAST_LOCK) /* no lock test */ + +#define FASTLOCKINIT(PFAST_LOCK)\ + (((FAST_LOCK *)(PFAST_LOCK))->ppend = \ + semBCreate(SEM_Q_PRIORITY, SEM_FULL)) +#define FASTLOCKFREE(PFAST_LOCK)\ + semDelete( ((FAST_LOCK *)(PFAST_LOCK))->ppend ) +#define FASTLOCK(PFAST_LOCK)\ + semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend, WAIT_FOREVER); +#define FASTUNLOCK(PFAST_LOCK)\ + semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend); +#define FASTLOCKNOWAIT(PFAST_LOCK) \ + ((semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend,NO_WAIT)==0) ? TRUE : FALSE) +#define FASTLOCKTEST(PFAST_LOCK) \ +(\ + (semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend,NO_WAIT)==0 )\ + ? (semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend),FALSE)\ + : TRUE \ +) + + +#elif defined(TASK_LOCK_FAST_LOCK) + +#define FASTLOCKINIT(PFAST_LOCK)\ + (\ + ((FAST_LOCK *)(PFAST_LOCK))->count =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->lock =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->ppend = \ + semBCreate(SEM_Q_PRIORITY, SEM_EMPTY) \ + ) +#define FASTLOCKFREE(PFAST_LOCK)\ + semDelete( ((FAST_LOCK *)(PFAST_LOCK))->ppend ) + +#define FASTLOCK(PFAST_LOCK)\ + {\ + TASK_LOCK;\ + while( ((FAST_LOCK *)(PFAST_LOCK))->lock ){\ + ((FAST_LOCK *)(PFAST_LOCK))->count++;\ + TASK_UNLOCK;\ + semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend, WAIT_FOREVER);\ + TASK_LOCK;\ + (((FAST_LOCK *)(PFAST_LOCK))->count)--;\ + }\ + ((FAST_LOCK *)(PFAST_LOCK))->lock= TRUE; + TASK_UNLOCK; + } + +#define FASTUNLOCK(PFAST_LOCK)\ + {\ + ((FAST_LOCK *)(PFAST_LOCK))->lock = FALSE;\ + if( ((FAST_LOCK *)(PFAST_LOCK))->count )\ + semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend);\ + }; + +#define FASTLOCKTEST(PFAST_LOCK)\ +( ((FAST_LOCK *)(PFAST_LOCK))->lock ) + +#else /* vxTas() fast lock */ + +/* + * extra paren avoids order of ops problems + * (returns what semBCreate returns on v5 vxWorks) + */ +#define FASTLOCKINIT(PFAST_LOCK)\ + (\ + ((FAST_LOCK *)(PFAST_LOCK))->count =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->lock =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->ppend = \ + semBCreate(SEM_Q_PRIORITY, SEM_EMPTY) \ + ) + +/* + * new requirement with v5 vxWorks + */ +#define FASTLOCKFREE(PFAST_LOCK)\ + semDelete( ((FAST_LOCK *)(PFAST_LOCK))->ppend ) + +#define FASTLOCK(PFAST_LOCK)\ + {\ + ((FAST_LOCK *)(PFAST_LOCK))->count++;\ + while(!vxTas( (char *)&( ((FAST_LOCK *)(PFAST_LOCK))->lock ) ))\ + semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend, WAIT_FOREVER);\ + ( ((FAST_LOCK *)(PFAST_LOCK))->count)--;\ + } + +#define FASTUNLOCK(PFAST_LOCK)\ + {\ + ((FAST_LOCK *)(PFAST_LOCK))->lock = FALSE;\ + if( ((FAST_LOCK *)(PFAST_LOCK))->count )\ + semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend);\ + }; + +#define FASTLOCKNOWAIT(PFAST_LOCK) (vxTas((char *)&(((FAST_LOCK *)(PFAST_LOCK))->lock))) + +#define FASTLOCKTEST(PFAST_LOCK)\ +( ((FAST_LOCK *)(PFAST_LOCK))->lock ) + +#endif + +#endif /* Nothing after this endif */