diff --git a/iocBoot/iocutca/run.sh b/iocBoot/iocutca/run.sh new file mode 100755 index 0000000..ccd9570 --- /dev/null +++ b/iocBoot/iocutca/run.sh @@ -0,0 +1,42 @@ +#!/bin/sh + +set -eu + +export SLOT=$1 + +CRATE=$(./getCrate.sh) +VSLOT=$(./getSlot.sh $SLOT) + +cmd= +case "$(decode-reg build_info -q --slot ${SLOT})" in + afc-tim-receive*) + CRATE=${CRATE#0} + + . ./tim-slot-mapping + val_name=CRATE_${CRATE}_TIM_RX_${VSLOT}_PV_AREA_PREFIX + eval "export AREA_PREFIX=\$${val_name}" + val_name=CRATE_${CRATE}_TIM_RX_${VSLOT}_PV_DEVICE_PREFIX + eval "export DEVICE_PREFIX=\$${val_name}" + + case $(hostname) in + ia-*) ;; + *) export EPICS_CA_ADDR_LIST=10.0.38.59:60000 + esac + + cmd=TIM + ;; + afcv4_fofb_ctrl*) + . ./fofb-slot-mapping + val_name=CRATE_${CRATE}_FOFB_${VSLOT}_PV_AREA_PREFIX + eval "export AREA_PREFIX=\$${val_name}" + val_name=CRATE_${CRATE}_FOFB_${VSLOT}_PV_DEVICE_PREFIX + eval "export DEVICE_PREFIX=\$${val_name}" + export RTM_PREFIX=SI-${CRATE} + + cmd=FOFB + ;; +esac + +if [ -n "$cmd" ]; then + exec procServ -f -n afc-ioc-${SLOT} -L- -i ^C^D -P $(expr 1700 + ${SLOT%-*}) ./st${cmd}.cmd +fi diff --git a/iocBoot/iocutca/runFOFB.sh b/iocBoot/iocutca/runFOFB.sh deleted file mode 100755 index 749eb5f..0000000 --- a/iocBoot/iocutca/runFOFB.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -set -eu - -export SLOT=$1 - -CRATE=$(./getCrate.sh) -VSLOT=$(./getSlot.sh $SLOT) - -. ./fofb-slot-mapping -val_name=CRATE_${CRATE}_FOFB_${VSLOT}_PV_AREA_PREFIX -eval "export AREA_PREFIX=\$${val_name}" -val_name=CRATE_${CRATE}_FOFB_${VSLOT}_PV_DEVICE_PREFIX -eval "export DEVICE_PREFIX=\$${val_name}" -export RTM_PREFIX=SI-${CRATE} - -exec procServ -f -n fofb${SLOT} -L- -i ^C^D -P $(expr 1700 + ${VSLOT}) ./stFOFB.cmd diff --git a/iocBoot/iocutca/runTIM.sh b/iocBoot/iocutca/runTIM.sh deleted file mode 100755 index c96eeda..0000000 --- a/iocBoot/iocutca/runTIM.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -set -eu - -export SLOT=$1 - -CRATE=$(./getCrate.sh) -VSLOT=$(./getSlot.sh $SLOT) - -CRATE=${CRATE#0} - -. ./tim-slot-mapping -val_name=CRATE_${CRATE}_TIM_RX_${VSLOT}_PV_AREA_PREFIX -eval "export AREA_PREFIX=\$${val_name}" -val_name=CRATE_${CRATE}_TIM_RX_${VSLOT}_PV_DEVICE_PREFIX -eval "export DEVICE_PREFIX=\$${val_name}" - -case $(hostname) in - ia-*) ;; - *) export EPICS_CA_ADDR_LIST=10.0.38.59:60000 -esac - -exec procServ -f -n tim${SLOT} -L- -i ^C^D -P $(expr 1700 + ${VSLOT}) ./stTIM.cmd diff --git a/service/95-erics.rules b/service/95-afc.rules similarity index 82% rename from service/95-erics.rules rename to service/95-afc.rules index 7edca3d..cca91ad 100644 --- a/service/95-erics.rules +++ b/service/95-afc.rules @@ -1 +1 @@ -SUBSYSTEM=="pci", ATTR{vendor}=="0x10ee", ATTR{subsystem_device}=="0x0007", RUN+="/usr/bin/setpci -s %k COMMAND=0x2", RUN+="/bin/sh -c 'chmod 666 /sys/bus/pci/devices/%k/resource*'", RUN+="/opt/erics/service/erics-start.sh %k" +SUBSYSTEM=="pci", ATTR{vendor}=="0x10ee", ATTR{subsystem_device}=="0x0007", RUN+="/usr/bin/setpci -s %k COMMAND=0x2", RUN+="/bin/sh -c 'chmod 666 /sys/bus/pci/devices/%k/resource*'", RUN+="/opt/afc-epics-ioc/service/ioc-start.sh %k" diff --git a/service/afc-ioc@.service b/service/afc-ioc@.service new file mode 100644 index 0000000..03cda5e --- /dev/null +++ b/service/afc-ioc@.service @@ -0,0 +1,11 @@ +[Unit] +Description=AFC EPICS IOC %i + +[Service] +User=iocs +Group=iocs + +MemoryAccounting=yes + +WorkingDirectory=/opt/afc-epics-ioc/iocBoot/iocutca +ExecStart=/opt/afc-epics-ioc/iocBoot/iocutca/run.sh %i diff --git a/service/erics-fofb@.service b/service/erics-fofb@.service deleted file mode 100644 index bfcc553..0000000 --- a/service/erics-fofb@.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=FOFB IOC %i - -[Service] -User=iocs -Group=iocs - -MemoryAccounting=yes - -WorkingDirectory=/opt/erics/iocBoot/iocutca -ExecStart=/opt/erics/iocBoot/iocutca/runFOFB.sh %i diff --git a/service/erics-start.sh b/service/erics-start.sh deleted file mode 100755 index 0e79182..0000000 --- a/service/erics-start.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -set -eu - -DEV=$1 - -devslot= -for slot in /sys/bus/pci/slots/* ; do - ADDR=$(cat ${slot}/address) - if [ "${ADDR}.0" = "${DEV}" ]; then - devslot=$(basename ${slot}) - break - fi -done - -if [ -n "${devslot}" -a "${devslot}" = "1" ]; then - systemctl restart erics-tim@${devslot}.service -fi - -if [ -n "${devslot}" -a "${devslot}" = "2-1" ]; then - systemctl restart erics-fofb@${devslot}.service -fi diff --git a/service/erics-tim@.service b/service/erics-tim@.service deleted file mode 100644 index a430b77..0000000 --- a/service/erics-tim@.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=TIM IOC %i - -[Service] -User=iocs -Group=iocs - -MemoryAccounting=yes - -WorkingDirectory=/opt/erics/iocBoot/iocutca -ExecStart=/opt/erics/iocBoot/iocutca/runTIM.sh %i diff --git a/service/ioc-start.sh b/service/ioc-start.sh new file mode 100755 index 0000000..253a0e4 --- /dev/null +++ b/service/ioc-start.sh @@ -0,0 +1,19 @@ +#!/bin/sh +set -eu + +DEV=$1 + +devslot= +for slot in /sys/bus/pci/slots/* ; do + ADDR=$(cat ${slot}/address) + if [ "${ADDR}.0" = "${DEV}" ]; then + devslot=$(basename ${slot}) + break + fi +done + +case "$(decode-reg build_info -q --slot ${devslot})" in + afc-tim-receive*|afcv4_fofb_ctrl*) + systemctl restart afc-ioc@${devslot}.service + ;; +esac