This is version described in 3.13beta11 App Dev Guide

This commit is contained in:
Marty Kraimer
1998-01-20 16:09:26 +00:00
parent b736f540cf
commit 9a6af026a5
2 changed files with 109 additions and 64 deletions

View File

@@ -1,8 +1,8 @@
/* initHooks.c ioc initialization hooks */
/* share/src/db @(#)initHooks.c 1.5 7/11/94 */
/* share/src/db/initHooks.c*/
/*
* Author: Marty Kraimer
* Authors: Benjamin Franksen (BESY) and Marty Kraimer
* Date: 06-01-91
* major Revision: 07JuL97
*
* Experimental Physics and Industrial Control System (EPICS)
*
@@ -31,60 +31,64 @@
* .02 09-10-92 rcz changed return from void to long
* .03 09-10-92 rcz changed completely
* .04 09-10-92 rcz bug - moved call to setMasterTimeToSelf later
* .04 07-15-97 mrk Benjamin Franksen allow multiple functions
*
*/
#include <vxWorks.h>
#include <stdlib.h>
#include <stddef.h>
#include <stdio.h>
#include <ellLib.h>
#include <initHooks.h>
typedef struct initHookLink {
ELLNODE node;
initHookFunction func;
} initHookLink;
static functionListInited = FALSE;
static ELLLIST functionList;
static void initFunctionList(void)
{
ellInit(&functionList);
functionListInited = TRUE;
}
/*
* INITHOOKS
*
* called by iocInit at various points during initialization
*
* To be called before iocInit reaches state desired.
*/
/* If this function (initHooks) is loaded, iocInit calls this function
* at certain defined points during IOC initialization */
void initHooks(callNumber)
int callNumber;
int initHookRegister(initHookFunction func)
{
switch (callNumber) {
case INITHOOKatBeginning :
break;
case INITHOOKafterGetResources :
break;
case INITHOOKafterLogInit :
break;
case INITHOOKafterCallbackInit :
break;
case INITHOOKafterCaLinkInit :
break;
case INITHOOKafterInitDrvSup :
break;
case INITHOOKafterInitRecSup :
break;
case INITHOOKafterInitDevSup :
break;
case INITHOOKafterTS_init :
break;
case INITHOOKafterInitDatabase :
break;
case INITHOOKafterFinishDevSup :
break;
case INITHOOKafterScanInit :
break;
case INITHOOKafterInterruptAccept :
break;
case INITHOOKafterInitialProcess :
break;
case INITHOOKatEnd :
break;
default:
break;
initHookLink *newHook;
if(!functionListInited) initFunctionList();
newHook = (initHookLink *)malloc(sizeof(initHookLink));
if (newHook == NULL)
{
printf("Cannot malloc a new initHookLink\n");
return ERROR;
}
newHook->func = func;
ellAdd(&functionList,&newHook->node);
return OK;
}
/*
* Called by iocInit at various points during initialization.
* Do not call this function from any other function than iocInit.
*/
void initHooks(initHookState state)
{
initHookLink *hook;
if(!functionListInited) initFunctionList();
hook = (initHookLink *)ellFirst(&functionList);
while(hook != NULL)
{
hook->func(state);
hook = (initHookLink *)ellNext(&hook->node);
}
return;
}

View File

@@ -1,7 +1,8 @@
/* share/src/db $Id$ */
/* share/src/db/initHooks.h*/
/*
* Author: Marty Kraimer
* Authors: Benjamin Franksen (BESY) and Marty Kraimer
* Date: 06-01-91
* major Revision: 07JuL97
*
* Experimental Physics and Industrial Control System (EPICS)
*
@@ -28,6 +29,7 @@
* -----------------
* .01 09-05-92 rcz initial version
* .02 09-10-92 rcz changed completely
* .03 07-15-97 mrk Benjamin Franksen allow multiple functions
*
*/
@@ -35,20 +37,59 @@
#ifndef INCinitHooksh
#define INCinitHooksh 1
#define INITHOOKatBeginning 0
#define INITHOOKafterGetResources 1
#define INITHOOKafterLogInit 2
#define INITHOOKafterCallbackInit 3
#define INITHOOKafterCaLinkInit 4
#define INITHOOKafterInitDrvSup 5
#define INITHOOKafterInitRecSup 6
#define INITHOOKafterInitDevSup 7
#define INITHOOKafterTS_init 8
#define INITHOOKafterInitDatabase 9
#define INITHOOKafterFinishDevSup 10
#define INITHOOKafterScanInit 11
#define INITHOOKafterInterruptAccept 12
#define INITHOOKafterInitialProcess 13
#define INITHOOKatEnd 14
typedef enum {
initHookAtBeginning,
initHookAfterGetResources,
initHookAfterLogInit,
initHookAfterCallbackInit,
initHookAfterCaLinkInit,
initHookAfterInitDrvSup,
initHookAfterInitRecSup,
initHookAfterInitDevSup,
initHookAfterTS_init,
initHookAfterInitDatabase,
initHookAfterFinishDevSup,
initHookAfterScanInit,
initHookAfterInterruptAccept,
initHookAfterInitialProcess,
initHookAtEnd
}initHookState;
#ifdef __cplusplus
extern "C" {
#endif
#ifdef __STDC__
typedef void (*initHookFunction)(initHookState state);
int initHookRegister(initHookFunction func);
void initHooks(initHookState state);
#else /*__STDC__*/
typedef void (*initHookFunction)();
int initHookRegister();
void initHooks();
#endif /*__STDC__*/
#ifdef __cplusplus
}
#endif
/*FOLLOWING IS OBSOLETE*/
/*The following are for compatibility with old initHooks.c functions*/
#define INITHOOKatBeginning initHookAtBeginning
#define INITHOOKafterGetResources initHookAfterGetResources
#define INITHOOKafterLogInit initHookAfterLogInit
#define INITHOOKafterCallbackInit initHookAfterCallbackInit
#define INITHOOKafterCaLinkInit initHookAfterCaLinkInit
#define INITHOOKafterInitDrvSup initHookAfterInitDrvSup
#define INITHOOKafterInitRecSup initHookAfterInitRecSup
#define INITHOOKafterInitDevSup initHookAfterInitDevSup
#define INITHOOKafterTS_init initHookAfterTS_init
#define INITHOOKafterInitDatabase initHookAfterInitDatabase
#define INITHOOKafterFinishDevSup initHookAfterFinishDevSup
#define INITHOOKafterScanInit initHookAfterScanInit
#define INITHOOKafterInterruptAccept initHookAfterInterruptAccept
#define INITHOOKafterInitialProcess initHookAfterInitialProcess
#define INITHOOKatEnd initHookAtEnd
/*END OF OBSOLETE DEFINITIONS*/
#endif /*INCinitHooksh*/