diff --git a/src/db/iocInit.c b/src/db/iocInit.c index 289029c27..b4eed270e 100644 --- a/src/db/iocInit.c +++ b/src/db/iocInit.c @@ -48,6 +48,7 @@ * .18 07-31-92 rcz moved database loading to function dbLoad * .19 08-14-92 jba included dblinks with maximize severity in lockset * .20 08-27-92 mrk removed wakeup_init (For old I/O Event scanning) + * .21 09-05-92 rcz changed dbUserExit to initHooks * */ @@ -84,6 +85,7 @@ #include #include #include +#include /*This module will declare and initilize module_type variables*/ #define MODULE_TYPES_INIT 1 #include @@ -108,14 +110,16 @@ long initDatabase(); long addToSet(); long initialProcess(); long getResources(); +long setMasterTimeToSelf(); int iocInit(pResourceFilename) char * pResourceFilename; { long status; + long hookrtn=0; char name[40]; long rtnval; - void (*pdbUserExit)(); + long (*pinitHooks)() = NULL; SYM_TYPE type; if(initialized) { @@ -125,10 +129,18 @@ char * pResourceFilename; coreRelease(); epicsSetEnvParams(); + /* if function initHooks exists call it */ + strcpy(name,"_"); + strcat(name,"initHooks"); + rtnval = symFindByName(sysSymTbl,name,(void *)&pinitHooks,&type); if (!pdbBase) { logMsg("iocInit aborting because No database loaded by dbLoad\n"); return(-1); } + if(rtnval==OK && (type&N_TEXT!=0)) { + hookrtn=(*pinitHooks)(SETMASTERTIMETOSELF); + logMsg("initHooks(SETMASTERTIMETOSELF) was called\n"); + } status=getResources(pResourceFilename); if(status!=0) { logMsg("iocInit aborting because getResources failed\n"); @@ -154,13 +166,9 @@ char * pResourceFilename; if(finishDevSup()!=0) logMsg("iocInit: Device Support Failed during Finalization\n"); - /* if user exit exists call it */ - strcpy(name,"_"); - strcat(name,"dbUserExit"); - rtnval = symFindByName(sysSymTbl,name,(void *)&pdbUserExit,&type); if(rtnval==OK && (type&N_TEXT!=0)) { - (*pdbUserExit)(); - logMsg("User Exit was called\n"); + hookrtn=(*pinitHooks)(DBUSEREXIT); + logMsg("initHooks(DBUSEREXIT) was called\n"); } callbackInit(); scanInit(); @@ -818,3 +826,44 @@ char * pfilename; } return (0); } +long setMasterTimeToSelf() +{ + BOOT_PARAMS bp; + char *pnext; + char name[] = "_EPICS_IOCMCLK_INET"; + char message[100]; + UTINY type; + long rtnval = 0; + char *pSymAddr; + int len = 0; + int i = 0; + char *ptr = 0; + + pnext = bootStringToStruct(sysBootLine, &bp); + if (*pnext != EOS) { + sprintf(message, + "setMasterTimeToSelf: unable to parse boot params\n"); + errMessage(-1L, message); + return (-1); + } + rtnval = symFindByName(sysSymTbl, name, &pSymAddr, &type); + if (rtnval != OK || (type & N_TEXT == 0)) { + sprintf(message, + "setMasterTimeToSelf: symBol EPICS_IOCMCLK_INET not found"); + errMessage(-1L, message); + return (-1); + } + ptr = (char*)&bp.ead; + len=strlen((char*)&bp.ead); + /* strip off maask */ + for (i=0; i