diff --git a/src/vxWorks/include/fast_lock.h b/src/vxWorks/include/fast_lock.h new file mode 100644 index 000000000..c987daa15 --- /dev/null +++ b/src/vxWorks/include/fast_lock.h @@ -0,0 +1,191 @@ +/* fast_lock.h */ +/* share/epicsH $Id$ */ + +/* + * Author: Jeff Hill + * Date: 4-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 041189 initial release into middle age + * .02 joh 071989 added fast lock test + * .03 joh 090391 VRTX kernel ifdef for V5 vxWorks + * .04 joh 091091 Now uses V5 vxWorks binary semaphore + * .05 joh 092491 Dont use V5 semaphore on V3 EPICS yet + * .06 jba 030692 added cast to vxTas arg in FASTLOCK vxWorks5 + * .07 jba 081092 added cast to vxTas arg in FASTLOCKNOWAIT + * .08 mgb 082493 Removed V5/V4 conditional defines + * .09 joh 082493 include vxLib.h for vxWorks V5.1 + * .10 joh 082593 made lock char as vxTas expects + * (padded structure to identical size) + * .11 joh 082593 made fast lock structure fields volatile + * .12 joh 091493 added sem and task lock based fast locks + * with ifdefs - removed volatile + */ + +/* + * + * + * Macros and data structures for a much faster (than vrtx semaphore) + * mutual exclusion lock/unlock. + * (semaphore in this case is only used to wait for unlock) + * + * On a 68020 the following times include lock and unlock + * + * FASTLOCK-FASTUNLOCK 8 microsecs + * semTake-semGive(Macro) 80 microsecs + * semTake-semGive 92 microsecs + * + */ + +#ifndef INCLfast_lockh +#define INCLfast_lockh + +#ifndef INCLsemLibh +#include +#endif +#ifndef INCLvxLibh +#include +#endif + +/* + * Macro equivalent of vxWorks glue for better performance + */ +#ifdef VRTX_KERNEL +# define semGive(SEMID)\ + { if ((SEMID)->count == 0)vrtxPost (&((SEMID)->count), 1); } + +# define semTake(SEMID)\ + {int dummy; vrtxPend (&((SEMID)->count), 0, &dummy); } +#endif + +typedef struct{ + SEM_ID ppend; /* wait for lock sem */ + unsigned short count; /* cnt of tasks waiting for lock */ + unsigned char lock; /* test and set lock bit */ + char pad; /* structure alignment */ +}FAST_LOCK; + +#define SEM_FAST_LOCK + +#if defined(SEM_FAST_LOCK) /* no lock test */ + +#define FASTLOCKINIT(PFAST_LOCK)\ + (((FAST_LOCK *)(PFAST_LOCK))->ppend = \ + semMCreate(SEM_DELETE_SAFE|SEM_INVERSION_SAFE|SEM_Q_PRIORITY)) +#define FASTLOCKFREE(PFAST_LOCK)\ + semDelete( ((FAST_LOCK *)(PFAST_LOCK))->ppend ) +#define FASTLOCK(PFAST_LOCK)\ + semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend, WAIT_FOREVER); +#define FASTUNLOCK(PFAST_LOCK)\ + semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend); +#define FASTLOCKNOWAIT(PFAST_LOCK) \ + ((semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend,NO_WAIT)==0) ? TRUE : FALSE) +#define FASTLOCKTEST(PFAST_LOCK) \ +(\ + (semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend,NO_WAIT)==0 )\ + ? (semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend),FALSE)\ + : TRUE \ +) + + +#elif defined(TASK_LOCK_FAST_LOCK) + +#define FASTLOCKINIT(PFAST_LOCK)\ + (\ + ((FAST_LOCK *)(PFAST_LOCK))->count =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->lock =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->ppend = \ + semBCreate(SEM_Q_PRIORITY, SEM_EMPTY) \ + ) +#define FASTLOCKFREE(PFAST_LOCK)\ + semDelete( ((FAST_LOCK *)(PFAST_LOCK))->ppend ) + +#define FASTLOCK(PFAST_LOCK)\ + {\ + TASK_LOCK;\ + while( ((FAST_LOCK *)(PFAST_LOCK))->lock ){\ + ((FAST_LOCK *)(PFAST_LOCK))->count++;\ + TASK_UNLOCK;\ + semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend, WAIT_FOREVER);\ + TASK_LOCK;\ + (((FAST_LOCK *)(PFAST_LOCK))->count)--;\ + }\ + ((FAST_LOCK *)(PFAST_LOCK))->lock= TRUE; + TASK_UNLOCK; + } + +#define FASTUNLOCK(PFAST_LOCK)\ + {\ + ((FAST_LOCK *)(PFAST_LOCK))->lock = FALSE;\ + if( ((FAST_LOCK *)(PFAST_LOCK))->count )\ + semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend);\ + }; + +#define FASTLOCKTEST(PFAST_LOCK)\ +( ((FAST_LOCK *)(PFAST_LOCK))->lock ) + +#else /* vxTas() fast lock */ + +/* + * extra paren avoids order of ops problems + * (returns what semBCreate returns on v5 vxWorks) + */ +#define FASTLOCKINIT(PFAST_LOCK)\ + (\ + ((FAST_LOCK *)(PFAST_LOCK))->count =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->lock =0, \ + ((FAST_LOCK *)(PFAST_LOCK))->ppend = \ + semBCreate(SEM_Q_PRIORITY, SEM_EMPTY) \ + ) + +/* + * new requirement with v5 vxWorks + */ +#define FASTLOCKFREE(PFAST_LOCK)\ + semDelete( ((FAST_LOCK *)(PFAST_LOCK))->ppend ) + +#define FASTLOCK(PFAST_LOCK)\ + {\ + ((FAST_LOCK *)(PFAST_LOCK))->count++;\ + while(!vxTas( (char *)&( ((FAST_LOCK *)(PFAST_LOCK))->lock ) ))\ + semTake(((FAST_LOCK *)(PFAST_LOCK))->ppend, WAIT_FOREVER);\ + ( ((FAST_LOCK *)(PFAST_LOCK))->count)--;\ + } + +#define FASTUNLOCK(PFAST_LOCK)\ + {\ + ((FAST_LOCK *)(PFAST_LOCK))->lock = FALSE;\ + if( ((FAST_LOCK *)(PFAST_LOCK))->count )\ + semGive(((FAST_LOCK *)(PFAST_LOCK))->ppend);\ + }; + +#define FASTLOCKNOWAIT(PFAST_LOCK) (vxTas((char *)&(((FAST_LOCK *)(PFAST_LOCK))->lock))) + +#define FASTLOCKTEST(PFAST_LOCK)\ +( ((FAST_LOCK *)(PFAST_LOCK))->lock ) + +#endif + +#endif /* Nothing after this endif */ diff --git a/src/vxWorks/include/task_params.h b/src/vxWorks/include/task_params.h new file mode 100644 index 000000000..013d57e5f --- /dev/null +++ b/src/vxWorks/include/task_params.h @@ -0,0 +1,275 @@ +/* $Id$ */ + +/* Parameters for tasks on IOC */ +/* + * Authors: Andy Kozubal, Jeff Hill, and Bob Dalesio + * Date: 2-24-89 + * + * Experimental Physics and Industrial Control System (EPICS) + * + * Copyright 1991, the Regents of the University of California, + * and the University of Chicago Board of Governors. + * + * This software was produced under U.S. Government contracts: + * (W-7405-ENG-36) at the Los Alamos National Laboratory, + * and (W-31-109-ENG-38) at Argonne National Laboratory. + * + * Initial development by: + * The Controls and Automation Group (AT-8) + * Ground Test Accelerator + * Accelerator Technology Division + * Los Alamos National Laboratory + * + * Co-developed with + * The Controls and Computing Group + * Accelerator Systems Division + * Advanced Photon Source + * Argonne National Laboratory + * + * Modification Log: + * ----------------- + * .01 07-23-91 ges Add time-stamp task. + * .02 09-12-91 joh stack sizes increased for v5 vxWorks. + * .03 10-24-91 lrd Increased stack sizes for scan tasks + * .04 12-12-91 joh Increased stack size for the + * wfDoneTask + * .05 12-18-91 mrk Added callback task priorities + * Changed def of PERIODSCAN_PRI and SEQUENCER_PRI + * Shortened length of task names + * .06 12-18-91 jba Global change of WDSCAN to TASKWD + * .07 01-21-92 rcz Increased all stack sizes by 1000 for V5 + * .08 01-21-92 jrw added the GPIB & BB driver task info + * .09 01-04-92 jba Added callback task priorities + * .10 03-16-92 jrw added BB rx and tx specific task info + * .11 05-22-92 lrd added the allen-bradley binary input Change of State scanner + * .12 08-26-92 joh added xy 240 stuff + * .13 08-26-92 joh added FP to CA repeater and on line to be safe + * .14 02-16-92 joh removed historical items + * .15 11-19-93 joh moved CA client priority up by one notch + * .16 09-13-93 joh incresed CA on line beacon maximum delay + * to 60 sec + * .17 03-18-94 mcn added entries for breakpoint tasks + * $Log$ + * Revision 1.4 1998/09/29 14:45:50 mrk + * Task priorities were changed so that no epics task has higher priority than netTask. + * Definitions for IOEVENTSCAN and TIMESTAMP were removed. + * + * Revision 1.3 1998/05/20 21:00:43 mrk + * raised DB_CA_PRI to just higher than sequencer + * + * Revision 1.2 1998/01/20 21:49:54 mrk + * added the arch_stack_factor for 64 bit architectures; changes for errlog + * + * Revision 1.1 1996/11/22 20:49:43 jhill + * installed + * + * Revision 1.1 1996/06/24 13:32:35 mrk + * added task_params.h + * + * Revision 1.3 1996/06/19 20:48:44 jhill + * dounled ca stack for each ca cleint in the server + * + * Revision 1.2 1996/04/22 14:31:08 mrk + * Changes for dynamic link modification + * + * Revision 1.1 1996/01/25 21:13:29 mrk + * moved includes; .ascii=> .db; path changes + * + * Revision 1.27 1995/11/29 19:27:59 jhill + * added $Log$ + * added Revision 1.4 1998/09/29 14:45:50 mrk + * added Task priorities were changed so that no epics task has higher priority than netTask. + * added Definitions for IOEVENTSCAN and TIMESTAMP were removed. + * added + * added Revision 1.3 1998/05/20 21:00:43 mrk + * added raised DB_CA_PRI to just higher than sequencer + * added + * added Revision 1.2 1998/01/20 21:49:54 mrk + * added added the arch_stack_factor for 64 bit architectures; changes for errlog + * added + * added Revision 1.1 1996/11/22 20:49:43 jhill + * added installed + * added + * added Revision 1.1 1996/06/24 13:32:35 mrk + * added added task_params.h + * added + * added Revision 1.3 1996/06/19 20:48:44 jhill + * added dounled ca stack for each ca cleint in the server + * added + * added Revision 1.2 1996/04/22 14:31:08 mrk + * added Changes for dynamic link modification + * added + * added Revision 1.1 1996/01/25 21:13:29 mrk + * added moved includes; .ascii=> .db; path changes + * added + * + */ + +#ifndef INCtaskLibh +#include +#endif + +#define VXTASKIDSELF 0 + +/* Task Names */ +#define EVENTSCAN_NAME "scanEvent" +#define SCANONCE_NAME "scanOnce" +#define SMCMD_NAME "smCommand" +#define SMRESP_NAME "smResponse" +#define ABDONE_NAME "abDone" +#define ABSCAN_NAME "abScan" +#define ABCOS_NAME "abBiCosScanner" +#define MOMENTARY_NAME "momentary" +#define WFDONE_NAME "wfDone" +#define SEQUENCER_NAME "sequencer" +#define BKPT_CONT_NAME "bkptCont" +#define SCANNER_NAME "scanner" +#define REQ_SRVR_NAME "CA TCP" +#define CA_CLIENT_NAME "CA client" +#define CA_EVENT_NAME "CA event" +#define CAST_SRVR_NAME "CA UDP" +#define CA_REPEATER_NAME "CA repeater" +#define CA_ONLINE_NAME "CA online" +#define TASKWD_NAME "taskwd" +#define SMIOTEST_NAME "smInout" +#define SMROTTEST_NAME "smRotate" +#define EVENT_PEND_NAME "event task" +#define XY240_NAME "xy 240 scan" +#define GPIBLINK_NAME "gpibLink" +#define BBLINK_NAME "bbLinkTask" +#define BBTXLINK_NAME "bbTx" +#define BBRXLINK_NAME "bbRx" +#define BBWDTASK_NAME "bbwd" +#define ERRLOG_NAME "errlog" +#define LOG_RESTART_NAME "logRestart" + +/* Task priorities */ +#define SCANONCE_PRI 129 /* scan one time */ +/*DO NOT RUN ANY RECORD PROCESSING TASKS AT HIGHER PRIORITY THAN _netTask=50*/ +#define CALLBACK_PRI_LOW 140 /* callback task - generall callback task */ +#define CALLBACK_PRI_MEDIUM 135 /* callback task - generall callback task */ +#define CALLBACK_PRI_HIGH 128 /* callback task - generall callback task */ +#define EVENTSCAN_PRI 129 /* Event Scanner - Runs on a global event */ +#define SMCMD_PRI 120 /* Stepper Motor Command Task - Waits for cmds */ +#define SMRESP_PRI 121 /* Stepper Motor Resp Task - Waits for resps */ +#define ABCOS_PRI 121 /* Allen-Bradley Binary Input COS io_event wakeup */ +#define ABDONE_PRI 122 /* Allen-Bradley Resp Task - Interrupt Driven */ +#define ABSCAN_PRI 123 /* Allen-Bradley Scan Task - Base Rate .1 secs */ +#define BBLINK_PRI 124 +#define BBWDTASK_PRI 123 /* BitBus watchdog task */ +#define BBRXLINK_PRI 124 /* BitBus link task */ +#define BBTXLINK_PRI 125 /* BitBus link task */ +#define GPIBLINK_PRI 125 /* GPIB link task */ +#define MOMENTARY_PRI 126 /* Momentary output - posted from watchdog */ +#define WFDONE_PRI 127 /* Waveform Task - Base Rate of .1 second */ +#define PERIODSCAN_PRI 139 /* Periodic Scanners - Slowest rate */ +#define DB_CA_PRI 149 /*database to channel access*/ +#define SEQUENCER_PRI 151 +#define XY240_PRI 160 /* xy 240 dio scanner */ +#define SCANNER_PRI 170 +#define REQ_SRVR_PRI 181 /* Channel Access TCP request server*/ +#define CA_CLIENT_PRI 180 /* Channel Access clients */ +#define CA_REPEATER_PRI 181 /* Channel Access repeater */ +#define ERRLOG_PRI CA_REPEATER_PRI /*error logger task*/ +#define CAST_SRVR_PRI 182 /* Channel Access broadcast server */ +#define CA_ONLINE_PRI 183 /* Channel Access server online notify */ +#define TASKWD_PRI 200 /* Watchdog Scan Task - runs every 6 seconds */ +#define SMIOTEST_PRI 205 /* Stepper Mtr in/out test - runs every .1 sec */ +#define SMROTTEST_PRI 205 /* Stepper Mtr rotate test - runs every .1 sec */ +#define LOG_RESTART_PRI 200 /* Log server connection watch dog */ + +/* Task delay times (seconds) */ +#define TASKWD_DELAY 6 + +/* Task delay times (tics) */ +#define ABSCAN_RATE (sysClkRateGet()/6) +#define SEQUENCER_DELAY (sysClkRateGet()/5) +#define SCANNER_DELAY (sysClkRateGet()/5) +#define CA_ONLINE_DELAY (sysClkRateGet()*15) +#define LOG_RESTART_DELAY (sysClkRateGet()*30) + +/* Task creation options */ +#define ERRLOG_OPT VX_FP_TASK +#define EVENTSCAN_OPT VX_FP_TASK +#define SCANONCE_OPT VX_FP_TASK +#define CALLBACK_OPT VX_FP_TASK +#define SMCMD_OPT VX_FP_TASK +#define SMRESP_OPT VX_FP_TASK +#define ABDONE_OPT VX_FP_TASK +#define ABCOS_OPT VX_FP_TASK +#define ABSCAN_OPT VX_FP_TASK +#define MOMENTARY_OPT VX_FP_TASK +#define PERIODSCAN_OPT VX_FP_TASK +#define WFDONE_OPT VX_FP_TASK +#define SEQUENCER_OPT VX_FP_TASK | VX_STDIO +#define BKPT_CONT_OPT VX_FP_TASK +#define SCANNER_OPT VX_FP_TASK +#define REQ_SRVR_OPT VX_FP_TASK +#define CAST_SRVR_OPT VX_FP_TASK +#define CA_CLIENT_OPT VX_FP_TASK +#define CA_REPEATER_OPT VX_FP_TASK +#define CA_ONLINE_OPT VX_FP_TASK +#define TASKWD_OPT VX_FP_TASK +#define SMIOTEST_OPT VX_FP_TASK +#define SMROTTEST_OPT VX_FP_TASK +#define EVENT_PEND_OPT VX_FP_TASK +#define GPIBLINK_OPT VX_FP_TASK|VX_STDIO +#define BBLINK_OPT VX_FP_TASK|VX_STDIO +#define BBTXLINK_OPT VX_FP_TASK|VX_STDIO +#define BBRXLINK_OPT VX_FP_TASK|VX_STDIO +#define BBWDTASK_OPT VX_FP_TASK|VX_STDIO +#define DB_CA_OPT (VX_FP_TASK | VX_STDIO) +#define XY_240_OPT (0) /* none */ +#define LOG_RESTART_OPT (VX_FP_TASK) + + +/* + * Task stack sizes + * + * (original stack sizes are appropriate for the 68k) + * ARCH_STACK_FACTOR allows scaling the stacks on particular + * processor architectures + */ +#if CPU_FAMILY == MC680X0 +#define ARCH_STACK_FACTOR 1 +#elif CPU_FAMILY == SPARC +#define ARCH_STACK_FACTOR 2 +#else +#define ARCH_STACK_FACTOR 2 +#endif + +#define ERRLOG_STACK (4000*ARCH_STACK_FACTOR) +#define EVENTSCAN_STACK (11000*ARCH_STACK_FACTOR) +#define SCANONCE_STACK (11000*ARCH_STACK_FACTOR) +#define CALLBACK_STACK (11000*ARCH_STACK_FACTOR) +#define SMCMD_STACK (3000*ARCH_STACK_FACTOR) +#define SMRESP_STACK (3000*ARCH_STACK_FACTOR) +#define ABCOS_STACK (3000*ARCH_STACK_FACTOR) +#define ABDONE_STACK (3000*ARCH_STACK_FACTOR) +#define ABSCAN_STACK (3000*ARCH_STACK_FACTOR) +#define MOMENTARY_STACK (2000*ARCH_STACK_FACTOR) +#define PERIODSCAN_STACK (11000*ARCH_STACK_FACTOR) +#define WFDONE_STACK (9000*ARCH_STACK_FACTOR) +#define SEQUENCER_STACK (5500*ARCH_STACK_FACTOR) +#define BKPT_CONT_STACK (11000*ARCH_STACK_FACTOR) +#define SCANNER_STACK (3048*ARCH_STACK_FACTOR) +#define RSP_SRVR_STACK (5096*ARCH_STACK_FACTOR) +#define REQ_SRVR_STACK (5096*ARCH_STACK_FACTOR) +#define CAST_SRVR_STACK (5096*ARCH_STACK_FACTOR) +#define CA_CLIENT_STACK (11000*ARCH_STACK_FACTOR) +#define CA_REPEATER_STACK (5096*ARCH_STACK_FACTOR) +#define CA_ONLINE_STACK (3048*ARCH_STACK_FACTOR) +#define TASKWD_STACK (2000*ARCH_STACK_FACTOR) +#define SMIOTEST_STACK (2000*ARCH_STACK_FACTOR) +#define SMROTTEST_STACK (2000*ARCH_STACK_FACTOR) +#define EVENT_PEND_STACK (5096*ARCH_STACK_FACTOR) +#define TIMESTAMP_STACK (4000*ARCH_STACK_FACTOR) +#define GPIBLINK_STACK (5000*ARCH_STACK_FACTOR) +#define BBLINK_STACK (5000*ARCH_STACK_FACTOR) +#define BBRXLINK_STACK (5000*ARCH_STACK_FACTOR) +#define BBTXLINK_STACK (5000*ARCH_STACK_FACTOR) +#define BBWDTASK_STACK (5000*ARCH_STACK_FACTOR) +#define DB_CA_STACK (11000*ARCH_STACK_FACTOR) +#define XY_240_STACK (4096*ARCH_STACK_FACTOR) +#define LOG_RESTART_STACK (0x1000*ARCH_STACK_FACTOR) +