From a8da2b9da41640a285808eb7231df93e704fed27 Mon Sep 17 00:00:00 2001 From: Marty Kraimer Date: Thu, 25 Jan 1996 21:24:40 +0000 Subject: [PATCH] moved include files from base/include --- src/dev/Makefile.Vx | 5 + src/dev/devApsEg.c | 87 +++-- src/dev/devApsEr.h | 74 +++++ src/dev/devCamac.h | 48 +++ src/dev/devCommonGpib.h | 348 ++++++++++++++++++++ src/dev/devMz8310.c | 17 +- src/dev/devTimerMz8310.c | 3 - src/drv/ansi/Makefile.Vx | 3 + src/drv/ansi/drvEpvxi.h | 477 +++++++++++++++++++++++++++ src/drv/ansi/epvxi.h | 532 +++++++++++++++++++++++++++++++ src/drv/old/Makefile.Vx | 10 + src/drv/old/drvBB232.h | 69 ++++ src/drv/old/drvBitBusErr.h | 43 +++ src/drv/old/drvBitBusInterface.h | 273 ++++++++++++++++ src/drv/old/drvGpibErr.h | 44 +++ src/drv/old/drvGpibInterface.h | 176 ++++++++++ src/drv/old/drvHiDEOSGpib.h | 12 + src/drv/old/drvMsg.h | 485 ++++++++++++++++++++++++++++ src/drv/old/drvRs232.h | 51 +++ src/drv/old/drvTy232.h | 77 +++++ src/libCom/Makefile.Unix | 15 + src/libCom/blderrSymTbl | 14 +- src/libCom/bucketLib.h | 133 ++++++++ src/libCom/bucketLib/bucketLib.h | 133 ++++++++ src/libCom/cvtFast.h | 107 +++++++ src/libCom/cvtFast/cvtFast.h | 107 +++++++ src/libCom/ellLib.h | 139 ++++++++ src/libCom/ellLib/ellLib.h | 139 ++++++++ src/libCom/env/envDefs.h | 104 ++++++ src/libCom/envDefs.h | 104 ++++++ src/libCom/epicsAssert.h | 80 +++++ src/libCom/epicsPrint.h | 19 ++ src/libCom/errMdef.h | 125 ++++++++ src/libCom/errPrintfUNIX.c | 10 +- src/libCom/error.h | 74 +++++ src/libCom/error/epicsPrint.h | 19 ++ src/libCom/error/errMdef.h | 125 ++++++++ src/libCom/error/error.h | 74 +++++ src/libCom/fdmgr.h | 272 ++++++++++++++++ src/libCom/fdmgr/fdmgr.h | 272 ++++++++++++++++ src/libCom/freeList.h | 63 ++++ src/libCom/freeList/freeList.h | 63 ++++ src/libCom/gpHash.h | 78 +++++ src/libCom/gpHash/gpHash.h | 78 +++++ src/libCom/memDebugLib.h | 73 +++++ src/libCom/osi/epicsAssert.h | 80 +++++ src/libCom/pal.h | 82 +++++ src/libCom/tsDefs.h | 320 +++++++++++++++++++ src/sequencer/Makefile.Unix | 5 + src/sequencer/seq.h | 198 ++++++++++++ src/sequencer/seqCom.h | 150 +++++++++ src/sequencer/seqU.h | 13 + src/sequencer/seq_taskLib.h | 93 ++++++ 53 files changed, 6127 insertions(+), 68 deletions(-) create mode 100644 src/dev/devApsEr.h create mode 100644 src/dev/devCamac.h create mode 100644 src/dev/devCommonGpib.h create mode 100644 src/drv/ansi/drvEpvxi.h create mode 100644 src/drv/ansi/epvxi.h create mode 100644 src/drv/old/drvBB232.h create mode 100644 src/drv/old/drvBitBusErr.h create mode 100644 src/drv/old/drvBitBusInterface.h create mode 100644 src/drv/old/drvGpibErr.h create mode 100644 src/drv/old/drvGpibInterface.h create mode 100644 src/drv/old/drvHiDEOSGpib.h create mode 100644 src/drv/old/drvMsg.h create mode 100644 src/drv/old/drvRs232.h create mode 100644 src/drv/old/drvTy232.h create mode 100644 src/libCom/bucketLib.h create mode 100644 src/libCom/bucketLib/bucketLib.h create mode 100644 src/libCom/cvtFast.h create mode 100644 src/libCom/cvtFast/cvtFast.h create mode 100644 src/libCom/ellLib.h create mode 100644 src/libCom/ellLib/ellLib.h create mode 100644 src/libCom/env/envDefs.h create mode 100644 src/libCom/envDefs.h create mode 100644 src/libCom/epicsAssert.h create mode 100644 src/libCom/epicsPrint.h create mode 100644 src/libCom/errMdef.h create mode 100644 src/libCom/error.h create mode 100644 src/libCom/error/epicsPrint.h create mode 100644 src/libCom/error/errMdef.h create mode 100644 src/libCom/error/error.h create mode 100644 src/libCom/fdmgr.h create mode 100644 src/libCom/fdmgr/fdmgr.h create mode 100644 src/libCom/freeList.h create mode 100644 src/libCom/freeList/freeList.h create mode 100644 src/libCom/gpHash.h create mode 100644 src/libCom/gpHash/gpHash.h create mode 100644 src/libCom/memDebugLib.h create mode 100644 src/libCom/osi/epicsAssert.h create mode 100644 src/libCom/pal.h create mode 100644 src/libCom/tsDefs.h create mode 100644 src/sequencer/seq.h create mode 100644 src/sequencer/seqCom.h create mode 100644 src/sequencer/seqU.h create mode 100644 src/sequencer/seq_taskLib.h diff --git a/src/dev/Makefile.Vx b/src/dev/Makefile.Vx index 1db842e17..d29bb738f 100644 --- a/src/dev/Makefile.Vx +++ b/src/dev/Makefile.Vx @@ -4,6 +4,11 @@ include $(EPICS)/config/CONFIG_BASE USR_INCLUDES = -I../../drv/ansi -I../../drv/old +INC += devApsEr.h +INC += devCamac.h +INC += devCommonGpib.h + + # SRCS.c += ../devAaiCamac.c # SRCS.c += ../devAiCamac.c SRCS.c += ../devAiDvx2502.c diff --git a/src/dev/devApsEg.c b/src/dev/devApsEg.c index 8d32f7b4e..c015d9f35 100644 --- a/src/dev/devApsEg.c +++ b/src/dev/devApsEg.c @@ -78,7 +78,6 @@ DEVELOPMENT CENTER AT ARGONNE NATIONAL LABORATORY (708-252-2000). #include #include #include -#include #include #include @@ -270,7 +269,7 @@ STATIC long EgLoadRamList(EgLinkStruct *pParm, long Ram) RamSpeed = pParm->Ram2Speed; /* When in ALT mode, all event records have to be downloaded */ - if (EgGetMode(pParm, 1) == EG_SEQ_MODE_ALTERNATE) + if (EgGetMode(pParm, 1) == egMOD1_Alternate) { pNode = ellFirst(&pParm->EgEvent1); RamSpeed = pParm->Ram1Speed; /* RAM1 clock used when in ALT mode */ @@ -431,12 +430,12 @@ STATIC void EgRamTask(void) /* Lock the EG link */ semTake (EgLink[j].EgLock, WAIT_FOREVER); /******** LOCK ***************/ - if (EgGetMode(&EgLink[j], 1) != EG_SEQ_MODE_ALTERNATE) + if (EgGetMode(&EgLink[j], 1) != egMOD1_Alternate) { /* Not in ALT mode, each ram is autonomous */ if(EgLink[j].Ram1Dirty != 0) { /* Make sure it is disabled and not running */ - if ((EgGetMode(&EgLink[j], 1) == EG_SEQ_MODE_OFF) && (EgGetBusyStatus(&EgLink[j], 1) == 0)) + if ((EgGetMode(&EgLink[j], 1) == egMOD1_Off) && (EgGetBusyStatus(&EgLink[j], 1) == 0)) { /* download the RAM */ EgClearSeq(&EgLink[j], 1); EgLoadRamList(&EgLink[j], 1); @@ -448,7 +447,7 @@ STATIC void EgRamTask(void) if(EgLink[j].Ram2Dirty != 0) { /* Make sure it is disabled and not running */ - if ((EgGetMode(&EgLink[j], 2) == EG_SEQ_MODE_OFF) && (EgGetBusyStatus(&EgLink[j], 2) == 0)) + if ((EgGetMode(&EgLink[j], 2) == egMOD1_Off) && (EgGetBusyStatus(&EgLink[j], 2) == 0)) { /* download the RAM */ EgClearSeq(&EgLink[j], 2); EgLoadRamList(&EgLink[j], 2); @@ -797,21 +796,21 @@ STATIC long EgProcEgRec(struct egRecord *pRec) { if (pRec->tpro > 10) printf(", Mode1=%d", pRec->mod1); - if (pRec->mod1 == EG_SEQ_MODE_ALTERNATE) + if (pRec->mod1 == egMOD1_Alternate) { - pRec->mod1 = EG_SEQ_MODE_ALTERNATE; - pRec->lmd1 = EG_SEQ_MODE_ALTERNATE; - pRec->mod2 = EG_SEQ_MODE_ALTERNATE; - pRec->lmd2 = EG_SEQ_MODE_ALTERNATE; + pRec->mod1 = egMOD1_Alternate; + pRec->lmd1 = egMOD1_Alternate; + pRec->mod2 = egMOD1_Alternate; + pRec->lmd2 = egMOD1_Alternate; pLink->Ram1Dirty = 1; pLink->Ram2Dirty = 1; } - else if (pRec->lmd1 == EG_SEQ_MODE_ALTERNATE) + else if (pRec->lmd1 == egMOD1_Alternate) { - pRec->mod2 = EG_SEQ_MODE_OFF; - pRec->lmd2 = EG_SEQ_MODE_OFF; - EgSetSeqMode(pLink, 2, EG_SEQ_MODE_OFF); + pRec->mod2 = egMOD1_Off; + pRec->lmd2 = egMOD1_Off; + EgSetSeqMode(pLink, 2, egMOD1_Off); pLink->Ram1Dirty = 1; pLink->Ram2Dirty = 1; } @@ -822,21 +821,21 @@ STATIC long EgProcEgRec(struct egRecord *pRec) { if (pRec->tpro > 10) printf(", Mode2=%d", pRec->mod2); - if (pRec->mod2 == EG_SEQ_MODE_ALTERNATE) + if (pRec->mod2 == egMOD1_Alternate) { - pRec->mod1 = EG_SEQ_MODE_ALTERNATE; - pRec->lmd1 = EG_SEQ_MODE_ALTERNATE; - pRec->mod2 = EG_SEQ_MODE_ALTERNATE; - pRec->lmd2 = EG_SEQ_MODE_ALTERNATE; + pRec->mod1 = egMOD1_Alternate; + pRec->lmd1 = egMOD1_Alternate; + pRec->mod2 = egMOD1_Alternate; + pRec->lmd2 = egMOD1_Alternate; pLink->Ram1Dirty = 1; pLink->Ram2Dirty = 1; } - else if (pRec->lmd2 == EG_SEQ_MODE_ALTERNATE) + else if (pRec->lmd2 == egMOD1_Alternate) { - pRec->mod1 = EG_SEQ_MODE_OFF; - pRec->lmd2 = EG_SEQ_MODE_OFF; - EgSetSeqMode(pLink, 1, EG_SEQ_MODE_OFF); + pRec->mod1 = egMOD1_Off; + pRec->lmd2 = egMOD1_Off; + EgSetSeqMode(pLink, 1, egMOD1_Off); pLink->Ram1Dirty = 1; pLink->Ram2Dirty = 1; } @@ -1055,7 +1054,7 @@ STATIC long EgInitEgEventRec(struct egeventRecord *pRec) /* Put the event record in the proper list */ semTake (EgLink[pRec->out.value.vmeio.card].EgLock, WAIT_FOREVER); - if (pRec->ram == REC_EGEVENT_RAM_2) + if (pRec->ram == egeventRAM_RAM_2) { ellAdd(&(EgLink[pRec->out.value.vmeio.card].EgEvent2), &(pRec->eln)); EgLink[pRec->out.value.vmeio.card].Ram2Dirty = 1; @@ -1097,7 +1096,7 @@ STATIC long EgProcEgEventRec(struct egeventRecord *pRec) semTake (EgLink[pRec->out.value.vmeio.card].EgLock, WAIT_FOREVER); /* Move to proper linked list */ - if (pRec->ram == REC_EGEVENT_RAM_2) + if (pRec->ram == egeventRAM_RAM_2) { ellDelete(&(EgLink[pRec->out.value.vmeio.card].EgEvent1), &(pRec->eln)); ellAdd(&(EgLink[pRec->out.value.vmeio.card].EgEvent2), &(pRec->eln)); @@ -1111,14 +1110,14 @@ STATIC long EgProcEgEventRec(struct egeventRecord *pRec) pRec->lram = pRec->ram; } - if (pRec->ram == REC_EGEVENT_RAM_2) + if (pRec->ram == egeventRAM_RAM_2) RamSpeed = EgLink[pRec->out.value.vmeio.card].Ram2Speed; else RamSpeed = EgLink[pRec->out.value.vmeio.card].Ram1Speed; if (pRec->enm != pRec->levt) { - if (pRec->ram == REC_EGEVENT_RAM_2) + if (pRec->ram == egeventRAM_RAM_2) EgLink[pRec->out.value.vmeio.card].Ram2Dirty = 1; else EgLink[pRec->out.value.vmeio.card].Ram1Dirty = 1; @@ -1165,7 +1164,7 @@ STATIC long EgProcEgEventRec(struct egeventRecord *pRec) printf("EgProcEgEventRec(%s) dpos=%d\n", pRec->name, pRec->dpos); pRec->ldly = pRec->dely; - if (pRec->ram == REC_EGEVENT_RAM_2) + if (pRec->ram == egeventRAM_RAM_2) EgLink[pRec->out.value.vmeio.card].Ram2Dirty = 1; else EgLink[pRec->out.value.vmeio.card].Ram1Dirty = 1; @@ -1517,7 +1516,7 @@ STATIC long EgSetSeqMode(EgLinkStruct *pParm, unsigned int Seq, int Mode) volatile ApsEgStruct *pEg = pParm->pEg; /* Stop and disable the sequence RAMs */ - if (Mode == EG_SEQ_MODE_ALTERNATE) + if (Mode == egMOD1_Alternate) { pEg->EventMask &= ~0x3006; /* Disable *BOTH* RAMs */ pEg->Control = (pEg->Control&CTL_OR_MASK)&~0x0066; @@ -1545,17 +1544,17 @@ STATIC long EgSetSeqMode(EgLinkStruct *pParm, unsigned int Seq, int Mode) switch (Mode) { - case EG_SEQ_MODE_OFF: + case egMOD1_Off: break; - case EG_SEQ_MODE_NORMAL: + case egMOD1_Normal: if (Seq == 1) pEg->EventMask |= 0x0004; /* Enable Seq RAM 1 */ else pEg->EventMask |= 0x0002; /* Enable Seq RAM 2 */ break; - case EG_SEQ_MODE_NORMAL_RECYCLE: + case egMOD1_Normal_Recycle: if (Seq == 1) { pEg->EventMask |= 0x0004; /* Enable Seq RAM 1 */ @@ -1568,14 +1567,14 @@ STATIC long EgSetSeqMode(EgLinkStruct *pParm, unsigned int Seq, int Mode) } break; - case EG_SEQ_MODE_SINGLE: + case egMOD1_Single: if (Seq == 1) pEg->EventMask |= 0x2004; /* Enable Seq RAM 1 in single mode */ else pEg->EventMask |= 0x1002; break; - case EG_SEQ_MODE_ALTERNATE: /* The ram downloader does all the work */ + case egMOD1_Alternate: /* The ram downloader does all the work */ pEg->EventMask |= 0x0800; /* turn on the ALT mode bit */ break; @@ -1646,7 +1645,7 @@ STATIC long EgGetMode(EgLinkStruct *pParm, int Ram) Control = pEg->Control & 0x0060; if (Mask & 0x0800) - return(EG_SEQ_MODE_ALTERNATE); + return(egMOD1_Alternate); if (Ram == 1) { @@ -1654,13 +1653,13 @@ STATIC long EgGetMode(EgLinkStruct *pParm, int Ram) Control &= 0x0040; if ((Mask == 0) && (Control == 0)) - return(EG_SEQ_MODE_OFF); + return(egMOD1_Off); if ((Mask == 0x0004) && (Control == 0)) - return(EG_SEQ_MODE_NORMAL); + return(egMOD1_Normal); if ((Mask == 0x0004) && (Control == 0x0040)) - return(EG_SEQ_MODE_NORMAL_RECYCLE); + return(egMOD1_Normal_Recycle); if (Mask & 0x2000) - return(EG_SEQ_MODE_SINGLE); + return(egMOD1_Single); } else { @@ -1668,13 +1667,13 @@ STATIC long EgGetMode(EgLinkStruct *pParm, int Ram) Control &= 0x0020; if ((Mask == 0) && (Control == 0)) - return(EG_SEQ_MODE_OFF); + return(egMOD1_Off); if ((Mask == 0x0002) && (Control == 0)) - return(EG_SEQ_MODE_NORMAL); + return(egMOD1_Normal); if ((Mask == 0x0002) && (Control == 0x0020)) - return(EG_SEQ_MODE_NORMAL_RECYCLE); + return(egMOD1_Normal_Recycle); if (Mask & 0x1000) - return(EG_SEQ_MODE_SINGLE); + return(egMOD1_Single); } printf("EgGetMode() seqence RAM in invalid state %04.4X %04.4X\n", pEg->Control, pEg->EventMask); return(-1); @@ -1963,7 +1962,7 @@ STATIC int ConfigSeq(EgLinkStruct *pParm, int channel) switch (buf[1]) { case '0': - EgSetSeqMode(pParm, channel, EG_SEQ_MODE_OFF); + EgSetSeqMode(pParm, channel, egMOD1_Off); break; case '1': if (EgSeqEnableCheck(pParm, channel)) diff --git a/src/dev/devApsEr.h b/src/dev/devApsEr.h new file mode 100644 index 000000000..790a2b011 --- /dev/null +++ b/src/dev/devApsEr.h @@ -0,0 +1,74 @@ +/* + * ***************************************************************** + * 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). + */ + +#ifndef EPICS_DEVAPSER_H +#define EPICS_DEVAPSER_H + +/* Error numbers passed to ERROR_FUNC routines */ +#define ERROR_TAXI 1 /* Taxi violation */ +#define ERROR_HEART 2 /* Lost the system heart beat */ +#define ERROR_LOST 3 /* Events were lost */ + +/* Globally reserved event numbers */ +#define ER_EVENT_NULL 0x00 /* NULL event */ +#define ER_EVENT_END 0x7f /* Event sequence end */ +#define ER_EVENT_FREEZE 0x7e /* Freeze the event sequence */ +#define ER_EVENT_RESET_TICK 0x7d /* Reset the tick counter */ +#define ER_EVENT_TICK 0x7c /* Add 1 to the tick counter */ +#define ER_EVENT_RESET_PRESCALERS 0x7b +#define ER_EVENT_HEARTBEAT 0x7a + +typedef void (*EVENT_FUNC)(int Card, int EventNum, unsigned long Ticks); +typedef void (*ERROR_FUNC)(int Card, int ErrorNum); + +long ErRegisterEventHandler(int Card, EVENT_FUNC func); +long ErRegisterErrorHandler(int Card, ERROR_FUNC func); +long ErGetTicks(int Card, unsigned long *Ticks); +long ErHaveReceiver(int Card); + +#endif diff --git a/src/dev/devCamac.h b/src/dev/devCamac.h new file mode 100644 index 000000000..270df1609 --- /dev/null +++ b/src/dev/devCamac.h @@ -0,0 +1,48 @@ +/* devCamac.h Camac Device Support */ +/* + * Author: Johnny Tang + * Date: 4-14-94 + * + * 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 + * + */ + +#define ADDRESS_SCAN -1 +#define BLOCK_TRANSFER 1 + +#define CDEBUG CAMAC_DEBUG +int CAMAC_DEBUG; +#define CONVERT 0 +#define DO_NOT_CONVERT 2 + +/*sizes of field types*/ +static int sizeofTypes[] = {0,1,1,2,2,4,4,4,8,2}; +/* DBF_STRING DBF_CHAR DBF_UCHAR DBF_SHORT DBF_USHORT DBF_LONG + DBF_ULONG DBF_FLOAT DBF_DOUBLE DBF_ENUM +*/ + + +struct dinfo{ + short f; + long ext; + long mask; +}; diff --git a/src/dev/devCommonGpib.h b/src/dev/devCommonGpib.h new file mode 100644 index 000000000..77cb9de68 --- /dev/null +++ b/src/dev/devCommonGpib.h @@ -0,0 +1,348 @@ +/* devCommonGpib.h */ +/* share/epicsH/devCommonGpib.h $Id$ */ +/* + * Author: John Winans + * Date: 11-19-91 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1988, 1989, 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 + * + * All rights reserved. No part of this publication may be reproduced, + * stored in a retrieval system, transmitted, in any form or by any + * means, electronic, mechanical, photocopying, recording, or otherwise + * without prior written permission of Los Alamos National Laboratory + * and Argonne National Laboratory. + * + * Modification Log: + * ----------------- + * .01 11-19-91 jrw Initial release + * .02 02-26-92 jrw removed declaration of callbackRequest() + * .03 05-11-92 jrw Added waveform record support + */ + +#ifndef DEVCOMMONGPIB_H +#define DEVCOMMONGPIB_H + +long devGpibLib_report(); +long devGpibLib_initDevSup(); +long devGpibLib_initAi(); +long devGpibLib_initAo(); +long devGpibLib_initLi(); +long devGpibLib_initLo(); +long devGpibLib_initBi(); +long devGpibLib_initBo(); +long devGpibLib_initMbbo(); +long devGpibLib_initMbbi(); +long devGpibLib_initSi(); +long devGpibLib_initSo(); +long devGpibLib_initXx(); +long devGpibLib_readAi(); +long devGpibLib_writeAo(); +long devGpibLib_readLi(); +long devGpibLib_writeLo(); +long devGpibLib_readBi(); +long devGpibLib_writeBo(); +long devGpibLib_readMbbi(); +long devGpibLib_writeMbbo(); +long devGpibLib_readSi(); +long devGpibLib_writeSo(); + +int devGpibLib_aiGpibWork(); +int devGpibLib_aiGpibSrq(); +int devGpibLib_aiGpibFinish(); +int devGpibLib_aoGpibWork(); +int devGpibLib_liGpibWork(); +int devGpibLib_liGpibSrq(); +int devGpibLib_liGpibFinish(); +int devGpibLib_loGpibWork(); +int devGpibLib_biGpibWork(); +int devGpibLib_biGpibSrq(); +int devGpibLib_biGpibFinish(); +int devGpibLib_boGpibWork(); +int devGpibLib_mbbiGpibWork(); +int devGpibLib_mbbiGpibSrq(); +int devGpibLib_mbbiGpibFinish(); +int devGpibLib_mbboGpibWork(); +int devGpibLib_stringinGpibWork(); +int devGpibLib_stringinGpibSrq(); +int devGpibLib_stringinGpibFinish(); +int devGpibLib_stringoutGpibWork(); +int devGpibLib_xxGpibWork(); + +int devGpibLib_wfGpibFinish(); +int devGpibLib_wfGpibSrq(); +int devGpibLib_wfGpibWork(); +long devGpibLib_readWf(); +long devGpibLib_initWf(); + +void devGpibLib_processCallback(); +long devGpibLib_setPvSevr(); + +typedef struct { + long number; + DEVSUPFUN funPtr[20]; +} gDset; + +/****************************************************************************** + * + * This structure holds device-related data on a per-device basis and is + * referenced by the gpibDpvt structures. They are built using a linked + * list entered from hwpvtHead. This linked list is only for this specific + * device type (other gpib devices may have their own lists.) + * + * The srqCallback() and parm fields are used for GPIBREADW type calls. They + * should place the address of the appropriate function (aiGpibSrq if an AI + * record is being processed) into the srqCallback() field and the pdpvt + * field for the device into the parm field. This allows the SrqHandler() + * function to locate the proper function and work areas to complete the + * GPIBREADW operation. + * + * The unsolicitedDpvt field is used if the user specifies a record with + * the parm number associated with handleing unsolicited SRQ interrupts. + * What is done, is that the record will be processed when an SRQ is + * detected for reasons other than GPIBREADW-related reasons. There may + * be at most, 1 single record in hte database that can specify the 'magic' + * parm number. If you need more, forward link it to a fanout record. + * + ******************************************************************************/ +struct hwpvt { + struct hwpvt *next; /* to next structure for same type device */ + + int linkType; /* is a GPIB_IO, BBGPIB_IO... from link.h */ + int link; /* link number */ + int bug; /* used only on BBGPIB_IO links */ + int device; /* gpib device number */ + + unsigned long tmoVal; /* time last timeout occurred */ + unsigned long tmoCount; /* total number of timeouts since boot time */ + + /* No semaphore guards here because can inly be mod'd by the linkTask */ + int (*srqCallback)(); /* filled by cmds expecting SRQ callbacks */ + caddr_t parm; /* filled in by cmds expecting SRQ callbacks */ + + struct gpibDpvt *unsolicitedDpvt; /* filled in if database calls for it */ + caddr_t pupvt; /* user defined pointer */ +}; + +/****************************************************************************** + * + * This structure will be attached to each pv (via psub->dpvt) to store the + * appropriate head.workStart pointer, callback address to record support, + * gpib link #, device address, and command information. + * + ******************************************************************************/ + +struct gpibDpvt { + struct dpvtGpibHead head; /* fields used by the GPIB driver */ + + short parm; /* parameter index into gpib commands */ + char *rsp; /* for read/write message error Responses*/ + char *msg; /* for read/write messages */ + struct dbCommon *precord; /* record this dpvt is part of */ + void (*process)(); /* callback to perform forward db processing */ + int processPri; /* process callback's priority */ + long linkType; /* GPIB_IO, BBGPIB_IO... */ + struct hwpvt *phwpvt; /* pointer to per-device private area */ + caddr_t pupvt; /* user defined pointer */ +}; + +#define GET_GPIB_HW_PVT(pGpibDpvt) (((struct gpibDpvt*)(pGpibDpvt))->phwpvt->pupvt) +#define SET_GPIB_HW_PVT(pGpibDpvt, value) (((struct gpibDpvt*)(pGpibDpvt))->phwpvt->pupvt = value) + +/****************************************************************************** + * + * This is used to define the strings that are used for button labels. + * These strings are put into the record's znam & onam foelds if the + * record is a BI or BO type and into the zrst, onst... fields of an + * MBBI or MBBO record. + * + * Before these strings are placed into the record, the record is + * check to see if there is already a string defined (could be user-entered + * with DCT.) If there is already a string present, it will be preserved. + * + * There MUST ALWAYS be 2 and only 2 entries in the names.item list + * for BI and BO records if a name list is being specified for them here. + * The names.count field is ignored for BI and BO record types, but + * should be properly specified as 2 for future compatibility. + * + * NOTE: + * If a name string is filled in an an MBBI/MBBO record, it's corresponding + * value will be filled in as well. For this reason, there MUST be + * a value array and a valid nobt value for every MBBI/MBBO record that + * contains an item array! + * + ******************************************************************************/ + +struct devGpibNames { + int count; /* CURRENTLY only used for MBBI and MBBO */ + char **item; + unsigned long *value; /* CURRENTLY only used for MBBI and MBBO */ + short nobt; /* CURRENTLY only used for MBBI and MBBO */ +}; + +/****************************************************************************** + * + * Enumeration of gpib command types supported. + * + * Each transaction type is described below : + * + * GPIBREAD : (1) The cmd string is sent to the instrument + * (2) Data is read from the inst into a buffer (gpibDpvt.msg) + * (3) The important data is extracted from the buffer using the + * format string. + * + * GPIBWRITE: (1) An ascii string is generated using the format string and + * contents of the gpibDpvt->dbAddr->precord->val + * (2) The ascii string is sent to the instrument + * + * GPIBCMD : (1) The cmd string is sent to the instrument + * + * GPIBCNTL : (1) The control string is sent to the instrument (ATN active) + * + * GPIBSOFT : (1) No GPIB activity involved - normally retrieves internal data + * + * GPIBREADW : (1) The cmd string is sent to the instrument + * (2) Wait for SRQ + * (3) Data is read from the inst into a buffer (gpibDpvt.msg) + * (4) The important data is extracted from the buffer using the + * format string. + * + * GPIBRAWREAD: Used internally with GPIBREADW. Not useful from cmd table. + * + * + * The following is only supported on mbbo and bo record types. + * + * GPIBEFASTO: (1) Sends out the string pointed to by p3[VAL] w/o formating + * + * The following are only supported on mbbi and bi record types. + * + * GPIBEFASTI: (1) Send out the cmd string + * (2) Data is read from the inst into a buffer (gpibDpvt.msg) + * (3) Check the response against P3[0..?] + * (4) Set the value field to index when response = P3[index] + * + * GPIBEFASTIW: (1) Send out the cmd string + * (2) Wait for SRQ + * (3) Data is read from the inst into a buffer (gpibDpvt.msg) + * (4) Check the response against P3[0..?] + * (5) Set the value field to index when response = P3[index] + * + * If a particular GPIB message does not fit one of these formats, a custom + * routine may be provided. Store a pointer to this routine in the + * gpibCmd.convert field to use it rather than the above approaches. + * + ******************************************************************************/ + +#define GPIBREAD 1 +#define GPIBWRITE 2 +#define GPIBCMD 3 +#define GPIBCNTL 4 +#define GPIBSOFT 5 +#define GPIBREADW 6 +#define GPIBRAWREAD 7 +#define GPIBEFASTO 8 +#define GPIBEFASTI 9 +#define GPIBEFASTIW 10 + + +struct gpibCmd { + gDset *rec_typ; /* used to indicate record type supported */ + int type; /* enum - GPIBREAD, GPIBWRITE, GPIBCMND */ + short pri; /* request priority--IB_Q_HIGH or IB_Q_LOW*/ + char *cmd; /* CONSTANT STRING to send to instrument */ + char *format; /* string used to generate or interpret msg*/ + long rspLen; /* room for response error message*/ + long msgLen; /* room for return data message length*/ + + int (*convert)(); /* custom routine for conversions */ + int P1; /* user defined parameter used in convert() */ + int P2; /* user defined parameter used in convert() */ + char **P3; /* user defined parameter used in convert() */ + + struct devGpibNames *namelist; /* pointer to name strings */ + + int companion; /* companion command (used at init time) */ +}; + +#define FILL {0,0,0,NULL,NULL,0,0,NULL,0,0,NULL,NULL,-1} +#define FILL10 FILL,FILL,FILL,FILL,FILL,FILL,FILL,FILL,FILL,FILL + +/****************************************************************************** + * + * debugFlag: + * Must point to a flag used to request debugging traces for the device + * while executing library code. + * + * respond2Writes: + * Set to TRUE if the device responds to write operations. This causes + * a read operation to follow each write operation. (See also wrConversion) + * + * timeWindow: + * Set to the number of system ticks that should be skipped after a timeout + * is detected on a device. All commands issued within this time window + * will be aborted and returned as errors. + * + * hwpvtHead: + * This is the root pointer for the per-hardware device private structure + * list. It should ALWAYS be initialized to NULL. + * + * gpibCmds: + * Pointer to the gpibCmds array. + * + * numparams: + * The number of parameters described in the gpibCmds array. + * + * magicSrq: + * Set to the parameter number that should be processed if an unsolicited + * SRQ is detected. + * + * name: + * Must point to a string containing the device name (used for + * debug messages.) + * + * srqHandler: + * Must point to the SRQ handler for the device support module if SRQs are + * supported or NULL if not. + * + * wrConversion: + * If not set to NULL and respond2Writes is true and a GPIBWRITE or GPIBCMD + * operation has completed it's read portion, this secondary conversion + * routine is called. + * + ******************************************************************************/ + +typedef struct devGpibParmBlock { + int *debugFlag; /* pointer to debug flag */ + int respond2Writes; /* set to true if a device responds to writes */ + int timeWindow; /* clock ticks to skip after a timeout */ + struct hwpvt *hwpvtHead; /* pointer to the hwpvt list for device type */ + struct gpibCmd *gpibCmds; /* pointer to gpib command list */ + int numparams; /* number of elements in the command list */ + int magicSrq; /* magic parm to handle unsolicited SRQs */ + char *name; /* pointer to a string containing device type */ + int dmaTimeout; /* clock ticks to wait for DMA to complete */ + + int (*srqHandler)(); /* user SRQ handler or NULL if not supported */ + + int (*wrConversion)(); /* secondary conversion routine */ +} devGpibParmBlockStruct; + +#endif diff --git a/src/dev/devMz8310.c b/src/dev/devMz8310.c index 71dcad5cb..40aab9a88 100644 --- a/src/dev/devMz8310.c +++ b/src/dev/devMz8310.c @@ -68,11 +68,8 @@ #include #include #include -#include #include -#include #include -#include #include /* Create the dsets for devMz8310 */ @@ -131,14 +128,14 @@ static unsigned short *shortaddr; #define HTS_FIELD 0x0010 /* defs for counter commands */ -#define CTR_READ REC_PULSECOUNTER_CMD_READ -#define CTR_CLEAR REC_PULSECOUNTER_CMD_CLEAR -#define CTR_START REC_PULSECOUNTER_CMD_START -#define CTR_STOP REC_PULSECOUNTER_CMD_STOP -#define CTR_SETUP REC_PULSECOUNTER_CMD_SETUP +#define CTR_READ pulseCounterCMD_Read +#define CTR_CLEAR pulseCounterCMD_Clear +#define CTR_START pulseCounterCMD_Start +#define CTR_STOP pulseCounterCMD_Stop +#define CTR_SETUP pulseCounterCMD_Setup -#define SIZE_16 REC_PULSECOUNTER_CSIZ_16 -#define SIZE_32 REC_PULSECOUNTER_CSIZ_32 +#define SIZE_16 pulseCounterCSIZ_16_bit +#define SIZE_32 pulseCounterCSIZ_32_bit /* defines specific to mz8310*/ diff --git a/src/dev/devTimerMz8310.c b/src/dev/devTimerMz8310.c index 89479eb48..6d6899dae 100644 --- a/src/dev/devTimerMz8310.c +++ b/src/dev/devTimerMz8310.c @@ -50,11 +50,8 @@ #include #include #include -#include #include -#include #include -#include #include #include diff --git a/src/drv/ansi/Makefile.Vx b/src/drv/ansi/Makefile.Vx index 502d73f3a..270aeac93 100644 --- a/src/drv/ansi/Makefile.Vx +++ b/src/drv/ansi/Makefile.Vx @@ -10,6 +10,9 @@ USR_CFLAGS = -ansi VX_WARN_YES = -Wall -pedantic +INC += epvxi.h +INC += drvEpvxi.h + SRCS.c += ../drvAb.c SRCS.c += ../drvAt5Vxi.c SRCS.c += ../drvEpvxi.c diff --git a/src/drv/ansi/drvEpvxi.h b/src/drv/ansi/drvEpvxi.h new file mode 100644 index 000000000..e2ea368cb --- /dev/null +++ b/src/drv/ansi/drvEpvxi.h @@ -0,0 +1,477 @@ +/* drvEpvxi.h */ +/* $Id$ */ +/* + * parameter file supporting the VXI library + * + * Author: Jeff Hill + * Date: 8-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 070792 joh Added MACROS to return the A24 and A32 base addr + * .02 072992 joh Added sccs id + * .03 081992 joh ANSI C func proto + * .04 082592 joh added arg to epvxiRead() and epvxiWrite() + * .05 090392 joh Now runtime links to NI trigger routing + * .06 092392 joh New status from epvxiRead() - VXI_BUFFER_FULL + * .07 033193 joh error codes converted to EPICS standard format + * .08 071293 joh record task id when opening a device + * .09 082793 joh -Wall cleanup and added drvEpvxiFetchPConfig() + * + * + */ + + +#ifndef INCepvxiLibh +#define INCepvxiLibh + +static char *epvxiLibhSccId = "$Id$"; + +#include +#include +#include + +/* + * Structure used to specify search patterns for epvxiLookupLA() + * + * Set a bit in the flags member for each item that is to be a + * constraint on the search. All other items are ignored during + * the search. The callback routine will be called for all devices + * which exactly match all items specified in the flags field + */ +#define VXI_DSP_make (1<<0) +#define VXI_DSP_model (1<<1) +#define VXI_DSP_class (1<<2) +#define VXI_DSP_slot (1<<3) +#define VXI_DSP_slot_zero_la (1<<4) +#define VXI_DSP_commander_la (1<<5) +#define VXI_DSP_extender_la (1<<6) /* id crates that have one */ + +typedef struct { + long flags; /* one bit enabling each field */ + unsigned short make; /* manufacture identification */ + unsigned short model; /* model code for the device */ + unsigned short class; /* vxi device class */ + unsigned char slot; /* slot where the device resides */ + unsigned char slot_zero_la; /* logical address of slot 0 dev */ + unsigned char commander_la; /* logical address of commander */ + unsigned char extender_la; /* logical address of bus repeater */ +}epvxiDeviceSearchPattern; + +typedef long EPVXISTAT; + +/* + * functions from epvxiLib.c + */ +EPVXISTAT epvxiResman( + void +); + +EPVXISTAT epvxiIOReport( + unsigned level +); + +EPVXISTAT epvxiDeviceList( + void +); + +EPVXISTAT epvxiCrateList( + void +); + +EPVXISTAT epvxiExtenderList( + void +); + +EPVXISTAT epvxiUniqueDriverID( + void +); + +EPVXISTAT epvxiDeviceVerify( + unsigned la +); + +EPVXISTAT epvxiOpen( + unsigned la, + int vxiDriverID, + unsigned long driverConfigSize, + void (*pio_report_func)() +); + +EPVXISTAT epvxiClose( + unsigned la, + int vxiDriverID +); + +EPVXISTAT epvxiLookupLA( + epvxiDeviceSearchPattern + *pdsp, + void (*pfunc)(), + void *parg +); + +EPVXISTAT epvxiRouteTriggerECL( + unsigned la, /* slot zero device logical address */ + unsigned enable_map, /* bits 0-5 correspond to trig 0-5 */ + /* a 1 enables a trigger */ + /* a 0 disables a trigger */ + unsigned io_map /* bits 0-5 correspond to trig 0-5 */ + /* a 1 sources the front panel */ + /* a 0 sources the back plane */ +); + +EPVXISTAT epvxiRouteTriggerTTL( + unsigned la, /* slot zero device logical address */ + unsigned enable_map, /* bits 0-5 correspond to trig 0-5 */ + /* a 1 enables a trigger */ + /* a 0 disables a trigger */ + unsigned io_map /* bits 0-5 correspond to trig 0-5 */ + /* a 1 sources the front panel */ + /* a 0 sources the back plane */ +); + +EPVXISTAT epvxiRegisterModelName( + unsigned int make, + unsigned int model, + char *pmodel_name +); + +EPVXISTAT epvxiRegisterMakeName( + unsigned int make, + char *pmake_name +); + +EPVXISTAT epuxiLookupModelName( + unsigned int make, /* VXI manuf. */ + unsigned int model, /* VXI model code */ + char *pbuffer, /* model name return */ + unsigned int bufsize, /* size of supplied buf */ + unsigned int *preadcount /* n bytes written */ +); + +EPVXISTAT epuxiLookupMakeName( + unsigned int make, /* VXI manuf. */ + char *pbuffer, /* model name return */ + unsigned int bufsize, /* size of supplied buf */ + unsigned int *preadcount /* n bytes written */ +); + +EPVXISTAT vxi_init( /* compatibility */ + void +); + +EPVXISTAT vxi_io_report( /* compatibility */ + unsigned level +); + +/* + * functions from epvxiMsgLib.c + */ +EPVXISTAT epvxiCmd( + unsigned la, + unsigned long cmd +); +EPVXISTAT epvxiQuery( + unsigned la, + unsigned long *presp +); +EPVXISTAT epvxiCmdQuery( + unsigned la, + unsigned long cmd, + unsigned long *presp +); +EPVXISTAT epvxiRead( + unsigned la, + char *pbuf, + unsigned long count, + unsigned long *pread_count, + unsigned long option +); +#define epvxiReadOptNone 0 + +EPVXISTAT epvxiWrite( + unsigned la, + char *pbuf, + unsigned long count, + unsigned long *pwrite_count, + unsigned long option +); +#define epvxiWriteOptNone 0 +#define epvxiWriteOptPartialMsg 1 /* message continues after this transfer */ + +EPVXISTAT epvxiSetTimeout( + unsigned la, + unsigned long timeout +); + +/* + * epvxiLib return codes (also used by epvxiMsgLib) + * + * These codes changed to the EPICS standrd format on 033193 + */ +#define VXI_SUCCESS 0 /* normal successful completion*/ +#define S_epvxi_noDevice (M_epvxi|1) /*device does not exist*/ +#define S_epvxi_notSlotZero (M_epvxi|2) /*not a slot zero devic*/ +#define S_epvxi_uknDevice (M_epvxi|3) /*device not supported*/ +#define S_epvxi_badTrigger (M_epvxi|4) /*specified trigger does not exist*/ +#define S_epvxi_badTrigIO (M_epvxi|5) /*specified trigger io does not exist*/ +#define S_epvxi_deviceOpen (M_epvxi|6) /*device already open*/ +#define S_epvxi_notOwner (M_epvxi|7) /*device in use by a different driver*/ +#define S_epvxi_noMemory (M_epvxi|8) /*memory allocation failed*/ +#define S_epvxi_notOpen (M_epvxi|9) /*device not open*/ +#define S_epvxi_notMsgDevice (M_epvxi|10) /*operation requires a message based device*/ +#define S_epvxi_deviceTMO (M_epvxi|11) /*message based dev timed out*/ +#define S_epvxi_msgDeviceFailure (M_epvxi|12) /*message based dev failed*/ +#define S_epvxi_badLA (M_epvxi|13) /*logical addr out of range*/ +#define S_epvxi_multipleQueries (M_epvxi|14) /*multiple queries serial protocol error*/ +#define S_epvxi_unsupportedCmd (M_epvxi|15) /*unsupported cmd serial protocol error*/ +#define S_epvxi_dirViolation (M_epvxi|16) /*DIR violation serial protocol error*/ +#define S_epvxi_dorViolation (M_epvxi|17) /*DOR violation serial protocol error*/ +#define S_epvxi_rrViolation (M_epvxi|18) /*RR violation serial protocol error*/ +#define S_epvxi_wrViolation (M_epvxi|19) /*WR violation serial protocol error*/ +#define S_epvxi_errFetchFailed (M_epvxi|20) /*unknown serial protocol error*/ +#define S_epvxi_selfTestFailed (M_epvxi|21) /*self test failed*/ +#define S_epvxi_timeoutToLarge (M_epvxi|22) /*specified timeout to long*/ +#define S_epvxi_protocolError (M_epvxi|23) /*protocol error*/ +#define S_epvxi_unreadData (M_epvxi|24) /*attempt to write when unread data from a previous command is present (RULE C.3.3)*/ +#define S_epvxi_nameMismatch (M_epvxi|25) /*make or model name already registered does not matchi supplied name*/ +#define S_epvxi_noMatch (M_epvxi|26) /*no name registered for the supplied make and or model*/ +#define S_epvxi_bufferFull (M_epvxi|27) /*read terminated with unread data remaining because the end of the supplied buffer was reached*/ +#define S_epvxi_noResman (M_epvxi|28) /*the VXI resource manager must run first*/ +#define S_epvxi_internal (M_epvxi|29) /*VXI internal failure*/ +#define S_epvxi_badConfig (M_epvxi|30) /*Incorrect system configuration*/ +#define S_epvxi_noCmdr (M_epvxi|31) /*No commander hardware support for message based comm - continuing*/ +#define S_epvxi_msgDeviceStatus (M_epvxi|32) /*VXI Message based device reporting error condition*/ +#define S_epvxi_slotNotFound (M_epvxi|33) /*VXI device's slot not found- MODID failure?*/ +#define S_epvxi_noMODID (M_epvxi|34) /*VXI device does not have MODID capability*/ + + +enum ext_type { ext_local_cpu, /* bus master constrained by module_types.h */ + ext_export_vxi_onto_mxi, /* VXI mapped into MXI addr space */ + ext_import_mxi_into_vxi /* MXI mapped into VXI addr space */ + /* + . + . + other bus extender types could be inserted here + . + . + */ + }; + +#ifndef SRCepvxiLib +extern +#endif +char *ext_type_name[] +#ifdef SRCepvxiLib + = { + "VXI hosted VME bus master", + "VXI mapped onto MXI addr space", + "MXI mapped into VXI addr space" + } +#endif +; + +typedef struct extender_device{ + ELLNODE node; + ELLLIST extenders; /* sub extenders */ + struct extender_device *pParent; + enum ext_type type; + int la; + int la_low; /* inclusive */ + int la_high; /* inclusive */ + unsigned long A24_base; + unsigned long A24_size; + unsigned long A32_base; + unsigned long A32_size; + unsigned la_mapped:1; /* device present */ + unsigned A24_mapped:1; + unsigned A32_mapped:1; + unsigned A24_ok:1; + unsigned A32_ok:1; +}VXIE; + +/* + * bits for the device type and a pointer + * to its configuration registers if + * available + */ +typedef struct slot_zero_device{ + ELLNODE node; + void (*set_modid)( + struct slot_zero_device *pvxisz, + unsigned slot); + void (*clear_modid)( + struct slot_zero_device *pvxisz); + VXIE *pvxie; + struct vxi_csr *pcsr; + unsigned char la; + unsigned reg:1; + unsigned msg:1; + unsigned nicpu030:1; +}VXISZ; + +typedef struct epvxiLibDeviceConfig{ + void (*pio_report_func)(); /* ptr to io report func */ + void *pDriverConfig; /* ptr to driver config */ + void *pMsgConfig; /* msg driver config area */ + void *pFatAddrBase; + VXIE *pvxie; /* extender info */ + VXIE *pvxieSelf; /* extender info for self */ + VXISZ *pvxisz; /* ptr to slot zero info */ + unsigned long driverID; /* unique driver id */ + int taskID; /* opened by this id */ + unsigned short make; + unsigned short model; + short slot; + short commander_la; + short extender_la; /* logical address of bus repeater */ + short slot_zero_la; + unsigned char class; + unsigned st_passed:1; /* self test passed */ + unsigned msg_dev_online:1; + unsigned slot0_dev:1; + unsigned A24_mapped:1; + unsigned A32_mapped:1; +}VXIDI; + +/* + * + * + * functions used from the nivxi library + * (to support runtime linking) + * + */ +enum nivxi_func_index { + e_SetMODID, + e_VXIinLR, + e_InitVXIlibrary, + e_vxiinit, + e_MapTrigToTrig, + e_GetMyLA, + e_EnableSignalInt, + e_SetSignalHandler, + e_RouteSignal + }; +#ifndef SRCepvxiLib +extern +#endif +char *nivxi_func_names[] +#ifdef SRCepvxiLib + = { + "_SetMODID", + "_VXIinLR", + "_InitVXIlibrary", + "_vxiinit", /* WARNING this is different than vxiInit */ + "_MapTrigToTrig", + "_GetMyLA", + "_EnableSignalInt", + "_SetSignalHandler", + "_RouteSignal" + } +#endif +; + +#ifdef SRCepvxiLib +int (*pnivxi_func[NELEMENTS(nivxi_func_names)])(); +#else +extern +int (*pnivxi_func[])(); +#endif + + +/* + * + * typical usage + * + * struct freds_driver_info pfdi; + * + * pfdi = epvxiPConfig(14, driverID, (struct freds_driver_info *)) + * + * RETURNS ptr to device config area or NULL + */ +#define PVXIDI(LA) (epvxiLibDeviceList[LA]) +#define epvxiPConfig(LA, ID, CAST) \ +( \ +PVXIDI(LA)? \ + PVXIDI(LA)->driverID==(ID)? \ + (CAST) PVXIDI(LA)->pDriverConfig \ + : \ + (CAST) NULL \ +: \ + (CAST) NULL \ +) + +/* + * epvxiFetchPConfig + * (improved version of the above returns status) + */ +#define epvxiFetchPConfig(LA, ID, PTR) \ +( \ +PVXIDI(LA)!=NULL? \ + (PVXIDI(LA)->driverID==(ID)? \ + (((PTR) = PVXIDI(LA)->pDriverConfig), VXI_SUCCESS) \ + : \ + S_epvxi_notOwner) \ +: \ + S_epvxi_noDevice \ +) + +/* + * A24 and A32 base addressing + */ +#define epvxiA24Base(LA) (PVXIDI(LA)->pFatAddrBase) +#define epvxiA32Base(LA) (PVXIDI(LA)->pFatAddrBase) + +#ifndef SRCepvxiLib +extern +#endif +VXIDI *epvxiLibDeviceList[NVXIADDR]; + +#define NO_DRIVER_ATTACHED_ID (0) +#define UNINITIALIZED_DRIVER_ID (0xffff) +#ifndef SRCepvxiLib +extern +#endif +unsigned long epvxiNextDriverID +#ifdef SRCepvxiLib += (NO_DRIVER_ATTACHED_ID+1) +#endif +; + +/* + * set by the RM when it is done and VXI modules are present + */ +#ifndef SRCepvxiLib +extern +#endif +int epvxiResourceMangerOK; + +#ifndef SRCepvxiLib +extern +#endif +void *epvxi_local_base; + +#define VXIBASE(LA) VXI_LA_TO_PA(LA, epvxi_local_base) + +#endif /* INCepvxiLibh */ diff --git a/src/drv/ansi/epvxi.h b/src/drv/ansi/epvxi.h new file mode 100644 index 000000000..43a999430 --- /dev/null +++ b/src/drv/ansi/epvxi.h @@ -0,0 +1,532 @@ +/* $Id$ + * + * VXI standard defines + * + * Author: Jeff Hill + * Date: 11-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 joh 021490 changed NVXIADDR to 32 before formal release + * .02 joh 120591 reorganized to support nivxi + * .03 joh 010892 added message based device registers and + * commands + * .04 joh 013091 moved some of the slot 0 stuff here + * .05 joh 070692 added KSC manufacturer id + * .06 joh 070692 added address space defines + * .07 joh 081992 added csr typedef + * .08 joh 071593 typedef for device registers + * .09 joh 051995 fixed incorrect MBC_TOP_LEVEL_CMDR def + * + */ + +#ifndef INCepvxih +#define INCepvxih + +#include + +/* + * offset from the bottom of VME short addr of + * VXI logical address space + */ +#define VXIBASEADDR 0xc000 + +typedef volatile uint16_t vxi16_t; +typedef volatile uint8_t vxi8_t; + +/* + * set NVXIADDR to less than 0x100 since other VME modules + * currently live in VXI address space + */ +#define NVXIADDR (0x100) +#define NVXISLOTS 13 +#define VXIDYNAMICADDR (0xff) +#define NVXIADDRBITS 8 +#define VXIADDRMASK ((1<>VXIDEVBITS)&VXIADDRMASK ) + +struct vxi_msg_dev_w{ + vxi16_t signal; + vxi16_t dextended; + vxi16_t dhigh; + vxi16_t dlow; +}; + +struct vxi_mxi_dev_w{ + vxi16_t modid; + vxi16_t la_window; + vxi8_t a16_window_high; + vxi8_t a16_window_low; + vxi8_t a24_window_high; + vxi8_t a24_window_low; + vxi8_t a32_window_high; + vxi8_t a32_window_low; + vxi16_t INTX_interrupt; + vxi16_t INTX_trigger; + vxi16_t dd7; + vxi16_t INTX_utility; + vxi16_t dd9; + vxi16_t dd10; + vxi16_t subclass; + vxi16_t control; + vxi16_t lock; + vxi16_t irq; + vxi16_t trigger_drive; + vxi16_t trigger_mode; + vxi16_t interrupt; + vxi16_t status_id; + vxi16_t trigger_config; + vxi16_t trigger_sync_ack; + vxi16_t trigger_async_ack; + vxi16_t irq_ack; +}; + +struct vxi_reg_dev_w{ + vxi16_t ddx08; + vxi16_t ddxoa; + vxi16_t ddx0c; + vxi16_t ddx0e; + vxi16_t ddx10; + vxi16_t ddx12; + vxi16_t ddx14; + vxi16_t ddx16; + vxi16_t ddx18; + vxi16_t ddx1a; + vxi16_t ddx1c; + vxi16_t ddx1e; + vxi16_t ddx20; + vxi16_t ddx22; + vxi16_t ddx24; + vxi16_t ddx26; + vxi16_t ddx28; + vxi16_t ddx2a; + vxi16_t ddx2c; + vxi16_t ddx2e; +}; + +struct vxi_reg_slot0_dev_w{ + vxi16_t modid; + vxi16_t ddxoa; + vxi16_t ddx0c; + vxi16_t ddx0e; + vxi16_t ddx10; + vxi16_t ddx12; + vxi16_t ddx14; + vxi16_t ddx16; + vxi16_t ddx18; + vxi16_t ddx1a; + vxi16_t ddx1c; + vxi16_t ddx1e; + vxi16_t ddx20; + vxi16_t ddx22; + vxi16_t ddx24; + vxi16_t ddx26; + vxi16_t ddx28; + vxi16_t ddx2a; + vxi16_t ddx2c; + vxi16_t ddx2e; +}; + +struct vxi_csr_w{ + vxi16_t addr; + vxi16_t pad0; + vxi16_t control; + vxi16_t offset; + union { + struct vxi_msg_dev_w msg; + struct vxi_mxi_dev_w mxi; + struct vxi_reg_dev_w reg; + struct vxi_reg_slot0_dev_w reg_s0; + }dd; +}; + +struct vxi_msg_dev_r{ + vxi16_t protocol; + vxi16_t response; + vxi16_t dhigh; + vxi16_t dlow; +}; + +struct vxi_mxi_dev_r{ + vxi16_t modid; + vxi16_t la_window; + vxi16_t a16_window; + vxi16_t a24_window; + vxi16_t a32_window; + vxi16_t dd5; + vxi16_t dd6; + vxi16_t dd7; + vxi16_t dd8; + vxi16_t dd9; + vxi16_t dd10; + vxi16_t subclass; + vxi16_t status; + vxi16_t lock; + vxi16_t irq; + vxi16_t read_la; + vxi16_t trigger_mode; + vxi16_t interrupt; + vxi16_t status_id; + vxi16_t trigger_config; + vxi16_t trigger_sync_ack; + vxi16_t trigger_async_ack; + vxi16_t irq_ack; +}; + +struct vxi_reg_dev_r{ + vxi16_t ddx08; + vxi16_t ddxoa; + vxi16_t ddx0c; + vxi16_t ddx0e; + vxi16_t ddx10; + vxi16_t ddx12; + vxi16_t ddx14; + vxi16_t ddx16; + vxi16_t ddx18; + vxi16_t ddx1a; + vxi16_t ddx1c; + vxi16_t ddx1e; + vxi16_t ddx20; + vxi16_t ddx22; + vxi16_t ddx24; + vxi16_t ddx26; + vxi16_t ddx28; + vxi16_t ddx2a; + vxi16_t ddx2c; + vxi16_t ddx2e; +}; + +struct vxi_reg_slot0_dev_r{ + vxi16_t modid; + vxi16_t ddxoa; + vxi16_t ddx0c; + vxi16_t ddx0e; + vxi16_t ddx10; + vxi16_t ddx12; + vxi16_t ddx14; + vxi16_t ddx16; + vxi16_t ddx18; + vxi16_t ddx1a; + vxi16_t ddx1c; + vxi16_t ddx1e; + vxi16_t ddx20; + vxi16_t ddx22; + vxi16_t ddx24; + vxi16_t ddx26; + vxi16_t ddx28; + vxi16_t ddx2a; + vxi16_t ddx2c; + vxi16_t ddx2e; +}; + +struct vxi_csr_r{ + vxi16_t make; + vxi16_t model; + vxi16_t status; + vxi16_t offset; + union { + struct vxi_msg_dev_r msg; + struct vxi_mxi_dev_r mxi; + struct vxi_reg_dev_r reg; + struct vxi_reg_slot0_dev_r reg_s0; + }dd; +}; + + +struct vxi_csr{ + union { + struct vxi_csr_w w; + struct vxi_csr_r r; + }dir; +}; + +typedef struct vxi_csr VXICSR; + +#define CSRRMEM(PSR,MEMBER) ( ((VXICSR *)(PSR))->MEMBER ) + +/* + * Reserved device types + */ +#define VXIMODELMASK(WD) ( (WD)&0xfff ) +#define VXIMODEL(PSR) ( (unsigned) VXIMODELMASK(CSRRMEM(PSR,dir.r.model)) ) +#define VXIMAKE(PSR) ( (unsigned) 0xfff&CSRRMEM(PSR,dir.r.make) ) +#define VXISLOT0MODELTEST(WD) ((WD)<0x100) +#define VXISLOT0MODEL(PCSR) (VXISLOT0MODELTEST(VXIMODEL(PCSR))) + +/* + * vxi device classes + */ +#define VXI_MEMORY_DEVICE 0 +#define VXI_EXTENDED_DEVICE 1 +#define VXI_MESSAGE_DEVICE 2 +#define VXI_REGISTER_DEVICE 3 +#define VXICLASS(PSR) ((unsigned)(0xc000&CSRRMEM(PSR,dir.r.make))>>14) +#define VXISUBCLASS(PSR) ((unsigned)CSRRMEM(PSR,dir.r.dd.mxi.subclass) ) +#define VXIMXI(PSR)\ +(VXICLASS(PSR)==VXI_EXTENDED_DEVICE ? VXISUBCLASS(PSR)==VXI_MXI_DEVICE : 0) +#define VXI_MXI_DEVICE 0xfffc +#define MXI_BASE_DEVICE 0xf +#define MXI_INTX_DEVICE 0xe +#define MXI_EXTENDED_TYPE(PSR) ((((unsigned)CSRRMEM(PSR,dir.r.status))>>10)&0xf) +#define MXIINTX(PSR) (MXI_EXTENDED_TYPE(PSR) == MXI_INTX_DEVICE) +#ifndef SRCepvxiLib +extern +#endif +char *vxi_device_class_names[] +#ifdef SRCepvxiLib + = { + "memory", + "extended", + "message", + "register"} +#endif +; + +/* + * A32/A24 address space + */ +#define VXIADDRSPACE(PSR) ( (unsigned long) 3&(CSRRMEM(PSR,dir.r.make)>>12) ) +#define VXIREQMEM(PSR) ( (unsigned long) 0xf&(CSRRMEM(PSR,dir.r.model)>>12) ) +#define VXIA24MEMSIZE(M) ( (long) 1<<(23-(M)) ) +#define VXIA32MEMSIZE(M) ( (long) 1<<(31-(M)) ) +#define VXI_ADDR_EXT_A24 0 +#define VXI_ADDR_EXT_A32 1 +#define VXI_ADDR_EXT_NONE 3 + +/* + * + * VXI vendor codes + * + */ +#define VXI_MAKE_HP 0xfff /* Hewlett Packard */ +#define VXI_MAKE_RD 0xffb /* Racal Dana */ +#define VXI_MAKE_NI 0xff6 /* National Instruments */ +#define VXI_MAKE_AT5 0xfa0 /* Los Alamos Natl Lab AT */ +#define VXI_MAKE_KSC 0xf29 /* Kinetic Systems */ +struct vxi_vendor_info{ + uint16_t make; + char *pvendor_name; +}; + +/* + * In decreasing order of vendor id + */ +#ifndef SRCepvxiLib + extern +#endif +struct vxi_vendor_info vxi_vi[] +#ifdef SRCepvxiLib += { + {VXI_MAKE_HP, "Hewlett-Packard"}, + {VXI_MAKE_RD, "Racal-Dana"}, + {VXI_MAKE_NI, "National Instruments"}, + {VXI_MAKE_AT5, "LANL AT5"}, + {VXI_MAKE_KSC, "Kinetic Systems"}, +} +#endif +; + + +/* + * MXI commands + * (for the MXI control register) + */ +#define MXI_UPPER_LOWER_BOUNDS 0x4000 +#define MXI_LA_WINDOW_SIZE_MASK 0x3 +#define MXIA24MASK (0xffff) +#define MXIA24MASKSIZE 16 +#define MXIA32MASK (0xffffff) +#define MXIA32MASKSIZE 24 +#define MXIA24ALIGN(A) (((unsigned long)(A)+MXIA24MASK)&~MXIA24MASK) +#define MXIA32ALIGN(A) (((unsigned long)(A)+MXIA32MASK)&~MXIA32MASK) + +/* + * applies to all vxi devices + */ +#define VXIMEMENBLMASK (0x8000) +#define VXIMEMENBL(PSR) (VXIMEMENBLMASK&CSRRMEM(PSR,dir.r.status)) +#define VXINDCDEVICESMASK (0xff) +#define VXINDCDEVICES(PSR) (VXINDCDEVICESMASK&CSRRMEM(PSR,dir.r.offset)) + +/* + * Register based slot zero + */ +#define VXIMODIDSTATUS(WD) ((WD)&0x4000?FALSE:TRUE) +#define VXIPASS 3 +#define VXIPASSEDSTATUS(WD) (((WD)>>2)&VXIPASS) + + +/* + * RULE C.4.4 + * + * The resource manager shall write all ones to the + * device dependent bits when writing to the control register + * + */ +#define VXISAFECONTROL 0x7fff /* sys fail inhibit, reset, no mem enbl */ +#define VXIMEMENBLCONTROL 0xfffc /* mem enbl, no sys fail inhibit, no reset */ + +#define VXI_SET_REG_MODID(PCSR, SLOT) \ +( ((VXICSR *)(PCSR))->dir.w.dd.reg_s0.modid = \ + 0x2000|1<<(SLOT) ) +#define VXI_CLR_ALL_REG_MODID(PCSR) \ +( ((VXICSR *)(PCSR))->dir.w.dd.reg_s0.modid = 0 ) + +/* + * vxi msg based functions + */ +#define VXIWRITEREADYMASK (0x0200) +#define VXIREADREADYMASK (0x0400) +#define VXIDIRMASK (0x1000) +#define VXIDORMASK (0x2000) +#define VXIFHSMMASK (0x0100) +#define VXIERRNOTMASK (0x0800) + +#define VXICMDRMASK (0x8000) +#define VXICMDR(PSR) (!(VXICMDRMASK&CSRRMEM(PSR,dir.r.dd.msg.protocol))) +#define VXIFHSMASK (0x0800) +#define VXIFHS(PSR) (!(VXIFHSMASK&CSRRMEM(PSR,dir.r.dd.msg.protocol))) +#define VXISHMMASK (0x0400) +#define VXISHM(PSR) (!(VXISHMMASK&CSRRMEM(PSR,dir.r.dd.msg.protocol))) +#define VXIMBINTMASK (0x1000) +#define VXIMBINT(PSR) (VXIMBINTMASK&CSRRMEM(PSR,dir.r.dd.msg.protocol)) +#define VXIVMEBMMASK (0x2000) +#define VXIVMEBM(PSR) (!(VXIVMEBMMASK&CSRRMEM(PSR,dir.r.dd.msg.protocol))) +#define VXISIGREGMASK (0x4000) +#define VXISIGREG(PSR) (!(VXISIGREGMASK&CSRRMEM(PSR,dir.r.dd.msg.protocol))) + +/* + * serial protocol errors + */ +#define MBE_NO_ERROR (0xff) +#define MBE_MULTIPLE_QUERIES (0xfd) +#define MBE_UNSUPPORTED_CMD (0xfc) +#define MBE_DIR_VIOLATION (0xfb) +#define MBE_DOR_VIOLATION (0xfa) +#define MBE_RR_VIOLATION (0xf9) +#define MBE_WR_VIOLATION (0xf8) + +/* + * vxi message based commands + */ +#define MBC_BEGIN_NORMAL_OPERATION 0xfcff +#define MBC_TOP_LEVEL_CMDR 0x0100 +#define MBC_READ_SERVANT_AREA 0xceff +#define MBC_BA 0xbc00 +#define MBC_BR 0xdeff +#define MBC_END 0x0100 +#define MBC_READ_PROTOCOL 0xdfff +#define MBC_ASSIGN_INTERRUPTER_LINE 0xaa00 +#define MBC_READ_INTERRUPTERS 0xcaff +#define MBC_READ_PROTOCOL_ERROR 0xcdff +#define MBC_GRANT_DEVICE 0xbf00 +#define MBC_IDENTIFY_COMMANDER 0xbe00 +#define MBC_CLEAR 0xffff + +/* + * async mode control commands + */ +#define MBC_ASYNC_MODE_CONTROL 0xa800 + +#define MBC_AMC_RESP_ENABLE 0x0000 +#define MBC_AMC_RESP_DISABLE 0x0008 +#define MBC_AMC_EVENT_ENABLE 0x0000 +#define MBC_AMC_EVENT_DISABLE 0x0004 + +#define MBC_AMC_RESP_INT_ENABLE 0x0000 +#define MBC_AMC_RESP_SIGNAL_ENABLE 0x0002 +#define MBC_AMC_EVENT_INT_ENABLE 0x0000 +#define MBC_AMC_EVENT_SIGNAL_ENABLE 0x0001 + +/* + * control resp command + * (enable all) + */ +#define MBC_CONTROL_RESPONSE 0x8fc0 + +/* + * msg based responses + */ +#define MBR_STATUS(RESP) (((RESP)>>12) & 0xf) +#define MBR_STATUS_SUCCESS 0xf +#define MBR_READ_SERVANT_AREA_MASK 0x00ff +#define MBR_CR_CONFIRM_MASK 0x007f + +/* + * read interrupters response + */ +#define MBR_READ_INTERRUPTERS_MASK 0x7 + +/* + * async mode control resp + */ +#define MBR_AMC_CONFIRM_MASK 0xf + +/* + * begin normal operation message based responses + */ +#define MBR_BNO_STATE(RESP) (((RESP)>>8) & 0xf) +#define MBR_BNO_STATE_NO 0xf + +/* + * read protocol message based responses + */ +#define MBR_RP_LW(RESP) (!((RESP)&0x1)) +#define MBR_RP_ELW(RESP) (!((RESP)&0x2)) +#define MBR_RP_I(RESP) (!((RESP)&0x4)) +#define MBR_RP_I4(RESP) (!((RESP)&0x8)) +#define MBR_RP_TRG(RESP) (!((RESP)&0x10)) +#define MBR_RP_PH(RESP) (!((RESP)&0x20)) +#define MBR_RP_PI(RESP) (!((RESP)&0x40)) +#define MBR_RP_EG(RESP) (!((RESP)&0x100)) +#define MBR_RP_RG(RESP) (!((RESP)&0x200)) +#define MBR_REV_12(RESP) (!((RESP)&0x8000)) + +/* + * protocol events + * vxi spec E.4 + */ +#define MBE_EVENT_TEST(EVENT) ((EVENT)&0x1000) + +/* + * vxi trigger constants + */ +#define VXI_N_TTL_TRIGGERS 8 +#define VXI_N_ECL_TRIGGERS 6 +#define MXI_ECL0_ENABLE 0x0800 +#define MXI_ECL0_FP_TO_BP 0x0400 +#define MXI_ECL0_BP_TO_FP 0 +#define MXI_ECL1_ENABLE 0x2000 +#define MXI_ECL1_FP_TO_BP 0x1000 +#define MXI_ECL1_BP_TO_FP 0 + +#endif /* INCvxih */ diff --git a/src/drv/old/Makefile.Vx b/src/drv/old/Makefile.Vx index d2b95599d..8408f7229 100644 --- a/src/drv/old/Makefile.Vx +++ b/src/drv/old/Makefile.Vx @@ -8,6 +8,16 @@ include $(EPICS)/config/CONFIG_BASE USR_CFLAGS = -fshared-data -fvolatile -mnobitfield -traditional +INC += drvBB232.h +INC += drvBitBusErr.h +INC += drvBitBusInterface.h +INC += drvMsg.h +INC += drvGpibInterface.h +INC += drvGpibErr.h +INC += drvHiDEOSGpib.h +INC += drvRs232.h +INC += drvTy232.h + SRCS.c += ../module_types.c SRCS.c += ../drvBB232.c SRCS.c += ../drvBb902.c diff --git a/src/drv/old/drvBB232.h b/src/drv/old/drvBB232.h new file mode 100644 index 000000000..d90bb1a69 --- /dev/null +++ b/src/drv/old/drvBB232.h @@ -0,0 +1,69 @@ +/* share/epicsH $Id$ */ +/* + * Author: John Winans + * Date: 5-21-92 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1988, 1989, 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 + * + * All rights reserved. No part of this publication may be reproduced, + * stored in a retrieval system, transmitted, in any form or by any + * means, electronic, mechanical, photocopying, recording, or otherwise + * without prior written permission of Los Alamos National Laboratory + * and Argonne National Laboratory. + * + * Modification Log: + * ----------------- + * .01 05-21-92 jrw Initial release + * .02 02-19-92 joh cpu independent clk rate + */ + +#ifndef DRVBB232_H +#define DRVBB232_H + +/****************************************************************************** + * + * Additional fields needed for the msgParmBlock structure. + * + ******************************************************************************/ +typedef struct { + int dmaTimeout; /* Clock ticks to wait for DMA to complete */ + int baud; /* baud rate to run the interface */ +} drvBB232ParmBlock; + +typedef struct { + int link; /* The BB card/link number */ + int node; /* the bug's node number */ + int port; /* The tty port number on that card */ + /* The pparmBlock is used to make sure only 1 device type is requested */ + /* on one single port. */ + msgParmBlock *pparmBlock; +} drvBB232Link; + +#ifndef DRVBB232_C +extern +#endif +msgDrvBlock drvBB232Block; + +#define BB232_DEFAULT_AGE (sysClkRateGet()) /* 1 second */ + +#define BB_232_EOI 0x20 +#endif diff --git a/src/drv/old/drvBitBusErr.h b/src/drv/old/drvBitBusErr.h new file mode 100644 index 000000000..160861d25 --- /dev/null +++ b/src/drv/old/drvBitBusErr.h @@ -0,0 +1,43 @@ +/* share/src/drv/drvBitBusErr.h $Id$ */ +/* Author: John Winans + * Date: 12-5-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-05-91 jrw Written + */ + +#ifndef BITBUS_ERRORS +#define BITBUS_ERRORS + +#include /* pick up the M_bitbus value */ + +#define S_BB_ok (M_bitbus|0| 0<<1) /* success */ +#define S_BB_badPrio (M_bitbus|1| 1<<1) /* Invalid xact request queue priority */ +#define S_BB_badlink (M_bitbus|1| 2<<2) /* Invalid bitbus link number */ +#define S_BB_rfu2 (M_bitbus|1| 3<<2) /* reserved for future use #2 */ +#define S_BB_rfu3 (M_bitbus|1| 4<<2) /* reserved for future use #3 */ +#define S_BB_rfu4 (M_bitbus|1| 5<<2) /* reserved for future use #4 */ + +#endif diff --git a/src/drv/old/drvBitBusInterface.h b/src/drv/old/drvBitBusInterface.h new file mode 100644 index 000000000..911649ba4 --- /dev/null +++ b/src/drv/old/drvBitBusInterface.h @@ -0,0 +1,273 @@ +/* drvBitBusInterface.h */ +/* share/src/drv %W% %G% */ +/* Author: John Winans + * Date: 09-10-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-30-91 jrw Written + * .02 12-02-91 jrw Added errMessage support + * .03 12-10-91 jrw moved in some stuff in from drvBitBus.h + */ + +#ifndef BITBUS_INTERFACE +#define BITBUS_INTERFACE + +#include + +int drvBitBusDumpMsg(); + +#define BB_APERLINK 256 /* node 255 is the master */ + +#define BB_Q_LOW 0 +#define BB_Q_HIGH 1 + +#define BB_NUM_PRIO 2 /* total number of priorities */ + +struct drvBitBusEt { + long number; + DRVSUPFUN report; /* Report on the status of the Bit Bus links */ + DRVSUPFUN init; /* Init the xvme card */ + DRVSUPFUN qReq; /* Queue a transaction request */ +}; + +#define BB_MSG_HEADER_SIZE 7 +#define BB_MAX_DAT_LEN 13 /* message data len on 8044 */ +#define BB_MAX_MSG_LENGTH BB_MSG_HEADER_SIZE + BB_MAX_DAT_LEN + +/* BitBus Transaction Message Structure */ +struct bitBusMsg { + unsigned short link; /* account for this in length only! */ + unsigned char length; + unsigned char route; + unsigned char node; + unsigned char tasks; + unsigned char cmd; + unsigned char *data; +}; + +/****************************************************************************** + * + * Any I/O request made must consist of a structure that begins with the + * following fields. + * + ******************************************************************************/ +struct dpvtBitBusHead { + int (*finishProc)(); /* callback task invoked in not NULL with RX */ + int priority; /* callback task priority */ + + SEM_ID *psyncSem; /* if not NULL, points to sem given w/RX */ + + struct dpvtBitBusHead *next; /* used to link dpvt's together */ + struct dpvtBitBusHead *prev; /* used to link dpvt's together */ + + int link; /* xvme link number */ + struct bitBusMsg txMsg; /* message to transmit on the link */ + struct bitBusMsg rxMsg; /* response from the node */ + int rxMaxLen; /* max length of the receive buffer */ + int status; /* message xfer status */ + unsigned char rxCmd; /* the command byte that signaled message end */ + + int ageLimit; /* Set in to max allowed age */ + unsigned long retire; /* used by the driver to time out xacts */ +}; + +/****************************************************************************** + * + * Valid dpvtHead.status from the driver are: + * + ******************************************************************************/ +#define BB_OK 0 /* all went as expected */ +#define BB_LENGTH 1 /* received message overflowed the buffer */ +#define BB_NONODE 2 /* transmit message to non-existant node */ +#define BB_TIMEOUT 3 /* response took too long from node */ + +#if 0 /* JRW moved to drvBitbus.h */ +/****************************************************************************** + * + * The BUSY/IDLE notion is used to count the number of outstanding + * messages for a specific node. The idea is that up to BUSY messages + * can be sent to a node before waiting before deciding not to send any more. + * According to the BitBus specs, this value is 7. However, it also + * states that responses can come back out of order. If this is even true + * for messages sent to the SAME TASK ON THE SAME NODE, the received messages + * CAN NOT be routed back to their initiators properly. Because the node# + * and task# is all we have to identify what a response message is for, + * I am limiting the per-node maximum to 1. + * + ******************************************************************************/ + +#define BB_BUSY 1 /* deviceStatus value if device is currently busy */ +#define BB_IDLE 0 /* deviceStatus value if device is currently idle */ + +struct bbList { + struct dpvtBitBusHead *head; /* head of the linked list */ + struct dpvtBitBusHead *tail; /* tail of the linked list */ + int elements; /* holds number of elements on the list */ + SEM_ID sem; /* semaphore for the queue list */ +}; + +/****************************************************************************** + * + * The bbLink structure holds all the required link-specific queueing + * information. + * + ******************************************************************************/ +struct bbLink { + int linkType; /* the type of link (defined in link.h) */ + int linkId; /* the link number of this structure */ + + int nukeEm; /* manual link restart flag */ + + SEM_ID linkEventSem; /* given when this link requires service */ + + struct bbList queue[BB_NUM_PRIO]; /* prioritized request queues */ + + /* + * In order to modify either the busyList entries or the deviceStatus + * table, the busyList.sem MUST be held first. + */ + struct bbList busyList; /* messages waiting on a response */ + unsigned char deviceStatus[BB_APERLINK];/* mark a device as idle or busy */ +}; +#endif + +#define BB_STANDARD_TX_ROUTE 0x40 /* Route value for TX message */ + +#define BB_RAC_TASK 0x00 /* RAC task ID */ +#define BB_GPIB_TASK 0x01 /* GPIB task ID */ +#define BB_232_TASK 0x01 /* RS232 task ID */ + +/****************************************************************************** + * + * Common commands that are supported by all non-RAC tasks. + * + ******************************************************************************/ + +#define BB_IDENTIFY 0x00 /* request ID word */ + +#define BB_ID_GPIB 1 +#define BB_ID_232 2 + +#define BB_MOD_NONE 0 /* task not altered */ +#define BB_MOD_DIG500 1 /* task altered to talk to DIG500 */ + +struct bbIdWord { + unsigned int taskType; /* One of BB_ID_* */ + unsigned int taskMods; /* One of BB_MOD_* */ + unsigned int revCode; /* Revision code number of the BUG's code */ +}; + +/****************************************************************************** + * + * List of GPIB command definitions (defined by the GPIB-BUG interface spec) + * + ******************************************************************************/ +#define BB_232_CMD 0x60 /* or'd with the port number */ +#define DD_232_PORT 0x1F /* port number is lowest 5 bits */ +#define BB_232_BREAK 0x40 /* or'd with the port number */ + +/****************************************************************************** + * + * List of GPIB command definitions (defined by the GPIB-BUG interface spec) + * + ******************************************************************************/ + +#define BB_IBCMD_IFC 1 /* set IFC for about 1/2 second */ +#define BB_IBCMD_READ 2 /* read <=13 bytes from GPIB */ +#define BB_IBCMD_WRITE 3 /* write <=13 bytes to GPIB */ +#define BB_IBCMD_WRITE_EOI 4 /* write <=13 bytes w/EOI on last */ +#define BB_IBCMD_WRITE_CMD 5 /* write <=13 bytes w/ATN high */ +#define BB_IBCMD_SET_TMO 6 /* set the timeout delay value */ + +/* For the sake of completeness, an or-mask for the non-addressable commands */ +#define BB_IBCMD_NOADDR 0x00 /* non-addressed command group */ + +/* to use the following commands, or the decice address with the command */ +#define BB_IBCMD_WRITE_XACT 0x20 /* cmd|address writes 13 w/EOI */ +#define BB_IBCMD_ADDR_WRITE 0x40 /* cmd|address writes 13 bytes */ +#define BB_IBCMD_READ_XACT 0x60 /* cmd|address wite 13 & read back */ + +/* + * The status response bits to a GPIB command are set as follows: + * + * 7 - UNDEF + * 6 - UNDEF + * 5 - 1 if read ended with EOI + * 4 - 1 if SRQ is currently HIGH + * 3 - UNDEF + * 2 - UNDEF + * 1 - UNDEF + * 0 - 1 if timeout occurred + */ +#define BB_IBSTAT_EOI 0x20 +#define BB_IBSTAT_SRQ 0x10 +#define BB_IBSTAT_TMO 0x01 + +/****************************************************************************** + * + * Partial List of RAC Command Definitions (defined in BitBus Specification) + * + ******************************************************************************/ +#define RAC_RESET_SLAVE 0x00 +#define RAC_CREATE_TASK 0x01 +#define RAC_DELETE_TASK 0x02 +#define RAC_GET_FUNC_IDS 0x03 +#define RAC_PROTECT 0x04 +#define RAC_READ_IO 0x05 +#define RAC_WRITE_IO 0x06 +#define RAC_UPDATE_IO 0x07 +#define RAC_UPLOAD_MEM 0x08 +#define RAC_DOWNLOAD_MEM 0x09 +#define RAC_OR_IO 0x0A +#define RAC_AND_IO 0x0B +#define RAC_XOR_IO 0x0C +#define RAC_STATUS_READ 0x0D +#define RAC_STATUS_WRITE 0x0E +#define RAC_NODE_INFO 0x0F +#define RAC_OFFLINE 0x10 +#define RAC_UPLOAD_CODE 0x11 +#define RAC_DOWNLOAD_CODE 0x12 + + +/* Reply message Command Byte Definitions */ +#define BB_NO_ERROR 0x00 + +/* 0x01 thru 0x7F are user defined */ +#define BB_SEND_TMO 0x70 + +/* 0x80 thru 0xFF are defined by BitBus */ +#define BB_NO_DEST_TASK 0x80 +#define BB_TASK_OVERFLOW 0x81 +#define BB_REG_BANK_OVERFLOW 0x82 +#define BB_DUP_FUNC_ID 0x83 +#define BB_NO_BUFFERS 0x84 + +#define BB_PROTOCOL_ERR 0x91 +#define BB_NO_DEST_DEV 0x93 +#define BB_RAC_PROTECTED 0x95 +#define BB_UNKNOWN_RAC_CMND 0x96 + +#endif + diff --git a/src/drv/old/drvGpibErr.h b/src/drv/old/drvGpibErr.h new file mode 100644 index 000000000..ac7512ff9 --- /dev/null +++ b/src/drv/old/drvGpibErr.h @@ -0,0 +1,44 @@ +/* share/epicsH/drvGpibErr.h $Id$ */ +/* Author: John Winans + * Date: 12-5-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-13-91 jrw created + */ + + +#ifndef GPIB_ERRORS +#define GPIB_ERRORS + +#include /* pick up the M_gpib value */ + +#define S_IB_ok (M_gpib|0| 0<<1) /* success */ +#define S_IB_badPrio (M_gpib|1| 1<<1) /* invalid xact request queue priority */ +#define S_IB_A24 (M_gpib|1| 2<<2) /* Out of A24 RAM */ +#define S_IB_SIZE (M_gpib|1| 3<<2) /* GPIB I/O buffer size exceeded */ +#define S_IB_rfu3 (M_gpib|1| 4<<2) /* reserved for future use #3 */ +#define S_IB_rfu4 (M_gpib|1| 5<<2) /* reserved for future use #4 */ + +#endif diff --git a/src/drv/old/drvGpibInterface.h b/src/drv/old/drvGpibInterface.h new file mode 100644 index 000000000..571c1926d --- /dev/null +++ b/src/drv/old/drvGpibInterface.h @@ -0,0 +1,176 @@ +/* #define GPIB_SUPER_DEBUG */ + +/* Author: John Winans + * Date: 09-10-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-13-91 jrw Written on Friday the 13th :-( + * .02 11-07-91 jrw added srqPollInhibit() to the drvGpibSet + * .03 01-07-92 jrw added a reference to ibLink in dpvtGpibHead + * + * $Log$ + * Revision 1.11 1995/03/17 21:25:58 winans + * Got rid of the old bogus header in the dpvtGpibHead structure. + * + * Revision 1.10 1994/12/12 19:00:16 winans + * Disabled the GPIB_SUPER_DEBUG by default. + * + */ + + +#ifndef GPIB_INTERFACE +#define GPIB_INTERFACE + +#include +#include +#include +#include /* To resolve the bitbus struct in dpvt */ + +#ifdef GPIB_SUPER_DEBUG + +#define GPIB_SUPER_DEBUG_HISTORY_SIZ 200 +#define GPIB_SUPER_DEBUG_HISTORY_STRLEN 150 +/* Super untra detailed debugging stuff used to log everything. */ + +typedef struct HistoryMsg +{ + unsigned long Time; + int DevAddr; + char Msg[GPIB_SUPER_DEBUG_HISTORY_STRLEN]; +} HistoryMsgStruct; +typedef struct HistoryStruct +{ + SEM_ID Sem; + unsigned long Next; /* Next slot to use in message table */ + unsigned long Num; /* Total number of messages */ + HistoryMsgStruct Hist[GPIB_SUPER_DEBUG_HISTORY_SIZ]; +} HistoryStruct; + +#endif + +#define BUSY 1 /* deviceStatus value if device is currently busy */ +#define IDLE 0 /* deviceStatus value if device is currently idle */ + +#define TADBASE 0x40 /* offset to GPIB listen address 0 */ +#define LADBASE 0x20 /* offset to GPIB talk address 0 */ + +#define IB_Q_LOW 1 /* priority levels for qGpibReq() */ +#define IB_Q_HIGH 2 + +#define IBAPERLINK 32 /* max number of gpib addresses per link */ + + +/* IOCTL commands supported by the driver */ + +#define IBNILNK 0 /* returns the max allowable NI links */ +#define IBTMO 3 /* one time timeout setting for next GPIB command */ +#define IBIFC 4 /* send an interface clear pulse */ +#define IBREN 5 /* turn on or off the REN line */ +#define IBGTS 6 /* go to controller standby (ATN off...) */ +#define IBGTA 7 /* go to active state */ +#define IBGENLINK 8 /* ask the driver to start a link running */ +#define IBGETLINK 9 /* request address of the ibLink structure */ + +#define SRQRINGSIZE 50 /* max number of events stored in the SRQ event ring */ + +#define POLLTIME 5 /* time to wait on DMA during polling */ + +/****************************************************************************** + * + * This structure defines the device driver's entry points. + * + ******************************************************************************/ +struct drvGpibSet { + long number; + DRVSUPFUN report; + DRVSUPFUN init; + int (*qGpibReq)(); + int (*registerSrqCallback)(); + int (*writeIb)(); + int (*readIb)(); + int (*writeIbCmd)(); + int (*ioctl)(); + int (*srqPollInhibit)(); +}; + +/****************************************************************************** + * + * The ibLink structure holds all the required link-specific data. + * + ******************************************************************************/ +struct ibLink { + int linkType; /* the type of link (defined in link.h) */ + int linkId; /* the link number of this structure */ + int bug; /* bug address if is a bb->gpib connection */ + + SEM_ID linkEventSem; /* given when this link requires service */ + + ELLLIST hiPriList; /* list head for high priority queue */ + SEM_ID hiPriSem; /* semaphore for high priority queue */ + ELLLIST loPriList; /* list head for low priority queue */ + SEM_ID loPriSem; /* semaphore for low priority queue */ + RING_ID srqRing; /* srq event queue */ + int (*srqHandler[IBAPERLINK])(); /* registered srq handlers for link */ + caddr_t srqParm[IBAPERLINK]; /* parms to pass to the srq handlers */ + + char deviceStatus[IBAPERLINK]; /* mark a device as idle or busy */ + char pollInhibit[IBAPERLINK]; /* mark a device as non-pollable */ + char srqIntFlag; /* set to 1 if an SRQ interrupt has occurred */ +#ifdef GPIB_SUPER_DEBUG + HistoryStruct History; +#endif +}; + +/****************************************************************************** + * + * This structure represents the items that are placed on the ibLink->srqRing. + * + ******************************************************************************/ +struct srqStatus{ + unsigned char device; /* device number */ + unsigned char status; /* data from the srq poll */ +}; + + +/****************************************************************************** + * + * All gpib records must have device private structures that begin with the + * following structure. + * + ******************************************************************************/ +struct dpvtGpibHead { + ELLNODE list; + CALLBACK callback; + + int (*workStart)(); /* work start function for the transaction */ + int link; /* GPIB link number */ + int device; /* GPIB device address for transaction */ + struct ibLink *pibLink; /* used by driver */ + struct dpvtBitBusHead *bitBusDpvt; /* used on bitbus->gpib links */ + int dmaTimeout; +}; + +int GpibDebug(struct ibLink *pIbLink, int Address, char *Msg, int DBLevel); +#endif diff --git a/src/drv/old/drvHiDEOSGpib.h b/src/drv/old/drvHiDEOSGpib.h new file mode 100644 index 000000000..3938f3d22 --- /dev/null +++ b/src/drv/old/drvHiDEOSGpib.h @@ -0,0 +1,12 @@ + +#ifndef EPICS_DRVHIDEOSGPIB_H +#define EPICS_DRVHIDEOSGPIB_H + +typedef int (*GPIB_HIDEOS_WRITECMD_FUNC)(void *td, char *Buf, unsigned long BufLen, unsigned long TimeOut); +typedef int (*GPIB_HIDEOS_WRITE_FUNC)(void *td, char *Buf, unsigned long BufLen, unsigned long devAddr, unsigned long TimeOut); +typedef void *(*GPIB_HIDEOS_INIT_FUNC)(int BoardId, char *TaskName); +typedef int (*GPIB_HIDEOS_READ_FUNC)(void *td, char *Buf, unsigned long BufLen, unsigned long *Actual, unsigned long devAddr, unsigned long TimeOut); +typedef int (*GPIB_HIDEOS_WRITEREAD_FUNC)(void *td, char *WBuf, unsigned long WBufLen, char *RBuf, unsigned long RBufLen, unsigned long *RActual, unsigned long devAddr, unsigned long TimeOut); + + +#endif diff --git a/src/drv/old/drvMsg.h b/src/drv/old/drvMsg.h new file mode 100644 index 000000000..c2c66a69b --- /dev/null +++ b/src/drv/old/drvMsg.h @@ -0,0 +1,485 @@ +/* share/epicsH $Id$ */ +/* + * Author: John Winans + * Date: 11-19-91 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1988, 1989, 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 + * + * All rights reserved. No part of this publication may be reproduced, + * stored in a retrieval system, transmitted, in any form or by any + * means, electronic, mechanical, photocopying, recording, or otherwise + * without prior written permission of Los Alamos National Laboratory + * and Argonne National Laboratory. + * + * Modification Log: + * ----------------- + * .02 05-26-92 jrw added enumeration of record types + * .03 08-10-92 jrw cleaned up the documentation + * & removed multi-parm stuff + */ + +#ifndef DEVXXMSG_H +#define DEVXXMSG_H +/****************************************************************************** + * + * This structure holds device-related data on a per-device basis and is + * referenced by the xact structures. They are built using a linked + * list starting from parmBlock.phwpvt. There is one linked list for each + * specific device type. + * + * Different types of device links could have different formatted hwpvt structs. + * The msgHwpvt structure includes those fields that are common to all device + * types. The customized part should be attached to msgHwpvt.p during the + * genHwpvt phase if the initilization process. + * + ******************************************************************************/ +struct msgHwpvt { + struct msgHwpvt *next; /* Next structure for same type device */ + + struct msgLink *pmsgLink; /* Associated link structure */ + + unsigned long tmoVal; /* Time last timeout occurred */ + unsigned long tmoCount; /* Total timeouts since boot time */ + + void *p; /* Place to add device-specific fields */ +}; +typedef struct msgHwpvt msgHwpvt; +/****************************************************************************** + * + * Any I/O request made must consist of the msgXact structure defined below. + * + * In general, one EPICS database record will have one and only one of these + * msgXact attached to it's dbCommon.dpvt field. + * + * The message driver system does not reference any database record fields that + * are not in dbCommon -- unless a user-provided function calls a + * record-specific support function. + * + ******************************************************************************/ +struct msgXact { + CALLBACK callback; + SEM_ID *psyncSem; /* if not NULL, points to sem given w/RX */ + + struct msgXact *next; /* used to link dpvt's together */ + struct msgXact *prev; /* used to link dpvt's together */ + + struct msgHwpvt *phwpvt; /* assoc'd hwpvt structure */ + struct msgParmBlock *pparmBlock; /* assoc'd parm block */ + struct dbCommon *prec; /* useful to msg based device support */ + unsigned int parm; /* operation parm number */ + int status; /* transaction completion status */ + + void *p; /* A place to add on device specific data */ +}; +typedef struct msgXact msgXact; +/****************************************************************************** + * + * Valid msgXact.status values are: + * + ******************************************************************************/ +#define XACT_OK 0 /* all went as expected */ +#define XACT_LENGTH 1 /* received message overflowed the buffer */ +#define XACT_TIMEOUT 3 /* response took too long from node */ +#define XACT_BADLINK 4 /* request sent to an invalid link number */ +#define XACT_BADPRIO 5 /* request had bad queueing priority */ +#define XACT_IOERR 6 /* some sort of I/O error occurred */ +#define XACT_BADCMD 7 /* bad command ID-number */ + +/****************************************************************************** + * + * Transaction requests are placed on queues (by the drvMsg_qXact() function) + * when submitted. These queues are described with the xactQueue structure. + * + ******************************************************************************/ +struct xactQueue { + struct msgXact *head; /* head of the linked list */ + struct msgXact *tail; /* tail of the linked list */ + FAST_LOCK lock; /* semaphore for the queue list */ +}; +typedef struct xactQueue xactQueue; +/****************************************************************************** + * + * A task is started to manage each message based link. It uses the msgLink + * structure to access the queues of work. + * + * A link is defined by the device-specific part of the genHwpvt() function. + * A link task will be started if the genHwpvt() function invokes the genLink() + * function to define a new link. + * + ******************************************************************************/ +struct msgLink{ + struct xactQueue queue[NUM_CALLBACK_PRIORITIES]; /* prioritized request queues */ + struct msgLink *next; /* next in msgDrvBlock list */ + SEM_ID linkEventSem; + void *p; /* A place to add on device specific data */ +}; +typedef struct msgLink msgLink; +/****************************************************************************** + * + * The msgParmBlock is defined by the user-contributed device support module. + * It is used to tell the message-driver what device driver to used to perform + * the I/O operations as well as to provide access to the command table, and + * other parameters. + * + * The msgParmBlock contains those parts that are common to all device types. + * Some devices may require more operating parameters. These additional + * parameters should be added via msgParmBlock.p. + * + ******************************************************************************/ +struct msgParmBlock{ + int *debugFlag; /* pointer to debug flag */ + struct msgHwpvt *pmsgHwpvt; /* pointer to the hwpvt list for device type */ + struct msgCmd *pcmds; /* pointer to command list */ + int numCmds; /* number of elements in the command list */ + char *name; /* pointer to a string containing device name */ + struct msgDrvBlock *pdrvBlock; /* link to the driver hook data structure */ + DRVSUPFUN doOp; /* user spec'd operation wedge function */ + void *p; /* A place to add device specific data */ +}; +typedef struct msgParmBlock msgParmBlock; + +/****************************************************************************** + * + * The msgCmd structure is used to define each entry in the command table. + * This table is used to define all the commands that a specific device type + * can handle. + * + * When a transaction is processed, the following happens: + * + * 1) if A defered read event has occurred, cmd.readOp is called. + * otherwise: + * 1) if cmd.writeOp is non-NULL, it is called and passed wrParm + * The job of writeOp is to send a string to the instrument + * 2) if cmd.readOp is non-NULL, it is called and passed rdParm + * The job of readOp is to read a string from the instrument + * + ******************************************************************************/ +struct msgCmdOp { + unsigned int op; + void *p; +}; +typedef struct msgCmdOp msgCmdOp; + +struct msgCmd{ + struct msgRecEnum *recTyp;/* used to indicate record type supported */ + unsigned int flags; /* 1 if readback is deferred, 0 if not */ + + struct msgCmdOp writeOp; + struct msgCmdOp readOp; + + struct devMsgNames *namelist;/* pointer to name strings */ + int companion; +}; +typedef struct msgCmd msgCmd; + +/* Possible values for msgCmd.flags (OR the set required together) */ +#define READ_NDLY 0 /* Do read now */ +#define READ_DEFER 1 /* Defer read, an event will signal it */ + +/****************************************************************************** + * + * Valid writeOp and readOp values. + * + * Any user-add-on codes start at MSG_OP_USER and continue upward. + * + ******************************************************************************/ +#define MSG_OP_NOP 0 /* Do nothing */ +#define MSG_OP_WRITE 1 /* Unformatted character write */ + +#define MSG_OP_FAI 2 /* Read and parse an analog input */ +#define MSG_OP_FAO 3 /* Format and output an analog output */ +#define MSG_OP_FBI 4 /* Read and parse */ +#define MSG_OP_FBO 5 /* Format and output */ +#define MSG_OP_FMI 6 /* Read and parse */ +#define MSG_OP_FMO 7 /* Format and output */ +#define MSG_OP_FLI 8 /* Read and parse */ +#define MSG_OP_FLO 9 /* Format and output */ +#define MSG_OP_FSI 10 /* Read and parse */ +#define MSG_OP_FSO 11 /* Format and output */ + +#define MSG_OP_RSI 12 /* Read a string raw */ +#define MSG_OP_RSO 13 /* Write a string raw */ + +#define MSG_OP_ACK 14 /* Read string and set alarm if not match */ + +#define MSG_OP_SBI 15 /* Read string, set BI on substring comparison */ + +/* NOT CURRENTLY SUPPORTED OPERATIONS */ +#if FALSE +#define MSG_OP_EBI /* enumerated operations */ +#define MSG_OP_EBO +#define MSG_OP_EMI +#define MSG_OP_EMO +#endif + +#define MSG_OP_USER 200 /* Start of user added operation codes */ + +/****************************************************************************** + * + * The following represent the op-codes that can be passed to the + * msgDrvBlock.genlink function. + * + ******************************************************************************/ +#define MSG_GENLINK_CREATE 0 /* Create structures for a new link */ +#define MSG_GENLINK_ABORT 1 /* Link failed init */ + +/****************************************************************************** + * + * Codes that can be returned from event checker routines. + * + ******************************************************************************/ +#define MSG_EVENT_NONE 0 +#define MSG_EVENT_READ 1 +#define MSG_EVENT_WRITE 2 + +/****************************************************************************** + * + * This is used to define the strings that are used for button labels. + * These strings are put into the record's znam & onam foelds if the + * record is a BI or BO type and into the zrst, onst... fields of an + * MBBI or MBBO record. + * + * Before these strings are placed into the record, the record is + * check to see if there is already a string defined (could be user-entered + * with DCT.) If there is already a string present, it will be preserved. + * + * There MUST ALWAYS be 2 and only 2 entries in the names.item list + * for BI and BO records if a name list is being specified for them here. + * The names.count field is ignored for BI and BO record types, but + * should be properly specified as 2 for future compatibility. + * + * NOTE: + * If a name string is filled in an an MBBI/MBBO record, it's corresponding + * value will be filled in as well. For this reason, there MUST be + * a value array and a valid nobt value for every MBBI/MBBO record that + * contains an item array! + * + ******************************************************************************/ + +struct drvMsgNames { + int count; /* CURRENTLY only used for MBBI and MBBO */ + char **item; + unsigned long *value; /* CURRENTLY only used for MBBI and MBBO */ + short nobt; /* CURRENTLY only used for MBBI and MBBO */ +}; +typedef struct drvMsgNames drvMsgNames; +/****************************************************************************** + * + * Public functions available from the message driver. + * + ******************************************************************************/ +msgXact *drvMsg_genXact(); +msgHwpvt *drvMsg_genHwpvt(); +msgLink *drvMsg_genLink(); +long drvMsg_qXact(); +long drvMsg_reportMsg(); +long drvMsg_initMsg(); +long drvMsg_xactWork(); +long drvMsg_initCallback(); +long drvMsg_checkParm(); +long drvMsg_drvWrite(); +long drvMsg_drvRead(); + +long drvMsg_initAi(), drvMsg_initAo(); +long drvMsg_initBi(), drvMsg_initBo(); +long drvMsg_initMi(), drvMsg_initMo(); +long drvMsg_initLi(), drvMsg_initLo(); +long drvMsg_initSi(), drvMsg_initSo(); +long drvMsg_initWf(); + +long drvMsg_procAi(), drvMsg_procAo(); +long drvMsg_procBi(), drvMsg_procBo(); +long drvMsg_procMi(), drvMsg_procMo(); +long drvMsg_procLi(), drvMsg_procLo(); +long drvMsg_procSi(), drvMsg_procSo(); +long drvMsg_procWf(); + +long drvMsg_proc(); + +/****************************************************************************** + * + * The msgDrvBlock is used by a message driver designer to specify functions + * that are to be invoked to initialize structures and to check for events + * that might have caused the link task to wake up. This is where hooks to + * device specific functions and data structures are added to the message + * based driver. + * + ******************************************************************************/ +struct msgDrvBlock{ + char *taskName; /* Used for the taskSpawn and messages */ + int taskPri; /* Used for the taskSpawn */ + int taskOpt; /* Used for the taskSpawn */ + int taskStack; /* Used for the taskSpawn */ + struct msgLink *pmsgLink; /* associated msgLink list head */ + + DRVSUPFUN drvWrite; /* Write string from buffer */ + DRVSUPFUN drvRead; /* Read string into buffer */ + DRVSUPFUN drvIoctl; /* perform device specific control function */ +}; +typedef struct msgDrvBlock msgDrvBlock; + +/* IOCTL functions that each message driver MUST support */ +#define MSGIOCTL_REPORT 0 +#define MSGIOCTL_INIT 1 +#define MSGIOCTL_INITREC 2 +#define MSGIOCTL_GENXACT 3 +#define MSGIOCTL_GENHWPVT 4 +#define MSGIOCTL_GENLINK 5 +#define MSGIOCTL_CHECKEVENT 6 +#define MSGIOCTL_COMMAND 7 /* device-type specific */ + +/****************************************************************************** + * + * The parameter passed to the IOCTL function is different depending on the + * function-code used in the IOCTL call. These parameters are defined below. + * + ******************************************************************************/ +struct msgDrvIniParm { + int parm; + struct msgDset *pdset; +}; +typedef struct msgDrvIniParm msgDrvIniParm; + +struct msgDrvGenXParm { + struct link *plink; + struct msgXact *pmsgXact; +}; +typedef struct msgDrvGenXParm msgDrvGenXParm; + +struct msgDrvGenHParm { + struct msgParmBlock *pparmBlock; + struct link *plink; + struct msgHwpvt *pmsgHwpvt; +}; +typedef struct msgDrvGenHParm msgDrvGenHParm; + +struct msgDrvGenLParm { + struct msgLink *pmsgLink; + struct link *plink; + int op; + struct msgParmBlock *pparmBlock; +}; +typedef struct msgDrvGenLParm msgDrvGenLParm; + +struct msgChkEParm { + struct msgDrvBlock *pdrvBlock; + struct msgLink *pmsgLink; + struct msgXact **pxact; +}; +typedef struct msgChkEParm msgChkEParm; + +/****************************************************************************** + * + * Each DSET ppoints to a msgRecEnum structure. This structure defines the + * type of record the dset represents. The idea here is that the address + * of this structure represents the enumeration value for a given record type. + * + * New record types may be added by the application developer + * by defining a msgRecEnum structure and then using its address in the + * DSET for the new record type. + * + * In the future it is intended that this structure be used to describe + * the locations and types of the I/O sensitive fields within a record. + * + ******************************************************************************/ +struct msgRecEnum{ + char recType[20]; /* Holds string describing record type */ +}; +typedef struct msgRecEnum msgRecEnum; + +extern msgRecEnum drvMsgAi; +extern msgRecEnum drvMsgAo; +extern msgRecEnum drvMsgBi; +extern msgRecEnum drvMsgBo; +extern msgRecEnum drvMsgMi; +extern msgRecEnum drvMsgMo; +extern msgRecEnum drvMsgLi; +extern msgRecEnum drvMsgLo; +extern msgRecEnum drvMsgSi; +extern msgRecEnum drvMsgSo; +extern msgRecEnum drvMsgWf; + +/****************************************************************************** + * + * This is a modified DSET that is used by device support modules that use + * the message driver's services. It starts the same as a regular DSET, and + * then includes 2 extra pointers. One to the parmBlock structure for the + * device type being defined. And one that points to the record-type + * enumeration structure. + * + ******************************************************************************/ +struct msgDset{ + long number; + DEVSUPFUN funPtr[10]; + msgParmBlock *pparmBlock; + msgRecEnum *precEnum; +}; +typedef struct msgDset msgDset; + +/****************************************************************************** + * + * This represents the parameters that are passed to the raw read and raw + * write physical device drivers when data is to be transferred. + * + * It is assumed that the 'len' values found in the following structures + * is the number of valid characters to transfer. There is always a '\0' + * added to the ens of this buffer, so the actual buffer size must be at + * least len+1 bytes long. + * + ******************************************************************************/ +typedef struct { + char *buf; /* Buffer to hold the data bytes */ + int len; /* Max number of bytes to read/write */ + int actual; /* actual number of bytes transfered */ +} msgStrParm; + +/****************************************************************************** + * + * The following are the parameters that are passed to the record-specific + * conversion functions. These functions are provided by the message driver + * for convenience only. They are only invoked if the command table contains + * the proper op-codes and/or if the user-supplied code calls them. + * + ******************************************************************************/ +typedef struct { + char *format; /* Format string for the sprintf function */ +} msgFoParm; + +typedef struct { + char *format; /* Format string for the sscanf function */ + int startLoc; /* where to start scanning the input string from */ + int len; /* Max number of bytes to read in */ +} msgFiParm; + +typedef struct { + char *str; /* value to compare response against */ + int index; /* index to start location of comparison */ + int len; /* max number of chars to read from device */ +} msgAkParm; + +typedef struct { + char *str; /* string to compare */ + int index; /* character position to start comparison */ + int len; /* max bytes to read from device */ +} msgSBIParm; + +#endif diff --git a/src/drv/old/drvRs232.h b/src/drv/old/drvRs232.h new file mode 100644 index 000000000..14b75deb0 --- /dev/null +++ b/src/drv/old/drvRs232.h @@ -0,0 +1,51 @@ +/* share/epicsH $Id$ */ +/* + * Author: John Winans + * Date: 04-16-92 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1988, 1989, 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 + * + * All rights reserved. No part of this publication may be reproduced, + * stored in a retrieval system, transmitted, in any form or by any + * means, electronic, mechanical, photocopying, recording, or otherwise + * without prior written permission of Los Alamos National Laboratory + * and Argonne National Laboratory. + * + * Modification Log: + * ----------------- + * .01 04-16-92 jrw Initial release + * .02 07-04-92 jrw Moved tty-specific stuff to devTy232.h + * + * This file contains the common parts of the RS-232 device support info. + */ + +#ifndef EPICS_DRVRS232_H +#define EPICS_DRVRS232_H + +typedef struct { + int cmd; + void *pparm; +} ioctlCommand; + +#define IOCTL232_BREAK 1 + +#endif diff --git a/src/drv/old/drvTy232.h b/src/drv/old/drvTy232.h new file mode 100644 index 000000000..07704d7b8 --- /dev/null +++ b/src/drv/old/drvTy232.h @@ -0,0 +1,77 @@ +/* share/epicsH $Id$ */ +/* + * Author: John Winans + * Date: 04-16-92 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1988, 1989, 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 + * + * All rights reserved. No part of this publication may be reproduced, + * stored in a retrieval system, transmitted, in any form or by any + * means, electronic, mechanical, photocopying, recording, or otherwise + * without prior written permission of Los Alamos National Laboratory + * and Argonne National Laboratory. + * + * Modification Log: + * ----------------- + * .01 04-16-92 jrw Initial release + */ + +#ifndef EPICS_DEVTY232_H +#define EPICS_DEVTY232_H + +/****************************************************************************** + * + * Additional fields needed for the msgParmBlock structure. + * + ******************************************************************************/ +typedef struct { + int timeWindow; /* Clock ticks to skip after a timeout */ + int dmaTimeout; /* Clock ticks to wait for DMA to complete */ + int flags; /* set to FALSE if does NOT echo characters */ + int eoi; /* eoi char value or -1 if none */ + int baud; /* baud rate to run the interface */ + int ttyOptions; /* ioctl options for the serial port */ +} devTy232ParmBlock; + +#define ECHO 1 /* Device echos characters sent to it */ + /* The CRLF option is only valid when ECHO is set */ +#define CRLF 2 /* Device does CR -> CR LF expansion */ +#define KILL_CRLF 4 /* Remove all CR and LF characters from input */ + +typedef struct { + CALLBACK callback; /* Used to do the ioctl when the dog wakes up */ + WDOG_ID doggie; /* For I/O timing */ + int dogAbort; /* Used to flag a timeout */ + int link; /* The tty card/link number */ + int port; /* The tty port number on that card */ + int ttyFd; /* The open file descriptor */ + /* The pparmBlock is used to make sure only 1 device type is requested */ + /* on one single port. */ + msgParmBlock *pparmBlock; +} devTy232Link; + +#ifndef DRVTY232_C +extern +#endif +msgDrvBlock drv232Block; + +#endif diff --git a/src/libCom/Makefile.Unix b/src/libCom/Makefile.Unix index 14064d438..6629aceb4 100644 --- a/src/libCom/Makefile.Unix +++ b/src/libCom/Makefile.Unix @@ -4,6 +4,21 @@ include $(EPICS)/config/CONFIG_BASE USR_CFLAGS = -D_NO_PROTO +INC += cvtFast.h +INC += ellLib.h +INC += envDefs.h +INC += epicsAssert.h +INC += epicsPrint.h +INC += errMdef.h +INC += error.h +INC += fdmgr.h +INC += freeList.h +INC += gpHash.h +INC += memDebugLib.h +INC += tsDefs.h +INC += bucketLib.h +INC += pal.h + SRCS.c += ../bucketLib.c SRCS.c += ../calcPerform.c SRCS.c += ../cvtFast.c diff --git a/src/libCom/blderrSymTbl b/src/libCom/blderrSymTbl index a60de69f7..d0eb83364 100755 --- a/src/libCom/blderrSymTbl +++ b/src/libCom/blderrSymTbl @@ -45,12 +45,14 @@ else DEF="${4}" fi - TMPMAKEFILE=/tmp/tmpmakefile SFILES=/tmp/sfiles EPICS=$1 HOST_ARCH=$2 MAKE=$3 +SRC=$EPICS/base/src +INCLUDEH="-I$SRC/include -I$SRC/as -I$SRC/ca -I$SRC/db -I$SRC/libCom\ + -I$SRC/drv/old -I$SRC/drv/ansi -I$SRC/dbStatic -I$SRC/bpt -I$SRC/dev" case $HOST_ARCH in alpha | hp700 | sgi | Linux) @@ -58,13 +60,13 @@ case $HOST_ARCH in GCC=`which gcc` if [ -x "$GCC" ]; then - FILES=`"$GCC" -M -D$DEF -I../../../include \ + FILES=`"$GCC" -M -D$DEF $INCLUDEH \ errInc.c 2>/dev/null \ | sed -e 's/errInc\.o.*: errInc\.c//' -e 's/\\\//'` else MAKEDEPEND=`which makedepend` if [ -x "$MAKEDEPEND" ]; then - FILES=`"$MAKEDEPEND" -f- -D$DEF -I../../../include \ + FILES=`"$MAKEDEPEND" -f- -D$DEF $INCLUDEH \ errInc.c 2>/dev/null | sed -e 's/errInc.o://' -e 's/\\\//'` else echo Neither GCC or MAKEDEPEND found. @@ -76,14 +78,14 @@ case $HOST_ARCH in # use -xM option of ACC to list dependencies CC=`$EPICS/base/tools/GetVar $EPICS ACC $HOST_ARCH` - FILES=`$CC -xM -D$DEF -I../../../include errInc.c \ + FILES=`$CC -xM -D$DEF $INCLUDEH errInc.c \ | grep "errInc.o" | grep -v "errInc.c" \ | sed -e 's/errInc\.o://'` ;; sun4) # use -M option of Sun compiler to list make dependencies - FILES=`cc -M -D$DEF -I../../../include errInc.c 2>/dev/null \ + FILES=`cc -M -D$DEF $INCLUDEH errInc.c 2>/dev/null \ | grep "errInc.o" | grep -v "errInc.c" \ | sed -e 's/errInc\.o://'` ;; @@ -103,7 +105,7 @@ grep "^#define[ ]*S_" $FILES /dev/null \ cat $SFILES | (awk ' BEGIN {print "errInc.o : errInc.c \\"} {print " "$0" \\" } -END {print " ../../../include/errMdef.h"} +END {print " ../errMdef.h"} ') > $TMPMAKEFILE diff --git a/src/libCom/bucketLib.h b/src/libCom/bucketLib.h new file mode 100644 index 000000000..2a09a511c --- /dev/null +++ b/src/libCom/bucketLib.h @@ -0,0 +1,133 @@ +/* + * $Id$ + * + * Author: Jeffrey O. Hill + * hill@luke.lanl.gov + * (505) 665 1831 + * Date: 9-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 091493 joh added nEntries to struct bucket + * .02 121693 joh added bucketFree() + * .03 052395 joh use std EPICS status + * $Log$ + * Revision 1.12 1995/12/19 19:44:25 jhill + * added C++ extern "C" { + * + * Revision 1.11 1995/09/29 21:34:32 jhill + * added def for BUCKET_SUCCESS + * + * Revision 1.10 1995/09/26 20:40:40 mrk + * include epicsTypes.h and also change const to READONLY (old style C) + * + * Revision 1.9 1995/08/11 23:46:13 jhill + * EPICS style status + * + * + * NOTES: + * .01 Storage for identifier must persist until an item is deleted + */ + +#ifndef INCbucketLibh +#define INCbucketLibh + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +typedef unsigned BUCKETID; + +typedef enum {bidtUnsigned, bidtPointer, bidtString} buckTypeOfId; + +typedef struct item{ + struct item *pItem; + READONLY void *pId; + void *pApp; + buckTypeOfId type; +}ITEM; + +typedef struct bucket{ + ITEM **pTable; + ITEM *pFreeItems; + unsigned hashIdMask; + unsigned hashIdNBits; + unsigned nInUse; +}BUCKET; + + +#ifdef __STDC__ +BUCKET *bucketCreate (unsigned nHashTableEntries); +int bucketFree (BUCKET *prb); +int bucketShow (BUCKET *pb); + +/* + * !! Identifier must exist (and remain constant) at the specified address until + * the item is deleted from the bucket !! + */ +int bucketAddItemUnsignedId (BUCKET *prb, READONLY unsigned *pId, void *pApp); +int bucketAddItemPointerId (BUCKET *prb, void * READONLY *pId, void *pApp); +int bucketAddItemStringId (BUCKET *prb, READONLY char *pId, void *pApp); + +int bucketRemoveItemUnsignedId (BUCKET *prb, READONLY unsigned *pId); +int bucketRemoveItemPointerId (BUCKET *prb, void * READONLY *pId); +int bucketRemoveItemStringId (BUCKET *prb, READONLY char *pId); + +void *bucketLookupItemUnsignedId (BUCKET *prb, READONLY unsigned *pId); +void *bucketLookupItemPointerId (BUCKET *prb, void * READONLY *pId); +void *bucketLookupItemStringId (BUCKET *prb, READONLY char *pId); + +#else /*__STDC__*/ +BUCKET *bucketCreate (); +int bucketFree (); +int bucketShow (); +int bucketAddItemUnsignedId (); +int bucketAddItemPointerId (); +int bucketAddItemStringId (); +int bucketRemoveItemUnsignedId (); +int bucketRemoveItemPointerId (); +int bucketRemoveItemStringId (); +void *bucketLookupItemUnsignedId (); +void *bucketLookupItemPointerId (); +void *bucketLookupItemStringId (); +#endif /*__STDC__*/ + +/* + * Status returned by bucketLib functions + */ +#define BUCKET_SUCCESS S_bucket_success +#define S_bucket_success 0 +#define S_bucket_noMemory (M_bucket | 1) /*Memory allocation failed*/ +#define S_bucket_idInUse (M_bucket | 2) /*Identifier already in use*/ +#define S_bucket_uknId (M_bucket | 3) /*Unknown identifier*/ + +#ifdef __cplusplus +} +#endif + +#endif /*INCbucketLibh*/ + diff --git a/src/libCom/bucketLib/bucketLib.h b/src/libCom/bucketLib/bucketLib.h new file mode 100644 index 000000000..2a09a511c --- /dev/null +++ b/src/libCom/bucketLib/bucketLib.h @@ -0,0 +1,133 @@ +/* + * $Id$ + * + * Author: Jeffrey O. Hill + * hill@luke.lanl.gov + * (505) 665 1831 + * Date: 9-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 091493 joh added nEntries to struct bucket + * .02 121693 joh added bucketFree() + * .03 052395 joh use std EPICS status + * $Log$ + * Revision 1.12 1995/12/19 19:44:25 jhill + * added C++ extern "C" { + * + * Revision 1.11 1995/09/29 21:34:32 jhill + * added def for BUCKET_SUCCESS + * + * Revision 1.10 1995/09/26 20:40:40 mrk + * include epicsTypes.h and also change const to READONLY (old style C) + * + * Revision 1.9 1995/08/11 23:46:13 jhill + * EPICS style status + * + * + * NOTES: + * .01 Storage for identifier must persist until an item is deleted + */ + +#ifndef INCbucketLibh +#define INCbucketLibh + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +typedef unsigned BUCKETID; + +typedef enum {bidtUnsigned, bidtPointer, bidtString} buckTypeOfId; + +typedef struct item{ + struct item *pItem; + READONLY void *pId; + void *pApp; + buckTypeOfId type; +}ITEM; + +typedef struct bucket{ + ITEM **pTable; + ITEM *pFreeItems; + unsigned hashIdMask; + unsigned hashIdNBits; + unsigned nInUse; +}BUCKET; + + +#ifdef __STDC__ +BUCKET *bucketCreate (unsigned nHashTableEntries); +int bucketFree (BUCKET *prb); +int bucketShow (BUCKET *pb); + +/* + * !! Identifier must exist (and remain constant) at the specified address until + * the item is deleted from the bucket !! + */ +int bucketAddItemUnsignedId (BUCKET *prb, READONLY unsigned *pId, void *pApp); +int bucketAddItemPointerId (BUCKET *prb, void * READONLY *pId, void *pApp); +int bucketAddItemStringId (BUCKET *prb, READONLY char *pId, void *pApp); + +int bucketRemoveItemUnsignedId (BUCKET *prb, READONLY unsigned *pId); +int bucketRemoveItemPointerId (BUCKET *prb, void * READONLY *pId); +int bucketRemoveItemStringId (BUCKET *prb, READONLY char *pId); + +void *bucketLookupItemUnsignedId (BUCKET *prb, READONLY unsigned *pId); +void *bucketLookupItemPointerId (BUCKET *prb, void * READONLY *pId); +void *bucketLookupItemStringId (BUCKET *prb, READONLY char *pId); + +#else /*__STDC__*/ +BUCKET *bucketCreate (); +int bucketFree (); +int bucketShow (); +int bucketAddItemUnsignedId (); +int bucketAddItemPointerId (); +int bucketAddItemStringId (); +int bucketRemoveItemUnsignedId (); +int bucketRemoveItemPointerId (); +int bucketRemoveItemStringId (); +void *bucketLookupItemUnsignedId (); +void *bucketLookupItemPointerId (); +void *bucketLookupItemStringId (); +#endif /*__STDC__*/ + +/* + * Status returned by bucketLib functions + */ +#define BUCKET_SUCCESS S_bucket_success +#define S_bucket_success 0 +#define S_bucket_noMemory (M_bucket | 1) /*Memory allocation failed*/ +#define S_bucket_idInUse (M_bucket | 2) /*Identifier already in use*/ +#define S_bucket_uknId (M_bucket | 3) /*Unknown identifier*/ + +#ifdef __cplusplus +} +#endif + +#endif /*INCbucketLibh*/ + diff --git a/src/libCom/cvtFast.h b/src/libCom/cvtFast.h new file mode 100644 index 000000000..6c031eaee --- /dev/null +++ b/src/libCom/cvtFast.h @@ -0,0 +1,107 @@ +/* $Id$ + * Very efficient routines to convert numbers to strings + * + * Author: Bob Dalesio wrote cvtFloatToString (called FF_TO_STR) + * Code is same for cvtDoubleToString + * Marty Kraimer wrote cvtCharToString,cvtUcharToString + * cvtShortToString,cvtUshortToString, + * cvtLongToString, and cvtUlongToString + * Mark Anderson wrote cvtLongToHexString, cvtLongToOctalString, + * adopted cvt[Float/Double]ExpString and + * cvt[Float/Double]CompactString from fToEStr + * and fixed calls to gcvt + * Date: 12-9-92 + * + * 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 mrk 12-09-92 Taken form dbAccess and made into library + * .02 mda 01-12-92 New routines, cleanup + * .03 joh 03-30-93 Added bit field extract/insert + * .04 mrk 07-22-93 Support both old C and ANSI C + */ +#ifndef INCcvtFasth +#define INCcvtFasth + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef __STDC__ + +/* + * each of these functions return the number of characters "transmitted" + * (as in ANSI-C/POSIX.1/XPG3 sprintf() functions) + */ +int cvtFloatToString(float value, char *pstring, unsigned short precision); +int cvtDoubleToString(double value, char *pstring, unsigned short precision); +int cvtFloatToExpString(float value, char *pstring, unsigned short precision); +int cvtDoubleToExpString(double value, char *pstring, unsigned short precision); +int cvtFloatToCompactString(float value, char *pstring, unsigned short precision); +int cvtDoubleToCompactString(double value, char *pstring, unsigned short precision); +int cvtCharToString(char value, char *pstring); +int cvtUcharToString(unsigned char value, char *pstring); +int cvtShortToString(short value, char *pstring); +int cvtUshortToString(unsigned short value, char *pstring); +int cvtLongToString(long value, char *pstring); +int cvtUlongToString(unsigned long value, char *pstring); +int cvtLongToHexString(long value, char *pstring); +int cvtLongToOctalString(long value, char *pstring); +unsigned long cvtBitsToUlong( + unsigned long src, + unsigned bitFieldOffset, + unsigned bitFieldLength); +unsigned long cvtUlongToBits( + unsigned long src, + unsigned long dest, + unsigned bitFieldOffset, + unsigned bitFieldLength); + +#else /*__STDC__*/ + +int cvtFloatToString(); +int cvtDoubleToString(); +int cvtFloatToExpString(); +int cvtDoubleToExpString(); +int cvtFloatToCompactString(); +int cvtDoubleToCompactString(); +int cvtCharToString(); +int cvtUcharToString(); +int cvtShortToString(); +int cvtUshortToString(); +int cvtLongToString(); +int cvtUlongToString(); +int cvtLongToHexString(); +int cvtLongToOctalString(); +unsigned long cvtBitsToUlong(); +unsigned long cvtUlongToBits(); + +#endif /*__STDC__*/ + +#ifdef __cplusplus +} +#endif + +#endif /*INCcvtFasth*/ diff --git a/src/libCom/cvtFast/cvtFast.h b/src/libCom/cvtFast/cvtFast.h new file mode 100644 index 000000000..6c031eaee --- /dev/null +++ b/src/libCom/cvtFast/cvtFast.h @@ -0,0 +1,107 @@ +/* $Id$ + * Very efficient routines to convert numbers to strings + * + * Author: Bob Dalesio wrote cvtFloatToString (called FF_TO_STR) + * Code is same for cvtDoubleToString + * Marty Kraimer wrote cvtCharToString,cvtUcharToString + * cvtShortToString,cvtUshortToString, + * cvtLongToString, and cvtUlongToString + * Mark Anderson wrote cvtLongToHexString, cvtLongToOctalString, + * adopted cvt[Float/Double]ExpString and + * cvt[Float/Double]CompactString from fToEStr + * and fixed calls to gcvt + * Date: 12-9-92 + * + * 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 mrk 12-09-92 Taken form dbAccess and made into library + * .02 mda 01-12-92 New routines, cleanup + * .03 joh 03-30-93 Added bit field extract/insert + * .04 mrk 07-22-93 Support both old C and ANSI C + */ +#ifndef INCcvtFasth +#define INCcvtFasth + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef __STDC__ + +/* + * each of these functions return the number of characters "transmitted" + * (as in ANSI-C/POSIX.1/XPG3 sprintf() functions) + */ +int cvtFloatToString(float value, char *pstring, unsigned short precision); +int cvtDoubleToString(double value, char *pstring, unsigned short precision); +int cvtFloatToExpString(float value, char *pstring, unsigned short precision); +int cvtDoubleToExpString(double value, char *pstring, unsigned short precision); +int cvtFloatToCompactString(float value, char *pstring, unsigned short precision); +int cvtDoubleToCompactString(double value, char *pstring, unsigned short precision); +int cvtCharToString(char value, char *pstring); +int cvtUcharToString(unsigned char value, char *pstring); +int cvtShortToString(short value, char *pstring); +int cvtUshortToString(unsigned short value, char *pstring); +int cvtLongToString(long value, char *pstring); +int cvtUlongToString(unsigned long value, char *pstring); +int cvtLongToHexString(long value, char *pstring); +int cvtLongToOctalString(long value, char *pstring); +unsigned long cvtBitsToUlong( + unsigned long src, + unsigned bitFieldOffset, + unsigned bitFieldLength); +unsigned long cvtUlongToBits( + unsigned long src, + unsigned long dest, + unsigned bitFieldOffset, + unsigned bitFieldLength); + +#else /*__STDC__*/ + +int cvtFloatToString(); +int cvtDoubleToString(); +int cvtFloatToExpString(); +int cvtDoubleToExpString(); +int cvtFloatToCompactString(); +int cvtDoubleToCompactString(); +int cvtCharToString(); +int cvtUcharToString(); +int cvtShortToString(); +int cvtUshortToString(); +int cvtLongToString(); +int cvtUlongToString(); +int cvtLongToHexString(); +int cvtLongToOctalString(); +unsigned long cvtBitsToUlong(); +unsigned long cvtUlongToBits(); + +#endif /*__STDC__*/ + +#ifdef __cplusplus +} +#endif + +#endif /*INCcvtFasth*/ diff --git a/src/libCom/ellLib.h b/src/libCom/ellLib.h new file mode 100644 index 000000000..c2333bc5c --- /dev/null +++ b/src/libCom/ellLib.h @@ -0,0 +1,139 @@ +/* ellLib.h $Id$ + * + * Author: John Winans (ANL) + * Date: 07-02-92 + * + * 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 jrw 07-02-92 created + * .02 rcz 07-23-93 changed name + * .03 rcz 07-26-93 changed name again + */ +#ifndef INCellLibh +#define INCellLibh + +#ifdef __cplusplus +extern "C" { +#endif + +#define DLLLIB_USE_MACROS + +struct ELLNODE { + struct ELLNODE *next; + struct ELLNODE *previous; +}; +typedef struct ELLNODE ELLNODE; + +struct ELLLIST { + ELLNODE node; + int count; +}; +typedef struct ELLLIST ELLLIST; + +#ifdef __STDC__ + +#ifdef DLLLIB_USE_MACROS + +#define ellInit(PLIST) { ((ELLLIST *)(PLIST))->node.next = NULL;\ + ((ELLLIST *)(PLIST))->node.previous = NULL;\ + ((ELLLIST *)(PLIST))->count = 0; } + +#define ellCount(PLIST) (((ELLLIST *)(PLIST))->count) + +#define ellFirst(PLIST) (((ELLLIST *)(PLIST))->node.next) + +#define ellLast(PLIST) (((ELLLIST *)(PLIST))->node.previous) + +#define ellNext(PNODE) (((ELLNODE *)(PNODE))->next) + +#define ellPrevious(PNODE) (((ELLNODE *)(PNODE))->previous) + +#else /*DLLLIB_USE_MACROS*/ + +void ellInit (ELLLIST *pList); +int ellCount (ELLLIST *pList); +ELLNODE *ellFirst (ELLLIST *pList); +ELLNODE *ellLast (ELLLIST *pList); +ELLNODE *ellNext (ELLNODE *pNode); +ELLNODE *ellPrevious (ELLNODE *pNode); + +#endif /*DLLLIB_USE_MACROS*/ + +void ellAdd (ELLLIST *pList, ELLNODE *pNode); +void ellConcat (ELLLIST *pDstList, ELLLIST *pAddList); +void ellDelete (ELLLIST *pList, ELLNODE *pNode); +void ellExtract (ELLLIST *pSrcList, ELLNODE *pStartNode, ELLNODE *pEndNode, ELLLIST *pDstList); +ELLNODE *ellGet (ELLLIST *pList); +void ellInsert (ELLLIST *plist, ELLNODE *pPrev, ELLNODE *pNode); +ELLNODE *ellNth (ELLLIST *pList, int nodeNum); +ELLNODE *ellNStep (ELLNODE *pNode, int nStep); +int ellFind (ELLLIST *pList, ELLNODE *pNode); +void ellFree (ELLLIST *pList); + +#else /*__STDC__*/ + +#ifdef DLLLIB_USE_MACROS + +#define ellInit(PLIST) { ((ELLLIST *)(PLIST))->node.next = NULL;\ + ((ELLLIST *)(PLIST))->node.previous = NULL;\ + ((ELLLIST *)(PLIST))->count = 0; } + +#define ellCount(PLIST) (((ELLLIST *)(PLIST))->count) + +#define ellFirst(PLIST) (((ELLLIST *)(PLIST))->node.next) + +#define ellLast(PLIST) (((ELLLIST *)(PLIST))->node.previous) + +#define ellNext(PNODE) (((ELLNODE *)(PNODE))->next) + +#define ellPrevious(PNODE) (((ELLNODE *)(PNODE))->previous) + +#else /*DLLLIB_USE_MACROS*/ + +void ellInit (); +int ellCount (); +ELLNODE *ellFirst (); +ELLNODE *ellNext (); +ELLNODE *ellLast (); +ELLNODE *ellPrevious (); + +#endif /*DLLLIB_USE_MACROS*/ + +void ellAdd (); +void ellConcat (); +void ellDelete (); +void ellExtract (); +ELLNODE *ellGet (); +void ellInsert (); +ELLNODE *ellNth (); +ELLNODE *ellNStep (); +int ellFind (); +void ellFree (); +#endif /*__STDC__*/ + +#ifdef __cplusplus +} +#endif + +#endif /*INCellLibh*/ diff --git a/src/libCom/ellLib/ellLib.h b/src/libCom/ellLib/ellLib.h new file mode 100644 index 000000000..c2333bc5c --- /dev/null +++ b/src/libCom/ellLib/ellLib.h @@ -0,0 +1,139 @@ +/* ellLib.h $Id$ + * + * Author: John Winans (ANL) + * Date: 07-02-92 + * + * 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 jrw 07-02-92 created + * .02 rcz 07-23-93 changed name + * .03 rcz 07-26-93 changed name again + */ +#ifndef INCellLibh +#define INCellLibh + +#ifdef __cplusplus +extern "C" { +#endif + +#define DLLLIB_USE_MACROS + +struct ELLNODE { + struct ELLNODE *next; + struct ELLNODE *previous; +}; +typedef struct ELLNODE ELLNODE; + +struct ELLLIST { + ELLNODE node; + int count; +}; +typedef struct ELLLIST ELLLIST; + +#ifdef __STDC__ + +#ifdef DLLLIB_USE_MACROS + +#define ellInit(PLIST) { ((ELLLIST *)(PLIST))->node.next = NULL;\ + ((ELLLIST *)(PLIST))->node.previous = NULL;\ + ((ELLLIST *)(PLIST))->count = 0; } + +#define ellCount(PLIST) (((ELLLIST *)(PLIST))->count) + +#define ellFirst(PLIST) (((ELLLIST *)(PLIST))->node.next) + +#define ellLast(PLIST) (((ELLLIST *)(PLIST))->node.previous) + +#define ellNext(PNODE) (((ELLNODE *)(PNODE))->next) + +#define ellPrevious(PNODE) (((ELLNODE *)(PNODE))->previous) + +#else /*DLLLIB_USE_MACROS*/ + +void ellInit (ELLLIST *pList); +int ellCount (ELLLIST *pList); +ELLNODE *ellFirst (ELLLIST *pList); +ELLNODE *ellLast (ELLLIST *pList); +ELLNODE *ellNext (ELLNODE *pNode); +ELLNODE *ellPrevious (ELLNODE *pNode); + +#endif /*DLLLIB_USE_MACROS*/ + +void ellAdd (ELLLIST *pList, ELLNODE *pNode); +void ellConcat (ELLLIST *pDstList, ELLLIST *pAddList); +void ellDelete (ELLLIST *pList, ELLNODE *pNode); +void ellExtract (ELLLIST *pSrcList, ELLNODE *pStartNode, ELLNODE *pEndNode, ELLLIST *pDstList); +ELLNODE *ellGet (ELLLIST *pList); +void ellInsert (ELLLIST *plist, ELLNODE *pPrev, ELLNODE *pNode); +ELLNODE *ellNth (ELLLIST *pList, int nodeNum); +ELLNODE *ellNStep (ELLNODE *pNode, int nStep); +int ellFind (ELLLIST *pList, ELLNODE *pNode); +void ellFree (ELLLIST *pList); + +#else /*__STDC__*/ + +#ifdef DLLLIB_USE_MACROS + +#define ellInit(PLIST) { ((ELLLIST *)(PLIST))->node.next = NULL;\ + ((ELLLIST *)(PLIST))->node.previous = NULL;\ + ((ELLLIST *)(PLIST))->count = 0; } + +#define ellCount(PLIST) (((ELLLIST *)(PLIST))->count) + +#define ellFirst(PLIST) (((ELLLIST *)(PLIST))->node.next) + +#define ellLast(PLIST) (((ELLLIST *)(PLIST))->node.previous) + +#define ellNext(PNODE) (((ELLNODE *)(PNODE))->next) + +#define ellPrevious(PNODE) (((ELLNODE *)(PNODE))->previous) + +#else /*DLLLIB_USE_MACROS*/ + +void ellInit (); +int ellCount (); +ELLNODE *ellFirst (); +ELLNODE *ellNext (); +ELLNODE *ellLast (); +ELLNODE *ellPrevious (); + +#endif /*DLLLIB_USE_MACROS*/ + +void ellAdd (); +void ellConcat (); +void ellDelete (); +void ellExtract (); +ELLNODE *ellGet (); +void ellInsert (); +ELLNODE *ellNth (); +ELLNODE *ellNStep (); +int ellFind (); +void ellFree (); +#endif /*__STDC__*/ + +#ifdef __cplusplus +} +#endif + +#endif /*INCellLibh*/ diff --git a/src/libCom/env/envDefs.h b/src/libCom/env/envDefs.h new file mode 100644 index 000000000..abdd6fdb8 --- /dev/null +++ b/src/libCom/env/envDefs.h @@ -0,0 +1,104 @@ +/* $Id$ + * Author: Roger A. Cole + * Date: 07-20-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 07-20-91 rac initial version + * .02 08-07-91 joh added ioc log env + * .03 09-26-94 joh ifdef out double inclusion + * .04 11-28-94 joh new CA env var + * .05 04-20-95 anj moved defaults to CONFIG_ENV + * + * make options + * -DvxWorks makes a version for VxWorks + * -DNDEBUG don't compile assert() checking + * -DDEBUG compile various debug code, including checks on + * malloc'd memory + */ +/*+/mod*********************************************************************** +* TITLE envDefs.h - definitions for environment get/set routines +* +* DESCRIPTION +* This file defines the environment parameters for EPICS. These +* ENV_PARAM's are initialized by $epics/share/bin/envSetupParams for +* use by EPICS programs running under UNIX and VxWorks. +* +* User programs can define their own environment parameters for their +* own use--the only caveat is that such parameters aren't automatically +* setup by EPICS. +* +* SEE ALSO +* $epics/share/bin/envSetupParams, envSubr.c +* +*-***************************************************************************/ + +#ifndef envDefsH +#define envDefsH + +#include + +typedef struct envParam { + char *name; /* text name of the parameter */ + char dflt[80]; /* default value for the parameter */ +} ENV_PARAM; + +/* + * bldEnvData looks for "epicsShareExtern ENV_PARAM" + */ +epicsShareExtern ENV_PARAM EPICS_CA_ADDR_LIST; +epicsShareExtern ENV_PARAM EPICS_CA_CONN_TMO; +epicsShareExtern ENV_PARAM EPICS_CA_BEACON_PERIOD; +epicsShareExtern ENV_PARAM EPICS_CA_AUTO_ADDR_LIST; +epicsShareExtern ENV_PARAM EPICS_CA_REPEATER_PORT; +epicsShareExtern ENV_PARAM EPICS_CA_SERVER_PORT; +epicsShareExtern ENV_PARAM EPICS_TS_MIN_WEST; +epicsShareExtern ENV_PARAM EPICS_TS_NTP_INET; +epicsShareExtern ENV_PARAM EPICS_IOC_LOG_PORT; +epicsShareExtern ENV_PARAM EPICS_IOC_LOG_INET; +epicsShareExtern ENV_PARAM EPICS_IOC_LOG_FILE_LIMIT; +epicsShareExtern ENV_PARAM EPICS_IOC_LOG_FILE_NAME; +epicsShareExtern ENV_PARAM EPICS_CMD_PROTO_PORT; +epicsShareExtern ENV_PARAM EPICS_AR_PORT; +#define EPICS_ENV_VARIABLE_COUNT 14 + +/* + * N elements added here to satisfy microsoft development tools + * (includes room for nill termination) + * + * bldEnvData looks for "epicsShareExtern ENV_PARAM" so + * this always needs to be divided into two lines + */ +epicsShareExtern ENV_PARAM + *env_param_list[EPICS_ENV_VARIABLE_COUNT+1]; + +char *envGetConfigParam(); +long envPrtConfigParam(); +long envSetConfigParam(); +long envGetInetAddrConfigParam(); +long envGetDoubleConfigParam(); +long envGetLongConfigParam(); + +#endif /*envDefsH*/ + diff --git a/src/libCom/envDefs.h b/src/libCom/envDefs.h new file mode 100644 index 000000000..abdd6fdb8 --- /dev/null +++ b/src/libCom/envDefs.h @@ -0,0 +1,104 @@ +/* $Id$ + * Author: Roger A. Cole + * Date: 07-20-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 07-20-91 rac initial version + * .02 08-07-91 joh added ioc log env + * .03 09-26-94 joh ifdef out double inclusion + * .04 11-28-94 joh new CA env var + * .05 04-20-95 anj moved defaults to CONFIG_ENV + * + * make options + * -DvxWorks makes a version for VxWorks + * -DNDEBUG don't compile assert() checking + * -DDEBUG compile various debug code, including checks on + * malloc'd memory + */ +/*+/mod*********************************************************************** +* TITLE envDefs.h - definitions for environment get/set routines +* +* DESCRIPTION +* This file defines the environment parameters for EPICS. These +* ENV_PARAM's are initialized by $epics/share/bin/envSetupParams for +* use by EPICS programs running under UNIX and VxWorks. +* +* User programs can define their own environment parameters for their +* own use--the only caveat is that such parameters aren't automatically +* setup by EPICS. +* +* SEE ALSO +* $epics/share/bin/envSetupParams, envSubr.c +* +*-***************************************************************************/ + +#ifndef envDefsH +#define envDefsH + +#include + +typedef struct envParam { + char *name; /* text name of the parameter */ + char dflt[80]; /* default value for the parameter */ +} ENV_PARAM; + +/* + * bldEnvData looks for "epicsShareExtern ENV_PARAM" + */ +epicsShareExtern ENV_PARAM EPICS_CA_ADDR_LIST; +epicsShareExtern ENV_PARAM EPICS_CA_CONN_TMO; +epicsShareExtern ENV_PARAM EPICS_CA_BEACON_PERIOD; +epicsShareExtern ENV_PARAM EPICS_CA_AUTO_ADDR_LIST; +epicsShareExtern ENV_PARAM EPICS_CA_REPEATER_PORT; +epicsShareExtern ENV_PARAM EPICS_CA_SERVER_PORT; +epicsShareExtern ENV_PARAM EPICS_TS_MIN_WEST; +epicsShareExtern ENV_PARAM EPICS_TS_NTP_INET; +epicsShareExtern ENV_PARAM EPICS_IOC_LOG_PORT; +epicsShareExtern ENV_PARAM EPICS_IOC_LOG_INET; +epicsShareExtern ENV_PARAM EPICS_IOC_LOG_FILE_LIMIT; +epicsShareExtern ENV_PARAM EPICS_IOC_LOG_FILE_NAME; +epicsShareExtern ENV_PARAM EPICS_CMD_PROTO_PORT; +epicsShareExtern ENV_PARAM EPICS_AR_PORT; +#define EPICS_ENV_VARIABLE_COUNT 14 + +/* + * N elements added here to satisfy microsoft development tools + * (includes room for nill termination) + * + * bldEnvData looks for "epicsShareExtern ENV_PARAM" so + * this always needs to be divided into two lines + */ +epicsShareExtern ENV_PARAM + *env_param_list[EPICS_ENV_VARIABLE_COUNT+1]; + +char *envGetConfigParam(); +long envPrtConfigParam(); +long envSetConfigParam(); +long envGetInetAddrConfigParam(); +long envGetDoubleConfigParam(); +long envGetLongConfigParam(); + +#endif /*envDefsH*/ + diff --git a/src/libCom/epicsAssert.h b/src/libCom/epicsAssert.h new file mode 100644 index 000000000..aff367653 --- /dev/null +++ b/src/libCom/epicsAssert.h @@ -0,0 +1,80 @@ +/* $Id$ + * + * EPICS assert + * + * Author: Jeffrey O. Hill + * Date: 022795 + * + * 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 assertEPICS +#define assertEPICS + +#ifdef __cplusplus +extern "C" { +#endif + +#undef assert + +#ifdef NDEBUG +# define assert(ignore) ((void) 0) +#else /* NDEBUG */ + +#if defined(__STDC__) || defined(__cplusplus) + +extern void epicsAssert (const char *pFile, const unsigned line, + const char *pMsg, const char *pAuthorName); + +#ifdef epicsAssertAuthor +#define assert(exp) \ +{if (!(exp)) epicsAssert (__FILE__, __LINE__, #exp, epicsAssertAuthor);} +#else /* epicsAssertAuthor */ +#define assert(exp) \ +{if (!(exp)) epicsAssert (__FILE__, __LINE__, #exp, 0);} +#endif /* epicsAssertAuthor */ + +#else /*__STDC__ or __cplusplus*/ + +extern void epicsAssert (); + +#ifdef epicsAssertAuthor +#define assert(exp) \ +{if (!(exp)) epicsAssert (__FILE__, __LINE__, "", epicsAssertAuthor);} +#else /* epicsAssertAuthor */ +{if (!(exp)) epicsAssert (__FILE__, __LINE__, "", 0);} +#endif /* epicsAssertAuthor */ + +#endif /*__STDC__ or __cplusplus*/ + +#endif /* NDEBUG */ + +#ifdef __cplusplus +} +#endif + + +#endif /* assertEPICS */ + diff --git a/src/libCom/epicsPrint.h b/src/libCom/epicsPrint.h new file mode 100644 index 000000000..c66dcc015 --- /dev/null +++ b/src/libCom/epicsPrint.h @@ -0,0 +1,19 @@ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef vxWorks +#include +int epicsPrintf(const char *pFormat, ...); +int epicsVprintf (const char *pFormat, va_list pvar); +int iocLogVPrintf(const char *pFormat, va_list pvar); +#else +#define epicsPrintf printf +#define epicsVprintf vprintf +#endif + +#ifdef __cplusplus +} +#endif + diff --git a/src/libCom/errMdef.h b/src/libCom/errMdef.h new file mode 100644 index 000000000..b7aae182c --- /dev/null +++ b/src/libCom/errMdef.h @@ -0,0 +1,125 @@ +/* errMdef.h err.h - Error Handling definitions */ +/* 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 mm-dd-yy iii Comment + * .02 12-02-91 jrw added GPIB and BB message codes + * .03 03-11-93 joh added __FILE__ and __LINE__ to errMessage() + * .04 04-01-93 joh added vxi + * .05 04-29-93 joh added errPrintStatus() func proto + * .06 09-04-93 rcz added functions ... for errSymLib.c merge + * .07 02-03-94 mrk RTN_SUCCESS is true only if status=0 + * .08 02-03-94 mrk Add access security library + * .09 05-23-95 joh Add bucket hashing library + */ + +#ifndef INCerrMdefh +#define INCerrMdefh + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __STDC__ +# include +#else +# include +#endif +#include + +#define RTN_SUCCESS(STATUS) ((STATUS)==0) + +#define M_dbAccess (501 <<16) /*Database Access Routines */ +#define M_drvSup (503 <<16) /*Driver Support*/ +#define M_devSup (504 <<16) /*Device Support*/ +#define M_recSup (505 <<16) /*Record Support*/ +#define M_recType (506 <<16) /*Record Type*/ +#define M_record (507 <<16) /*Database Records*/ +#define M_ar (508 <<16) /*Archiver; see arDefs.h*/ +#define M_ts (509 <<16) /*Time Stamp Routines; see tsDefs.h*/ +#define M_arAcc (510 <<16) /*Archive Access Library Routines*/ +#define M_bf (511 <<16) /*Block File Routines; see bfDefs.h*/ +#define M_syd (512 <<16) /*Sync Data Routines; see sydDefs.h*/ +#define M_ppr (513 <<16) /*Portable Plot Routines; see pprPlotDefs.h*/ +#define M_env (514 <<16) /*Environment Routines; see envDefs.h*/ +#define M_gen (515 <<16) /*General Purpose Routines; see genDefs.h*/ +#define M_gpib (516 <<16) /*Gpib driver & device support; see drvGpibInterface.h*/ +#define M_bitbus (517 <<16) /*Bitbus driver & device support; see drvBitBusInterface.h*/ +#define M_dbCa (518 <<16) /*CA_LINKs; see calink.h*/ +#define M_dbLib (519 <<16) /*Static Database Access */ +#define M_epvxi (520 <<16) /*VXI Driver*/ +#define M_devLib (521 <<16) /*Device Resource Registration*/ +#define M_asLib (522 <<16) /*Access Security */ +#define M_cas (523 <<16) /*CA server*/ +#define M_casApp (524 <<16) /*CA server application*/ +#define M_bucket (525 <<16) /*Bucket Hash*/ +#define M_sbuf (526 <<16) /*Shared Buffer*/ + + +/* + * redefine errMessage with a macro so we can print + * the file and line number + */ +#define errMessage(S, PM) \ + errPrintf(S, __FILE__, __LINE__, PM) + +#ifdef __STDC__ +int errSymFind(long status, char *name); +int UnixSymFind(long status, char *name, long *value); +int ModSymFind(long status, char *name, long *value); +void errSymTest(unsigned short modnum, unsigned short begErrNum, unsigned short endErrNum); +void errSymTestPrint(long errNum); +int errSymBld(); +int errSymbolAdd (long errNum,char *name); +void errPrintf(long status, const char *pFileName, + int lineno, const char *pformat, ...); +void errSymDump(); +void tstErrSymFind(); +void errInit(void); + +#else /*__STDC__*/ + +void errSymTest(); +int errSymFind(); +int UnixSymFind(); +int ModSymFind(); +void errSymTestPrint(); +int errSymBld(); +int errSymbolAdd(); +void errPrintf(); +void errSymDump(); +void tstErrSymFind(); +#endif /*__STDC__*/ + +extern int errVerbose; + +#ifdef __cplusplus +} +#endif + +#endif /*INCerrMdefh*/ diff --git a/src/libCom/errPrintfUNIX.c b/src/libCom/errPrintfUNIX.c index 504bb1756..4e447674b 100644 --- a/src/libCom/errPrintfUNIX.c +++ b/src/libCom/errPrintfUNIX.c @@ -59,7 +59,7 @@ void errPrintf(long status, const char *pFileName, va_start(pvar, pformat); if(pFileName && errVerbose){ - printf("filename=\"%s\" line number=%d\n", pFileName, lineno); + fprintf(stderr,"filename=\"%s\" line number=%d\n", pFileName, lineno); } if(status==0) status = errno; if(status>0) { @@ -71,15 +71,15 @@ void errPrintf(long status, const char *pFileName, modnum = status >> 16; errnum = status & 0xffff; if(rtnval) { - printf( "Error status (module %hu, number %hu) not in symbol table", + fprintf(stderr, "Error status (module %hu, number %hu) not in symbol table", modnum, errnum); } else { - printf("%s ",name); + fprintf(stderr,"%s ",name); } } if (pformat) { - vprintf(pformat,pvar); + vfprintf(stderr,pformat,pvar); } - printf("\n"); + fprintf(stderr,"\n"); } diff --git a/src/libCom/error.h b/src/libCom/error.h new file mode 100644 index 000000000..cbb0a49f9 --- /dev/null +++ b/src/libCom/error.h @@ -0,0 +1,74 @@ +/* error.h - errMessage symbol table header */ +/* 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 mm-dd-yy iii Comment + */ + + +#ifndef INCerrorh +#define INCerrorh 1 + +#define LOCAL static +#define NELEMENTS(array) /* number of elements in an array */ \ + (sizeof (array) / sizeof ((array) [0])) + + +typedef struct /* ERRSYMBOL - entry in symbol table */ + { + char *name; /* pointer to symbol name */ + long errNum; /* errMessage symbol number */ + } ERRSYMBOL; +typedef struct /* ERRSYMTAB - symbol table */ + { + short nsymbols; /* current number of symbols in table */ + ERRSYMBOL *symbols; /* ptr to array of symbol entries */ + } ERRSYMTAB; +typedef ERRSYMTAB *ERRSYMTAB_ID; + +#ifdef vxWorks +#define MYERRNO (errnoGet()&0xffff) +#else +#define MYERRNO errno +#endif + + +/*************************************************************/ +struct errSet { /* This defines one module error set */ + long number; /* dimension of err strings */ + char **papName; /* ptr to arr of ptr to error string */ +}; +struct errDes { /* An array of error sets for modules */ + long number; /* number of err modules */ + struct errSet **papErrSet; /* ptr to arr of ptr to errSet */ +}; +extern struct errDes *dbErrDes; +/*************************************************************/ + +#endif /*INCerrorh*/ diff --git a/src/libCom/error/epicsPrint.h b/src/libCom/error/epicsPrint.h new file mode 100644 index 000000000..c66dcc015 --- /dev/null +++ b/src/libCom/error/epicsPrint.h @@ -0,0 +1,19 @@ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef vxWorks +#include +int epicsPrintf(const char *pFormat, ...); +int epicsVprintf (const char *pFormat, va_list pvar); +int iocLogVPrintf(const char *pFormat, va_list pvar); +#else +#define epicsPrintf printf +#define epicsVprintf vprintf +#endif + +#ifdef __cplusplus +} +#endif + diff --git a/src/libCom/error/errMdef.h b/src/libCom/error/errMdef.h new file mode 100644 index 000000000..b7aae182c --- /dev/null +++ b/src/libCom/error/errMdef.h @@ -0,0 +1,125 @@ +/* errMdef.h err.h - Error Handling definitions */ +/* 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 mm-dd-yy iii Comment + * .02 12-02-91 jrw added GPIB and BB message codes + * .03 03-11-93 joh added __FILE__ and __LINE__ to errMessage() + * .04 04-01-93 joh added vxi + * .05 04-29-93 joh added errPrintStatus() func proto + * .06 09-04-93 rcz added functions ... for errSymLib.c merge + * .07 02-03-94 mrk RTN_SUCCESS is true only if status=0 + * .08 02-03-94 mrk Add access security library + * .09 05-23-95 joh Add bucket hashing library + */ + +#ifndef INCerrMdefh +#define INCerrMdefh + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __STDC__ +# include +#else +# include +#endif +#include + +#define RTN_SUCCESS(STATUS) ((STATUS)==0) + +#define M_dbAccess (501 <<16) /*Database Access Routines */ +#define M_drvSup (503 <<16) /*Driver Support*/ +#define M_devSup (504 <<16) /*Device Support*/ +#define M_recSup (505 <<16) /*Record Support*/ +#define M_recType (506 <<16) /*Record Type*/ +#define M_record (507 <<16) /*Database Records*/ +#define M_ar (508 <<16) /*Archiver; see arDefs.h*/ +#define M_ts (509 <<16) /*Time Stamp Routines; see tsDefs.h*/ +#define M_arAcc (510 <<16) /*Archive Access Library Routines*/ +#define M_bf (511 <<16) /*Block File Routines; see bfDefs.h*/ +#define M_syd (512 <<16) /*Sync Data Routines; see sydDefs.h*/ +#define M_ppr (513 <<16) /*Portable Plot Routines; see pprPlotDefs.h*/ +#define M_env (514 <<16) /*Environment Routines; see envDefs.h*/ +#define M_gen (515 <<16) /*General Purpose Routines; see genDefs.h*/ +#define M_gpib (516 <<16) /*Gpib driver & device support; see drvGpibInterface.h*/ +#define M_bitbus (517 <<16) /*Bitbus driver & device support; see drvBitBusInterface.h*/ +#define M_dbCa (518 <<16) /*CA_LINKs; see calink.h*/ +#define M_dbLib (519 <<16) /*Static Database Access */ +#define M_epvxi (520 <<16) /*VXI Driver*/ +#define M_devLib (521 <<16) /*Device Resource Registration*/ +#define M_asLib (522 <<16) /*Access Security */ +#define M_cas (523 <<16) /*CA server*/ +#define M_casApp (524 <<16) /*CA server application*/ +#define M_bucket (525 <<16) /*Bucket Hash*/ +#define M_sbuf (526 <<16) /*Shared Buffer*/ + + +/* + * redefine errMessage with a macro so we can print + * the file and line number + */ +#define errMessage(S, PM) \ + errPrintf(S, __FILE__, __LINE__, PM) + +#ifdef __STDC__ +int errSymFind(long status, char *name); +int UnixSymFind(long status, char *name, long *value); +int ModSymFind(long status, char *name, long *value); +void errSymTest(unsigned short modnum, unsigned short begErrNum, unsigned short endErrNum); +void errSymTestPrint(long errNum); +int errSymBld(); +int errSymbolAdd (long errNum,char *name); +void errPrintf(long status, const char *pFileName, + int lineno, const char *pformat, ...); +void errSymDump(); +void tstErrSymFind(); +void errInit(void); + +#else /*__STDC__*/ + +void errSymTest(); +int errSymFind(); +int UnixSymFind(); +int ModSymFind(); +void errSymTestPrint(); +int errSymBld(); +int errSymbolAdd(); +void errPrintf(); +void errSymDump(); +void tstErrSymFind(); +#endif /*__STDC__*/ + +extern int errVerbose; + +#ifdef __cplusplus +} +#endif + +#endif /*INCerrMdefh*/ diff --git a/src/libCom/error/error.h b/src/libCom/error/error.h new file mode 100644 index 000000000..cbb0a49f9 --- /dev/null +++ b/src/libCom/error/error.h @@ -0,0 +1,74 @@ +/* error.h - errMessage symbol table header */ +/* 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 mm-dd-yy iii Comment + */ + + +#ifndef INCerrorh +#define INCerrorh 1 + +#define LOCAL static +#define NELEMENTS(array) /* number of elements in an array */ \ + (sizeof (array) / sizeof ((array) [0])) + + +typedef struct /* ERRSYMBOL - entry in symbol table */ + { + char *name; /* pointer to symbol name */ + long errNum; /* errMessage symbol number */ + } ERRSYMBOL; +typedef struct /* ERRSYMTAB - symbol table */ + { + short nsymbols; /* current number of symbols in table */ + ERRSYMBOL *symbols; /* ptr to array of symbol entries */ + } ERRSYMTAB; +typedef ERRSYMTAB *ERRSYMTAB_ID; + +#ifdef vxWorks +#define MYERRNO (errnoGet()&0xffff) +#else +#define MYERRNO errno +#endif + + +/*************************************************************/ +struct errSet { /* This defines one module error set */ + long number; /* dimension of err strings */ + char **papName; /* ptr to arr of ptr to error string */ +}; +struct errDes { /* An array of error sets for modules */ + long number; /* number of err modules */ + struct errSet **papErrSet; /* ptr to arr of ptr to errSet */ +}; +extern struct errDes *dbErrDes; +/*************************************************************/ + +#endif /*INCerrorh*/ diff --git a/src/libCom/fdmgr.h b/src/libCom/fdmgr.h new file mode 100644 index 000000000..c7fcf9944 --- /dev/null +++ b/src/libCom/fdmgr.h @@ -0,0 +1,272 @@ +/* fdmgr.h + * + * share/epicsH/$Id$ + * + * Header file associated with a file descriptor manager + * for use with the UNIX system call select + * + * Author Jeffrey O. Hill + * hill@atdiv.lanl.gov + * 505 665 1831 + * + * 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 + * + * + * + * History + * .00 joh 011993 Created + * .01 pg 050494 HPUX port modifications. + * + * + */ + +#ifndef includeFdmgrH +#define includeFdmgrH + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#if defined(vxWorks) +# include +# include +# include +# include +# include +# include +# define FDMGR_OS vxWorks +#endif + +#if defined(UNIX) +# include +# include +# include +# define FDMGR_OS UNIX +#endif + +#if defined(WIN32) +# include +# include +# include +# include +# include +# define FDMGR_OS WIN32 +#endif + +#if defined(VMS) +# include +# include +# include +# define FDMGR_OS VMS +#endif + +#ifndef FDMGR_OS +Please Define an OS Type +#endif + + +enum fdi_type {fdi_read, fdi_write, fdi_excp}; +enum alarm_list_type {alt_invalid, alt_alarm, alt_expired, alt_free}; + +typedef struct{ + ELLLIST fdentry_list; + ELLLIST fdentry_in_use_list; + ELLLIST fdentry_free_list; + ELLLIST alarm_list; + ELLLIST expired_alarm_list; + ELLLIST free_alarm_list; + fd_set readch; + fd_set writech; + fd_set excpch; + BUCKET *pAlarmBucket; + unsigned nextAlarmId; + int maxfd; + int select_tmo; +# if defined (vxWorks) + SEM_ID lock; + SEM_ID fdmgr_pend_event_lock; + SEM_ID expired_alarm_lock; + SEM_ID fd_handler_lock; + unsigned long clk_rate; /* ticks per sec */ + unsigned long last_tick_count; + unsigned long sec_offset; + WIND_TCB *fdmgr_pend_event_tid; +# else + unsigned fdmgr_pend_event_in_use; +# endif +}fdctx; + +/* + * C "typedef" name "alarm" was changed to "fdmgrAlarm" to avoid collisions + * with other libraries. Next the identifier was changed again to + * an unsigned integer type "fdmgrAlarmId". + * + * This "#define" is for codes that used to use a pointer to the old typedef + * "alarm" or "fdmgrAlarm" types to identify an alarm. + * + * ie the following code will allow compilation against + * all versions: + * + * #if defined (NEW_FDMGR_ALARMID) + * fdmgrAlarmId XXXX + * #elif defined (NEW_FDMGR_ALARM) + * fdmgrAlarm *XXXX; + * #else + * alarm *XXXX; + * #endif + * + * XXXX = fdmgrAlarmId fdmgr_add_timeout() + */ +typedef unsigned fdmgrAlarmId; +#define NEW_FDMGR_ALARMID + +#ifdef __STDC__ + +/* + * + * Initialize a file descriptor manager session + * + */ +fdctx *fdmgr_init(void); + +/* + * Specify a function to be called with a specified parameter + * after a specified delay relative to the current time + * + * Returns fdmgrNoAlarm (zero) if alarm cant be created + */ +#define fdmgrNoAlarm 0 +fdmgrAlarmId fdmgr_add_timeout( +fdctx *pfdctx, /* fd mgr ctx from fdmgr_init() */ +struct timeval *ptimeout, /* relative delay from current time */ +void (*func)(void *pParam), + /* function (handler) to call */ +void *param /* first parameter passed to the func */ +); + +/* + * Clear a timeout which has not executed its function (handler) + * yet. + */ +int fdmgr_clear_timeout( +fdctx *pfdctx, /* fd mgr ctx from fdmgr_init() */ +fdmgrAlarmId id /* alarm to delete */ +); + +/* + * + * Specify a function (handler) to be called with a specified parameter + * when a file descriptor becomes active. The parameter fdi (file + * descriptor interest) specifies the type of activity (IO) we wish + * to be informed of: read, write, or exception. For more + * info on this see the man pages for the UNIX system call select(). + * + * read and exception callbacks are permanent( ie the application's + * function (handler) continues to be called each time the + * file descriptor becomes active until fdmgr_add_callback() + * is called). + * + * write callbacks are called only once after each call to + * fdmgr_add_callback() + * + */ +int fdmgr_add_callback( +fdctx *pfdctx, /* fd mgr ctx from fdmgr_init() */ +int fd, /* file descriptor */ +enum fdi_type fdi, /* file descriptor interest type */ +void (*pfunc)(void *pParam), /* function (handler) to call */ +void *param /* first parameter passed to the func */ +); + +/* + * + * Clear nterest in a type of file descriptor activity (IO). + * + */ +int fdmgr_clear_callback( +fdctx *pfdctx, /* fd mgr ctx from fdmgr_init() */ +int fd, /* file descriptor */ +enum fdi_type fdi /* file descriptor interest type */ +); + +/* + * + * Wait a specified delay relative from the current time for file + * descriptor activity (IO) or timeouts (timer expiration). Application + * specified functions (handlers) will not be called unless the + * application waits in this function or polls it frequently + * enough. + * + */ +int fdmgr_pend_event( +fdctx *pfdctx, /* fd mgr ctx from fdmgr_init() */ +struct timeval *ptimeout +); + + +/* + * obsolete interface + */ +int fdmgr_clear_fd( +fdctx *pfdctx, /* fd mgr ctx from fdmgr_init() */ +int fd +); + +/* + * obsolete interface + */ +int fdmgr_add_fd( +fdctx *pfdctx, /* fd mgr ctx from fdmgr_init() */ +int fd, +void (*pfunc)(void *pParam), +void *param +); + +int fdmgr_delete(fdctx *pfdctx); + +#else + +fdctx *fdmgr_init(); +fdmgrAlarmId fdmgr_add_timeout(); +int fdmgr_clear_timeout(); +int fdmgr_add_callback(); +int fdmgr_clear_callback(); +int fdmgr_pend_event(); +int fdmgr_delete(); + +/* + * obsolete interface + */ +int fdmgr_clear_fd(); +int fdmgr_add_fd(); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef includeFdmgrH (last line in this file) */ + diff --git a/src/libCom/fdmgr/fdmgr.h b/src/libCom/fdmgr/fdmgr.h new file mode 100644 index 000000000..c7fcf9944 --- /dev/null +++ b/src/libCom/fdmgr/fdmgr.h @@ -0,0 +1,272 @@ +/* fdmgr.h + * + * share/epicsH/$Id$ + * + * Header file associated with a file descriptor manager + * for use with the UNIX system call select + * + * Author Jeffrey O. Hill + * hill@atdiv.lanl.gov + * 505 665 1831 + * + * 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 + * + * + * + * History + * .00 joh 011993 Created + * .01 pg 050494 HPUX port modifications. + * + * + */ + +#ifndef includeFdmgrH +#define includeFdmgrH + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#if defined(vxWorks) +# include +# include +# include +# include +# include +# include +# define FDMGR_OS vxWorks +#endif + +#if defined(UNIX) +# include +# include +# include +# define FDMGR_OS UNIX +#endif + +#if defined(WIN32) +# include +# include +# include +# include +# include +# define FDMGR_OS WIN32 +#endif + +#if defined(VMS) +# include +# include +# include +# define FDMGR_OS VMS +#endif + +#ifndef FDMGR_OS +Please Define an OS Type +#endif + + +enum fdi_type {fdi_read, fdi_write, fdi_excp}; +enum alarm_list_type {alt_invalid, alt_alarm, alt_expired, alt_free}; + +typedef struct{ + ELLLIST fdentry_list; + ELLLIST fdentry_in_use_list; + ELLLIST fdentry_free_list; + ELLLIST alarm_list; + ELLLIST expired_alarm_list; + ELLLIST free_alarm_list; + fd_set readch; + fd_set writech; + fd_set excpch; + BUCKET *pAlarmBucket; + unsigned nextAlarmId; + int maxfd; + int select_tmo; +# if defined (vxWorks) + SEM_ID lock; + SEM_ID fdmgr_pend_event_lock; + SEM_ID expired_alarm_lock; + SEM_ID fd_handler_lock; + unsigned long clk_rate; /* ticks per sec */ + unsigned long last_tick_count; + unsigned long sec_offset; + WIND_TCB *fdmgr_pend_event_tid; +# else + unsigned fdmgr_pend_event_in_use; +# endif +}fdctx; + +/* + * C "typedef" name "alarm" was changed to "fdmgrAlarm" to avoid collisions + * with other libraries. Next the identifier was changed again to + * an unsigned integer type "fdmgrAlarmId". + * + * This "#define" is for codes that used to use a pointer to the old typedef + * "alarm" or "fdmgrAlarm" types to identify an alarm. + * + * ie the following code will allow compilation against + * all versions: + * + * #if defined (NEW_FDMGR_ALARMID) + * fdmgrAlarmId XXXX + * #elif defined (NEW_FDMGR_ALARM) + * fdmgrAlarm *XXXX; + * #else + * alarm *XXXX; + * #endif + * + * XXXX = fdmgrAlarmId fdmgr_add_timeout() + */ +typedef unsigned fdmgrAlarmId; +#define NEW_FDMGR_ALARMID + +#ifdef __STDC__ + +/* + * + * Initialize a file descriptor manager session + * + */ +fdctx *fdmgr_init(void); + +/* + * Specify a function to be called with a specified parameter + * after a specified delay relative to the current time + * + * Returns fdmgrNoAlarm (zero) if alarm cant be created + */ +#define fdmgrNoAlarm 0 +fdmgrAlarmId fdmgr_add_timeout( +fdctx *pfdctx, /* fd mgr ctx from fdmgr_init() */ +struct timeval *ptimeout, /* relative delay from current time */ +void (*func)(void *pParam), + /* function (handler) to call */ +void *param /* first parameter passed to the func */ +); + +/* + * Clear a timeout which has not executed its function (handler) + * yet. + */ +int fdmgr_clear_timeout( +fdctx *pfdctx, /* fd mgr ctx from fdmgr_init() */ +fdmgrAlarmId id /* alarm to delete */ +); + +/* + * + * Specify a function (handler) to be called with a specified parameter + * when a file descriptor becomes active. The parameter fdi (file + * descriptor interest) specifies the type of activity (IO) we wish + * to be informed of: read, write, or exception. For more + * info on this see the man pages for the UNIX system call select(). + * + * read and exception callbacks are permanent( ie the application's + * function (handler) continues to be called each time the + * file descriptor becomes active until fdmgr_add_callback() + * is called). + * + * write callbacks are called only once after each call to + * fdmgr_add_callback() + * + */ +int fdmgr_add_callback( +fdctx *pfdctx, /* fd mgr ctx from fdmgr_init() */ +int fd, /* file descriptor */ +enum fdi_type fdi, /* file descriptor interest type */ +void (*pfunc)(void *pParam), /* function (handler) to call */ +void *param /* first parameter passed to the func */ +); + +/* + * + * Clear nterest in a type of file descriptor activity (IO). + * + */ +int fdmgr_clear_callback( +fdctx *pfdctx, /* fd mgr ctx from fdmgr_init() */ +int fd, /* file descriptor */ +enum fdi_type fdi /* file descriptor interest type */ +); + +/* + * + * Wait a specified delay relative from the current time for file + * descriptor activity (IO) or timeouts (timer expiration). Application + * specified functions (handlers) will not be called unless the + * application waits in this function or polls it frequently + * enough. + * + */ +int fdmgr_pend_event( +fdctx *pfdctx, /* fd mgr ctx from fdmgr_init() */ +struct timeval *ptimeout +); + + +/* + * obsolete interface + */ +int fdmgr_clear_fd( +fdctx *pfdctx, /* fd mgr ctx from fdmgr_init() */ +int fd +); + +/* + * obsolete interface + */ +int fdmgr_add_fd( +fdctx *pfdctx, /* fd mgr ctx from fdmgr_init() */ +int fd, +void (*pfunc)(void *pParam), +void *param +); + +int fdmgr_delete(fdctx *pfdctx); + +#else + +fdctx *fdmgr_init(); +fdmgrAlarmId fdmgr_add_timeout(); +int fdmgr_clear_timeout(); +int fdmgr_add_callback(); +int fdmgr_clear_callback(); +int fdmgr_pend_event(); +int fdmgr_delete(); + +/* + * obsolete interface + */ +int fdmgr_clear_fd(); +int fdmgr_add_fd(); + +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* ifndef includeFdmgrH (last line in this file) */ + diff --git a/src/libCom/freeList.h b/src/libCom/freeList.h new file mode 100644 index 000000000..9d2784a7a --- /dev/null +++ b/src/libCom/freeList.h @@ -0,0 +1,63 @@ +/* share/epicsH/freeList.h */ +/* share/epicsH $Id$ */ +/* Author: Marty Kraimer Date: 04-19-94 */ +/***************************************************************** + 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). + * + * Modification Log: + * ----------------- + * .01 04-19-94 mrk Initial Implementation + */ + +#ifndef INCfreeListh +#define INCfreeListh + +void freeListInitPvt(void **ppvt,int size,int nmalloc); +void *freeListCalloc(void *pvt); +void *freeListMalloc(void *pvt); +void freeListFree(void *pvt,void*pmem); +void freeListCleanup(void *pvt); +#endif /*INCfreeListh*/ diff --git a/src/libCom/freeList/freeList.h b/src/libCom/freeList/freeList.h new file mode 100644 index 000000000..9d2784a7a --- /dev/null +++ b/src/libCom/freeList/freeList.h @@ -0,0 +1,63 @@ +/* share/epicsH/freeList.h */ +/* share/epicsH $Id$ */ +/* Author: Marty Kraimer Date: 04-19-94 */ +/***************************************************************** + 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). + * + * Modification Log: + * ----------------- + * .01 04-19-94 mrk Initial Implementation + */ + +#ifndef INCfreeListh +#define INCfreeListh + +void freeListInitPvt(void **ppvt,int size,int nmalloc); +void *freeListCalloc(void *pvt); +void *freeListMalloc(void *pvt); +void freeListFree(void *pvt,void*pmem); +void freeListCleanup(void *pvt); +#endif /*INCfreeListh*/ diff --git a/src/libCom/gpHash.h b/src/libCom/gpHash.h new file mode 100644 index 000000000..7d9623273 --- /dev/null +++ b/src/libCom/gpHash.h @@ -0,0 +1,78 @@ +/* gpHash.h */ +/* share/epicsH $Id$ */ +/* Author: Marty Kraimer Date: 04-07-94 */ +/***************************************************************** + 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). + * + * Modification Log: + * ----------------- + * .01 04-07-94 mrk Initial Implementation + */ + +/* gph provides a general purpose directory accessed via a hash table*/ +#ifndef INCgpHashh +#define INCgpHashh 1 + +#include +#ifdef vxWorks +#include +#endif + +typedef struct{ + ELLNODE node; + char *name; /*address of name placed in directory*/ + void *pvtid; /*private name for subsystem user*/ + void *userPvt; /*private for user*/ +} GPHENTRY; + +/*tableSize must be power of 2 in range 256 to 65536*/ +void gphInitPvt(void **ppvt,int tableSize); +GPHENTRY *gphFind(void *pvt,char *name,void *pvtid); +GPHENTRY *gphAdd(void *pvt,char *name,void *pvtid); +void gphDelete(void *pvt,char *name,void *pvtid); +void gphFreeMem(void *pvt); +void gphDump(void *pvt); +#endif /*INCgpHashh*/ diff --git a/src/libCom/gpHash/gpHash.h b/src/libCom/gpHash/gpHash.h new file mode 100644 index 000000000..7d9623273 --- /dev/null +++ b/src/libCom/gpHash/gpHash.h @@ -0,0 +1,78 @@ +/* gpHash.h */ +/* share/epicsH $Id$ */ +/* Author: Marty Kraimer Date: 04-07-94 */ +/***************************************************************** + 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). + * + * Modification Log: + * ----------------- + * .01 04-07-94 mrk Initial Implementation + */ + +/* gph provides a general purpose directory accessed via a hash table*/ +#ifndef INCgpHashh +#define INCgpHashh 1 + +#include +#ifdef vxWorks +#include +#endif + +typedef struct{ + ELLNODE node; + char *name; /*address of name placed in directory*/ + void *pvtid; /*private name for subsystem user*/ + void *userPvt; /*private for user*/ +} GPHENTRY; + +/*tableSize must be power of 2 in range 256 to 65536*/ +void gphInitPvt(void **ppvt,int tableSize); +GPHENTRY *gphFind(void *pvt,char *name,void *pvtid); +GPHENTRY *gphAdd(void *pvt,char *name,void *pvtid); +void gphDelete(void *pvt,char *name,void *pvtid); +void gphFreeMem(void *pvt); +void gphDump(void *pvt); +#endif /*INCgpHashh*/ diff --git a/src/libCom/memDebugLib.h b/src/libCom/memDebugLib.h new file mode 100644 index 000000000..486d726b1 --- /dev/null +++ b/src/libCom/memDebugLib.h @@ -0,0 +1,73 @@ +/* share/epicsH $Id$ + * memDebugLib.h + * Author: Jeff Hill + * Date: 03-29-94 + * + * 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 iii Comment + */ + +#ifndef __INCmemDebugLibh +#define __INCmemDebugLibh + +/* + * force the first inclusion of stdlib.h + * so that the redefine of malloc, free, etc + * does not redefine the declaration of + * free and malloc + */ +#include + +extern unsigned memDebugLevel; + +#ifdef __STDC__ +char *memDebugMalloc(char *pFile, unsigned long line, unsigned long size); +char *memDebugCalloc(char *pFile, unsigned long line, + unsigned long nelem, unsigned long elsize); +void memDebugFree(char *pFile, unsigned long line, void *ptr); +int memDebugVerifyAll(); +int memDebugPrintAll(unsigned long ignoreBeforeThisTick); +#else /*__STDC__*/ +char *memDebugMalloc(); +char *memDebugCalloc(); +void memDebugFree(); +int memDebugVerifyAll(); +int memDebugPrintAll(); +#endif /*__STDC__*/ + +/* + * If this is enabled then declarations + * of malloc, calloc, or free below this point in the src + * will cause problems + */ +#ifdef __REPLACE_ALLOC_CALLS__ +#define malloc(S) memDebugMalloc(__FILE__,__LINE__,S) +#define calloc(N,S) memDebugCalloc(__FILE__,__LINE__,N,S) +#define free(P) memDebugFree(__FILE__,__LINE__,P) +#endif /* __REPLACE_ALLOC_CALLS__ */ + +#endif /*__INCmemDebugLibh*/ + + diff --git a/src/libCom/osi/epicsAssert.h b/src/libCom/osi/epicsAssert.h new file mode 100644 index 000000000..aff367653 --- /dev/null +++ b/src/libCom/osi/epicsAssert.h @@ -0,0 +1,80 @@ +/* $Id$ + * + * EPICS assert + * + * Author: Jeffrey O. Hill + * Date: 022795 + * + * 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 assertEPICS +#define assertEPICS + +#ifdef __cplusplus +extern "C" { +#endif + +#undef assert + +#ifdef NDEBUG +# define assert(ignore) ((void) 0) +#else /* NDEBUG */ + +#if defined(__STDC__) || defined(__cplusplus) + +extern void epicsAssert (const char *pFile, const unsigned line, + const char *pMsg, const char *pAuthorName); + +#ifdef epicsAssertAuthor +#define assert(exp) \ +{if (!(exp)) epicsAssert (__FILE__, __LINE__, #exp, epicsAssertAuthor);} +#else /* epicsAssertAuthor */ +#define assert(exp) \ +{if (!(exp)) epicsAssert (__FILE__, __LINE__, #exp, 0);} +#endif /* epicsAssertAuthor */ + +#else /*__STDC__ or __cplusplus*/ + +extern void epicsAssert (); + +#ifdef epicsAssertAuthor +#define assert(exp) \ +{if (!(exp)) epicsAssert (__FILE__, __LINE__, "", epicsAssertAuthor);} +#else /* epicsAssertAuthor */ +{if (!(exp)) epicsAssert (__FILE__, __LINE__, "", 0);} +#endif /* epicsAssertAuthor */ + +#endif /*__STDC__ or __cplusplus*/ + +#endif /* NDEBUG */ + +#ifdef __cplusplus +} +#endif + + +#endif /* assertEPICS */ + diff --git a/src/libCom/pal.h b/src/libCom/pal.h new file mode 100644 index 000000000..9aded6bb9 --- /dev/null +++ b/src/libCom/pal.h @@ -0,0 +1,82 @@ +/* base/include $Id$ */ + +/* + * pal.h + * + * PAL emulator header file + * AT-8 hardware design + * + */ + +/* + * general constants + */ +#define INTBITS 32 /* # of bits in an integer */ +#define NORMAL 0 /* normal polarity */ +#define INVERTED 1 /* inverted polarity */ +#define REGISTERED 1 /* registered output */ +#define COMBINATORIAL 0 /* combinatorial output */ +#define RETRY 3 /* file open retry count */ + +/* + * PAL data structures + */ +struct rowsel + { + int prow; /* primary fuse row */ + int arow; /* alternate fuse row */ + int sel; /* macrocell select bit */ + int psel; /* sel value for prow */ + }; + +struct blk + { + unsigned int *array; /* fuse array */ + int blksiz; /* pal block size (in product terms) */ + int loc; /* starting fuse address */ + int pol; /* output polarity */ + int typ; /* combinatorial or registered */ + int val; /* current value */ + int row; /* feedback row */ + int nrofst; /* row offset for negative feedback */ + struct rowsel *rsel; /* feedback row select info */ + }; + +struct thresh + { + double hithresh; /* logic "1" threshold */ + double lothresh; /* logic "0" threshold */ + int val; /* current value */ + int row; /* fuse row */ + int nrofst; /* row offset for regative feedback */ + struct rowsel *rsel; /* input row select info */ + }; + +struct palinit + { + int mc[8]; /* macrocell config data */ + char *path; /* path to files */ + char *name; /* PAL device type */ + char *def; /* JEDEC definition file */ + int blk0; /* starting fuse address of first pal block */ + int polloc; /* starting fuse address of polarity info */ + int typloc; /* starting fuse address of output type info */ + int s0; /* starting fuse address of macrocell config bits */ + int snum; /* number of config bits */ + }; + +struct pal + { + struct pal *flink; /* link to next PAL */ + char *recnam; /* record name */ + struct blk *bptr; /* PAL block data */ + struct thresh *ithresh; /* input limit data */ + int *scan; /* scan order data */ + struct palinit *iptr; /* initialization data */ + int blkelm; /* longwords per product term */ + int blkbits; /* bits per product term */ + int blknum; /* number of pal blocks in device */ + int inp; /* number of inputs */ + int blktyp; /* macrocell type */ + }; + diff --git a/src/libCom/tsDefs.h b/src/libCom/tsDefs.h new file mode 100644 index 000000000..9154f78c7 --- /dev/null +++ b/src/libCom/tsDefs.h @@ -0,0 +1,320 @@ +#ifndef INC_tsDefs_h +#define INC_tsDefs_h +/* $Id$ + * Author: Roger A. Cole + * Date: 08-09-90 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991-92, 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 08-09-90 rac initial version + * .02 06-18-91 rac installed in SCCS + * .03 08-03-92 rac added tsRound routines + * + */ +/*+/mod*********************************************************************** +* TITLE tsDefs.h - time-stamp related definitions +* +* DESCRIPTION +* +* BUGS +* o only a single, manually configured, conversion between local +* time and GMT is supported. Thus, if a new `rule' for daylight +* savings time were invented, then this code would be `broken' +* until this file were configured for the new rule. BUT, then +* this code is `broken' for the period prior to the new rule's +* effect. +* o only dates following Jan 1, 1990 are handled; stamps on Jan 1, +* 1990 are treated as `dateless' times. +* +*-***************************************************************************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include /* get M_ts for this subsystem's `number' */ + +/*--------------------------------------------------------------------------- +- +* TS_STAMP +* +* This is the form taken by time stamps in GTACS, and is the form used +* by the various tools used for dealing with time stamps. +* +* The time stamp represents the number of nanoseconds past 0000 Jan 1, 199 +0, +* GMT (or UTC, if you prefer). +* +*---------------------------------------------------------------------------- +*/ +typedef struct { + unsigned secPastEpoch; /* seconds since 0000 Jan 1, 1990 */ + unsigned nsec; /* nanoseconds within second */ +} TS_STAMP; + +/*---------------------------------------------------------------------------- +* TS_TEXT_xxx text type codes for converting between text and time stamp +* +* TS_TEXT_MONDDYYYY Mon dd, yyyy hh:mm:ss.nano-secs +* TS_TEXT_MMDDYY mm/dd/yy hh:mm:ss.nano-secs +* 123456789012345678901234567890123456789 +* 0 1 2 3 +*----------------------------------------------------------------------------*/ +enum tsTextType{ + TS_TEXT_MONDDYYYY, + TS_TEXT_MMDDYY +}; + +/*/subhead configuration------------------------------------------------------ +* C O N F I G U R A T I O N D E F I N I T I O N S +* +* TS_DST_BEGIN the day number for starting DST +* TS_DST_END the day number for ending DST +* TS_MIN_WEST the number of minutes west of GMT for time zone (zones east +* will have negative values) +* TS_DST_HOUR_ON the hour (standard time) when DST turns on +* TS_DST_HOUR_OFF the hour (standard time) when DST turns off +* TS_DST_HRS_ADD hours to add when DST is on +* +* day numbers start with 0 for Jan 1; day numbers in these defines are +* based on a NON-leap year. The start and end days for DST are assumed to be +* Sundays. A negative day indicates that the following Sunday is to be used; +* a positive day indicates the prior Sunday. If the begin date is larger than +* the end date, then DST overlaps the change of the year (e.g., for southern +* hemisphere). +* +* Note well that TS_DST_HOUR_ON and TS_DST_HOUR_OFF are both STANDARD time. +* So, if dst begins at 2 a.m. (standard time) and ends at 2 a.m. (daylight +* time), the two values would be 2 and 1, respectively (assuming +* TS_DST_HRS_ADD is 1). +*----------------------------------------------------------------------------*/ +#define TS_DST_BEGIN -90 /* first Sun in Apr (Apr 1 = 90) */ +#define TS_DST_END 303 /* last Sun in Oct (Oct 31 = 303) */ +#define TS_DST_HOUR_ON 2 /* 2 a.m. (standard time) */ +#define TS_DST_HOUR_OFF 1 /* 2 a.m. (1 a.m. standard time) */ +#define TS_DST_HRS_ADD 1 /* add one hour */ +#define TS_MIN_WEST 7 * 60 /* USA mountain time zone */ +#if 0 /* first set is for testing only */ +#define TS_EPOCH_YEAR 1989 +#define TS_EPOCH_SEC_PAST_1970 6940*86400 /* 1/1/89 19 yr (5 leap) of seconds */ +#define TS_EPOCH_WDAY_NUM 0 /* Jan 1 1989 was Sun (wkday num = 0) */ +#else +#define TS_EPOCH_YEAR 1990 +#define TS_EPOCH_SEC_PAST_1970 7305*86400 /* 1/1/90 20 yr (5 leap) of seconds */ +#define TS_EPOCH_WDAY_NUM 1 /* Jan 1 1990 was Mon (wkday num = 1) */ +#endif +#define TS_MAX_YEAR TS_EPOCH_YEAR+134 /* ULONG can handle 135 years */ +#define TS_TRUNC 1000000 /* truncate to milli-second significance */ + +/*/subhead struct tsDetail---------------------------------------------------- +* breakdown structure for working with secPastEpoch +*----------------------------------------------------------------------------*/ + +struct tsDetail { + int year; /* 4 digit year */ + int dayYear; /* day number in year; 0 = Jan 1 */ + int monthNum; /* month number; 0 = Jan */ + int dayMonth; /* day number; 0 = 1st of month */ + int hours; /* hours within day */ + int minutes; /* minutes within hour */ + int seconds; /* seconds within minute */ + int dayOfWeek; /* weekday number; 0 = Sun */ + int leapYear; /* (0, 1) for year (isn't, is) a leap year */ + char dstOverlapChar; /* indicator for distinguishing duplicate + times in the `switch to standard' time period: + ':'--time isn't ambiguous; + 's'--time is standard time + 'd'--time is daylight time */ +}; + +/*/subhead status codes------------------------------------------------------- +* S T A T U S C O D E S +* +* +* Status codes for time stamp routines have the form S_ts_briefMessage . +* +* The macro TsStatusToText(stat) can be used to obtain a text string +* corresponding to a status code. +* +*----------------------------------------------------------------------------*/ +#define S_ts_OK 0 +#define S_ts_sysTimeError (M_ts|1| 1<<1) /* error getting system time */ +#define S_ts_badTextCode (M_ts|1| 2<<1) /* invalid TS_TEXT_xxx code */ +#define S_ts_inputTextError (M_ts|1| 3<<1) /* error in text date or time */ +#define S_ts_timeSkippedDST (M_ts|1| 4<<1) /* time skipped on switch to DST */ +#define S_ts_badRoundInterval (M_ts|1| 5<<1) /* invalid rounding interval */ + +#define TS_S_PAST 6 /* one past last legal code */ + +#define TsStatusToIndex(status) \ + ( ((status&0xffff0000)!=M_ts) \ + ? TS_S_PAST \ + : ( (((status&0xffff)>>1)>=TS_S_PAST) \ + ? TS_S_PAST \ + : ((status&0xffff)>>1) \ + ) \ + ) + +#define TsStatusToText(status) \ + (glTsStatText[TsStatusToIndex(status)]) + +#ifndef TS_PRIVATE_DATA + epicsShareExtern char *glTsStatText[7]; +#else + char *glTsStatText[] = { + /* S_ts_OK */ "success", + /* S_ts_sysTimeError */ "error getting system time", + /* S_ts_badTextCode */ "invalid TS_TEXT_xxx code", + /* S_ts_inputTextError */ "error in text date or time", + /* S_ts_timeSkippedDST */ "time skipped on switch to DST", + /* S_ts_badRoundInterval */ "rounding interval is invalid", + + /* TS_S_PAST */ "illegal TS status code", + }; +#endif + +/*/subhead macros------------------------------------------------------------- +* arithmetic macros +* +* care has been taken in writing these macros that the result can +* be stored back into either operand time stamp. For example, +* both of the following (as well as other variations) are legal: +* TsAddStamps(pS1, pS1, pS2); +* TsDiffAsStamp(pS2, pS1, pS2); +*----------------------------------------------------------------------------*/ +#if WIN32 /* the microsoft compiler will not compile the TsAddDouble() macro */ +#define TsAddDouble(pSum, pS1, dbl) tsAddDouble(pSum, pS1, dbl) +void TsAddDouble(TS_STAMP *pSum, TS_STAMP *pS1, double dbl); +#else /*WIN32*/ +#define TsAddDouble(pSum, pS1, dbl) \ + (void)( \ + dbl >= 0. \ + ? ((*pSum).secPastEpoch = (*pS1).secPastEpoch + (unsigned long)dbl, \ + ( ((*pSum).nsec = (*pS1).nsec + (unsigned long)(1000000000. * \ + (dbl - (double)((unsigned long)dbl))) ) ) \ + >= 1000000000 \ + ?((*pSum).secPastEpoch += (*pSum).nsec/1000000000, \ + (*pSum).nsec %= 1000000000) \ + :0) \ + : ((*pSum).secPastEpoch = (*pS1).secPastEpoch - (unsigned long)(-dbl), \ + (*pS1).nsec >= (unsigned long)(1000000000. * \ + ((-dbl) - (double)((unsigned long)(-dbl)))) \ + ?( (*pSum).nsec = (*pS1).nsec - (unsigned long)(1000000000.* \ + ((-dbl) - (double)((unsigned long)(-dbl))))) \ + :( (*pSum).nsec = (*pS1).nsec + 1000000000 - \ + (unsigned long)(1000000000.* \ + ((-dbl) - (double)((unsigned long)(-dbl)))), \ + (*pSum).secPastEpoch -= 1) ) ) +#endif /*WIN32*/ +#define TsAddStamps(pSum, pS1, pS2) \ + (void)( \ + ((*pSum).secPastEpoch = (*pS1).secPastEpoch + (*pS2).secPastEpoch) , \ + ( ((*pSum).nsec = (*pS1).nsec + (*pS2).nsec) >= 1000000000 \ + ?((*pSum).secPastEpoch += (*pSum).nsec/1000000000, \ + (*pSum).nsec %= 1000000000) \ + :0) ) +#define TsDiffAsDouble(pDbl, pS1, pS2) \ + (void)( \ + *pDbl = ((double)(*pS1).nsec - (double)(*pS2).nsec)/1000000000., \ + *pDbl += (double)(*pS1).secPastEpoch - (double)(*pS2).secPastEpoch ) +/* TsDiffAsStamp() assumes that stamp1 >= stamp2 */ +#define TsDiffAsStamp(pDiff, pS1, pS2) \ + (void)( \ + (*pDiff).secPastEpoch = (*pS1).secPastEpoch - (*pS2).secPastEpoch , \ + (*pS1).nsec >= (*pS2).nsec \ + ?( (*pDiff).nsec = (*pS1).nsec - (*pS2).nsec ) \ + :( (*pDiff).nsec = ((*pS1).nsec + 1000000000) - (*pS2).nsec, \ + (*pDiff).secPastEpoch -= 1 ) ) +/*---------------------------------------------------------------------------- +* comparison macros +*----------------------------------------------------------------------------*/ +#define TsCmpStampsEQ(pS1, pS2) \ + (((*pS1).secPastEpoch) == ((*pS2).secPastEpoch) && \ + ((*pS1).nsec) == ((*pS2).nsec)) +#define TsCmpStampsNE(pS1, pS2) \ + (((*pS1).secPastEpoch) != ((*pS2).secPastEpoch) || \ + ((*pS1).nsec) != ((*pS2).nsec)) +#define TsCmpStampsGT(pS1, pS2) \ + ((((*pS1).secPastEpoch) > ((*pS2).secPastEpoch)) \ + ?1 \ + :((((*pS1).secPastEpoch) == ((*pS2).secPastEpoch)) \ + ?((((*pS1).nsec) > ((*pS2).nsec)) ? 1 : 0) \ + :0 )) +#define TsCmpStampsGE(pS1, pS2) \ + ((((*pS1).secPastEpoch) > ((*pS2).secPastEpoch)) \ + ?1 \ + :((((*pS1).secPastEpoch) == ((*pS2).secPastEpoch)) \ + ?((((*pS1).nsec) >= ((*pS2).nsec)) ? 1 : 0) \ + :0 )) +#define TsCmpStampsLT(pS1, pS2) \ + ((((*pS1).secPastEpoch) < ((*pS2).secPastEpoch)) \ + ?1 \ + :((((*pS1).secPastEpoch) == ((*pS2).secPastEpoch)) \ + ?((((*pS1).nsec) < ((*pS2).nsec)) ? 1 : 0) \ + :0 )) +#define TsCmpStampsLE(pS1, pS2) \ + ((((*pS1).secPastEpoch) < ((*pS2).secPastEpoch)) \ + ?1 \ + :((((*pS1).secPastEpoch) == ((*pS2).secPastEpoch)) \ + ?((((*pS1).nsec) <= ((*pS2).nsec)) ? 1 : 0) \ + :0 )) +/*---------------------------------------------------------------------------- +* `prototypes' +*----------------------------------------------------------------------------*/ + +int nextIntFieldAsInt( +char **ppText, /* I/O pointer to pointer to text to scan */ +int *pIntVal, /* O pointer to return field's value */ +char *pDelim /* O pointer to return field's delimiter */ +); + +int nextAlph1UCField( +char **ppText, /* I/O pointer to pointer to text to scan */ +char **ppField, /* O pointer to pointer to field */ +char *pDelim /* O pointer to return field's delimiter */ +); + +int nextIntFieldAsLong( +char **ppText, /* I/O pointer to pointer to text to scan */ +long *pLongVal, /* O pointer to return field's value */ +char *pDelim /* O pointer to return field's delimiter */ +); + +long tsLocalTime (TS_STAMP *pStamp); +void tsAddDouble(); +int tsCmpStamps(); +void tsDiffAsDouble(); +long tsRoundDownLocal(); +long tsRoundUpLocal(); +char *tsStampToText(); +long tsTextToStamp(); +long tsTimeTextToStamp(); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/sequencer/Makefile.Unix b/src/sequencer/Makefile.Unix index df6da61c0..f41b17cde 100644 --- a/src/sequencer/Makefile.Unix +++ b/src/sequencer/Makefile.Unix @@ -9,6 +9,11 @@ include $(EPICS)/config/CONFIG_BASE USR_LDLIBS = -ll YACCOPT = -d -v +INC += seq.h +INC += seqCom.h +INC += seqU.h +INC += seq_taskLib.h + SRCS.c = ../snc_main.c ../parse.c ../phase2.c ../gen_ss_code.c \ ../gen_tables.c sncVersion.c snc.c diff --git a/src/sequencer/seq.h b/src/sequencer/seq.h new file mode 100644 index 000000000..0a733ea07 --- /dev/null +++ b/src/sequencer/seq.h @@ -0,0 +1,198 @@ +/* /share/epicsH %W% %G% + * + * DESCRIPTION: Definitions for the run-time sequencer. + * + * Author: Andy Kozubal + * Date: + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991,2,3, 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: + * ----------------- + * 07mar91,ajk Changed SSCB semaphore id names. + * 05jul91,ajk Added function prototypes. + * 16dec91,ajk Setting up for VxWorks version 5. + * 27apr92,ajk Changed to new event flag mode (SSCB & PROG changed). + * 27apr92,ajk Removed getSemId from CHAN. + * 28apr92,ajk Implemented new event flag mode. + * 17feb93,ajk Fixed some functions prototypes. + * 10jun93,ajk Removed VxWorks V4/V5 conditional compile. + * 20jul93,ajk Removed non-ANSI function definitions. + * 21mar94,ajk Implemented new i/f with snc (see seqCom.h). + * 21mar94,ajk Implemented assignment of array elements to db. Also, + allow "unlimited" number of channels. + * 28mar94,ajk Added time stamp support. + * 29mar94,ajk Added dbOffset in db_channel structure; allows faster processing + of values returned with monitors and pvGet(). + */ +#ifndef INCLseqh +#define INCLseqh + +#ifndef TRUE +#include +#endif + +#include "seqCom.h" + +#ifndef VOID +#include "cadef.h" +#include "db_access.h" +#include "alarm.h" +#ifdef vxWorks +#include "vxWorks.h" +#include "ioLib.h" +#include "semLib.h" +#include "taskLib.h" +#endif /* vxWorks */ +#endif + + /* Structure to hold information about database channels */ +struct db_channel +{ + /* These are supplied by SNC */ + char *dbAsName; /* channel name from assign statement */ + char *pVar; /* ptr to variable */ + char *pVarName; /* variable name string */ + char *pVarType; /* variable type string (e.g. ("int") */ + int count; /* number of elements in array */ + int efId; /* event flag id if synced */ + int eventNum; /* event number */ + BOOL monFlag; /* TRUE if channel is to be monitored */ + + /* These are filled in at run time */ + char *dbName; /* channel name after macro expansion */ + int index; /* index in array of db channels */ + chid chid; /* ptr to channel id (from ca_search()) */ + BOOL assigned; /* TRUE only if channel is assigned */ + BOOL connected; /* TRUE only if channel is connected */ + BOOL getComplete; /* TRUE if previous pvGet completed */ + short dbOffset; /* Offset to value in db access structure */ + short status; /* last db access status code */ + TS_STAMP timeStamp; /* time stamp */ + int dbCount; /* actual count for db access */ + short severity; /* last db access severity code */ + short size; /* size (in bytes) of single variable element */ + short getType; /* db get type (e.g. DBR_STS_INT) */ + short putType; /* db put type (e.g. DBR_INT) */ + BOOL monitored; /* TRUE if channel IS monitored */ + evid evid; /* event id (supplied by CA) */ + SEM_ID getSemId; /* semaphore id for async get */ + struct state_program *sprog; /* state program that owns this structure */ +}; +typedef struct db_channel CHAN; + +/* Structure to hold information about a state */ +struct state_info_block +{ + char *pStateName; /* state name */ + FUNCPTR actionFunc; /* ptr to action routine for this state */ + FUNCPTR eventFunc; /* ptr to event routine for this state */ + FUNCPTR delayFunc; /* ptr to delay setup routine for this state */ + bitMask *pEventMask; /* event mask for this state */ +}; +typedef struct state_info_block STATE; + + #define MAX_NDELAY 20 /* max # delays allowed in each SS */ +/* Structure to hold information about a State Set */ +struct state_set_control_block +{ + char *pSSName; /* state set name (for debugging) */ + int taskId; /* task id */ + int taskPriority; /* task priority */ + SEM_ID syncSemId; /* semaphore for event sync */ + SEM_ID getSemId; /* semaphore for synchronous pvGet() */ + int numStates; /* number of states */ + STATE *pStates; /* ptr to array of state blocks */ + short currentState; /* current state index */ + short nextState; /* next state index */ + short prevState; /* previous state index */ + short errorState; /* error state index (-1 if none defined) */ + short transNum; /* highest priority trans. # that triggered */ + bitMask *pMask; /* current event mask */ + int numDelays; /* number of delays activated */ + ULONG delay[MAX_NDELAY]; /* queued delay value in tics */ + BOOL delayExpired[MAX_NDELAY]; /* TRUE if delay expired */ + ULONG timeEntered; /* time that a state was entered */ + struct state_program *sprog; /* ptr back to state program block */ +}; +typedef struct state_set_control_block SSCB; + +/* Macro table */ +typedef struct macro { + char *pName; + char *pValue; +} MACRO; + + /* All information about a state program. + The address of this structure is passed to the run-time sequencer: + */ +struct state_program +{ + char *pProgName; /* program name (for debugging) */ + int taskId; /* task id (main task) */ + BOOL task_is_deleted;/* TRUE if main task has been deleted */ + int taskPriority; /* task priority */ + SEM_ID caSemId; /* semiphore for locking CA events */ + CHAN *pChan; /* table of channels */ + int numChans; /* number of db channels, incl. unassigned */ + int assignCount; /* number of db channels assigned */ + int connCount; /* number of channels connected */ + SSCB *pSS; /* array of state set control blocks */ + int numSS; /* number of state sets */ + char *pVar; /* ptr to user variable area */ + int varSize; /* # bytes in user variable area */ + MACRO *pMacros; /* ptr to macro table */ + char *pParams; /* program paramters */ + bitMask *pEvents; /* event bits for event flags & db */ + int numEvents; /* number of events */ + int options; /* options (bit-encoded) */ + FUNCPTR exitFunc; /* exit function */ + SEM_ID logSemId; /* logfile locking semaphore */ + int logFd; /* logfile file descr. */ +}; +typedef struct state_program SPROG; + +#define MAX_MACROS 50 + + /* Task parameters */ +#define SPAWN_STACK_SIZE 10000 +#define SPAWN_OPTIONS VX_DEALLOC_STACK | VX_FP_TASK | VX_STDIO +#define SPAWN_PRIORITY 100 + +/* Function declarations for internal sequencer funtions */ +int seqConnect(SPROG *); +VOID seqEventHandler(struct event_handler_args); +VOID seqConnHandler(struct connection_handler_args); +VOID seqCallbackHandler(struct event_handler_args); +VOID seqWakeup(SPROG *, int); +int seq(struct seqProgram *, char *, int); +VOID seqFree(SPROG *); +int sequencer(SPROG *, int, char *); +VOID ssEntry(SPROG *, SSCB *); +int sprogDelete(int); +int seqMacParse(char *, SPROG *); +char *seqMacValGet(MACRO *, char *); +VOID seqMacEval(char *, char *, int, MACRO *); +STATUS seq_log(); +SPROG *seqFindProg(int); + +#endif /* INCLseqh */ diff --git a/src/sequencer/seqCom.h b/src/sequencer/seqCom.h new file mode 100644 index 000000000..93064db0c --- /dev/null +++ b/src/sequencer/seqCom.h @@ -0,0 +1,150 @@ +/* * base/include seqCom.h,v 1.3 1995/10/10 01:25:08 wright Exp + * + * DESCRIPTION: Common definitions for state programs and run-time sequencer. + * + * Author: Andy Kozubal + * Date: 01mar94 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1993 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 + * Modification Log: + * ----------------- + * + */ +#ifndef INCLseqComh +#define INCLseqComh + +#define MAGIC 940501 /* current magic number for SPROG */ + +#include "tsDefs.h" /* time stamp defs */ + +/* Bit encoding for run-time options */ +#define OPT_DEBUG (1<<0) /* turn on debugging */ +#define OPT_ASYNC (1<<1) /* use async. gets */ +#define OPT_CONN (1<<2) /* wait for all connections */ +#define OPT_REENT (1<<3) /* generate reentrant code */ +#define OPT_NEWEF (1<<4) /* new event flag mode */ +#define OPT_TIME (1<<5) /* get time stamps */ +#define OPT_VXWORKS (1<<6) /* include VxWorks files */ + +/* Macros to handle set & clear event bits */ +#define NBITS 32 /* # bits in bitMask word */ +typedef long bitMask; + +#define bitSet(word, bitnum) (word[(bitnum)/NBITS] |= (1<<((bitnum)%NBITS))) +#define bitClear(word, bitnum) (word[(bitnum)/NBITS] &= ~(1<<((bitnum)%NBITS))) +#define bitTest(word, bitnum) ((word[(bitnum)/NBITS] & (1<<((bitnum)%NBITS))) != 0) + +#ifndef TRUE +#define TRUE 1 +#define FALSE 0 +#endif /* TRUE */ + +typedef int (*PFUNC)(); /* ptr to a function */ +typedef long SS_ID; /* state set id */ + +#ifdef OFFSET +#undef OFFSET +#endif +/* The OFFSET macro calculates the byte offset of a structure member + * from the start of a structure */ +#define OFFSET(structure, member) ((int) &(((structure *) 0) -> member)) + + /* Structure to hold information about database channels */ +struct seqChan +{ + char *dbAsName; /* assigned channel name */ + void *pVar; /* ptr to variable (-r option) + * or structure offset (+r option) */ + char *pVarName; /* variable name, including subscripts */ + char *pVarType; /* variable type, e.g. "int" */ + int count; /* element count for arrays */ + int eventNum; /* event number for this channel */ + int efId; /* event flag id if synced */ + int monFlag; /* TRUE if channel is to be monitored */ +}; + +/* Structure to hold information about a state */ +struct seqState +{ + char *pStateName; /* state name */ + PFUNC actionFunc; /* action routine for this state */ + PFUNC eventFunc; /* event routine for this state */ + PFUNC delayFunc; /* delay setup routine for this state */ + bitMask *pEventMask; /* event mask for this state */ +}; + +/* Structure to hold information about a State Set */ +struct seqSS +{ + char *pSSName; /* state set name */ + struct seqState *pStates; /* array of state blocks */ + int numStates; /* number of states in this state set */ + int errorState; /* error state index (-1 if none defined) */ +}; + +/* All information about a state program */ +struct seqProgram +{ + int magic; /* magic number */ + char *pProgName; /* program name (for debugging) */ + struct seqChan *pChan; /* table of channels */ + int numChans; /* number of db channels */ + struct seqSS *pSS; /* array of state set info structs */ + int numSS; /* number of state sets */ + int varSize; /* # bytes in user variable area */ + char *pParams; /* program paramters */ + int numEvents; /* number of event flags */ + int options; /* options (bit-encoded) */ + PFUNC exitFunc; /* exit function */ +}; + + +/* + * Function declarations for interface between state program & sequencer. + * Notes: + * "seq_" is added by SNC to guarantee global uniqueness. + * These functions appear in the module seq_if.c. + * The SNC must generate these modules--see gen_ss_code.c. + */ +/*#define ANSI*/ +#ifdef ANSI +void seq_efSet(SS_ID, int); /* set an event flag */ +int seq_efTest(SS_ID, int); /* test an event flag */ +int seq_efClear(SS_ID, int); /* clear an event flag */ +int seq_efTestAndClear(SS_ID, int); /* test & clear an event flag */ +int seq_pvGet(SS_ID, int); /* get pv value */ +int seq_pvPut(SS_ID, int); /* put pv value */ +TS_STAMP seq_pvTimeStamp(SS_ID, int); /* get time stamp value */ +int seq_pvAssign(SS_ID, int, char *);/* assign/connect to a pv */ +int seq_pvMonitor(SS_ID, int); /* enable monitoring on pv */ +int seq_pvStopMonitor(SS_ID, int); /* disable monitoring on pv */ +int seq_pvStatus(SS_ID, int); /* returns pv alarm status code */ +int seq_pvSeverity(SS_ID, int); /* returns pv alarm severity */ +int seq_pvAssigned(SS_ID, int); /* returns TRUE if assigned */ +int seq_pvConnected(SS_ID, int); /* TRUE if connected */ +int seq_pvGetComplete(SS_ID, int); /* TRUE if last get completed */ +int seq_pvChannelCount(SS_ID); /* returns number of channels */ +int seq_pvConnectCount(SS_ID); /* returns number of channels connected */ +int seq_pvAssignCount(SS_ID); /* returns number of channels assigned */ +int seq_pvCount(SS_ID, int); /* returns number of elements in array */ +void seq_pvFlush(); /* flush put/get requests */ +int seq_pvIndex(SS_ID, int); /* returns index of pv */ +int seq_seqLog(); /* Logging: variable number of parameters */ +void seq_delayInit(SS_ID, int, float);/* initialize a delay entry */ +int seq_delay(SS_ID, int); /* test a delay entry */ +char *seq_macValueGet(SS_ID, char *); /* Given macro name, return ptr to value */ +#endif /* ANSI */ +#endif /* INCLseqComh */ diff --git a/src/sequencer/seqU.h b/src/sequencer/seqU.h new file mode 100644 index 000000000..e62bc51ce --- /dev/null +++ b/src/sequencer/seqU.h @@ -0,0 +1,13 @@ +/* $Id$ */ +typedef long bitMask; +#define bitSet(word, bitnum) (word[bitnum/NBITS] |= (1<<(bitnum%NBITS))) +#define NBITS 32 /* # bits in bit mask word */ +#define NWRDS 8 /* # words in bit fields */ +#define MAGIC 920505 /* magic number for SPROG */ +/* Bit encoding for run-time options */ +#define OPT_DEBUG (1<<0) +#define OPT_ASYNC (1<<1) +#define OPT_CONN (1<<2) +#define OPT_REENT (1<<3) +#define OPT_NEWEF (1<<4) +#define MAX_NDELAY 20 /* max # delays allowed in each SS */ diff --git a/src/sequencer/seq_taskLib.h b/src/sequencer/seq_taskLib.h new file mode 100644 index 000000000..7519662f0 --- /dev/null +++ b/src/sequencer/seq_taskLib.h @@ -0,0 +1,93 @@ +/* + * $Id$ + */ +#ifdef DECTHREAD +#include +#include +#endif +#ifdef FSUTHREAD +#include "pthread/pthread.h" +#endif +#include +#include +#include +#include +#include +#include + +#define GLOBALLOCK \ + {\ + pthread_lock_global_np(); \ + } + +#define GLOBALUNLOCK \ + {\ + pthread_unlock_global_np(); \ + } + + +#define FASTLOCKINIT(PFAST_LOCK) \ + {\ + mutex_init(PFAST_LOCK,0,NULL); \ + } + +#define FASTLOCKFREE(PFAST_LOCK) \ + {\ + pthread_mutex_destroy(PFAST_LOCK); \ + } + +#define FASTLOCK(PFAST_LOCK) \ + {\ + mutex_enter( (PFAST_LOCK)); \ + } + +#define FASTUNLOCK(PFAST_LOCK) \ + {\ + mutex_exit( (PFAST_LOCK)); \ + } + +#define FASTLOCKNOWAIT(PFAST_LOCK) \ + {\ + mutex_tryenter( (PFAST_LOCK)); \ + } + +/* #define DEBUG */ + +#define THDNUM 100 + +#define ST_INIT 0 +#define ST_LOCKED 1 +#define ST_RUNNING 2 +#define ST_SUSPEND 3 +#define ST_CANCELED 4 + +/*char *st_status[] = { + "INIT", + "LOCKED", + "RUNNING", + "SUSPENDED", + "CANCELED"}; +*/ + +/* DEC/POSIX type to FSU POSIX type*/ +#ifdef FSUTHREAD +#define pthread_startroutine_t pthread_func_t +#define pthread_addr_t any_t +#endif + +/* Sun Solaris 5.0 using DEC/ POSIX */ +#define thread_id_t pthread_t +#define mutex_t pthread_mutex_t +#define condvar_t pthread_cond_t + +#define STATUS int + +#define PROMPT "Seq> " /* prompt string */ +#define MAXLINSIZE 81 /* command line width */ + +#define check(status,string) if(status == -1)perror(string) + +#define FAST_LOCK pthread_mutex_t /* fastlock for pthread_mutex_t */ + + +