Table of Contents Previous Chapter Chapter 11: IOC Initialization

Chapter 11: IOC Initialization

1. Overview

After vxWorks is loaded at IOC boot time, the following commands are issued to load and initialize the control system software:

  ld  <  targetmv167/iocCore
  ld  <  targetmv167/drvSup
  ld  <  targetmv167/recSup
  ld  <  targetmv167/devSup
  ld  <  initHooks.o
  # iocLogDisable = 1
  # TSconfigure(0)          #See below for options
  dbLoadRecords("<.db file>")
  dbLoadTemplates("<.db file>,"<template_def>")
    . . .
  iocInit ("<resource file>")
The first four commands load various components of the EPICS software.

InitHooks.o is an optional routine that, if supplied, is called after most steps of IOC initialization.

The dbLoad loads the information obtained from the ASCII definition files. One or more dbLoadRecords, and dbLoadTemplate commands load database files with the GDCT .db format. It is also possible to use dbLoad to load databases saved in the DCT .database format. In this case it is possible to have multiple dbLoad comnmands as long as all the databases must have identical SDR information.

iocInit performs the following functions:



See "Synchronous Time Stamp Support", by Jim Kowalkowski for details. Note that the default is to be a slave. If no master is found the slave will obtain a starting time from Unix.


This routine, if loaded before iocInit is invoked, is called by iocInit after each significant initialization step. When called it passes a single argument identifying the step just completed. The argument is defined in epicsH/initHooks.h as follows:

  #define  INITHOOKatBeginning   0
  #define  INITHOOKafterSetEnvParams   1
  #define  INITHOOKafterGetResources   2
  #define  INITHOOKafterLogInit   3
  #define  INITHOOKafterCallbackInit   4
  #define  INITHOOKafterCaLinkInit1   5
  #define  INITHOOKafterInitDrvSup   6
  #define  INITHOOKafterInitRecSup   7
  #define  INITHOOKafterInitDevSup   8
  #define  INITHOOKafterTS_init   9
  #define  INITHOOKafterInitDatabase   10
  #define  INITHOOKafterCaLinkInit2   11
  #define  INITHOOKafterFinishDevSup   12
  #define  INITHOOKafterScanInit   13
  #define  INITHOOKafterInterruptAccept   14
  #define  INITHOOKafterInitialProcess   15
  #define  INITHOOKatEnd   16
The following is the default initHooks.c file. It merely declares the IOC as the master timing IOC.

#include   <vxWorks.h>
#include   <initHooks.h>
/* If this function (initHooks) is loaded, iocInit calls this function
 * at certain defined points during IOC initialization */
void initHooks  (callNumber)
int   callNumber;
  switch (callNumber) {
  case INITHOOKatBeginning :
  case INITHOOKafterSetEnvParams :
  case INITHOOKafterGetResources :
  case INITHOOKafterLogInit :
  case INITHOOKafterCallbackInit :
  case INITHOOKafterCaLinkInit1 :
  case INITHOOKafterInitDrvSup :
  case INITHOOKafterInitRecSup :
  case INITHOOKafterInitDevSup :
  case INITHOOKafterTS_init :
  case INITHOOKafterInitDatabase :
  case INITHOOKafterCaLinkInit2 :
  case INITHOOKafterFinishDevSup :
  case INITHOOKafterScanInit :
  case INITHOOKafterInterruptAccept :
  case INITHOOKafterInitialProcess :
  case INITHOOKatEnd :


This command is used to load the ASCII configuration converted to default.dctsdr format. In addition it can also load DCT .database files which contain the ASCII information as welll as record instances. Multiple dbLoad commands can be issued to load multiple database files. Each must have identical SDR records except, of course, the SDR_DB_RECORDS. The IOC needs the following self defining records:

It is highly recommanded that dbLoad load only the default.dctsdr information and use dbLoadRecords and/or dbLoadTemplate to load record instances.

dbLoadRecords and dbLoadTemplates

These commands are used to load record instance definition that are in the GDCT .db format. The simplest usage is to use dbLoadRecords with a single argument, which is the name of the .db file. dbLoadRecords also provides a macro substitution capability. dbLoadTemplate accepts a .db file that is actually a template that can be instantiated multiple times. The full usage of these commands is described in man pages.

Print a message specifying the EPICS release.

Set Environment Variables

At one time a number of EPICS related environment variables were defined. Many of the values associated with the variables were also needed by the IOCs. Although another mechanism, not using environment variables, is now used on Unix, the values are still needed on the IOCs. These values are defined by a routine epicsEnvParams, which is stored in the epics/share/site directory. Note that the values defined by epicsEnvParams can be overridden by the resource definition file described in the next section.

Get Resource Definitions

GetResource gives values to IOC global variables. The resource file contains lines with the following format:

  global_name   type   value
global_name is the name of the variable to be changed.

type must be one of the following:

value is the value to be assigned to the global variable.

Please note that you MUST set type so that it matches the actual type of the global variable because there is no way for GetResources to know the actual type.

One use of GetResources is to override the default values for the EPICS realted environment variables described in the previous section. Please note that all of these environment variables are of type DBF_STIRING.

The variables that are used in the IOC are:

Initialize Logging

Initialize the logging system. This system traps all logMsg calls and sends a copy to a Unix file. Note that this can be disabled by issuing the command iocLogDisable=1 before issuing iocInit.

Start Task Watchdog

Start the task watchdog task. This task accepts requests to watch other tasks. It runs periodically and checks to see if any of the tasks is suspended. If so it issues an error message. It can also optionally invoke a callback routine.

Start Callback Tasks

Start the general purpose callback tasks. Three tasks are started with the only difference being scheduling priority.

Initialize Channel Access Links - Pass 1

Calls dbCaLinkInit specifying that it is the first call.

Initialize Driver Support

InitDrvSup locates each device driver entry table and calls the init routine of each driver.

Initialize Record Support

InitRecSup locates each record support entry table and calls the init routine.

Initialize Device Support

InitDevSup locates each device support entry table and calls the init routine with an argument specifying that this is the initial call.

Initialize Timing System

Ts_init initializes the timing system. If a hardware timing board resides in the IOC, hardware timing support is used, otherwise software timing is used. If the IOC has been declared to be a master timer, the initial time is obtained from the UNIX master timer, otherwise the initial time is obtained from the IOC master timer.

Initialize Database

InitDatabase makes four passes over the database performing the following functions:

Initialize Channel Access Links - Pass 2

Calls dbCaLinkInit specifying that it is the second call.

Finish Device Support

InitDevSup locates each device support entry table and calls the init routine with an argument specifying that this is the finish call.

Initialize Database Scanners

The periodic, event, and io event scanners are initialized and started.

Accept Interrupts

A global variable "interruptAccept" is set TRUE. Until this time no request should be made to process records and all interrupts should be ignored.

Perform Initial Processing

dbProcess is called for all records that have PINI TRUE.

Start Channel Access Server

The Channel Access server is started.

Table of Contents Next Chapter