# Generic MPS Link Node startup script wdStart(20) # Debugger stub daemon ld("rtems-gdb-stub.obj") chdir("..") ld("bin/RTEMS-uC5282/mpsLinkNode.obj") # note: you can substitute getbenv for bsp_getbenv for AUTOBOOT, but not for # others... mpsReadBenvFactory(bsp_getbenv("FACTORY")) mpsReadBenvRevision(bsp_getbenv("REVISION")) mpsReadBenvSerial(bsp_getbenv("SERIAL")) mpsReadBenvConsole(bsp_getbenv("CONSOLE")) mpsReadBenvKernel(bsp_getbenv("KERNEL")) mpsReadBenvKernelArgs(bsp_getbenv("KERNEL_ARGS")) mpsReadBenvHWAddr0(bsp_getbenv("HWADDR0")) mpsReadBenvFirmware(bsp_getbenv("FW_VERSION")) mpsReadBenvStartPoint(bsp_getbenv("_0")) mpsReadBenvRAMImage(bsp_getbenv("RAMIMAGE")) mpsReadBenvCache(bsp_getbenv("CACHE")) mpsReadBenvAutoboot(bsp_getbenv("AUTOBOOT")) mpsReadBenvBootpEnable(bsp_getbenv("BP_ENBL")) ## /data now mapped by pre_st.cmd nfsMountsShow() ## Register all support components dbLoadDatabase("dbd/mpsLinkNode.dbd",0,0) mpsLinkNode_registerRecordDeviceDriver(pdbbase) #rtems_gdb_start(0,0) ## Load record instances substr=malloc(500) #freed before iocInit() ## Link node ID is used to determine which database to load. ## Link node ID is set with rotary switch on the circuit board. ## This value is accessible via memory mapped I/O register, but ## hardware initialization must be done in order to read it, so ## instead of doing hardware init via iocInit, it MUST be done here mpsInitialise() sprintf(substr,"db/mps%s%s.template",mpsGetLinkNodeLOCA(),mpsGetLinkNodeUNIT()) dbLoadTemplate(substr) sprintf(substr,"db/mps%s%s.blm_ln32_template",mpsGetLinkNodeLOCA(),mpsGetLinkNodeUNIT()) dbLoadTemplate(substr) sprintf(substr,"IOC=EIOC:%s:%s",mpsGetLinkNodeLOCA(),mpsGetLinkNodeUNIT()) dbLoadRecords("db/iocAdmin.db",substr) sprintf(substr,"P=EIOC:%s:%s:",mpsGetLinkNodeLOCA(),mpsGetLinkNodeUNIT()) dbLoadRecords("db/save_restoreStatus.db",substr) drvMpsFlag = 0 drvMpsGetADCFlag = 0 drvMpsSetDebounceFlag = 0 drvMpsGetDebounceFlag = 0 drvMpsGetLatchedFlag = 0 drvMpsGetBlmHVFlag = 0 drvMpsParseXMLFlag = 0 devAiMpsFlag = 0 devAoMpsFlag = 0 devLonginMpsFlag = 0 devLongoutMpsFlag = 0 devStringinMpsFlag = 0 ## ============================================== ## Begin Part 1. New method for autosave and restore ## ============================================== sprintf(substr,"EIOC:%s:%s:",mpsGetLinkNodeLOCA(),mpsGetLinkNodeUNIT()) printf("Using save_restoreSet_status_prefix %s\n",substr) save_restoreSet_status_prefix( substr) save_restoreSet_IncompleteSetsOk(1) save_restoreSet_DatedBackupFiles(1) ## ============================================== ## From pre_st.cmd, /data gets mapped to /u1/lcls/epics/ioc/data/ ## ============================================== set_requestfile_path("/data/autosave-req") set_requestfile_path("./") ################## may not need this ## ============================================== # Reusing substr from above for the save ## ============================================== set_savefile_path("/data","autosave") ## ============================================== ## Decide what is saved by specifying it in the EPICS databases ## ============================================= set_pass0_restoreFile("info_settings.sav") set_pass1_restoreFile("info_settings.sav") ## ============================================= ## Load Access Security File ## caPutLog now depends on this running. ## ============================================= asSetFilename("db/mpsLinkNode.acf") ## ============================================== ## End Part 1. New method for autosave and restore ## ============================================== drvMpsParseDebounceConfigFlag=4 mpsReadDatabaseVersion("/boot/lcls/epics/iocTop/MachineProtection/mpsConfiguration/database/current") sprintf(substr,"/boot/lcls/epics/iocTop/MachineProtection/mpsConfiguration/database/%s/csv/LinkNodeDebounce.csv",mpsGetDatabaseVersion()) printf("%s\n",substr) mpsParseDebounceConfig(substr) # Need to read link_node_type_enum for this link_node_id to know what type it is sprintf(substr,"/boot/lcls/epics/iocTop/MachineProtection/mpsConfiguration/database/%s/csv/LinkNode.csv",mpsGetDatabaseVersion()) printf("%s\n",substr) mpsParseNodeConfig(substr) sprintf(substr,"/boot/lcls/epics/iocTop/MachineProtection/mpsConfiguration/database/%s/csv/LinkNodeChannel.csv",mpsGetDatabaseVersion()) printf("%s\n",substr) mpsParseChannelsConfig(substr) sprintf(substr,"/boot/lcls/epics/iocTop/MachineProtection/mpsConfiguration/database/%s/csv/LinkNodeRack.csv",mpsGetDatabaseVersion()) printf("%s\n",substr) mpsParseNodeRackConfig(substr) iocInit() # get the CSR values to be displayed. may be too invasive, but ... sprintf(substr,"%s:%s:%s:QADC_READ.PROC",mpsGetLinkNodePRIM(),mpsGetLinkNodeLOCA(),mpsGetLinkNodeUNIT()) printf("After iocInit, read QADC to update readback: %s\n",substr) dbpf(substr,"1") ## ============================================== ## Begin Part 2. New method for autosave and restore ## ============================================== ## Turn on caPutLogging: ## Log values only on change to the iocLogServer: ## ===================================================== caPutLogInit("172.27.8.31:7004") caPutLogShow(2) ## =========================================================== ## Start autosave routines to save our data ## =========================================================== ## optional, needed if the IOC takes a very long time to boot. ## =========================================================== epicsThreadSleep( 1.0) ## =========================================================== ## Handle autosave 'commands' contained in loaded databases. ## change directory to ioc startup area to run makeAutosaveFiles() ## =========================================================== printf("making autosave files in: /data/autosave-req\n") chdir("/data/autosave-req") iocshCmd("makeAutosaveFiles()") ## =========================================================== ## Explaining the args: ## you save the the settings every 30 sec ## to a file (if they change more freq, the values are kept in RAM ## and so if IOC reboots, you risk restoring data stale by up to 30 sec create_monitor_set("info_settings.req", 30, "U=") ## ============================================== ## End Part 2. New method for autosave and restore ## ============================================== free(substr)