From 077b41e6c10575f6f748ae1b5fb918c3c46e0747 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 30 Aug 2020 18:36:18 -0700 Subject: [PATCH 001/195] Extract compiler pre-defined macros as Make variables --- .gitignore | 1 + configure/CONFIG | 1 + configure/Makefile | 21 +++++++++++++++++- configure/os/CONFIG.Common.RTEMS | 2 +- configure/toolchain.c | 37 ++++++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 configure/toolchain.c diff --git a/.gitignore b/.gitignore index 94e36205a..23a5179e8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ /include/ /templates/ /configure/*.local +/configure/os/CONFIG_TOOLCHAIN.* /modules/RELEASE.*.local /modules/Makefile.local O.*/ diff --git a/configure/CONFIG b/configure/CONFIG index fab3c245f..320ee8200 100644 --- a/configure/CONFIG +++ b/configure/CONFIG @@ -71,6 +71,7 @@ ifdef T_A # Target architecture specific definitions # + -include $(CONFIG)/os/CONFIG_TOOLCHAIN.Common.$(T_A) -include $(CONFIG)/os/CONFIG.Common.$(T_A) # Host-Target architecture specific definitions diff --git a/configure/Makefile b/configure/Makefile index f48278dd3..157dde0ea 100644 --- a/configure/Makefile +++ b/configure/Makefile @@ -15,7 +15,8 @@ include $(TOP)/configure/CONFIG TOOLS = $(TOP)/src/tools CONFIGS += $(subst ../,,$(wildcard ../CONFIG*)) -CONFIGS += $(subst ../,,$(wildcard ../os/CONFIG*)) +CONFIGS += $(subst ../,,$(wildcard ../os/CONFIG.*)) +CONFIGS += $(subst ../,,$(wildcard ../os/CONFIG_SITE.*)) CONFIGS += $(subst ../,,$(wildcard ../RELEASE*)) CONFIGS += $(subst ../,,$(wildcard ../RULES*)) @@ -31,3 +32,21 @@ CFG += CONFIG_DATABASE_VERSION include $(TOP)/configure/RULES +ifdef T_A + +install: $(TOP)/configure/os/CONFIG_TOOLCHAIN.Common.$(T_A) + +$(TOP)/configure/os/CONFIG_TOOLCHAIN.Common.$(T_A): toolchain.c + $(PREPROCESS.cpp) + +else + +realclean: clean_toolchain +clean: clean_toolchain + +clean_toolchain: + $(RM) $(wildcard os/CONFIG_TOOLCHAIN.Common.*) + +.PHONY: clean_toolchain + +endif # T_A diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 8425e6ef9..7a2a616a2 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -41,7 +41,7 @@ include $(CONFIG.CC) # RTEMS cross-development tools CC = $(RTEMS_TOOLS)/bin/$(CC_FOR_TARGET) $(GCCSPECS) -fasm CCC = $(RTEMS_TOOLS)/bin/$(CXX) -CPP = $(RTEMS_TOOLS)/bin/$(CC_FOR_TARGET) -x c -E +CPP = $(RTEMS_TOOLS)/bin/$(CC_FOR_TARGET) -x c -E $(GCCSPECS) AR = $(RTEMS_TOOLS)/bin/$(AR_FOR_TARGET) LD = $(RTEMS_TOOLS)/bin/$(LD_FOR_TARGET) -r diff --git a/configure/toolchain.c b/configure/toolchain.c new file mode 100644 index 000000000..c19d1049d --- /dev/null +++ b/configure/toolchain.c @@ -0,0 +1,37 @@ +#ifdef _COMMENT_ +/* Extract compiler pre-defined macros as Make variables + * + * Expanded as configure/os/CONFIG_TOOLCHAIN.Common.$(T_A) + * + * Must be careful not to #include any C definitions + * into what is really a Makefile snippet + * + * cf. https://sourceforge.net/p/predef/wiki/Home/ + */ +/* GCC preprocessor drops C comments from output. + * MSVC preprocessor emits C comments in output + */ +#endif + +#if defined(__GNUC__) && !defined(__clang__) +GCC_MAJOR = __GNUC__ +GCC_MINOR = __GNUC_MINOR__ +GCC_PATCH = __GNUC_PATCHLEVEL__ + +#elif defined(__clang__) +CLANG_MAJOR = __clang_major__ +CLANG_MINOR = __clang_minor__ +CLANG_PATCH = __clang_patchlevel__ + +#elif defined(_MSC_VER) +MSVC_VER = _MSC_VER +#endif + +#ifdef __rtems__ +#include +# if __RTEMS_MAJOR__>=5 +OS_API = posix +# else +OS_API = kernel +# endif +#endif From bba7d8c8f8aac3ca081e8bd285ec408fefa7e9f4 Mon Sep 17 00:00:00 2001 From: Heinz Junkes Date: Sat, 5 Sep 2020 20:17:30 +0200 Subject: [PATCH 002/195] Enable Epics for RTEMS5 (posix) --- configure/CONFIG_COMMON | 5 +- configure/os/CONFIG.Common.RTEMS | 36 +- .../os/CONFIG.Common.RTEMS-beagleboneblack | 18 + configure/os/CONFIG.Common.RTEMS-beatnik | 8 +- configure/os/CONFIG.Common.RTEMS-pc386-qemu | 3 +- configure/os/CONFIG.Common.RTEMS-pc686 | 25 + configure/os/CONFIG.Common.RTEMS-qoriq_e500 | 48 + .../CONFIG.Common.RTEMS-xilinx_zynq_a9_qemu | 20 + .../CONFIG.Common.RTEMS-xilinx_zynq_zedboard | 19 + configure/os/CONFIG.darwin-x86.Common | 3 +- configure/os/CONFIG_SITE.Common.RTEMS | 6 +- documentation/RELEASE_NOTES.md | 17 + modules/libcom/RTEMS/Makefile | 9 + modules/libcom/RTEMS/epicsNtp.c | 85 ++ modules/libcom/RTEMS/epicsNtp.h | 43 + .../libcom/RTEMS/{ => kernel}/rtems_config.c | 0 .../libcom/RTEMS/{ => kernel}/rtems_init.c | 0 .../RTEMS/{ => kernel}/rtems_netconfig.c | 0 .../RTEMS/posix/epicsRtemsInitHookPost.c | 18 + .../RTEMS/posix/epicsRtemsInitHookPre.c | 18 + .../libcom/RTEMS/posix/epicsRtemsInitHooks.h | 24 + modules/libcom/RTEMS/posix/libbsd_netconfig.c | 116 ++ modules/libcom/RTEMS/posix/libbsd_netconfig.h | 24 + modules/libcom/RTEMS/posix/rtems_config.c | 153 +++ modules/libcom/RTEMS/posix/rtems_init.c | 1007 +++++++++++++++++ .../RTEMS/posix/setBootConfigFromNVRAM.c | 369 ++++++ .../os/{RTEMS => RTEMS-kernel}/devLibVMEOSD.c | 0 .../epicsAtomicOSD.cpp | 0 .../{RTEMS => RTEMS-kernel}/epicsAtomicOSD.h | 0 .../os/{RTEMS => RTEMS-kernel}/epicsMath.h | 0 .../osi/os/{RTEMS => RTEMS-kernel}/osdEnv.c | 0 .../osi/os/{RTEMS => RTEMS-kernel}/osdEvent.c | 0 .../osi/os/{RTEMS => RTEMS-kernel}/osdEvent.h | 0 .../{RTEMS => RTEMS-kernel}/osdFindSymbol.c | 0 .../src/osi/os/RTEMS-kernel/osdMessageQueue.c | 251 ++++ .../src/osi/os/RTEMS-kernel/osdMessageQueue.h | 29 + .../osi/os/{RTEMS => RTEMS-kernel}/osdMutex.c | 0 .../osi/os/{RTEMS => RTEMS-kernel}/osdMutex.h | 0 .../{RTEMS => RTEMS-kernel}/osdPoolStatus.c | 0 .../os/{RTEMS => RTEMS-kernel}/osdProcess.c | 0 .../os/{RTEMS => RTEMS-kernel}/osdReadline.c | 0 .../os/{RTEMS => RTEMS-kernel}/osdSignal.cpp | 0 .../osi/os/{RTEMS => RTEMS-kernel}/osdSock.h | 0 .../osi/os/{RTEMS => RTEMS-kernel}/osdSpin.c | 0 .../os/{RTEMS => RTEMS-kernel}/osdStrtod.h | 0 .../os/{RTEMS => RTEMS-kernel}/osdThread.c | 0 .../os/{RTEMS => RTEMS-kernel}/osdThread.h | 0 .../{RTEMS => RTEMS-kernel}/osdThreadExtra.c | 0 .../os/{RTEMS => RTEMS-kernel}/osdTime.cpp | 0 .../osi/os/{RTEMS => RTEMS-kernel}/osdTime.h | 0 .../os/{RTEMS => RTEMS-kernel}/osiUnistd.h | 0 .../src/osi/os/RTEMS-posix/osdMessageQueue.c | 160 +++ .../src/osi/os/RTEMS-posix/osdMessageQueue.h | 29 + .../libcom/src/osi/os/RTEMS-posix/osdMutex.c | 6 + .../src/osi/os/RTEMS-posix/osdPoolStatus.c | 27 + .../libcom/src/osi/os/RTEMS-posix/osdSock.h | 81 ++ 56 files changed, 2645 insertions(+), 12 deletions(-) create mode 100644 configure/os/CONFIG.Common.RTEMS-beagleboneblack create mode 100644 configure/os/CONFIG.Common.RTEMS-pc686 create mode 100644 configure/os/CONFIG.Common.RTEMS-qoriq_e500 create mode 100644 configure/os/CONFIG.Common.RTEMS-xilinx_zynq_a9_qemu create mode 100644 configure/os/CONFIG.Common.RTEMS-xilinx_zynq_zedboard create mode 100644 modules/libcom/RTEMS/epicsNtp.c create mode 100644 modules/libcom/RTEMS/epicsNtp.h rename modules/libcom/RTEMS/{ => kernel}/rtems_config.c (100%) rename modules/libcom/RTEMS/{ => kernel}/rtems_init.c (100%) rename modules/libcom/RTEMS/{ => kernel}/rtems_netconfig.c (100%) create mode 100644 modules/libcom/RTEMS/posix/epicsRtemsInitHookPost.c create mode 100644 modules/libcom/RTEMS/posix/epicsRtemsInitHookPre.c create mode 100644 modules/libcom/RTEMS/posix/epicsRtemsInitHooks.h create mode 100644 modules/libcom/RTEMS/posix/libbsd_netconfig.c create mode 100644 modules/libcom/RTEMS/posix/libbsd_netconfig.h create mode 100644 modules/libcom/RTEMS/posix/rtems_config.c create mode 100644 modules/libcom/RTEMS/posix/rtems_init.c create mode 100644 modules/libcom/RTEMS/posix/setBootConfigFromNVRAM.c rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/devLibVMEOSD.c (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/epicsAtomicOSD.cpp (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/epicsAtomicOSD.h (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/epicsMath.h (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdEnv.c (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdEvent.c (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdEvent.h (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdFindSymbol.c (100%) create mode 100644 modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c create mode 100644 modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdMutex.c (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdMutex.h (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdPoolStatus.c (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdProcess.c (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdReadline.c (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdSignal.cpp (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdSock.h (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdSpin.c (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdStrtod.h (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdThread.c (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdThread.h (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdThreadExtra.c (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdTime.cpp (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osdTime.h (100%) rename modules/libcom/src/osi/os/{RTEMS => RTEMS-kernel}/osiUnistd.h (100%) create mode 100644 modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c create mode 100644 modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h create mode 100644 modules/libcom/src/osi/os/RTEMS-posix/osdMutex.c create mode 100644 modules/libcom/src/osi/os/RTEMS-posix/osdPoolStatus.c create mode 100644 modules/libcom/src/osi/os/RTEMS-posix/osdSock.h diff --git a/configure/CONFIG_COMMON b/configure/CONFIG_COMMON index 6c0e11e0d..9ccdf2804 100644 --- a/configure/CONFIG_COMMON +++ b/configure/CONFIG_COMMON @@ -142,9 +142,10 @@ BUILDLIB_SUFFIX = $(BUILDLIB_SUFFIX_$(SHARED_LIBRARIES)) #-------------------------------------------------- # vpath directories POSIX_YES = os/posix +OS_IMPL_DIRS = $(if $(OS_API),os/$(OS_CLASS)-$(OS_API),) os/$(OS_CLASS) GENERIC_SRC_DIRS = .. $(SRC_DIRS) OS_SRC_DIRS += . $(foreach dir, .. $(SRC_DIRS), \ - $(addprefix $(dir)/, os/$(OS_CLASS) $(POSIX_$(POSIX)) os/default )) + $(addprefix $(dir)/, $(OS_IMPL_DIRS) $(POSIX_$(POSIX)) os/default )) CMPLR_SRC_DIRS += . $(foreach dir, .. $(SRC_DIRS), \ $(addprefix $(dir)/, compiler/$(CMPLR_CLASS) compiler/default )) ALL_SRC_DIRS = $(CMPLR_SRC_DIRS) $(OS_SRC_DIRS) $(GENERIC_SRC_DIRS) @@ -306,7 +307,7 @@ LDLIBS = $(POSIX_LDLIBS) $(ARCH_DEP_LDLIBS) $(DEBUG_LDLIBS) $(OP_SYS_LDLIBS)\ CPPFLAGS = $($(BUILD_CLASS)_CPPFLAGS) $(POSIX_CPPFLAGS) $(OPT_CPPFLAGS)\ $(DEBUG_CPPFLAGS) $(WARN_CPPFLAGS) $(BASE_CPPFLAGS) $(TARGET_CPPFLAGS)\ $(USR_CPPFLAGS) $(CMD_CPPFLAGS) $(ARCH_DEP_CPPFLAGS) $(OP_SYS_CPPFLAGS)\ - $(OP_SYS_INCLUDE_CPPFLAGS) $(CODE_CPPFLAGS) $(API_CPPFLAGS) + $(OP_SYS_INCLUDE_CPPFLAGS) $(CODE_CPPFLAGS) #-------------------------------------------------- # ar definition default diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 7a2a616a2..86a037295 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -33,7 +33,7 @@ RTEMS_BSP ?= $(subst RTEMS-,,$(T_A)) #------------------------------------------------------- # Pick up the RTEMS tool/path definitions from the RTEMS BSP directory. -include $(RTEMS_BASE)/$(RTEMS_TARGET_CPU)-rtems$(RTEMS_VERSION)/$(RTEMS_BSP)/Makefile.inc +include $(RTEMS_BASE)/$(GNU_TARGET)$(RTEMS_VERSION)/$(RTEMS_BSP)/Makefile.inc include $(RTEMS_CUSTOM) include $(CONFIG.CC) @@ -94,16 +94,46 @@ MODEXT=.obj # operating system class (include/os/) OS_CLASS = RTEMS +#-------------------------------------------------- +#print warning +ifeq ($(RTEMS_HAS_POSIX_API),no) +ifeq ($(EPICS_VERSION),7) + $(error Warning: Epics Version $(EPICS_VERSION) must not be used without POSIX enabled on RTEMS !!!) +endif +endif +# operating system API (src/os/-) +ifeq ($(RTEMS_HAS_POSIX_API),yes) +OS_API = posix +else +OS_API = kernel +endif + #-------------------------------------------------- # Operating system flags -OP_SYS_LDLIBS += -lrtemsCom -lc -lrtemscpu -lCom -lnfs -lm -OP_SYS_LDFLAGS += $(CPU_CFLAGS) -u Init \ +#OP_SYS_LDLIBS += -lrtemsCom -lc -lrtemscpu -lCom -lnfs -lm +ifeq ($(RTEMS_API),5) +OP_SYS_CFLAGS += -D__LINUX_ERRNO_EXTENSIONS__ +#OP_SYS_LDLIBS += -lrtemsCom -lrtemscpu -lrtemsbsp -ltftpfs -ltelnetd -lbsd -lz -lm +OP_SYS_LDLIBS += -lrtemsCom -lc -lrtemscpu -ltftpfs -lbsd -lz -lm +else +OP_SYS_LDLIBS += -lrtemsCom -lrtemscpu -lrtemsbsp +endif + +ifeq ($(RTEMS_HAS_NETWORKING),yes) +OP_SYS_CFLAGS += -DRTEMS_LEGACY_STACK +else +OP_SYS_CFLAGS += -DHAVE_SOCKADDR_SA_LEN=1 +endif + +OP_SYS_LDFLAGS_posix += -u POSIX_Init +OP_SYS_LDFLAGS_kernel += $(CPU_CFLAGS) -u Init \ $(PROJECT_RELEASE)/lib/no-dpmem.rel \ $(PROJECT_RELEASE)/lib/no-mp.rel \ $(PROJECT_RELEASE)/lib/no-part.rel \ $(PROJECT_RELEASE)/lib/no-signal.rel \ $(PROJECT_RELEASE)/lib/no-rtmon.rel +OP_SYS_LDFLAGS += $(CPU_CFLAGS) $(OP_SYS_LDFLAGS_$(OS_API)) MOD_SYS_LDFLAGS += $(CPU_CFLAGS) -Wl,-r -nostdlib # Do not link against libraries which are part of the Generic Image diff --git a/configure/os/CONFIG.Common.RTEMS-beagleboneblack b/configure/os/CONFIG.Common.RTEMS-beagleboneblack new file mode 100644 index 000000000..4b6107b05 --- /dev/null +++ b/configure/os/CONFIG.Common.RTEMS-beagleboneblack @@ -0,0 +1,18 @@ +# +# CONFIG.Common.RTEMS-beaglebineblack +# Author: Heinz Junkes +# +# All RTEMS targets use the same Makefile fragment +# +#EXE = .elf +RTEMS_BSP = beagleboneblack +RTEMS_TARGET_CPU = arm +GNU_TARGET = arm-rtems + +OP_SYS_LDLIBS += -Wl,--gc-sections +ARCH_DEP_LDFLAGS = -L$(RTEMS_BASE)/$(GNU_TARGET)$(RTEMS_VERSION)/beagleboneblack/lib/ + +include $(CONFIG)/os/CONFIG.Common.RTEMS + + + diff --git a/configure/os/CONFIG.Common.RTEMS-beatnik b/configure/os/CONFIG.Common.RTEMS-beatnik index aaa45e4c9..84ba42667 100644 --- a/configure/os/CONFIG.Common.RTEMS-beatnik +++ b/configure/os/CONFIG.Common.RTEMS-beatnik @@ -8,14 +8,18 @@ EXE = .elf RTEMS_BSP = beatnik RTEMS_TARGET_CPU = powerpc GNU_TARGET = powerpc-rtems -ARCH_DEP_CFLAGS += -DMY_DO_BOOTP=NULL +# optimization trouble in postfix.c +ARCH_DEP_CFLAGS += -DRTEMS_HAS_ALTIVEC +#will use bootp +#ARCH_DEP_CFLAGS += -DMY_DO_BOOTP=NULL ARCH_DEP_CFLAGS += -DHAVE_MOTLOAD ARCH_DEP_CFLAGS += -DRTEMS_NETWORK_CONFIG_MBUF_SPACE=2048 ARCH_DEP_CFLAGS += -DRTEMS_NETWORK_CONFIG_CLUSTER_SPACE=5120 -OP_SYS_LDLIBS += -lbspExt +OP_SYS_LDLIBS += -lbspExt #does not use posix stuff ... want to ignore MUNCH_SUFFIX = .boot +MUNCHNAME = $(PRODNAME:%$(EXE)=%$(MUNCH_SUFFIX)) define MUNCH_CMD $(RTEMS_TOOLS)/bin/$(OBJCOPY_FOR_TARGET) -O binary $< $@ endef diff --git a/configure/os/CONFIG.Common.RTEMS-pc386-qemu b/configure/os/CONFIG.Common.RTEMS-pc386-qemu index 684f01a19..29196ff65 100644 --- a/configure/os/CONFIG.Common.RTEMS-pc386-qemu +++ b/configure/os/CONFIG.Common.RTEMS-pc386-qemu @@ -6,6 +6,7 @@ #------------------------------------------------------- # Include definitions from RTEMS-pc386 -include $(CONFIG)/os/CONFIG.Common.RTEMS-pc386 +# For Tests overwrite it with pc686 +include $(CONFIG)/os/CONFIG.Common.RTEMS-pc686 RTEMS_QEMU_FIXUPS = YES diff --git a/configure/os/CONFIG.Common.RTEMS-pc686 b/configure/os/CONFIG.Common.RTEMS-pc686 new file mode 100644 index 000000000..43849744f --- /dev/null +++ b/configure/os/CONFIG.Common.RTEMS-pc686 @@ -0,0 +1,25 @@ +# +# Author: W. Eric Norum +# Canadian Light Source +# eric@cls.usask.ca +# +# All RTEMS targets use the same Makefile fragment +# +RTEMS_BSP = pc686 +RTEMS_TARGET_CPU = i386 +GNU_TARGET = i386-rtems + +MUNCH_SUFFIX = .boot +define MUNCH_CMD + $(RTEMS_TOOLS)/bin/$(OBJCOPY_FOR_TARGET) -O binary -R .comment -S $< $@ +endef + +OP_SYS_LDLIBS += -Wl,--gc-sections +ARCH_DEP_LDFLAGS = -L$(RTEMS_BASE)/$(GNU_TARGET)$(RTEMS_VERSION)/pc686/lib/ + +include $(CONFIG)/os/CONFIG.Common.RTEMS + +# +# Put text segment where it will work with etherboot +# +OP_SYS_LDFLAGS += -Wl,-Ttext,0x100000 diff --git a/configure/os/CONFIG.Common.RTEMS-qoriq_e500 b/configure/os/CONFIG.Common.RTEMS-qoriq_e500 new file mode 100644 index 000000000..9ea6aec5d --- /dev/null +++ b/configure/os/CONFIG.Common.RTEMS-qoriq_e500 @@ -0,0 +1,48 @@ +# +# CONFIG.Common.RTEMS-qoriq_e500 +# Author: Heinz Junkes +# +# All RTEMS targets use the same Makefile fragment +# +EXE = .elf +RTEMS_BSP = qoriq_e500 +RTEMS_TARGET_CPU = powerpc +GNU_TARGET = powerpc-rtems +# optimization trouble in postfix.c +#ARCH_DEP_CFLAGS += -DRTEMS_HAS_ALTIVEC +#will use bootp +#ARCH_DEP_CFLAGS += -DMY_DO_BOOTP=NULL + +#ARCH_DEP_CFLAGS += -DRTEMS_NETWORK_CONFIG_MBUF_SPACE=2048 +#ARCH_DEP_CFLAGS += -DRTEMS_NETWORK_CONFIG_CLUSTER_SPACE=5120 + +#netbsdlib +#ARCH_DEP_CFLAGS += -I$(RTEMS_BASE)/powerpc-rtems5/qoriq_e500/lib/include + +#OP_SYS_LDLIBS += -lbspExt #does not use posix stuff ... want to ignore +OP_SYS_LDLIBS += -Wl,--gc-sections +#ARCH_DEP_LDFLAGS = -mcpu=8540 -meabi -msdata=sysv -mstrict-align -mspe -mabi=spe -mfloat-gprs=double +ARCH_DEP_LDFLAGS = -L$(RTEMS_BASE)/powerpc-rtems5/qoriq_e500/lib + +MUNCH_SUFFIX = .img +MUNCHNAME = $(PRODNAME:%$(EXE)=%$(MUNCH_SUFFIX)) +define MUNCH_CMD + $(RTEMS_TOOLS)/bin/$(OBJCOPY_FOR_TARGET) -O binary $< $@ + gzip -9 -f $@ + mkimage -A ppc -O linux -T kernel -a 0x4000 -e 0x4000 -n $* -d $@.gz $*.img +endef + +include $(CONFIG)/os/CONFIG.Common.RTEMS + +RTEMSSYMS=$(PRODNAME:%$(EXE)=%.sym) +RTEMSIMGS=$(PRODNAME:%$(EXE)=%.bin) +INSTALL_RTEMSSYMS=$(RTEMSSYMS:%=$(INSTALL_BIN)/%) +INSTALL_RTEMSIMGS=$(RTEMSIMGS:%=$(INSTALL_BIN)/%) + +%.sym: %$(EXE) + $(XSYMS) $^ $@ + +%.bin: %$(EXE) + $(OBJCOPY) -Obinary $^ $@ + +#PRODTARGETS+=$(INSTALL_RTEMSSYMS) $(INSTALL_RTEMSIMGS) diff --git a/configure/os/CONFIG.Common.RTEMS-xilinx_zynq_a9_qemu b/configure/os/CONFIG.Common.RTEMS-xilinx_zynq_a9_qemu new file mode 100644 index 000000000..83b518b69 --- /dev/null +++ b/configure/os/CONFIG.Common.RTEMS-xilinx_zynq_a9_qemu @@ -0,0 +1,20 @@ +# +# CONFIG.Common.RTEMS-xilinx_zynq_a9_qemu +# Author: Heinz Junkes +# +# All RTEMS targets use the same Makefile fragment +# +#EXE = .elf +RTEMS_BSP = xilinx_zynq_a9_qemu +RTEMS_TARGET_CPU = arm +GNU_TARGET = arm-rtems + +#use dhcp/bootp +ARCH_DEP_CFLAGS += -DMY_DO_BOOTP=NULL + +OP_SYS_LDLIBS += -Wl,--gc-sections +ARCH_DEP_LDFLAGS = -L$(RTEMS_BASE)/$(GNU_TARGET)$(RTEMS_VERSION)/xilinx_zynq_a9_qemu/lib/ + + +include $(CONFIG)/os/CONFIG.Common.RTEMS + diff --git a/configure/os/CONFIG.Common.RTEMS-xilinx_zynq_zedboard b/configure/os/CONFIG.Common.RTEMS-xilinx_zynq_zedboard new file mode 100644 index 000000000..bac33eb91 --- /dev/null +++ b/configure/os/CONFIG.Common.RTEMS-xilinx_zynq_zedboard @@ -0,0 +1,19 @@ +# +# CONFIG.Common.RTEMS-xilinx_zynq_zedboard +# Author: Heinz Junkes +# +# All RTEMS targets use the same Makefile fragment +# +#EXE = .elf +RTEMS_BSP = xilinx_zynq_zedboard +RTEMS_TARGET_CPU = arm +GNU_TARGET = arm-rtems + +OP_SYS_LDLIBS += -Wl,--gc-sections +ARCH_DEP_LDFLAGS = -L$(RTEMS_BASE)/$(GNU_TARGET)$(RTEMS_VERSION)/xilinx_zynq_zedboard/lib/ + + +include $(CONFIG)/os/CONFIG.Common.RTEMS + + + diff --git a/configure/os/CONFIG.darwin-x86.Common b/configure/os/CONFIG.darwin-x86.Common index e779f7dc1..960c74b8a 100644 --- a/configure/os/CONFIG.darwin-x86.Common +++ b/configure/os/CONFIG.darwin-x86.Common @@ -3,6 +3,7 @@ # Definitions for darwin-x86 host builds # Sites may override these definitions in CONFIG_SITE.darwin-x86.Common #------------------------------------------------------- - +#support for IPv6 etc. +OP_SYS_CFLAGS += -DHAVE_SOCKADDR_SA_LEN=1 #Include definitions common to unix hosts include $(CONFIG)/os/CONFIG.UnixCommon.Common diff --git a/configure/os/CONFIG_SITE.Common.RTEMS b/configure/os/CONFIG_SITE.Common.RTEMS index 0b5d227ee..47de204dd 100644 --- a/configure/os/CONFIG_SITE.Common.RTEMS +++ b/configure/os/CONFIG_SITE.Common.RTEMS @@ -5,9 +5,9 @@ # Where to find RTEMS # -# APS: -RTEMS_VERSION = 4.10.2 -RTEMS_BASE = /usr/local/vw/rtems/rtems-$(RTEMS_VERSION) +# FHI: +RTEMS_VERSION = 5 +RTEMS_BASE = /home/travis/.rtems # Cross-compile toolchain in $(RTEMS_TOOLS)/bin # diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 8533f8276..5bbd1647b 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -71,6 +71,23 @@ This also fixes [lauchpad bug #1714455](https://bugs.launchpad.net/bugs/1714455) These changes are to more closely follow the JSON5 standard, which doesn't support octal character escapes or the `\a` (Bel, `\x07`) escape sequence. +### Support for RTEMS 5 + +The new major release of the RTEMS real-time OS contains many changes including +the ability to support SMP systems. The earlier EPICS support for RTEMS made use +of various RTEMS-specific kernel APIs which cannot be used on an SMP system, so +the changes here required acompletely new port to the Posix real-time APIs that +RTEMS-5 now recommends. +A new RTEMS configuration variable RTEMS_SERIES has been added which should be +set to the first two components of the OS version number, e.g. 4.9. When this +is 4.12 or greater, true for 5.0 as well, the new libCom/osi/os/RTEMS-posix +source files will be used; the older API source files can now be found in +libCom/osi/os/RTEMS-kernel, and those which are common to both installations are +in libCom/osi/os/RTEMS. The compiler options are read from the Makefile.inc of +the corresponding BSP and set in the configuration files. It checks that the BSP +was also built with the --enable-posix option. It also checks if the BSP was built +with the legacy stack or libbsd. + ### Filters in database input links Input database links can now use channel filters, it is not necessary to diff --git a/modules/libcom/RTEMS/Makefile b/modules/libcom/RTEMS/Makefile index b46889db1..5865ff8e8 100644 --- a/modules/libcom/RTEMS/Makefile +++ b/modules/libcom/RTEMS/Makefile @@ -11,22 +11,31 @@ TOP = ../../.. include $(TOP)/configure/CONFIG include $(TOP)/configure/CONFIG_LIBCOM_VERSION +# check check +SRC_DIRS += ../$(OS_API) + PERL_SCRIPTS += epicsMakeMemFs.pl INC += epicsRtemsInitHooks.h INC += epicsMemFs.h +INC += epicsNtp.h ifeq ($(RTEMS_QEMU_FIXUPS),YES) rtems_init_CPPFLAGS += -DQEMU_FIXUPS endif rtemsCom_SRCS += rtems_init.c rtemsCom_SRCS += rtems_config.c +ifeq ($(RTEMS_HAS_NETWORKING), yes) rtemsCom_SRCS += rtems_netconfig.c +else +rtemsCom_SRCS += libbsd_netconfig.c +endif rtemsCom_SRCS += rtems_util.c rtemsCom_SRCS += setBootConfigFromNVRAM.c rtemsCom_SRCS += epicsRtemsInitHookPre.c rtemsCom_SRCS += epicsRtemsInitHookPost.c rtemsCom_SRCS += epicsMemFs.c +rtemsCom_SRCS += epicsNtp.c ifeq ($(RTEMS_BSP),pc386) rtemsCom_SRCS += ne2kpci.c diff --git a/modules/libcom/RTEMS/epicsNtp.c b/modules/libcom/RTEMS/epicsNtp.c new file mode 100644 index 000000000..9a28cb223 --- /dev/null +++ b/modules/libcom/RTEMS/epicsNtp.c @@ -0,0 +1,85 @@ +/*************************************************************************\ +* (C) 2014 David Lettier. +* http://www.lettier.com/ +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "epicsNtp.h" + +int epicsNtpGetTime(char *ntpIp, struct timespec *now) +{ + + int sockfd, n; // Socket file descriptor and the n return result from writing/reading from the socket. + int portno = 123; // NTP UDP port number. + + // Create and zero out the packet. All 48 bytes worth. + ntp_packet packet = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; + memset( &packet, 0, sizeof( ntp_packet ) ); + // Set the first byte's bits to 00,011,011 for li = 0, vn = 3, and mode = 3. The rest will be left set to zero. + *( ( char * ) &packet + 0 ) = 0x1b; // Represents 27 in base 10 or 00011011 in base 2. + + // Create a UDP socket, convert the host-name to an IP address, set the port number, + // connect to the server, send the packet, and then read in the return packet. + struct sockaddr_in serv_addr; // Server address data structure. + + sockfd = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP ); // Create a UDP socket. + + if ( sockfd < 0 ) { + perror( "epicsNtpGetTime" ); + return -1; + } + + // Zero out the server address structure. + bzero( ( char* ) &serv_addr, sizeof( serv_addr ) ); + + serv_addr.sin_family = AF_INET; + serv_addr.sin_addr.s_addr = inet_addr(ntpIp); + serv_addr.sin_port = htons( portno ); + + // Call up the server using its IP address and port number. + if ( connect( sockfd, ( struct sockaddr * ) &serv_addr, sizeof( serv_addr) ) < 0 ) { + perror( "epicsNtpGetTime" ); + return -1; + } + + // Send it the NTP packet it wants. If n == -1, it failed. + n = write( sockfd, ( char* ) &packet, sizeof( ntp_packet ) ); + if ( n < 0 ) { + perror( "epicsNtpGetTime" ); + return -1; + } + +// Wait and receive the packet back from the server. If n == -1, it failed. + n = read( sockfd, ( char* ) &packet, sizeof( ntp_packet ) ); + if ( n < 0 ) { + perror( "epicsNtpGetTime" ); + return -1; + } + + // These two fields contain the time-stamp seconds as the packet left the NTP server. + // The number of seconds correspond to the seconds passed since 1900. + // ntohl() converts the bit/byte order from the network's to host's "endianness". + packet.txTm_s = ntohl( packet.txTm_s ); // Time-stamp seconds. + packet.txTm_f = ntohl( packet.txTm_f ); // Time-stamp fraction of a second. + + // Extract the 32 bits that represent the time-stamp seconds (since NTP epoch) from when the packet left the server. + // Subtract 70 years worth of seconds from the seconds since 1900. + // This leaves the seconds since the UNIX epoch of 1970. + // (1900)------------------(1970)**************************************(Time Packet Left the Server) + time_t txTm = ( time_t ) ( packet.txTm_s - NTP_TIMESTAMP_DELTA ); + now->tv_sec = txTm; + return 0; +} diff --git a/modules/libcom/RTEMS/epicsNtp.h b/modules/libcom/RTEMS/epicsNtp.h new file mode 100644 index 000000000..dfff00a6b --- /dev/null +++ b/modules/libcom/RTEMS/epicsNtp.h @@ -0,0 +1,43 @@ +/*************************************************************************\ +* (C) 2014 David Lettier. +* http://www.lettier.com/ +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +#ifndef EPICSNTP_H +#define EPICSNTP_H + +#define NTP_TIMESTAMP_DELTA 2208988800ull + +int epicsNtpGetTime(char *ntpIp, struct timespec *now); + +typedef struct +{ + + uint8_t li_vn_mode; // Eight bits. li, vn, and mode. + // li. Two bits. Leap indicator. + // vn. Three bits. Version number of the protocol. + // mode. Three bits. Client will pick mode 3 for client. + + uint8_t stratum; // Eight bits. Stratum level of the local clock. + uint8_t poll; // Eight bits. Maximum interval between successive messages. + uint8_t precision; // Eight bits. Precision of the local clock. + + uint32_t rootDelay; // 32 bits. Total round trip delay time. + uint32_t rootDispersion; // 32 bits. Max error aloud from primary clock source. + uint32_t refId; // 32 bits. Reference clock identifier. + + uint32_t refTm_s; // 32 bits. Reference time-stamp seconds. + uint32_t refTm_f; // 32 bits. Reference time-stamp fraction of a second. + + uint32_t origTm_s; // 32 bits. Originate time-stamp seconds. + uint32_t origTm_f; // 32 bits. Originate time-stamp fraction of a second. + + uint32_t rxTm_s; // 32 bits. Received time-stamp seconds. + uint32_t rxTm_f; // 32 bits. Received time-stamp fraction of a second. + + uint32_t txTm_s; // 32 bits and the most important field the client cares about. Transmit time-stamp seconds. + uint32_t txTm_f; // 32 bits. Transmit time-stamp fraction of a second. + +} ntp_packet; // Total: 384 bits or 48 bytes. +#endif // EPICSNTP_H diff --git a/modules/libcom/RTEMS/rtems_config.c b/modules/libcom/RTEMS/kernel/rtems_config.c similarity index 100% rename from modules/libcom/RTEMS/rtems_config.c rename to modules/libcom/RTEMS/kernel/rtems_config.c diff --git a/modules/libcom/RTEMS/rtems_init.c b/modules/libcom/RTEMS/kernel/rtems_init.c similarity index 100% rename from modules/libcom/RTEMS/rtems_init.c rename to modules/libcom/RTEMS/kernel/rtems_init.c diff --git a/modules/libcom/RTEMS/rtems_netconfig.c b/modules/libcom/RTEMS/kernel/rtems_netconfig.c similarity index 100% rename from modules/libcom/RTEMS/rtems_netconfig.c rename to modules/libcom/RTEMS/kernel/rtems_netconfig.c diff --git a/modules/libcom/RTEMS/posix/epicsRtemsInitHookPost.c b/modules/libcom/RTEMS/posix/epicsRtemsInitHookPost.c new file mode 100644 index 000000000..f589eb9cf --- /dev/null +++ b/modules/libcom/RTEMS/posix/epicsRtemsInitHookPost.c @@ -0,0 +1,18 @@ +/*************************************************************************\ +* Copyright (c) 2006 The University of Chicago, as Operator of Argonne +* National Laboratory. +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * Dummy version -- use if application does not provide its own version + */ +#include "epicsRtemsInitHooks.h" + +int +epicsRtemsInitPostSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config) +{ + return 0; +} diff --git a/modules/libcom/RTEMS/posix/epicsRtemsInitHookPre.c b/modules/libcom/RTEMS/posix/epicsRtemsInitHookPre.c new file mode 100644 index 000000000..08efe1fe2 --- /dev/null +++ b/modules/libcom/RTEMS/posix/epicsRtemsInitHookPre.c @@ -0,0 +1,18 @@ +/*************************************************************************\ +* Copyright (c) 2006 The University of Chicago, as Operator of Argonne +* National Laboratory. +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * Dummy version -- use if application does not provide its own version + */ +#include "epicsRtemsInitHooks.h" + +int +epicsRtemsInitPreSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config) +{ + return 0; +} diff --git a/modules/libcom/RTEMS/posix/epicsRtemsInitHooks.h b/modules/libcom/RTEMS/posix/epicsRtemsInitHooks.h new file mode 100644 index 000000000..8671bebbf --- /dev/null +++ b/modules/libcom/RTEMS/posix/epicsRtemsInitHooks.h @@ -0,0 +1,24 @@ +/*************************************************************************\ +* Copyright (c) 2006 The University of Chicago, as Operator of Argonne +* National Laboratory. +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * Hooks into RTEMS startup code + */ +#include + +extern char *env_nfsServer; +extern char *env_nfsPath; +extern char *env_nfsMountPoint; + +/* + * Return 0 for success, non-zero for failure (will cause panic) + */ +int epicsRtemsInitPreSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config); +int epicsRtemsInitPostSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config); +/* Return 0 if local file system was setup, or non-zero (will fall back to network */ +int epicsRtemsMountLocalFilesystem(char **argv); diff --git a/modules/libcom/RTEMS/posix/libbsd_netconfig.c b/modules/libcom/RTEMS/posix/libbsd_netconfig.c new file mode 100644 index 000000000..d9c9f704d --- /dev/null +++ b/modules/libcom/RTEMS/posix/libbsd_netconfig.c @@ -0,0 +1,116 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Saskatchewan +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * RTEMS network configuration for EPICS + * Author: W. Eric Norum + * eric.norum@usask.ca + * (306) 966-5394 + * + * This file can be copied to an application source dirctory + * and modified to override the values shown below. + */ +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#include "libbsd_netconfig.h" + +#include +#include + +#define IFACE_IPV4_DHCP(iface) \ + "ifconfig_" # iface "=\"SYNCDHCP\"\n" + +#define IFACE_IPV4(iface, addr) \ + "ifconfig_" # iface "=\"inet " # addr " netmask 255.255.255.0\"\n" + +static const char* rc_conf_text = \ + "\n" \ + "syslog_priority=\"debug\"\n" \ + "\n" \ + "#create_args_myvlan=\"vlan 102\"\n" \ + "#create_args_yourvlan=\"vlan 202\"\n" \ + IFACE_IPV4_DHCP(cgem0) \ + "\n" \ + "dhcpcd_priority=\"100\"\n" \ + "\n" \ + "#defaultrouter=\"" NET_CFG_GATEWAY_IP "\"\n" \ + "defaultroute_delay=\"5\"\n" \ + "\n" \ + "#telnetd_enable=\"YES\"\n" \ + "#telnetd_options=\"-C 2 -P 100 \"\n" \ + "\n" \ + "#ftpd_enable=\"YES\"\n" \ + "#ftpd_options=\"-v -p 21 -C 2 -P 150 -L -I 10 -R /\"\n" \ + "\n" \ + "#pf_enable=\"YES\"\n" \ + "#pf_rules=\"/etc/mypf.conf\"\n" \ + "#pf_flags=\"-q -z\"\n" \ + "\n"; + +static const char* dhcpcd_conf_text = \ + "\n" \ +"clientid RTEMS test client\n" \ +"\n" \ +"nodhcp6\n" \ +"ipv4only\n" \ +"option ntp_servers\n" \ +"option rtems_cmdline\n"; + +int +epicsRtemsPrepareAndRunRCConfFile(void) +{ + size_t len; + size_t written; + int fd; + int rv; + struct stat sb; + + mkdir("/etc", S_IRWXU | S_IRWXG | S_IRWXO); /* ignore errors, check the dir after. */ + assert(stat("/etc", &sb) == 0); + assert(S_ISDIR(sb.st_mode)); + + printf("--------------- dhcpcd.conf -----------------\n"); + printf(dhcpcd_conf_text); + printf("-----------------------------------------\n"); + + len = strlen(dhcpcd_conf_text); + fd = open("/etc/dhcpcd.conf", O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); + assert(fd != -1); + written = write(fd, dhcpcd_conf_text, len); + assert(written == len); + rv = close(fd); + assert(rv == 0); + + printf("--------------- rc.conf -----------------\n"); + printf(rc_conf_text); + printf("-----------------------------------------\n"); + + len = strlen(rc_conf_text); + fd = open("/etc/rc.conf", O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); + assert(fd != -1); + written = write(fd, rc_conf_text, len); + assert(written == len); + rv = close(fd); + assert(rv == 0); + + return (rtems_bsd_run_etc_rc_conf(20, true)); +} diff --git a/modules/libcom/RTEMS/posix/libbsd_netconfig.h b/modules/libcom/RTEMS/posix/libbsd_netconfig.h new file mode 100644 index 000000000..b253b652d --- /dev/null +++ b/modules/libcom/RTEMS/posix/libbsd_netconfig.h @@ -0,0 +1,24 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Saskatchewan +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * RTEMS network configuration header for EPICS + * + * This file can be copied to an application source dirctory + * and modified to override the values shown below. + */ +#include +#include + +#define NET_CFG_INTERFACE_0 "cgem0" +#define DEFAULT_NETWORK_DHCPCD_ENABLE +#define DEFAULT_NETWORK_NO_INTERFACE_0 + +// Tests +#define NET_CFG_SELF_IP "141.14.128.89" +#define NET_CFG_NETMASK "255.255.240.0" +#define NET_CFG_GATEWAY_IP "141.14.128.128" + +int epicsRtemsPrepareAndRunRCConfFile(void); diff --git a/modules/libcom/RTEMS/posix/rtems_config.c b/modules/libcom/RTEMS/posix/rtems_config.c new file mode 100644 index 000000000..9c8e29ea3 --- /dev/null +++ b/modules/libcom/RTEMS/posix/rtems_config.c @@ -0,0 +1,153 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Saskatchewan +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * RTEMS configuration for EPICS + * Author: W. Eric Norum + * norume@aps.anl.gov + * (630) 252-4793 + */ + +#include + +/* + *********************************************************************** + * RTEMS CONFIGURATION * + *********************************************************************** + */ + +extern void *POSIX_Init(void *argument); + +#define CONFIGURE_POSIX_INIT_THREAD_TABLE +#define CONFIGURE_POSIX_INIT_THREAD_ENTRY_POINT POSIX_Init +#define CONFIGURE_POSIX_INIT_THREAD_STACK_SIZE (64*1024) + +#define CONFIGURE_MAXIMUM_PERIODS 5 +#define CONFIGURE_MICROSECONDS_PER_TICK 10000 +#define CONFIGURE_MALLOC_STATISTICS 1 +/* MINIMUM_STACK_SIZE == 8K */ +#define CONFIGURE_EXTRA_TASK_STACKS (4000 * RTEMS_MINIMUM_STACK_SIZE) + +#define CONFIGURE_FILESYSTEM_DEVFS +#define CONFIGURE_FILESYSTEM_TFTPFS +#define CONFIGURE_FILESYSTEM_NFS +#define CONFIGURE_FILESYSTEM_IMFS +#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM + +/* + * Configure LibBSD. + */ +#define RTEMS_BSD_CONFIG_NET_PF_UNIX +#define RTEMS_BSD_CONFIG_NET_IF_BRIDGE +#define RTEMS_BSD_CONFIG_NET_IF_LAGG +#define RTEMS_BSD_CONFIG_NET_IF_VLAN +#define RTEMS_BSD_CONFIG_BSP_CONFIG +#define RTEMS_BSD_CONFIG_INIT + +#include + +/* + * Configure RTEMS. + */ +#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER +#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK + +#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 150 +#define CONFIGURE_IMFS_ENABLE_MKFIFO 2 + +#define CONFIGURE_MAXIMUM_NFS_MOUNTS 3 +#define CONFIGURE_MAXIMUM_USER_EXTENSIONS 5 + +#define CONFIGURE_UNLIMITED_ALLOCATION_SIZE 32 +#define CONFIGURE_UNLIMITED_OBJECTS +#define CONFIGURE_UNIFIED_WORK_AREAS + +#define CONFIGURE_STACK_CHECKER_ENABLED + +#define CONFIGURE_BDBUF_BUFFER_MAX_SIZE (64 * 1024) +#define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS 4 +#define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE (1 * 1024 * 1024) + +/* we are using POSIX_INIT +#define CONFIGURE_RTEMS_INIT_TASKS_TABLE +#define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024) +#define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES +#define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT +*/ + +//#define RTEMS_PCI_CONFIG_LIB +//#define CONFIGURE_PCI_LIB PCI_LIB_AUTO + +#define CONFIGURE_SHELL_COMMANDS_INIT + +#include + +#include + +#define CONFIGURE_SHELL_USER_COMMANDS \ + &bsp_interrupt_shell_command, \ + &rtems_shell_HOSTNAME_Command, \ + &rtems_shell_PING_Command, \ + &rtems_shell_ROUTE_Command, \ + &rtems_shell_NETSTAT_Command, \ + &rtems_shell_IFCONFIG_Command, \ + &rtems_shell_TCPDUMP_Command, \ + &rtems_shell_PFCTL_Command, \ + &rtems_shell_SYSCTL_Command + +#define CONFIGURE_SHELL_COMMAND_CPUUSE +#define CONFIGURE_SHELL_COMMAND_PERIODUSE +#define CONFIGURE_SHELL_COMMAND_STACKUSE +#define CONFIGURE_SHELL_COMMAND_PROFREPORT + +#define CONFIGURE_SHELL_COMMAND_CP +#define CONFIGURE_SHELL_COMMAND_PWD +#define CONFIGURE_SHELL_COMMAND_LS +#define CONFIGURE_SHELL_COMMAND_LN +#define CONFIGURE_SHELL_COMMAND_LSOF +#define CONFIGURE_SHELL_COMMAND_CHDIR +#define CONFIGURE_SHELL_COMMAND_CD +#define CONFIGURE_SHELL_COMMAND_MKDIR +#define CONFIGURE_SHELL_COMMAND_RMDIR +#define CONFIGURE_SHELL_COMMAND_CAT +#define CONFIGURE_SHELL_COMMAND_MV +#define CONFIGURE_SHELL_COMMAND_RM +#define CONFIGURE_SHELL_COMMAND_MALLOC_INFO +#define CONFIGURE_SHELL_COMMAND_SHUTDOWN + +#include +#define RTEMS_BSD_CONFIG_BSP_CONFIG +#define RTEMS_BSD_CONFIG_SERVICE_TELNETD +#define RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE (16 * 1024) +#define RTEMS_BSD_CONFIG_SERVICE_FTPD +#define RTEMS_BSD_CONFIG_FIREWALL_PF + +#define CONFIGURE_MAXIMUM_DRIVERS 40 + +/* + * This should be made BSP dependent, not CPU dependent but I know of no + * appropriate conditionals to use. + * The new general time support makes including the RTC driver less important. + */ +#if !defined(mpc604) && !defined(__mc68040__) && !defined(__mcf5200__) && \ + !defined(mpc7455) && !defined(__arm__) && !defined(__nios2__) + /* don't have RTC code */ +#define CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER +#endif + +#if defined(LIBBSP_I386_PC386_BSP_H) +#define RTEMS_BSD_CONFIG_DOMAIN_PAGE_MBUFS_SIZE (64 * 1024 * 1024) +#elif defined(LIBBSP_POWERPC_QORIQ_BSP_H) +#define RTEMS_BSD_CONFIG_DOMAIN_PAGE_MBUFS_SIZE (32 * 1024 * 1024) +#endif + +#define CONFIGURE_INIT + +#include + diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c new file mode 100644 index 000000000..fe3e5586f --- /dev/null +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -0,0 +1,1007 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Saskatchewan +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * RTEMS startup task for EPICS + * Author: W. Eric Norum + * eric.norum@usask.ca + * (306) 966-5394 + */ + +/* + * This is the first implementation with posix and rtems5. + * Currently only dhcp is supported with libbsd. The reading of the + * environment variables from e.g. u-boot environment is still missing. + * Extensive tests so far only with qemu. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef RTEMS_LEGACY_STACK +#include +#include +#else // libbsd stack +#include +#include +#include +#include "libbsd_netconfig.h" +#include +#endif + +#include +#include + +#include "epicsVersion.h" +#include "epicsThread.h" +#include "epicsTime.h" +#include "epicsExit.h" +#include "envDefs.h" +#include "errlog.h" +#include "logClient.h" +#include "osiUnistd.h" +#include "iocsh.h" +#include "osdTime.h" +#include "epicsMemFs.h" +#include "epicsEvent.h" + +#include "epicsRtemsInitHooks.h" + +#ifdef RTEMS_LEGACY_STACK +#pragma message "RTEMS uses legacy stack" +#else +#pragma message "RTEMS uses libbsd stack" +// setup own ntp-client to get time +#include "epicsNtp.h" +epicsEventId dhcpDone; +#endif + + +/* these settings are needed by the rtems startup + * may provide by dhcp/bootp + * or environments from the "BIOS" like u-boot, motboot etc. + */ +struct in_addr rtems_bsdnet_bootp_server_address; +char rtemsInit_NTP_server_ip[16]; +char bootp_server_name_init[128] = "1001.1001@141.14.128.9:/Volumes/Epics"; +char *rtems_bsdnet_bootp_server_name = bootp_server_name_init; +char bootp_boot_file_name_init[128] = "/Volumes/Epics/myExample/bin/RTEMS-qoriq_e500/myExample.boot"; +char *rtems_bsdnet_bootp_boot_file_name = bootp_boot_file_name_init; +char bootp_cmdline_init[128] = "/Volumes/Epics/myExample/iocBoot/iocmyExample/st.cmd"; +char *rtems_bsdnet_bootp_cmdline = bootp_cmdline_init; + +/* + * Prototypes for some functions not in header files + */ +//void tzset(void); +int fileno(FILE *); +int main(int argc, char **argv); + +static void +logReset (void) +{ + void rtems_bsp_reset_cause(char *buf, size_t capacity) __attribute__((weak)); + void (*fp)(char *buf, size_t capacity) = rtems_bsp_reset_cause; + + if (fp) { + char buf[80]; + fp(buf, sizeof buf); + errlogPrintf ("Startup after %s.\n", buf); + } + else { + errlogPrintf ("Startup.\n"); + } +} + +/* + *********************************************************************** + * FATAL ERROR REPORTING * + *********************************************************************** + */ +/* + * Delay for a while, then terminate + */ +static void +delayedPanic (const char *msg) +{ + rtems_task_wake_after (rtems_clock_get_ticks_per_second()); + rtems_task_wake_after (rtems_clock_get_ticks_per_second()); + rtems_panic (msg); +} + +/* + * Log error and terminate + */ +void +LogFatal (const char *msg, ...) +{ + va_list ap; + + va_start (ap, msg); + errlogVprintf (msg, ap); + va_end (ap); + delayedPanic (msg); +} + +/* + * Log RTEMS error and terminate + */ +void +LogRtemsFatal (const char *msg, rtems_status_code sc) +{ + errlogPrintf ("%s: %s\n", msg, rtems_status_text (sc)); + delayedPanic (msg); +} + +/* + * Log network error and terminate + */ +void +LogNetFatal (const char *msg, int err) +{ + errlogPrintf ("%s: %d\n", msg, err); + delayedPanic (msg); +} + +void * +mustMalloc(int size, const char *msg) +{ + void *p; + + if ((p = malloc (size)) == NULL) + LogFatal ("Can't allocate space for %s.\n", msg); + return p; +} + +/* + *********************************************************************** + * REMOTE FILE ACCESS * + *********************************************************************** + */ +#ifdef OMIT_NFS_SUPPORT +# include +#endif + +const epicsMemFS *epicsRtemsFSImage __attribute__((weak)); +const epicsMemFS *epicsRtemsFSImage = (void*)&epicsRtemsFSImage; + +/* hook to allow app specific FS setup */ +int +epicsRtemsMountLocalFilesystem(char **argv) __attribute__((weak)); +int +epicsRtemsMountLocalFilesystem(char **argv) +{ + if(epicsRtemsFSImage==(void*)&epicsRtemsFSImage) + return -1; /* no FS image provided. */ + else if(epicsRtemsFSImage==NULL) + return 0; /* no FS image provided, but none is needed. */ + else { + printf("***** Using compiled in file data *****\n"); + if (epicsMemFsLoad(epicsRtemsFSImage) != 0) { + printf("Can't unpack tar filesystem\n"); + return -1; + } else { + argv[1] = "/"; + return 0; + } + } +} + +static int +initialize_local_filesystem(char **argv) +{ + extern char _DownloadLocation[] __attribute__((weak)); + extern char _FlashBase[] __attribute__((weak)); + extern char _FlashSize[] __attribute__((weak)); + + argv[0] = rtems_bsdnet_bootp_boot_file_name; + if (epicsRtemsMountLocalFilesystem(argv)==0) { + return 1; /* FS setup successful */ + } +/* else if (_FlashSize && (_DownloadLocation || _FlashBase)) { + extern char _edata[]; + size_t flashIndex = _edata - _DownloadLocation; + char *header = _FlashBase + flashIndex; + + if (memcmp(header + 257, "ustar ", 8) == 0) { + int fd; + printf ("***** Unpack in-memory file system (IMFS) *****\n"); + if (rtems_tarfs_load("/", (unsigned char *)header, (size_t)_FlashSize - flashIndex) != 0) { + printf("Can't unpack tar filesystem\n"); + return 0; + } + if ((fd = open(rtems_bsdnet_bootp_cmdline, 0)) >= 0) { + close(fd); + printf ("***** Found startup script (%s) in IMFS *****\n", rtems_bsdnet_bootp_cmdline); + argv[1] = rtems_bsdnet_bootp_cmdline; + return 1; + } + printf ("***** Startup script (%s) not in IMFS *****\n", rtems_bsdnet_bootp_cmdline); + } + } */ + return 0; +} + +#ifndef OMIT_NFS_SUPPORT +int +nfsMount(char *uidhost, char *path, char *mntpoint) +{ + int devl = strlen(uidhost) + strlen(path) + 2; + char *dev; + int rval = -1; + + if ((dev = malloc(devl)) == NULL) { + fprintf(stderr,"nfsMount: out of memory\n"); + return -1; + } + sprintf(dev, "%s:%s", uidhost, path); + printf("Mount %s on %s\n", dev, mntpoint); + rval = mount_and_make_target_path ( + dev, mntpoint, RTEMS_FILESYSTEM_TYPE_NFS, + RTEMS_FILESYSTEM_READ_WRITE, NULL ); + if(rval) + perror("mount failed"); + free(dev); + return rval; +} +#define NFS_INIT +#endif + + +static void +initialize_remote_filesystem(char **argv, int hasLocalFilesystem) +{ +#ifdef OMIT_NFS_SUPPORT + printf ("***** Initializing TFTP *****\n"); + mount_and_make_target_path(NULL, + "/TFTP", + RTEMS_FILESYSTEM_TYPE_TFTPFS, + RTEMS_FILESYSTEM_READ_WRITE, + NULL); + if (!hasLocalFilesystem) { + char *path; + int pathsize = 200; + int l; + + path = mustMalloc(pathsize, "Command path name "); + strcpy (path, "/TFTP/BOOTP_HOST/epics/"); + l = strlen (path); + if (gethostname (&path[l], pathsize - l - 10) || (path[l] == '\0')) + { + LogFatal ("Can't get host name"); + } + strcat (path, "/st.cmd"); + argv[1] = path; + } +#else + char *server_name; + char *server_path; + char *mount_point; + char *cp; + int l = 0; + + printf ("***** Initializing NFS *****\n"); + NFS_INIT + if (env_nfsServer && env_nfsPath && env_nfsMountPoint) { + server_name = env_nfsServer; + server_path = env_nfsPath; + mount_point = env_nfsMountPoint; + cp = mount_point; + while ((cp = strchr(cp+1, '/')) != NULL) { + *cp = '\0'; + if ((mkdir (mount_point, 0755) != 0) + && (errno != EEXIST)) + LogFatal("Can't create directory \"%s\": %s.\n", + mount_point, strerror(errno)); + *cp = '/'; + } + argv[1] = rtems_bsdnet_bootp_cmdline; + } + else if (hasLocalFilesystem) { + return; + } + else { + /* + * Use first component of nvram/bootp command line pathname + * to set up initial NFS mount. A "/tftpboot/" is prepended + * if the pathname does not begin with a '/'. This allows + * NFS and TFTP to have a similar view of the remote system. + */ + if (rtems_bsdnet_bootp_cmdline[0] == '/') + cp = rtems_bsdnet_bootp_cmdline + 1; + else + cp = rtems_bsdnet_bootp_cmdline; + cp = strchr(cp, '/'); + if ((cp == NULL) + || ((l = cp - rtems_bsdnet_bootp_cmdline) == 0)) + LogFatal("\"%s\" is not a valid command pathname.\n", rtems_bsdnet_bootp_cmdline); + cp = mustMalloc(l + 20, "NFS mount paths"); + server_path = cp; +printf( " rtems_bootp_server_name: %s\n",rtems_bsdnet_bootp_server_name); + server_name = rtems_bsdnet_bootp_server_name; + if (rtems_bsdnet_bootp_cmdline[0] == '/') { + mount_point = server_path; + strncpy(mount_point, rtems_bsdnet_bootp_cmdline, l); + mount_point[l] = '\0'; + argv[1] = rtems_bsdnet_bootp_cmdline; + /* + * Its probably common to embed the mount point in the server + * name so, when this is occurring, dont clobber the mount point + * by appending the first node from the command path. This allows + * the mount point to be a different path then the server's mount + * path. + * + * This allows for example a line similar to as follows the DHCP + * configuration file. + * + * server-name "159.233@192.168.0.123:/vol/vol0/bootRTEMS"; + */ + if ( server_name ) { + const size_t allocSize = strlen ( server_name ) + 2; + char * const pServerName = mustMalloc( allocSize, + "NFS mount paths"); + char * const pServerPath = mustMalloc ( allocSize, + "NFS mount paths"); + const int scanfStatus = sscanf ( + server_name, + "%[^:] : / %s", + pServerName, + pServerPath + 1u ); + if ( scanfStatus == 2 ) { + pServerPath[0u]= '/'; + server_name = pServerName; + // is this a general solution? + server_path = mount_point = pServerPath; + } + else { + free ( pServerName ); + free ( pServerPath ); + } + } + } + else { + char *abspath = mustMalloc(strlen(rtems_bsdnet_bootp_cmdline)+2,"Absolute command path"); + strcpy(server_path, "/tftpboot/"); + mount_point = server_path + strlen(server_path); + strncpy(mount_point, rtems_bsdnet_bootp_cmdline, l); + mount_point[l] = '\0'; + mount_point--; + strcpy(abspath, "/"); + strcat(abspath, rtems_bsdnet_bootp_cmdline); + argv[1] = abspath; + } + } + errlogPrintf("nfsMount(\"%s\", \"%s\", \"%s\")\n", + server_name, server_path, mount_point); + nfsMount(server_name, server_path, mount_point); +#endif +} + +static +char rtems_etc_hosts[] = "127.0.0.1 localhost\n"; + +/* If it doesn't already exist, create /etc/hosts with an entry for 'localhost' */ +static +void fixup_hosts(void) +{ + FILE *fp; + int ret; + struct stat STAT; + + ret=stat("/etc/hosts", &STAT); + if(ret==0) + { + return; /* already exists, assume file */ + } else if(errno!=ENOENT) { + perror("error: fixup_hosts stat /etc/hosts"); + return; + } + + ret = mkdir("/etc", 0775); + if(ret!=0 && errno!=EEXIST) + { + perror("error: fixup_hosts create /etc"); + return; + } + + if((fp=fopen("/etc/hosts", "w"))==NULL) + { + perror("error: fixup_hosts create /etc/hosts"); + } + + if(fwrite(rtems_etc_hosts, 1, sizeof(rtems_etc_hosts)-1, fp)!=sizeof(rtems_etc_hosts)-1) + { + perror("error: failed to write /etc/hosts"); + } + + fclose(fp); +} + +/* + * Get to the startup script directory + * The TFTP filesystem requires a trailing '/' on chdir arguments. + */ +static void +set_directory (const char *commandline) +{ + const char *cp; + char *directoryPath; + int l; + + cp = strrchr(commandline, '/'); + if (cp == NULL) { + l = 0; + cp = "/"; + } + else { + l = cp - commandline; + cp = commandline; + } + directoryPath = mustMalloc(l + 2, "Command path directory "); + strncpy(directoryPath, cp, l); + directoryPath[l] = '/'; + directoryPath[l+1] = '\0'; + if (chdir (directoryPath) < 0) + LogFatal ("Can't set initial directory(%s): %s\n", directoryPath, strerror(errno)); + else + errlogPrintf("chdir(\"%s\")\n", directoryPath); + free(directoryPath); +} + +/* + *********************************************************************** + * RTEMS/EPICS COMMANDS * + *********************************************************************** + */ + +static const iocshArg rtshellArg0 = { "cmd", iocshArgString}; +static const iocshArg rtshellArg1 = { "args", iocshArgArgv}; +static const iocshArg * rtshellArgs[2] = { &rtshellArg0, &rtshellArg1}; +static const iocshFuncDef rtshellFuncDef = { "rt",2, rtshellArgs}; +static void rtshellCallFunc(const iocshArgBuf *args) +{ + rtems_shell_cmd_t *cmd = rtems_shell_lookup_cmd(args[0].sval); + int ret; + + if (!cmd) { + fprintf(stderr, "ERR: No such command\n"); + + } else { + fflush(stdout); + fflush(stderr); + ret = (*cmd->command)(args[1].aval.ac,args[1].aval.av); + fflush(stdout); + fflush(stderr); + if(ret) + fprintf(stderr, "ERR: %d\n",ret); + } +} + +/* + * RTEMS status + */ +static void +rtems_netstat (unsigned int level) +{ +/* + rtems_bsdnet_show_if_stats (); + rtems_bsdnet_show_mbuf_stats (); + if (level >= 1) { + rtems_bsdnet_show_inet_routes (); + } + if (level >= 2) { + rtems_bsdnet_show_ip_stats (); + rtems_bsdnet_show_icmp_stats (); + rtems_bsdnet_show_udp_stats (); + rtems_bsdnet_show_tcp_stats (); + } +*/ +} + +static const iocshArg netStatArg0 = { "level",iocshArgInt}; +static const iocshArg * const netStatArgs[1] = {&netStatArg0}; +static const iocshFuncDef netStatFuncDef = {"netstat",1,netStatArgs}; +static void netStatCallFunc(const iocshArgBuf *args) +{ + rtems_netstat(args[0].ival); +} + +static const iocshFuncDef heapSpaceFuncDef = {"heapSpace",0,NULL}; +static void heapSpaceCallFunc(const iocshArgBuf *args) +{ + Heap_Information_block info; + double x; + + malloc_info (&info); + x = info.Stats.size - (unsigned long) + (info.Stats.lifetime_allocated - info.Stats.lifetime_freed); + if (x >= 1024*1024) + printf("Heap space: %.1f MB\n", x / (1024 * 1024)); + else + printf("Heap space: %.1f kB\n", x / 1024); +} + +#ifndef OMIT_NFS_SUPPORT +static const iocshArg nfsMountArg0 = { "[uid.gid@]host",iocshArgString}; +static const iocshArg nfsMountArg1 = { "server path",iocshArgString}; +static const iocshArg nfsMountArg2 = { "mount point",iocshArgString}; +static const iocshArg * const nfsMountArgs[3] = {&nfsMountArg0,&nfsMountArg1, + &nfsMountArg2}; +static const iocshFuncDef nfsMountFuncDef = {"nfsMount",3,nfsMountArgs}; +static void nfsMountCallFunc(const iocshArgBuf *args) +{ + char *cp = args[2].sval; + while ((cp = strchr(cp+1, '/')) != NULL) { + *cp = '\0'; + if ((mkdir (args[2].sval, 0755) != 0) && (errno != EEXIST)) { + printf("Can't create directory \"%s\": %s.\n", + args[2].sval, strerror(errno)); + return; + } + *cp = '/'; + } + nfsMount(args[0].sval, args[1].sval, args[2].sval); +} +#endif + + +void zoneset(const char *zone) +{ + if(zone) + setenv("TZ", zone, 1); + else + unsetenv("TZ"); + tzset(); +} + +static const iocshArg zonesetArg0 = {"zone string", iocshArgString}; +static const iocshArg * const zonesetArgs[1] = {&zonesetArg0}; +static const iocshFuncDef zonesetFuncDef = {"zoneset",1,zonesetArgs}; +static void zonesetCallFunc(const iocshArgBuf *args) +{ + zoneset(args[0].sval); +} + + +/* + * Register RTEMS-specific commands + */ +static void iocshRegisterRTEMS (void) +{ + iocshRegister(&netStatFuncDef, netStatCallFunc); + iocshRegister(&heapSpaceFuncDef, heapSpaceCallFunc); +#ifndef OMIT_NFS_SUPPORT + iocshRegister(&nfsMountFuncDef, nfsMountCallFunc); +#endif + iocshRegister(&zonesetFuncDef, &zonesetCallFunc); + iocshRegister(&rtshellFuncDef, &rtshellCallFunc); + rtems_shell_init_environment(); +} + +/* + * Set up the console serial line (no handshaking) + */ +static void +initConsole (void) +{ + struct termios t; + +printf("\n initConsole --- Info ---\n"); +printf("stdin: fileno: %d, ttyname: %s\n", fileno(stdin), ttyname(fileno(stdin))); +printf("stdout: fileno: %d, ttyname: %s\n", fileno(stdout), ttyname(fileno(stdout))); +printf("stderr: fileno: %d, ttyname: %s\n", fileno(stderr), ttyname(fileno(stderr))); + + if (tcgetattr (fileno (stdin), &t) < 0) { + printf ("tcgetattr failed: %s\n", strerror (errno)); + return; + } + t.c_iflag &= ~(IXOFF | IXON | IXANY); + if (tcsetattr (fileno (stdin), TCSANOW, &t) < 0) { + printf ("tcsetattr failed: %s\n", strerror (errno)); + return; + } +} + +/* + * Hook to ensure that BSP cleanup code gets run on exit + */ +static void +exitHandler(void) +{ + rtems_shutdown_executive(0); +} + +static char* getPrimaryNetworkInterface(void) +{ + // lookup available network interfaces + char ifnamebuf[IF_NAMESIZE]; + char *ifname; + // get primary network interface + ifname = if_indextoname(1, &ifnamebuf[0]); + if (ifname == NULL) return (NULL); + printf("\n***** Primary Network interface : %s *****\n", ifname); + return (ifname); +} + +static void +dhcpcd_hook_handler(rtems_dhcpcd_hook *hook, char *const *env) +{ + int bound = 0; + char iName[16]; + char *name; + char *value; + + (void)hook; + + char ifnamebuf[IF_NAMESIZE]; + *ifnamebuf = getPrimaryNetworkInterface(); + + while (*env != NULL) { + name = strtok(*env,"="); + value = strtok(NULL,"="); + printf("all out ---> %s = %s\n", name, value); + if (!strncmp(name, "interface", 9) && !strcmp(value, ifnamebuf)) + strncpy(iName, value, 16); + if (!strncmp(name, "reason", 6) && !strncmp(value, "BOUND", 5)){ + printf ("Interface %s bounded\n", iName); + bound = 1; + } + if (bound) { + // as there is no ntp-support in rtems-libbsd, we call our own client + if(!strncmp(name, "new_ntp_servers", 15)) + strcpy(rtemsInit_NTP_server_ip,value); + if(!strncmp(name, "new_host_name", 13)) + sethostname (value, strlen (value)); + if(!strncmp(name, "new_tftp_server_name", 20)){ + //printf(" new_tftp_server_name : %s\n", value); + strncpy(rtems_bsdnet_bootp_server_name,value, sizeof(bootp_server_name_init)); + printf(" rtems_bsdnet_bootp_server_name : %s\n", rtems_bsdnet_bootp_server_name); + } + if(!strncmp(name, "new_bootfile_name", 20)){ + //printf(" new_bootfile_name : %s\n", value); + strncpy(rtems_bsdnet_bootp_boot_file_name,value, sizeof(bootp_boot_file_name_init)); + printf(" rtems_bsdnet_bootp_boot_file_name : %s\n", rtems_bsdnet_bootp_boot_file_name); + } + if(!strncmp(name, "new_rtems_cmdline", 20)){ + //printf(" new_rtems_cmdline : %s\n", value); + strncpy(rtems_bsdnet_bootp_cmdline,value, sizeof(bootp_cmdline_init)); + printf(" rtems_bsdnet_bootp_cmdline : %s\n", rtems_bsdnet_bootp_cmdline); + } + // printf("---> %s = %s\n", name, value); + } + ++env; + } + if (bound) + epicsEventSignal(dhcpDone); + } + +static rtems_dhcpcd_hook dhcpcd_hook = { + .name = "ioc boot", + .handler = dhcpcd_hook_handler +}; + +static void +default_network_on_exit(int exit_code, void *arg) +{ + rtems_printer printer; + + (void)arg; + + rtems_print_printer_printf(&printer); + rtems_stack_checker_report_usage_with_plugin(&printer); + + if (exit_code == 0) { + puts("*** END OF TEST ***"); + } +} + +static void +default_network_set_self_prio(rtems_task_priority prio) +{ + rtems_status_code sc; + + sc = rtems_task_set_priority(RTEMS_SELF, prio, &prio); + assert(sc == RTEMS_SUCCESSFUL); +} + +static void +default_network_dhcpcd(void) +{ + static const char default_cfg[] = "clientid FHI test client\n"; + rtems_status_code sc; + int fd; + int rv; + ssize_t n; + + fd = open("/etc/dhcpcd.conf", O_CREAT | O_WRONLY, + S_IRWXU | S_IRWXG | S_IRWXO); + assert(fd >= 0); + + n = write(fd, default_cfg, sizeof(default_cfg) - 1); + assert(n == (ssize_t) sizeof(default_cfg) - 1); + + static const char fhi_cfg[] = + "nodhcp6\n" \ + "ipv4only\n" \ + "option ntp_servers\n" \ + "option rtems_cmdline\n" \ + "option tftp_server_name\n" \ + "option bootfile_name"; + + n = write(fd, fhi_cfg, sizeof(fhi_cfg) - 1); + assert(n == (ssize_t) sizeof(fhi_cfg) - 1); + + rv = close(fd); + assert(rv == 0); + + sc = rtems_dhcpcd_start(NULL); + assert(sc == RTEMS_SUCCESSFUL); +} + +/* + * RTEMS Startup task + */ +void * +POSIX_Init (void *argument) +{ + int result; + char *argv[3] = { NULL, NULL, NULL }; + // char *cp; + rtems_status_code sc; + struct timespec now; + char timeBuff[100]; + + initConsole (); + + /* + * Use BSP-supplied time of day if available otherwise supply default time. + * It is very likely that other time synchronization facilities in EPICS + * will soon override this value. + */ + /* check for RTC ... unfortunately seems to be missing with libbsd and qemu ? + if (checkRealtime() >= 0) { + setRealTimeToRTEMS(); + } else + */ + { + // set time to 14.4.2014 + now.tv_sec = 1397460606; + now.tv_nsec = 0; + if (clock_settime(CLOCK_REALTIME, &now) < 0) + printf ("***** Can't set time: %s\n", rtems_status_text (sc)); + } + if ( clock_gettime( CLOCK_REALTIME, &now) < 0) { + printf ("***** Can't get time: %s\n", rtems_status_text (sc)); + } else { + strftime(timeBuff, sizeof timeBuff, "%D %T", gmtime(&now.tv_sec)); + printf("time set to : %s.%09ld UTC\n", timeBuff, now.tv_nsec); + } + + /* + * Explain why we're here + */ + logReset(); + + /* TBD ... + * Architecture-specific hooks + if (epicsRtemsInitPreSetBootConfigFromNVRAM(&rtems_bsdnet_config) != 0) + delayedPanic("epicsRtemsInitPreSetBootConfigFromNVRAM"); + if (rtems_bsdnet_config.bootp == NULL) { + extern void setBootConfigFromNVRAM(void); + setBootConfigFromNVRAM(); + } + if (epicsRtemsInitPostSetBootConfigFromNVRAM(&rtems_bsdnet_config) != 0) + delayedPanic("epicsRtemsInitPostSetBootConfigFromNVRAM"); + + */ + + /* + * Override RTEMS Posix configuration, it gets started with posix prio 2 + */ + epicsThreadSetPriority(epicsThreadGetIdSelf(), epicsThreadPriorityIocsh); + + /* + * Create a reasonable environment + */ + + putenv ("TERM=xterm"); + putenv ("IOCSH_HISTSIZE=20"); + + /* + * Display some OS information + */ + printf("\n***** RTEMS Version: %s *****\n", + rtems_get_version_string()); + + + printf("\n***** Initializing network (dhcp) *****\n"); + rtems_bsd_setlogpriority("debug"); + on_exit(default_network_on_exit, NULL); + /* Let other tasks run to complete background work */ + default_network_set_self_prio(RTEMS_MAXIMUM_PRIORITY - 1U); + + /* supress all output from bsd network initialization + rtems_bsd_vprintf_handler bsd_vprintf_handler_old; + bsd_vprintf_handler_old = rtems_bsd_set_vprintf_handler(rtems_bsd_vprintf_handler_mute); + */ + + sc = rtems_bsd_initialize(); + assert(sc == RTEMS_SUCCESSFUL); + + /* Let the callout timer allocate its resources */ + sc = rtems_task_wake_after(2); + assert(sc == RTEMS_SUCCESSFUL); + + rtems_bsd_ifconfig_lo0(); + + // if MY_BOOTP??? + default_network_dhcpcd(); + + /* this seems to be hard coded in the BSP -> Sebastian Huber ? + printf("\n--Info (hpj)-- bsd task prio IRQS: %d -----\n", rtems_bsd_get_task_priority("IRQS")); + printf("\n--Info (hpj)-- bsd task prio TIME: %d -----\n", rtems_bsd_get_task_priority("TIME")); + */ + + // implement DHCP hook ... and wait for acknowledge + dhcpDone = epicsEventMustCreate(epicsEventEmpty); + rtems_dhcpcd_add_hook(&dhcpcd_hook); + + /* use /etc/rc.conf, /etc/dhclient.conf ... */ + //epicsRtemsPrepareAndRunRCConfFile(); + + // wait for dhcp done ... should be if SYNCDHCP is used + epicsEventWaitStatus stat; + int counter = 10; + do { + printf("\n ---- Wait for DHCP done ...\n"); + stat = epicsEventWaitWithTimeout(dhcpDone, 5.0); + } while ((stat == epicsEventWaitTimeout) && (--counter > 0)); + if (stat == epicsEventOK) + epicsEventDestroy(dhcpDone); + else + printf("\n ---- dhcpDone Event Unknown state %d\n", stat); + + const char* ifconfg_args[] = { + "ifconfig", NULL + }; + const char* netstat_args[] = { + "netstat", "-rn", NULL + }; + + printf("-------------- IFCONFIG -----------------\n"); + rtems_bsd_command_ifconfig(1, (char**) ifconfg_args); + printf("-------------- NETSTAT ------------------\n"); + rtems_bsd_command_netstat(2, (char**) netstat_args); + + /* until now there is no NTP support in libbsd -> Sebastian Huber ... */ + printf("\n***** Until now no NTP support in RTEMS 5 with rtems-libbsd *****\n"); + printf("\n***** Ask ntp server once... *****\n"); + if (epicsNtpGetTime(rtemsInit_NTP_server_ip, &now) < 0) { + printf ("***** Can't get time from ntp ...\n"); + } else { + if (clock_settime(CLOCK_REALTIME, &now) < 0){ + printf ("***** Can't set time: %s\n", rtems_status_text (sc)); + } else { + strftime(timeBuff, sizeof timeBuff, "%D %T", gmtime(&now.tv_sec)); + printf("time from ntp : %s.%09ld UTC\n", timeBuff, now.tv_nsec); + } + } + + printf("\n***** Setting up file system *****\n"); + initialize_remote_filesystem(argv, initialize_local_filesystem(argv)); + fixup_hosts(); + + /* + * More environment: iocsh prompt and hostname + */ + { + char hostname[1024]; + gethostname(hostname, 1023); + char *cp = mustMalloc(strlen(hostname)+3, "iocsh prompt"); + sprintf(cp, "%s> ", hostname); + epicsEnvSet ("IOCSH_PS1", cp); + epicsEnvSet("IOC_NAME", hostname); + } + + if (getenv("") == NULL) { + const char *tzp = envGetConfigParamPtr(&EPICS_TZ); + if (tzp == NULL) { + printf("Warning -- no timezone information available -- times will be displayed as GMT.\n"); + } + + } + tzset(); + printf(" check for time registered , C++ initialization ...\n"); + //osdTimeRegister(); + /*/Volumes/Epics/myExample/bin/RTEMS-xilinx_zynq_a9_qemu + * Run the EPICS startup script + */ + printf ("***** Preparing EPICS application *****\n"); + iocshRegisterRTEMS (); + set_directory (argv[1]); + epicsEnvSet ("IOC_STARTUP_SCRIPT", argv[1]); + atexit(exitHandler); + errlogFlush(); + printf ("***** Starting EPICS application *****\n"); + result = main ((sizeof argv / sizeof argv[0]) - 1, argv); + printf ("***** IOC application terminating *****\n"); + epicsThreadSleep(1.0); + epicsExit(result); + return NULL; +} + +#if defined(QEMU_FIXUPS) +/* Override some hooks (weak symbols) + * if BSP defaults aren't configured for running tests. + */ + + +/* Ensure that stdio goes to serial (so it can be captured) */ +#if defined(__i386__) && !USE_COM1_AS_CONSOLE +#include +#include + +extern int BSPPrintkPort; +void bsp_predriver_hook(void) +{ + Console_Port_Minor = BSP_CONSOLE_PORT_COM1; + BSPPrintkPort = BSP_CONSOLE_PORT_COM1; +} +#endif + +/* reboot immediately when done. */ +#if defined(__i386__) && BSP_PRESS_KEY_FOR_RESET +void bsp_cleanup(void) +{ + void bsp_reset(); + bsp_reset(); +} +#endif + +#endif /* QEMU_FIXUPS */ + +int cexpdebug __attribute__((weak)); + +/* defines in rtems_config.c +#define CONFIGURE_SHELL_COMMANDS_INIT +#define CONFIGURE_SHELL_COMMANDS_ALL +// exclude commands which won't work right with our configuration +#define CONFIGURE_SHELL_NO_COMMAND_EXIT +#define CONFIGURE_SHELL_NO_COMMAND_LOGOFF +// exclude commands which unnecessarily pull in block driver +#define CONFIGURE_SHELL_NO_COMMAND_MSDOSFMT +#define CONFIGURE_SHELL_NO_COMMAND_BLKSYNC +#define CONFIGURE_SHELL_NO_COMMAND_MKRFS +#define CONFIGURE_SHELL_NO_COMMAND_DEBUGRFS +#define CONFIGURE_SHELL_NO_COMMAND_FDISK + +#include +*/ diff --git a/modules/libcom/RTEMS/posix/setBootConfigFromNVRAM.c b/modules/libcom/RTEMS/posix/setBootConfigFromNVRAM.c new file mode 100644 index 000000000..b029b3253 --- /dev/null +++ b/modules/libcom/RTEMS/posix/setBootConfigFromNVRAM.c @@ -0,0 +1,369 @@ +/*************************************************************************\ +* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne +* National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +char *env_nfsServer; +char *env_nfsPath; +char *env_nfsMountPoint; + +/* + * Split argument string of form nfs_server:nfs_export: + * The nfs_export component will be used as: + * - the path to the directory exported from the NFS server + * - the local mount point + * - a prefix of + * For example, the argument string: + * romeo:/export/users:smith/ioc/iocexample/st.cmd + * would: + * - mount /export/users from NFS server romeo on /export/users + * - chdir to /export/users/smith/ioc/iocexample + * - read commands from st.cmd + */ +static void +splitRtemsBsdnetBootpCmdline(void) +{ + char *cp1, *cp2, *cp3; + + if ((cp1 = rtems_bsdnet_bootp_cmdline) == NULL) + return; + if (((cp2 = strchr(cp1, ':')) != NULL) + && (((cp3 = strchr(cp2+1, ' ')) != NULL) + || ((cp3 = strchr(cp2+1, ':')) != NULL))) { + int l1 = cp2 - cp1; + int l2 = cp3 - cp2 - 1; + int l3 = strlen(cp3) - 1; + if (l1 && l2 && l3) { + *cp2++ = '\0'; + *cp3 = '\0'; + env_nfsServer = cp1; + env_nfsMountPoint = env_nfsPath = epicsStrDup(cp2); + *cp3 = '/'; + rtems_bsdnet_bootp_cmdline = cp2; + } + } +} + +/* + * Split NFS mount information of the form nfs_server:host_path:local_path + */ +static void +splitNfsMountPath(char *nfsString) +{ + char *cp2, *cp3; + + if (nfsString == NULL) + return; + if (((cp2 = strchr(nfsString, ':')) != NULL) + && (((cp3 = strchr(cp2+1, ' ')) != NULL) + || ((cp3 = strchr(cp2+1, ':')) != NULL))) { + int l1 = cp2 - nfsString; + int l2 = cp3 - cp2 - 1; + int l3 = strlen(cp3) - 1; + if (l1 && l2 && l3) { + *cp2++ = '\0'; + *cp3++ = '\0'; + env_nfsServer = nfsString; + env_nfsPath = cp2; + env_nfsMountPoint = cp3; + } + } +} + +#if defined(HAVE_MOTLOAD) + +/* + * Motorola MOTLOAD NVRAM Access + */ +static char * +gev(const char *parm, volatile char *nvp) +{ + const char *val; + const char *name; + char *ret; + char c; + + for (;;) { + if (*nvp == '\0') + return NULL; + name = parm; + while ((c = *nvp++) != '\0') { + if ((c == '=') && (*name == '\0')) { + val = (char *)nvp; + while (*nvp++ != '\0') + continue; + ret = malloc(nvp - val); + if (ret == NULL) + return NULL; + strcpy(ret, val); + return ret; + } + if (c != *name++) { + while (*nvp++ != '\0') + continue; + break; + } + } + } +} + +static char * +motScriptParm(const char *mot_script_boot, char parm) +{ + const char *cp; + char *ret; + int l; + + while (*mot_script_boot != '\0') { + if (isspace(*(unsigned char *)mot_script_boot) + && (*(mot_script_boot+1) == '-') + && (*(mot_script_boot+2) == parm)) { + mot_script_boot += 3; + cp = mot_script_boot; + while ((*mot_script_boot != '\0') && + !isspace(*(unsigned char *)mot_script_boot)) + mot_script_boot++; + l = mot_script_boot - cp; + ret = malloc(l+1); + if (ret == NULL) + return NULL; + strncpy(ret, cp, l); + *(ret+l) = '\0'; + return ret; + } + mot_script_boot++; + } + return NULL; +} + +void +setBootConfigFromNVRAM(void) +{ + char *cp; + const char *mot_script_boot; + char *nvp; + +# if defined(BSP_NVRAM_BASE_ADDR) + nvp = (volatile unsigned char *)(BSP_NVRAM_BASE_ADDR+0x70f8); +# elif defined(BSP_I2C_VPD_EEPROM_DEV_NAME) + char gev_buf[3592]; + int fd; + if ((fd = open(BSP_I2C_VPD_EEPROM_DEV_NAME, 0)) < 0) { + printf("Can't open %s: %s\n", BSP_I2C_VPD_EEPROM_DEV_NAME, strerror(errno)); + return; + } + lseek(fd, 0x10f8, SEEK_SET); + if (read(fd, gev_buf, sizeof gev_buf) != sizeof gev_buf) { + printf("Can't read %s: %s\n", BSP_I2C_VPD_EEPROM_DEV_NAME, strerror(errno)); + return; + } + close(fd); + nvp = gev_buf; +# else +# error "No way to read GEV!" +# endif + + if (rtems_bsdnet_config.bootp != NULL) + return; + mot_script_boot = gev("mot-script-boot", nvp); + if ((rtems_bsdnet_bootp_server_name = gev("mot-/dev/enet0-sipa", nvp)) == NULL) + rtems_bsdnet_bootp_server_name = motScriptParm(mot_script_boot, 's'); + if ((rtems_bsdnet_config.gateway = gev("mot-/dev/enet0-gipa", nvp)) == NULL) + rtems_bsdnet_config.gateway = motScriptParm(mot_script_boot, 'g'); + if ((rtems_bsdnet_config.ifconfig->ip_netmask = gev("mot-/dev/enet0-snma", nvp)) == NULL) + rtems_bsdnet_config.ifconfig->ip_netmask = motScriptParm(mot_script_boot, 'm'); + + rtems_bsdnet_config.name_server[0] = gev("rtems-dns-server", nvp); + if (rtems_bsdnet_config.name_server[0] == NULL) + rtems_bsdnet_config.name_server[0] = rtems_bsdnet_bootp_server_name; + cp = gev("rtems-dns-domainname", nvp); + if (cp) + rtems_bsdnet_config.domainname = cp; + + if ((rtems_bsdnet_config.ifconfig->ip_address = gev("mot-/dev/enet0-cipa", nvp)) == NULL) + rtems_bsdnet_config.ifconfig->ip_address = motScriptParm(mot_script_boot, 'c'); + rtems_bsdnet_config.hostname = gev("rtems-client-name", nvp); + if (rtems_bsdnet_config.hostname == NULL) + rtems_bsdnet_config.hostname = rtems_bsdnet_config.ifconfig->ip_address; + + if ((rtems_bsdnet_bootp_boot_file_name = gev("mot-/dev/enet0-file", nvp)) == NULL) + rtems_bsdnet_bootp_boot_file_name = motScriptParm(mot_script_boot, 'f'); + rtems_bsdnet_bootp_cmdline = gev("epics-script", nvp); + splitRtemsBsdnetBootpCmdline(); + splitNfsMountPath(gev("epics-nfsmount", nvp)); + rtems_bsdnet_config.ntp_server[0] = gev("epics-ntpserver", nvp); + if (rtems_bsdnet_config.ntp_server[0] == NULL) + rtems_bsdnet_config.ntp_server[0] = rtems_bsdnet_bootp_server_name; + if ((cp = gev("epics-tz", nvp)) != NULL) + epicsEnvSet("TZ", cp); +} + +#elif defined(HAVE_PPCBUG) +/* + * Motorola PPCBUG NVRAM Access + */ +struct ppcbug_nvram { + uint32_t PacketVersionIdentifier; + uint32_t NodeControlMemoryAddress; + uint32_t BootFileLoadAddress; + uint32_t BootFileExecutionAddress; + uint32_t BootFileExecutionDelay; + uint32_t BootFileLength; + uint32_t BootFileByteOffset; + uint32_t TraceBufferAddress; + uint32_t ClientIPAddress; + uint32_t ServerIPAddress; + uint32_t SubnetIPAddressMask; + uint32_t BroadcastIPAddressMask; + uint32_t GatewayIPAddress; + uint8_t BootpRarpRetry; + uint8_t TftpRarpRetry; + uint8_t BootpRarpControl; + uint8_t UpdateControl; + char BootFilenameString[64]; + char ArgumentFilenameString[64]; +}; + +static char *addr(char *cbuf, uint32_t addr) +{ + struct in_addr a; + if ((a.s_addr = addr) == 0) + return NULL; + return (char *)inet_ntop(AF_INET, &a, cbuf, INET_ADDRSTRLEN); +} + +void +setBootConfigFromNVRAM(void) +{ + static struct ppcbug_nvram nvram; + static char ip_address[INET_ADDRSTRLEN]; + static char ip_netmask[INET_ADDRSTRLEN]; + static char server[INET_ADDRSTRLEN]; + static char gateway[INET_ADDRSTRLEN]; + + if (rtems_bsdnet_config.bootp != NULL) + return; + + /* + * Get network configuation from PPCBUG. + * The 'correct' way to do this would be to issue a .NETCFIG PPCBUG + * system call. Unfortunately it is very difficult to issue such a + * call once RTEMS is up and running so we just copy from the 'known' + * location of the network configuration parameters. + * Care must be taken to access the NVRAM a byte at a time. + */ + +#if defined(NVRAM_INDIRECT) + { + volatile char *addrLo = (volatile char *)0x80000074; + volatile char *addrHi = (volatile char *)0x80000075; + volatile char *data = (volatile char *)0x80000077; + int addr = 0x1000; + char *d = (char *)&nvram; + + while (d < ((char *)&nvram + sizeof nvram)) { + *addrLo = addr & 0xFF; + *addrHi = (addr >> 8) & 0xFF; + *d++ = *data; + addr++; + } + } +#else + { + volatile char *s = (volatile char *)0xFFE81000; + char *d = (char *)&nvram; + + while (d < ((char *)&nvram + sizeof nvram)) + *d++ = *s++; + } +#endif + /* + * Assume that the boot server is also the name, log and ntp server! + */ + rtems_bsdnet_config.name_server[0] = + rtems_bsdnet_config.ntp_server[0] = + rtems_bsdnet_bootp_server_name = addr(server, nvram.ServerIPAddress); + rtems_bsdnet_bootp_server_address.s_addr = nvram.ServerIPAddress; + /* + * Nothing better to use as host name! + */ + rtems_bsdnet_config.ifconfig->ip_address = + rtems_bsdnet_config.hostname = addr(ip_address, nvram.ClientIPAddress); + + rtems_bsdnet_config.gateway = addr(gateway, nvram.GatewayIPAddress); + rtems_bsdnet_config.ifconfig->ip_netmask = addr(ip_netmask, nvram.SubnetIPAddressMask); + + rtems_bsdnet_bootp_boot_file_name = nvram.BootFilenameString; + rtems_bsdnet_bootp_cmdline = nvram.ArgumentFilenameString; + splitRtemsBsdnetBootpCmdline(); +} + +#elif defined(__mcf528x__) + +static char * +env(const char *parm, const char *defaultValue) +{ + const char *cp = bsp_getbenv(parm); + + if (!cp) { + if (!defaultValue) + return NULL; + cp = defaultValue; + printf ("%s environment variable missing -- using %s.\n", parm, cp); + } + return epicsStrDup(cp); +} + +void +setBootConfigFromNVRAM(void) +{ + const char *cp1; + + if (rtems_bsdnet_config.bootp != NULL) + return; + rtems_bsdnet_config.gateway = env("GATEWAY", NULL); + rtems_bsdnet_config.ifconfig->ip_netmask = env("NETMASK", "255.255.252.0"); + + rtems_bsdnet_bootp_server_name = env("SERVER", "192.168.0.1"); + rtems_bsdnet_config.name_server[0] = env("NAMESERVER", rtems_bsdnet_bootp_server_name); + rtems_bsdnet_config.ntp_server[0] = env("NTPSERVER", rtems_bsdnet_bootp_server_name); + cp1 = env("DOMAIN", NULL); + if (cp1 != NULL) + rtems_bsdnet_config.domainname = cp1; + rtems_bsdnet_config.hostname = env("HOSTNAME", "iocNobody"); + rtems_bsdnet_config.ifconfig->ip_address = env("IPADDR0", "192.168.0.2"); + rtems_bsdnet_bootp_boot_file_name = env("BOOTFILE", "uC5282App.boot"); + rtems_bsdnet_bootp_cmdline = env("CMDLINE", "epics/iocBoot/iocNobody/st.cmd"); + splitNfsMountPath(env("NFSMOUNT", NULL)); + if ((cp1 = env("TZ", NULL)) != NULL) + epicsEnvSet("TZ", cp1); +} + +#else +/* + * Placeholder for systems without NVRAM + */ +void +setBootConfigFromNVRAM(void) +{ + printf("SYSTEM HAS NO NON-VOLATILE RAM!\n"); + printf("YOU MUST USE SOME OTHER METHOD TO OBTAIN NETWORK CONFIGURATION\n"); +} +#endif diff --git a/modules/libcom/src/osi/os/RTEMS/devLibVMEOSD.c b/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/devLibVMEOSD.c rename to modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c diff --git a/modules/libcom/src/osi/os/RTEMS/epicsAtomicOSD.cpp b/modules/libcom/src/osi/os/RTEMS-kernel/epicsAtomicOSD.cpp similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/epicsAtomicOSD.cpp rename to modules/libcom/src/osi/os/RTEMS-kernel/epicsAtomicOSD.cpp diff --git a/modules/libcom/src/osi/os/RTEMS/epicsAtomicOSD.h b/modules/libcom/src/osi/os/RTEMS-kernel/epicsAtomicOSD.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/epicsAtomicOSD.h rename to modules/libcom/src/osi/os/RTEMS-kernel/epicsAtomicOSD.h diff --git a/modules/libcom/src/osi/os/RTEMS/epicsMath.h b/modules/libcom/src/osi/os/RTEMS-kernel/epicsMath.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/epicsMath.h rename to modules/libcom/src/osi/os/RTEMS-kernel/epicsMath.h diff --git a/modules/libcom/src/osi/os/RTEMS/osdEnv.c b/modules/libcom/src/osi/os/RTEMS-kernel/osdEnv.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdEnv.c rename to modules/libcom/src/osi/os/RTEMS-kernel/osdEnv.c diff --git a/modules/libcom/src/osi/os/RTEMS/osdEvent.c b/modules/libcom/src/osi/os/RTEMS-kernel/osdEvent.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdEvent.c rename to modules/libcom/src/osi/os/RTEMS-kernel/osdEvent.c diff --git a/modules/libcom/src/osi/os/RTEMS/osdEvent.h b/modules/libcom/src/osi/os/RTEMS-kernel/osdEvent.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdEvent.h rename to modules/libcom/src/osi/os/RTEMS-kernel/osdEvent.h diff --git a/modules/libcom/src/osi/os/RTEMS/osdFindSymbol.c b/modules/libcom/src/osi/os/RTEMS-kernel/osdFindSymbol.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdFindSymbol.c rename to modules/libcom/src/osi/os/RTEMS-kernel/osdFindSymbol.c diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c b/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c new file mode 100644 index 000000000..c7a05fcc5 --- /dev/null +++ b/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c @@ -0,0 +1,251 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * Author W. Eric Norum + * norume@aps.anl.gov + * 630 252 4793 + */ + +/* + * We want to access information which is + * normally hidden from application programs. + */ +#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1 + +#define epicsExportSharedSymbols +#include +#include +#include +#include +#include +#include +#include "epicsMessageQueue.h" +#include "errlog.h" + +LIBCOM_API epicsMessageQueueId epicsStdCall +epicsMessageQueueCreate(unsigned int capacity, unsigned int maximumMessageSize) +{ + rtems_status_code sc; + epicsMessageQueueId id = calloc(1, sizeof(*id)); + rtems_interrupt_level level; + static char c1 = 'a'; + static char c2 = 'a'; + static char c3 = 'a'; + + if(!id) + return NULL; + + sc = rtems_message_queue_create (rtems_build_name ('Q', c3, c2, c1), + capacity, + maximumMessageSize, + RTEMS_FIFO|RTEMS_LOCAL, + &id->id); + if (sc != RTEMS_SUCCESSFUL) { + free(id); + errlogPrintf ("Can't create message queue: %s\n", rtems_status_text (sc)); + return NULL; + } + id->maxSize = maximumMessageSize; + id->localBuf = NULL; + rtems_interrupt_disable (level); + if (c1 == 'z') { + if (c2 == 'z') { + if (c3 == 'z') { + c3 = 'a'; + } + else { + c3++; + } + c2 = 'a'; + } + else { + c2++; + } + c1 = 'a'; + } + else { + c1++; + } + rtems_interrupt_enable (level); + return id; +} + +static rtems_status_code rtems_message_queue_send_timeout( + rtems_id id, + void *buffer, + uint32_t size, + rtems_interval timeout) +{ + Message_queue_Control *the_message_queue; + Objects_Locations location; + CORE_message_queue_Status msg_status; + + the_message_queue = _Message_queue_Get( id, &location ); + switch ( location ) + { + case OBJECTS_ERROR: + return RTEMS_INVALID_ID; + + case OBJECTS_LOCAL: + msg_status = _CORE_message_queue_Send( + &the_message_queue->message_queue, + buffer, + size, + id, + NULL, + 1, + timeout + ); + + _Thread_Enable_dispatch(); + + /* + * If we had to block, then this is where the task returns + * after it wakes up. The returned status is correct for + * non-blocking operations but if we blocked, then we need + * to look at the status in our TCB. + */ + + if ( msg_status == CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT ) + msg_status = _Thread_Executing->Wait.return_code; + return _Message_queue_Translate_core_message_queue_return_code( msg_status ); + } + return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ +} + +LIBCOM_API int epicsStdCall epicsMessageQueueSend( + epicsMessageQueueId id, + void *message, + unsigned int messageSize) +{ + if (rtems_message_queue_send_timeout(id->id, message, messageSize, RTEMS_NO_TIMEOUT) == RTEMS_SUCCESSFUL) + return 0; + else + return -1; +} + +LIBCOM_API int epicsStdCall epicsMessageQueueSendWithTimeout( + epicsMessageQueueId id, + void *message, + unsigned int messageSize, + double timeout) +{ + rtems_interval delay; + extern double rtemsTicksPerSecond_double; + + /* + * Convert time to ticks + */ + if (timeout <= 0.0) + return epicsMessageQueueTrySend(id, message, messageSize); + delay = (int)(timeout * rtemsTicksPerSecond_double); + if (delay == 0) + delay++; + if (rtems_message_queue_send_timeout(id->id, message, messageSize, delay) == RTEMS_SUCCESSFUL) + return 0; + else + return -1; +} + +static int receiveMessage( + epicsMessageQueueId id, + void *buffer, + uint32_t size, + uint32_t wait, + rtems_interval delay) +{ + size_t rsize; + rtems_status_code sc; + + if (size < id->maxSize) { + if (id->localBuf == NULL) { + id->localBuf = malloc(id->maxSize); + if (id->localBuf == NULL) + return -1; + } + rsize = receiveMessage(id, id->localBuf, id->maxSize, wait, delay); + if (rsize > size) + return -1; + memcpy(buffer, id->localBuf, rsize); + } + else { + sc = rtems_message_queue_receive(id->id, buffer, &rsize, wait, delay); + if (sc != RTEMS_SUCCESSFUL) + return -1; + } + return rsize; +} + +LIBCOM_API int epicsStdCall epicsMessageQueueTryReceive( + epicsMessageQueueId id, + void *message, + unsigned int size) +{ + return receiveMessage(id, message, size, RTEMS_NO_WAIT, 0); +} + +LIBCOM_API int epicsStdCall epicsMessageQueueReceive( + epicsMessageQueueId id, + void *message, + unsigned int size) +{ + return receiveMessage(id, message, size, RTEMS_WAIT, RTEMS_NO_TIMEOUT); +} + +LIBCOM_API int epicsStdCall epicsMessageQueueReceiveWithTimeout( + epicsMessageQueueId id, + void *message, + unsigned int size, + double timeout) +{ + rtems_interval delay; + uint32_t wait; + extern double rtemsTicksPerSecond_double; + + /* + * Convert time to ticks + */ + if (timeout <= 0.0) { + wait = RTEMS_NO_WAIT; + delay = 0; + } + else { + wait = RTEMS_WAIT; + delay = (int)(timeout * rtemsTicksPerSecond_double); + if (delay == 0) + delay++; + } + return receiveMessage(id, message, size, wait, delay); +} + +LIBCOM_API int epicsStdCall epicsMessageQueuePending( + epicsMessageQueueId id) +{ + uint32_t count; + rtems_status_code sc; + + sc = rtems_message_queue_get_number_pending(id->id, &count); + if (sc != RTEMS_SUCCESSFUL) { + errlogPrintf("Message queue %x get number pending failed: %s\n", + (unsigned int)id, + rtems_status_text(sc)); + return -1; + } + return count; +} + +LIBCOM_API void epicsStdCall epicsMessageQueueShow( + epicsMessageQueueId id, + int level) +{ + int pending = epicsMessageQueuePending(id); + if (pending >= 0) + printf ("Message queue %lx -- Pending: %d\n", (unsigned long)id, pending); +} diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h b/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h new file mode 100644 index 000000000..0244a1f0b --- /dev/null +++ b/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h @@ -0,0 +1,29 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * Author W. Eric Norum + * norume@aps.anl.gov + * 630 252 4793 + */ + +/* + * Very thin shims around RTEMS routines + */ +#include + +struct epicsMessageQueueOSD { + rtems_id id; + unsigned int maxSize; + void *localBuf; + +}; +#define epicsMessageQueueDestroy(q) (rtems_message_queue_delete((q)->id)) + +#define epicsMessageQueueTrySend(q,m,l) (rtems_message_queue_send((q)->id, (m), (l)) == RTEMS_SUCCESSFUL ? 0 : -1) diff --git a/modules/libcom/src/osi/os/RTEMS/osdMutex.c b/modules/libcom/src/osi/os/RTEMS-kernel/osdMutex.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdMutex.c rename to modules/libcom/src/osi/os/RTEMS-kernel/osdMutex.c diff --git a/modules/libcom/src/osi/os/RTEMS/osdMutex.h b/modules/libcom/src/osi/os/RTEMS-kernel/osdMutex.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdMutex.h rename to modules/libcom/src/osi/os/RTEMS-kernel/osdMutex.h diff --git a/modules/libcom/src/osi/os/RTEMS/osdPoolStatus.c b/modules/libcom/src/osi/os/RTEMS-kernel/osdPoolStatus.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdPoolStatus.c rename to modules/libcom/src/osi/os/RTEMS-kernel/osdPoolStatus.c diff --git a/modules/libcom/src/osi/os/RTEMS/osdProcess.c b/modules/libcom/src/osi/os/RTEMS-kernel/osdProcess.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdProcess.c rename to modules/libcom/src/osi/os/RTEMS-kernel/osdProcess.c diff --git a/modules/libcom/src/osi/os/RTEMS/osdReadline.c b/modules/libcom/src/osi/os/RTEMS-kernel/osdReadline.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdReadline.c rename to modules/libcom/src/osi/os/RTEMS-kernel/osdReadline.c diff --git a/modules/libcom/src/osi/os/RTEMS/osdSignal.cpp b/modules/libcom/src/osi/os/RTEMS-kernel/osdSignal.cpp similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdSignal.cpp rename to modules/libcom/src/osi/os/RTEMS-kernel/osdSignal.cpp diff --git a/modules/libcom/src/osi/os/RTEMS/osdSock.h b/modules/libcom/src/osi/os/RTEMS-kernel/osdSock.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdSock.h rename to modules/libcom/src/osi/os/RTEMS-kernel/osdSock.h diff --git a/modules/libcom/src/osi/os/RTEMS/osdSpin.c b/modules/libcom/src/osi/os/RTEMS-kernel/osdSpin.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdSpin.c rename to modules/libcom/src/osi/os/RTEMS-kernel/osdSpin.c diff --git a/modules/libcom/src/osi/os/RTEMS/osdStrtod.h b/modules/libcom/src/osi/os/RTEMS-kernel/osdStrtod.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdStrtod.h rename to modules/libcom/src/osi/os/RTEMS-kernel/osdStrtod.h diff --git a/modules/libcom/src/osi/os/RTEMS/osdThread.c b/modules/libcom/src/osi/os/RTEMS-kernel/osdThread.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdThread.c rename to modules/libcom/src/osi/os/RTEMS-kernel/osdThread.c diff --git a/modules/libcom/src/osi/os/RTEMS/osdThread.h b/modules/libcom/src/osi/os/RTEMS-kernel/osdThread.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdThread.h rename to modules/libcom/src/osi/os/RTEMS-kernel/osdThread.h diff --git a/modules/libcom/src/osi/os/RTEMS/osdThreadExtra.c b/modules/libcom/src/osi/os/RTEMS-kernel/osdThreadExtra.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdThreadExtra.c rename to modules/libcom/src/osi/os/RTEMS-kernel/osdThreadExtra.c diff --git a/modules/libcom/src/osi/os/RTEMS/osdTime.cpp b/modules/libcom/src/osi/os/RTEMS-kernel/osdTime.cpp similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdTime.cpp rename to modules/libcom/src/osi/os/RTEMS-kernel/osdTime.cpp diff --git a/modules/libcom/src/osi/os/RTEMS/osdTime.h b/modules/libcom/src/osi/os/RTEMS-kernel/osdTime.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osdTime.h rename to modules/libcom/src/osi/os/RTEMS-kernel/osdTime.h diff --git a/modules/libcom/src/osi/os/RTEMS/osiUnistd.h b/modules/libcom/src/osi/os/RTEMS-kernel/osiUnistd.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS/osiUnistd.h rename to modules/libcom/src/osi/os/RTEMS-kernel/osiUnistd.h diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c b/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c new file mode 100644 index 000000000..3774ef2d8 --- /dev/null +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c @@ -0,0 +1,160 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * Author W. Eric Norum + * norume@aps.anl.gov + * 630 252 4793 + */ + +/* + * We want to access information which is + * normally hidden from application programs. + */ +#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1 + +#define epicsExportSharedSymbols +#include +#include +#include +#include +#include +#include +#include "epicsMessageQueue.h" +#include "errlog.h" +#include + +#include +#include +#include + +LIBCOM_API epicsMessageQueueId epicsStdCall +epicsMessageQueueCreate(unsigned int capacity, unsigned int maximumMessageSize) +{ + struct mq_attr the_attr; + epicsMessageQueueId id = (epicsMessageQueueId)calloc(1, sizeof(*id)); + + epicsAtomicIncrIntT(&id->idCnt); + sprintf(id->name, "MQ_%01d", epicsAtomicGetIntT(&id->idCnt)); + the_attr.mq_maxmsg = capacity; + the_attr.mq_msgsize = maximumMessageSize; + id->id = mq_open(id->name, O_RDWR | O_CREAT | O_EXCL, 0644, &the_attr); + if (id->id <0) { + fprintf (stderr, "Can't create message queue: %s\n", strerror (errno)); + return NULL; + } + return id; +} + +LIBCOM_API void epicsStdCall epicsMessageQueueDestroy( + epicsMessageQueueId id) +{ + int rv; + rv = mq_close(id->id); + if( rv ) { + fprintf(stderr, "epicsMessageQueueDestroy mq_close failed: %s\n", + strerror(rv)); + } + rv = mq_unlink(id->name); + if( rv ) { + fprintf(stderr,"epicsMessageQueueDestroy mq_unlink %s failed: %s\n", + id->name, strerror(rv)); + } + free(id); +} + + +LIBCOM_API int epicsStdCall epicsMessageQueueTrySend( + epicsMessageQueueId id, + void *message, + unsigned int messageSize) +{ + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + return mq_timedsend(id->id, (char const *)message, messageSize, 0, &ts); +} + +LIBCOM_API int epicsStdCall epicsMessageQueueSendWithTimeout( + epicsMessageQueueId id, + void *message, + unsigned int messageSize, + double timeout) +{ + struct timespec ts; + unsigned long micros; + + // assume timeout in sec + micros = (unsigned long)(timeout * 1000000.0); + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += micros / 1000000L; + ts.tv_nsec += (micros % 1000000L) * 1000L; + + return mq_timedsend (id->id, (const char *)message, messageSize, 0, &ts); +} + +LIBCOM_API int epicsStdCall epicsMessageQueueTryReceive( + epicsMessageQueueId id, + void *message, + unsigned int size) +{ + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + return mq_timedreceive(id->id, (char *)message, size, NULL, &ts); +} + +LIBCOM_API int epicsStdCall epicsMessageQueueReceiveWithTimeout( + epicsMessageQueueId id, + void *message, + unsigned int size, + double timeout) +{ + unsigned long micros; + struct timespec ts; + + micros = (unsigned long)(timeout * 1000000.0); + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += micros / 1000000L; + ts.tv_nsec += (micros % 1000000L) * 1000L; + + return mq_timedreceive(id->id, (char *)message, size, NULL, &ts); +} + +LIBCOM_API int epicsStdCall epicsMessageQueuePending( + epicsMessageQueueId id) +{ + int rv; + struct mq_attr the_attr; + + rv = mq_getattr(id->id, &the_attr); + if (rv) { + fprintf(stderr, "Epics Message queue %x (%s) get attr failed: %s\n", + (unsigned int)id->id, id->name, strerror(rv)); + return -1; + } + return the_attr.mq_curmsgs; +} +LIBCOM_API void epicsStdCall epicsMessageQueueShow( + epicsMessageQueueId id, + int level) +{ + int rv; + struct mq_attr the_attr; + + rv = mq_getattr(id->id, &the_attr); + if (rv) { + fprintf(stderr, "Epics Message queue %x (%s) get attr failed: %s\n", + (unsigned int)id->id, id->name, strerror(rv)); + } + + printf("Message Queue Used:%ld Max Msg:%lu", the_attr.mq_curmsgs, the_attr.mq_maxmsg); + if (level >= 1) + printf(" Maximum size:%lu", the_attr.mq_msgsize); + + printf("\n"); +} diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h b/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h new file mode 100644 index 000000000..0311ee486 --- /dev/null +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h @@ -0,0 +1,29 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * Author W. Eric Norum + * norume@aps.anl.gov + * 630 252 4793 + */ + +/* + * Very thin shims around RTEMS routines + */ +#include +#include + +struct epicsMessageQueueOSD { + mqd_t id; + char name[24]; + int idCnt; + +}; +#define epicsMessageQueueSend(q,m,l) (mq_send((q)->id, (const char*)(m), (l), 0)) +#define epicsMessageQueueReceive(q,m,s) (mq_receive((q)->id, (char*)(m), (s), NULL)) \ No newline at end of file diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdMutex.c b/modules/libcom/src/osi/os/RTEMS-posix/osdMutex.c new file mode 100644 index 000000000..09b02e0a2 --- /dev/null +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdMutex.c @@ -0,0 +1,6 @@ +#include +#include +#include +#include + +#include "../posix/osdMutex.c" \ No newline at end of file diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdPoolStatus.c b/modules/libcom/src/osi/os/RTEMS-posix/osdPoolStatus.c new file mode 100644 index 000000000..43d2e2b28 --- /dev/null +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdPoolStatus.c @@ -0,0 +1,27 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +#include +#include +#include +#define epicsExportSharedSymbols +#include "osiPoolStatus.h" + +/* + * osiSufficentSpaceInPool () + */ +LIBCOM_API int epicsStdCall osiSufficentSpaceInPool ( size_t contiguousBlockSize ) +{ + unsigned long n; + Heap_Information_block info; + + malloc_info( &info ); + n = info.Stats.size - (unsigned long)(info.Stats.lifetime_allocated - info.Stats.lifetime_freed); + return (n > (50000 + contiguousBlockSize)); +} diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h b/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h new file mode 100644 index 000000000..e5568fc1b --- /dev/null +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h @@ -0,0 +1,81 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * Linux specific socket include + */ + +#ifndef osdSockH +#define osdSockH + +#include + +#include +#include /* for MAXHOSTNAMELEN */ +#include +#include +#include +#include +#include +#include +#include +#include +#include /* close() and others */ + + +typedef int SOCKET; +#define INVALID_SOCKET (-1) +#define SOCKERRNO errno +#define socket_ioctl(A,B,C) ioctl(A,B,C) +typedef int osiSockIoctl_t; +typedef socklen_t osiSocklen_t; +typedef int osiSockOptMcastLoop_t; +typedef int osiSockOptMcastTTL_t; + +#define FD_IN_FDSET(FD) ((FD)ifr_name)) + +#ifndef IPPORT_USERRESERVED +#define IPPORT_USERRESERVED 5000 +#endif + +#endif /*osdSockH*/ From e2e606d53f5502ed1f6b7a61fdf9eb73302da139 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 9 Sep 2020 20:47:56 -0700 Subject: [PATCH 003/195] RTEMS: auto-detect OS_API --- configure/os/CONFIG.Common.RTEMS | 18 ++---------------- configure/os/CONFIG.Common.RTEMS-pc386 | 1 + modules/libcom/RTEMS/Makefile | 2 +- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 86a037295..4b1701892 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -94,29 +94,15 @@ MODEXT=.obj # operating system class (include/os/) OS_CLASS = RTEMS -#-------------------------------------------------- -#print warning -ifeq ($(RTEMS_HAS_POSIX_API),no) -ifeq ($(EPICS_VERSION),7) - $(error Warning: Epics Version $(EPICS_VERSION) must not be used without POSIX enabled on RTEMS !!!) -endif -endif -# operating system API (src/os/-) -ifeq ($(RTEMS_HAS_POSIX_API),yes) -OS_API = posix -else -OS_API = kernel -endif - #-------------------------------------------------- # Operating system flags #OP_SYS_LDLIBS += -lrtemsCom -lc -lrtemscpu -lCom -lnfs -lm -ifeq ($(RTEMS_API),5) +ifeq ($(OS_API),posix) OP_SYS_CFLAGS += -D__LINUX_ERRNO_EXTENSIONS__ #OP_SYS_LDLIBS += -lrtemsCom -lrtemscpu -lrtemsbsp -ltftpfs -ltelnetd -lbsd -lz -lm OP_SYS_LDLIBS += -lrtemsCom -lc -lrtemscpu -ltftpfs -lbsd -lz -lm else -OP_SYS_LDLIBS += -lrtemsCom -lrtemscpu -lrtemsbsp +OP_SYS_LDLIBS += -lrtemsCom -lc -lrtemscpu -lCom -lnfs -lm endif ifeq ($(RTEMS_HAS_NETWORKING),yes) diff --git a/configure/os/CONFIG.Common.RTEMS-pc386 b/configure/os/CONFIG.Common.RTEMS-pc386 index 8dfa7d2ba..bb4f3e7c7 100644 --- a/configure/os/CONFIG.Common.RTEMS-pc386 +++ b/configure/os/CONFIG.Common.RTEMS-pc386 @@ -7,6 +7,7 @@ # RTEMS_BSP = pc386 RTEMS_TARGET_CPU = i386 +GNU_TARGET = i386-rtems MUNCH_SUFFIX = .boot define MUNCH_CMD diff --git a/modules/libcom/RTEMS/Makefile b/modules/libcom/RTEMS/Makefile index 5865ff8e8..87bf43db3 100644 --- a/modules/libcom/RTEMS/Makefile +++ b/modules/libcom/RTEMS/Makefile @@ -37,7 +37,7 @@ rtemsCom_SRCS += epicsRtemsInitHookPost.c rtemsCom_SRCS += epicsMemFs.c rtemsCom_SRCS += epicsNtp.c -ifeq ($(RTEMS_BSP),pc386) +ifeq ($(RTEMS_TARGET_CPU),i386) rtemsCom_SRCS += ne2kpci.c endif From 8366770d72e88ccc8fbe81103f424bdfec4386d9 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 9 Sep 2020 15:40:35 -0700 Subject: [PATCH 004/195] ci: RTEMS update --- .ci | 2 +- .github/workflows/ci-scripts-build.yml | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.ci b/.ci index ad8dd4a13..37fa7315b 160000 --- a/.ci +++ b/.ci @@ -1 +1 @@ -Subproject commit ad8dd4a136348c7dc889fdc03a645e0f0358a2dc +Subproject commit 37fa7315b73813c191b0be4bd8acbf61634bb8d1 diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index 02daab742..1535442d6 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -34,6 +34,7 @@ jobs: WINE: ${{ matrix.wine }} RTEMS: ${{ matrix.rtems }} EXTRA: ${{ matrix.extra }} + TEST: ${{ matrix.test }} strategy: fail-fast: false matrix: @@ -68,6 +69,12 @@ jobs: extra: "CMD_CXXFLAGS=-std=c++11" name: "Ub-20 clang-10 C++11" + - os: ubuntu-20.04 + cmp: gcc + configuration: default + rtems: "5" + test: NO + - os: ubuntu-20.04 cmp: gcc configuration: default From 10aff42da68cd4a31e6b8dce7bf000a822de66f4 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 10 Sep 2020 09:24:48 -0700 Subject: [PATCH 005/195] epicsNtp: avoid deprecated/non-standard bzero() --- modules/libcom/RTEMS/epicsNtp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/libcom/RTEMS/epicsNtp.c b/modules/libcom/RTEMS/epicsNtp.c index 9a28cb223..8f4e70ada 100644 --- a/modules/libcom/RTEMS/epicsNtp.c +++ b/modules/libcom/RTEMS/epicsNtp.c @@ -43,7 +43,7 @@ int epicsNtpGetTime(char *ntpIp, struct timespec *now) } // Zero out the server address structure. - bzero( ( char* ) &serv_addr, sizeof( serv_addr ) ); + memset( ( char* ) &serv_addr, 0, sizeof( serv_addr ) ); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = inet_addr(ntpIp); From 5a5345d44a92547282754e16c18dc7a1dd633c79 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 10 Sep 2020 10:12:29 -0700 Subject: [PATCH 006/195] WIP: fix missing bits needed by osiNTPTime.c --- modules/libcom/RTEMS/posix/rtems_init.c | 5 +++++ modules/libcom/src/osi/os/posix/osdTime.cpp | 12 ++++++++++++ modules/libcom/src/osi/os/posix/osdTime.h | 8 ++++++++ 3 files changed, 25 insertions(+) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index fe3e5586f..6773608f7 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -98,6 +98,11 @@ char *rtems_bsdnet_bootp_boot_file_name = bootp_boot_file_name_init; char bootp_cmdline_init[128] = "/Volumes/Epics/myExample/iocBoot/iocmyExample/st.cmd"; char *rtems_bsdnet_bootp_cmdline = bootp_cmdline_init; +int osdNTPGet(struct timespec *now) +{ + return !epicsNtpGetTime(rtemsInit_NTP_server_ip, now); +} + /* * Prototypes for some functions not in header files */ diff --git a/modules/libcom/src/osi/os/posix/osdTime.cpp b/modules/libcom/src/osi/os/posix/osdTime.cpp index 6d7b86048..b3bb84725 100644 --- a/modules/libcom/src/osi/os/posix/osdTime.cpp +++ b/modules/libcom/src/osi/os/posix/osdTime.cpp @@ -125,3 +125,15 @@ extern "C" LIBCOM_API void ++wakeTime->tv_sec; } } + +#ifdef __rtems__ +int osdTickGet() +{ + return epicsMonotonicGet(); // ns +} +int osdTickRateGet() +{ + return 1000000000; +} +void osdNTPReport() {} +#endif diff --git a/modules/libcom/src/osi/os/posix/osdTime.h b/modules/libcom/src/osi/os/posix/osdTime.h index 807b6d682..2aab01f3e 100644 --- a/modules/libcom/src/osi/os/posix/osdTime.h +++ b/modules/libcom/src/osi/os/posix/osdTime.h @@ -31,6 +31,14 @@ extern "C" { LIBCOM_API void epicsStdCall convertDoubleToWakeTime(double timeout,struct timespec *wakeTime); +#ifdef __rtems__ +void osdNTPInit(void); +int osdNTPGet(struct timespec *now); +int osdTickGet(void); +int osdTickRateGet(void); +void osdNTPReport(void); +#endif + #ifdef __cplusplus } #endif /* __cplusplus */ From 2b28d97063f23ac7f63c8287285c85fb5b554546 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 10 Sep 2020 10:41:15 -0700 Subject: [PATCH 007/195] RTEMS5: redirect to serial via runtime --- modules/libcom/RTEMS/posix/rtems_init.c | 15 +-------------- src/tools/makeTestfile.pl | 2 +- 2 files changed, 2 insertions(+), 15 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 6773608f7..16c46ba4e 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -45,6 +45,7 @@ #include #include #include +#include #ifdef RTEMS_LEGACY_STACK #include @@ -968,20 +969,6 @@ POSIX_Init (void *argument) * if BSP defaults aren't configured for running tests. */ - -/* Ensure that stdio goes to serial (so it can be captured) */ -#if defined(__i386__) && !USE_COM1_AS_CONSOLE -#include -#include - -extern int BSPPrintkPort; -void bsp_predriver_hook(void) -{ - Console_Port_Minor = BSP_CONSOLE_PORT_COM1; - BSPPrintkPort = BSP_CONSOLE_PORT_COM1; -} -#endif - /* reboot immediately when done. */ #if defined(__i386__) && BSP_PRESS_KEY_FOR_RESET void bsp_cleanup(void) diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index 7a8234962..694aebe84 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -39,7 +39,7 @@ if( $TA =~ /^win32-x86/ && $HA !~ /^win/ ) { # Run pc386 test harness w/ QEMU } elsif( $TA =~ /^RTEMS-pc386-qemu$/ ) { - $exec = "qemu-system-i386 -m 64 -no-reboot -serial stdio -display none -net nic,model=ne2k_pci -net user,restrict=yes -kernel $exe"; + $exec = "qemu-system-i386 -m 64 -no-reboot -serial stdio -display none -net nic,model=ne2k_pci -net user,restrict=yes -append --console=/dev/com1 -kernel $exe"; # Explicitly fail for other RTEMS targets } elsif( $TA =~ /^RTEMS-/ ) { From 4d69b7621db6956f7a8dc43edac9af2213ce9c59 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 10 Sep 2020 11:16:27 -0700 Subject: [PATCH 008/195] RTEMS: fix NIC for testing w/ RTEMS5 Add two NICs, ne2k used by RTEMS 4.x and e1000 used by RTEMS 5.1. Each ignores the NIC it doesn't understand. --- src/tools/makeTestfile.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index 694aebe84..e9643783d 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -39,7 +39,7 @@ if( $TA =~ /^win32-x86/ && $HA !~ /^win/ ) { # Run pc386 test harness w/ QEMU } elsif( $TA =~ /^RTEMS-pc386-qemu$/ ) { - $exec = "qemu-system-i386 -m 64 -no-reboot -serial stdio -display none -net nic,model=ne2k_pci -net user,restrict=yes -append --console=/dev/com1 -kernel $exe"; + $exec = "qemu-system-i386 -m 64 -no-reboot -serial stdio -display none -net nic,model=e1000 -net nic,model=ne2k_pci -net user,restrict=yes -append --console=/dev/com1 -kernel $exe"; # Explicitly fail for other RTEMS targets } elsif( $TA =~ /^RTEMS-/ ) { From 8a2f336f8f6c374c0f360789677eedb33de0d6e9 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 19 Sep 2020 18:39:07 -0700 Subject: [PATCH 009/195] re-drop RTEMS osdMessageQueue --- .../src/osi/os/RTEMS-kernel/osdMessageQueue.c | 251 ------------------ .../src/osi/os/RTEMS-kernel/osdMessageQueue.h | 29 -- .../src/osi/os/RTEMS-posix/osdMessageQueue.c | 160 ----------- .../src/osi/os/RTEMS-posix/osdMessageQueue.h | 29 -- 4 files changed, 469 deletions(-) delete mode 100644 modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c delete mode 100644 modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h delete mode 100644 modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c delete mode 100644 modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c b/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c deleted file mode 100644 index c7a05fcc5..000000000 --- a/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c +++ /dev/null @@ -1,251 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2002 The University of Chicago, as Operator of Argonne -* National Laboratory. -* Copyright (c) 2002 The Regents of the University of California, as -* Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ -/* - * Author W. Eric Norum - * norume@aps.anl.gov - * 630 252 4793 - */ - -/* - * We want to access information which is - * normally hidden from application programs. - */ -#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1 - -#define epicsExportSharedSymbols -#include -#include -#include -#include -#include -#include -#include "epicsMessageQueue.h" -#include "errlog.h" - -LIBCOM_API epicsMessageQueueId epicsStdCall -epicsMessageQueueCreate(unsigned int capacity, unsigned int maximumMessageSize) -{ - rtems_status_code sc; - epicsMessageQueueId id = calloc(1, sizeof(*id)); - rtems_interrupt_level level; - static char c1 = 'a'; - static char c2 = 'a'; - static char c3 = 'a'; - - if(!id) - return NULL; - - sc = rtems_message_queue_create (rtems_build_name ('Q', c3, c2, c1), - capacity, - maximumMessageSize, - RTEMS_FIFO|RTEMS_LOCAL, - &id->id); - if (sc != RTEMS_SUCCESSFUL) { - free(id); - errlogPrintf ("Can't create message queue: %s\n", rtems_status_text (sc)); - return NULL; - } - id->maxSize = maximumMessageSize; - id->localBuf = NULL; - rtems_interrupt_disable (level); - if (c1 == 'z') { - if (c2 == 'z') { - if (c3 == 'z') { - c3 = 'a'; - } - else { - c3++; - } - c2 = 'a'; - } - else { - c2++; - } - c1 = 'a'; - } - else { - c1++; - } - rtems_interrupt_enable (level); - return id; -} - -static rtems_status_code rtems_message_queue_send_timeout( - rtems_id id, - void *buffer, - uint32_t size, - rtems_interval timeout) -{ - Message_queue_Control *the_message_queue; - Objects_Locations location; - CORE_message_queue_Status msg_status; - - the_message_queue = _Message_queue_Get( id, &location ); - switch ( location ) - { - case OBJECTS_ERROR: - return RTEMS_INVALID_ID; - - case OBJECTS_LOCAL: - msg_status = _CORE_message_queue_Send( - &the_message_queue->message_queue, - buffer, - size, - id, - NULL, - 1, - timeout - ); - - _Thread_Enable_dispatch(); - - /* - * If we had to block, then this is where the task returns - * after it wakes up. The returned status is correct for - * non-blocking operations but if we blocked, then we need - * to look at the status in our TCB. - */ - - if ( msg_status == CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT ) - msg_status = _Thread_Executing->Wait.return_code; - return _Message_queue_Translate_core_message_queue_return_code( msg_status ); - } - return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ -} - -LIBCOM_API int epicsStdCall epicsMessageQueueSend( - epicsMessageQueueId id, - void *message, - unsigned int messageSize) -{ - if (rtems_message_queue_send_timeout(id->id, message, messageSize, RTEMS_NO_TIMEOUT) == RTEMS_SUCCESSFUL) - return 0; - else - return -1; -} - -LIBCOM_API int epicsStdCall epicsMessageQueueSendWithTimeout( - epicsMessageQueueId id, - void *message, - unsigned int messageSize, - double timeout) -{ - rtems_interval delay; - extern double rtemsTicksPerSecond_double; - - /* - * Convert time to ticks - */ - if (timeout <= 0.0) - return epicsMessageQueueTrySend(id, message, messageSize); - delay = (int)(timeout * rtemsTicksPerSecond_double); - if (delay == 0) - delay++; - if (rtems_message_queue_send_timeout(id->id, message, messageSize, delay) == RTEMS_SUCCESSFUL) - return 0; - else - return -1; -} - -static int receiveMessage( - epicsMessageQueueId id, - void *buffer, - uint32_t size, - uint32_t wait, - rtems_interval delay) -{ - size_t rsize; - rtems_status_code sc; - - if (size < id->maxSize) { - if (id->localBuf == NULL) { - id->localBuf = malloc(id->maxSize); - if (id->localBuf == NULL) - return -1; - } - rsize = receiveMessage(id, id->localBuf, id->maxSize, wait, delay); - if (rsize > size) - return -1; - memcpy(buffer, id->localBuf, rsize); - } - else { - sc = rtems_message_queue_receive(id->id, buffer, &rsize, wait, delay); - if (sc != RTEMS_SUCCESSFUL) - return -1; - } - return rsize; -} - -LIBCOM_API int epicsStdCall epicsMessageQueueTryReceive( - epicsMessageQueueId id, - void *message, - unsigned int size) -{ - return receiveMessage(id, message, size, RTEMS_NO_WAIT, 0); -} - -LIBCOM_API int epicsStdCall epicsMessageQueueReceive( - epicsMessageQueueId id, - void *message, - unsigned int size) -{ - return receiveMessage(id, message, size, RTEMS_WAIT, RTEMS_NO_TIMEOUT); -} - -LIBCOM_API int epicsStdCall epicsMessageQueueReceiveWithTimeout( - epicsMessageQueueId id, - void *message, - unsigned int size, - double timeout) -{ - rtems_interval delay; - uint32_t wait; - extern double rtemsTicksPerSecond_double; - - /* - * Convert time to ticks - */ - if (timeout <= 0.0) { - wait = RTEMS_NO_WAIT; - delay = 0; - } - else { - wait = RTEMS_WAIT; - delay = (int)(timeout * rtemsTicksPerSecond_double); - if (delay == 0) - delay++; - } - return receiveMessage(id, message, size, wait, delay); -} - -LIBCOM_API int epicsStdCall epicsMessageQueuePending( - epicsMessageQueueId id) -{ - uint32_t count; - rtems_status_code sc; - - sc = rtems_message_queue_get_number_pending(id->id, &count); - if (sc != RTEMS_SUCCESSFUL) { - errlogPrintf("Message queue %x get number pending failed: %s\n", - (unsigned int)id, - rtems_status_text(sc)); - return -1; - } - return count; -} - -LIBCOM_API void epicsStdCall epicsMessageQueueShow( - epicsMessageQueueId id, - int level) -{ - int pending = epicsMessageQueuePending(id); - if (pending >= 0) - printf ("Message queue %lx -- Pending: %d\n", (unsigned long)id, pending); -} diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h b/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h deleted file mode 100644 index 0244a1f0b..000000000 --- a/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2002 The University of Chicago, as Operator of Argonne -* National Laboratory. -* Copyright (c) 2002 The Regents of the University of California, as -* Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ -/* - * Author W. Eric Norum - * norume@aps.anl.gov - * 630 252 4793 - */ - -/* - * Very thin shims around RTEMS routines - */ -#include - -struct epicsMessageQueueOSD { - rtems_id id; - unsigned int maxSize; - void *localBuf; - -}; -#define epicsMessageQueueDestroy(q) (rtems_message_queue_delete((q)->id)) - -#define epicsMessageQueueTrySend(q,m,l) (rtems_message_queue_send((q)->id, (m), (l)) == RTEMS_SUCCESSFUL ? 0 : -1) diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c b/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c deleted file mode 100644 index 3774ef2d8..000000000 --- a/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c +++ /dev/null @@ -1,160 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2002 The University of Chicago, as Operator of Argonne -* National Laboratory. -* Copyright (c) 2002 The Regents of the University of California, as -* Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ -/* - * Author W. Eric Norum - * norume@aps.anl.gov - * 630 252 4793 - */ - -/* - * We want to access information which is - * normally hidden from application programs. - */ -#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1 - -#define epicsExportSharedSymbols -#include -#include -#include -#include -#include -#include -#include "epicsMessageQueue.h" -#include "errlog.h" -#include - -#include -#include -#include - -LIBCOM_API epicsMessageQueueId epicsStdCall -epicsMessageQueueCreate(unsigned int capacity, unsigned int maximumMessageSize) -{ - struct mq_attr the_attr; - epicsMessageQueueId id = (epicsMessageQueueId)calloc(1, sizeof(*id)); - - epicsAtomicIncrIntT(&id->idCnt); - sprintf(id->name, "MQ_%01d", epicsAtomicGetIntT(&id->idCnt)); - the_attr.mq_maxmsg = capacity; - the_attr.mq_msgsize = maximumMessageSize; - id->id = mq_open(id->name, O_RDWR | O_CREAT | O_EXCL, 0644, &the_attr); - if (id->id <0) { - fprintf (stderr, "Can't create message queue: %s\n", strerror (errno)); - return NULL; - } - return id; -} - -LIBCOM_API void epicsStdCall epicsMessageQueueDestroy( - epicsMessageQueueId id) -{ - int rv; - rv = mq_close(id->id); - if( rv ) { - fprintf(stderr, "epicsMessageQueueDestroy mq_close failed: %s\n", - strerror(rv)); - } - rv = mq_unlink(id->name); - if( rv ) { - fprintf(stderr,"epicsMessageQueueDestroy mq_unlink %s failed: %s\n", - id->name, strerror(rv)); - } - free(id); -} - - -LIBCOM_API int epicsStdCall epicsMessageQueueTrySend( - epicsMessageQueueId id, - void *message, - unsigned int messageSize) -{ - struct timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); - return mq_timedsend(id->id, (char const *)message, messageSize, 0, &ts); -} - -LIBCOM_API int epicsStdCall epicsMessageQueueSendWithTimeout( - epicsMessageQueueId id, - void *message, - unsigned int messageSize, - double timeout) -{ - struct timespec ts; - unsigned long micros; - - // assume timeout in sec - micros = (unsigned long)(timeout * 1000000.0); - clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_sec += micros / 1000000L; - ts.tv_nsec += (micros % 1000000L) * 1000L; - - return mq_timedsend (id->id, (const char *)message, messageSize, 0, &ts); -} - -LIBCOM_API int epicsStdCall epicsMessageQueueTryReceive( - epicsMessageQueueId id, - void *message, - unsigned int size) -{ - struct timespec ts; - clock_gettime(CLOCK_REALTIME, &ts); - return mq_timedreceive(id->id, (char *)message, size, NULL, &ts); -} - -LIBCOM_API int epicsStdCall epicsMessageQueueReceiveWithTimeout( - epicsMessageQueueId id, - void *message, - unsigned int size, - double timeout) -{ - unsigned long micros; - struct timespec ts; - - micros = (unsigned long)(timeout * 1000000.0); - clock_gettime(CLOCK_REALTIME, &ts); - ts.tv_sec += micros / 1000000L; - ts.tv_nsec += (micros % 1000000L) * 1000L; - - return mq_timedreceive(id->id, (char *)message, size, NULL, &ts); -} - -LIBCOM_API int epicsStdCall epicsMessageQueuePending( - epicsMessageQueueId id) -{ - int rv; - struct mq_attr the_attr; - - rv = mq_getattr(id->id, &the_attr); - if (rv) { - fprintf(stderr, "Epics Message queue %x (%s) get attr failed: %s\n", - (unsigned int)id->id, id->name, strerror(rv)); - return -1; - } - return the_attr.mq_curmsgs; -} -LIBCOM_API void epicsStdCall epicsMessageQueueShow( - epicsMessageQueueId id, - int level) -{ - int rv; - struct mq_attr the_attr; - - rv = mq_getattr(id->id, &the_attr); - if (rv) { - fprintf(stderr, "Epics Message queue %x (%s) get attr failed: %s\n", - (unsigned int)id->id, id->name, strerror(rv)); - } - - printf("Message Queue Used:%ld Max Msg:%lu", the_attr.mq_curmsgs, the_attr.mq_maxmsg); - if (level >= 1) - printf(" Maximum size:%lu", the_attr.mq_msgsize); - - printf("\n"); -} diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h b/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h deleted file mode 100644 index 0311ee486..000000000 --- a/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2002 The University of Chicago, as Operator of Argonne -* National Laboratory. -* Copyright (c) 2002 The Regents of the University of California, as -* Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ -/* - * Author W. Eric Norum - * norume@aps.anl.gov - * 630 252 4793 - */ - -/* - * Very thin shims around RTEMS routines - */ -#include -#include - -struct epicsMessageQueueOSD { - mqd_t id; - char name[24]; - int idCnt; - -}; -#define epicsMessageQueueSend(q,m,l) (mq_send((q)->id, (const char*)(m), (l), 0)) -#define epicsMessageQueueReceive(q,m,s) (mq_receive((q)->id, (char*)(m), (s), NULL)) \ No newline at end of file From 75548c95d1d8cf1ebeef42fb2ccff1902ca312c4 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 21 Nov 2020 09:40:57 -0800 Subject: [PATCH 010/195] rtems5: fix linking of dependent modules, need -lCom after -lrtemsCom --- configure/os/CONFIG.Common.RTEMS | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 4b1701892..2f63b1508 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -96,11 +96,9 @@ OS_CLASS = RTEMS #-------------------------------------------------- # Operating system flags -#OP_SYS_LDLIBS += -lrtemsCom -lc -lrtemscpu -lCom -lnfs -lm ifeq ($(OS_API),posix) OP_SYS_CFLAGS += -D__LINUX_ERRNO_EXTENSIONS__ -#OP_SYS_LDLIBS += -lrtemsCom -lrtemscpu -lrtemsbsp -ltftpfs -ltelnetd -lbsd -lz -lm -OP_SYS_LDLIBS += -lrtemsCom -lc -lrtemscpu -ltftpfs -lbsd -lz -lm +OP_SYS_LDLIBS += -lrtemsCom -lc -lrtemscpu -lCom -ltftpfs -lbsd -lz -lm else OP_SYS_LDLIBS += -lrtemsCom -lc -lrtemscpu -lCom -lnfs -lm endif From bb860ae001abf0fc6567d98e94eceeadf2a371b6 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 21 Nov 2020 10:10:54 -0800 Subject: [PATCH 011/195] rtems5: correct ifreq_size() --- modules/libcom/src/osi/os/RTEMS-posix/osdSock.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h b/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h index e5568fc1b..315c460dd 100644 --- a/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h @@ -72,7 +72,7 @@ typedef int osiSockOptMcastTTL_t; # define SHUT_RDWR 2 #endif -#define ifreq_size(pifreq) (sizeof(pifreq->ifr_name)) +#define ifreq_size(pifreq) (pifreq->ifr_addr.sa_len + sizeof(pifreq->ifr_name)) #ifndef IPPORT_USERRESERVED #define IPPORT_USERRESERVED 5000 From 629f958427976ac40d2afd93f83df3783cfddc90 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 25 Sep 2020 10:30:16 -0500 Subject: [PATCH 012/195] Install toolchain data into cfg/ directory --- .gitignore | 1 - configure/CONFIG | 4 +++- configure/Makefile | 20 +++----------------- configure/toolchain.c | 2 +- 4 files changed, 7 insertions(+), 20 deletions(-) diff --git a/.gitignore b/.gitignore index 23a5179e8..94e36205a 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ /include/ /templates/ /configure/*.local -/configure/os/CONFIG_TOOLCHAIN.* /modules/RELEASE.*.local /modules/Makefile.local O.*/ diff --git a/configure/CONFIG b/configure/CONFIG index 320ee8200..1c1242858 100644 --- a/configure/CONFIG +++ b/configure/CONFIG @@ -62,6 +62,9 @@ include $(CONFIG)/os/CONFIG.$(EPICS_HOST_ARCH).Common RELEASE_TOPS := $(shell $(CONVERTRELEASE) -T $(TOP) releaseTops) ifdef T_A + # Information from the target's compiler + # + -include $(EPICS_BASE)/cfg/TOOLCHAIN.$(EPICS_HOST_ARCH).$(T_A) # Cross compile specific definitions # @@ -71,7 +74,6 @@ ifdef T_A # Target architecture specific definitions # - -include $(CONFIG)/os/CONFIG_TOOLCHAIN.Common.$(T_A) -include $(CONFIG)/os/CONFIG.Common.$(T_A) # Host-Target architecture specific definitions diff --git a/configure/Makefile b/configure/Makefile index 157dde0ea..ba77d5089 100644 --- a/configure/Makefile +++ b/configure/Makefile @@ -30,23 +30,9 @@ CFG += CONFIG_CA_VERSION CFG += CONFIG_DATABASE_MODULE CFG += CONFIG_DATABASE_VERSION +CFG += TOOLCHAIN.$(EPICS_HOST_ARCH).$(T_A) + include $(TOP)/configure/RULES -ifdef T_A - -install: $(TOP)/configure/os/CONFIG_TOOLCHAIN.Common.$(T_A) - -$(TOP)/configure/os/CONFIG_TOOLCHAIN.Common.$(T_A): toolchain.c +TOOLCHAIN.$(EPICS_HOST_ARCH).$(T_A): toolchain.c $(PREPROCESS.cpp) - -else - -realclean: clean_toolchain -clean: clean_toolchain - -clean_toolchain: - $(RM) $(wildcard os/CONFIG_TOOLCHAIN.Common.*) - -.PHONY: clean_toolchain - -endif # T_A diff --git a/configure/toolchain.c b/configure/toolchain.c index c19d1049d..3120d4fdc 100644 --- a/configure/toolchain.c +++ b/configure/toolchain.c @@ -1,7 +1,7 @@ #ifdef _COMMENT_ /* Extract compiler pre-defined macros as Make variables * - * Expanded as configure/os/CONFIG_TOOLCHAIN.Common.$(T_A) + * Expanded as $(INSTALL_CFG)/TOOLCHAIN.$(EPICS_HOST_ARCH).$(T_A) * * Must be careful not to #include any C definitions * into what is really a Makefile snippet From 8b766f767f3da63cbef6c6ded9168d8a406bf305 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 25 Sep 2020 11:03:45 -0500 Subject: [PATCH 013/195] Set GNU_TARGET automatically The individual CONFIG.Common.RTEMS-$(T_A) files don't really need to set the new GNU_TARGET variable themselves, this addition allows the unmodified RTEMS-uC5282 target build fine (on 4.10.1 at least). --- configure/os/CONFIG.Common.RTEMS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 2f63b1508..bcab2ac49 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -28,8 +28,9 @@ ifneq ($(CONFIG),$(TOP)/configure) endif #-------------------------------------------------- -# Set RTEMS_BSP from T_A if not already done +# Set RTEMS_BSP and GNU_TARGET if not already done RTEMS_BSP ?= $(subst RTEMS-,,$(T_A)) +GNU_TARGET ?= $(RTEMS_TARGET_CPU)-rtems #------------------------------------------------------- # Pick up the RTEMS tool/path definitions from the RTEMS BSP directory. From b2c4f0d015344667b5509a22fafecf2ecdc9f0d2 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 25 Sep 2020 11:27:59 -0500 Subject: [PATCH 014/195] Explain the RTEMS config variables --- configure/os/CONFIG_SITE.Common.RTEMS | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/configure/os/CONFIG_SITE.Common.RTEMS b/configure/os/CONFIG_SITE.Common.RTEMS index 47de204dd..9b44101eb 100644 --- a/configure/os/CONFIG_SITE.Common.RTEMS +++ b/configure/os/CONFIG_SITE.Common.RTEMS @@ -3,12 +3,28 @@ # Site-specific information for all RTEMS targets #------------------------------------------------------- -# Where to find RTEMS +# Where to find RTEMS, and what version is it # -# FHI: +# RTEMS_BASE must point to the specific installation of RTEMS to +# build the target code with. +# RTEMS_VERSION is used in the path to the toolsets inside that +# installation. For RTEMS 5 only the major version number is +# used, but for RTEMS 4.10.2 say all 3 components are required. +# +# TRAVIS-CI: RTEMS_VERSION = 5 RTEMS_BASE = /home/travis/.rtems +# FHI: +#RTEMS_VERSION = 5 +#RTEMS_BASE = /home/h1/DBG/rtems + +# APS: +#RTEMS_VERSION = 4.10.2 +#RTEMS_BASE = /usr/local/vw/rtems/rtems-4.10.2 +#RTEMS_VERSION = 5 +#RTEMS_BASE = /usr/local/vw/rtems/rtems-5.1 + # Cross-compile toolchain in $(RTEMS_TOOLS)/bin # RTEMS_TOOLS = $(RTEMS_BASE) From 708cecfadc8f71d08d932a96f8f854d525e13432 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 25 Sep 2020 12:04:24 -0500 Subject: [PATCH 015/195] Move HAVE_SOCKADDR_SA_LEN=1 for darwin targets --- configure/os/CONFIG.darwin-x86.Common | 3 +-- configure/os/CONFIG.darwinCommon.darwinCommon | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/configure/os/CONFIG.darwin-x86.Common b/configure/os/CONFIG.darwin-x86.Common index 960c74b8a..e779f7dc1 100644 --- a/configure/os/CONFIG.darwin-x86.Common +++ b/configure/os/CONFIG.darwin-x86.Common @@ -3,7 +3,6 @@ # Definitions for darwin-x86 host builds # Sites may override these definitions in CONFIG_SITE.darwin-x86.Common #------------------------------------------------------- -#support for IPv6 etc. -OP_SYS_CFLAGS += -DHAVE_SOCKADDR_SA_LEN=1 + #Include definitions common to unix hosts include $(CONFIG)/os/CONFIG.UnixCommon.Common diff --git a/configure/os/CONFIG.darwinCommon.darwinCommon b/configure/os/CONFIG.darwinCommon.darwinCommon index bfd61830d..5575eb35f 100644 --- a/configure/os/CONFIG.darwinCommon.darwinCommon +++ b/configure/os/CONFIG.darwinCommon.darwinCommon @@ -30,8 +30,10 @@ ARCH_DEP_LDFLAGS += $(ARCH_DEP_FLAGS) # # Special flags for Darwin # No common blocks (as required when using shared libraries) +# OS provides socket address length # OP_SYS_CFLAGS += -fno-common +OP_SYS_CFLAGS += -DHAVE_SOCKADDR_SA_LEN=1 # # Darwin os definition From ec94351a5e2edf94b3373e13e42a75b4f4b86395 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 25 Sep 2020 17:57:31 -0500 Subject: [PATCH 016/195] Add RTEMS-pc686-qemu for use on RTEMS 5.x RTEMS 5.x moved the PC BSP to 686. This commit makes the EPICS target match; RTEMS-pc386 and the -qemu variant can only be built when RTEMS_VERSION != 5, whereas RTEMS-pc686 and its -qemu version will only build when RTEMS_VERSION == 5 (there are checks with descriptive errors included). makeTestFile.pl was also reformatted and modified to use exec to run tests on non-Windows hosts as required by the Perl test harness. --- configure/os/CONFIG.Common.RTEMS-pc386 | 17 ++- configure/os/CONFIG.Common.RTEMS-pc386-qemu | 3 +- configure/os/CONFIG.Common.RTEMS-pc686 | 17 ++- configure/os/CONFIG.Common.RTEMS-pc686-qemu | 11 ++ .../os/CONFIG_SITE.Common.RTEMS-pc386-qemu | 2 +- .../os/CONFIG_SITE.Common.RTEMS-pc686-qemu | 9 ++ src/tools/makeTestfile.pl | 100 ++++++++---------- 7 files changed, 88 insertions(+), 71 deletions(-) create mode 100644 configure/os/CONFIG.Common.RTEMS-pc686-qemu create mode 100644 configure/os/CONFIG_SITE.Common.RTEMS-pc686-qemu diff --git a/configure/os/CONFIG.Common.RTEMS-pc386 b/configure/os/CONFIG.Common.RTEMS-pc386 index bb4f3e7c7..9fc518d6b 100644 --- a/configure/os/CONFIG.Common.RTEMS-pc386 +++ b/configure/os/CONFIG.Common.RTEMS-pc386 @@ -1,10 +1,10 @@ +# CONFIG.Common.RTEMS-pc386 # -# Author: W. Eric Norum -# Canadian Light Source -# eric@cls.usask.ca -# -# All RTEMS targets use the same Makefile fragment +# Definitions for the RTEMS-pc386 target, RTEMS 4.x only +# Site-specific overrides go in CONFIG_SITE.Common.RTEMS-pc386 # +#------------------------------------------------------- + RTEMS_BSP = pc386 RTEMS_TARGET_CPU = i386 GNU_TARGET = i386-rtems @@ -23,3 +23,10 @@ include $(CONFIG)/os/CONFIG.Common.RTEMS # Put text segment where it will work with etherboot # OP_SYS_LDFLAGS += -Wl,-Ttext,0x100000 + +# This check must appear after the above include +ifeq ($(RTEMS_VERSION),5) + $(info *** This target is not compatible with the configured RTEMS version.) + $(info *** Build the RTEMS-pc686 (-qemu) target for RTEMS 5.x) + $(error Can't continue) +endif diff --git a/configure/os/CONFIG.Common.RTEMS-pc386-qemu b/configure/os/CONFIG.Common.RTEMS-pc386-qemu index 29196ff65..684f01a19 100644 --- a/configure/os/CONFIG.Common.RTEMS-pc386-qemu +++ b/configure/os/CONFIG.Common.RTEMS-pc386-qemu @@ -6,7 +6,6 @@ #------------------------------------------------------- # Include definitions from RTEMS-pc386 -# For Tests overwrite it with pc686 -include $(CONFIG)/os/CONFIG.Common.RTEMS-pc686 +include $(CONFIG)/os/CONFIG.Common.RTEMS-pc386 RTEMS_QEMU_FIXUPS = YES diff --git a/configure/os/CONFIG.Common.RTEMS-pc686 b/configure/os/CONFIG.Common.RTEMS-pc686 index 43849744f..7f9446e1e 100644 --- a/configure/os/CONFIG.Common.RTEMS-pc686 +++ b/configure/os/CONFIG.Common.RTEMS-pc686 @@ -1,10 +1,10 @@ +# CONFIG.Common.RTEMS-pc686 # -# Author: W. Eric Norum -# Canadian Light Source -# eric@cls.usask.ca -# -# All RTEMS targets use the same Makefile fragment +# Definitions for the RTEMS-pc686 target, RTEMS 5.x only +# Site-specific overrides go in CONFIG_SITE.Common.RTEMS-pc686 # +#------------------------------------------------------- + RTEMS_BSP = pc686 RTEMS_TARGET_CPU = i386 GNU_TARGET = i386-rtems @@ -23,3 +23,10 @@ include $(CONFIG)/os/CONFIG.Common.RTEMS # Put text segment where it will work with etherboot # OP_SYS_LDFLAGS += -Wl,-Ttext,0x100000 + +# This check must appear after the above include +ifneq ($(RTEMS_VERSION),5) + $(info *** This target is not compatible with the configured RTEMS version.) + $(info *** Build the RTEMS-pc386 (-qemu) target for RTEMS 4.x) + $(error Can't continue) +endif diff --git a/configure/os/CONFIG.Common.RTEMS-pc686-qemu b/configure/os/CONFIG.Common.RTEMS-pc686-qemu new file mode 100644 index 000000000..1de543a30 --- /dev/null +++ b/configure/os/CONFIG.Common.RTEMS-pc686-qemu @@ -0,0 +1,11 @@ +# CONFIG.Common.RTEMS-pc686-qemu +# +# Definitions for the RTEMS-pc686-qemu target +# Site-specific overrides go in CONFIG_SITE.Common.RTEMS-pc686-qemu +# +#------------------------------------------------------- + +# Include definitions from RTEMS-pc686 +include $(CONFIG)/os/CONFIG.Common.RTEMS-pc686 + +RTEMS_QEMU_FIXUPS = YES diff --git a/configure/os/CONFIG_SITE.Common.RTEMS-pc386-qemu b/configure/os/CONFIG_SITE.Common.RTEMS-pc386-qemu index 027dcf4ab..0f930c5d9 100644 --- a/configure/os/CONFIG_SITE.Common.RTEMS-pc386-qemu +++ b/configure/os/CONFIG_SITE.Common.RTEMS-pc386-qemu @@ -6,4 +6,4 @@ # If you're building this architecture you _probably_ want to # run the tests for it under QEMU, but if not you can turn # them off here by commenting out this line: -CROSS_COMPILER_RUNTEST_ARCHS += RTEMS-pc386-qemu +CROSS_COMPILER_RUNTEST_ARCHS += $(T_A) diff --git a/configure/os/CONFIG_SITE.Common.RTEMS-pc686-qemu b/configure/os/CONFIG_SITE.Common.RTEMS-pc686-qemu new file mode 100644 index 000000000..4ed2ed36c --- /dev/null +++ b/configure/os/CONFIG_SITE.Common.RTEMS-pc686-qemu @@ -0,0 +1,9 @@ +# CONFIG_SITE.Common.RTEMS-pc686-qemu +# +# Site-specific overrides for the RTEMS-pc686-qemu target +# + +# If you're building this architecture you _probably_ want to +# run the tests for it under QEMU, but if not you can turn +# them off here by commenting out this line: +CROSS_COMPILER_RUNTEST_ARCHS += $(T_A) diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index e9643783d..efac61aba 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -24,75 +24,59 @@ use strict; my ($TA, $HA, $target, $exe) = @ARGV; -my $exec; +my ($exec, $error); -# Use WINE to run windows target executables on non-windows host -if( $TA =~ /^win32-x86/ && $HA !~ /^win/ ) { - # new deb. derivatives have wine32 and wine64 - # older have wine and wine64 - # prefer wine32 if present - my $wine32 = "/usr/bin/wine32"; - $wine32 = "/usr/bin/wine" if ! -x $wine32; - $exec = "$wine32 $exe"; -} elsif( $TA =~ /^windows-x64/ && $HA !~ /^win/ ) { - $exec = "wine64 $exe"; - -# Run pc386 test harness w/ QEMU -} elsif( $TA =~ /^RTEMS-pc386-qemu$/ ) { - $exec = "qemu-system-i386 -m 64 -no-reboot -serial stdio -display none -net nic,model=e1000 -net nic,model=ne2k_pci -net user,restrict=yes -append --console=/dev/com1 -kernel $exe"; - -# Explicitly fail for other RTEMS targets -} elsif( $TA =~ /^RTEMS-/ ) { - die "$0: I don't know how to create scripts for testing $TA on $HA\n"; - -} else { - $exec = "./$exe"; +if ($TA =~ /^win32-x86/ && $HA !~ /^win/) { + # Use WINE to run win32-x86 executables on non-windows hosts. + # New Debian derivatives have wine32 and wine64, older ones have + # wine and wine64. We prefer wine32 if present. + my $wine32 = "/usr/bin/wine32"; + $wine32 = "/usr/bin/wine" if ! -x $wine32; + $error = $exec = "$wine32 $exe"; +} +elsif ($TA =~ /^windows-x64/ && $HA !~ /^win/) { + # Use WINE to run windows-x64 executables on non-windows hosts. + $error = $exec = "wine64 $exe"; +} +elsif ($TA =~ /^RTEMS-pc[36]86-qemu$/) { + # Run the pc386 and pc686 test harness w/ QEMU + $exec = "qemu-system-i386 -m 64 -no-reboot " + . "-serial stdio -display none " + . "-net nic,model=e1000 -net nic,model=ne2k_pci " + . "-net user,restrict=yes " + . "-append --console=/dev/com1 " + . "-kernel $exe"; + $error = "qemu-system-i386 ... -kernel $exe"; +} +elsif ($TA =~ /^RTEMS-/) { + # Explicitly fail for other RTEMS targets + die "$0: I don't know how to create scripts for testing $TA on $HA\n"; +} +else { + # Assume it's directly executable on other targets + $error = $exec = "./$exe"; } -# Ensure that Windows interactive error handling is disabled. -# This setting is inherited by the test process. -# Set SEM_FAILCRITICALERRORS (1) Disable critical-error-handler dialog -# Clear SEM_NOGPFAULTERRORBOX (2) Enabled WER to allow automatic post mortem debugging (AeDebug) -# Clear SEM_NOALIGNMENTFAULTEXCEPT (4) Allow alignment fixups -# Set SEM_NOOPENFILEERRORBOX (0x8000) Prevent dialog on some I/O errors -# https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-seterrormode?redirectedfrom=MSDN -my $sem = $^O ne 'MSWin32' ? '' : <import(\$sem); - }; - eval { - require Win32API::File; - Win32API::File->import(\$sem); - } if \$@; - SetErrorMode(0x8001) unless \$@; -} -ENDBEGIN +# Run the test program with system on Windows, exec elsewhere. +# This is required by the Perl test harness. +my $runtest = ($^O eq 'MSWin32') ? + "system('$exec') == 0" : "exec '$exec'"; -open(my $OUT, '>', $target) or die "Can't create $target: $!\n"; +open my $OUT, '>', $target + or die "Can't create $target: $!\n"; -print $OUT <> 8; -} -else { - exec '$exec' or die "Can't run $exec: \$!\\n"; -} -EOF +$runtest + or die "Can't run $error: \$!\\n"; +__EOF__ -close $OUT or die "Can't close $target: $!\n"; +close $OUT + or die "Can't close $target: $!\n"; From 9c01c55f086cfe96de2a7432be1e8befd30ef62d Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 25 Sep 2020 18:07:58 -0500 Subject: [PATCH 017/195] Clean up CONFIG.Common.RTEMS --- configure/os/CONFIG.Common.RTEMS | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index bcab2ac49..5bd06e953 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -98,27 +98,29 @@ OS_CLASS = RTEMS #-------------------------------------------------- # Operating system flags ifeq ($(OS_API),posix) -OP_SYS_CFLAGS += -D__LINUX_ERRNO_EXTENSIONS__ -OP_SYS_LDLIBS += -lrtemsCom -lc -lrtemscpu -lCom -ltftpfs -lbsd -lz -lm -else -OP_SYS_LDLIBS += -lrtemsCom -lc -lrtemscpu -lCom -lnfs -lm + OP_SYS_CFLAGS += -D__LINUX_ERRNO_EXTENSIONS__ endif ifeq ($(RTEMS_HAS_NETWORKING),yes) -OP_SYS_CFLAGS += -DRTEMS_LEGACY_STACK + OP_SYS_CFLAGS += -DRTEMS_LEGACY_STACK else -OP_SYS_CFLAGS += -DHAVE_SOCKADDR_SA_LEN=1 + OP_SYS_CFLAGS += -DHAVE_SOCKADDR_SA_LEN=1 endif -OP_SYS_LDFLAGS_posix += -u POSIX_Init -OP_SYS_LDFLAGS_kernel += $(CPU_CFLAGS) -u Init \ +OP_SYS_LDLIBS_posix = -ltftpfs -lbsd -lz +OP_SYS_LDLIBS_kernel = -lCom -lnfs +OP_SYS_LDLIBS += -lrtemsCom -lCom -lc -lrtemscpu $(OP_SYS_LDLIBS_$(OS_API)) -lm + +OP_SYS_LDFLAGS_posix = -u POSIX_Init +OP_SYS_LDFLAGS_kernel = -u Init \ $(PROJECT_RELEASE)/lib/no-dpmem.rel \ $(PROJECT_RELEASE)/lib/no-mp.rel \ $(PROJECT_RELEASE)/lib/no-part.rel \ $(PROJECT_RELEASE)/lib/no-signal.rel \ $(PROJECT_RELEASE)/lib/no-rtmon.rel - OP_SYS_LDFLAGS += $(CPU_CFLAGS) $(OP_SYS_LDFLAGS_$(OS_API)) + +# Settings for GeSys MOD_SYS_LDFLAGS += $(CPU_CFLAGS) -Wl,-r -nostdlib # Do not link against libraries which are part of the Generic Image From 14140acd787e990f34bf1d4d827d6bb4903f282a Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 25 Sep 2020 18:10:56 -0500 Subject: [PATCH 018/195] Enable RTEMS testing in modules/database/test/std/link --- modules/database/test/std/link/Makefile | 9 +++++++++ modules/database/test/std/link/lnkCalcTest.c | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/modules/database/test/std/link/Makefile b/modules/database/test/std/link/Makefile index 2563fd591..fca089966 100644 --- a/modules/database/test/std/link/Makefile +++ b/modules/database/test/std/link/Makefile @@ -47,6 +47,8 @@ testHarness_SRCS += epicsRunLinkTests.c linkTestHarness_SRCS += $(testHarness_SRCS) linkTestHarness_SRCS_RTEMS += rtemsTestHarness.c +PROD_SRCS_RTEMS += rtemsTestData.c + PROD_vxWorks = linkTestHarness PROD_RTEMS = linkTestHarness @@ -54,9 +56,16 @@ TESTSPEC_vxWorks = linkTestHarness.munch; epicsRunLinkTests TESTSPEC_RTEMS = linkTestHarness.boot; epicsRunLinkTests TESTSCRIPTS_HOST += $(TESTS:%=%.t) +ifneq ($(filter $(T_A),$(CROSS_COMPILER_RUNTEST_ARCHS)),) + TESTPROD = $(TESTPROD_HOST) + TESTSCRIPTS_RTEMS += $(TESTS:%=%.t) +endif include $(TOP)/configure/RULES ioRecord$(DEP): $(COMMON_DIR)/ioRecord.h lnkStateTest$(DEP): $(COMMON_DIR)/ioRecord.h lnkCalcTest$(DEP): $(COMMON_DIR)/ioRecord.h + +rtemsTestData.c : $(TESTFILES) $(TOOLS)/epicsMakeMemFs.pl + $(PERL) $(TOOLS)/epicsMakeMemFs.pl $@ epicsRtemsFSImage $(TESTFILES) diff --git a/modules/database/test/std/link/lnkCalcTest.c b/modules/database/test/std/link/lnkCalcTest.c index 5297a53c5..b573e345d 100644 --- a/modules/database/test/std/link/lnkCalcTest.c +++ b/modules/database/test/std/link/lnkCalcTest.c @@ -157,7 +157,7 @@ static void testCalc() MAIN(lnkCalcTest) { - testPlan(0); + testPlan(30); testCalc(); From f685b0edb44794c6aacce2605c28c1f8025f6ab1 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 28 Oct 2020 13:38:50 -0500 Subject: [PATCH 019/195] Set RTEMS_TARGET for Travis builds --- .github/workflows/ci-scripts-build.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index 1535442d6..79b85ccd9 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -33,6 +33,7 @@ jobs: BCFG: ${{ matrix.configuration }} WINE: ${{ matrix.wine }} RTEMS: ${{ matrix.rtems }} + RTEMS_TARGET: ${{ matrix.rtems_target }} EXTRA: ${{ matrix.extra }} TEST: ${{ matrix.test }} strategy: @@ -73,6 +74,7 @@ jobs: cmp: gcc configuration: default rtems: "5" + rtems_target: RTEMS-pc686-qemu test: NO - os: ubuntu-20.04 @@ -80,12 +82,14 @@ jobs: configuration: default rtems: "4.10" name: "Ub-20 gcc-9 + RT-4.10" + rtems_target: RTEMS-pc386-qemu - os: ubuntu-20.04 cmp: gcc configuration: default rtems: "4.9" name: "Ub-20 gcc-9 + RT-4.9" + rtems_target: RTEMS-pc386-qemu - os: ubuntu-16.04 cmp: gcc-4.8 From 761ebff6d74059d886fc3fb6ae9cea65c7e591d2 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 28 Oct 2020 13:41:00 -0500 Subject: [PATCH 020/195] Simplify RTEMS OP_SYS_CFLAGS settings --- configure/os/CONFIG.Common.RTEMS | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 5bd06e953..610057d53 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -96,16 +96,13 @@ MODEXT=.obj OS_CLASS = RTEMS #-------------------------------------------------- -# Operating system flags -ifeq ($(OS_API),posix) - OP_SYS_CFLAGS += -D__LINUX_ERRNO_EXTENSIONS__ -endif +# Operating system compile & link flags +OP_SYS_CFLAGS_API_posix = -D__LINUX_ERRNO_EXTENSIONS__ +OP_SYS_CFLAGS += $(OP_SYS_CFLAGS_API_$(OS_API)) -ifeq ($(RTEMS_HAS_NETWORKING),yes) - OP_SYS_CFLAGS += -DRTEMS_LEGACY_STACK -else - OP_SYS_CFLAGS += -DHAVE_SOCKADDR_SA_LEN=1 -endif +OP_SYS_CFLAGS_NET_yes = -DRTEMS_LEGACY_STACK +OP_SYS_CFLAGS_NET_no = -DHAVE_SOCKADDR_SA_LEN=1 +OP_SYS_CFLAGS += $(OP_SYS_CFLAGS_NET_$(RTEMS_HAS_NETWORKING)) OP_SYS_LDLIBS_posix = -ltftpfs -lbsd -lz OP_SYS_LDLIBS_kernel = -lCom -lnfs From 1b6b32e9caa09498bc9dfc1dd40eb22f4d71c3e9 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 21 Nov 2020 13:33:37 -0800 Subject: [PATCH 021/195] restore $(API_CPPFLAGS) --- configure/CONFIG_COMMON | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure/CONFIG_COMMON b/configure/CONFIG_COMMON index 9ccdf2804..d56802968 100644 --- a/configure/CONFIG_COMMON +++ b/configure/CONFIG_COMMON @@ -307,7 +307,7 @@ LDLIBS = $(POSIX_LDLIBS) $(ARCH_DEP_LDLIBS) $(DEBUG_LDLIBS) $(OP_SYS_LDLIBS)\ CPPFLAGS = $($(BUILD_CLASS)_CPPFLAGS) $(POSIX_CPPFLAGS) $(OPT_CPPFLAGS)\ $(DEBUG_CPPFLAGS) $(WARN_CPPFLAGS) $(BASE_CPPFLAGS) $(TARGET_CPPFLAGS)\ $(USR_CPPFLAGS) $(CMD_CPPFLAGS) $(ARCH_DEP_CPPFLAGS) $(OP_SYS_CPPFLAGS)\ - $(OP_SYS_INCLUDE_CPPFLAGS) $(CODE_CPPFLAGS) + $(OP_SYS_INCLUDE_CPPFLAGS) $(CODE_CPPFLAGS) $(API_CPPFLAGS) #-------------------------------------------------- # ar definition default From 8ef4d29c48b3c6ca52828ba6a84b116f0b83e999 Mon Sep 17 00:00:00 2001 From: Heinz Junkes Date: Sat, 5 Sep 2020 20:17:30 +0200 Subject: [PATCH 022/195] Enable Epics for RTEMS5 (posix) --- configure/CONFIG_COMMON | 2 +- configure/os/CONFIG.Common.RTEMS | 10 +- configure/os/CONFIG.Common.RTEMS-pc386-qemu | 3 +- configure/os/CONFIG.Common.RTEMS-pc686 | 9 +- configure/os/CONFIG.darwin-x86.Common | 3 +- configure/os/CONFIG_SITE.Common.RTEMS | 3 - modules/libcom/RTEMS/epicsNtp.c | 1 + .../src/osi/os/RTEMS-kernel/osdMessageQueue.c | 251 ++++++++++++++++++ .../src/osi/os/RTEMS-kernel/osdMessageQueue.h | 29 ++ .../src/osi/os/RTEMS-posix/osdMessageQueue.c | 160 +++++++++++ .../src/osi/os/RTEMS-posix/osdMessageQueue.h | 29 ++ 11 files changed, 489 insertions(+), 11 deletions(-) create mode 100644 modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c create mode 100644 modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h create mode 100644 modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c create mode 100644 modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h diff --git a/configure/CONFIG_COMMON b/configure/CONFIG_COMMON index d56802968..9ccdf2804 100644 --- a/configure/CONFIG_COMMON +++ b/configure/CONFIG_COMMON @@ -307,7 +307,7 @@ LDLIBS = $(POSIX_LDLIBS) $(ARCH_DEP_LDLIBS) $(DEBUG_LDLIBS) $(OP_SYS_LDLIBS)\ CPPFLAGS = $($(BUILD_CLASS)_CPPFLAGS) $(POSIX_CPPFLAGS) $(OPT_CPPFLAGS)\ $(DEBUG_CPPFLAGS) $(WARN_CPPFLAGS) $(BASE_CPPFLAGS) $(TARGET_CPPFLAGS)\ $(USR_CPPFLAGS) $(CMD_CPPFLAGS) $(ARCH_DEP_CPPFLAGS) $(OP_SYS_CPPFLAGS)\ - $(OP_SYS_INCLUDE_CPPFLAGS) $(CODE_CPPFLAGS) $(API_CPPFLAGS) + $(OP_SYS_INCLUDE_CPPFLAGS) $(CODE_CPPFLAGS) #-------------------------------------------------- # ar definition default diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 610057d53..2d9243a60 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -104,12 +104,14 @@ OP_SYS_CFLAGS_NET_yes = -DRTEMS_LEGACY_STACK OP_SYS_CFLAGS_NET_no = -DHAVE_SOCKADDR_SA_LEN=1 OP_SYS_CFLAGS += $(OP_SYS_CFLAGS_NET_$(RTEMS_HAS_NETWORKING)) -OP_SYS_LDLIBS_posix = -ltftpfs -lbsd -lz -OP_SYS_LDLIBS_kernel = -lCom -lnfs -OP_SYS_LDLIBS += -lrtemsCom -lCom -lc -lrtemscpu $(OP_SYS_LDLIBS_$(OS_API)) -lm +OP_SYS_LDLIBS_posix_NET_yes = -ltftpfs -lbsd -lz +OP_SYS_LDLIBS_posix_NET_no = -ltftpfs -lbsd -lz +OP_SYS_LDLIBS_kernel_NET_yes = -lCom -lnfs +OP_SYS_LDLIBS_kernel_NET_no = -lCom -lnfs +OP_SYS_LDLIBS += -lrtemsCom -lCom -lc -lrtemscpu $(OP_SYS_LDLIBS_$(OS_API)_NET_$(RTEMS_HAS_NETWORKING)) -lm OP_SYS_LDFLAGS_posix = -u POSIX_Init -OP_SYS_LDFLAGS_kernel = -u Init \ +OP_SYS_LDFLAGS_kernel = $(CPU_FLAGS) -u Init \ $(PROJECT_RELEASE)/lib/no-dpmem.rel \ $(PROJECT_RELEASE)/lib/no-mp.rel \ $(PROJECT_RELEASE)/lib/no-part.rel \ diff --git a/configure/os/CONFIG.Common.RTEMS-pc386-qemu b/configure/os/CONFIG.Common.RTEMS-pc386-qemu index 684f01a19..29196ff65 100644 --- a/configure/os/CONFIG.Common.RTEMS-pc386-qemu +++ b/configure/os/CONFIG.Common.RTEMS-pc386-qemu @@ -6,6 +6,7 @@ #------------------------------------------------------- # Include definitions from RTEMS-pc386 -include $(CONFIG)/os/CONFIG.Common.RTEMS-pc386 +# For Tests overwrite it with pc686 +include $(CONFIG)/os/CONFIG.Common.RTEMS-pc686 RTEMS_QEMU_FIXUPS = YES diff --git a/configure/os/CONFIG.Common.RTEMS-pc686 b/configure/os/CONFIG.Common.RTEMS-pc686 index 7f9446e1e..882a2f3cb 100644 --- a/configure/os/CONFIG.Common.RTEMS-pc686 +++ b/configure/os/CONFIG.Common.RTEMS-pc686 @@ -4,7 +4,13 @@ # Site-specific overrides go in CONFIG_SITE.Common.RTEMS-pc686 # #------------------------------------------------------- - +# +# Author: W. Eric Norum +# Canadian Light Source +# eric@cls.usask.ca +# +# All RTEMS targets use the same Makefile fragment +# RTEMS_BSP = pc686 RTEMS_TARGET_CPU = i386 GNU_TARGET = i386-rtems @@ -24,6 +30,7 @@ include $(CONFIG)/os/CONFIG.Common.RTEMS # OP_SYS_LDFLAGS += -Wl,-Ttext,0x100000 + # This check must appear after the above include ifneq ($(RTEMS_VERSION),5) $(info *** This target is not compatible with the configured RTEMS version.) diff --git a/configure/os/CONFIG.darwin-x86.Common b/configure/os/CONFIG.darwin-x86.Common index e779f7dc1..960c74b8a 100644 --- a/configure/os/CONFIG.darwin-x86.Common +++ b/configure/os/CONFIG.darwin-x86.Common @@ -3,6 +3,7 @@ # Definitions for darwin-x86 host builds # Sites may override these definitions in CONFIG_SITE.darwin-x86.Common #------------------------------------------------------- - +#support for IPv6 etc. +OP_SYS_CFLAGS += -DHAVE_SOCKADDR_SA_LEN=1 #Include definitions common to unix hosts include $(CONFIG)/os/CONFIG.UnixCommon.Common diff --git a/configure/os/CONFIG_SITE.Common.RTEMS b/configure/os/CONFIG_SITE.Common.RTEMS index 9b44101eb..18d62ddca 100644 --- a/configure/os/CONFIG_SITE.Common.RTEMS +++ b/configure/os/CONFIG_SITE.Common.RTEMS @@ -11,9 +11,6 @@ # installation. For RTEMS 5 only the major version number is # used, but for RTEMS 4.10.2 say all 3 components are required. # -# TRAVIS-CI: -RTEMS_VERSION = 5 -RTEMS_BASE = /home/travis/.rtems # FHI: #RTEMS_VERSION = 5 diff --git a/modules/libcom/RTEMS/epicsNtp.c b/modules/libcom/RTEMS/epicsNtp.c index 8f4e70ada..9dcd6cd69 100644 --- a/modules/libcom/RTEMS/epicsNtp.c +++ b/modules/libcom/RTEMS/epicsNtp.c @@ -47,6 +47,7 @@ int epicsNtpGetTime(char *ntpIp, struct timespec *now) serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = inet_addr(ntpIp); + serv_addr.sin_port = htons( portno ); // Call up the server using its IP address and port number. diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c b/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c new file mode 100644 index 000000000..c7a05fcc5 --- /dev/null +++ b/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c @@ -0,0 +1,251 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * Author W. Eric Norum + * norume@aps.anl.gov + * 630 252 4793 + */ + +/* + * We want to access information which is + * normally hidden from application programs. + */ +#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1 + +#define epicsExportSharedSymbols +#include +#include +#include +#include +#include +#include +#include "epicsMessageQueue.h" +#include "errlog.h" + +LIBCOM_API epicsMessageQueueId epicsStdCall +epicsMessageQueueCreate(unsigned int capacity, unsigned int maximumMessageSize) +{ + rtems_status_code sc; + epicsMessageQueueId id = calloc(1, sizeof(*id)); + rtems_interrupt_level level; + static char c1 = 'a'; + static char c2 = 'a'; + static char c3 = 'a'; + + if(!id) + return NULL; + + sc = rtems_message_queue_create (rtems_build_name ('Q', c3, c2, c1), + capacity, + maximumMessageSize, + RTEMS_FIFO|RTEMS_LOCAL, + &id->id); + if (sc != RTEMS_SUCCESSFUL) { + free(id); + errlogPrintf ("Can't create message queue: %s\n", rtems_status_text (sc)); + return NULL; + } + id->maxSize = maximumMessageSize; + id->localBuf = NULL; + rtems_interrupt_disable (level); + if (c1 == 'z') { + if (c2 == 'z') { + if (c3 == 'z') { + c3 = 'a'; + } + else { + c3++; + } + c2 = 'a'; + } + else { + c2++; + } + c1 = 'a'; + } + else { + c1++; + } + rtems_interrupt_enable (level); + return id; +} + +static rtems_status_code rtems_message_queue_send_timeout( + rtems_id id, + void *buffer, + uint32_t size, + rtems_interval timeout) +{ + Message_queue_Control *the_message_queue; + Objects_Locations location; + CORE_message_queue_Status msg_status; + + the_message_queue = _Message_queue_Get( id, &location ); + switch ( location ) + { + case OBJECTS_ERROR: + return RTEMS_INVALID_ID; + + case OBJECTS_LOCAL: + msg_status = _CORE_message_queue_Send( + &the_message_queue->message_queue, + buffer, + size, + id, + NULL, + 1, + timeout + ); + + _Thread_Enable_dispatch(); + + /* + * If we had to block, then this is where the task returns + * after it wakes up. The returned status is correct for + * non-blocking operations but if we blocked, then we need + * to look at the status in our TCB. + */ + + if ( msg_status == CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT ) + msg_status = _Thread_Executing->Wait.return_code; + return _Message_queue_Translate_core_message_queue_return_code( msg_status ); + } + return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ +} + +LIBCOM_API int epicsStdCall epicsMessageQueueSend( + epicsMessageQueueId id, + void *message, + unsigned int messageSize) +{ + if (rtems_message_queue_send_timeout(id->id, message, messageSize, RTEMS_NO_TIMEOUT) == RTEMS_SUCCESSFUL) + return 0; + else + return -1; +} + +LIBCOM_API int epicsStdCall epicsMessageQueueSendWithTimeout( + epicsMessageQueueId id, + void *message, + unsigned int messageSize, + double timeout) +{ + rtems_interval delay; + extern double rtemsTicksPerSecond_double; + + /* + * Convert time to ticks + */ + if (timeout <= 0.0) + return epicsMessageQueueTrySend(id, message, messageSize); + delay = (int)(timeout * rtemsTicksPerSecond_double); + if (delay == 0) + delay++; + if (rtems_message_queue_send_timeout(id->id, message, messageSize, delay) == RTEMS_SUCCESSFUL) + return 0; + else + return -1; +} + +static int receiveMessage( + epicsMessageQueueId id, + void *buffer, + uint32_t size, + uint32_t wait, + rtems_interval delay) +{ + size_t rsize; + rtems_status_code sc; + + if (size < id->maxSize) { + if (id->localBuf == NULL) { + id->localBuf = malloc(id->maxSize); + if (id->localBuf == NULL) + return -1; + } + rsize = receiveMessage(id, id->localBuf, id->maxSize, wait, delay); + if (rsize > size) + return -1; + memcpy(buffer, id->localBuf, rsize); + } + else { + sc = rtems_message_queue_receive(id->id, buffer, &rsize, wait, delay); + if (sc != RTEMS_SUCCESSFUL) + return -1; + } + return rsize; +} + +LIBCOM_API int epicsStdCall epicsMessageQueueTryReceive( + epicsMessageQueueId id, + void *message, + unsigned int size) +{ + return receiveMessage(id, message, size, RTEMS_NO_WAIT, 0); +} + +LIBCOM_API int epicsStdCall epicsMessageQueueReceive( + epicsMessageQueueId id, + void *message, + unsigned int size) +{ + return receiveMessage(id, message, size, RTEMS_WAIT, RTEMS_NO_TIMEOUT); +} + +LIBCOM_API int epicsStdCall epicsMessageQueueReceiveWithTimeout( + epicsMessageQueueId id, + void *message, + unsigned int size, + double timeout) +{ + rtems_interval delay; + uint32_t wait; + extern double rtemsTicksPerSecond_double; + + /* + * Convert time to ticks + */ + if (timeout <= 0.0) { + wait = RTEMS_NO_WAIT; + delay = 0; + } + else { + wait = RTEMS_WAIT; + delay = (int)(timeout * rtemsTicksPerSecond_double); + if (delay == 0) + delay++; + } + return receiveMessage(id, message, size, wait, delay); +} + +LIBCOM_API int epicsStdCall epicsMessageQueuePending( + epicsMessageQueueId id) +{ + uint32_t count; + rtems_status_code sc; + + sc = rtems_message_queue_get_number_pending(id->id, &count); + if (sc != RTEMS_SUCCESSFUL) { + errlogPrintf("Message queue %x get number pending failed: %s\n", + (unsigned int)id, + rtems_status_text(sc)); + return -1; + } + return count; +} + +LIBCOM_API void epicsStdCall epicsMessageQueueShow( + epicsMessageQueueId id, + int level) +{ + int pending = epicsMessageQueuePending(id); + if (pending >= 0) + printf ("Message queue %lx -- Pending: %d\n", (unsigned long)id, pending); +} diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h b/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h new file mode 100644 index 000000000..0244a1f0b --- /dev/null +++ b/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h @@ -0,0 +1,29 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * Author W. Eric Norum + * norume@aps.anl.gov + * 630 252 4793 + */ + +/* + * Very thin shims around RTEMS routines + */ +#include + +struct epicsMessageQueueOSD { + rtems_id id; + unsigned int maxSize; + void *localBuf; + +}; +#define epicsMessageQueueDestroy(q) (rtems_message_queue_delete((q)->id)) + +#define epicsMessageQueueTrySend(q,m,l) (rtems_message_queue_send((q)->id, (m), (l)) == RTEMS_SUCCESSFUL ? 0 : -1) diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c b/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c new file mode 100644 index 000000000..3774ef2d8 --- /dev/null +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c @@ -0,0 +1,160 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * Author W. Eric Norum + * norume@aps.anl.gov + * 630 252 4793 + */ + +/* + * We want to access information which is + * normally hidden from application programs. + */ +#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1 + +#define epicsExportSharedSymbols +#include +#include +#include +#include +#include +#include +#include "epicsMessageQueue.h" +#include "errlog.h" +#include + +#include +#include +#include + +LIBCOM_API epicsMessageQueueId epicsStdCall +epicsMessageQueueCreate(unsigned int capacity, unsigned int maximumMessageSize) +{ + struct mq_attr the_attr; + epicsMessageQueueId id = (epicsMessageQueueId)calloc(1, sizeof(*id)); + + epicsAtomicIncrIntT(&id->idCnt); + sprintf(id->name, "MQ_%01d", epicsAtomicGetIntT(&id->idCnt)); + the_attr.mq_maxmsg = capacity; + the_attr.mq_msgsize = maximumMessageSize; + id->id = mq_open(id->name, O_RDWR | O_CREAT | O_EXCL, 0644, &the_attr); + if (id->id <0) { + fprintf (stderr, "Can't create message queue: %s\n", strerror (errno)); + return NULL; + } + return id; +} + +LIBCOM_API void epicsStdCall epicsMessageQueueDestroy( + epicsMessageQueueId id) +{ + int rv; + rv = mq_close(id->id); + if( rv ) { + fprintf(stderr, "epicsMessageQueueDestroy mq_close failed: %s\n", + strerror(rv)); + } + rv = mq_unlink(id->name); + if( rv ) { + fprintf(stderr,"epicsMessageQueueDestroy mq_unlink %s failed: %s\n", + id->name, strerror(rv)); + } + free(id); +} + + +LIBCOM_API int epicsStdCall epicsMessageQueueTrySend( + epicsMessageQueueId id, + void *message, + unsigned int messageSize) +{ + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + return mq_timedsend(id->id, (char const *)message, messageSize, 0, &ts); +} + +LIBCOM_API int epicsStdCall epicsMessageQueueSendWithTimeout( + epicsMessageQueueId id, + void *message, + unsigned int messageSize, + double timeout) +{ + struct timespec ts; + unsigned long micros; + + // assume timeout in sec + micros = (unsigned long)(timeout * 1000000.0); + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += micros / 1000000L; + ts.tv_nsec += (micros % 1000000L) * 1000L; + + return mq_timedsend (id->id, (const char *)message, messageSize, 0, &ts); +} + +LIBCOM_API int epicsStdCall epicsMessageQueueTryReceive( + epicsMessageQueueId id, + void *message, + unsigned int size) +{ + struct timespec ts; + clock_gettime(CLOCK_REALTIME, &ts); + return mq_timedreceive(id->id, (char *)message, size, NULL, &ts); +} + +LIBCOM_API int epicsStdCall epicsMessageQueueReceiveWithTimeout( + epicsMessageQueueId id, + void *message, + unsigned int size, + double timeout) +{ + unsigned long micros; + struct timespec ts; + + micros = (unsigned long)(timeout * 1000000.0); + clock_gettime(CLOCK_REALTIME, &ts); + ts.tv_sec += micros / 1000000L; + ts.tv_nsec += (micros % 1000000L) * 1000L; + + return mq_timedreceive(id->id, (char *)message, size, NULL, &ts); +} + +LIBCOM_API int epicsStdCall epicsMessageQueuePending( + epicsMessageQueueId id) +{ + int rv; + struct mq_attr the_attr; + + rv = mq_getattr(id->id, &the_attr); + if (rv) { + fprintf(stderr, "Epics Message queue %x (%s) get attr failed: %s\n", + (unsigned int)id->id, id->name, strerror(rv)); + return -1; + } + return the_attr.mq_curmsgs; +} +LIBCOM_API void epicsStdCall epicsMessageQueueShow( + epicsMessageQueueId id, + int level) +{ + int rv; + struct mq_attr the_attr; + + rv = mq_getattr(id->id, &the_attr); + if (rv) { + fprintf(stderr, "Epics Message queue %x (%s) get attr failed: %s\n", + (unsigned int)id->id, id->name, strerror(rv)); + } + + printf("Message Queue Used:%ld Max Msg:%lu", the_attr.mq_curmsgs, the_attr.mq_maxmsg); + if (level >= 1) + printf(" Maximum size:%lu", the_attr.mq_msgsize); + + printf("\n"); +} diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h b/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h new file mode 100644 index 000000000..0311ee486 --- /dev/null +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h @@ -0,0 +1,29 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE Versions 3.13.7 +* and higher are distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * Author W. Eric Norum + * norume@aps.anl.gov + * 630 252 4793 + */ + +/* + * Very thin shims around RTEMS routines + */ +#include +#include + +struct epicsMessageQueueOSD { + mqd_t id; + char name[24]; + int idCnt; + +}; +#define epicsMessageQueueSend(q,m,l) (mq_send((q)->id, (const char*)(m), (l), 0)) +#define epicsMessageQueueReceive(q,m,s) (mq_receive((q)->id, (char*)(m), (s), NULL)) \ No newline at end of file From 9f387b9675d5bc4fba44740ecd78d0c2bb1a747a Mon Sep 17 00:00:00 2001 From: Heinz Junkes Date: Tue, 8 Sep 2020 11:48:03 +0200 Subject: [PATCH 023/195] Prepared RTEMS 4.10 posix with network --- modules/libcom/RTEMS/posix/rtems_config.c | 20 ++- modules/libcom/RTEMS/posix/rtems_init.c | 77 ++++++++++- modules/libcom/RTEMS/posix/rtems_netconfig.c | 124 ++++++++++++++++++ .../libcom/src/osi/os/RTEMS-posix/osdMutex.c | 4 +- .../src/osi/os/RTEMS-posix/osdPoolStatus.c | 16 +++ .../libcom/src/osi/os/RTEMS-posix/osdSock.h | 10 ++ .../libcom/src/osi/os/posix/osdFindSymbol.c | 23 +++- modules/libcom/src/osi/os/posix/osdThread.c | 6 +- 8 files changed, 266 insertions(+), 14 deletions(-) create mode 100644 modules/libcom/RTEMS/posix/rtems_netconfig.c diff --git a/modules/libcom/RTEMS/posix/rtems_config.c b/modules/libcom/RTEMS/posix/rtems_config.c index 9c8e29ea3..d9448460f 100644 --- a/modules/libcom/RTEMS/posix/rtems_config.c +++ b/modules/libcom/RTEMS/posix/rtems_config.c @@ -31,12 +31,15 @@ extern void *POSIX_Init(void *argument); /* MINIMUM_STACK_SIZE == 8K */ #define CONFIGURE_EXTRA_TASK_STACKS (4000 * RTEMS_MINIMUM_STACK_SIZE) +#if __RTEMS_MAJOR__ > 4 #define CONFIGURE_FILESYSTEM_DEVFS #define CONFIGURE_FILESYSTEM_TFTPFS +#endif #define CONFIGURE_FILESYSTEM_NFS #define CONFIGURE_FILESYSTEM_IMFS -#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM +#ifndef RTEMS_LEGACY_STACK +#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM /* * Configure LibBSD. */ @@ -48,6 +51,7 @@ extern void *POSIX_Init(void *argument); #define RTEMS_BSD_CONFIG_INIT #include +#endif // not LEGACY_STACK /* * Configure RTEMS. @@ -56,7 +60,6 @@ extern void *POSIX_Init(void *argument); #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER #define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER #define CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER -#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 150 #define CONFIGURE_IMFS_ENABLE_MKFIFO 2 @@ -70,20 +73,25 @@ extern void *POSIX_Init(void *argument); #define CONFIGURE_STACK_CHECKER_ENABLED +//#if __RTEMS_MAJOR__ > 4 +#define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK #define CONFIGURE_BDBUF_BUFFER_MAX_SIZE (64 * 1024) #define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS 4 #define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE (1 * 1024 * 1024) +//#endif -/* we are using POSIX_INIT +/* we are using POSIX_INIT needed by V4 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE #define CONFIGURE_INIT_TASK_STACK_SIZE (32 * 1024) #define CONFIGURE_INIT_TASK_INITIAL_MODES RTEMS_DEFAULT_MODES #define CONFIGURE_INIT_TASK_ATTRIBUTES RTEMS_FLOATING_POINT +#endif */ //#define RTEMS_PCI_CONFIG_LIB //#define CONFIGURE_PCI_LIB PCI_LIB_AUTO +#ifndef RTEMS_LEGACY_STACK #define CONFIGURE_SHELL_COMMANDS_INIT #include @@ -127,6 +135,11 @@ extern void *POSIX_Init(void *argument); #define RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE (16 * 1024) #define RTEMS_BSD_CONFIG_SERVICE_FTPD #define RTEMS_BSD_CONFIG_FIREWALL_PF +#endif // not LEGACY_STACK + +#if __RTEMS_MAJOR__ < 5 // still needed in Version 4? +#define CONFIGURE_MAXIMUM_TASKS rtems_resource_unlimited(30) +#endif #define CONFIGURE_MAXIMUM_DRIVERS 40 @@ -150,4 +163,3 @@ extern void *POSIX_Init(void *argument); #define CONFIGURE_INIT #include - diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 16c46ba4e..4953a7e2b 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -44,8 +44,11 @@ #include #include #include +#if __RTEMS_MAJOR__ > 4 #include -#include +#else +#include +#endif #ifdef RTEMS_LEGACY_STACK #include @@ -59,8 +62,9 @@ #endif #include +#if __RTEMS_MAJOR__ > 4 #include - +#endif #include "epicsVersion.h" #include "epicsThread.h" #include "epicsTime.h" @@ -86,6 +90,7 @@ epicsEventId dhcpDone; #endif +#ifndef RTEMS_LEGACY_STACK /* these settings are needed by the rtems startup * may provide by dhcp/bootp * or environments from the "BIOS" like u-boot, motboot etc. @@ -98,6 +103,7 @@ char bootp_boot_file_name_init[128] = "/Volumes/Epics/myExample/bin/RTEMS-qoriq_ char *rtems_bsdnet_bootp_boot_file_name = bootp_boot_file_name_init; char bootp_cmdline_init[128] = "/Volumes/Epics/myExample/iocBoot/iocmyExample/st.cmd"; char *rtems_bsdnet_bootp_cmdline = bootp_cmdline_init; +#endif // not LEGACY Stack int osdNTPGet(struct timespec *now) { @@ -543,6 +549,7 @@ static void netStatCallFunc(const iocshArgBuf *args) static const iocshFuncDef heapSpaceFuncDef = {"heapSpace",0,NULL}; static void heapSpaceCallFunc(const iocshArgBuf *args) { +#if __RTEMS_MAJOR__ > 4 Heap_Information_block info; double x; @@ -553,6 +560,17 @@ static void heapSpaceCallFunc(const iocshArgBuf *args) printf("Heap space: %.1f MB\n", x / (1024 * 1024)); else printf("Heap space: %.1f kB\n", x / 1024); +#else + rtems_malloc_statistics_t s; + double x; + + malloc_get_statistics(&s); + x = s.space_available - (unsigned long)(s.lifetime_allocated - s.lifetime_freed); + if (x >= 1024*1024) + printf("Heap space: %.1f MB\n", x / (1024 * 1024)); + else + printf("Heap space: %.1f kB\n", x / 1024); +#endif // RTEMS < 5 } #ifndef OMIT_NFS_SUPPORT @@ -609,7 +627,9 @@ static void iocshRegisterRTEMS (void) #endif iocshRegister(&zonesetFuncDef, &zonesetCallFunc); iocshRegister(&rtshellFuncDef, &rtshellCallFunc); - rtems_shell_init_environment(); +#if __RTEMS_MAJOR__ > 4 + riocshRegisterRTEMStems_shell_init_environment(); +#endif } /* @@ -645,6 +665,7 @@ exitHandler(void) rtems_shutdown_executive(0); } +#ifndef RTEMS_LEGACY_STACK static char* getPrimaryNetworkInterface(void) { // lookup available network interfaces @@ -771,7 +792,7 @@ default_network_dhcpcd(void) sc = rtems_dhcpcd_start(NULL); assert(sc == RTEMS_SUCCESSFUL); } - +#endif // not RTEMS_LEGACY_STACK /* * RTEMS Startup task */ @@ -847,14 +868,17 @@ POSIX_Init (void *argument) printf("\n***** RTEMS Version: %s *****\n", rtems_get_version_string()); - - printf("\n***** Initializing network (dhcp) *****\n"); +#ifndef RTEMS_LEGACY_STACK + /* + * Start network (libbsd) + */ + printf("\n***** Initializing network (libbsd, dhcpcd) *****\n"); rtems_bsd_setlogpriority("debug"); on_exit(default_network_on_exit, NULL); /* Let other tasks run to complete background work */ default_network_set_self_prio(RTEMS_MAXIMUM_PRIORITY - 1U); - /* supress all output from bsd network initialization + /* supress all output from bsd network initialization (Info: to be switched on in production!) rtems_bsd_vprintf_handler bsd_vprintf_handler_old; bsd_vprintf_handler_old = rtems_bsd_set_vprintf_handler(rtems_bsd_vprintf_handler_mute); */ @@ -920,6 +944,25 @@ POSIX_Init (void *argument) printf("time from ntp : %s.%09ld UTC\n", timeBuff, now.tv_nsec); } } +#else // Legacy stack, old network initialization + /* + * Start network + */ + char *cp; + if ((cp = getenv("EPICS_TS_NTP_INET")) != NULL) + rtems_bsdnet_config.ntp_server[0] = cp; + if (rtems_bsdnet_config.network_task_priority == 0) + { + unsigned int p; + if (epicsThreadHighestPriorityLevelBelow(epicsThreadPriorityScanLow, &p) + == epicsThreadBooleanStatusSuccess) + { + rtems_bsdnet_config.network_task_priority = p; + } + } + printf("\n***** Initializing network (Legacy Stack) *****\n"); + rtems_bsdnet_initialize_network(); +#endif // not RTEMS_LEGACY_STACK printf("\n***** Setting up file system *****\n"); initialize_remote_filesystem(argv, initialize_local_filesystem(argv)); @@ -969,6 +1012,26 @@ POSIX_Init (void *argument) * if BSP defaults aren't configured for running tests. */ + +/* Ensure that stdio goes to serial (so it can be captured) */ +#if defined(__i386__) && !USE_COM1_AS_CONSOLE +#include +#if __RTEMS_MAJOR__ > 4 +#include +#endif + +extern int BSPPrintkPort; +void bsp_predriver_hook(void) +{ +#if __RTEMS_MAJOR__ > 4 + Console_Port_Minor = BSP_CONSOLE_PORT_COM1; +#else + BSPConsolePort = BSP_CONSOLE_PORT_COM1; +#endif + BSPPrintkPort = BSP_CONSOLE_PORT_COM1; +} +#endif + /* reboot immediately when done. */ #if defined(__i386__) && BSP_PRESS_KEY_FOR_RESET void bsp_cleanup(void) diff --git a/modules/libcom/RTEMS/posix/rtems_netconfig.c b/modules/libcom/RTEMS/posix/rtems_netconfig.c new file mode 100644 index 000000000..2dece2079 --- /dev/null +++ b/modules/libcom/RTEMS/posix/rtems_netconfig.c @@ -0,0 +1,124 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Saskatchewan +* SPDX-License-Identifier: EPICS +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * RTEMS network configuration for EPICS + * Author: W. Eric Norum + * eric.norum@usask.ca + * (306) 966-5394 + * + * This file can be copied to an application source dirctory + * and modified to override the values shown below. + */ +#include +#include +#include + +extern void rtems_bsdnet_loopattach(); +static struct rtems_bsdnet_ifconfig loopback_config = { + "lo0", /* name */ + (int (*)(struct rtems_bsdnet_ifconfig *, int))rtems_bsdnet_loopattach, /* attach function */ + NULL, /* link to next interface */ + "127.0.0.1", /* IP address */ + "255.0.0.0", /* IP net mask */ +}; + +/* + * The following conditionals select the network interface card. + * + * On RTEMS-pc386 targets all network drivers which support run-time + * probing are linked. + * On other targets the network interface specified by the board-support + * package is used. + * To use a different NIC for a particular application, copy this file to the + * application directory and make the appropriate changes. + */ +#if defined(__i386__) + +/* no more support for ne2kpci_driver ? */ + +extern int rtems_fxp_attach (struct rtems_bsdnet_ifconfig *, int); +static struct rtems_bsdnet_ifconfig fxp_driver_config = { + "fxp1", /* name */ + rtems_fxp_attach, /* attach function */ + &loopback_config, /* link to next interface */ +}; +extern int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *, int); +static struct rtems_bsdnet_ifconfig e3c509_driver_config = { + "ep0", /* name */ + rtems_3c509_driver_attach, /* attach function */ + &fxp_driver_config, /* link to next interface */ +}; +#define FIRST_DRIVER_CONFIG &e3c509_driver_config +#else + +# if defined(__PPC) + /* + * FIXME: This really belongs in the BSP + */ +# ifndef RTEMS_BSP_NETWORK_DRIVER_NAME +# define RTEMS_BSP_NETWORK_DRIVER_NAME "dc1" +# endif +# ifndef RTEMS_BSP_NETWORK_DRIVER_ATTACH +# define RTEMS_BSP_NETWORK_DRIVER_ATTACH rtems_dec21140_driver_attach + extern int rtems_dec21140_driver_attach(); +# endif +# endif + +static struct rtems_bsdnet_ifconfig bsp_driver_config = { + RTEMS_BSP_NETWORK_DRIVER_NAME, /* name */ + RTEMS_BSP_NETWORK_DRIVER_ATTACH, /* attach function */ + &loopback_config, /* link to next interface */ +}; +#define FIRST_DRIVER_CONFIG &bsp_driver_config + +#endif + +/* + * Allow configure/os/CONFIG_SITE.Common.RTEMS to provide domain name + */ +#ifdef RTEMS_NETWORK_CONFIG_DNS_DOMAINNAME +# define XSTR(x) STR(x) +# define STR(x) #x +# define MY_DOMAINNAME XSTR(RTEMS_NETWORK_CONFIG_DNS_DOMAINNAME) +#else +# define MY_DOMAINNAME NULL +#endif + +/* + * Allow non-BOOTP network configuration + */ +#ifndef MY_DO_BOOTP +# define MY_DO_BOOTP rtems_bsdnet_do_bootp +#endif + +/* + * Allow site- and BSP-specific network buffer space configuration. + * The macro values are specified in KBytes. + */ +#ifndef RTEMS_NETWORK_CONFIG_MBUF_SPACE +# define RTEMS_NETWORK_CONFIG_MBUF_SPACE 180 +#endif +#ifndef RTEMS_NETWORK_CONFIG_CLUSTER_SPACE +# define RTEMS_NETWORK_CONFIG_CLUSTER_SPACE 350 +#endif + +/* + * Network configuration + */ +struct rtems_bsdnet_config rtems_bsdnet_config = { + FIRST_DRIVER_CONFIG, /* Link to next interface */ + MY_DO_BOOTP, /* How to find network config */ + 10, /* If 0 then the network daemons will run at a */ + /* priority just less than the lowest-priority */ + /* EPICS scan thread. */ + /* If non-zero then the network daemons will run */ + /* at this *RTEMS* priority */ + RTEMS_NETWORK_CONFIG_MBUF_SPACE*1024, + RTEMS_NETWORK_CONFIG_CLUSTER_SPACE*1024, + NULL, /* Host name */ + MY_DOMAINNAME, /* Domain name */ +}; diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdMutex.c b/modules/libcom/src/osi/os/RTEMS-posix/osdMutex.c index 09b02e0a2..2ee16bf88 100644 --- a/modules/libcom/src/osi/os/RTEMS-posix/osdMutex.c +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdMutex.c @@ -1,6 +1,8 @@ #include #include #include +#ifndef RTEMS_LEGACY_STACK #include +#endif -#include "../posix/osdMutex.c" \ No newline at end of file +#include "../posix/osdMutex.c" diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdPoolStatus.c b/modules/libcom/src/osi/os/RTEMS-posix/osdPoolStatus.c index 43d2e2b28..5b202fd1d 100644 --- a/modules/libcom/src/osi/os/RTEMS-posix/osdPoolStatus.c +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdPoolStatus.c @@ -13,6 +13,21 @@ #define epicsExportSharedSymbols #include "osiPoolStatus.h" +#if __RTEMS_MAJOR__<5 +/* + * * osiSufficentSpaceInPool () + * */ +LIBCOM_API int epicsStdCall osiSufficentSpaceInPool ( size_t contiguousBlockSize ) +{ + rtems_malloc_statistics_t s; + unsigned long n; + + malloc_get_statistics(&s); + n = s.space_available - (unsigned long)(s.lifetime_allocated - s.lifetime_freed); + return (n > (50000 + contiguousBlockSize)); +} + +#else /* * osiSufficentSpaceInPool () */ @@ -25,3 +40,4 @@ LIBCOM_API int epicsStdCall osiSufficentSpaceInPool ( size_t contiguousBlockSize n = info.Stats.size - (unsigned long)(info.Stats.lifetime_allocated - info.Stats.lifetime_freed); return (n > (50000 + contiguousBlockSize)); } +#endif diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h b/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h index 315c460dd..925fa6899 100644 --- a/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h @@ -28,7 +28,17 @@ #include #include /* close() and others */ +#ifdef RTEMS_LEGACY_STACK +#ifdef __cplusplus +extern "C" { +#endif +int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); + +#ifdef __cplusplus +} +#endif +#endif // LEGACY_STACK typedef int SOCKET; #define INVALID_SOCKET (-1) #define SOCKERRNO errno diff --git a/modules/libcom/src/osi/os/posix/osdFindSymbol.c b/modules/libcom/src/osi/os/posix/osdFindSymbol.c index 6c26696c8..09cd7a432 100644 --- a/modules/libcom/src/osi/os/posix/osdFindSymbol.c +++ b/modules/libcom/src/osi/os/posix/osdFindSymbol.c @@ -7,9 +7,29 @@ \*************************************************************************/ /* osi/os/posix/osdFindSymbol.c */ +#include "epicsFindSymbol.h" + +/* RTEMS posix but without libbsd */ +#ifdef RTEMS_LEGACY_STACK +LIBCOM_API void * epicsLoadLibrary(const char *name) +{ + return 0; +} + +LIBCOM_API const char *epicsLoadError(void) +{ + return "epicsLoadLibrary not implemented"; +} + +LIBCOM_API void * epicsStdCall epicsFindSymbol(const char *name) +{ + return 0; +} + +#else + #include -#include "epicsFindSymbol.h" /* non-POSIX extension available on Linux (glibc at least) and OSX. */ @@ -31,3 +51,4 @@ LIBCOM_API void * epicsStdCall epicsFindSymbol(const char *name) { return dlsym(RTLD_DEFAULT, name); } +#endif // RTEMS_LEGACY_STACK diff --git a/modules/libcom/src/osi/os/posix/osdThread.c b/modules/libcom/src/osi/os/posix/osdThread.c index fe375fd16..41f46479e 100644 --- a/modules/libcom/src/osi/os/posix/osdThread.c +++ b/modules/libcom/src/osi/os/posix/osdThread.c @@ -25,7 +25,9 @@ #include #if defined(_POSIX_MEMLOCK) && _POSIX_MEMLOCK > 0 -#include +#ifndef RTEMS_LEGACY_STACK // seems to be part of libbsd? +#include +#endif // LEGACY STACK #endif #include "epicsStdio.h" @@ -426,6 +428,7 @@ LIBCOM_API void epicsThreadRealtimeLock(void) { #if defined(_POSIX_MEMLOCK) && _POSIX_MEMLOCK > 0 +#ifndef RTEMS_LEGACY_STACK // seems to be part of libbsd? if (pcommonAttr->maxPriority > pcommonAttr->minPriority) { int status = mlockall(MCL_CURRENT | MCL_FUTURE); @@ -450,6 +453,7 @@ void epicsThreadRealtimeLock(void) } } } +#endif // LEGACY STACK #endif } From a718357211ef918ce92220800de23e35431593ef Mon Sep 17 00:00:00 2001 From: Heinz Junkes Date: Tue, 22 Sep 2020 21:45:42 +0200 Subject: [PATCH 024/195] Fixed stupid typo in CONFIG.Common.RTEMS --- modules/libcom/RTEMS/posix/rtems_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 4953a7e2b..1c552a535 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -628,7 +628,7 @@ static void iocshRegisterRTEMS (void) iocshRegister(&zonesetFuncDef, &zonesetCallFunc); iocshRegister(&rtshellFuncDef, &rtshellCallFunc); #if __RTEMS_MAJOR__ > 4 - riocshRegisterRTEMStems_shell_init_environment(); + rtems_shell_init_environment(); #endif } From 97ce6aecc70a875e03af82ab97a61cc4562b293a Mon Sep 17 00:00:00 2001 From: Heinz Junkes Date: Sat, 26 Sep 2020 21:45:00 +0200 Subject: [PATCH 025/195] cleanup netconfig --- modules/libcom/RTEMS/Makefile | 7 +- modules/libcom/RTEMS/epicsRtemsInitHookPost.c | 3 +- modules/libcom/RTEMS/epicsRtemsInitHookPre.c | 3 +- modules/libcom/RTEMS/epicsRtemsInitHooks.h | 4 + .../RTEMS/posix/epicsRtemsInitHookPost.c | 18 - .../RTEMS/posix/epicsRtemsInitHookPre.c | 18 - .../libcom/RTEMS/posix/epicsRtemsInitHooks.h | 24 -- modules/libcom/RTEMS/posix/libbsd_netconfig.c | 116 ------ modules/libcom/RTEMS/posix/libbsd_netconfig.h | 24 -- modules/libcom/RTEMS/posix/rtems_config.c | 2 - modules/libcom/RTEMS/posix/rtems_init.c | 72 ++-- modules/libcom/RTEMS/posix/rtems_netconfig.c | 124 ------ .../RTEMS/posix/setBootConfigFromNVRAM.c | 369 ------------------ .../RTEMS/{kernel => }/rtems_netconfig.c | 14 +- modules/libcom/RTEMS/setBootConfigFromNVRAM.c | 13 +- 15 files changed, 59 insertions(+), 752 deletions(-) delete mode 100644 modules/libcom/RTEMS/posix/epicsRtemsInitHookPost.c delete mode 100644 modules/libcom/RTEMS/posix/epicsRtemsInitHookPre.c delete mode 100644 modules/libcom/RTEMS/posix/epicsRtemsInitHooks.h delete mode 100644 modules/libcom/RTEMS/posix/libbsd_netconfig.c delete mode 100644 modules/libcom/RTEMS/posix/libbsd_netconfig.h delete mode 100644 modules/libcom/RTEMS/posix/rtems_netconfig.c delete mode 100644 modules/libcom/RTEMS/posix/setBootConfigFromNVRAM.c rename modules/libcom/RTEMS/{kernel => }/rtems_netconfig.c (95%) diff --git a/modules/libcom/RTEMS/Makefile b/modules/libcom/RTEMS/Makefile index 87bf43db3..e1ac0ed04 100644 --- a/modules/libcom/RTEMS/Makefile +++ b/modules/libcom/RTEMS/Makefile @@ -25,11 +25,7 @@ rtems_init_CPPFLAGS += -DQEMU_FIXUPS endif rtemsCom_SRCS += rtems_init.c rtemsCom_SRCS += rtems_config.c -ifeq ($(RTEMS_HAS_NETWORKING), yes) rtemsCom_SRCS += rtems_netconfig.c -else -rtemsCom_SRCS += libbsd_netconfig.c -endif rtemsCom_SRCS += rtems_util.c rtemsCom_SRCS += setBootConfigFromNVRAM.c rtemsCom_SRCS += epicsRtemsInitHookPre.c @@ -40,6 +36,9 @@ rtemsCom_SRCS += epicsNtp.c ifeq ($(RTEMS_TARGET_CPU),i386) rtemsCom_SRCS += ne2kpci.c endif +ifeq ($(RTEMS_BSP),pc686) +rtemsCom_SRCS += ne2kpci.c +endif LIBRARY_RTEMS = rtemsCom diff --git a/modules/libcom/RTEMS/epicsRtemsInitHookPost.c b/modules/libcom/RTEMS/epicsRtemsInitHookPost.c index ba14aae4c..674c32662 100644 --- a/modules/libcom/RTEMS/epicsRtemsInitHookPost.c +++ b/modules/libcom/RTEMS/epicsRtemsInitHookPost.c @@ -10,9 +10,10 @@ * Dummy version -- use if application does not provide its own version */ #include "epicsRtemsInitHooks.h" - +#ifdef RTEMS_LEGACY_STACK int epicsRtemsInitPostSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config) { return 0; } +#endif diff --git a/modules/libcom/RTEMS/epicsRtemsInitHookPre.c b/modules/libcom/RTEMS/epicsRtemsInitHookPre.c index 4c8544745..b84fa7ac3 100644 --- a/modules/libcom/RTEMS/epicsRtemsInitHookPre.c +++ b/modules/libcom/RTEMS/epicsRtemsInitHookPre.c @@ -10,9 +10,10 @@ * Dummy version -- use if application does not provide its own version */ #include "epicsRtemsInitHooks.h" - +#ifdef RTEMS_LEGACY_STACK int epicsRtemsInitPreSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config) { return 0; } +#endif diff --git a/modules/libcom/RTEMS/epicsRtemsInitHooks.h b/modules/libcom/RTEMS/epicsRtemsInitHooks.h index cdbc74315..e08b7fa35 100644 --- a/modules/libcom/RTEMS/epicsRtemsInitHooks.h +++ b/modules/libcom/RTEMS/epicsRtemsInitHooks.h @@ -10,7 +10,9 @@ * Hooks into RTEMS startup code */ #include +#ifdef RTEMS_LEGACY_STACK #include +#endif extern char *env_nfsServer; extern char *env_nfsPath; @@ -23,8 +25,10 @@ extern "C" { /* * Return 0 for success, non-zero for failure (will cause panic) */ +#ifdef RTEMS_LEGACY_STACK int epicsRtemsInitPreSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config); int epicsRtemsInitPostSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config); +#endif /* Return 0 if local file system was setup, or non-zero (will fall back to network */ int epicsRtemsMountLocalFilesystem(char **argv); diff --git a/modules/libcom/RTEMS/posix/epicsRtemsInitHookPost.c b/modules/libcom/RTEMS/posix/epicsRtemsInitHookPost.c deleted file mode 100644 index f589eb9cf..000000000 --- a/modules/libcom/RTEMS/posix/epicsRtemsInitHookPost.c +++ /dev/null @@ -1,18 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2006 The University of Chicago, as Operator of Argonne -* National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ - -/* - * Dummy version -- use if application does not provide its own version - */ -#include "epicsRtemsInitHooks.h" - -int -epicsRtemsInitPostSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config) -{ - return 0; -} diff --git a/modules/libcom/RTEMS/posix/epicsRtemsInitHookPre.c b/modules/libcom/RTEMS/posix/epicsRtemsInitHookPre.c deleted file mode 100644 index 08efe1fe2..000000000 --- a/modules/libcom/RTEMS/posix/epicsRtemsInitHookPre.c +++ /dev/null @@ -1,18 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2006 The University of Chicago, as Operator of Argonne -* National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ - -/* - * Dummy version -- use if application does not provide its own version - */ -#include "epicsRtemsInitHooks.h" - -int -epicsRtemsInitPreSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config) -{ - return 0; -} diff --git a/modules/libcom/RTEMS/posix/epicsRtemsInitHooks.h b/modules/libcom/RTEMS/posix/epicsRtemsInitHooks.h deleted file mode 100644 index 8671bebbf..000000000 --- a/modules/libcom/RTEMS/posix/epicsRtemsInitHooks.h +++ /dev/null @@ -1,24 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2006 The University of Chicago, as Operator of Argonne -* National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ - -/* - * Hooks into RTEMS startup code - */ -#include - -extern char *env_nfsServer; -extern char *env_nfsPath; -extern char *env_nfsMountPoint; - -/* - * Return 0 for success, non-zero for failure (will cause panic) - */ -int epicsRtemsInitPreSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config); -int epicsRtemsInitPostSetBootConfigFromNVRAM(struct rtems_bsdnet_config *config); -/* Return 0 if local file system was setup, or non-zero (will fall back to network */ -int epicsRtemsMountLocalFilesystem(char **argv); diff --git a/modules/libcom/RTEMS/posix/libbsd_netconfig.c b/modules/libcom/RTEMS/posix/libbsd_netconfig.c deleted file mode 100644 index d9c9f704d..000000000 --- a/modules/libcom/RTEMS/posix/libbsd_netconfig.c +++ /dev/null @@ -1,116 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2002 The University of Saskatchewan -* EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ -/* - * RTEMS network configuration for EPICS - * Author: W. Eric Norum - * eric.norum@usask.ca - * (306) 966-5394 - * - * This file can be copied to an application source dirctory - * and modified to override the values shown below. - */ -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include - -#include "libbsd_netconfig.h" - -#include -#include - -#define IFACE_IPV4_DHCP(iface) \ - "ifconfig_" # iface "=\"SYNCDHCP\"\n" - -#define IFACE_IPV4(iface, addr) \ - "ifconfig_" # iface "=\"inet " # addr " netmask 255.255.255.0\"\n" - -static const char* rc_conf_text = \ - "\n" \ - "syslog_priority=\"debug\"\n" \ - "\n" \ - "#create_args_myvlan=\"vlan 102\"\n" \ - "#create_args_yourvlan=\"vlan 202\"\n" \ - IFACE_IPV4_DHCP(cgem0) \ - "\n" \ - "dhcpcd_priority=\"100\"\n" \ - "\n" \ - "#defaultrouter=\"" NET_CFG_GATEWAY_IP "\"\n" \ - "defaultroute_delay=\"5\"\n" \ - "\n" \ - "#telnetd_enable=\"YES\"\n" \ - "#telnetd_options=\"-C 2 -P 100 \"\n" \ - "\n" \ - "#ftpd_enable=\"YES\"\n" \ - "#ftpd_options=\"-v -p 21 -C 2 -P 150 -L -I 10 -R /\"\n" \ - "\n" \ - "#pf_enable=\"YES\"\n" \ - "#pf_rules=\"/etc/mypf.conf\"\n" \ - "#pf_flags=\"-q -z\"\n" \ - "\n"; - -static const char* dhcpcd_conf_text = \ - "\n" \ -"clientid RTEMS test client\n" \ -"\n" \ -"nodhcp6\n" \ -"ipv4only\n" \ -"option ntp_servers\n" \ -"option rtems_cmdline\n"; - -int -epicsRtemsPrepareAndRunRCConfFile(void) -{ - size_t len; - size_t written; - int fd; - int rv; - struct stat sb; - - mkdir("/etc", S_IRWXU | S_IRWXG | S_IRWXO); /* ignore errors, check the dir after. */ - assert(stat("/etc", &sb) == 0); - assert(S_ISDIR(sb.st_mode)); - - printf("--------------- dhcpcd.conf -----------------\n"); - printf(dhcpcd_conf_text); - printf("-----------------------------------------\n"); - - len = strlen(dhcpcd_conf_text); - fd = open("/etc/dhcpcd.conf", O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); - assert(fd != -1); - written = write(fd, dhcpcd_conf_text, len); - assert(written == len); - rv = close(fd); - assert(rv == 0); - - printf("--------------- rc.conf -----------------\n"); - printf(rc_conf_text); - printf("-----------------------------------------\n"); - - len = strlen(rc_conf_text); - fd = open("/etc/rc.conf", O_WRONLY | O_CREAT, S_IRWXU | S_IRWXG | S_IRWXO); - assert(fd != -1); - written = write(fd, rc_conf_text, len); - assert(written == len); - rv = close(fd); - assert(rv == 0); - - return (rtems_bsd_run_etc_rc_conf(20, true)); -} diff --git a/modules/libcom/RTEMS/posix/libbsd_netconfig.h b/modules/libcom/RTEMS/posix/libbsd_netconfig.h deleted file mode 100644 index b253b652d..000000000 --- a/modules/libcom/RTEMS/posix/libbsd_netconfig.h +++ /dev/null @@ -1,24 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2002 The University of Saskatchewan -* EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ -/* - * RTEMS network configuration header for EPICS - * - * This file can be copied to an application source dirctory - * and modified to override the values shown below. - */ -#include -#include - -#define NET_CFG_INTERFACE_0 "cgem0" -#define DEFAULT_NETWORK_DHCPCD_ENABLE -#define DEFAULT_NETWORK_NO_INTERFACE_0 - -// Tests -#define NET_CFG_SELF_IP "141.14.128.89" -#define NET_CFG_NETMASK "255.255.240.0" -#define NET_CFG_GATEWAY_IP "141.14.128.128" - -int epicsRtemsPrepareAndRunRCConfFile(void); diff --git a/modules/libcom/RTEMS/posix/rtems_config.c b/modules/libcom/RTEMS/posix/rtems_config.c index d9448460f..bba6fc9d9 100644 --- a/modules/libcom/RTEMS/posix/rtems_config.c +++ b/modules/libcom/RTEMS/posix/rtems_config.c @@ -73,12 +73,10 @@ extern void *POSIX_Init(void *argument); #define CONFIGURE_STACK_CHECKER_ENABLED -//#if __RTEMS_MAJOR__ > 4 #define CONFIGURE_APPLICATION_NEEDS_LIBBLOCK #define CONFIGURE_BDBUF_BUFFER_MAX_SIZE (64 * 1024) #define CONFIGURE_BDBUF_MAX_READ_AHEAD_BLOCKS 4 #define CONFIGURE_BDBUF_CACHE_MEMORY_SIZE (1 * 1024 * 1024) -//#endif /* we are using POSIX_INIT needed by V4 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 1c552a535..f7d2a1c2c 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -57,7 +57,6 @@ #include #include #include -#include "libbsd_netconfig.h" #include #endif @@ -102,7 +101,7 @@ char *rtems_bsdnet_bootp_server_name = bootp_server_name_init; char bootp_boot_file_name_init[128] = "/Volumes/Epics/myExample/bin/RTEMS-qoriq_e500/myExample.boot"; char *rtems_bsdnet_bootp_boot_file_name = bootp_boot_file_name_init; char bootp_cmdline_init[128] = "/Volumes/Epics/myExample/iocBoot/iocmyExample/st.cmd"; -char *rtems_bsdnet_bootp_cmdline = bootp_cmdline_init; +char *rtems_bootp_cmdline = bootp_cmdline_init; #endif // not LEGACY Stack int osdNTPGet(struct timespec *now) @@ -230,9 +229,11 @@ epicsRtemsMountLocalFilesystem(char **argv) static int initialize_local_filesystem(char **argv) { + /* extern char _DownloadLocation[] __attribute__((weak)); extern char _FlashBase[] __attribute__((weak)); extern char _FlashSize[] __attribute__((weak)); + */ argv[0] = rtems_bsdnet_bootp_boot_file_name; if (epicsRtemsMountLocalFilesystem(argv)==0) { @@ -250,13 +251,13 @@ initialize_local_filesystem(char **argv) printf("Can't unpack tar filesystem\n"); return 0; } - if ((fd = open(rtems_bsdnet_bootp_cmdline, 0)) >= 0) { + if ((fd = open(rtems_bootp_cmdline, 0)) >= 0) { close(fd); - printf ("***** Found startup script (%s) in IMFS *****\n", rtems_bsdnet_bootp_cmdline); - argv[1] = rtems_bsdnet_bootp_cmdline; + printf ("***** Found startup script (%s) in IMFS *****\n", rtems_bootp_cmdline); + argv[1] = rtems_bootp_cmdline; return 1; } - printf ("***** Startup script (%s) not in IMFS *****\n", rtems_bsdnet_bootp_cmdline); + printf ("***** Startup script (%s) not in IMFS *****\n", rtems_bootp_cmdline); } } */ return 0; @@ -335,7 +336,7 @@ initialize_remote_filesystem(char **argv, int hasLocalFilesystem) mount_point, strerror(errno)); *cp = '/'; } - argv[1] = rtems_bsdnet_bootp_cmdline; + argv[1] = rtems_bootp_cmdline; } else if (hasLocalFilesystem) { return; @@ -347,23 +348,22 @@ initialize_remote_filesystem(char **argv, int hasLocalFilesystem) * if the pathname does not begin with a '/'. This allows * NFS and TFTP to have a similar view of the remote system. */ - if (rtems_bsdnet_bootp_cmdline[0] == '/') - cp = rtems_bsdnet_bootp_cmdline + 1; + if (rtems_bootp_cmdline[0] == '/') + cp = rtems_bootp_cmdline + 1; else - cp = rtems_bsdnet_bootp_cmdline; + cp = rtems_bootp_cmdline; cp = strchr(cp, '/'); if ((cp == NULL) - || ((l = cp - rtems_bsdnet_bootp_cmdline) == 0)) - LogFatal("\"%s\" is not a valid command pathname.\n", rtems_bsdnet_bootp_cmdline); + || ((l = cp - rtems_bootp_cmdline) == 0)) + LogFatal("\"%s\" is not a valid command pathname.\n", rtems_bootp_cmdline); cp = mustMalloc(l + 20, "NFS mount paths"); server_path = cp; -printf( " rtems_bootp_server_name: %s\n",rtems_bsdnet_bootp_server_name); server_name = rtems_bsdnet_bootp_server_name; - if (rtems_bsdnet_bootp_cmdline[0] == '/') { + if (rtems_bootp_cmdline[0] == '/') { mount_point = server_path; - strncpy(mount_point, rtems_bsdnet_bootp_cmdline, l); + strncpy(mount_point, rtems_bootp_cmdline, l); mount_point[l] = '\0'; - argv[1] = rtems_bsdnet_bootp_cmdline; + argv[1] = rtems_bootp_cmdline; /* * Its probably common to embed the mount point in the server * name so, when this is occurring, dont clobber the mount point @@ -400,14 +400,14 @@ printf( " rtems_bootp_server_name: %s\n",rtems_bsdnet_bootp_server_name); } } else { - char *abspath = mustMalloc(strlen(rtems_bsdnet_bootp_cmdline)+2,"Absolute command path"); + char *abspath = mustMalloc(strlen(rtems_bootp_cmdline)+2,"Absolute command path"); strcpy(server_path, "/tftpboot/"); mount_point = server_path + strlen(server_path); - strncpy(mount_point, rtems_bsdnet_bootp_cmdline, l); + strncpy(mount_point, rtems_bootp_cmdline, l); mount_point[l] = '\0'; mount_point--; strcpy(abspath, "/"); - strcat(abspath, rtems_bsdnet_bootp_cmdline); + strcat(abspath, rtems_bootp_cmdline); argv[1] = abspath; } } @@ -689,7 +689,7 @@ dhcpcd_hook_handler(rtems_dhcpcd_hook *hook, char *const *env) (void)hook; char ifnamebuf[IF_NAMESIZE]; - *ifnamebuf = getPrimaryNetworkInterface(); + sprintf(ifnamebuf, "%s", getPrimaryNetworkInterface()); while (*env != NULL) { name = strtok(*env,"="); @@ -719,8 +719,8 @@ dhcpcd_hook_handler(rtems_dhcpcd_hook *hook, char *const *env) } if(!strncmp(name, "new_rtems_cmdline", 20)){ //printf(" new_rtems_cmdline : %s\n", value); - strncpy(rtems_bsdnet_bootp_cmdline,value, sizeof(bootp_cmdline_init)); - printf(" rtems_bsdnet_bootp_cmdline : %s\n", rtems_bsdnet_bootp_cmdline); + strncpy(rtems_bootp_cmdline,value, sizeof(bootp_cmdline_init)); + printf(" rtems_bootp_cmdline : %s\n", rtems_bootp_cmdline); } // printf("---> %s = %s\n", name, value); } @@ -822,7 +822,8 @@ POSIX_Init (void *argument) // set time to 14.4.2014 now.tv_sec = 1397460606; now.tv_nsec = 0; - if (clock_settime(CLOCK_REALTIME, &now) < 0) + sc = clock_settime(CLOCK_REALTIME, &now); + if (sc < 0) printf ("***** Can't set time: %s\n", rtems_status_text (sc)); } if ( clock_gettime( CLOCK_REALTIME, &now) < 0) { @@ -839,6 +840,8 @@ POSIX_Init (void *argument) /* TBD ... * Architecture-specific hooks + */ +#ifdef RTEMS_LEGACY_STACK if (epicsRtemsInitPreSetBootConfigFromNVRAM(&rtems_bsdnet_config) != 0) delayedPanic("epicsRtemsInitPreSetBootConfigFromNVRAM"); if (rtems_bsdnet_config.bootp == NULL) { @@ -848,8 +851,7 @@ POSIX_Init (void *argument) if (epicsRtemsInitPostSetBootConfigFromNVRAM(&rtems_bsdnet_config) != 0) delayedPanic("epicsRtemsInitPostSetBootConfigFromNVRAM"); - */ - +#endif /* * Override RTEMS Posix configuration, it gets started with posix prio 2 */ @@ -904,9 +906,6 @@ POSIX_Init (void *argument) dhcpDone = epicsEventMustCreate(epicsEventEmpty); rtems_dhcpcd_add_hook(&dhcpcd_hook); - /* use /etc/rc.conf, /etc/dhclient.conf ... */ - //epicsRtemsPrepareAndRunRCConfFile(); - // wait for dhcp done ... should be if SYNCDHCP is used epicsEventWaitStatus stat; int counter = 10; @@ -1027,6 +1026,7 @@ void bsp_predriver_hook(void) Console_Port_Minor = BSP_CONSOLE_PORT_COM1; #else BSPConsolePort = BSP_CONSOLE_PORT_COM1; + #endif BSPPrintkPort = BSP_CONSOLE_PORT_COM1; } @@ -1044,19 +1044,3 @@ void bsp_cleanup(void) #endif /* QEMU_FIXUPS */ int cexpdebug __attribute__((weak)); - -/* defines in rtems_config.c -#define CONFIGURE_SHELL_COMMANDS_INIT -#define CONFIGURE_SHELL_COMMANDS_ALL -// exclude commands which won't work right with our configuration -#define CONFIGURE_SHELL_NO_COMMAND_EXIT -#define CONFIGURE_SHELL_NO_COMMAND_LOGOFF -// exclude commands which unnecessarily pull in block driver -#define CONFIGURE_SHELL_NO_COMMAND_MSDOSFMT -#define CONFIGURE_SHELL_NO_COMMAND_BLKSYNC -#define CONFIGURE_SHELL_NO_COMMAND_MKRFS -#define CONFIGURE_SHELL_NO_COMMAND_DEBUGRFS -#define CONFIGURE_SHELL_NO_COMMAND_FDISK - -#include -*/ diff --git a/modules/libcom/RTEMS/posix/rtems_netconfig.c b/modules/libcom/RTEMS/posix/rtems_netconfig.c deleted file mode 100644 index 2dece2079..000000000 --- a/modules/libcom/RTEMS/posix/rtems_netconfig.c +++ /dev/null @@ -1,124 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2002 The University of Saskatchewan -* SPDX-License-Identifier: EPICS -* EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ -/* - * RTEMS network configuration for EPICS - * Author: W. Eric Norum - * eric.norum@usask.ca - * (306) 966-5394 - * - * This file can be copied to an application source dirctory - * and modified to override the values shown below. - */ -#include -#include -#include - -extern void rtems_bsdnet_loopattach(); -static struct rtems_bsdnet_ifconfig loopback_config = { - "lo0", /* name */ - (int (*)(struct rtems_bsdnet_ifconfig *, int))rtems_bsdnet_loopattach, /* attach function */ - NULL, /* link to next interface */ - "127.0.0.1", /* IP address */ - "255.0.0.0", /* IP net mask */ -}; - -/* - * The following conditionals select the network interface card. - * - * On RTEMS-pc386 targets all network drivers which support run-time - * probing are linked. - * On other targets the network interface specified by the board-support - * package is used. - * To use a different NIC for a particular application, copy this file to the - * application directory and make the appropriate changes. - */ -#if defined(__i386__) - -/* no more support for ne2kpci_driver ? */ - -extern int rtems_fxp_attach (struct rtems_bsdnet_ifconfig *, int); -static struct rtems_bsdnet_ifconfig fxp_driver_config = { - "fxp1", /* name */ - rtems_fxp_attach, /* attach function */ - &loopback_config, /* link to next interface */ -}; -extern int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *, int); -static struct rtems_bsdnet_ifconfig e3c509_driver_config = { - "ep0", /* name */ - rtems_3c509_driver_attach, /* attach function */ - &fxp_driver_config, /* link to next interface */ -}; -#define FIRST_DRIVER_CONFIG &e3c509_driver_config -#else - -# if defined(__PPC) - /* - * FIXME: This really belongs in the BSP - */ -# ifndef RTEMS_BSP_NETWORK_DRIVER_NAME -# define RTEMS_BSP_NETWORK_DRIVER_NAME "dc1" -# endif -# ifndef RTEMS_BSP_NETWORK_DRIVER_ATTACH -# define RTEMS_BSP_NETWORK_DRIVER_ATTACH rtems_dec21140_driver_attach - extern int rtems_dec21140_driver_attach(); -# endif -# endif - -static struct rtems_bsdnet_ifconfig bsp_driver_config = { - RTEMS_BSP_NETWORK_DRIVER_NAME, /* name */ - RTEMS_BSP_NETWORK_DRIVER_ATTACH, /* attach function */ - &loopback_config, /* link to next interface */ -}; -#define FIRST_DRIVER_CONFIG &bsp_driver_config - -#endif - -/* - * Allow configure/os/CONFIG_SITE.Common.RTEMS to provide domain name - */ -#ifdef RTEMS_NETWORK_CONFIG_DNS_DOMAINNAME -# define XSTR(x) STR(x) -# define STR(x) #x -# define MY_DOMAINNAME XSTR(RTEMS_NETWORK_CONFIG_DNS_DOMAINNAME) -#else -# define MY_DOMAINNAME NULL -#endif - -/* - * Allow non-BOOTP network configuration - */ -#ifndef MY_DO_BOOTP -# define MY_DO_BOOTP rtems_bsdnet_do_bootp -#endif - -/* - * Allow site- and BSP-specific network buffer space configuration. - * The macro values are specified in KBytes. - */ -#ifndef RTEMS_NETWORK_CONFIG_MBUF_SPACE -# define RTEMS_NETWORK_CONFIG_MBUF_SPACE 180 -#endif -#ifndef RTEMS_NETWORK_CONFIG_CLUSTER_SPACE -# define RTEMS_NETWORK_CONFIG_CLUSTER_SPACE 350 -#endif - -/* - * Network configuration - */ -struct rtems_bsdnet_config rtems_bsdnet_config = { - FIRST_DRIVER_CONFIG, /* Link to next interface */ - MY_DO_BOOTP, /* How to find network config */ - 10, /* If 0 then the network daemons will run at a */ - /* priority just less than the lowest-priority */ - /* EPICS scan thread. */ - /* If non-zero then the network daemons will run */ - /* at this *RTEMS* priority */ - RTEMS_NETWORK_CONFIG_MBUF_SPACE*1024, - RTEMS_NETWORK_CONFIG_CLUSTER_SPACE*1024, - NULL, /* Host name */ - MY_DOMAINNAME, /* Domain name */ -}; diff --git a/modules/libcom/RTEMS/posix/setBootConfigFromNVRAM.c b/modules/libcom/RTEMS/posix/setBootConfigFromNVRAM.c deleted file mode 100644 index b029b3253..000000000 --- a/modules/libcom/RTEMS/posix/setBootConfigFromNVRAM.c +++ /dev/null @@ -1,369 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne -* National Laboratory. -* EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -char *env_nfsServer; -char *env_nfsPath; -char *env_nfsMountPoint; - -/* - * Split argument string of form nfs_server:nfs_export: - * The nfs_export component will be used as: - * - the path to the directory exported from the NFS server - * - the local mount point - * - a prefix of - * For example, the argument string: - * romeo:/export/users:smith/ioc/iocexample/st.cmd - * would: - * - mount /export/users from NFS server romeo on /export/users - * - chdir to /export/users/smith/ioc/iocexample - * - read commands from st.cmd - */ -static void -splitRtemsBsdnetBootpCmdline(void) -{ - char *cp1, *cp2, *cp3; - - if ((cp1 = rtems_bsdnet_bootp_cmdline) == NULL) - return; - if (((cp2 = strchr(cp1, ':')) != NULL) - && (((cp3 = strchr(cp2+1, ' ')) != NULL) - || ((cp3 = strchr(cp2+1, ':')) != NULL))) { - int l1 = cp2 - cp1; - int l2 = cp3 - cp2 - 1; - int l3 = strlen(cp3) - 1; - if (l1 && l2 && l3) { - *cp2++ = '\0'; - *cp3 = '\0'; - env_nfsServer = cp1; - env_nfsMountPoint = env_nfsPath = epicsStrDup(cp2); - *cp3 = '/'; - rtems_bsdnet_bootp_cmdline = cp2; - } - } -} - -/* - * Split NFS mount information of the form nfs_server:host_path:local_path - */ -static void -splitNfsMountPath(char *nfsString) -{ - char *cp2, *cp3; - - if (nfsString == NULL) - return; - if (((cp2 = strchr(nfsString, ':')) != NULL) - && (((cp3 = strchr(cp2+1, ' ')) != NULL) - || ((cp3 = strchr(cp2+1, ':')) != NULL))) { - int l1 = cp2 - nfsString; - int l2 = cp3 - cp2 - 1; - int l3 = strlen(cp3) - 1; - if (l1 && l2 && l3) { - *cp2++ = '\0'; - *cp3++ = '\0'; - env_nfsServer = nfsString; - env_nfsPath = cp2; - env_nfsMountPoint = cp3; - } - } -} - -#if defined(HAVE_MOTLOAD) - -/* - * Motorola MOTLOAD NVRAM Access - */ -static char * -gev(const char *parm, volatile char *nvp) -{ - const char *val; - const char *name; - char *ret; - char c; - - for (;;) { - if (*nvp == '\0') - return NULL; - name = parm; - while ((c = *nvp++) != '\0') { - if ((c == '=') && (*name == '\0')) { - val = (char *)nvp; - while (*nvp++ != '\0') - continue; - ret = malloc(nvp - val); - if (ret == NULL) - return NULL; - strcpy(ret, val); - return ret; - } - if (c != *name++) { - while (*nvp++ != '\0') - continue; - break; - } - } - } -} - -static char * -motScriptParm(const char *mot_script_boot, char parm) -{ - const char *cp; - char *ret; - int l; - - while (*mot_script_boot != '\0') { - if (isspace(*(unsigned char *)mot_script_boot) - && (*(mot_script_boot+1) == '-') - && (*(mot_script_boot+2) == parm)) { - mot_script_boot += 3; - cp = mot_script_boot; - while ((*mot_script_boot != '\0') && - !isspace(*(unsigned char *)mot_script_boot)) - mot_script_boot++; - l = mot_script_boot - cp; - ret = malloc(l+1); - if (ret == NULL) - return NULL; - strncpy(ret, cp, l); - *(ret+l) = '\0'; - return ret; - } - mot_script_boot++; - } - return NULL; -} - -void -setBootConfigFromNVRAM(void) -{ - char *cp; - const char *mot_script_boot; - char *nvp; - -# if defined(BSP_NVRAM_BASE_ADDR) - nvp = (volatile unsigned char *)(BSP_NVRAM_BASE_ADDR+0x70f8); -# elif defined(BSP_I2C_VPD_EEPROM_DEV_NAME) - char gev_buf[3592]; - int fd; - if ((fd = open(BSP_I2C_VPD_EEPROM_DEV_NAME, 0)) < 0) { - printf("Can't open %s: %s\n", BSP_I2C_VPD_EEPROM_DEV_NAME, strerror(errno)); - return; - } - lseek(fd, 0x10f8, SEEK_SET); - if (read(fd, gev_buf, sizeof gev_buf) != sizeof gev_buf) { - printf("Can't read %s: %s\n", BSP_I2C_VPD_EEPROM_DEV_NAME, strerror(errno)); - return; - } - close(fd); - nvp = gev_buf; -# else -# error "No way to read GEV!" -# endif - - if (rtems_bsdnet_config.bootp != NULL) - return; - mot_script_boot = gev("mot-script-boot", nvp); - if ((rtems_bsdnet_bootp_server_name = gev("mot-/dev/enet0-sipa", nvp)) == NULL) - rtems_bsdnet_bootp_server_name = motScriptParm(mot_script_boot, 's'); - if ((rtems_bsdnet_config.gateway = gev("mot-/dev/enet0-gipa", nvp)) == NULL) - rtems_bsdnet_config.gateway = motScriptParm(mot_script_boot, 'g'); - if ((rtems_bsdnet_config.ifconfig->ip_netmask = gev("mot-/dev/enet0-snma", nvp)) == NULL) - rtems_bsdnet_config.ifconfig->ip_netmask = motScriptParm(mot_script_boot, 'm'); - - rtems_bsdnet_config.name_server[0] = gev("rtems-dns-server", nvp); - if (rtems_bsdnet_config.name_server[0] == NULL) - rtems_bsdnet_config.name_server[0] = rtems_bsdnet_bootp_server_name; - cp = gev("rtems-dns-domainname", nvp); - if (cp) - rtems_bsdnet_config.domainname = cp; - - if ((rtems_bsdnet_config.ifconfig->ip_address = gev("mot-/dev/enet0-cipa", nvp)) == NULL) - rtems_bsdnet_config.ifconfig->ip_address = motScriptParm(mot_script_boot, 'c'); - rtems_bsdnet_config.hostname = gev("rtems-client-name", nvp); - if (rtems_bsdnet_config.hostname == NULL) - rtems_bsdnet_config.hostname = rtems_bsdnet_config.ifconfig->ip_address; - - if ((rtems_bsdnet_bootp_boot_file_name = gev("mot-/dev/enet0-file", nvp)) == NULL) - rtems_bsdnet_bootp_boot_file_name = motScriptParm(mot_script_boot, 'f'); - rtems_bsdnet_bootp_cmdline = gev("epics-script", nvp); - splitRtemsBsdnetBootpCmdline(); - splitNfsMountPath(gev("epics-nfsmount", nvp)); - rtems_bsdnet_config.ntp_server[0] = gev("epics-ntpserver", nvp); - if (rtems_bsdnet_config.ntp_server[0] == NULL) - rtems_bsdnet_config.ntp_server[0] = rtems_bsdnet_bootp_server_name; - if ((cp = gev("epics-tz", nvp)) != NULL) - epicsEnvSet("TZ", cp); -} - -#elif defined(HAVE_PPCBUG) -/* - * Motorola PPCBUG NVRAM Access - */ -struct ppcbug_nvram { - uint32_t PacketVersionIdentifier; - uint32_t NodeControlMemoryAddress; - uint32_t BootFileLoadAddress; - uint32_t BootFileExecutionAddress; - uint32_t BootFileExecutionDelay; - uint32_t BootFileLength; - uint32_t BootFileByteOffset; - uint32_t TraceBufferAddress; - uint32_t ClientIPAddress; - uint32_t ServerIPAddress; - uint32_t SubnetIPAddressMask; - uint32_t BroadcastIPAddressMask; - uint32_t GatewayIPAddress; - uint8_t BootpRarpRetry; - uint8_t TftpRarpRetry; - uint8_t BootpRarpControl; - uint8_t UpdateControl; - char BootFilenameString[64]; - char ArgumentFilenameString[64]; -}; - -static char *addr(char *cbuf, uint32_t addr) -{ - struct in_addr a; - if ((a.s_addr = addr) == 0) - return NULL; - return (char *)inet_ntop(AF_INET, &a, cbuf, INET_ADDRSTRLEN); -} - -void -setBootConfigFromNVRAM(void) -{ - static struct ppcbug_nvram nvram; - static char ip_address[INET_ADDRSTRLEN]; - static char ip_netmask[INET_ADDRSTRLEN]; - static char server[INET_ADDRSTRLEN]; - static char gateway[INET_ADDRSTRLEN]; - - if (rtems_bsdnet_config.bootp != NULL) - return; - - /* - * Get network configuation from PPCBUG. - * The 'correct' way to do this would be to issue a .NETCFIG PPCBUG - * system call. Unfortunately it is very difficult to issue such a - * call once RTEMS is up and running so we just copy from the 'known' - * location of the network configuration parameters. - * Care must be taken to access the NVRAM a byte at a time. - */ - -#if defined(NVRAM_INDIRECT) - { - volatile char *addrLo = (volatile char *)0x80000074; - volatile char *addrHi = (volatile char *)0x80000075; - volatile char *data = (volatile char *)0x80000077; - int addr = 0x1000; - char *d = (char *)&nvram; - - while (d < ((char *)&nvram + sizeof nvram)) { - *addrLo = addr & 0xFF; - *addrHi = (addr >> 8) & 0xFF; - *d++ = *data; - addr++; - } - } -#else - { - volatile char *s = (volatile char *)0xFFE81000; - char *d = (char *)&nvram; - - while (d < ((char *)&nvram + sizeof nvram)) - *d++ = *s++; - } -#endif - /* - * Assume that the boot server is also the name, log and ntp server! - */ - rtems_bsdnet_config.name_server[0] = - rtems_bsdnet_config.ntp_server[0] = - rtems_bsdnet_bootp_server_name = addr(server, nvram.ServerIPAddress); - rtems_bsdnet_bootp_server_address.s_addr = nvram.ServerIPAddress; - /* - * Nothing better to use as host name! - */ - rtems_bsdnet_config.ifconfig->ip_address = - rtems_bsdnet_config.hostname = addr(ip_address, nvram.ClientIPAddress); - - rtems_bsdnet_config.gateway = addr(gateway, nvram.GatewayIPAddress); - rtems_bsdnet_config.ifconfig->ip_netmask = addr(ip_netmask, nvram.SubnetIPAddressMask); - - rtems_bsdnet_bootp_boot_file_name = nvram.BootFilenameString; - rtems_bsdnet_bootp_cmdline = nvram.ArgumentFilenameString; - splitRtemsBsdnetBootpCmdline(); -} - -#elif defined(__mcf528x__) - -static char * -env(const char *parm, const char *defaultValue) -{ - const char *cp = bsp_getbenv(parm); - - if (!cp) { - if (!defaultValue) - return NULL; - cp = defaultValue; - printf ("%s environment variable missing -- using %s.\n", parm, cp); - } - return epicsStrDup(cp); -} - -void -setBootConfigFromNVRAM(void) -{ - const char *cp1; - - if (rtems_bsdnet_config.bootp != NULL) - return; - rtems_bsdnet_config.gateway = env("GATEWAY", NULL); - rtems_bsdnet_config.ifconfig->ip_netmask = env("NETMASK", "255.255.252.0"); - - rtems_bsdnet_bootp_server_name = env("SERVER", "192.168.0.1"); - rtems_bsdnet_config.name_server[0] = env("NAMESERVER", rtems_bsdnet_bootp_server_name); - rtems_bsdnet_config.ntp_server[0] = env("NTPSERVER", rtems_bsdnet_bootp_server_name); - cp1 = env("DOMAIN", NULL); - if (cp1 != NULL) - rtems_bsdnet_config.domainname = cp1; - rtems_bsdnet_config.hostname = env("HOSTNAME", "iocNobody"); - rtems_bsdnet_config.ifconfig->ip_address = env("IPADDR0", "192.168.0.2"); - rtems_bsdnet_bootp_boot_file_name = env("BOOTFILE", "uC5282App.boot"); - rtems_bsdnet_bootp_cmdline = env("CMDLINE", "epics/iocBoot/iocNobody/st.cmd"); - splitNfsMountPath(env("NFSMOUNT", NULL)); - if ((cp1 = env("TZ", NULL)) != NULL) - epicsEnvSet("TZ", cp1); -} - -#else -/* - * Placeholder for systems without NVRAM - */ -void -setBootConfigFromNVRAM(void) -{ - printf("SYSTEM HAS NO NON-VOLATILE RAM!\n"); - printf("YOU MUST USE SOME OTHER METHOD TO OBTAIN NETWORK CONFIGURATION\n"); -} -#endif diff --git a/modules/libcom/RTEMS/kernel/rtems_netconfig.c b/modules/libcom/RTEMS/rtems_netconfig.c similarity index 95% rename from modules/libcom/RTEMS/kernel/rtems_netconfig.c rename to modules/libcom/RTEMS/rtems_netconfig.c index 4f7a84149..09c29931c 100644 --- a/modules/libcom/RTEMS/kernel/rtems_netconfig.c +++ b/modules/libcom/RTEMS/rtems_netconfig.c @@ -15,6 +15,8 @@ */ #include #include + +#ifdef RTEMS_LEGACY_STACK // old non libbsd stack #include extern void rtems_bsdnet_loopattach(); @@ -37,7 +39,6 @@ static struct rtems_bsdnet_ifconfig loopback_config = { * application directory and make the appropriate changes. */ #if defined(__i386__) - extern int rtems_ne2kpci_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach); static struct rtems_bsdnet_ifconfig ne2k_driver_config = { @@ -45,11 +46,12 @@ static struct rtems_bsdnet_ifconfig ne2k_driver_config = { rtems_ne2kpci_driver_attach, /* attach function */ &loopback_config, /* link to next interface */ }; + extern int rtems_fxp_attach (struct rtems_bsdnet_ifconfig *, int); static struct rtems_bsdnet_ifconfig fxp_driver_config = { "fxp1", /* name */ rtems_fxp_attach, /* attach function */ - &ne2k_driver_config, /* link to next interface */ + &ne2k_driver_config, /* link to next interface */ }; extern int rtems_3c509_driver_attach (struct rtems_bsdnet_ifconfig *, int); static struct rtems_bsdnet_ifconfig e3c509_driver_config = { @@ -127,3 +129,11 @@ struct rtems_bsdnet_config rtems_bsdnet_config = { NULL, /* Host name */ MY_DOMAINNAME, /* Domain name */ }; +#else // libbsd "new" stack +// nothing to do?? +#endif // RTEMS_LEGACY_STACK + + + + + diff --git a/modules/libcom/RTEMS/setBootConfigFromNVRAM.c b/modules/libcom/RTEMS/setBootConfigFromNVRAM.c index 6fcca54b2..192c950ea 100644 --- a/modules/libcom/RTEMS/setBootConfigFromNVRAM.c +++ b/modules/libcom/RTEMS/setBootConfigFromNVRAM.c @@ -12,7 +12,9 @@ #include #include #include +#ifdef RTEMS_LEGACY_STACK #include +#endif #include #include #include @@ -26,6 +28,7 @@ char *env_nfsServer; char *env_nfsPath; char *env_nfsMountPoint; +extern char* rtems_bootp_cmdline; /* * Split argument string of form nfs_server:nfs_export: * The nfs_export component will be used as: @@ -44,7 +47,7 @@ splitRtemsBsdnetBootpCmdline(void) { char *cp1, *cp2, *cp3; - if ((cp1 = rtems_bsdnet_bootp_cmdline) == NULL) + if ((cp1 = rtems_bootp_cmdline) == NULL) return; if (((cp2 = strchr(cp1, ':')) != NULL) && (((cp3 = strchr(cp2+1, ' ')) != NULL) @@ -58,7 +61,7 @@ splitRtemsBsdnetBootpCmdline(void) env_nfsServer = cp1; env_nfsMountPoint = env_nfsPath = epicsStrDup(cp2); *cp3 = '/'; - rtems_bsdnet_bootp_cmdline = cp2; + rtems_bootp_cmdline = cp2; } } } @@ -207,7 +210,7 @@ setBootConfigFromNVRAM(void) if ((rtems_bsdnet_bootp_boot_file_name = gev("mot-/dev/enet0-file", nvp)) == NULL) rtems_bsdnet_bootp_boot_file_name = motScriptParm(mot_script_boot, 'f'); - rtems_bsdnet_bootp_cmdline = gev("epics-script", nvp); + rtems_bootp_cmdline = gev("epics-script", nvp); splitRtemsBsdnetBootpCmdline(); splitNfsMountPath(gev("epics-nfsmount", nvp)); rtems_bsdnet_config.ntp_server[0] = gev("epics-ntpserver", nvp); @@ -313,7 +316,7 @@ setBootConfigFromNVRAM(void) rtems_bsdnet_config.ifconfig->ip_netmask = addr(ip_netmask, nvram.SubnetIPAddressMask); rtems_bsdnet_bootp_boot_file_name = nvram.BootFilenameString; - rtems_bsdnet_bootp_cmdline = nvram.ArgumentFilenameString; + rtems_bootp_cmdline = nvram.ArgumentFilenameString; splitRtemsBsdnetBootpCmdline(); } @@ -352,7 +355,7 @@ setBootConfigFromNVRAM(void) rtems_bsdnet_config.hostname = env("HOSTNAME", "iocNobody"); rtems_bsdnet_config.ifconfig->ip_address = env("IPADDR0", "192.168.0.2"); rtems_bsdnet_bootp_boot_file_name = env("BOOTFILE", "uC5282App.boot"); - rtems_bsdnet_bootp_cmdline = env("CMDLINE", "epics/iocBoot/iocNobody/st.cmd"); + rtems_bootp_cmdline = env("CMDLINE", "epics/iocBoot/iocNobody/st.cmd"); splitNfsMountPath(env("NFSMOUNT", NULL)); if ((cp1 = env("TZ", NULL)) != NULL) epicsEnvSet("TZ", cp1); From 4127f6efecf094487988fafd6070ed7af409e87d Mon Sep 17 00:00:00 2001 From: Heinz Junkes Date: Mon, 12 Oct 2020 16:54:59 +0200 Subject: [PATCH 026/195] MQ name creation changed --- modules/libcom/RTEMS/posix/rtems_config.c | 9 ++--- modules/libcom/RTEMS/posix/rtems_init.c | 38 +++++++++++-------- .../src/osi/os/RTEMS-posix/osdMessageQueue.c | 12 +++--- .../src/osi/os/RTEMS-posix/osdMessageQueue.h | 5 +-- 4 files changed, 35 insertions(+), 29 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_config.c b/modules/libcom/RTEMS/posix/rtems_config.c index bba6fc9d9..62a82c90d 100644 --- a/modules/libcom/RTEMS/posix/rtems_config.c +++ b/modules/libcom/RTEMS/posix/rtems_config.c @@ -43,13 +43,12 @@ extern void *POSIX_Init(void *argument); /* * Configure LibBSD. */ -#define RTEMS_BSD_CONFIG_NET_PF_UNIX -#define RTEMS_BSD_CONFIG_NET_IF_BRIDGE -#define RTEMS_BSD_CONFIG_NET_IF_LAGG -#define RTEMS_BSD_CONFIG_NET_IF_VLAN +//#define RTEMS_BSD_CONFIG_NET_PF_UNIX +//#define RTEMS_BSD_CONFIG_NET_IF_BRIDGE +//#define RTEMS_BSD_CONFIG_NET_IF_LAGG +//#define RTEMS_BSD_CONFIG_NET_IF_VLAN #define RTEMS_BSD_CONFIG_BSP_CONFIG #define RTEMS_BSD_CONFIG_INIT - #include #endif // not LEGACY_STACK diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index f7d2a1c2c..3efb8553e 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -793,6 +793,7 @@ default_network_dhcpcd(void) assert(sc == RTEMS_SUCCESSFUL); } #endif // not RTEMS_LEGACY_STACK + /* * RTEMS Startup task */ @@ -826,7 +827,8 @@ POSIX_Init (void *argument) if (sc < 0) printf ("***** Can't set time: %s\n", rtems_status_text (sc)); } - if ( clock_gettime( CLOCK_REALTIME, &now) < 0) { + sc = clock_gettime( CLOCK_REALTIME, &now); + if ( sc < 0) { printf ("***** Can't get time: %s\n", rtems_status_text (sc)); } else { strftime(timeBuff, sizeof timeBuff, "%D %T", gmtime(&now.tv_sec)); @@ -850,7 +852,6 @@ POSIX_Init (void *argument) } if (epicsRtemsInitPostSetBootConfigFromNVRAM(&rtems_bsdnet_config) != 0) delayedPanic("epicsRtemsInitPostSetBootConfigFromNVRAM"); - #endif /* * Override RTEMS Posix configuration, it gets started with posix prio 2 @@ -869,21 +870,26 @@ POSIX_Init (void *argument) */ printf("\n***** RTEMS Version: %s *****\n", rtems_get_version_string()); - + #ifndef RTEMS_LEGACY_STACK /* * Start network (libbsd) + * + * start qemu like this + * qemu-system-i386 -m 64 -no-reboot -serial stdio -display none \ + * -net nic,model=e1000,macaddr=0e:b0:ba:5e:ba:11 -net user,restrict=yes \ + * -append "--video=off --console=/dev/com1" -kernel libComTestHarness */ printf("\n***** Initializing network (libbsd, dhcpcd) *****\n"); rtems_bsd_setlogpriority("debug"); on_exit(default_network_on_exit, NULL); + /* Let other tasks run to complete background work */ default_network_set_self_prio(RTEMS_MAXIMUM_PRIORITY - 1U); - /* supress all output from bsd network initialization (Info: to be switched on in production!) + /* supress all output from bsd network initialization */ rtems_bsd_vprintf_handler bsd_vprintf_handler_old; bsd_vprintf_handler_old = rtems_bsd_set_vprintf_handler(rtems_bsd_vprintf_handler_mute); - */ sc = rtems_bsd_initialize(); assert(sc == RTEMS_SUCCESSFUL); @@ -892,23 +898,25 @@ POSIX_Init (void *argument) sc = rtems_task_wake_after(2); assert(sc == RTEMS_SUCCESSFUL); + printf("\n***** ifconfig lo0 *****\n"); rtems_bsd_ifconfig_lo0(); - // if MY_BOOTP??? - default_network_dhcpcd(); - - /* this seems to be hard coded in the BSP -> Sebastian Huber ? - printf("\n--Info (hpj)-- bsd task prio IRQS: %d -----\n", rtems_bsd_get_task_priority("IRQS")); - printf("\n--Info (hpj)-- bsd task prio TIME: %d -----\n", rtems_bsd_get_task_priority("TIME")); - */ - - // implement DHCP hook ... and wait for acknowledge + printf("\n***** add dhcpcd hook *****\n"); dhcpDone = epicsEventMustCreate(epicsEventEmpty); rtems_dhcpcd_add_hook(&dhcpcd_hook); + printf("\n***** Start default network dhcpcd *****\n"); + // if MY_BOOTP??? + default_network_dhcpcd(); + + /* this seems to be hard coded in the BSP -> Sebastian Huber ? */ + printf("\n--Info (hpj)-- bsd task prio IRQS: %d -----\n", rtems_bsd_get_task_priority("IRQS")); + printf("\n--Info (hpj)-- bsd task prio TIME: %d -----\n", rtems_bsd_get_task_priority("TIME")); + + // wait for dhcp done ... should be if SYNCDHCP is used epicsEventWaitStatus stat; - int counter = 10; + int counter = 2; do { printf("\n ---- Wait for DHCP done ...\n"); stat = epicsEventWaitWithTimeout(dhcpDone, 5.0); diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c b/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c index 3774ef2d8..7c7ea8aad 100644 --- a/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.c @@ -3,9 +3,9 @@ * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* SPDX-License-Identifier: EPICS +* EPICS Base is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. \*************************************************************************/ /* * Author W. Eric Norum @@ -34,14 +34,14 @@ #include #include +static int idCnt; + LIBCOM_API epicsMessageQueueId epicsStdCall epicsMessageQueueCreate(unsigned int capacity, unsigned int maximumMessageSize) { struct mq_attr the_attr; epicsMessageQueueId id = (epicsMessageQueueId)calloc(1, sizeof(*id)); - - epicsAtomicIncrIntT(&id->idCnt); - sprintf(id->name, "MQ_%01d", epicsAtomicGetIntT(&id->idCnt)); + sprintf(id->name, "MQ_%0d", epicsAtomicIncrIntT(&idCnt)); the_attr.mq_maxmsg = capacity; the_attr.mq_msgsize = maximumMessageSize; id->id = mq_open(id->name, O_RDWR | O_CREAT | O_EXCL, 0644, &the_attr); diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h b/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h index 0311ee486..95e66e73e 100644 --- a/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdMessageQueue.h @@ -22,8 +22,7 @@ struct epicsMessageQueueOSD { mqd_t id; char name[24]; - int idCnt; - }; #define epicsMessageQueueSend(q,m,l) (mq_send((q)->id, (const char*)(m), (l), 0)) -#define epicsMessageQueueReceive(q,m,s) (mq_receive((q)->id, (char*)(m), (s), NULL)) \ No newline at end of file +#define epicsMessageQueueReceive(q,m,s) (mq_receive((q)->id, (char*)(m), (s), NULL)) + From 54f2d8887fee72b625450ee115187fae3a52f178 Mon Sep 17 00:00:00 2001 From: Heinz Junkes Date: Mon, 23 Nov 2020 17:13:51 +0100 Subject: [PATCH 027/195] changed pvAccess url, save adaption to old network stack --- .gitmodules | 2 +- configure/os/CONFIG.Common.RTEMS | 2 +- configure/os/CONFIG_SITE.Common.RTEMS | 1 + modules/libcom/RTEMS/posix/rtems_config.c | 2 + modules/libcom/RTEMS/posix/rtems_init.c | 74 ++++++++++--------- modules/libcom/RTEMS/rtems_netconfig.c | 29 +++++++- modules/libcom/RTEMS/setBootConfigFromNVRAM.c | 12 +-- modules/libcom/src/calc/postfix.c | 7 ++ 8 files changed, 83 insertions(+), 46 deletions(-) diff --git a/.gitmodules b/.gitmodules index e537fc586..62cca0f74 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,7 +4,7 @@ branch = master [submodule "modules/pvAccess"] path = modules/pvAccess - url = https://github.com/epics-base/pvAccessCPP + url = https://github.com/mdavidsaver/pvAccessCPP branch = master [submodule "modules/normativeTypes"] path = modules/normativeTypes diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 2d9243a60..e4b046b00 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -104,7 +104,7 @@ OP_SYS_CFLAGS_NET_yes = -DRTEMS_LEGACY_STACK OP_SYS_CFLAGS_NET_no = -DHAVE_SOCKADDR_SA_LEN=1 OP_SYS_CFLAGS += $(OP_SYS_CFLAGS_NET_$(RTEMS_HAS_NETWORKING)) -OP_SYS_LDLIBS_posix_NET_yes = -ltftpfs -lbsd -lz +OP_SYS_LDLIBS_posix_NET_yes = -ltftpfs -lnfs -lz OP_SYS_LDLIBS_posix_NET_no = -ltftpfs -lbsd -lz OP_SYS_LDLIBS_kernel_NET_yes = -lCom -lnfs OP_SYS_LDLIBS_kernel_NET_no = -lCom -lnfs diff --git a/configure/os/CONFIG_SITE.Common.RTEMS b/configure/os/CONFIG_SITE.Common.RTEMS index 18d62ddca..e6b3de2ec 100644 --- a/configure/os/CONFIG_SITE.Common.RTEMS +++ b/configure/os/CONFIG_SITE.Common.RTEMS @@ -15,6 +15,7 @@ # FHI: #RTEMS_VERSION = 5 #RTEMS_BASE = /home/h1/DBG/rtems +#RTEMS_BASE = /home/ad/MVME6100/rtems/$(RTEMS_VERSION) # APS: #RTEMS_VERSION = 4.10.2 diff --git a/modules/libcom/RTEMS/posix/rtems_config.c b/modules/libcom/RTEMS/posix/rtems_config.c index 62a82c90d..65c8ae96b 100644 --- a/modules/libcom/RTEMS/posix/rtems_config.c +++ b/modules/libcom/RTEMS/posix/rtems_config.c @@ -132,6 +132,8 @@ extern void *POSIX_Init(void *argument); #define RTEMS_BSD_CONFIG_TELNETD_STACK_SIZE (16 * 1024) #define RTEMS_BSD_CONFIG_SERVICE_FTPD #define RTEMS_BSD_CONFIG_FIREWALL_PF +#else +#include #endif // not LEGACY_STACK #if __RTEMS_MAJOR__ < 5 // still needed in Version 4? diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 3efb8553e..6a4d627bf 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -88,26 +88,23 @@ epicsEventId dhcpDone; #endif - -#ifndef RTEMS_LEGACY_STACK /* these settings are needed by the rtems startup * may provide by dhcp/bootp * or environments from the "BIOS" like u-boot, motboot etc. */ -struct in_addr rtems_bsdnet_bootp_server_address; -char rtemsInit_NTP_server_ip[16]; +char rtemsInit_NTP_server_ip[16] = "141.14.142.121"; char bootp_server_name_init[128] = "1001.1001@141.14.128.9:/Volumes/Epics"; -char *rtems_bsdnet_bootp_server_name = bootp_server_name_init; -char bootp_boot_file_name_init[128] = "/Volumes/Epics/myExample/bin/RTEMS-qoriq_e500/myExample.boot"; -char *rtems_bsdnet_bootp_boot_file_name = bootp_boot_file_name_init; +char bootp_boot_file_name_init[128] = "/Volumes/Epics/myExample/bin/RTEMS-beatnik/myExample.boot"; char bootp_cmdline_init[128] = "/Volumes/Epics/myExample/iocBoot/iocmyExample/st.cmd"; -char *rtems_bootp_cmdline = bootp_cmdline_init; + +struct in_addr rtems_bsdnet_bootp_server_address; +//!! check rtems_bsdnet_bootp_cmdline +#ifndef RTEMS_LEGACY_STACK +char *rtems_bsdnet_bootp_server_name = bootp_server_name_init; +char *rtems_bsdnet_bootp_boot_file_name = bootp_boot_file_name_init; +char *rtems_bsdnet_bootp_cmdline = bootp_cmdline_init; #endif // not LEGACY Stack -int osdNTPGet(struct timespec *now) -{ - return !epicsNtpGetTime(rtemsInit_NTP_server_ip, now); -} /* * Prototypes for some functions not in header files @@ -251,13 +248,13 @@ initialize_local_filesystem(char **argv) printf("Can't unpack tar filesystem\n"); return 0; } - if ((fd = open(rtems_bootp_cmdline, 0)) >= 0) { + if ((fd = open(rtems_bsdnet_bootp_cmdline, 0)) >= 0) { close(fd); - printf ("***** Found startup script (%s) in IMFS *****\n", rtems_bootp_cmdline); - argv[1] = rtems_bootp_cmdline; + printf ("***** Found startup script (%s) in IMFS *****\n", rtems_bsdnet_bootp_cmdline); + argv[1] = rtems_bsdnet_bootp_cmdline; return 1; } - printf ("***** Startup script (%s) not in IMFS *****\n", rtems_bootp_cmdline); + printf ("***** Startup script (%s) not in IMFS *****\n", rtems_bsdnet_bootp_cmdline); } } */ return 0; @@ -336,7 +333,7 @@ initialize_remote_filesystem(char **argv, int hasLocalFilesystem) mount_point, strerror(errno)); *cp = '/'; } - argv[1] = rtems_bootp_cmdline; + argv[1] = rtems_bsdnet_bootp_cmdline; } else if (hasLocalFilesystem) { return; @@ -348,22 +345,22 @@ initialize_remote_filesystem(char **argv, int hasLocalFilesystem) * if the pathname does not begin with a '/'. This allows * NFS and TFTP to have a similar view of the remote system. */ - if (rtems_bootp_cmdline[0] == '/') - cp = rtems_bootp_cmdline + 1; + if (rtems_bsdnet_bootp_cmdline[0] == '/') + cp = rtems_bsdnet_bootp_cmdline + 1; else - cp = rtems_bootp_cmdline; + cp = rtems_bsdnet_bootp_cmdline; cp = strchr(cp, '/'); if ((cp == NULL) - || ((l = cp - rtems_bootp_cmdline) == 0)) - LogFatal("\"%s\" is not a valid command pathname.\n", rtems_bootp_cmdline); + || ((l = cp - rtems_bsdnet_bootp_cmdline) == 0)) + LogFatal("\"%s\" is not a valid command pathname.\n", rtems_bsdnet_bootp_cmdline); cp = mustMalloc(l + 20, "NFS mount paths"); server_path = cp; server_name = rtems_bsdnet_bootp_server_name; - if (rtems_bootp_cmdline[0] == '/') { + if (rtems_bsdnet_bootp_cmdline[0] == '/') { mount_point = server_path; - strncpy(mount_point, rtems_bootp_cmdline, l); + strncpy(mount_point, rtems_bsdnet_bootp_cmdline, l); mount_point[l] = '\0'; - argv[1] = rtems_bootp_cmdline; + argv[1] = rtems_bsdnet_bootp_cmdline; /* * Its probably common to embed the mount point in the server * name so, when this is occurring, dont clobber the mount point @@ -400,14 +397,14 @@ initialize_remote_filesystem(char **argv, int hasLocalFilesystem) } } else { - char *abspath = mustMalloc(strlen(rtems_bootp_cmdline)+2,"Absolute command path"); + char *abspath = mustMalloc(strlen(rtems_bsdnet_bootp_cmdline)+2,"Absolute command path"); strcpy(server_path, "/tftpboot/"); mount_point = server_path + strlen(server_path); - strncpy(mount_point, rtems_bootp_cmdline, l); + strncpy(mount_point, rtems_bsdnet_bootp_cmdline, l); mount_point[l] = '\0'; mount_point--; strcpy(abspath, "/"); - strcat(abspath, rtems_bootp_cmdline); + strcat(abspath, rtems_bsdnet_bootp_cmdline); argv[1] = abspath; } } @@ -523,7 +520,9 @@ static void rtshellCallFunc(const iocshArgBuf *args) static void rtems_netstat (unsigned int level) { -/* +#ifndef RTEMS_LEGACY_STACK + printf ("***** Sorry not implemented yet with the new network stack (bsdlib)\n"); +#else rtems_bsdnet_show_if_stats (); rtems_bsdnet_show_mbuf_stats (); if (level >= 1) { @@ -535,7 +534,7 @@ rtems_netstat (unsigned int level) rtems_bsdnet_show_udp_stats (); rtems_bsdnet_show_tcp_stats (); } -*/ +#endif } static const iocshArg netStatArg0 = { "level",iocshArgInt}; @@ -719,8 +718,8 @@ dhcpcd_hook_handler(rtems_dhcpcd_hook *hook, char *const *env) } if(!strncmp(name, "new_rtems_cmdline", 20)){ //printf(" new_rtems_cmdline : %s\n", value); - strncpy(rtems_bootp_cmdline,value, sizeof(bootp_cmdline_init)); - printf(" rtems_bootp_cmdline : %s\n", rtems_bootp_cmdline); + strncpy(rtems_bsdnet_bootp_cmdline,value, sizeof(bootp_cmdline_init)); + printf(" rtems_bsdnet_bootp_cmdline : %s\n", rtems_bsdnet_bootp_cmdline); } // printf("---> %s = %s\n", name, value); } @@ -952,12 +951,14 @@ POSIX_Init (void *argument) } } #else // Legacy stack, old network initialization - /* - * Start network - */ char *cp; if ((cp = getenv("EPICS_TS_NTP_INET")) != NULL) rtems_bsdnet_config.ntp_server[0] = cp; + + int rtems_bsdnet_ntpserver_count = 1; + struct in_addr rtems_bsdnet_ntpserver[1]; + memcpy(rtems_bsdnet_ntpserver, rtems_bsdnet_config.ntp_server, sizeof(struct in_addr)); + if (rtems_bsdnet_config.network_task_priority == 0) { unsigned int p; @@ -969,6 +970,9 @@ POSIX_Init (void *argument) } printf("\n***** Initializing network (Legacy Stack) *****\n"); rtems_bsdnet_initialize_network(); + printf("\n***** Network Status *****\n"); + rtems_netstat(3); + rtems_bsdnet_synchronize_ntp (0, 0); #endif // not RTEMS_LEGACY_STACK printf("\n***** Setting up file system *****\n"); diff --git a/modules/libcom/RTEMS/rtems_netconfig.c b/modules/libcom/RTEMS/rtems_netconfig.c index 09c29931c..2ce9293d8 100644 --- a/modules/libcom/RTEMS/rtems_netconfig.c +++ b/modules/libcom/RTEMS/rtems_netconfig.c @@ -16,9 +16,26 @@ #include #include +#ifndef VERSION_INT +# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) +#endif +#define RTEMS_VERSION_INT VERSION_INT(__RTEMS_MAJOR__, __RTEMS_MINOR__, 0, 0) + + #ifdef RTEMS_LEGACY_STACK // old non libbsd stack #include +/* + * Comment (by sebastian.huber): + * + * This rtems_bsdnet_loopattach() was a hack and is no longer needed in RTEMS + * 4.11. + * + * -- + * Ticket URL: + */ + +#if RTEMS_VERSION_INT<=VERSION_INT(4,10,0,0) extern void rtems_bsdnet_loopattach(); static struct rtems_bsdnet_ifconfig loopback_config = { "lo0", /* name */ @@ -27,7 +44,7 @@ static struct rtems_bsdnet_ifconfig loopback_config = { "127.0.0.1", /* IP address */ "255.0.0.0", /* IP net mask */ }; - +#endif /* * The following conditionals select the network interface card. * @@ -44,7 +61,11 @@ rtems_ne2kpci_driver_attach (struct rtems_bsdnet_ifconfig *config, int attach); static struct rtems_bsdnet_ifconfig ne2k_driver_config = { "ne2", /* name */ rtems_ne2kpci_driver_attach, /* attach function */ +#if RTEMS_VERSION_INT<=VERSION_INT(4,10,0,0) &loopback_config, /* link to next interface */ +#else + NULL, +#endif }; extern int rtems_fxp_attach (struct rtems_bsdnet_ifconfig *, int); @@ -75,12 +96,14 @@ static struct rtems_bsdnet_ifconfig e3c509_driver_config = { # endif # endif -static struct rtems_bsdnet_ifconfig bsp_driver_config = { +static struct rtems_bsdnet_ifconfig netdriver_config = { RTEMS_BSP_NETWORK_DRIVER_NAME, /* name */ RTEMS_BSP_NETWORK_DRIVER_ATTACH, /* attach function */ +#if RTEMS_VERSION_INT<=VERSION_INT(4,10,0,0) &loopback_config, /* link to next interface */ +#endif }; -#define FIRST_DRIVER_CONFIG &bsp_driver_config +#define FIRST_DRIVER_CONFIG &netdriver_config #endif diff --git a/modules/libcom/RTEMS/setBootConfigFromNVRAM.c b/modules/libcom/RTEMS/setBootConfigFromNVRAM.c index 192c950ea..deb9f0654 100644 --- a/modules/libcom/RTEMS/setBootConfigFromNVRAM.c +++ b/modules/libcom/RTEMS/setBootConfigFromNVRAM.c @@ -28,7 +28,7 @@ char *env_nfsServer; char *env_nfsPath; char *env_nfsMountPoint; -extern char* rtems_bootp_cmdline; +extern char* rtems_bsdnet_bootp_cmdline; /* * Split argument string of form nfs_server:nfs_export: * The nfs_export component will be used as: @@ -47,7 +47,7 @@ splitRtemsBsdnetBootpCmdline(void) { char *cp1, *cp2, *cp3; - if ((cp1 = rtems_bootp_cmdline) == NULL) + if ((cp1 = rtems_bsdnet_bootp_cmdline) == NULL) return; if (((cp2 = strchr(cp1, ':')) != NULL) && (((cp3 = strchr(cp2+1, ' ')) != NULL) @@ -61,7 +61,7 @@ splitRtemsBsdnetBootpCmdline(void) env_nfsServer = cp1; env_nfsMountPoint = env_nfsPath = epicsStrDup(cp2); *cp3 = '/'; - rtems_bootp_cmdline = cp2; + rtems_bsdnet_bootp_cmdline = cp2; } } } @@ -210,7 +210,7 @@ setBootConfigFromNVRAM(void) if ((rtems_bsdnet_bootp_boot_file_name = gev("mot-/dev/enet0-file", nvp)) == NULL) rtems_bsdnet_bootp_boot_file_name = motScriptParm(mot_script_boot, 'f'); - rtems_bootp_cmdline = gev("epics-script", nvp); + rtems_bsdnet_bootp_cmdline = gev("epics-script", nvp); splitRtemsBsdnetBootpCmdline(); splitNfsMountPath(gev("epics-nfsmount", nvp)); rtems_bsdnet_config.ntp_server[0] = gev("epics-ntpserver", nvp); @@ -316,7 +316,7 @@ setBootConfigFromNVRAM(void) rtems_bsdnet_config.ifconfig->ip_netmask = addr(ip_netmask, nvram.SubnetIPAddressMask); rtems_bsdnet_bootp_boot_file_name = nvram.BootFilenameString; - rtems_bootp_cmdline = nvram.ArgumentFilenameString; + rtems_bsdnet_bootp_cmdline = nvram.ArgumentFilenameString; splitRtemsBsdnetBootpCmdline(); } @@ -355,7 +355,7 @@ setBootConfigFromNVRAM(void) rtems_bsdnet_config.hostname = env("HOSTNAME", "iocNobody"); rtems_bsdnet_config.ifconfig->ip_address = env("IPADDR0", "192.168.0.2"); rtems_bsdnet_bootp_boot_file_name = env("BOOTFILE", "uC5282App.boot"); - rtems_bootp_cmdline = env("CMDLINE", "epics/iocBoot/iocNobody/st.cmd"); + rtems_bsdnet_bootp_cmdline = env("CMDLINE", "epics/iocBoot/iocNobody/st.cmd"); splitNfsMountPath(env("NFSMOUNT", NULL)); if ((cp1 = env("TZ", NULL)) != NULL) epicsEnvSet("TZ", cp1); diff --git a/modules/libcom/src/calc/postfix.c b/modules/libcom/src/calc/postfix.c index 6519d9a39..b3a99e08b 100644 --- a/modules/libcom/src/calc/postfix.c +++ b/modules/libcom/src/calc/postfix.c @@ -27,6 +27,10 @@ #include "postfixPvt.h" #include "libComAPI.h" +#ifdef RTEMS_HAS_ALTIVEC +#pragma GCC push_options +#pragma GCC optimize ("O0") +#endif /* declarations for postfix */ @@ -626,3 +630,6 @@ LIBCOM_API void } } } +#ifdef RTEMS_HAS_ALTIVEC +#pragma GCC pop_options +#endif From 97e6f0a53d6dd8877eacab788150ac96bcd81a44 Mon Sep 17 00:00:00 2001 From: Heinz Junkes Date: Tue, 24 Nov 2020 08:56:51 +0100 Subject: [PATCH 028/195] Link pvData module to mdavidsaver --- .gitmodules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitmodules b/.gitmodules index 62cca0f74..544d6ea4b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "modules/pvData"] path = modules/pvData - url = https://github.com/epics-base/pvDataCPP + url = https://github.com/mdavidsaver/pvDataCPP branch = master [submodule "modules/pvAccess"] path = modules/pvAccess From 341ca91229d8df4da9058365c698677bb2f1f127 Mon Sep 17 00:00:00 2001 From: Heinz Junkes Date: Wed, 25 Nov 2020 18:20:49 +0100 Subject: [PATCH 029/195] Add LEGACY_STACK_SUPPORT and telnet client --- configure/os/CONFIG.Common.RTEMS | 2 +- modules/libcom/RTEMS/posix/rtems_init.c | 71 +++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 1 deletion(-) diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index e4b046b00..40c8120eb 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -104,7 +104,7 @@ OP_SYS_CFLAGS_NET_yes = -DRTEMS_LEGACY_STACK OP_SYS_CFLAGS_NET_no = -DHAVE_SOCKADDR_SA_LEN=1 OP_SYS_CFLAGS += $(OP_SYS_CFLAGS_NET_$(RTEMS_HAS_NETWORKING)) -OP_SYS_LDLIBS_posix_NET_yes = -ltftpfs -lnfs -lz +OP_SYS_LDLIBS_posix_NET_yes = -ltftpfs -lnfs -lz -telnetd OP_SYS_LDLIBS_posix_NET_no = -ltftpfs -lbsd -lz OP_SYS_LDLIBS_kernel_NET_yes = -lCom -lnfs OP_SYS_LDLIBS_kernel_NET_no = -lCom -lnfs diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 6a4d627bf..605c5f992 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -63,6 +63,7 @@ #include #if __RTEMS_MAJOR__ > 4 #include +#include #endif #include "epicsVersion.h" #include "epicsThread.h" @@ -76,6 +77,7 @@ #include "osdTime.h" #include "epicsMemFs.h" #include "epicsEvent.h" +#include "errlog.h" #include "epicsRtemsInitHooks.h" @@ -793,6 +795,68 @@ default_network_dhcpcd(void) } #endif // not RTEMS_LEGACY_STACK +#if __RTEMS_MAJOR__>4 +/* + *********************************************************************** + * TELNET DAEMON * + *********************************************************************** + */ +#define LINE_SIZE 256 +static void +telnet_pseudoIocsh(char *name, void *arg) +{ + char line[LINE_SIZE]; + int fid[3], save_fid[3]; + + printf("info: pty dev name = %s\n", name); + + save_fid[1] = dup2(1,1); + fid[1] = dup2( fileno(stdout), 1); + if (fid[1] == -1 ) printf("Can't dup stdout\n"); + save_fid[2] = dup2(2,2); + fid[2] = dup2( fileno(stderr), 2); + if (fid[2] == -1 ) printf("Can't dup stderr\n"); + + const char *prompt = "tIocSh> "; + + while (1) { + fputs(prompt, stdout); + fflush(stdout); + /* telnet close not detected ??? tbd */ + if (fgets(line, LINE_SIZE, stdin) == NULL) { + dup2(save_fid[1],1); ++ dup2(save_fid[2],2); + return; + } + if (line[strlen(line)-1] == '\n') line[strlen(line)-1] = 0; + if (!strncmp( line, "bye",3)) { + printf( "%s", "Will end session\n"); + dup2(save_fid[1],1); + dup2(save_fid[2],2); + return; + } + iocshCmd(line); + } +} + +#define SHELL_ENTRY telnet_pseudoIocsh + +/* + * Telnet daemon configuration + */ +rtems_telnetd_config_table rtems_telnetd_config = { + .command = SHELL_ENTRY, + .arg = NULL, + .priority = 99, // if RTEMS_NETWORK and .priority == 0 bsd_network_prio should be used ... + .stack_size = 0, + .client_maximum = 5, // should be 1, on RTEMS and Epics it makes only sense for one connection a time + .login_check = NULL, + .keep_stdio = false +}; + +#endif + + /* * RTEMS Startup task */ @@ -1004,6 +1068,13 @@ POSIX_Init (void *argument) /*/Volumes/Epics/myExample/bin/RTEMS-xilinx_zynq_a9_qemu * Run the EPICS startup script */ +#if __RTEMS_MAJOR__>4 + // if telnetd is requested ... + printf(" Will try to start telnetd with prio %d ...\n", rtems_telnetd_config.priority); + result = rtems_telnetd_initialize(); + printf (" telnetd initialized with result %d\n", result); +#endif + printf ("***** Preparing EPICS application *****\n"); iocshRegisterRTEMS (); set_directory (argv[1]); From 399c63ec5c801c11cfb5053ef9ee5a08bda71134 Mon Sep 17 00:00:00 2001 From: Heinz Junkes Date: Wed, 6 Jan 2021 16:29:01 +0100 Subject: [PATCH 030/195] Add posix cpp flags to RTEMS config --- configure/os/CONFIG.Common.RTEMS | 4 ++++ modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c | 6 ++++++ modules/libcom/src/osi/os/RTEMS-posix/osdSock.h | 4 ++-- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 40c8120eb..708363a69 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -104,6 +104,10 @@ OP_SYS_CFLAGS_NET_yes = -DRTEMS_LEGACY_STACK OP_SYS_CFLAGS_NET_no = -DHAVE_SOCKADDR_SA_LEN=1 OP_SYS_CFLAGS += $(OP_SYS_CFLAGS_NET_$(RTEMS_HAS_NETWORKING)) +ifeq ($(RTEMS_HAS_POSIX_API),yes) +POSIX_CPPFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE +endif + OP_SYS_LDLIBS_posix_NET_yes = -ltftpfs -lnfs -lz -telnetd OP_SYS_LDLIBS_posix_NET_no = -ltftpfs -lbsd -lz OP_SYS_LDLIBS_kernel_NET_yes = -lCom -lnfs diff --git a/modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c b/modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c new file mode 100644 index 000000000..c83c338d9 --- /dev/null +++ b/modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c @@ -0,0 +1,6 @@ +#ifdef RTEMS_LEGACY_STACK +#include "../RTEMS-kernel/devLibVMEOSD.c" +#else +#pragma message "\n VME-Support only with RTEMS Legacy stack\n" +#include "../default/devLibVMEOSD.c" +#endif diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h b/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h index 925fa6899..0682256b6 100644 --- a/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h @@ -45,8 +45,8 @@ typedef int SOCKET; #define socket_ioctl(A,B,C) ioctl(A,B,C) typedef int osiSockIoctl_t; typedef socklen_t osiSocklen_t; -typedef int osiSockOptMcastLoop_t; -typedef int osiSockOptMcastTTL_t; +typedef char osiSockOptMcastLoop_t; +typedef char osiSockOptMcastTTL_t; #define FD_IN_FDSET(FD) ((FD) Date: Wed, 13 Jan 2021 17:51:44 +0100 Subject: [PATCH 031/195] Cosmetics and some typos --- configure/CONFIG_SITE | 2 +- modules/libcom/RTEMS/posix/rtems_init.c | 59 +++++++++++++++++-------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index a575c61bf..fa66d8371 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -103,7 +103,7 @@ # Which target architectures to cross-compile for. # Definitions in configure/os/CONFIG_SITE..Common # may override this setting. -CROSS_COMPILER_TARGET_ARCHS= +CROSS_COMPILER_TARGET_ARCHS=RTEMS-beatnik #CROSS_COMPILER_TARGET_ARCHS=vxWorks-ppc32 # If only some of your host architectures can compile the diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 605c5f992..9247ece07 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -44,6 +44,9 @@ #include #include #include +#include +#include + #if __RTEMS_MAJOR__ > 4 #include #else @@ -93,6 +96,7 @@ epicsEventId dhcpDone; /* these settings are needed by the rtems startup * may provide by dhcp/bootp * or environments from the "BIOS" like u-boot, motboot etc. + * these are settings within FHI infrastructure (01/13/2021) */ char rtemsInit_NTP_server_ip[16] = "141.14.142.121"; char bootp_server_name_init[128] = "1001.1001@141.14.128.9:/Volumes/Epics"; @@ -100,14 +104,13 @@ char bootp_boot_file_name_init[128] = "/Volumes/Epics/myExample/bin/RTEMS-beatni char bootp_cmdline_init[128] = "/Volumes/Epics/myExample/iocBoot/iocmyExample/st.cmd"; struct in_addr rtems_bsdnet_bootp_server_address; -//!! check rtems_bsdnet_bootp_cmdline +/* TODO check rtems_bsdnet_bootp_cmdline */ #ifndef RTEMS_LEGACY_STACK char *rtems_bsdnet_bootp_server_name = bootp_server_name_init; char *rtems_bsdnet_bootp_boot_file_name = bootp_boot_file_name_init; char *rtems_bsdnet_bootp_cmdline = bootp_cmdline_init; #endif // not LEGACY Stack - /* * Prototypes for some functions not in header files */ @@ -144,7 +147,7 @@ delayedPanic (const char *msg) { rtems_task_wake_after (rtems_clock_get_ticks_per_second()); rtems_task_wake_after (rtems_clock_get_ticks_per_second()); - rtems_panic (msg); + rtems_panic ("%s", msg); } /* @@ -228,17 +231,14 @@ epicsRtemsMountLocalFilesystem(char **argv) static int initialize_local_filesystem(char **argv) { - /* extern char _DownloadLocation[] __attribute__((weak)); extern char _FlashBase[] __attribute__((weak)); extern char _FlashSize[] __attribute__((weak)); - */ argv[0] = rtems_bsdnet_bootp_boot_file_name; if (epicsRtemsMountLocalFilesystem(argv)==0) { return 1; /* FS setup successful */ - } -/* else if (_FlashSize && (_DownloadLocation || _FlashBase)) { + } else if (_FlashSize && (_DownloadLocation || _FlashBase)) { extern char _edata[]; size_t flashIndex = _edata - _DownloadLocation; char *header = _FlashBase + flashIndex; @@ -258,7 +258,7 @@ initialize_local_filesystem(char **argv) } printf ("***** Startup script (%s) not in IMFS *****\n", rtems_bsdnet_bootp_cmdline); } - } */ + } return 0; } @@ -276,7 +276,7 @@ nfsMount(char *uidhost, char *path, char *mntpoint) } sprintf(dev, "%s:%s", uidhost, path); printf("Mount %s on %s\n", dev, mntpoint); - rval = mount_and_make_target_path ( + rval = mount_and_make_target_path ( dev, mntpoint, RTEMS_FILESYSTEM_TYPE_NFS, RTEMS_FILESYSTEM_READ_WRITE, NULL ); if(rval) @@ -496,7 +496,12 @@ set_directory (const char *commandline) static const iocshArg rtshellArg0 = { "cmd", iocshArgString}; static const iocshArg rtshellArg1 = { "args", iocshArgArgv}; static const iocshArg * rtshellArgs[2] = { &rtshellArg0, &rtshellArg1}; -static const iocshFuncDef rtshellFuncDef = { "rt",2, rtshellArgs}; +static const iocshFuncDef rtshellFuncDef = { "rt",2, rtshellArgs +#ifdef IOCSHFUNCDEF_HAS_USAGE + , "run rtems shell command" +#endif + }; + static void rtshellCallFunc(const iocshArgBuf *args) { rtems_shell_cmd_t *cmd = rtems_shell_lookup_cmd(args[0].sval); @@ -541,13 +546,21 @@ rtems_netstat (unsigned int level) static const iocshArg netStatArg0 = { "level",iocshArgInt}; static const iocshArg * const netStatArgs[1] = {&netStatArg0}; -static const iocshFuncDef netStatFuncDef = {"netstat",1,netStatArgs}; +static const iocshFuncDef netStatFuncDef = {"netstat",1,netStatArgs +#ifdef IOCSHFUNCDEF_HAS_USAGE + , "show network status" +#endif + }; static void netStatCallFunc(const iocshArgBuf *args) { rtems_netstat(args[0].ival); } -static const iocshFuncDef heapSpaceFuncDef = {"heapSpace",0,NULL}; +static const iocshFuncDef heapSpaceFuncDef = {"heapSpace",0,NULL +#ifdef IOCSHFUNCDEF_HAS_USAGE + , "show malloc statistic" +#endif + }; static void heapSpaceCallFunc(const iocshArgBuf *args) { #if __RTEMS_MAJOR__ > 4 @@ -580,7 +593,11 @@ static const iocshArg nfsMountArg1 = { "server path",iocshArgString}; static const iocshArg nfsMountArg2 = { "mount point",iocshArgString}; static const iocshArg * const nfsMountArgs[3] = {&nfsMountArg0,&nfsMountArg1, &nfsMountArg2}; -static const iocshFuncDef nfsMountFuncDef = {"nfsMount",3,nfsMountArgs}; +static const iocshFuncDef nfsMountFuncDef = {"nfsMount",3,nfsMountArgs +#ifdef IOCSHFUNCDEF_HAS_USAGE + , "mount nfs drive" +#endif + }; static void nfsMountCallFunc(const iocshArgBuf *args) { char *cp = args[2].sval; @@ -609,7 +626,11 @@ void zoneset(const char *zone) static const iocshArg zonesetArg0 = {"zone string", iocshArgString}; static const iocshArg * const zonesetArgs[1] = {&zonesetArg0}; -static const iocshFuncDef zonesetFuncDef = {"zoneset",1,zonesetArgs}; +static const iocshFuncDef zonesetFuncDef = {"zoneset",1,zonesetArgs +#ifdef IOCSHFUNCDEF_HAS_USAGE + , "set timezone (obsolete?)" +#endif + }; static void zonesetCallFunc(const iocshArgBuf *args) { zoneset(args[0].sval); @@ -803,7 +824,7 @@ default_network_dhcpcd(void) */ #define LINE_SIZE 256 static void -telnet_pseudoIocsh(char *name, void *arg) +telnet_pseudoIocsh(char *name, __attribute__((unused))void *arg) { char line[LINE_SIZE]; int fid[3], save_fid[3]; @@ -825,7 +846,7 @@ telnet_pseudoIocsh(char *name, void *arg) /* telnet close not detected ??? tbd */ if (fgets(line, LINE_SIZE, stdin) == NULL) { dup2(save_fid[1],1); -+ dup2(save_fid[2],2); + dup2(save_fid[2],2); return; } if (line[strlen(line)-1] == '\n') line[strlen(line)-1] = 0; @@ -861,7 +882,7 @@ rtems_telnetd_config_table rtems_telnetd_config = { * RTEMS Startup task */ void * -POSIX_Init (void *argument) +POSIX_Init (__attribute__((unused)) void *argument) { int result; char *argv[3] = { NULL, NULL, NULL }; @@ -940,7 +961,7 @@ POSIX_Init (void *argument) * * start qemu like this * qemu-system-i386 -m 64 -no-reboot -serial stdio -display none \ - * -net nic,model=e1000,macaddr=0e:b0:ba:5e:ba:11 -net user,restrict=yes \ + * -net nic,model=rtl8139,macaddr=0e:b0:ba:5e:ba:11 -net user,restrict=yes \ * -append "--video=off --console=/dev/com1" -kernel libComTestHarness */ printf("\n***** Initializing network (libbsd, dhcpcd) *****\n"); @@ -1020,7 +1041,7 @@ POSIX_Init (void *argument) rtems_bsdnet_config.ntp_server[0] = cp; int rtems_bsdnet_ntpserver_count = 1; - struct in_addr rtems_bsdnet_ntpserver[1]; + struct in_addr rtems_bsdnet_ntpserver[rtems_bsdnet_ntpserver_count]; memcpy(rtems_bsdnet_ntpserver, rtems_bsdnet_config.ntp_server, sizeof(struct in_addr)); if (rtems_bsdnet_config.network_task_priority == 0) From 08b7dd12083dec4e8640cb2e873812ffb1b4814c Mon Sep 17 00:00:00 2001 From: Heinz Junkes Date: Fri, 15 Jan 2021 17:22:58 +0100 Subject: [PATCH 032/195] Add dhcp option cmdline (129) --- configure/CONFIG_SITE | 2 +- configure/os/CONFIG.Common.RTEMS-qoriq_e500 | 2 +- configure/os/CONFIG_SITE.Common.RTEMS | 1 + .../test/ioc/db/callbackParallelTest.c | 2 +- modules/database/test/ioc/db/callbackTest.c | 2 +- modules/libcom/RTEMS/posix/rtems_init.c | 25 +++++++++++++------ 6 files changed, 22 insertions(+), 12 deletions(-) diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index fa66d8371..dec7d2ef3 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -103,7 +103,7 @@ # Which target architectures to cross-compile for. # Definitions in configure/os/CONFIG_SITE..Common # may override this setting. -CROSS_COMPILER_TARGET_ARCHS=RTEMS-beatnik +CROSS_COMPILER_TARGET_ARCHS=RTEMS-qoriq_e500 #CROSS_COMPILER_TARGET_ARCHS=vxWorks-ppc32 # If only some of your host architectures can compile the diff --git a/configure/os/CONFIG.Common.RTEMS-qoriq_e500 b/configure/os/CONFIG.Common.RTEMS-qoriq_e500 index 9ea6aec5d..41415c9ca 100644 --- a/configure/os/CONFIG.Common.RTEMS-qoriq_e500 +++ b/configure/os/CONFIG.Common.RTEMS-qoriq_e500 @@ -9,7 +9,7 @@ RTEMS_BSP = qoriq_e500 RTEMS_TARGET_CPU = powerpc GNU_TARGET = powerpc-rtems # optimization trouble in postfix.c -#ARCH_DEP_CFLAGS += -DRTEMS_HAS_ALTIVEC +ARCH_DEP_CFLAGS += -DRTEMS_HAS_ALTIVEC #will use bootp #ARCH_DEP_CFLAGS += -DMY_DO_BOOTP=NULL diff --git a/configure/os/CONFIG_SITE.Common.RTEMS b/configure/os/CONFIG_SITE.Common.RTEMS index e6b3de2ec..6857dc9a9 100644 --- a/configure/os/CONFIG_SITE.Common.RTEMS +++ b/configure/os/CONFIG_SITE.Common.RTEMS @@ -16,6 +16,7 @@ #RTEMS_VERSION = 5 #RTEMS_BASE = /home/h1/DBG/rtems #RTEMS_BASE = /home/ad/MVME6100/rtems/$(RTEMS_VERSION) +#RTEMS_BASE = /opt/RTEMS/qoriq/rtems/$(RTEMS_VERSION) # APS: #RTEMS_VERSION = 4.10.2 diff --git a/modules/database/test/ioc/db/callbackParallelTest.c b/modules/database/test/ioc/db/callbackParallelTest.c index 731ed361b..7955fb6a1 100644 --- a/modules/database/test/ioc/db/callbackParallelTest.c +++ b/modules/database/test/ioc/db/callbackParallelTest.c @@ -54,7 +54,7 @@ typedef struct myPvt { int resultFail; } myPvt; -epicsEventId finished; +static epicsEventId finished; static void myCallback(epicsCallback *pCallback) { diff --git a/modules/database/test/ioc/db/callbackTest.c b/modules/database/test/ioc/db/callbackTest.c index e83943b4a..2863720f0 100644 --- a/modules/database/test/ioc/db/callbackTest.c +++ b/modules/database/test/ioc/db/callbackTest.c @@ -54,7 +54,7 @@ typedef struct myPvt { int resultFail; } myPvt; -epicsEventId finished; +static epicsEventId finished; static void myCallback(epicsCallback *pCallback) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 9247ece07..5b28d2869 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -66,7 +66,6 @@ #include #if __RTEMS_MAJOR__ > 4 #include -#include #endif #include "epicsVersion.h" #include "epicsThread.h" @@ -238,6 +237,7 @@ initialize_local_filesystem(char **argv) argv[0] = rtems_bsdnet_bootp_boot_file_name; if (epicsRtemsMountLocalFilesystem(argv)==0) { return 1; /* FS setup successful */ +#ifdef RTEMS_LEGACY_STACK } else if (_FlashSize && (_DownloadLocation || _FlashBase)) { extern char _edata[]; size_t flashIndex = _edata - _DownloadLocation; @@ -258,6 +258,7 @@ initialize_local_filesystem(char **argv) } printf ("***** Startup script (%s) not in IMFS *****\n", rtems_bsdnet_bootp_cmdline); } +#endif /* only with old stack, check check libbsd dependency! */ } return 0; } @@ -803,7 +804,9 @@ default_network_dhcpcd(void) "option ntp_servers\n" \ "option rtems_cmdline\n" \ "option tftp_server_name\n" \ - "option bootfile_name"; + "option bootfile_name\n" \ + "define 129 string rtems_cmdline\n"; + "vendopt 129 string rtems_cmdline"; n = write(fd, fhi_cfg, sizeof(fhi_cfg) - 1); assert(n == (ssize_t) sizeof(fhi_cfg) - 1); @@ -882,7 +885,7 @@ rtems_telnetd_config_table rtems_telnetd_config = { * RTEMS Startup task */ void * -POSIX_Init (__attribute__((unused)) void *argument) +POSIX_Init ( void *argument __attribute__((unused))) { int result; char *argv[3] = { NULL, NULL, NULL }; @@ -1060,8 +1063,11 @@ POSIX_Init (__attribute__((unused)) void *argument) rtems_bsdnet_synchronize_ntp (0, 0); #endif // not RTEMS_LEGACY_STACK + /* show messages from network after initialization ? good idea? */ + rtems_bsd_set_vprintf_handler(bsd_vprintf_handler_old); + printf("\n***** Setting up file system *****\n"); - initialize_remote_filesystem(argv, initialize_local_filesystem(argv)); + //???initialize_remote_filesystem(argv, initialize_local_filesystem(argv)); fixup_hosts(); /* @@ -1091,9 +1097,9 @@ POSIX_Init (__attribute__((unused)) void *argument) */ #if __RTEMS_MAJOR__>4 // if telnetd is requested ... - printf(" Will try to start telnetd with prio %d ...\n", rtems_telnetd_config.priority); - result = rtems_telnetd_initialize(); - printf (" telnetd initialized with result %d\n", result); + // printf(" Will try to start telnetd with prio %d ...\n", rtems_telnetd_config.priority); + // result = rtems_telnetd_initialize(); + // printf (" telnetd initialized with result %d\n", result); #endif printf ("***** Preparing EPICS application *****\n"); @@ -1107,7 +1113,10 @@ POSIX_Init (__attribute__((unused)) void *argument) printf ("***** IOC application terminating *****\n"); epicsThreadSleep(1.0); epicsExit(result); - return NULL; +#if defined(__rtems__) + delayedPanic("will reset rtems ... end of POSIX_Init"); +#endif + exit(0); } #if defined(QEMU_FIXUPS) From e4885d2446bdb3b6c8a0b907cf32a4736b849dbd Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 19 Jan 2021 09:48:22 -0600 Subject: [PATCH 033/195] Remove redundant CPU_FLAGS use. This variable is included in the generic OP_SYS_LDFLAGS and doesn't need to also be set in OP_SYS_LDFLAGS_kernel. --- configure/os/CONFIG.Common.RTEMS | 2 +- modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS}/osdEnv.c | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS}/osdEnv.c (100%) diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 708363a69..c9f22b343 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -115,7 +115,7 @@ OP_SYS_LDLIBS_kernel_NET_no = -lCom -lnfs OP_SYS_LDLIBS += -lrtemsCom -lCom -lc -lrtemscpu $(OP_SYS_LDLIBS_$(OS_API)_NET_$(RTEMS_HAS_NETWORKING)) -lm OP_SYS_LDFLAGS_posix = -u POSIX_Init -OP_SYS_LDFLAGS_kernel = $(CPU_FLAGS) -u Init \ +OP_SYS_LDFLAGS_kernel = -u Init \ $(PROJECT_RELEASE)/lib/no-dpmem.rel \ $(PROJECT_RELEASE)/lib/no-mp.rel \ $(PROJECT_RELEASE)/lib/no-part.rel \ diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdEnv.c b/modules/libcom/src/osi/os/RTEMS/osdEnv.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdEnv.c rename to modules/libcom/src/osi/os/RTEMS/osdEnv.c From fe3e2c60a5aed0a59d07250df80ee2289f0907a2 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 19 Jan 2021 17:23:20 -0600 Subject: [PATCH 034/195] remove missing rtems_bsd_set_vprintf_handler --- modules/libcom/RTEMS/posix/rtems_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 5b28d2869..bc7dc7284 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -1064,7 +1064,7 @@ POSIX_Init ( void *argument __attribute__((unused))) #endif // not RTEMS_LEGACY_STACK /* show messages from network after initialization ? good idea? */ - rtems_bsd_set_vprintf_handler(bsd_vprintf_handler_old); + //rtems_bsd_set_vprintf_handler(bsd_vprintf_handler_old); printf("\n***** Setting up file system *****\n"); //???initialize_remote_filesystem(argv, initialize_local_filesystem(argv)); From 277e9050a8b6f12b4bb4494498eff58329837500 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Wed, 20 Jan 2021 09:34:10 -0600 Subject: [PATCH 035/195] Fixes for CI mechanics - Removed .travis.yml since we're no longer using travis. - Named the rtems pc686 target in github actions - Cleaned up CONFIG_SITE.Common.RTEMS --- .github/workflows/ci-scripts-build.yml | 1 + configure/CONFIG_SITE | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index 79b85ccd9..dce5dedbb 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -75,6 +75,7 @@ jobs: configuration: default rtems: "5" rtems_target: RTEMS-pc686-qemu + name: "Ub-20 gcc-9 + RT-5.1" test: NO - os: ubuntu-20.04 diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index dec7d2ef3..eb6a96bad 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -103,7 +103,6 @@ # Which target architectures to cross-compile for. # Definitions in configure/os/CONFIG_SITE..Common # may override this setting. -CROSS_COMPILER_TARGET_ARCHS=RTEMS-qoriq_e500 #CROSS_COMPILER_TARGET_ARCHS=vxWorks-ppc32 # If only some of your host architectures can compile the From e2927417c3466ee65356214c2b745ea2ccd3a427 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Wed, 20 Jan 2021 10:25:54 -0600 Subject: [PATCH 036/195] Remove tab from ci-scripts-build.yml --- .github/workflows/ci-scripts-build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index dce5dedbb..e88684ff9 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -75,7 +75,7 @@ jobs: configuration: default rtems: "5" rtems_target: RTEMS-pc686-qemu - name: "Ub-20 gcc-9 + RT-5.1" + name: "Ub-20 gcc-9 + RT-5.1" test: NO - os: ubuntu-20.04 From a5604ccbf09243047ba716811e64145920fdbfe6 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Thu, 21 Jan 2021 17:50:02 -0600 Subject: [PATCH 037/195] Reintroduce API_CPPFLAGS argument to fix Windows builds --- configure/CONFIG_COMMON | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure/CONFIG_COMMON b/configure/CONFIG_COMMON index 9ccdf2804..d56802968 100644 --- a/configure/CONFIG_COMMON +++ b/configure/CONFIG_COMMON @@ -307,7 +307,7 @@ LDLIBS = $(POSIX_LDLIBS) $(ARCH_DEP_LDLIBS) $(DEBUG_LDLIBS) $(OP_SYS_LDLIBS)\ CPPFLAGS = $($(BUILD_CLASS)_CPPFLAGS) $(POSIX_CPPFLAGS) $(OPT_CPPFLAGS)\ $(DEBUG_CPPFLAGS) $(WARN_CPPFLAGS) $(BASE_CPPFLAGS) $(TARGET_CPPFLAGS)\ $(USR_CPPFLAGS) $(CMD_CPPFLAGS) $(ARCH_DEP_CPPFLAGS) $(OP_SYS_CPPFLAGS)\ - $(OP_SYS_INCLUDE_CPPFLAGS) $(CODE_CPPFLAGS) + $(OP_SYS_INCLUDE_CPPFLAGS) $(CODE_CPPFLAGS) $(API_CPPFLAGS) #-------------------------------------------------- # ar definition default From 9cac0b64105f582d0fefca88fe438e515bcc83c9 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Thu, 21 Jan 2021 17:50:55 -0600 Subject: [PATCH 038/195] Make pvData and pvAccess submodules use epics-base Previously they used mdavidsaver's branch in order to pick up some commits that hadn't made it into mainline yet. --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 544d6ea4b..e537fc586 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,10 +1,10 @@ [submodule "modules/pvData"] path = modules/pvData - url = https://github.com/mdavidsaver/pvDataCPP + url = https://github.com/epics-base/pvDataCPP branch = master [submodule "modules/pvAccess"] path = modules/pvAccess - url = https://github.com/mdavidsaver/pvAccessCPP + url = https://github.com/epics-base/pvAccessCPP branch = master [submodule "modules/normativeTypes"] path = modules/normativeTypes From 54c91f145874ec5352c876b356524b75bf3ea0c5 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 2 Feb 2021 16:44:01 -0600 Subject: [PATCH 039/195] Fix compile errors after rebasing changes for RTEMS5 --- configure/os/CONFIG.Common.RTEMS | 3 +-- modules/libcom/RTEMS/kernel/rtems_init.c | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index c9f22b343..fb3b3521a 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -97,8 +97,7 @@ OS_CLASS = RTEMS #-------------------------------------------------- # Operating system compile & link flags -OP_SYS_CFLAGS_API_posix = -D__LINUX_ERRNO_EXTENSIONS__ -OP_SYS_CFLAGS += $(OP_SYS_CFLAGS_API_$(OS_API)) +OP_SYS_CFLAGS += -D__LINUX_ERRNO_EXTENSIONS__ OP_SYS_CFLAGS_NET_yes = -DRTEMS_LEGACY_STACK OP_SYS_CFLAGS_NET_no = -DHAVE_SOCKADDR_SA_LEN=1 diff --git a/modules/libcom/RTEMS/kernel/rtems_init.c b/modules/libcom/RTEMS/kernel/rtems_init.c index 986e09623..99a67226d 100644 --- a/modules/libcom/RTEMS/kernel/rtems_init.c +++ b/modules/libcom/RTEMS/kernel/rtems_init.c @@ -42,7 +42,7 @@ #include "logClient.h" #include "osiUnistd.h" #include "iocsh.h" -#include "osdTime.h" +#include "../../src/osi/os/RTEMS-kernel/osdTime.h" #include "epicsMemFs.h" #include "epicsRtemsInitHooks.h" From 8d7c98aac493d480c54da69f16e91457be763048 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Thu, 4 Feb 2021 12:00:37 -0600 Subject: [PATCH 040/195] Make RTEMS-pc386-qemu use RTEMS-pc386 rather than pc686 --- configure/os/CONFIG.Common.RTEMS-pc386-qemu | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure/os/CONFIG.Common.RTEMS-pc386-qemu b/configure/os/CONFIG.Common.RTEMS-pc386-qemu index 29196ff65..07bf30e7c 100644 --- a/configure/os/CONFIG.Common.RTEMS-pc386-qemu +++ b/configure/os/CONFIG.Common.RTEMS-pc386-qemu @@ -7,6 +7,6 @@ # Include definitions from RTEMS-pc386 # For Tests overwrite it with pc686 -include $(CONFIG)/os/CONFIG.Common.RTEMS-pc686 +include $(CONFIG)/os/CONFIG.Common.RTEMS-pc386 RTEMS_QEMU_FIXUPS = YES From cd0e6a4f9a1d0e847282cbbba3486386f0dc3302 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Fri, 5 Feb 2021 10:42:02 -0600 Subject: [PATCH 041/195] Make sure the definition of IPPORT_USERRESERVED is defined caProto.h was using IPPORT_USERRESERVED but not including itself, meaning there was an order dependency of header inclusion when using this header. Now there shouldn't be. Also, RTEMS wasn't defining IPPORT_USERRESERVED, so that definition has been added. --- modules/ca/src/client/caProto.h | 3 +++ modules/libcom/src/osi/os/RTEMS-kernel/osdSock.h | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/modules/ca/src/client/caProto.h b/modules/ca/src/client/caProto.h index 1af7ec298..397b1edaf 100644 --- a/modules/ca/src/client/caProto.h +++ b/modules/ca/src/client/caProto.h @@ -17,6 +17,9 @@ #ifndef INC_caProto_H #define INC_caProto_H +// Pick up definition of IPPORT_USERRESERVED +#include + #define capStrOf(A) #A #define capStrOfX(A) capStrOf ( A ) diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdSock.h b/modules/libcom/src/osi/os/RTEMS-kernel/osdSock.h index 49023fe78..c70845d84 100644 --- a/modules/libcom/src/osi/os/RTEMS-kernel/osdSock.h +++ b/modules/libcom/src/osi/os/RTEMS-kernel/osdSock.h @@ -37,6 +37,10 @@ int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, str } #endif +#ifndef IPPORT_USERRESERVED +#define IPPORT_USERRESERVED 5000 +#endif + typedef int SOCKET; #define INVALID_SOCKET (-1) #define SOCKERRNO errno From 347d24a2a80214ed0205ac16cbe19ca716842bfb Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Fri, 5 Feb 2021 11:42:42 -0600 Subject: [PATCH 042/195] Switch to rtl8139 network interface for RTEMS tests --- src/tools/makeTestfile.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index efac61aba..183454485 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -42,7 +42,7 @@ elsif ($TA =~ /^RTEMS-pc[36]86-qemu$/) { # Run the pc386 and pc686 test harness w/ QEMU $exec = "qemu-system-i386 -m 64 -no-reboot " . "-serial stdio -display none " - . "-net nic,model=e1000 -net nic,model=ne2k_pci " + . "-net nic,model=rtl8139 -net nic,model=ne2k_pci " . "-net user,restrict=yes " . "-append --console=/dev/com1 " . "-kernel $exe"; From 0adaa7fcf1aa11bb0b595ab38cc27e882f133e6f Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Fri, 5 Feb 2021 13:40:42 -0600 Subject: [PATCH 043/195] re-remove osdMessageQueue.c from RTEMS-kernel --- .../src/osi/os/RTEMS-kernel/osdMessageQueue.c | 251 ------------------ .../src/osi/os/RTEMS-kernel/osdMessageQueue.h | 29 -- 2 files changed, 280 deletions(-) delete mode 100644 modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c delete mode 100644 modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c b/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c deleted file mode 100644 index c7a05fcc5..000000000 --- a/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.c +++ /dev/null @@ -1,251 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2002 The University of Chicago, as Operator of Argonne -* National Laboratory. -* Copyright (c) 2002 The Regents of the University of California, as -* Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ -/* - * Author W. Eric Norum - * norume@aps.anl.gov - * 630 252 4793 - */ - -/* - * We want to access information which is - * normally hidden from application programs. - */ -#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__ 1 - -#define epicsExportSharedSymbols -#include -#include -#include -#include -#include -#include -#include "epicsMessageQueue.h" -#include "errlog.h" - -LIBCOM_API epicsMessageQueueId epicsStdCall -epicsMessageQueueCreate(unsigned int capacity, unsigned int maximumMessageSize) -{ - rtems_status_code sc; - epicsMessageQueueId id = calloc(1, sizeof(*id)); - rtems_interrupt_level level; - static char c1 = 'a'; - static char c2 = 'a'; - static char c3 = 'a'; - - if(!id) - return NULL; - - sc = rtems_message_queue_create (rtems_build_name ('Q', c3, c2, c1), - capacity, - maximumMessageSize, - RTEMS_FIFO|RTEMS_LOCAL, - &id->id); - if (sc != RTEMS_SUCCESSFUL) { - free(id); - errlogPrintf ("Can't create message queue: %s\n", rtems_status_text (sc)); - return NULL; - } - id->maxSize = maximumMessageSize; - id->localBuf = NULL; - rtems_interrupt_disable (level); - if (c1 == 'z') { - if (c2 == 'z') { - if (c3 == 'z') { - c3 = 'a'; - } - else { - c3++; - } - c2 = 'a'; - } - else { - c2++; - } - c1 = 'a'; - } - else { - c1++; - } - rtems_interrupt_enable (level); - return id; -} - -static rtems_status_code rtems_message_queue_send_timeout( - rtems_id id, - void *buffer, - uint32_t size, - rtems_interval timeout) -{ - Message_queue_Control *the_message_queue; - Objects_Locations location; - CORE_message_queue_Status msg_status; - - the_message_queue = _Message_queue_Get( id, &location ); - switch ( location ) - { - case OBJECTS_ERROR: - return RTEMS_INVALID_ID; - - case OBJECTS_LOCAL: - msg_status = _CORE_message_queue_Send( - &the_message_queue->message_queue, - buffer, - size, - id, - NULL, - 1, - timeout - ); - - _Thread_Enable_dispatch(); - - /* - * If we had to block, then this is where the task returns - * after it wakes up. The returned status is correct for - * non-blocking operations but if we blocked, then we need - * to look at the status in our TCB. - */ - - if ( msg_status == CORE_MESSAGE_QUEUE_STATUS_UNSATISFIED_WAIT ) - msg_status = _Thread_Executing->Wait.return_code; - return _Message_queue_Translate_core_message_queue_return_code( msg_status ); - } - return RTEMS_INTERNAL_ERROR; /* unreached - only to remove warnings */ -} - -LIBCOM_API int epicsStdCall epicsMessageQueueSend( - epicsMessageQueueId id, - void *message, - unsigned int messageSize) -{ - if (rtems_message_queue_send_timeout(id->id, message, messageSize, RTEMS_NO_TIMEOUT) == RTEMS_SUCCESSFUL) - return 0; - else - return -1; -} - -LIBCOM_API int epicsStdCall epicsMessageQueueSendWithTimeout( - epicsMessageQueueId id, - void *message, - unsigned int messageSize, - double timeout) -{ - rtems_interval delay; - extern double rtemsTicksPerSecond_double; - - /* - * Convert time to ticks - */ - if (timeout <= 0.0) - return epicsMessageQueueTrySend(id, message, messageSize); - delay = (int)(timeout * rtemsTicksPerSecond_double); - if (delay == 0) - delay++; - if (rtems_message_queue_send_timeout(id->id, message, messageSize, delay) == RTEMS_SUCCESSFUL) - return 0; - else - return -1; -} - -static int receiveMessage( - epicsMessageQueueId id, - void *buffer, - uint32_t size, - uint32_t wait, - rtems_interval delay) -{ - size_t rsize; - rtems_status_code sc; - - if (size < id->maxSize) { - if (id->localBuf == NULL) { - id->localBuf = malloc(id->maxSize); - if (id->localBuf == NULL) - return -1; - } - rsize = receiveMessage(id, id->localBuf, id->maxSize, wait, delay); - if (rsize > size) - return -1; - memcpy(buffer, id->localBuf, rsize); - } - else { - sc = rtems_message_queue_receive(id->id, buffer, &rsize, wait, delay); - if (sc != RTEMS_SUCCESSFUL) - return -1; - } - return rsize; -} - -LIBCOM_API int epicsStdCall epicsMessageQueueTryReceive( - epicsMessageQueueId id, - void *message, - unsigned int size) -{ - return receiveMessage(id, message, size, RTEMS_NO_WAIT, 0); -} - -LIBCOM_API int epicsStdCall epicsMessageQueueReceive( - epicsMessageQueueId id, - void *message, - unsigned int size) -{ - return receiveMessage(id, message, size, RTEMS_WAIT, RTEMS_NO_TIMEOUT); -} - -LIBCOM_API int epicsStdCall epicsMessageQueueReceiveWithTimeout( - epicsMessageQueueId id, - void *message, - unsigned int size, - double timeout) -{ - rtems_interval delay; - uint32_t wait; - extern double rtemsTicksPerSecond_double; - - /* - * Convert time to ticks - */ - if (timeout <= 0.0) { - wait = RTEMS_NO_WAIT; - delay = 0; - } - else { - wait = RTEMS_WAIT; - delay = (int)(timeout * rtemsTicksPerSecond_double); - if (delay == 0) - delay++; - } - return receiveMessage(id, message, size, wait, delay); -} - -LIBCOM_API int epicsStdCall epicsMessageQueuePending( - epicsMessageQueueId id) -{ - uint32_t count; - rtems_status_code sc; - - sc = rtems_message_queue_get_number_pending(id->id, &count); - if (sc != RTEMS_SUCCESSFUL) { - errlogPrintf("Message queue %x get number pending failed: %s\n", - (unsigned int)id, - rtems_status_text(sc)); - return -1; - } - return count; -} - -LIBCOM_API void epicsStdCall epicsMessageQueueShow( - epicsMessageQueueId id, - int level) -{ - int pending = epicsMessageQueuePending(id); - if (pending >= 0) - printf ("Message queue %lx -- Pending: %d\n", (unsigned long)id, pending); -} diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h b/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h deleted file mode 100644 index 0244a1f0b..000000000 --- a/modules/libcom/src/osi/os/RTEMS-kernel/osdMessageQueue.h +++ /dev/null @@ -1,29 +0,0 @@ -/*************************************************************************\ -* Copyright (c) 2002 The University of Chicago, as Operator of Argonne -* National Laboratory. -* Copyright (c) 2002 The Regents of the University of California, as -* Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. -\*************************************************************************/ -/* - * Author W. Eric Norum - * norume@aps.anl.gov - * 630 252 4793 - */ - -/* - * Very thin shims around RTEMS routines - */ -#include - -struct epicsMessageQueueOSD { - rtems_id id; - unsigned int maxSize; - void *localBuf; - -}; -#define epicsMessageQueueDestroy(q) (rtems_message_queue_delete((q)->id)) - -#define epicsMessageQueueTrySend(q,m,l) (rtems_message_queue_send((q)->id, (m), (l)) == RTEMS_SUCCESSFUL ? 0 : -1) From 518ac1d7c1b435adf925bd164ceaa713333a631b Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Fri, 5 Feb 2021 14:01:12 -0600 Subject: [PATCH 044/195] Remove define of bzero to use memset As far as I can tell, we don't use bzero(). --- modules/libcom/src/osi/os/RTEMS-kernel/osdSock.h | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdSock.h b/modules/libcom/src/osi/os/RTEMS-kernel/osdSock.h index c70845d84..3090234af 100644 --- a/modules/libcom/src/osi/os/RTEMS-kernel/osdSock.h +++ b/modules/libcom/src/osi/os/RTEMS-kernel/osdSock.h @@ -72,7 +72,6 @@ typedef unsigned char osiSockOptMcastTTL_t; #define SOCK_ENOTSOCK ENOTSOCK #define SOCK_EBADF EBADF -#define bzero(p,n) memset(p,0,n) #include #include #include From 188f46f74bd04a024c7867a45e0ace398ddcab9a Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Fri, 5 Feb 2021 14:26:02 -0600 Subject: [PATCH 045/195] Remove prototype definition of select() from osdSock.h --- modules/libcom/src/osi/os/RTEMS-posix/osdSock.h | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h b/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h index 0682256b6..5d765b3a7 100644 --- a/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h @@ -28,17 +28,6 @@ #include #include /* close() and others */ -#ifdef RTEMS_LEGACY_STACK -#ifdef __cplusplus -extern "C" { -#endif - -int select(int n, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, struct timeval *timeout); - -#ifdef __cplusplus -} -#endif -#endif // LEGACY_STACK typedef int SOCKET; #define INVALID_SOCKET (-1) #define SOCKERRNO errno From ce264306b8c3e0c9bf652c9843625d4b76f6207c Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Fri, 5 Feb 2021 15:10:22 -0600 Subject: [PATCH 046/195] Fix merge issues with src/tools/makeTestfile.pl When I switched from merge to rebase of RTEMS5 changes, I think this file didn't get merge correctly. These changes bring the file back to match what was originally merged, and I believe correct. --- src/tools/makeTestfile.pl | 58 ++++++++++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index 183454485..686e3c1a3 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -6,7 +6,7 @@ # Operator of Los Alamos National Laboratory. # SPDX-License-Identifier: EPICS # EPICS BASE is distributed subject to a Software License Agreement found -# in file LICENSE that is included with this distribution. +# in file LICENSE that is included with this distribution. #************************************************************************* # The makeTestfile.pl script generates a file $target.t which is needed @@ -41,11 +41,11 @@ elsif ($TA =~ /^windows-x64/ && $HA !~ /^win/) { elsif ($TA =~ /^RTEMS-pc[36]86-qemu$/) { # Run the pc386 and pc686 test harness w/ QEMU $exec = "qemu-system-i386 -m 64 -no-reboot " - . "-serial stdio -display none " - . "-net nic,model=rtl8139 -net nic,model=ne2k_pci " - . "-net user,restrict=yes " - . "-append --console=/dev/com1 " - . "-kernel $exe"; + . "-serial stdio -display none " + . "-net nic,model=rtl8139 -net nic,model=ne2k_pci " + . "-net user,restrict=yes " + . "-append --console=/dev/com1 " + . "-kernel $exe"; $error = "qemu-system-i386 ... -kernel $exe"; } elsif ($TA =~ /^RTEMS-/) { @@ -57,26 +57,52 @@ else { $error = $exec = "./$exe"; } -# Run the test program with system on Windows, exec elsewhere. -# This is required by the Perl test harness. -my $runtest = ($^O eq 'MSWin32') ? - "system('$exec') == 0" : "exec '$exec'"; +# Ensure that Windows interactive error handling is disabled. +# This setting is inherited by the test process. +# Set SEM_FAILCRITICALERRORS (1) Disable critical-error-handler dialog +# Clear SEM_NOGPFAULTERRORBOX (2) Enabled WER to allow automatic post mortem debugging (AeDebug) +# Clear SEM_NOALIGNMENTFAULTEXCEPT (4) Allow alignment fixups +# Set SEM_NOOPENFILEERRORBOX (0x8000) Prevent dialog on some I/O errors +# https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-seterrormode?redirectedfrom=MSDN +my $sem = $^O ne 'MSWin32' ? '' : <import(\$sem); + }; + eval { + require Win32API::File; + Win32API::File->import(\$sem); + } if \$@; + SetErrorMode(0x8001) unless \$@; +} +ENDBEGIN open my $OUT, '>', $target or die "Can't create $target: $!\n"; -print $OUT <<__EOF__; +print $OUT <> 8; +} +else { + exec '$exec' or die "Can't run $exec: \$!\\n"; +} +EOF -close $OUT + close $OUT or die "Can't close $target: $!\n"; From c523fe7a3e744b33486a81480ed852ba81370f88 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Fri, 5 Feb 2021 15:25:56 -0600 Subject: [PATCH 047/195] Restore CROSS_COMPILER_TARGET_ARCHS initialization in CONFIG_SITE --- configure/CONFIG_SITE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index eb6a96bad..6fd0033dd 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -103,7 +103,7 @@ # Which target architectures to cross-compile for. # Definitions in configure/os/CONFIG_SITE..Common # may override this setting. -#CROSS_COMPILER_TARGET_ARCHS=vxWorks-ppc32 +CROSS_COMPILER_TARGET_ARCHS= # If only some of your host architectures can compile the # above CROSS_COMPILER_TARGET_ARCHS specify those host From 6bf26782a019297edd89b5c9a8d65607bcfbedda Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 9 Feb 2021 14:25:55 -0600 Subject: [PATCH 048/195] Fix license comment in epicsNtp.c and .h --- modules/libcom/RTEMS/epicsNtp.c | 3 +-- modules/libcom/RTEMS/epicsNtp.h | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/modules/libcom/RTEMS/epicsNtp.c b/modules/libcom/RTEMS/epicsNtp.c index 9dcd6cd69..760d62610 100644 --- a/modules/libcom/RTEMS/epicsNtp.c +++ b/modules/libcom/RTEMS/epicsNtp.c @@ -1,8 +1,7 @@ /*************************************************************************\ * (C) 2014 David Lettier. * http://www.lettier.com/ -* EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* SPDX-License-Identifier: BSD-3-Clause \*************************************************************************/ #include diff --git a/modules/libcom/RTEMS/epicsNtp.h b/modules/libcom/RTEMS/epicsNtp.h index dfff00a6b..062970f30 100644 --- a/modules/libcom/RTEMS/epicsNtp.h +++ b/modules/libcom/RTEMS/epicsNtp.h @@ -1,8 +1,7 @@ /*************************************************************************\ * (C) 2014 David Lettier. * http://www.lettier.com/ -* EPICS BASE is distributed subject to a Software License Agreement found -* in file LICENSE that is included with this distribution. +* SPDX-License-Identifier: BSD-3-Clause \*************************************************************************/ #ifndef EPICSNTP_H #define EPICSNTP_H From ea40041b45f4e5522e754def38792090758aaa1b Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 9 Feb 2021 14:26:26 -0600 Subject: [PATCH 049/195] Remove FHI specific information from NTP and bootp variable init --- modules/libcom/RTEMS/posix/rtems_init.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index bc7dc7284..4b082b34d 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -95,12 +95,11 @@ epicsEventId dhcpDone; /* these settings are needed by the rtems startup * may provide by dhcp/bootp * or environments from the "BIOS" like u-boot, motboot etc. - * these are settings within FHI infrastructure (01/13/2021) */ -char rtemsInit_NTP_server_ip[16] = "141.14.142.121"; -char bootp_server_name_init[128] = "1001.1001@141.14.128.9:/Volumes/Epics"; -char bootp_boot_file_name_init[128] = "/Volumes/Epics/myExample/bin/RTEMS-beatnik/myExample.boot"; -char bootp_cmdline_init[128] = "/Volumes/Epics/myExample/iocBoot/iocmyExample/st.cmd"; +char rtemsInit_NTP_server_ip[16] = "10.0.5.1"; +char bootp_server_name_init[128] = "1001.1001@10.0.5.1:/epics"; +char bootp_boot_file_name_init[128] = "/epics/myExample/bin/RTEMS-beatnik/myExample.boot"; +char bootp_cmdline_init[128] = "/epics/myExample/iocBoot/iocmyExample/st.cmd"; struct in_addr rtems_bsdnet_bootp_server_address; /* TODO check rtems_bsdnet_bootp_cmdline */ @@ -767,10 +766,6 @@ default_network_on_exit(int exit_code, void *arg) rtems_print_printer_printf(&printer); rtems_stack_checker_report_usage_with_plugin(&printer); - - if (exit_code == 0) { - puts("*** END OF TEST ***"); - } } static void From e4b17bdab5f7067dc9b7f2a81b52351b4ea47724 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 9 Feb 2021 14:27:24 -0600 Subject: [PATCH 050/195] Remove local def of VERSION_INIT in favor of one from epicsVersion.h --- modules/libcom/RTEMS/rtems_netconfig.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/libcom/RTEMS/rtems_netconfig.c b/modules/libcom/RTEMS/rtems_netconfig.c index 2ce9293d8..0207512c7 100644 --- a/modules/libcom/RTEMS/rtems_netconfig.c +++ b/modules/libcom/RTEMS/rtems_netconfig.c @@ -15,13 +15,10 @@ */ #include #include +#include -#ifndef VERSION_INT -# define VERSION_INT(V,R,M,P) ( ((V)<<24) | ((R)<<16) | ((M)<<8) | (P)) -#endif #define RTEMS_VERSION_INT VERSION_INT(__RTEMS_MAJOR__, __RTEMS_MINOR__, 0, 0) - #ifdef RTEMS_LEGACY_STACK // old non libbsd stack #include From a8262573f5cdd4109b5beea1e4618139628ac5c0 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 9 Feb 2021 14:28:11 -0600 Subject: [PATCH 051/195] Don't use or include mlock() on RTEMS --- modules/libcom/src/osi/os/posix/osdThread.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/modules/libcom/src/osi/os/posix/osdThread.c b/modules/libcom/src/osi/os/posix/osdThread.c index 41f46479e..22321caca 100644 --- a/modules/libcom/src/osi/os/posix/osdThread.c +++ b/modules/libcom/src/osi/os/posix/osdThread.c @@ -24,10 +24,9 @@ #include #include -#if defined(_POSIX_MEMLOCK) && _POSIX_MEMLOCK > 0 -#ifndef RTEMS_LEGACY_STACK // seems to be part of libbsd? +#define USE_MEMLOCK (defined(_POSIX_MEMLOCK) && (_POSIX_MEMLOCK > 0) && !defined(__rtems__)) +#if USE_MEMLOCK #include -#endif // LEGACY STACK #endif #include "epicsStdio.h" @@ -427,7 +426,7 @@ static void epicsThreadInit(void) LIBCOM_API void epicsThreadRealtimeLock(void) { -#if defined(_POSIX_MEMLOCK) && _POSIX_MEMLOCK > 0 +#if USE_MEMLOCK #ifndef RTEMS_LEGACY_STACK // seems to be part of libbsd? if (pcommonAttr->maxPriority > pcommonAttr->minPriority) { int status = mlockall(MCL_CURRENT | MCL_FUTURE); From 3fd9ffc995001b0bf6bc888837a053909b4a47d0 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 9 Feb 2021 15:05:31 -0600 Subject: [PATCH 052/195] Include osdTime using compiler include path Previously it was using a relative directory name, #included in the .c file. --- modules/libcom/RTEMS/kernel/rtems_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/libcom/RTEMS/kernel/rtems_init.c b/modules/libcom/RTEMS/kernel/rtems_init.c index 99a67226d..986e09623 100644 --- a/modules/libcom/RTEMS/kernel/rtems_init.c +++ b/modules/libcom/RTEMS/kernel/rtems_init.c @@ -42,7 +42,7 @@ #include "logClient.h" #include "osiUnistd.h" #include "iocsh.h" -#include "../../src/osi/os/RTEMS-kernel/osdTime.h" +#include "osdTime.h" #include "epicsMemFs.h" #include "epicsRtemsInitHooks.h" From 4755d6c7f036c52ca365d9fecd719eef87734eb1 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Fri, 12 Feb 2021 09:11:42 -0600 Subject: [PATCH 053/195] Enable tests for RTEMS5 --- .github/workflows/ci-scripts-build.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index e88684ff9..b3aef6467 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -76,7 +76,6 @@ jobs: rtems: "5" rtems_target: RTEMS-pc686-qemu name: "Ub-20 gcc-9 + RT-5.1" - test: NO - os: ubuntu-20.04 cmp: gcc From c628db82acff738763d90ecfe1ca9fd1d1cdbc7f Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 16 Feb 2021 12:51:11 -0600 Subject: [PATCH 054/195] RTEMS DHCP: Use safer versions of string functions Use strtok_r rather than strtok Use strlen() rather than harcoded string size. GCC should optimize this to the hardcoded string size, so the result should be the same but maybe prevents future mistakes. replace strncpy() with snprintf() to avoid issues with NULL terminated strings. --- modules/libcom/RTEMS/posix/rtems_init.c | 67 ++++++++++++++++--------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 4b082b34d..79962c142 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -707,50 +707,71 @@ dhcpcd_hook_handler(rtems_dhcpcd_hook *hook, char *const *env) char iName[16]; char *name; char *value; - + char * env_position; + (void)hook; char ifnamebuf[IF_NAMESIZE]; sprintf(ifnamebuf, "%s", getPrimaryNetworkInterface()); while (*env != NULL) { - name = strtok(*env,"="); - value = strtok(NULL,"="); + char const * interface = "interface"; + char const * reason = "reason"; + char const * bound = "BOUND"; + + name = strtok_r(*env,"=", &env_position); + value = strtok_r(NULL,"=", &env_position); printf("all out ---> %s = %s\n", name, value); - if (!strncmp(name, "interface", 9) && !strcmp(value, ifnamebuf)) - strncpy(iName, value, 16); - if (!strncmp(name, "reason", 6) && !strncmp(value, "BOUND", 5)){ + + if (!strncmp(name, interface, strlen(interface)) && + !strcmp(value, ifnamebuf)) { + snprintf(iName, sizeof(iName), "%s", value); + } + + if (!strncmp(name, reason, strlen(reason)) && + !strncmp(value, bound, strlen(bound))) { printf ("Interface %s bounded\n", iName); bound = 1; - } - if (bound) { + } + + if (bound) { // as there is no ntp-support in rtems-libbsd, we call our own client - if(!strncmp(name, "new_ntp_servers", 15)) - strcpy(rtemsInit_NTP_server_ip,value); - if(!strncmp(name, "new_host_name", 13)) + char const * new_ntp_servers = "new_ntp_servers"; + char const * new_host_name = "new_host_name"; + char const * new_tftp_server_name = "new_tftp_server_name"; + + if (!strncmp(name, new_ntp_servers, strlen(new_ntp_servers))) + snprintf(rtemsInit_NTP_server_ip, + sizeof(rtemsInit_NTP_server_ip), + "%s", value); + + if (!strncmp(name, new_host_name, strlen(new_host_name))) sethostname (value, strlen (value)); - if(!strncmp(name, "new_tftp_server_name", 20)){ - //printf(" new_tftp_server_name : %s\n", value); - strncpy(rtems_bsdnet_bootp_server_name,value, sizeof(bootp_server_name_init)); + + if (!strncmp(name, new_tftp_server_name, strlen(new_tftp_server_name))){ + snprintf(rtems_bsdnet_bootp_server_name, + sizeof(bootp_server_name_init), + "%s", value); printf(" rtems_bsdnet_bootp_server_name : %s\n", rtems_bsdnet_bootp_server_name); } if(!strncmp(name, "new_bootfile_name", 20)){ - //printf(" new_bootfile_name : %s\n", value); - strncpy(rtems_bsdnet_bootp_boot_file_name,value, sizeof(bootp_boot_file_name_init)); + snprintf(rtems_bsdnet_bootp_boot_file_name, + sizeof(bootp_boot_file_name_init), + "%s", value); printf(" rtems_bsdnet_bootp_boot_file_name : %s\n", rtems_bsdnet_bootp_boot_file_name); } if(!strncmp(name, "new_rtems_cmdline", 20)){ - //printf(" new_rtems_cmdline : %s\n", value); - strncpy(rtems_bsdnet_bootp_cmdline,value, sizeof(bootp_cmdline_init)); + snprintf(rtems_bsdnet_bootp_cmdline, + sizeof(bootp_cmdline_init), + "%s", value); printf(" rtems_bsdnet_bootp_cmdline : %s\n", rtems_bsdnet_bootp_cmdline); } - // printf("---> %s = %s\n", name, value); - } - ++env; - } + } + ++env; + } if (bound) epicsEventSignal(dhcpDone); - } +} static rtems_dhcpcd_hook dhcpcd_hook = { .name = "ioc boot", From e38a8b15d490b597c634f183419b5ab15770f8cf Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 16 Feb 2021 15:11:40 -0600 Subject: [PATCH 055/195] squash me --- modules/libcom/RTEMS/posix/rtems_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 79962c142..470905559 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -717,7 +717,7 @@ dhcpcd_hook_handler(rtems_dhcpcd_hook *hook, char *const *env) while (*env != NULL) { char const * interface = "interface"; char const * reason = "reason"; - char const * bound = "BOUND"; + char const * bound_str = "BOUND"; name = strtok_r(*env,"=", &env_position); value = strtok_r(NULL,"=", &env_position); @@ -729,7 +729,7 @@ dhcpcd_hook_handler(rtems_dhcpcd_hook *hook, char *const *env) } if (!strncmp(name, reason, strlen(reason)) && - !strncmp(value, bound, strlen(bound))) { + !strncmp(value, bound_str, strlen(bound_str))) { printf ("Interface %s bounded\n", iName); bound = 1; } From 125fc089939a6a853263882347c5704ec574c61f Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 16 Feb 2021 15:12:06 -0600 Subject: [PATCH 056/195] Clean up a couple warnings in RTEMS code --- modules/libcom/RTEMS/posix/rtems_init.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 470905559..d192041be 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -822,7 +822,6 @@ default_network_dhcpcd(void) "option tftp_server_name\n" \ "option bootfile_name\n" \ "define 129 string rtems_cmdline\n"; - "vendopt 129 string rtems_cmdline"; n = write(fd, fhi_cfg, sizeof(fhi_cfg) - 1); assert(n == (ssize_t) sizeof(fhi_cfg) - 1); @@ -991,8 +990,7 @@ POSIX_Init ( void *argument __attribute__((unused))) default_network_set_self_prio(RTEMS_MAXIMUM_PRIORITY - 1U); /* supress all output from bsd network initialization */ - rtems_bsd_vprintf_handler bsd_vprintf_handler_old; - bsd_vprintf_handler_old = rtems_bsd_set_vprintf_handler(rtems_bsd_vprintf_handler_mute); + rtems_bsd_set_vprintf_handler(rtems_bsd_vprintf_handler_mute); sc = rtems_bsd_initialize(); assert(sc == RTEMS_SUCCESSFUL); From b0dfb768715b941a83495a05ed63c8ce037f30d9 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 16 Feb 2021 15:12:28 -0600 Subject: [PATCH 057/195] Change telnetd configuration to use defaults Currently, this configuration doesn't seem to be used yet, but regardless we'll update the settings to use RTEMS defaults. --- modules/libcom/RTEMS/posix/rtems_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index d192041be..141abafea 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -882,13 +882,14 @@ telnet_pseudoIocsh(char *name, __attribute__((unused))void *arg) /* * Telnet daemon configuration + * 0 or NULL for most fields in thsi struct indicate default values to RTEMS. */ rtems_telnetd_config_table rtems_telnetd_config = { .command = SHELL_ENTRY, .arg = NULL, - .priority = 99, // if RTEMS_NETWORK and .priority == 0 bsd_network_prio should be used ... + .priority = 0, .stack_size = 0, - .client_maximum = 5, // should be 1, on RTEMS and Epics it makes only sense for one connection a time + .client_maximum = 0, .login_check = NULL, .keep_stdio = false }; From a309912c8b80e89b0968bd7d24f10af8bb0afa20 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 16 Feb 2021 12:51:11 -0600 Subject: [PATCH 058/195] RTEMS DHCP: Use safer versions of string functions Use strtok_r rather than strtok Use strlen() rather than harcoded string size. GCC should optimize this to the hardcoded string size, so the result should be the same but maybe prevents future mistakes. replace strncpy() with snprintf() to avoid issues with NULL terminated strings. --- modules/libcom/RTEMS/posix/rtems_init.c | 67 ++++++++++++++++--------- 1 file changed, 44 insertions(+), 23 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 4b082b34d..470905559 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -707,50 +707,71 @@ dhcpcd_hook_handler(rtems_dhcpcd_hook *hook, char *const *env) char iName[16]; char *name; char *value; - + char * env_position; + (void)hook; char ifnamebuf[IF_NAMESIZE]; sprintf(ifnamebuf, "%s", getPrimaryNetworkInterface()); while (*env != NULL) { - name = strtok(*env,"="); - value = strtok(NULL,"="); + char const * interface = "interface"; + char const * reason = "reason"; + char const * bound_str = "BOUND"; + + name = strtok_r(*env,"=", &env_position); + value = strtok_r(NULL,"=", &env_position); printf("all out ---> %s = %s\n", name, value); - if (!strncmp(name, "interface", 9) && !strcmp(value, ifnamebuf)) - strncpy(iName, value, 16); - if (!strncmp(name, "reason", 6) && !strncmp(value, "BOUND", 5)){ + + if (!strncmp(name, interface, strlen(interface)) && + !strcmp(value, ifnamebuf)) { + snprintf(iName, sizeof(iName), "%s", value); + } + + if (!strncmp(name, reason, strlen(reason)) && + !strncmp(value, bound_str, strlen(bound_str))) { printf ("Interface %s bounded\n", iName); bound = 1; - } - if (bound) { + } + + if (bound) { // as there is no ntp-support in rtems-libbsd, we call our own client - if(!strncmp(name, "new_ntp_servers", 15)) - strcpy(rtemsInit_NTP_server_ip,value); - if(!strncmp(name, "new_host_name", 13)) + char const * new_ntp_servers = "new_ntp_servers"; + char const * new_host_name = "new_host_name"; + char const * new_tftp_server_name = "new_tftp_server_name"; + + if (!strncmp(name, new_ntp_servers, strlen(new_ntp_servers))) + snprintf(rtemsInit_NTP_server_ip, + sizeof(rtemsInit_NTP_server_ip), + "%s", value); + + if (!strncmp(name, new_host_name, strlen(new_host_name))) sethostname (value, strlen (value)); - if(!strncmp(name, "new_tftp_server_name", 20)){ - //printf(" new_tftp_server_name : %s\n", value); - strncpy(rtems_bsdnet_bootp_server_name,value, sizeof(bootp_server_name_init)); + + if (!strncmp(name, new_tftp_server_name, strlen(new_tftp_server_name))){ + snprintf(rtems_bsdnet_bootp_server_name, + sizeof(bootp_server_name_init), + "%s", value); printf(" rtems_bsdnet_bootp_server_name : %s\n", rtems_bsdnet_bootp_server_name); } if(!strncmp(name, "new_bootfile_name", 20)){ - //printf(" new_bootfile_name : %s\n", value); - strncpy(rtems_bsdnet_bootp_boot_file_name,value, sizeof(bootp_boot_file_name_init)); + snprintf(rtems_bsdnet_bootp_boot_file_name, + sizeof(bootp_boot_file_name_init), + "%s", value); printf(" rtems_bsdnet_bootp_boot_file_name : %s\n", rtems_bsdnet_bootp_boot_file_name); } if(!strncmp(name, "new_rtems_cmdline", 20)){ - //printf(" new_rtems_cmdline : %s\n", value); - strncpy(rtems_bsdnet_bootp_cmdline,value, sizeof(bootp_cmdline_init)); + snprintf(rtems_bsdnet_bootp_cmdline, + sizeof(bootp_cmdline_init), + "%s", value); printf(" rtems_bsdnet_bootp_cmdline : %s\n", rtems_bsdnet_bootp_cmdline); } - // printf("---> %s = %s\n", name, value); - } - ++env; - } + } + ++env; + } if (bound) epicsEventSignal(dhcpDone); - } +} static rtems_dhcpcd_hook dhcpcd_hook = { .name = "ioc boot", From af88e9f6c6e58c88baa23ea810bf4d9b56c8098a Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 16 Feb 2021 15:12:06 -0600 Subject: [PATCH 059/195] Clean up a couple warnings in RTEMS code --- modules/libcom/RTEMS/posix/rtems_init.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 470905559..d192041be 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -822,7 +822,6 @@ default_network_dhcpcd(void) "option tftp_server_name\n" \ "option bootfile_name\n" \ "define 129 string rtems_cmdline\n"; - "vendopt 129 string rtems_cmdline"; n = write(fd, fhi_cfg, sizeof(fhi_cfg) - 1); assert(n == (ssize_t) sizeof(fhi_cfg) - 1); @@ -991,8 +990,7 @@ POSIX_Init ( void *argument __attribute__((unused))) default_network_set_self_prio(RTEMS_MAXIMUM_PRIORITY - 1U); /* supress all output from bsd network initialization */ - rtems_bsd_vprintf_handler bsd_vprintf_handler_old; - bsd_vprintf_handler_old = rtems_bsd_set_vprintf_handler(rtems_bsd_vprintf_handler_mute); + rtems_bsd_set_vprintf_handler(rtems_bsd_vprintf_handler_mute); sc = rtems_bsd_initialize(); assert(sc == RTEMS_SUCCESSFUL); From 6965f86298dddcdadf124742f0e43756aba1d028 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 16 Feb 2021 15:12:28 -0600 Subject: [PATCH 060/195] Change telnetd configuration to use defaults Currently, this configuration doesn't seem to be used yet, but regardless we'll update the settings to use RTEMS defaults. --- modules/libcom/RTEMS/posix/rtems_init.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index d192041be..141abafea 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -882,13 +882,14 @@ telnet_pseudoIocsh(char *name, __attribute__((unused))void *arg) /* * Telnet daemon configuration + * 0 or NULL for most fields in thsi struct indicate default values to RTEMS. */ rtems_telnetd_config_table rtems_telnetd_config = { .command = SHELL_ENTRY, .arg = NULL, - .priority = 99, // if RTEMS_NETWORK and .priority == 0 bsd_network_prio should be used ... + .priority = 0, .stack_size = 0, - .client_maximum = 5, // should be 1, on RTEMS and Epics it makes only sense for one connection a time + .client_maximum = 0, .login_check = NULL, .keep_stdio = false }; From a934570cce75fe233dc2cf3c0bdf1a6df50d17f2 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Mon, 22 Feb 2021 16:08:18 -0600 Subject: [PATCH 061/195] rtems dhcp: remove strncmp on environment vars in favor of strcmp --- modules/libcom/RTEMS/posix/rtems_init.c | 27 +++++++++---------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 141abafea..2e3b703b9 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -715,52 +715,43 @@ dhcpcd_hook_handler(rtems_dhcpcd_hook *hook, char *const *env) sprintf(ifnamebuf, "%s", getPrimaryNetworkInterface()); while (*env != NULL) { - char const * interface = "interface"; - char const * reason = "reason"; - char const * bound_str = "BOUND"; - name = strtok_r(*env,"=", &env_position); value = strtok_r(NULL,"=", &env_position); printf("all out ---> %s = %s\n", name, value); - if (!strncmp(name, interface, strlen(interface)) && + if (!strcmp(name, "interface") && !strcmp(value, ifnamebuf)) { snprintf(iName, sizeof(iName), "%s", value); } - if (!strncmp(name, reason, strlen(reason)) && - !strncmp(value, bound_str, strlen(bound_str))) { - printf ("Interface %s bounded\n", iName); - bound = 1; + if (!strcmp(name, "if_up") && !strcmp(value, "true")) { + printf ("Interface %s is up\n", iName); + bound = true; } if (bound) { // as there is no ntp-support in rtems-libbsd, we call our own client - char const * new_ntp_servers = "new_ntp_servers"; - char const * new_host_name = "new_host_name"; - char const * new_tftp_server_name = "new_tftp_server_name"; - - if (!strncmp(name, new_ntp_servers, strlen(new_ntp_servers))) + if (!strcmp(name, "new_ntp_servers")) snprintf(rtemsInit_NTP_server_ip, sizeof(rtemsInit_NTP_server_ip), "%s", value); - if (!strncmp(name, new_host_name, strlen(new_host_name))) + if (!strcmp(name, "new_host_name")) sethostname (value, strlen (value)); - if (!strncmp(name, new_tftp_server_name, strlen(new_tftp_server_name))){ + if (!strcmp(name, "new_tftp_server_name")) { snprintf(rtems_bsdnet_bootp_server_name, sizeof(bootp_server_name_init), "%s", value); printf(" rtems_bsdnet_bootp_server_name : %s\n", rtems_bsdnet_bootp_server_name); } - if(!strncmp(name, "new_bootfile_name", 20)){ + if(!strcmp(name, "new_bootfile_name")){ snprintf(rtems_bsdnet_bootp_boot_file_name, sizeof(bootp_boot_file_name_init), "%s", value); printf(" rtems_bsdnet_bootp_boot_file_name : %s\n", rtems_bsdnet_bootp_boot_file_name); } - if(!strncmp(name, "new_rtems_cmdline", 20)){ + if(!strcmp(name, "new_rtems_cmdline")){ snprintf(rtems_bsdnet_bootp_cmdline, sizeof(bootp_cmdline_init), "%s", value); From 3bdfb9ec456c671ccf1af9ec65ca2219eb38acc1 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Mon, 22 Feb 2021 16:11:50 -0600 Subject: [PATCH 062/195] Increase DHCP timeouts RTEMS dhcp will wait indefinitely for a response. rtems_init.c will wait on DHCP for 10 minutes, before timing out and starting main(). Note that rtems should still be waiting in the background and a dhcp connection could still come up after this timeout. --- modules/libcom/RTEMS/posix/rtems_init.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 2e3b703b9..bc286e113 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -806,13 +806,14 @@ default_network_dhcpcd(void) assert(n == (ssize_t) sizeof(default_cfg) - 1); static const char fhi_cfg[] = - "nodhcp6\n" \ - "ipv4only\n" \ - "option ntp_servers\n" \ - "option rtems_cmdline\n" \ - "option tftp_server_name\n" \ - "option bootfile_name\n" \ - "define 129 string rtems_cmdline\n"; + "nodhcp6\n" + "ipv4only\n" + "option ntp_servers\n" + "option rtems_cmdline\n" + "option tftp_server_name\n" + "option bootfile_name\n" + "define 129 string rtems_cmdline\n" + "timeout 0"; n = write(fd, fhi_cfg, sizeof(fhi_cfg) - 1); assert(n == (ssize_t) sizeof(fhi_cfg) - 1); @@ -1009,13 +1010,12 @@ POSIX_Init ( void *argument __attribute__((unused))) // wait for dhcp done ... should be if SYNCDHCP is used epicsEventWaitStatus stat; - int counter = 2; - do { - printf("\n ---- Wait for DHCP done ...\n"); - stat = epicsEventWaitWithTimeout(dhcpDone, 5.0); - } while ((stat == epicsEventWaitTimeout) && (--counter > 0)); + printf("\n ---- Waiting for DHCP ...\n"); + stat = epicsEventWaitWithTimeout(dhcpDone, 600); if (stat == epicsEventOK) epicsEventDestroy(dhcpDone); + else if (stat == epicsEventWaitTimeout) + printf("\n ---- DHCP timed out!\n"); else printf("\n ---- dhcpDone Event Unknown state %d\n", stat); From 74fa27d316d81fc590299107e4680c600540832b Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Mon, 22 Feb 2021 16:18:00 -0600 Subject: [PATCH 063/195] Add commented code that starts an RTEMS shell, useful for debugging In the future, it would be nice to add an ioc shell command to launch into an RTEMS shell, but for now, it can be helpful when debugging to enable this section for poking around in an RTEMS shell check network configuration and stuff like that. --- modules/libcom/RTEMS/posix/rtems_init.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index bc286e113..10795a66e 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -1115,10 +1115,20 @@ POSIX_Init ( void *argument __attribute__((unused))) atexit(exitHandler); errlogFlush(); printf ("***** Starting EPICS application *****\n"); + +#if 0 +// Start an rtems shell before main, for debugging RTEMS system issues + rtems_shell_init("SHLL", RTEMS_MINIMUM_STACK_SIZE * 4, + 100, "/dev/console", + false, true, + NULL); +#endif + result = main ((sizeof argv / sizeof argv[0]) - 1, argv); printf ("***** IOC application terminating *****\n"); epicsThreadSleep(1.0); epicsExit(result); + #if defined(__rtems__) delayedPanic("will reset rtems ... end of POSIX_Init"); #endif From dc1bf9106e305395ba059bcd4f85c76ff549596f Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Mon, 22 Feb 2021 16:20:01 -0600 Subject: [PATCH 064/195] osiSockTest: Give a clearer error message if sendto() fails --- modules/libcom/test/osiSockTest.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/libcom/test/osiSockTest.c b/modules/libcom/test/osiSockTest.c index f2adb41cd..84ae84458 100644 --- a/modules/libcom/test/osiSockTest.c +++ b/modules/libcom/test/osiSockTest.c @@ -325,7 +325,9 @@ void udpSockFanoutTestIface(const osiSockAddr* addr) /* test to see if send is possible (not EPERM) */ ret = sendto(sender, buf.bytes, sizeof(buf.bytes), 0, &addr->sa, sizeof(*addr)); if(ret!=(int)sizeof(buf.bytes)) { - testDiag("test sendto() error %d (%d)", ret, (int)SOCKERRNO); + char err[256] = {0}; + strerror_r(errno, &err, sizeof(err)); + testDiag("test sendto() error %d (%d): %s", ret, (int)SOCKERRNO, err); goto cleanup; } From a1d073955f0059bdcde8e833fea8208e1e396f35 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Mon, 22 Feb 2021 16:21:07 -0600 Subject: [PATCH 065/195] makeTestfile: revert to e1000 rt18139 was not working with DHCP when running osiSockTest. e1000 exhibits the annoying ~60s delay when rtems initializes, but at least the tests get a network connection for now. --- src/tools/makeTestfile.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index 686e3c1a3..ecf3ea47a 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -42,7 +42,7 @@ elsif ($TA =~ /^RTEMS-pc[36]86-qemu$/) { # Run the pc386 and pc686 test harness w/ QEMU $exec = "qemu-system-i386 -m 64 -no-reboot " . "-serial stdio -display none " - . "-net nic,model=rtl8139 -net nic,model=ne2k_pci " + . "-net nic,model=e1000 -net nic,model=ne2k_pci " . "-net user,restrict=yes " . "-append --console=/dev/com1 " . "-kernel $exe"; From f5eb5033f2cd7dac643cee15b79326dfcb9d06fd Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Mon, 22 Feb 2021 17:00:31 -0600 Subject: [PATCH 066/195] osiSockTest: use strerror rather than strerror_r Windows vsc19 and mingw on ubuntu were failing with this symbol. --- modules/libcom/test/osiSockTest.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/modules/libcom/test/osiSockTest.c b/modules/libcom/test/osiSockTest.c index 84ae84458..e99b9a8c9 100644 --- a/modules/libcom/test/osiSockTest.c +++ b/modules/libcom/test/osiSockTest.c @@ -325,9 +325,7 @@ void udpSockFanoutTestIface(const osiSockAddr* addr) /* test to see if send is possible (not EPERM) */ ret = sendto(sender, buf.bytes, sizeof(buf.bytes), 0, &addr->sa, sizeof(*addr)); if(ret!=(int)sizeof(buf.bytes)) { - char err[256] = {0}; - strerror_r(errno, &err, sizeof(err)); - testDiag("test sendto() error %d (%d): %s", ret, (int)SOCKERRNO, err); + testDiag("test sendto() error %d (%d): %s", ret, (int)SOCKERRNO, strerror(err)); goto cleanup; } From 25b9655f60d192f7f3c8352c07284a679c68e25c Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 16 Feb 2021 12:51:11 -0600 Subject: [PATCH 067/195] RTEMS DHCP: Use safer versions of string functions Use strtok_r rather than strtok Use strlen() rather than harcoded string size. GCC should optimize this to the hardcoded string size, so the result should be the same but maybe prevents future mistakes. replace strncpy() with snprintf() to avoid issues with NULL terminated strings. --- modules/libcom/RTEMS/posix/rtems_init.c | 27 ++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 10795a66e..bd31e6033 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -715,43 +715,52 @@ dhcpcd_hook_handler(rtems_dhcpcd_hook *hook, char *const *env) sprintf(ifnamebuf, "%s", getPrimaryNetworkInterface()); while (*env != NULL) { + char const * interface = "interface"; + char const * reason = "reason"; + char const * bound_str = "BOUND"; + name = strtok_r(*env,"=", &env_position); value = strtok_r(NULL,"=", &env_position); printf("all out ---> %s = %s\n", name, value); - if (!strcmp(name, "interface") && + if (!strncmp(name, interface, strlen(interface)) && !strcmp(value, ifnamebuf)) { snprintf(iName, sizeof(iName), "%s", value); } - if (!strcmp(name, "if_up") && !strcmp(value, "true")) { - printf ("Interface %s is up\n", iName); - bound = true; + if (!strncmp(name, reason, strlen(reason)) && + !strncmp(value, bound_str, strlen(bound_str))) { + printf ("Interface %s bounded\n", iName); + bound = 1; } if (bound) { // as there is no ntp-support in rtems-libbsd, we call our own client - if (!strcmp(name, "new_ntp_servers")) + char const * new_ntp_servers = "new_ntp_servers"; + char const * new_host_name = "new_host_name"; + char const * new_tftp_server_name = "new_tftp_server_name"; + + if (!strncmp(name, new_ntp_servers, strlen(new_ntp_servers))) snprintf(rtemsInit_NTP_server_ip, sizeof(rtemsInit_NTP_server_ip), "%s", value); - if (!strcmp(name, "new_host_name")) + if (!strncmp(name, new_host_name, strlen(new_host_name))) sethostname (value, strlen (value)); - if (!strcmp(name, "new_tftp_server_name")) { + if (!strncmp(name, new_tftp_server_name, strlen(new_tftp_server_name))){ snprintf(rtems_bsdnet_bootp_server_name, sizeof(bootp_server_name_init), "%s", value); printf(" rtems_bsdnet_bootp_server_name : %s\n", rtems_bsdnet_bootp_server_name); } - if(!strcmp(name, "new_bootfile_name")){ + if(!strncmp(name, "new_bootfile_name", 20)){ snprintf(rtems_bsdnet_bootp_boot_file_name, sizeof(bootp_boot_file_name_init), "%s", value); printf(" rtems_bsdnet_bootp_boot_file_name : %s\n", rtems_bsdnet_bootp_boot_file_name); } - if(!strcmp(name, "new_rtems_cmdline")){ + if(!strncmp(name, "new_rtems_cmdline", 20)){ snprintf(rtems_bsdnet_bootp_cmdline, sizeof(bootp_cmdline_init), "%s", value); From cd6e642eee6f1e581bc050dc63503e74acd7c1cf Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Mon, 22 Feb 2021 16:21:07 -0600 Subject: [PATCH 068/195] makeTestfile: revert to e1000 rt18139 was not working with DHCP when running osiSockTest. e1000 exhibits the annoying ~60s delay when rtems initializes, but at least the tests get a network connection for now. --- src/tools/makeTestfile.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index 686e3c1a3..ecf3ea47a 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -42,7 +42,7 @@ elsif ($TA =~ /^RTEMS-pc[36]86-qemu$/) { # Run the pc386 and pc686 test harness w/ QEMU $exec = "qemu-system-i386 -m 64 -no-reboot " . "-serial stdio -display none " - . "-net nic,model=rtl8139 -net nic,model=ne2k_pci " + . "-net nic,model=e1000 -net nic,model=ne2k_pci " . "-net user,restrict=yes " . "-append --console=/dev/com1 " . "-kernel $exe"; From 2c29dd0c7ef54910cad421f3155dd4a3e859015c Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Mon, 22 Feb 2021 17:32:57 -0600 Subject: [PATCH 069/195] Fix merge error in osiSockTest.c --- modules/libcom/test/osiSockTest.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/libcom/test/osiSockTest.c b/modules/libcom/test/osiSockTest.c index e99b9a8c9..f2adb41cd 100644 --- a/modules/libcom/test/osiSockTest.c +++ b/modules/libcom/test/osiSockTest.c @@ -325,7 +325,7 @@ void udpSockFanoutTestIface(const osiSockAddr* addr) /* test to see if send is possible (not EPERM) */ ret = sendto(sender, buf.bytes, sizeof(buf.bytes), 0, &addr->sa, sizeof(*addr)); if(ret!=(int)sizeof(buf.bytes)) { - testDiag("test sendto() error %d (%d): %s", ret, (int)SOCKERRNO, strerror(err)); + testDiag("test sendto() error %d (%d)", ret, (int)SOCKERRNO); goto cleanup; } From c4944b53575175c11599c36734ed4f126871a9d1 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Thu, 25 Feb 2021 11:23:26 -0600 Subject: [PATCH 070/195] Enable initializing the filesystem in RTEMS5 --- modules/libcom/RTEMS/posix/rtems_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index bd31e6033..ee8f56ecc 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -1082,7 +1082,7 @@ POSIX_Init ( void *argument __attribute__((unused))) //rtems_bsd_set_vprintf_handler(bsd_vprintf_handler_old); printf("\n***** Setting up file system *****\n"); - //???initialize_remote_filesystem(argv, initialize_local_filesystem(argv)); + initialize_remote_filesystem(argv, initialize_local_filesystem(argv)); fixup_hosts(); /* From 35ec367eac124b7bfb25ad0013f0dfb5bef161f9 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Thu, 25 Feb 2021 11:24:02 -0600 Subject: [PATCH 071/195] Remove unused variable --- modules/libcom/RTEMS/posix/rtems_init.c | 1 - 1 file changed, 1 deletion(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index ee8f56ecc..0e984cee3 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -906,7 +906,6 @@ POSIX_Init ( void *argument __attribute__((unused))) { int result; char *argv[3] = { NULL, NULL, NULL }; - // char *cp; rtems_status_code sc; struct timespec now; char timeBuff[100]; From 45907d6553aff575525a1dba6b5043524a6f04a8 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Thu, 25 Feb 2021 14:03:36 -0600 Subject: [PATCH 072/195] RTEMS e500: use mkimage from RTEMS rathr than system one --- configure/os/CONFIG.Common.RTEMS-qoriq_e500 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure/os/CONFIG.Common.RTEMS-qoriq_e500 b/configure/os/CONFIG.Common.RTEMS-qoriq_e500 index 41415c9ca..7f5c42e8e 100644 --- a/configure/os/CONFIG.Common.RTEMS-qoriq_e500 +++ b/configure/os/CONFIG.Common.RTEMS-qoriq_e500 @@ -29,7 +29,7 @@ MUNCHNAME = $(PRODNAME:%$(EXE)=%$(MUNCH_SUFFIX)) define MUNCH_CMD $(RTEMS_TOOLS)/bin/$(OBJCOPY_FOR_TARGET) -O binary $< $@ gzip -9 -f $@ - mkimage -A ppc -O linux -T kernel -a 0x4000 -e 0x4000 -n $* -d $@.gz $*.img + $(RTEMS_TOOLS)/bin/mkimage.py -A ppc -O linux -T kernel -a 0x4000 -e 0x4000 -n $* -d $@.gz $*.img endef include $(CONFIG)/os/CONFIG.Common.RTEMS From 11fedecefcbbe67352d1fe8529012301d81ec370 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Thu, 25 Feb 2021 15:50:58 -0600 Subject: [PATCH 073/195] Only write out dhcpcd.conf if it doesn't exist. rtems_init.c will write out a dhcpcd.conf if one doesn't already exist, but if there's a filesystem including this file, don't write over it, use whatever's there instead. --- modules/libcom/RTEMS/posix/rtems_init.c | 43 +++++++++++++------------ 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index 0e984cee3..d8a836a64 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -801,35 +801,38 @@ default_network_set_self_prio(rtems_task_priority prio) static void default_network_dhcpcd(void) { - static const char default_cfg[] = "clientid FHI test client\n"; + static const char default_cfg[] = "clientid test client\n"; rtems_status_code sc; int fd; int rv; ssize_t n; + struct stat statbuf; - fd = open("/etc/dhcpcd.conf", O_CREAT | O_WRONLY, - S_IRWXU | S_IRWXG | S_IRWXO); - assert(fd >= 0); + if (ENOENT == stat("/etc/dhcpcd.conf", &statbuf)) { + fd = open("/etc/dhcpcd.conf", O_CREAT | O_WRONLY, + S_IRWXU | S_IRWXG | S_IRWXO); + assert(fd >= 0); - n = write(fd, default_cfg, sizeof(default_cfg) - 1); - assert(n == (ssize_t) sizeof(default_cfg) - 1); + n = write(fd, default_cfg, sizeof(default_cfg) - 1); + assert(n == (ssize_t) sizeof(default_cfg) - 1); - static const char fhi_cfg[] = - "nodhcp6\n" - "ipv4only\n" - "option ntp_servers\n" - "option rtems_cmdline\n" - "option tftp_server_name\n" - "option bootfile_name\n" - "define 129 string rtems_cmdline\n" - "timeout 0"; + static const char fhi_cfg[] = + "nodhcp6\n" + "ipv4only\n" + "option ntp_servers\n" + "option rtems_cmdline\n" + "option tftp_server_name\n" + "option bootfile_name\n" + "define 129 string rtems_cmdline\n" + "timeout 0"; - n = write(fd, fhi_cfg, sizeof(fhi_cfg) - 1); - assert(n == (ssize_t) sizeof(fhi_cfg) - 1); - - rv = close(fd); - assert(rv == 0); + n = write(fd, fhi_cfg, sizeof(fhi_cfg) - 1); + assert(n == (ssize_t) sizeof(fhi_cfg) - 1); + rv = close(fd); + assert(rv == 0); + } + sc = rtems_dhcpcd_start(NULL); assert(sc == RTEMS_SUCCESSFUL); } From 79242da5156856a3caf98bc02f371defaab4cfc3 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Sun, 28 Feb 2021 20:07:33 -0600 Subject: [PATCH 074/195] epicPosicMutexInit: avoid calling with 0 which is platform dependent Different platforms (RTEMS5) can define different values for PTHREAD_MUTEX_DEFAULT, so we shouldn't pass 0 assuming its PTHREAD_MUTEX_DEFAULT. --- modules/libcom/src/osi/os/posix/osdEvent.c | 2 +- modules/libcom/src/osi/os/posix/osdPosixMutexPriv.h | 2 +- modules/libcom/src/osi/os/posix/osdSpin.c | 2 +- modules/libcom/src/osi/os/posix/osdThread.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/libcom/src/osi/os/posix/osdEvent.c b/modules/libcom/src/osi/os/posix/osdEvent.c index db61c240b..b22a3430b 100644 --- a/modules/libcom/src/osi/os/posix/osdEvent.c +++ b/modules/libcom/src/osi/os/posix/osdEvent.c @@ -51,7 +51,7 @@ LIBCOM_API epicsEventId epicsEventCreate(epicsEventInitialState init) epicsEventId pevent = malloc(sizeof(*pevent)); if (pevent) { - int status = osdPosixMutexInit(&pevent->mutex, 0); + int status = osdPosixMutexInit(&pevent->mutex, PTHREAD_MUTEX_DEFAULT); pevent->isFull = (init == epicsEventFull); if (status) { diff --git a/modules/libcom/src/osi/os/posix/osdPosixMutexPriv.h b/modules/libcom/src/osi/os/posix/osdPosixMutexPriv.h index 2b6846c91..87289be5f 100644 --- a/modules/libcom/src/osi/os/posix/osdPosixMutexPriv.h +++ b/modules/libcom/src/osi/os/posix/osdPosixMutexPriv.h @@ -18,7 +18,7 @@ extern "C" { #endif /* Returns ENOTSUP if requested mutextype is not supported */ -/* At the moment, only 0 (default non recursive mutex) and PTHREAD_MUTEX_RECURSIVE are supported */ +/* At the moment, only PTHREAD_MUTEX_DEFAULT and PTHREAD_MUTEX_RECURSIVE are supported */ int osdPosixMutexInit(pthread_mutex_t *,int mutextype); #ifdef __cplusplus diff --git a/modules/libcom/src/osi/os/posix/osdSpin.c b/modules/libcom/src/osi/os/posix/osdSpin.c index f039e7c34..0b924ee3a 100644 --- a/modules/libcom/src/osi/os/posix/osdSpin.c +++ b/modules/libcom/src/osi/os/posix/osdSpin.c @@ -123,7 +123,7 @@ epicsSpinId epicsSpinCreate(void) { if (!spin) goto fail; - status = osdPosixMutexInit(&spin->lock, 0); + status = osdPosixMutexInit(&spin->lock, PTHREAD_MUTEX_DEFAULT); checkStatus(status, "osdPosixMutexInit"); if (status) goto fail; diff --git a/modules/libcom/src/osi/os/posix/osdThread.c b/modules/libcom/src/osi/os/posix/osdThread.c index d7d53fefa..8690afad4 100644 --- a/modules/libcom/src/osi/os/posix/osdThread.c +++ b/modules/libcom/src/osi/os/posix/osdThread.c @@ -329,9 +329,9 @@ static void once(void) int status; pthread_key_create(&getpthreadInfo,0); - status = osdPosixMutexInit(&onceLock,0); + status = osdPosixMutexInit(&onceLock,PTHREAD_MUTEX_DEFAULT); checkStatusOnceQuit(status,"osdPosixMutexInit","epicsThreadInit"); - status = osdPosixMutexInit(&listLock,0); + status = osdPosixMutexInit(&listLock,PTHREAD_MUTEX_DEFAULT); checkStatusOnceQuit(status,"osdPosixMutexInit","epicsThreadInit"); pcommonAttr = calloc(1,sizeof(commonAttr)); if(!pcommonAttr) checkStatusOnceQuit(errno,"calloc","epicsThreadInit"); From 8e50b3109a2114afccc9124f5f13fffe378e630a Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 2 Mar 2021 09:23:27 -0600 Subject: [PATCH 075/195] Allow RTEMS to use normal dlopen() symbols RTEMS supports POSIX dlopen related symbols, so we should allow using them. --- .../libcom/src/osi/os/posix/osdFindSymbol.c | 20 ------------------- 1 file changed, 20 deletions(-) diff --git a/modules/libcom/src/osi/os/posix/osdFindSymbol.c b/modules/libcom/src/osi/os/posix/osdFindSymbol.c index 09cd7a432..fc175fc60 100644 --- a/modules/libcom/src/osi/os/posix/osdFindSymbol.c +++ b/modules/libcom/src/osi/os/posix/osdFindSymbol.c @@ -9,25 +9,6 @@ #include "epicsFindSymbol.h" -/* RTEMS posix but without libbsd */ -#ifdef RTEMS_LEGACY_STACK -LIBCOM_API void * epicsLoadLibrary(const char *name) -{ - return 0; -} - -LIBCOM_API const char *epicsLoadError(void) -{ - return "epicsLoadLibrary not implemented"; -} - -LIBCOM_API void * epicsStdCall epicsFindSymbol(const char *name) -{ - return 0; -} - -#else - #include @@ -51,4 +32,3 @@ LIBCOM_API void * epicsStdCall epicsFindSymbol(const char *name) { return dlsym(RTLD_DEFAULT, name); } -#endif // RTEMS_LEGACY_STACK From f34d744f5fd76cbf3a097c92b80c31f6f6c4ca9e Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Tue, 2 Mar 2021 15:03:56 -0600 Subject: [PATCH 076/195] Remove unused DHAVE_SOCKADDR_SA_LEN --- configure/os/CONFIG.Common.RTEMS | 1 - configure/os/CONFIG.darwin-x86.Common | 1 - configure/os/CONFIG.darwinCommon.darwinCommon | 1 - 3 files changed, 3 deletions(-) diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index cf138c873..abb6f8716 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -100,7 +100,6 @@ OS_CLASS = RTEMS OP_SYS_CFLAGS += -D__LINUX_ERRNO_EXTENSIONS__ OP_SYS_CFLAGS_NET_yes = -DRTEMS_LEGACY_STACK -OP_SYS_CFLAGS_NET_no = -DHAVE_SOCKADDR_SA_LEN=1 OP_SYS_CFLAGS += $(OP_SYS_CFLAGS_NET_$(RTEMS_HAS_NETWORKING)) ifeq ($(RTEMS_HAS_POSIX_API),yes) diff --git a/configure/os/CONFIG.darwin-x86.Common b/configure/os/CONFIG.darwin-x86.Common index 960c74b8a..c88d8f7ea 100644 --- a/configure/os/CONFIG.darwin-x86.Common +++ b/configure/os/CONFIG.darwin-x86.Common @@ -4,6 +4,5 @@ # Sites may override these definitions in CONFIG_SITE.darwin-x86.Common #------------------------------------------------------- #support for IPv6 etc. -OP_SYS_CFLAGS += -DHAVE_SOCKADDR_SA_LEN=1 #Include definitions common to unix hosts include $(CONFIG)/os/CONFIG.UnixCommon.Common diff --git a/configure/os/CONFIG.darwinCommon.darwinCommon b/configure/os/CONFIG.darwinCommon.darwinCommon index 5575eb35f..3ee6fd5f9 100644 --- a/configure/os/CONFIG.darwinCommon.darwinCommon +++ b/configure/os/CONFIG.darwinCommon.darwinCommon @@ -33,7 +33,6 @@ ARCH_DEP_LDFLAGS += $(ARCH_DEP_FLAGS) # OS provides socket address length # OP_SYS_CFLAGS += -fno-common -OP_SYS_CFLAGS += -DHAVE_SOCKADDR_SA_LEN=1 # # Darwin os definition From 75063a69ec62faaefc313b01c9d7ab722de5a1b4 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Wed, 3 Mar 2021 15:53:52 -0600 Subject: [PATCH 077/195] RTEMS ne2kpci: clean up when its included This looks like a merge issue, where we included ne2kpci possibly twice, based on CPU being i386 and BSP being pc686. Just checking CPU as i386 should be sufficient for all cases. --- modules/libcom/RTEMS/Makefile | 3 --- 1 file changed, 3 deletions(-) diff --git a/modules/libcom/RTEMS/Makefile b/modules/libcom/RTEMS/Makefile index e1ac0ed04..a670133ed 100644 --- a/modules/libcom/RTEMS/Makefile +++ b/modules/libcom/RTEMS/Makefile @@ -36,9 +36,6 @@ rtemsCom_SRCS += epicsNtp.c ifeq ($(RTEMS_TARGET_CPU),i386) rtemsCom_SRCS += ne2kpci.c endif -ifeq ($(RTEMS_BSP),pc686) -rtemsCom_SRCS += ne2kpci.c -endif LIBRARY_RTEMS = rtemsCom From 102e30eaa9b4323900567ebf580ce28e013aaf7b Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Wed, 3 Mar 2021 17:02:03 -0600 Subject: [PATCH 078/195] rtems_config: Guard using __RTEMS_MAJOR__ rather than net stack --- modules/libcom/RTEMS/posix/rtems_config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/libcom/RTEMS/posix/rtems_config.c b/modules/libcom/RTEMS/posix/rtems_config.c index 65c8ae96b..e51912cf5 100644 --- a/modules/libcom/RTEMS/posix/rtems_config.c +++ b/modules/libcom/RTEMS/posix/rtems_config.c @@ -88,7 +88,7 @@ extern void *POSIX_Init(void *argument); //#define RTEMS_PCI_CONFIG_LIB //#define CONFIGURE_PCI_LIB PCI_LIB_AUTO -#ifndef RTEMS_LEGACY_STACK +#ifndef __RTEMS_MAJOR__ > 4 #define CONFIGURE_SHELL_COMMANDS_INIT #include From f69ff5afdec9c3a41886fa0c18764a482917d590 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Thu, 4 Mar 2021 14:06:24 -0600 Subject: [PATCH 079/195] rtems_config: Fix typo in #if statement --- modules/libcom/RTEMS/posix/rtems_config.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/libcom/RTEMS/posix/rtems_config.c b/modules/libcom/RTEMS/posix/rtems_config.c index e51912cf5..c984b20be 100644 --- a/modules/libcom/RTEMS/posix/rtems_config.c +++ b/modules/libcom/RTEMS/posix/rtems_config.c @@ -88,7 +88,7 @@ extern void *POSIX_Init(void *argument); //#define RTEMS_PCI_CONFIG_LIB //#define CONFIGURE_PCI_LIB PCI_LIB_AUTO -#ifndef __RTEMS_MAJOR__ > 4 +#if __RTEMS_MAJOR__ > 4 #define CONFIGURE_SHELL_COMMANDS_INIT #include From c606048e57ccccf0eeaf5bdcb3d560118bf3dda4 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Thu, 4 Mar 2021 14:06:55 -0600 Subject: [PATCH 080/195] rtems_config: Change config options based on BSP name This replaces an implementation that used a header guard being defined to indicate BSP specific options. Hopefully this method is more explicit when config options should be set for specific BSPs. --- modules/libcom/RTEMS/Makefile | 2 ++ modules/libcom/RTEMS/posix/rtems_config.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/libcom/RTEMS/Makefile b/modules/libcom/RTEMS/Makefile index a670133ed..c939563fc 100644 --- a/modules/libcom/RTEMS/Makefile +++ b/modules/libcom/RTEMS/Makefile @@ -37,6 +37,8 @@ ifeq ($(RTEMS_TARGET_CPU),i386) rtemsCom_SRCS += ne2kpci.c endif +rtems_config_CPPFLAGS += -DBSP_$(RTEMS_BSP) + LIBRARY_RTEMS = rtemsCom # shared library ABI version. diff --git a/modules/libcom/RTEMS/posix/rtems_config.c b/modules/libcom/RTEMS/posix/rtems_config.c index c984b20be..4319013a1 100644 --- a/modules/libcom/RTEMS/posix/rtems_config.c +++ b/modules/libcom/RTEMS/posix/rtems_config.c @@ -153,9 +153,9 @@ extern void *POSIX_Init(void *argument); #define CONFIGURE_APPLICATION_NEEDS_RTC_DRIVER #endif -#if defined(LIBBSP_I386_PC386_BSP_H) +#if defined(BSP_pc386) || defined(BSP_pc686) #define RTEMS_BSD_CONFIG_DOMAIN_PAGE_MBUFS_SIZE (64 * 1024 * 1024) -#elif defined(LIBBSP_POWERPC_QORIQ_BSP_H) +#elif defined(BSP_qoriq_e500) #define RTEMS_BSD_CONFIG_DOMAIN_PAGE_MBUFS_SIZE (32 * 1024 * 1024) #endif From 31ade32004709a9d47e87b3ede231f8bc1322ab1 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 4 Mar 2021 23:15:31 -0600 Subject: [PATCH 081/195] Fixes for RTEMS-uC5282 with legacy stack --- configure/os/CONFIG.Common.RTEMS | 10 ++++++---- configure/os/CONFIG.Common.RTEMS-uC5282 | 4 ++++ modules/libcom/RTEMS/posix/rtems_config.c | 8 ++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index abb6f8716..4eae21898 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -106,11 +106,13 @@ ifeq ($(RTEMS_HAS_POSIX_API),yes) POSIX_CPPFLAGS = -D_GNU_SOURCE -D_DEFAULT_SOURCE endif -OP_SYS_LDLIBS_posix_NET_yes = -ltftpfs -lnfs -lz -telnetd +OP_SYS_LDLIBS_posix_NET_yes = -ltftpfs -lnfs -lz -ltelnetd OP_SYS_LDLIBS_posix_NET_no = -ltftpfs -lbsd -lz -OP_SYS_LDLIBS_kernel_NET_yes = -lCom -lnfs -OP_SYS_LDLIBS_kernel_NET_no = -lCom -lnfs -OP_SYS_LDLIBS += -lrtemsCom -lCom -lc -lrtemscpu $(OP_SYS_LDLIBS_$(OS_API)_NET_$(RTEMS_HAS_NETWORKING)) -lm +OP_SYS_LDLIBS_kernel_NET_yes = -lnfs +OP_SYS_LDLIBS_kernel_NET_no = -lnfs +OP_SYS_LDLIBS += -lrtemsCom -lCom +OP_SYS_LDLIBS += $(OP_SYS_LDLIBS_$(OS_API)_NET_$(RTEMS_HAS_NETWORKING)) +OP_SYS_LDLIBS += -lrtemscpu -lc -lm OP_SYS_LDFLAGS_posix = -u POSIX_Init OP_SYS_LDFLAGS_kernel = -u Init \ diff --git a/configure/os/CONFIG.Common.RTEMS-uC5282 b/configure/os/CONFIG.Common.RTEMS-uC5282 index 2cb215aca..c0cdaff74 100644 --- a/configure/os/CONFIG.Common.RTEMS-uC5282 +++ b/configure/os/CONFIG.Common.RTEMS-uC5282 @@ -9,6 +9,10 @@ RTEMS_BSP = uC5282 RTEMS_TARGET_CPU = m68k ARCH_DEP_CFLAGS += -DMY_DO_BOOTP=NULL +# Hopefully a temporary fix: +ARCH_DEP_CXXFLAGS_5 = -std=c++98 +ARCH_DEP_CXXFLAGS += $(ARCH_DEP_CXXFLAGS_$(RTEMS_VERSION)) + MUNCH_SUFFIX = .boot define MUNCH_CMD $(RTEMS_TOOLS)/bin/$(OBJCOPY_FOR_TARGET) -O binary -R .comment -S $< $@ diff --git a/modules/libcom/RTEMS/posix/rtems_config.c b/modules/libcom/RTEMS/posix/rtems_config.c index 4319013a1..d0a123b6d 100644 --- a/modules/libcom/RTEMS/posix/rtems_config.c +++ b/modules/libcom/RTEMS/posix/rtems_config.c @@ -93,6 +93,7 @@ extern void *POSIX_Init(void *argument); #include +#ifndef RTEMS_LEGACY_STACK #include #define CONFIGURE_SHELL_USER_COMMANDS \ @@ -105,6 +106,13 @@ extern void *POSIX_Init(void *argument); &rtems_shell_TCPDUMP_Command, \ &rtems_shell_PFCTL_Command, \ &rtems_shell_SYSCTL_Command +#else // LEGACY_STACK: +#define CONFIGURE_SHELL_USER_COMMANDS \ + &bsp_interrupt_shell_command, \ + &rtems_shell_PING_Command, \ + &rtems_shell_ROUTE_Command, \ + &rtems_shell_IFCONFIG_Command +#endif #define CONFIGURE_SHELL_COMMAND_CPUUSE #define CONFIGURE_SHELL_COMMAND_PERIODUSE From c0886b3037c50e9f2174a0c1044ed1ae85c78068 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 6 May 2017 21:24:17 -0400 Subject: [PATCH 082/195] RTEMS: Drop dependency on bspExt integrate the polling implementation of bspExt. --- configure/os/CONFIG.Common.RTEMS | 2 +- configure/os/CONFIG.Common.RTEMS-beatnik | 2 - configure/os/CONFIG.Common.RTEMS-mvme2100 | 2 - configure/os/CONFIG.Common.RTEMS-mvme2700 | 2 - configure/os/CONFIG.Common.RTEMS-mvme3100 | 2 - configure/os/CONFIG.Common.RTEMS-mvme5500 | 4 -- .../src/osi/os/RTEMS-kernel/devLibVMEOSD.c | 55 +++++++++++++++++-- 7 files changed, 52 insertions(+), 17 deletions(-) diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 4eae21898..1cfe0fe56 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -128,7 +128,7 @@ MOD_SYS_LDFLAGS += $(CPU_CFLAGS) -Wl,-r -nostdlib # Do not link against libraries which are part of the Generic Image GESYS_LIBS += -lgcc -GESYS_LIBS += -lc -lm -lrtemscpu -lrtemsbsp -lrtems++ -lbspExt +GESYS_LIBS += -lc -lm -lrtemscpu -lrtemsbsp -lrtems++ GESYS_LIBS += -lcexp -ltecla_r -lspencer_regexp -lpmelf -lpmbfd GESYS_LIBS += -lnfs -ltelnetd -lrtems-gdb-stub diff --git a/configure/os/CONFIG.Common.RTEMS-beatnik b/configure/os/CONFIG.Common.RTEMS-beatnik index 84ba42667..b133fd489 100644 --- a/configure/os/CONFIG.Common.RTEMS-beatnik +++ b/configure/os/CONFIG.Common.RTEMS-beatnik @@ -16,8 +16,6 @@ ARCH_DEP_CFLAGS += -DHAVE_MOTLOAD ARCH_DEP_CFLAGS += -DRTEMS_NETWORK_CONFIG_MBUF_SPACE=2048 ARCH_DEP_CFLAGS += -DRTEMS_NETWORK_CONFIG_CLUSTER_SPACE=5120 -OP_SYS_LDLIBS += -lbspExt #does not use posix stuff ... want to ignore - MUNCH_SUFFIX = .boot MUNCHNAME = $(PRODNAME:%$(EXE)=%$(MUNCH_SUFFIX)) define MUNCH_CMD diff --git a/configure/os/CONFIG.Common.RTEMS-mvme2100 b/configure/os/CONFIG.Common.RTEMS-mvme2100 index a8e8bf76e..1e222b5ab 100644 --- a/configure/os/CONFIG.Common.RTEMS-mvme2100 +++ b/configure/os/CONFIG.Common.RTEMS-mvme2100 @@ -11,8 +11,6 @@ GNU_TARGET = powerpc-rtems ARCH_DEP_CFLAGS += -DMY_DO_BOOTP=NULL ARCH_DEP_CFLAGS += -DHAVE_PPCBUG -OP_SYS_LDLIBS += -lbspExt - MUNCH_SUFFIX = .boot define MUNCH_CMD $(RTEMS_TOOLS)/bin/$(OBJCOPY_FOR_TARGET) -O binary -R .comment -S $< rtems diff --git a/configure/os/CONFIG.Common.RTEMS-mvme2700 b/configure/os/CONFIG.Common.RTEMS-mvme2700 index a5ad7fbf5..655e0a5b0 100644 --- a/configure/os/CONFIG.Common.RTEMS-mvme2700 +++ b/configure/os/CONFIG.Common.RTEMS-mvme2700 @@ -20,6 +20,4 @@ define MUNCH_CMD rm -f rtems.gz endef -OP_SYS_LDLIBS += -lbspExt - include $(CONFIG)/os/CONFIG.Common.RTEMS diff --git a/configure/os/CONFIG.Common.RTEMS-mvme3100 b/configure/os/CONFIG.Common.RTEMS-mvme3100 index 283e7d680..2cbf49a84 100644 --- a/configure/os/CONFIG.Common.RTEMS-mvme3100 +++ b/configure/os/CONFIG.Common.RTEMS-mvme3100 @@ -13,8 +13,6 @@ ARCH_DEP_CFLAGS += -DHAVE_MOTLOAD ARCH_DEP_CFLAGS += -DRTEMS_NETWORK_CONFIG_MBUF_SPACE=2048 ARCH_DEP_CFLAGS += -DRTEMS_NETWORK_CONFIG_CLUSTER_SPACE=5120 -OP_SYS_LDLIBS += -lbspExt - MUNCH_SUFFIX = .boot define MUNCH_CMD $(RTEMS_TOOLS)/bin/$(OBJCOPY_FOR_TARGET) -O binary $< $@ diff --git a/configure/os/CONFIG.Common.RTEMS-mvme5500 b/configure/os/CONFIG.Common.RTEMS-mvme5500 index 0329185bb..a240a298a 100644 --- a/configure/os/CONFIG.Common.RTEMS-mvme5500 +++ b/configure/os/CONFIG.Common.RTEMS-mvme5500 @@ -14,13 +14,9 @@ ARCH_DEP_CFLAGS += -DRTEMS_NETWORK_CONFIG_MBUF_SPACE=2048 ARCH_DEP_CFLAGS += -DRTEMS_NETWORK_CONFIG_CLUSTER_SPACE=5120 ARCH_DEP_CFLAGS += -DBSP_NVRAM_BASE_ADDR=0xf1110000 -OP_SYS_LDLIBS += -lbspExt - MUNCH_SUFFIX = .boot define MUNCH_CMD $(RTEMS_TOOLS)/bin/$(OBJCOPY_FOR_TARGET) -O binary $< $@ endef -OP_SYS_LDLIBS += -lbspExt - include $(CONFIG)/os/CONFIG.Common.RTEMS diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c b/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c index f8b05421c..fdbfb2c46 100644 --- a/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c +++ b/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c @@ -19,12 +19,12 @@ #include #include "devLibVME.h" #include +#include #if defined(__PPC__) || defined(__mcf528x__) #if defined(__PPC__) #include -#include #endif @@ -126,8 +126,7 @@ static long rtemsDevInit(void) { /* assume the vme bridge has been initialized by bsp */ - /* init BSP extensions [memProbe etc.] */ - return bspExtInit(); + return 0; } /* @@ -245,11 +244,59 @@ static long rtemsDevMapAddr (epicsAddressType addrType, unsigned options, return 0; } +static +rtems_status_code bspExtMemProbe(void *addr, int write, int size, void *pval) +{ + rtems_interrupt_level flags; + rtems_status_code ret = RTEMS_SUCCESSFUL; + epicsUInt32 val; + + /* bspExt allows caller to write uninitialized values, we don't */ + if(write && !pval) + return RTEMS_INVALID_NUMBER; + + switch(size) { + case 1: + case 2: + case 4: + break; + default: + return RTEMS_INVALID_SIZE; + } + + if(write) + memcpy(&val, pval, size); + + rtems_interrupt_disable(flags); + _BSP_clear_hostbridge_errors(0,1); + + if(!write) { + switch(size) { + case 1: val = ioread8(addr)<<24; break; + case 2: val = nat_ioread16(addr)<<16; break; + case 4: val = nat_ioread32(addr); break; + } + } else { + switch(size) { + case 1: iowrite8(addr, val>>24); break; + case 2: nat_iowrite16(addr, val>>16); break; + case 4: nat_iowrite32(addr, val); break; + } + } + + ret = _BSP_clear_hostbridge_errors(0,1); + rtems_interrupt_enable(flags); + + if(!write && pval) + memcpy(pval, &val, size); + + return ret; +} + /* * a bus error safe "wordSize" read at the specified address which returns * unsuccessful status if the device isnt present */ -rtems_status_code bspExtMemProbe(void *addr, int write, int size, void *pval); static long rtemsDevReadProbe (unsigned wordSize, volatile const void *ptr, void *pValue) { long status; From 01cc99ac87ff9edf886b9e47125b9295308b722e Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 7 Mar 2021 09:29:16 -0800 Subject: [PATCH 083/195] ci: update toolchain and test more targets --- .ci | 2 +- .github/workflows/ci-scripts-build.yml | 58 +++++++++++++++++++++++++- .gitmodules | 2 +- 3 files changed, 59 insertions(+), 3 deletions(-) diff --git a/.ci b/.ci index 37fa7315b..028b752cb 160000 --- a/.ci +++ b/.ci @@ -1 +1 @@ -Subproject commit 37fa7315b73813c191b0be4bd8acbf61634bb8d1 +Subproject commit 028b752cb226f7e94b22189c9c8da2e1e20095a9 diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index 66972e8c9..7394814cb 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -75,7 +75,63 @@ jobs: configuration: default rtems: "5" rtems_target: RTEMS-pc686-qemu - name: "Ub-20 gcc-9 + RT-5.1" + name: "Ub-20 gcc-9 + RT-5.1 pc686" + + - os: ubuntu-20.04 + cmp: gcc + configuration: default + rtems: "5" + rtems_target: RTEMS-beatnik + test: NO + name: "Ub-20 gcc-9 + RT-5.1 beatnik" + + - os: ubuntu-20.04 + cmp: gcc + configuration: default + rtems: "5" + rtems_target: RTEMS-mvme2100 + test: NO + name: "Ub-20 gcc-9 + RT-5.1 mvme2100" + + - os: ubuntu-20.04 + cmp: gcc + configuration: default + rtems: "5" + rtems_target: RTEMS-mvme3100 + test: NO + name: "Ub-20 gcc-9 + RT-5.1 mvme3100" + + - os: ubuntu-20.04 + cmp: gcc + configuration: default + rtems: "5" + rtems_target: RTEMS-qoriq_e500 + test: NO + name: "Ub-20 gcc-9 + RT-5.1 qoriq_e500" + + - os: ubuntu-20.04 + cmp: gcc + configuration: default + rtems: "5" + rtems_target: RTEMS-xilinx_zynq_a9_qemu + test: NO + name: "Ub-20 gcc-9 + RT-5.1 xilinx_zynq_a9_qemu" + + - os: ubuntu-20.04 + cmp: gcc + configuration: default + rtems: "5" + rtems_target: RTEMS-mvme167 + test: NO + name: "Ub-20 gcc-9 + RT-5.1 mvme167" + + - os: ubuntu-20.04 + cmp: gcc + configuration: default + rtems: "5" + rtems_target: RTEMS-uC5282 + test: NO + name: "Ub-20 gcc-9 + RT-5.1 uC5282" - os: ubuntu-20.04 cmp: gcc diff --git a/.gitmodules b/.gitmodules index e537fc586..1e39a85ac 100644 --- a/.gitmodules +++ b/.gitmodules @@ -24,5 +24,5 @@ branch = master [submodule ".ci"] path = .ci - url = https://github.com/epics-base/ci-scripts + url = https://github.com/mdavidsaver/ci-scripts branch = master From c6af4a245dac9b231906e3e6e73855506dfa154f Mon Sep 17 00:00:00 2001 From: Freddie Akeroyd Date: Wed, 10 Mar 2021 01:17:47 +0000 Subject: [PATCH 084/195] Use waitable timers --- src/libCom/osi/os/WIN32/osdEvent.c | 37 +++++++++++++------ src/libCom/osi/os/WIN32/osdThread.c | 57 ++++++++++++++++++++++------- 2 files changed, 69 insertions(+), 25 deletions(-) diff --git a/src/libCom/osi/os/WIN32/osdEvent.c b/src/libCom/osi/os/WIN32/osdEvent.c index 314138b27..c25ee5f65 100644 --- a/src/libCom/osi/os/WIN32/osdEvent.c +++ b/src/libCom/osi/os/WIN32/osdEvent.c @@ -84,36 +84,49 @@ epicsShareFunc epicsEventStatus epicsEventWait ( epicsEventId pSem ) } } +extern HANDLE osdThreadGetTimer(); + /* * epicsEventWaitWithTimeout () */ epicsShareFunc epicsEventStatus epicsEventWaitWithTimeout ( epicsEventId pSem, double timeOut ) { - static const unsigned mSecPerSec = 1000; + static const unsigned nSec100PerSec = 10000000; + HANDLE handles[2]; DWORD status; - DWORD tmo; + LARGE_INTEGER tmo; + HANDLE timer; if ( timeOut <= 0.0 ) { - tmo = 0u; - } - else if ( timeOut >= INFINITE / mSecPerSec ) { - tmo = INFINITE - 1; + tmo.QuadPart = 0u; } else { - tmo = ( DWORD ) ( ( timeOut * mSecPerSec ) + 0.5 ); - if ( tmo == 0 ) { - tmo = 1; - } + tmo.QuadPart = -((LONGLONG)(timeOut * nSec100PerSec + 0.5)); // +0.99999999 ? + } + + if (tmo.QuadPart < 0) { + timer = osdThreadGetTimer(); + if (!SetWaitableTimer(timer, &tmo, 0, NULL, NULL, 0)) + { + printf("event error %d\n", GetLastError()); + return epicsEventError; + } + handles[0] = pSem->handle; + handles[1] = timer; + status = WaitForMultipleObjects (2, handles, FALSE, INFINITE); + } + else { + status = WaitForSingleObject(pSem->handle, 0); } - status = WaitForSingleObject ( pSem->handle, tmo ); if ( status == WAIT_OBJECT_0 ) { return epicsEventOK; } - else if ( status == WAIT_TIMEOUT ) { + else if ( status == WAIT_OBJECT_0 + 1 || status == WAIT_TIMEOUT ) { return epicsEventWaitTimeout; } else { + printf("event error %d\n", GetLastError()); return epicsEventError; } } diff --git a/src/libCom/osi/os/WIN32/osdThread.c b/src/libCom/osi/os/WIN32/osdThread.c index 8cdb4a3f4..a5c455dac 100644 --- a/src/libCom/osi/os/WIN32/osdThread.c +++ b/src/libCom/osi/os/WIN32/osdThread.c @@ -18,9 +18,6 @@ #define VC_EXTRALEAN #define STRICT -#ifndef _WIN32_WINNT -# define _WIN32_WINNT 0x400 /* No support for W95 */ -#endif #include #include /* for _endthread() etc */ @@ -53,6 +50,7 @@ typedef struct epicsThreadOSD { DWORD id; unsigned epicsPriority; char isSuspended; + HANDLE timer; /* waitable timer */ } win32ThreadParam; typedef struct epicsThreadPrivateOSD { @@ -244,6 +242,8 @@ static void epicsParmCleanupWIN32 ( win32ThreadParam * pParm ) LeaveCriticalSection ( & pGbl->mutex ); CloseHandle ( pParm->handle ); + CloseHandle ( pParm->timer ); + pParm->timer = NULL; free ( pParm ); TlsSetValue ( pGbl->tlsIndexThreadLibraryEPICS, 0 ); } @@ -526,6 +526,11 @@ static win32ThreadParam * epicsThreadParmCreate ( const char *pName ) pParmWIN32->pName = (char *) ( pParmWIN32 + 1 ); strcpy ( pParmWIN32->pName, pName ); pParmWIN32->isSuspended = 0; +#ifdef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION + pParmWIN32->timer = CreateWaitableTimerEx(NULL, NULL, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS); +#else + pParmWIN32->timer = CreateWaitableTimer(NULL, 0, NULL); +#endif } return pParmWIN32; } @@ -764,24 +769,50 @@ epicsShareFunc int epicsShareAPI epicsThreadIsSuspended ( epicsThreadId id ) } } +HANDLE osdThreadGetTimer() +{ + win32ThreadGlobal * pGbl = fetchWin32ThreadGlobal (); + win32ThreadParam * pParm; + + assert ( pGbl ); + + pParm = ( win32ThreadParam * ) + TlsGetValue ( pGbl->tlsIndexThreadLibraryEPICS ); + + return pParm->timer; +} + /* * epicsThreadSleep () */ epicsShareFunc void epicsShareAPI epicsThreadSleep ( double seconds ) { - static const unsigned mSecPerSec = 1000; - DWORD milliSecDelay; + static const unsigned nSec100PerSec = 10000000; + LARGE_INTEGER tmo; + HANDLE timer; - if ( seconds > 0.0 ) { - seconds *= mSecPerSec; - seconds += 0.99999999; /* 8 9s here is optimal */ - milliSecDelay = ( seconds >= INFINITE ) ? - INFINITE - 1 : ( DWORD ) seconds; + if ( seconds <= 0.0 ) { + tmo.QuadPart = 0u; } - else { /* seconds <= 0 or NAN */ - milliSecDelay = 0u; + else { + tmo.QuadPart = -((LONGLONG)(seconds * nSec100PerSec + 0.5)); // +0.99999999 ? + } + + if (tmo.QuadPart == 0) { + Sleep ( 0 ); + } + else { + timer = osdThreadGetTimer(); + if (!SetWaitableTimer(timer, &tmo, 0, NULL, NULL, 0)) + { + printf("timer error %d\n", GetLastError()); + return; + } + if (WaitForSingleObject(timer, INFINITE) != WAIT_OBJECT_0) + { + printf("timer error %d\n", GetLastError()); + } } - Sleep ( milliSecDelay ); } /* From 5f94ab6d9fb914c2bab80368f836d8d8d9b968f4 Mon Sep 17 00:00:00 2001 From: Freddie Akeroyd Date: Wed, 10 Mar 2021 10:47:24 +0000 Subject: [PATCH 085/195] Tidy up --- src/libCom/osi/os/WIN32/osdEvent.c | 13 ++++++------- src/libCom/osi/os/WIN32/osdThread.c | 21 +++++++++++++-------- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/libCom/osi/os/WIN32/osdEvent.c b/src/libCom/osi/os/WIN32/osdEvent.c index c25ee5f65..9d300e71c 100644 --- a/src/libCom/osi/os/WIN32/osdEvent.c +++ b/src/libCom/osi/os/WIN32/osdEvent.c @@ -84,7 +84,7 @@ epicsShareFunc epicsEventStatus epicsEventWait ( epicsEventId pSem ) } } -extern HANDLE osdThreadGetTimer(); +extern HANDLE osdThreadGetTimer(void); /* from osdThread.c */ /* * epicsEventWaitWithTimeout () @@ -92,7 +92,7 @@ extern HANDLE osdThreadGetTimer(); epicsShareFunc epicsEventStatus epicsEventWaitWithTimeout ( epicsEventId pSem, double timeOut ) { - static const unsigned nSec100PerSec = 10000000; + static const unsigned nSec100PerSec = 10000000u; HANDLE handles[2]; DWORD status; LARGE_INTEGER tmo; @@ -102,14 +102,12 @@ epicsShareFunc epicsEventStatus epicsEventWaitWithTimeout ( tmo.QuadPart = 0u; } else { - tmo.QuadPart = -((LONGLONG)(timeOut * nSec100PerSec + 0.5)); // +0.99999999 ? + tmo.QuadPart = -((LONGLONG)(timeOut * nSec100PerSec + 0.5)); } if (tmo.QuadPart < 0) { timer = osdThreadGetTimer(); - if (!SetWaitableTimer(timer, &tmo, 0, NULL, NULL, 0)) - { - printf("event error %d\n", GetLastError()); + if (!SetWaitableTimer(timer, &tmo, 0, NULL, NULL, 0)) { return epicsEventError; } handles[0] = pSem->handle; @@ -123,10 +121,11 @@ epicsShareFunc epicsEventStatus epicsEventWaitWithTimeout ( return epicsEventOK; } else if ( status == WAIT_OBJECT_0 + 1 || status == WAIT_TIMEOUT ) { + /* WaitForMultipleObjects will trigger WAIT_OBJECT_0 + 1, + WaitForSingleObject will trigger WAIT_TIMEOUT */ return epicsEventWaitTimeout; } else { - printf("event error %d\n", GetLastError()); return epicsEventError; } } diff --git a/src/libCom/osi/os/WIN32/osdThread.c b/src/libCom/osi/os/WIN32/osdThread.c index a5c455dac..1b590de27 100644 --- a/src/libCom/osi/os/WIN32/osdThread.c +++ b/src/libCom/osi/os/WIN32/osdThread.c @@ -528,6 +528,9 @@ static win32ThreadParam * epicsThreadParmCreate ( const char *pName ) pParmWIN32->isSuspended = 0; #ifdef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION pParmWIN32->timer = CreateWaitableTimerEx(NULL, NULL, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS); + if (pParmWIN32->timer == NULL) { + pParmWIN32->timer = CreateWaitableTimer(NULL, 0, NULL); + } #else pParmWIN32->timer = CreateWaitableTimer(NULL, 0, NULL); #endif @@ -769,6 +772,10 @@ epicsShareFunc int epicsShareAPI epicsThreadIsSuspended ( epicsThreadId id ) } } +/** + * osdThreadGetTimer () + * return stored waitable timer object for thread + */ HANDLE osdThreadGetTimer() { win32ThreadGlobal * pGbl = fetchWin32ThreadGlobal (); @@ -787,7 +794,7 @@ HANDLE osdThreadGetTimer() */ epicsShareFunc void epicsShareAPI epicsThreadSleep ( double seconds ) { - static const unsigned nSec100PerSec = 10000000; + static const unsigned nSec100PerSec = 10000000u; LARGE_INTEGER tmo; HANDLE timer; @@ -795,7 +802,7 @@ epicsShareFunc void epicsShareAPI epicsThreadSleep ( double seconds ) tmo.QuadPart = 0u; } else { - tmo.QuadPart = -((LONGLONG)(seconds * nSec100PerSec + 0.5)); // +0.99999999 ? + tmo.QuadPart = -((LONGLONG)(seconds * nSec100PerSec + 0.5)); } if (tmo.QuadPart == 0) { @@ -803,14 +810,12 @@ epicsShareFunc void epicsShareAPI epicsThreadSleep ( double seconds ) } else { timer = osdThreadGetTimer(); - if (!SetWaitableTimer(timer, &tmo, 0, NULL, NULL, 0)) - { - printf("timer error %d\n", GetLastError()); + if (!SetWaitableTimer(timer, &tmo, 0, NULL, NULL, 0)) { + fprintf ( stderr, "epicsThreadSleep: SetWaitableTimer failed %lu\n", GetLastError() ); return; } - if (WaitForSingleObject(timer, INFINITE) != WAIT_OBJECT_0) - { - printf("timer error %d\n", GetLastError()); + if (WaitForSingleObject(timer, INFINITE) != WAIT_OBJECT_0) { + fprintf ( stderr, "epicsThreadSleep: WaitForSingleObject failed %lu\n", GetLastError() ); } } } From c140a0a8047d154c7e94a878e223d8e70cd007c9 Mon Sep 17 00:00:00 2001 From: Freddie Akeroyd Date: Wed, 10 Mar 2021 21:58:35 +0000 Subject: [PATCH 086/195] Add additional cleanup and error handling --- src/libCom/osi/os/WIN32/osdEvent.c | 4 +-- src/libCom/osi/os/WIN32/osdThread.c | 37 +++++++++++++++++--------- src/libCom/osi/os/WIN32/osdThreadPvt.h | 14 ++++++++++ 3 files changed, 41 insertions(+), 14 deletions(-) create mode 100644 src/libCom/osi/os/WIN32/osdThreadPvt.h diff --git a/src/libCom/osi/os/WIN32/osdEvent.c b/src/libCom/osi/os/WIN32/osdEvent.c index 9d300e71c..fb67d6c79 100644 --- a/src/libCom/osi/os/WIN32/osdEvent.c +++ b/src/libCom/osi/os/WIN32/osdEvent.c @@ -26,6 +26,8 @@ #include "shareLib.h" #include "epicsEvent.h" +#include "osdThreadPvt.h" + typedef struct epicsEventOSD { HANDLE handle; } epicsEventOSD; @@ -84,8 +86,6 @@ epicsShareFunc epicsEventStatus epicsEventWait ( epicsEventId pSem ) } } -extern HANDLE osdThreadGetTimer(void); /* from osdThread.c */ - /* * epicsEventWaitWithTimeout () */ diff --git a/src/libCom/osi/os/WIN32/osdThread.c b/src/libCom/osi/os/WIN32/osdThread.c index 1b590de27..0057ee953 100644 --- a/src/libCom/osi/os/WIN32/osdThread.c +++ b/src/libCom/osi/os/WIN32/osdThread.c @@ -30,6 +30,8 @@ #include "ellLib.h" #include "epicsExit.h" +#include "osdThreadPvt.h" + epicsShareFunc void osdThreadHooksRun(epicsThreadId id); void setThreadName ( DWORD dwThreadID, LPCSTR szThreadName ); @@ -227,6 +229,19 @@ static win32ThreadGlobal * fetchWin32ThreadGlobal ( void ) return pWin32ThreadGlobal; } +static void epicsParmCleanupDataWIN32 ( win32ThreadParam * pParm ) +{ + if ( pParm ) { + if ( pParm->handle ) { + CloseHandle ( pParm->handle ); + } + if ( pParm->timer ) { + CloseHandle ( pParm->timer ); + } + free ( pParm ); + } +} + static void epicsParmCleanupWIN32 ( win32ThreadParam * pParm ) { win32ThreadGlobal * pGbl = fetchWin32ThreadGlobal (); @@ -241,10 +256,8 @@ static void epicsParmCleanupWIN32 ( win32ThreadParam * pParm ) ellDelete ( & pGbl->threadList, & pParm->node ); LeaveCriticalSection ( & pGbl->mutex ); - CloseHandle ( pParm->handle ); - CloseHandle ( pParm->timer ); - pParm->timer = NULL; - free ( pParm ); + epicsParmCleanupDataWIN32 ( pParm ); + TlsSetValue ( pGbl->tlsIndexThreadLibraryEPICS, 0 ); } } @@ -528,12 +541,14 @@ static win32ThreadParam * epicsThreadParmCreate ( const char *pName ) pParmWIN32->isSuspended = 0; #ifdef CREATE_WAITABLE_TIMER_HIGH_RESOLUTION pParmWIN32->timer = CreateWaitableTimerEx(NULL, NULL, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS); +#endif if (pParmWIN32->timer == NULL) { pParmWIN32->timer = CreateWaitableTimer(NULL, 0, NULL); } -#else - pParmWIN32->timer = CreateWaitableTimer(NULL, 0, NULL); -#endif + if (pParmWIN32->timer == NULL) { + free(pParmWIN32); + return NULL; + } } return pParmWIN32; } @@ -616,7 +631,7 @@ epicsShareFunc epicsThreadId epicsShareAPI epicsThreadCreate (const char *pName, CREATE_SUSPENDED | STACK_SIZE_PARAM_IS_A_RESERVATION, & threadId ); if ( pParmWIN32->handle == 0 ) { - free ( pParmWIN32 ); + epicsParmCleanupDataWIN32 ( pParmWIN32 ); return NULL; } /* weird win32 interface threadId parameter inconsistency */ @@ -626,8 +641,7 @@ epicsShareFunc epicsThreadId epicsShareAPI epicsThreadCreate (const char *pName, osdPriority = epicsThreadGetOsdPriorityValue (priority); bstat = SetThreadPriority ( pParmWIN32->handle, osdPriority ); if (!bstat) { - CloseHandle ( pParmWIN32->handle ); - free ( pParmWIN32 ); + epicsParmCleanupDataWIN32 ( pParmWIN32 ); return NULL; } @@ -640,8 +654,7 @@ epicsShareFunc epicsThreadId epicsShareAPI epicsThreadCreate (const char *pName, EnterCriticalSection ( & pGbl->mutex ); ellDelete ( & pGbl->threadList, & pParmWIN32->node ); LeaveCriticalSection ( & pGbl->mutex ); - CloseHandle ( pParmWIN32->handle ); - free ( pParmWIN32 ); + epicsParmCleanupDataWIN32 ( pParmWIN32 ); return NULL; } diff --git a/src/libCom/osi/os/WIN32/osdThreadPvt.h b/src/libCom/osi/os/WIN32/osdThreadPvt.h new file mode 100644 index 000000000..9c0e4f0ac --- /dev/null +++ b/src/libCom/osi/os/WIN32/osdThreadPvt.h @@ -0,0 +1,14 @@ +#ifndef osdThreadPvth +#define osdThreadPvth + +#ifdef __cplusplus +extern "C" { +#endif + +extern HANDLE osdThreadGetTimer(void); + +#ifdef __cplusplus +} +#endif + +#endif /* osdThreadPvth */ From 29e9843056bd9c9e65b04c1a50c4e22fd445eac3 Mon Sep 17 00:00:00 2001 From: Freddie Akeroyd Date: Fri, 12 Mar 2021 19:24:09 +0000 Subject: [PATCH 087/195] Add release notes entry for waitable timers --- documentation/RELEASE_NOTES.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 374152589..66d843645 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -12,6 +12,14 @@ The names of the generated junit xml test output files have been changed from `.xml` to `-results.xml`, to allow better distinction from other xml files. (I.e., for easy wildcard matching.) +### Use waitable timers on Microsoft Windows + +The `epicsEventWaitWithTimeout` and `epicsThreadSleep` functions have +been changed to use waitable timers. On Windows 10 version 1803 or higher +they will use high resolution timers for more consistent timing. + +See https://groups.google.com/a/chromium.org/g/scheduler-dev/c/0GlSPYreJeY +for a comparison of the performance of different timers. ## Changes made between 3.15.7 and 3.15.8 From 3874c1bcfccb15f420743482b6f9c0c4fc1e08be Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Mon, 15 Mar 2021 14:28:04 -0500 Subject: [PATCH 088/195] Disable building mvme2100, mvme167, uC8252 for RTEMS5 Someone needs to take a look at these targets and get them to work with RTEMS5, but for now, disable building them in the CI scripts. --- .github/workflows/ci-scripts-build.yml | 42 +++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index 7394814cb..98cdfc75c 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -85,13 +85,13 @@ jobs: test: NO name: "Ub-20 gcc-9 + RT-5.1 beatnik" - - os: ubuntu-20.04 - cmp: gcc - configuration: default - rtems: "5" - rtems_target: RTEMS-mvme2100 - test: NO - name: "Ub-20 gcc-9 + RT-5.1 mvme2100" + # - os: ubuntu-20.04 + # cmp: gcc + # configuration: default + # rtems: "5" + # rtems_target: RTEMS-mvme2100 + # test: NO + # name: "Ub-20 gcc-9 + RT-5.1 mvme2100" - os: ubuntu-20.04 cmp: gcc @@ -117,21 +117,21 @@ jobs: test: NO name: "Ub-20 gcc-9 + RT-5.1 xilinx_zynq_a9_qemu" - - os: ubuntu-20.04 - cmp: gcc - configuration: default - rtems: "5" - rtems_target: RTEMS-mvme167 - test: NO - name: "Ub-20 gcc-9 + RT-5.1 mvme167" + # - os: ubuntu-20.04 + # cmp: gcc + # configuration: default + # rtems: "5" + # rtems_target: RTEMS-mvme167 + # test: NO + # name: "Ub-20 gcc-9 + RT-5.1 mvme167" - - os: ubuntu-20.04 - cmp: gcc - configuration: default - rtems: "5" - rtems_target: RTEMS-uC5282 - test: NO - name: "Ub-20 gcc-9 + RT-5.1 uC5282" + # - os: ubuntu-20.04 + # cmp: gcc + # configuration: default + # rtems: "5" + # rtems_target: RTEMS-uC5282 + # test: NO + # name: "Ub-20 gcc-9 + RT-5.1 uC5282" - os: ubuntu-20.04 cmp: gcc From af2d4de94274a3a6e677b2984608fea527cc814f Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Fri, 19 Mar 2021 13:17:07 -0500 Subject: [PATCH 089/195] Update release notes and documentation for RTEMS5 --- configure/CONFIG_SITE | 5 +++++ documentation/RELEASE_NOTES.md | 40 +++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 17 deletions(-) diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index 6fd0033dd..49dfcab98 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -86,6 +86,7 @@ # vxWorks-mpc8540 # vxWorks-mpc8548 # RTEMS-at91rm9200ek +# RTEMS-beagleboneblack # RTEMS-beatnik # RTEMS-gen68360 # RTEMS-mcp750 @@ -95,8 +96,12 @@ # RTEMS-mvme3100 # RTEMS-mvme5500 # RTEMS-pc386 +# RTEMS-pc686 # RTEMS-psim +# RTEMS-qoriq_e500 # RTEMS-uC5282 +# RTEMS-xilinx-zynq_a9_qemu +# RTEMS-xilinx_zynq_zedboad # win32-x86-mingw (linux-x86 or -x86_64 host) # diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 8fd606ef8..078b07ece 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -18,6 +18,29 @@ should also be read to understand what has changed since earlier releases. +### Support for RTEMS 5 + +The new major release of the RTEMS real-time OS contains many changes +including the ability to support SMP systems. The earlier EPICS +support for RTEMS made use of various RTEMS-specific kernel APIs which +cannot be used on an SMP system, so the changes here required a +completely new port to the Posix real-time APIs that RTEMS-5 now +recommends. + +A new RTEMS configuration variable RTEMS_VERSION has been added which +should be set to the OS version number, e.g. 4.9. When this is 4.12 or +greater, true for 5.0 as well, the new libCom/osi/os/RTEMS-posix +source files will be used; the older API source files can now be found +in libCom/osi/os/RTEMS-kernel, and those which are common to both +installations are in libCom/osi/os/RTEMS. The compiler options are +read from the Makefile.inc of the corresponding BSP and set in the +configuration files. It checks that the BSP was also built with the +--enable-posix option. It also checks if the BSP was built with the +legacy stack or libbsd. + +RTEMS5 brings support for new targets including: +RTEMS-beagleboneblack, RTEMS-pc686, RTEMS-qoriq_e500, +RTEMS-xilinx-zynq-a9_qemu, RTEMS-xilinx_zynq_zedboard ### Priority inversion safe posix mutexes @@ -106,23 +129,6 @@ This also fixes [lauchpad bug #1714455](https://bugs.launchpad.net/bugs/1714455) These changes are to more closely follow the JSON5 standard, which doesn't support octal character escapes or the `\a` (Bel, `\x07`) escape sequence. -### Support for RTEMS 5 - -The new major release of the RTEMS real-time OS contains many changes including -the ability to support SMP systems. The earlier EPICS support for RTEMS made use -of various RTEMS-specific kernel APIs which cannot be used on an SMP system, so -the changes here required acompletely new port to the Posix real-time APIs that -RTEMS-5 now recommends. -A new RTEMS configuration variable RTEMS_SERIES has been added which should be -set to the first two components of the OS version number, e.g. 4.9. When this -is 4.12 or greater, true for 5.0 as well, the new libCom/osi/os/RTEMS-posix -source files will be used; the older API source files can now be found in -libCom/osi/os/RTEMS-kernel, and those which are common to both installations are -in libCom/osi/os/RTEMS. The compiler options are read from the Makefile.inc of -the corresponding BSP and set in the configuration files. It checks that the BSP -was also built with the --enable-posix option. It also checks if the BSP was built -with the legacy stack or libbsd. - ### Filters in database input links Input database links can now use channel filters, it is not necessary to From fc4379595e11c5bcd8a9675dcdf08da3889e78c7 Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Wed, 24 Mar 2021 13:06:18 -0500 Subject: [PATCH 090/195] Update release note about RTEMS 5 support --- documentation/RELEASE_NOTES.md | 53 ++++++++++++++++++++++------------ 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 078b07ece..1f549f3e0 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -18,29 +18,44 @@ should also be read to understand what has changed since earlier releases. -### Support for RTEMS 5 - +### Experimental Support for RTEMS 5 The new major release of the RTEMS real-time OS contains many changes -including the ability to support SMP systems. The earlier EPICS -support for RTEMS made use of various RTEMS-specific kernel APIs which -cannot be used on an SMP system, so the changes here required a -completely new port to the Posix real-time APIs that RTEMS-5 now -recommends. +including the ability to support SMP systems and support for several +new targets: +- RTEMS-beagleboneblack +- RTEMS-pc686 +- RTEMS-qoriq_e500 +- RTEMS-xilinx-zynq-a9_qemu +- RTEMS-xilinx_zynq_zedboard + +The earlier EPICS support for RTEMS made use of various +RTEMS-specific kernel APIs which cannot be used on an SMP system, so +the changes here required a completely new port to the Posix +real-time APIs that RTEMS-5 now recommends. + A new RTEMS configuration variable RTEMS_VERSION has been added which -should be set to the OS version number, e.g. 4.9. When this is 4.12 or -greater, true for 5.0 as well, the new libCom/osi/os/RTEMS-posix -source files will be used; the older API source files can now be found -in libCom/osi/os/RTEMS-kernel, and those which are common to both -installations are in libCom/osi/os/RTEMS. The compiler options are -read from the Makefile.inc of the corresponding BSP and set in the -configuration files. It checks that the BSP was also built with the ---enable-posix option. It also checks if the BSP was built with the -legacy stack or libbsd. +should be set to the OS version number, e.g. 4.9. When this is 4.12 +or greater, true for 5.1 as well, the new libCom/osi/os/RTEMS-posix +source files will be used; the older API source files can now be +found in libCom/osi/os/RTEMS-kernel, and those which are common to +both installations are in libCom/osi/os/RTEMS. The compiler options +are read from the Makefile.inc of the corresponding BSP and set in +the configuration files. It checks that the BSP was also built with +the --enable-posix option. It also checks if the BSP was built with +the legacy stack or libbsd. + +The dependency on bspExt has been removed. RTEMS 5 provides the bus +support natively now. + +Known Issues: +- MVME2100, MVME167, and uC5282 have not yet been updated to compile for RTEMS 5. +- VMEBus support is not available for all powerpc BSPs. +- There are some known issues with floating point on MVME2500 +- Changed network driver for beatnik to work with libbsd. Some + issues with DHCP, but network stack usable. Can load env from + NVRAM. -RTEMS5 brings support for new targets including: -RTEMS-beagleboneblack, RTEMS-pc686, RTEMS-qoriq_e500, -RTEMS-xilinx-zynq-a9_qemu, RTEMS-xilinx_zynq_zedboard ### Priority inversion safe posix mutexes From c78db512f228a524f70d3d13891427b9f13a7f04 Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Fri, 26 Mar 2021 17:30:36 +0100 Subject: [PATCH 091/195] Windows: use -Z7 instead of -Zi to generate debug symbols "C7 compatible" or "old-style" debug information is kept local in the translation unit (.obj file) and does not create issues with parallel builds --- configure/os/CONFIG.win32-x86.win32-x86 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure/os/CONFIG.win32-x86.win32-x86 b/configure/os/CONFIG.win32-x86.win32-x86 index 6a5078d60..f92856205 100644 --- a/configure/os/CONFIG.win32-x86.win32-x86 +++ b/configure/os/CONFIG.win32-x86.win32-x86 @@ -49,9 +49,9 @@ OPT_CFLAGS_YES_NO = -Ox -Oy- OPT_CFLAGS_YES = $(OPT_CFLAGS_YES_$(OPT_WHOLE_PROGRAM)) # -# -Zi generate program database for debugging information +# -Z7 generate C7 compatible debugging information (inside .obj) # -RTCsu enable run-time error checks -OPT_CFLAGS_NO = -Zi -RTCsu +OPT_CFLAGS_NO = -Z7 -RTCsu # specify object file name and location OBJ_CFLAG = -Fo @@ -116,9 +116,9 @@ OPT_CXXFLAGS_YES_NO = -Ox -Oy- OPT_CXXFLAGS_YES = $(OPT_CXXFLAGS_YES_$(OPT_WHOLE_PROGRAM)) # -# -Zi generate program database for debugging information +# -Z7 generate C7 compatible debugging information (inside .obj) # -RTCsu enable run-time error checks -OPT_CXXFLAGS_NO = -RTCsu -Zi +OPT_CXXFLAGS_NO = -RTCsu -Z7 # specify object file name and location OBJ_CXXFLAG = -Fo From fa069b0845b09b587ae327b6e452a623c4262662 Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Mon, 29 Mar 2021 17:49:02 +0200 Subject: [PATCH 092/195] Revert config fixes for parallel builds with MSVC This reverts commit 1454f42a2737fd476531a1476653f16ffcf7bb9f. This reverts commit 4aee25e8e2f911c08c8ebaf4245abd54d70bd84c. --- configure/os/CONFIG.win32-x86.win32-x86 | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/configure/os/CONFIG.win32-x86.win32-x86 b/configure/os/CONFIG.win32-x86.win32-x86 index f92856205..c3b780c3e 100644 --- a/configure/os/CONFIG.win32-x86.win32-x86 +++ b/configure/os/CONFIG.win32-x86.win32-x86 @@ -140,20 +140,6 @@ STATIC_LDLIBS_NO= STATIC_LDFLAGS= RANLIB= -# -# option needed for parallel builds with Visual Studio 2013 onward -# VS2012 and above have VisualStudioVersion, so just need to exclude 2012 (11.0) -# -FS Force Synchronous PDB Writes -# -ifneq ($(VisualStudioVersion),) -ifneq ($(VisualStudioVersion),11.0) - OPT_CXXFLAGS_NO += -FS - OPT_CFLAGS_NO += -FS -endif -endif - - -# # add -profile here to run the ms profiler # -LTCG whole program optimization # -incremental:no full linking From 892a361de7002bf2b3f375f24bc5bf61858de2e5 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 30 Mar 2020 13:56:13 -0700 Subject: [PATCH 093/195] add alarm message field --- modules/database/src/ioc/db/dbCommon.dbd.pod | 10 ++++++ modules/database/src/ioc/db/recGbl.c | 35 +++++++++++++++++++- modules/database/src/ioc/db/recGbl.h | 9 +++++ 3 files changed, 53 insertions(+), 1 deletion(-) diff --git a/modules/database/src/ioc/db/dbCommon.dbd.pod b/modules/database/src/ioc/db/dbCommon.dbd.pod index 36b9c1adb..24624abf6 100644 --- a/modules/database/src/ioc/db/dbCommon.dbd.pod +++ b/modules/database/src/ioc/db/dbCommon.dbd.pod @@ -279,6 +279,11 @@ support routines which write to the VAL field are responsible for setting UDF. special(SPC_NOMOD) menu(menuAlarmSevr) } + field(AMSG,DBF_STRING) { + prompt("Alarm Message") + special(SPC_NOMOD) + size(40) + } field(NSTA,DBF_MENU) { prompt("New Alarm Status") special(SPC_NOMOD) @@ -291,6 +296,11 @@ support routines which write to the VAL field are responsible for setting UDF. interest(2) menu(menuAlarmSevr) } + field(NAMSG,DBF_STRING) { + prompt("New Alarm Message") + special(SPC_NOMOD) + size(40) + } field(ACKS,DBF_MENU) { prompt("Alarm Ack Severity") special(SPC_NOMOD) diff --git a/modules/database/src/ioc/db/recGbl.c b/modules/database/src/ioc/db/recGbl.c index e9f6e5e89..c2cdf2bbf 100644 --- a/modules/database/src/ioc/db/recGbl.c +++ b/modules/database/src/ioc/db/recGbl.c @@ -24,6 +24,7 @@ #include "epicsMath.h" #include "epicsPrint.h" #include "epicsStdlib.h" +#include "epicsStdio.h" #include "epicsTime.h" #include "errlog.h" @@ -184,6 +185,11 @@ unsigned short recGblResetAlarms(void *precord) if (new_sevr > INVALID_ALARM) new_sevr = INVALID_ALARM; + if(strcmp(pdbc->namsg, pdbc->amsg)!=0) { + strcpy(pdbc->amsg, pdbc->namsg); + stat_mask = DBE_ALARM; + } + pdbc->stat = new_stat; pdbc->sevr = new_sevr; pdbc->nsta = 0; @@ -198,6 +204,7 @@ unsigned short recGblResetAlarms(void *precord) } if (stat_mask) { db_post_events(pdbc, &pdbc->stat, stat_mask); + db_post_events(pdbc, &pdbc->amsg, stat_mask); val_mask = DBE_ALARM; if (!pdbc->ackt || new_sevr >= pdbc->acks) { @@ -211,18 +218,44 @@ unsigned short recGblResetAlarms(void *precord) } return val_mask; } +int recGblSetSevrMsg(void *precord, epicsEnum16 new_stat, + epicsEnum16 new_sevr, + const char *msg, ...) +{ + int ret; + va_list args; + va_start(args, msg); + ret = recGblSetSevrVMsg(precord, new_stat, new_sevr, msg, args); + va_end(args); + return ret; +} -int recGblSetSevr(void *precord, epicsEnum16 new_stat, epicsEnum16 new_sevr) +int recGblSetSevrVMsg(void *precord, epicsEnum16 new_stat, + epicsEnum16 new_sevr, + const char *msg, va_list args) { struct dbCommon *prec = precord; if (prec->nsev < new_sevr) { prec->nsta = new_stat; prec->nsev = new_sevr; + if(msg) { + epicsVsnprintf(prec->namsg, sizeof(prec->namsg)-1, msg, args); + prec->namsg[sizeof(prec->namsg)-1] = '\0'; + + } else { + prec->namsg[0] = '\0'; + } + prec->namsg[sizeof(prec->namsg)-1] = '\0'; return TRUE; } return FALSE; } +int recGblSetSevr(void *precord, epicsEnum16 new_stat, epicsEnum16 new_sevr) +{ + return recGblSetSevrMsg(precord, new_stat, new_sevr, NULL); +} + void recGblInheritSevr(int msMode, void *precord, epicsEnum16 stat, epicsEnum16 sevr) { diff --git a/modules/database/src/ioc/db/recGbl.h b/modules/database/src/ioc/db/recGbl.h index fd08123ef..03c4202e2 100644 --- a/modules/database/src/ioc/db/recGbl.h +++ b/modules/database/src/ioc/db/recGbl.h @@ -15,6 +15,9 @@ #ifndef INCrecGblh #define INCrecGblh 1 +#include + +#include "compilerDependencies.h" #include "epicsTypes.h" #include "dbCoreAPI.h" @@ -62,6 +65,12 @@ DBCORE_API int recGblSetSevr(void *precord, epicsEnum16 new_stat, epicsEnum16 new_sevr); DBCORE_API void recGblInheritSevr(int msMode, void *precord, epicsEnum16 stat, epicsEnum16 sevr); +DBCORE_API int recGblSetSevrMsg(void *precord, epicsEnum16 new_stat, + epicsEnum16 new_sevr, + const char *msg, ...) EPICS_PRINTF_STYLE(4,5); +DBCORE_API int recGblSetSevrVMsg(void *precord, epicsEnum16 new_stat, + epicsEnum16 new_sevr, + const char *msg, va_list args); DBCORE_API void recGblFwdLink(void *precord); DBCORE_API void recGblGetTimeStamp(void *precord); DBCORE_API void recGblGetTimeStampSimm(void *prec, const epicsEnum16 simm, struct link *siol); From d19586fdfdbba51b4617e12ce7983d3694ddf97f Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 30 Mar 2020 21:32:15 -0700 Subject: [PATCH 094/195] use recGblSetSevrMsg() --- modules/database/src/ioc/db/dbAccess.c | 2 +- modules/database/src/ioc/db/dbLink.c | 29 ++++++++++++++------ modules/database/src/std/dev/devEnviron.c | 4 +-- modules/database/src/std/rec/aiRecord.c | 2 +- modules/database/src/std/rec/calcoutRecord.c | 6 ++-- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/modules/database/src/ioc/db/dbAccess.c b/modules/database/src/ioc/db/dbAccess.c index d4d8e873a..6c418f968 100644 --- a/modules/database/src/ioc/db/dbAccess.c +++ b/modules/database/src/ioc/db/dbAccess.c @@ -523,7 +523,7 @@ long dbProcess(dbCommon *precord) (precord->lcnt++ < MAX_LOCK) || (precord->sevr >= INVALID_ALARM)) goto all_done; - recGblSetSevr(precord, SCAN_ALARM, INVALID_ALARM); + recGblSetSevrMsg(precord, SCAN_ALARM, INVALID_ALARM, "Async in progress"); monitor_mask = recGblResetAlarms(precord); monitor_mask |= DBE_VALUE|DBE_LOG; pdbFldDes = pdbRecordType->papFldDes[pdbRecordType->indvalFlddes]; diff --git a/modules/database/src/ioc/db/dbLink.c b/modules/database/src/ioc/db/dbLink.c index d23355e0e..f2e19dbcb 100644 --- a/modules/database/src/ioc/db/dbLink.c +++ b/modules/database/src/ioc/db/dbLink.c @@ -313,10 +313,27 @@ long dbTryGetLink(struct link *plink, short dbrType, void *pbuffer, return plset->getValue(plink, dbrType, pbuffer, pnRequest); } +static +void setLinkAlarm(struct link* plink) +{ + struct dbCommon *precord = plink->precord; + dbRecordType *rdes = precord->rdes; + const char* amsg = NULL; + short i; + + for(i=0; ino_links; i++) { + dbFldDes *fdes = rdes->papFldDes[rdes->link_ind[i]]; + if((char*)plink - (char*)precord == fdes->offset) { + amsg = fdes->name; + } + } + + recGblSetSevrMsg(precord, LINK_ALARM, INVALID_ALARM, "field %s", amsg); +} + long dbGetLink(struct link *plink, short dbrType, void *pbuffer, long *poptions, long *pnRequest) { - struct dbCommon *precord = plink->precord; long status; if (poptions && *poptions) { @@ -328,7 +345,7 @@ long dbGetLink(struct link *plink, short dbrType, void *pbuffer, if (status == S_db_noLSET) return -1; if (status) - recGblSetSevr(precord, LINK_ALARM, INVALID_ALARM); + setLinkAlarm(plink); return status; } @@ -416,9 +433,7 @@ long dbPutLink(struct link *plink, short dbrType, const void *pbuffer, status = plset->putValue(plink, dbrType, pbuffer, nRequest); if (status) { - struct dbCommon *precord = plink->precord; - - recGblSetSevr(precord, LINK_ALARM, INVALID_ALARM); + setLinkAlarm(plink); } return status; } @@ -443,9 +458,7 @@ long dbPutLinkAsync(struct link *plink, short dbrType, const void *pbuffer, status = plset->putAsync(plink, dbrType, pbuffer, nRequest); if (status) { - struct dbCommon *precord = plink->precord; - - recGblSetSevr(precord, LINK_ALARM, INVALID_ALARM); + setLinkAlarm(plink); } return status; } diff --git a/modules/database/src/std/dev/devEnviron.c b/modules/database/src/std/dev/devEnviron.c index 77b89d001..910f1f0c7 100644 --- a/modules/database/src/std/dev/devEnviron.c +++ b/modules/database/src/std/dev/devEnviron.c @@ -63,7 +63,7 @@ static long read_lsi(lsiRecord *prec) prec->val[0] = 0; prec->len = 1; prec->udf = TRUE; - recGblSetSevr(prec, UDF_ALARM, prec->udfs); + recGblSetSevrMsg(prec, UDF_ALARM, prec->udfs, "No such ENV"); } return 0; @@ -114,7 +114,7 @@ static long read_stringin(stringinRecord *prec) else { prec->val[0] = 0; prec->udf = TRUE; - recGblSetSevr(prec, UDF_ALARM, prec->udfs); + recGblSetSevrMsg(prec, UDF_ALARM, prec->udfs, "No such ENV"); } return 0; diff --git a/modules/database/src/std/rec/aiRecord.c b/modules/database/src/std/rec/aiRecord.c index c149211b9..8d31b07ff 100644 --- a/modules/database/src/std/rec/aiRecord.c +++ b/modules/database/src/std/rec/aiRecord.c @@ -432,7 +432,7 @@ static void convert(aiRecord *prec) default: /* must use breakpoint table */ if (cvtRawToEngBpt(&val,prec->linr,prec->init,(void *)&prec->pbrk,&prec->lbrk)!=0) { - recGblSetSevr(prec,SOFT_ALARM,MAJOR_ALARM); + recGblSetSevrMsg(prec,SOFT_ALARM,MAJOR_ALARM, "BPT Error"); } } diff --git a/modules/database/src/std/rec/calcoutRecord.c b/modules/database/src/std/rec/calcoutRecord.c index dbd6be3f9..eadcc5862 100644 --- a/modules/database/src/std/rec/calcoutRecord.c +++ b/modules/database/src/std/rec/calcoutRecord.c @@ -236,7 +236,7 @@ static long process(struct dbCommon *pcommon) } if (fetch_values(prec) == 0) { if (calcPerform(&prec->a, &prec->val, prec->rpcl)) { - recGblSetSevr(prec, CALC_ALARM, INVALID_ALARM); + recGblSetSevrMsg(prec, CALC_ALARM, INVALID_ALARM, "calcPerform"); } else { prec->udf = isnan(prec->val); } @@ -610,7 +610,7 @@ static void execOutput(calcoutRecord *prec) break; case calcoutDOPT_Use_OVAL: if (calcPerform(&prec->a, &prec->oval, prec->orpc)) { - recGblSetSevr(prec, CALC_ALARM, INVALID_ALARM); + recGblSetSevrMsg(prec, CALC_ALARM, INVALID_ALARM, "OCAL calcPerform"); } else { prec->udf = isnan(prec->oval); } @@ -770,7 +770,7 @@ static long writeValue(calcoutRecord *prec) if (!pcalcoutDSET || !pcalcoutDSET->write) { errlogPrintf("%s DSET write does not exist\n", prec->name); - recGblSetSevr(prec, SOFT_ALARM, INVALID_ALARM); + recGblSetSevrMsg(prec, SOFT_ALARM, INVALID_ALARM, "DSET write does not exist"); prec->pact = TRUE; return(-1); } From a12684e7ad7a0b2f987b53490a0b8775b0c731df Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 29 Aug 2020 15:13:09 -0700 Subject: [PATCH 095/195] AMSG feature test --- modules/database/src/ioc/db/recGbl.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/database/src/ioc/db/recGbl.h b/modules/database/src/ioc/db/recGbl.h index 03c4202e2..269777ec6 100644 --- a/modules/database/src/ioc/db/recGbl.h +++ b/modules/database/src/ioc/db/recGbl.h @@ -25,6 +25,14 @@ extern "C" { #endif +/** Feature test macro for alarm message (AMSG) field and support + * + * Covers addition of dbCommon::amsg, recGblSetSevrMsg(), lset::getAlarmMsg() + * + * @since UNRELEASED + */ +#define HAS_ALARM_MESSAGE 1 + /*************************************************************************/ /* Structures needed for args */ From 5143c71a436078f269f0bb4d1bf90adbf49c9b27 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 29 Aug 2020 15:37:58 -0700 Subject: [PATCH 096/195] add lset::getAlarmMsg() --- modules/database/src/ioc/db/dbDbLink.c | 17 ++++++++++-- modules/database/src/ioc/db/dbLink.c | 17 +++++++++--- modules/database/src/ioc/db/dbLink.h | 24 ++++++++++++++++ modules/database/src/std/link/lnkCalc.c | 37 +++++++++++++++++++------ 4 files changed, 79 insertions(+), 16 deletions(-) diff --git a/modules/database/src/ioc/db/dbDbLink.c b/modules/database/src/ioc/db/dbDbLink.c index 0fb325f30..0243fde9a 100644 --- a/modules/database/src/ioc/db/dbDbLink.c +++ b/modules/database/src/ioc/db/dbDbLink.c @@ -337,8 +337,8 @@ static long dbDbGetUnits(const struct link *plink, char *units, int unitsSize) return 0; } -static long dbDbGetAlarm(const struct link *plink, epicsEnum16 *status, - epicsEnum16 *severity) +static long dbDbGetAlarmMsg(const struct link *plink, epicsEnum16 *status, + epicsEnum16 *severity, char *msgbuf, size_t msgbuflen) { dbChannel *chan = linkChannel(plink); dbCommon *precord = dbChannelRecord(chan); @@ -346,9 +346,19 @@ static long dbDbGetAlarm(const struct link *plink, epicsEnum16 *status, *status = precord->stat; if (severity) *severity = precord->sevr; + if (msgbuf && msgbuflen) { + strncpy(msgbuf, precord->amsg, msgbuflen-1); + msgbuf[msgbuflen-1] = '\0'; + } return 0; } +static long dbDbGetAlarm(const struct link *plink, epicsEnum16 *status, + epicsEnum16 *severity) +{ + return dbDbGetAlarmMsg(plink, status, severity, NULL, 0u); +} + static long dbDbGetTimeStamp(const struct link *plink, epicsTimeStamp *pstamp) { dbChannel *chan = linkChannel(plink); @@ -403,7 +413,8 @@ static lset dbDb_lset = { dbDbGetPrecision, dbDbGetUnits, dbDbGetAlarm, dbDbGetTimeStamp, dbDbPutValue, NULL, - dbDbScanFwdLink, doLocked + dbDbScanFwdLink, doLocked, + dbDbGetAlarmMsg, }; diff --git a/modules/database/src/ioc/db/dbLink.c b/modules/database/src/ioc/db/dbLink.c index f2e19dbcb..45b5e0f7e 100644 --- a/modules/database/src/ioc/db/dbLink.c +++ b/modules/database/src/ioc/db/dbLink.c @@ -402,14 +402,23 @@ long dbGetUnits(const struct link *plink, char *units, int unitsSize) } long dbGetAlarm(const struct link *plink, epicsEnum16 *status, - epicsEnum16 *severity) + epicsEnum16 *severity) +{ + return dbGetAlarmMsg(plink, status, severity, NULL, 0); +} + +long dbGetAlarmMsg(const struct link *plink, epicsEnum16 *status, + epicsEnum16 *severity, char *msgbuf, size_t msgbuflen) { lset *plset = plink->lset; - if (!plset || !plset->getAlarm) + if (plset && plset->getAlarmMsg) { + return plset->getAlarmMsg(plink, status, severity, msgbuf, msgbuflen); + } else if(plset && plset->getAlarm) { + return plset->getAlarm(plink, status, severity); + } else { return S_db_noLSET; - - return plset->getAlarm(plink, status, severity); + } } long dbGetTimeStamp(const struct link *plink, epicsTimeStamp *pstamp) diff --git a/modules/database/src/ioc/db/dbLink.h b/modules/database/src/ioc/db/dbLink.h index dd7163c8c..c0540271a 100644 --- a/modules/database/src/ioc/db/dbLink.h +++ b/modules/database/src/ioc/db/dbLink.h @@ -282,6 +282,8 @@ typedef struct lset { * @param status where to put the alarm status (or NULL) * @param severity where to put the severity (or NULL) * @returns status value + * + * @note Link types which provide getAlarm should also provided getAlarmMsg(). */ long (*getAlarm)(const struct link *plink, epicsEnum16 *status, epicsEnum16 *severity); @@ -361,6 +363,20 @@ typedef struct lset { * @returns status value */ long (*doLocked)(struct link *plink, dbLinkUserCallback rtn, void *priv); + + /** @brief Extended version of getAlarm + * + * Equivalent of getAlarm() and also copy out alarm message string. + * The msgbuf argument may be NULL and/or msgbuflen==0, in which case + * the call must be the same as a call to getAlarm(). + * + * Implementations must write a trailing nil to msgbuf whenever + * @code msgbuf!=NULL && msgbuflen>0 @endcode . + * + * @since UNRELEASED + */ + long (*getAlarmMsg)(const struct link *plink, epicsEnum16 *status, + epicsEnum16 *severity, char *msgbuf, size_t msgbuflen); } lset; #define dbGetSevr(link, sevr) \ @@ -402,6 +418,14 @@ DBCORE_API long dbGetUnits(const struct link *plink, char *units, int unitsSize); DBCORE_API long dbGetAlarm(const struct link *plink, epicsEnum16 *status, epicsEnum16 *severity); +/** Get link alarm and message string. + * To ensure the complete message string is copied, ensure @code msgbuflen >= sizeof (dbCommon::amsg) @endcode . + * A trailing nil will be added whenever @code msgbuflen > 0 @endcode . + * @since UNRELEASED + */ +DBCORE_API long dbGetAlarmMsg(const struct link *plink, epicsEnum16 *status, + epicsEnum16 *severity, char *msgbuf, size_t msgbuflen); +#define dbGetAlarmMsg(LINK, STAT, SEVR, BUF, BUFLEN) dbGetAlarmMsg(LINK, STAT, SEVR, BUF, BUFLEN) DBCORE_API long dbGetTimeStamp(const struct link *plink, epicsTimeStamp *pstamp); DBCORE_API long dbPutLink(struct link *plink, short dbrType, diff --git a/modules/database/src/std/link/lnkCalc.c b/modules/database/src/std/link/lnkCalc.c index 8d7f72c69..7c3eab722 100644 --- a/modules/database/src/std/link/lnkCalc.c +++ b/modules/database/src/std/link/lnkCalc.c @@ -53,6 +53,7 @@ typedef struct calc_link { } pstate; epicsEnum16 stat; epicsEnum16 sevr; + char amsg[MAX_STRING_SIZE]; short prec; char *expr; char *major; @@ -385,9 +386,10 @@ static void lnkCalc_report(const jlink *pjlink, int level, int indent) if (level > 0) { if (clink->sevr) - printf("%*s Alarm: %s, %s\n", indent, "", + printf("%*s Alarm: %s, %s, \"%s\"\n", indent, "", epicsAlarmSeverityStrings[clink->sevr], - epicsAlarmConditionStrings[clink->stat]); + epicsAlarmConditionStrings[clink->stat], + clink->amsg); if (clink->post_major) printf("%*s Major expression: \"%s\"\n", indent, "", @@ -583,6 +585,7 @@ static long lnkCalc_getValue(struct link *plink, short dbrType, void *pbuffer, } clink->stat = 0; clink->sevr = 0; + clink->amsg[0] = '\0'; if (clink->post_expr) { status = calcPerform(clink->arg, &clink->val, clink->post_expr); @@ -604,7 +607,8 @@ static long lnkCalc_getValue(struct link *plink, short dbrType, void *pbuffer, if (!status && alval) { clink->stat = LINK_ALARM; clink->sevr = MAJOR_ALARM; - recGblSetSevr(prec, clink->stat, clink->sevr); + strcpy(clink->amsg, "post_major error"); + recGblSetSevrMsg(prec, clink->stat, clink->sevr, "post_major error"); } } @@ -615,7 +619,8 @@ static long lnkCalc_getValue(struct link *plink, short dbrType, void *pbuffer, if (!status && alval) { clink->stat = LINK_ALARM; clink->sevr = MINOR_ALARM; - recGblSetSevr(prec, clink->stat, clink->sevr); + strcpy(clink->amsg, "post_minor error"); + recGblSetSevrMsg(prec, clink->stat, clink->sevr, "post_minor error"); } } @@ -659,6 +664,7 @@ static long lnkCalc_putValue(struct link *plink, short dbrType, } clink->stat = 0; clink->sevr = 0; + clink->amsg[0] = '\0'; /* Get the value being output as VAL */ status = conv(pbuffer, &clink->val, NULL); @@ -673,7 +679,8 @@ static long lnkCalc_putValue(struct link *plink, short dbrType, if (!status && alval) { clink->stat = LINK_ALARM; clink->sevr = MAJOR_ALARM; - recGblSetSevr(prec, clink->stat, clink->sevr); + strcpy(clink->amsg, "post_major error"); + recGblSetSevrMsg(prec, clink->stat, clink->sevr, "post_major error"); } } @@ -684,7 +691,8 @@ static long lnkCalc_putValue(struct link *plink, short dbrType, if (!status && alval) { clink->stat = LINK_ALARM; clink->sevr = MINOR_ALARM; - recGblSetSevr(prec, clink->stat, clink->sevr); + strcpy(clink->amsg, "post_major error"); + recGblSetSevrMsg(prec, clink->stat, clink->sevr, "post_minor error"); } } @@ -718,8 +726,8 @@ static long lnkCalc_getUnits(const struct link *plink, char *units, int len) return 0; } -static long lnkCalc_getAlarm(const struct link *plink, epicsEnum16 *status, - epicsEnum16 *severity) +static long lnkCalc_getAlarmMsg(const struct link *plink, epicsEnum16 *status, + epicsEnum16 *severity, char *msgbuf, size_t msgbuflen) { calc_link *clink = CONTAINER(plink->value.json.jlink, struct calc_link, jlink); @@ -728,10 +736,20 @@ static long lnkCalc_getAlarm(const struct link *plink, epicsEnum16 *status, *status = clink->stat; if (severity) *severity = clink->sevr; + if (msgbuf && msgbuflen) { + strncpy(msgbuf, clink->amsg, msgbuflen-1); + msgbuf[msgbuflen-1] = '\0'; + } return 0; } +static long lnkCalc_getAlarm(const struct link *plink, epicsEnum16 *status, + epicsEnum16 *severity) +{ + return lnkCalc_getAlarmMsg(plink, status, severity, NULL, 0u); +} + static long lnkCalc_getTimestamp(const struct link *plink, epicsTimeStamp *pstamp) { calc_link *clink = CONTAINER(plink->value.json.jlink, @@ -763,7 +781,8 @@ static lset lnkCalc_lset = { lnkCalc_getPrecision, lnkCalc_getUnits, lnkCalc_getAlarm, lnkCalc_getTimestamp, lnkCalc_putValue, NULL, - NULL, doLocked + NULL, doLocked, + lnkCalc_getAlarmMsg, }; static jlif lnkCalcIf = { From 4ca765d813df4dad3f03056665029b972b0080fb Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 15 Apr 2020 17:52:14 -0700 Subject: [PATCH 097/195] dbCommon add UTAG --- modules/database/src/ioc/db/dbCommon.dbd.pod | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/modules/database/src/ioc/db/dbCommon.dbd.pod b/modules/database/src/ioc/db/dbCommon.dbd.pod index 24624abf6..509982cfc 100644 --- a/modules/database/src/ioc/db/dbCommon.dbd.pod +++ b/modules/database/src/ioc/db/dbCommon.dbd.pod @@ -524,6 +524,11 @@ field which is then used to acquire a timestamp. interest(2) extra("epicsTimeStamp time") } + field(UTAG,DBF_LONG) { + prompt("Time Tag") + special(SPC_NOMOD) + interest(3) + } field(FLNK,DBF_FWDLINK) { prompt("Forward Process Link") promptgroup("20 - Scan") From 12f1818b39de1cd3de3bcd517f1880f2aafe5460 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 20 Apr 2020 14:04:51 -0700 Subject: [PATCH 098/195] propagate utag w/ links (including TSEL) add lset::getTimestampTag() --- modules/database/src/ioc/db/dbDbLink.c | 10 +++++++++- modules/database/src/ioc/db/dbLink.c | 15 ++++++++++++--- modules/database/src/ioc/db/dbLink.h | 13 +++++++++++++ modules/database/src/ioc/db/recGbl.c | 2 +- modules/database/src/std/link/lnkCalc.c | 20 ++++++++++++++++---- 5 files changed, 51 insertions(+), 9 deletions(-) diff --git a/modules/database/src/ioc/db/dbDbLink.c b/modules/database/src/ioc/db/dbDbLink.c index 0243fde9a..442e9f48d 100644 --- a/modules/database/src/ioc/db/dbDbLink.c +++ b/modules/database/src/ioc/db/dbDbLink.c @@ -359,14 +359,21 @@ static long dbDbGetAlarm(const struct link *plink, epicsEnum16 *status, return dbDbGetAlarmMsg(plink, status, severity, NULL, 0u); } -static long dbDbGetTimeStamp(const struct link *plink, epicsTimeStamp *pstamp) +static long dbDbGetTimeStampTag(const struct link *plink, epicsTimeStamp *pstamp, epicsInt32 *ptag) { dbChannel *chan = linkChannel(plink); dbCommon *precord = dbChannelRecord(chan); *pstamp = precord->time; + if(ptag) + *ptag = precord->utag; return 0; } +static long dbDbGetTimeStamp(const struct link *plink, epicsTimeStamp *pstamp) +{ + return dbDbGetTimeStampTag(plink, pstamp, NULL); +} + static long dbDbPutValue(struct link *plink, short dbrType, const void *pbuffer, long nRequest) { @@ -415,6 +422,7 @@ static lset dbDb_lset = { dbDbPutValue, NULL, dbDbScanFwdLink, doLocked, dbDbGetAlarmMsg, + dbDbGetTimeStampTag, }; diff --git a/modules/database/src/ioc/db/dbLink.c b/modules/database/src/ioc/db/dbLink.c index 45b5e0f7e..5e13c4a4e 100644 --- a/modules/database/src/ioc/db/dbLink.c +++ b/modules/database/src/ioc/db/dbLink.c @@ -422,13 +422,22 @@ long dbGetAlarmMsg(const struct link *plink, epicsEnum16 *status, } long dbGetTimeStamp(const struct link *plink, epicsTimeStamp *pstamp) +{ + return dbGetTimeStampTag(plink, pstamp, NULL); +} + +long dbGetTimeStampTag(const struct link *plink, + epicsTimeStamp *pstamp, epicsInt32 *ptag) { lset *plset = plink->lset; - if (!plset || !plset->getTimeStamp) + if (plset && plset->getTimeStampTag) { + return plset->getTimeStampTag(plink, pstamp, ptag); + } else if(plset && plset->getTimeStamp) { + return plset->getTimeStamp(plink, pstamp); + } else { return S_db_noLSET; - - return plset->getTimeStamp(plink, pstamp); + } } long dbPutLink(struct link *plink, short dbrType, const void *pbuffer, diff --git a/modules/database/src/ioc/db/dbLink.h b/modules/database/src/ioc/db/dbLink.h index c0540271a..384ff8fe4 100644 --- a/modules/database/src/ioc/db/dbLink.h +++ b/modules/database/src/ioc/db/dbLink.h @@ -377,6 +377,15 @@ typedef struct lset { */ long (*getAlarmMsg)(const struct link *plink, epicsEnum16 *status, epicsEnum16 *severity, char *msgbuf, size_t msgbuflen); + + /** @brief Extended version of getTimeStamp + * + * Equivalent of getTimeStamp() and also copy out time tag. + * ptag may be NULL. + * + * @since Added after UNRELEASED + */ + long (*getTimeStampTag)(const struct link *plink, epicsTimeStamp *pstamp, epicsInt32 *ptag); } lset; #define dbGetSevr(link, sevr) \ @@ -428,6 +437,10 @@ DBCORE_API long dbGetAlarmMsg(const struct link *plink, epicsEnum16 *status, #define dbGetAlarmMsg(LINK, STAT, SEVR, BUF, BUFLEN) dbGetAlarmMsg(LINK, STAT, SEVR, BUF, BUFLEN) DBCORE_API long dbGetTimeStamp(const struct link *plink, epicsTimeStamp *pstamp); +/** @since UNRELEASED */ +DBCORE_API long dbGetTimeStampTag(const struct link *plink, + epicsTimeStamp *pstamp, epicsInt32 *ptag); +#define dbGetTimeStampTag(LINK, STAMP, TAG) dbGetTimeStampTag(LINK, STAMP, TAG) DBCORE_API long dbPutLink(struct link *plink, short dbrType, const void *pbuffer, long nRequest); DBCORE_API void dbLinkAsyncComplete(struct link *plink); diff --git a/modules/database/src/ioc/db/recGbl.c b/modules/database/src/ioc/db/recGbl.c index c2cdf2bbf..9f5b90479 100644 --- a/modules/database/src/ioc/db/recGbl.c +++ b/modules/database/src/ioc/db/recGbl.c @@ -304,7 +304,7 @@ void recGblGetTimeStampSimm(void *pvoid, const epicsEnum16 simm, struct link *si if (!dbLinkIsConstant(plink)) { if (plink->flags & DBLINK_FLAG_TSELisTIME) { - if (dbGetTimeStamp(plink, &prec->time)) + if (dbGetTimeStampTag(plink, &prec->time, &prec->utag)) errlogPrintf("recGblGetTimeStamp: dbGetTimeStamp failed for %s.TSEL\n", prec->name); return; diff --git a/modules/database/src/std/link/lnkCalc.c b/modules/database/src/std/link/lnkCalc.c index 7c3eab722..9b8421cb9 100644 --- a/modules/database/src/std/link/lnkCalc.c +++ b/modules/database/src/std/link/lnkCalc.c @@ -67,6 +67,7 @@ typedef struct calc_link { struct link out; double arg[CALCPERFORM_NARGS]; epicsTimeStamp time; + epicsInt32 utag; double val; } calc_link; @@ -534,6 +535,7 @@ static long lnkCalc_getElements(const struct link *plink, long *nelements) struct lcvt { double *pval; epicsTimeStamp *ptime; + epicsInt32 *ptag; }; static long readLocked(struct link *pinp, void *vvt) @@ -543,7 +545,7 @@ static long readLocked(struct link *pinp, void *vvt) long status = dbGetLink(pinp, DBR_DOUBLE, pvt->pval, NULL, &nReq); if (!status && pvt->ptime) - dbGetTimeStamp(pinp, pvt->ptime); + dbGetTimeStampTag(pinp, pvt->ptime, pvt->ptag); return status; } @@ -569,7 +571,7 @@ static long lnkCalc_getValue(struct link *plink, short dbrType, void *pbuffer, long nReq = 1; if (i == clink->tinp) { - struct lcvt vt = {&clink->arg[i], &clink->time}; + struct lcvt vt = {&clink->arg[i], &clink->time, &clink->utag}; status = dbLinkDoLocked(child, readLocked, &vt); if (status == S_db_noLSET) @@ -578,6 +580,7 @@ static long lnkCalc_getValue(struct link *plink, short dbrType, void *pbuffer, if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) { prec->time = clink->time; + prec->utag = clink->utag; } } else @@ -648,7 +651,7 @@ static long lnkCalc_putValue(struct link *plink, short dbrType, long nReq = 1; if (i == clink->tinp) { - struct lcvt vt = {&clink->arg[i], &clink->time}; + struct lcvt vt = {&clink->arg[i], &clink->time, &clink->utag}; status = dbLinkDoLocked(child, readLocked, &vt); if (status == S_db_noLSET) @@ -657,6 +660,7 @@ static long lnkCalc_putValue(struct link *plink, short dbrType, if (dbLinkIsConstant(&prec->tsel) && prec->tse == epicsTimeEventDeviceTime) { prec->time = clink->time; + prec->utag = clink->utag; } } else @@ -750,19 +754,26 @@ static long lnkCalc_getAlarm(const struct link *plink, epicsEnum16 *status, return lnkCalc_getAlarmMsg(plink, status, severity, NULL, 0u); } -static long lnkCalc_getTimestamp(const struct link *plink, epicsTimeStamp *pstamp) +static long lnkCalc_getTimestampTag(const struct link *plink, epicsTimeStamp *pstamp, epicsInt32 *ptag) { calc_link *clink = CONTAINER(plink->value.json.jlink, struct calc_link, jlink); if (clink->tinp >= 0) { *pstamp = clink->time; + if(ptag) + *ptag = clink->utag; return 0; } return -1; } +static long lnkCalc_getTimestamp(const struct link *plink, epicsTimeStamp *pstamp) +{ + return lnkCalc_getTimestampTag(plink, pstamp, NULL); +} + static long doLocked(struct link *plink, dbLinkUserCallback rtn, void *priv) { return rtn(plink, priv); @@ -783,6 +794,7 @@ static lset lnkCalc_lset = { lnkCalc_putValue, NULL, NULL, doLocked, lnkCalc_getAlarmMsg, + lnkCalc_getTimestampTag, }; static jlif lnkCalcIf = { From aad3476c04f760ab153ef20918637558126537db Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 2 Nov 2020 09:39:04 -0800 Subject: [PATCH 099/195] add dbDbLinkTest --- modules/database/test/ioc/db/Makefile | 8 ++ modules/database/test/ioc/db/dbDbLinkTest.c | 136 ++++++++++++++++++ modules/database/test/ioc/db/dbDbLinkTest.db | 6 + .../database/test/ioc/db/epicsRunDbTests.c | 2 + 4 files changed, 152 insertions(+) create mode 100644 modules/database/test/ioc/db/dbDbLinkTest.c create mode 100644 modules/database/test/ioc/db/dbDbLinkTest.db diff --git a/modules/database/test/ioc/db/Makefile b/modules/database/test/ioc/db/Makefile index a34da94bf..664291641 100644 --- a/modules/database/test/ioc/db/Makefile +++ b/modules/database/test/ioc/db/Makefile @@ -117,6 +117,13 @@ testHarness_SRCS += dbCACTest.cpp TESTS += dbCaLinkTest TESTFILES += ../dbCaLinkTest1.db ../dbCaLinkTest2.db ../dbCaLinkTest3.db +TESTPROD_HOST += dbDbLinkTest +dbDbLinkTest_SRCS += dbDbLinkTest.c +dbDbLinkTest_SRCS += dbTestIoc_registerRecordDeviceDriver.cpp +testHarness_SRCS += dbDbLinkTest.c +TESTS += dbDbLinkTest +TESTFILES += ../dbDbLinkTest.db + TESTPROD_HOST += scanIoTest scanIoTest_SRCS += scanIoTest.c scanIoTest_SRCS += dbTestIoc_registerRecordDeviceDriver.cpp @@ -200,6 +207,7 @@ include $(TOP)/configure/RULES arrRecord$(DEP): $(COMMON_DIR)/arrRecord.h dbCaLinkTest$(DEP): $(COMMON_DIR)/xRecord.h $(COMMON_DIR)/arrRecord.h +dbDbLinkTest$(DEP): $(COMMON_DIR)/xRecord.h dbPutLinkTest$(DEP): $(COMMON_DIR)/xRecord.h dbStressLock$(DEP): $(COMMON_DIR)/xRecord.h devx$(DEP): $(COMMON_DIR)/xRecord.h diff --git a/modules/database/test/ioc/db/dbDbLinkTest.c b/modules/database/test/ioc/db/dbDbLinkTest.c new file mode 100644 index 000000000..08f414cec --- /dev/null +++ b/modules/database/test/ioc/db/dbDbLinkTest.c @@ -0,0 +1,136 @@ +/*************************************************************************\ + * Copyright (c) 2020 Michael Davidsaver + * SPDX-License-Identifier: EPICS + * EPICS BASE is distributed subject to a Software License Agreement found + * in file LICENSE that is included with this distribution. + \*************************************************************************/ + +#include + +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include "xRecord.h" + +void dbTestIoc_registerRecordDeviceDriver(struct dbBase *); + +static +void checkTime(void) +{ + epicsTimeStamp stamp; + epicsInt32 tag; + + dbCommon* target = testdbRecordPtr("target"); + dbCommon* src = testdbRecordPtr("src"); + + testDiag("checkTime()"); + + dbScanLock(target); + target->time.secPastEpoch = 0x12345678; + target->time.nsec = 0x9abcdef0; + target->utag = 0xdeadbeef; + dbScanUnlock(target); + + dbScanLock(src); + testOk1(0==dbGetTimeStamp(dbGetDevLink(src), &stamp)); + dbScanUnlock(src); + + testOk1(stamp.secPastEpoch==0x12345678); + testOk1(stamp.nsec==0x9abcdef0); + stamp.secPastEpoch = 0; + stamp.nsec = 0; + + dbScanLock(src); + testOk1(0==dbGetTimeStampTag(dbGetDevLink(src), &stamp, &tag)); + dbScanUnlock(src); + + testOk1(stamp.secPastEpoch==0x12345678); + testOk1(stamp.nsec==0x9abcdef0); + testOk1(tag==0xdeadbeef); +} + +static +void alarmProc(xRecord *prec) +{ + recGblSetSevrMsg(prec, READ_ALARM, MAJOR_ALARM, "a %s", "message"); + prec->val = 0; +} + +static +void checkAlarm(void) +{ + epicsEnum16 stat, sevr; + + xRecord* target = (xRecord*)testdbRecordPtr("target"); + dbCommon* src = testdbRecordPtr("src"); + + char amsg[sizeof(src->amsg)]; + + testDiag("checkAlarm()"); + + dbScanLock((dbCommon*)target); + target->clbk = &alarmProc; + dbProcess((dbCommon*)target); + target->clbk = NULL; + dbScanUnlock((dbCommon*)target); + + dbScanLock(src); + testOk1(0==dbGetAlarm(dbGetDevLink(src), &stat, &sevr)); + dbScanUnlock(src); + + testOk1(stat==READ_ALARM); + testOk1(sevr==MAJOR_ALARM); + stat = sevr = 0; + + dbScanLock(src); + testOk1(0==dbGetAlarmMsg(dbGetDevLink(src), &stat, &sevr, amsg, sizeof(amsg))); + dbScanUnlock(src); + + testOk1(stat==READ_ALARM); + testOk1(sevr==MAJOR_ALARM); + testOk1(strcmp(amsg, "a message")==0); + stat = sevr = 0; + memset(amsg, 0, sizeof(amsg)); + + dbScanLock(src); + testOk1(0==dbGetAlarmMsg(dbGetDevLink(src), &stat, &sevr, amsg, 5)); + dbScanUnlock(src); + + testOk1(stat==READ_ALARM); + testOk1(sevr==MAJOR_ALARM); + testOk1(strcmp(amsg, "a me")==0); +} + +MAIN(dbDbLinkTest) +{ + testPlan(18); + + testdbPrepare(); + + testdbReadDatabase("dbTestIoc.dbd", NULL, NULL); + + dbTestIoc_registerRecordDeviceDriver(pdbbase); + + testdbReadDatabase("dbDbLinkTest.db", NULL, NULL); + + eltc(0); + testIocInitOk(); + eltc(1); + + checkTime(); + checkAlarm(); + + testIocShutdownOk(); + + testdbCleanup(); + + return testDone(); +} diff --git a/modules/database/test/ioc/db/dbDbLinkTest.db b/modules/database/test/ioc/db/dbDbLinkTest.db new file mode 100644 index 000000000..39ce5d8ae --- /dev/null +++ b/modules/database/test/ioc/db/dbDbLinkTest.db @@ -0,0 +1,6 @@ +record(x, "target") { +} + +record(x, "src") { + field(INP, "target.VAL") +} diff --git a/modules/database/test/ioc/db/epicsRunDbTests.c b/modules/database/test/ioc/db/epicsRunDbTests.c index 602b15e05..6c7ce84c9 100644 --- a/modules/database/test/ioc/db/epicsRunDbTests.c +++ b/modules/database/test/ioc/db/epicsRunDbTests.c @@ -30,6 +30,7 @@ int dbLockTest(void); int dbPutLinkTest(void); int dbStaticTest(void); int dbCaLinkTest(void); +int dbDbLinkTest(void); int testDbChannel(void); int chfPluginTest(void); int arrShorthandTest(void); @@ -52,6 +53,7 @@ void epicsRunDbTests(void) runTest(dbPutLinkTest); runTest(dbStaticTest); runTest(dbCaLinkTest); + runTest(dbDbLinkTest); runTest(testDbChannel); runTest(arrShorthandTest); runTest(recGblCheckDeadbandTest); From 633859d7abfd5d61e24351f0922c887aa8f76e96 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 15 Apr 2020 20:26:37 -0700 Subject: [PATCH 100/195] pass amsg/utag through dbGet() options --- modules/database/src/ioc/db/dbAccess.c | 11 ++ modules/database/src/ioc/db/dbAccessDefs.h | 7 +- modules/database/src/ioc/db/dbEvent.c | 3 + modules/database/src/ioc/db/db_field_log.h | 2 + modules/database/test/ioc/db/dbPutGetTest.c | 179 ++++++++++++++++++- modules/database/test/ioc/db/dbPutGetTest.db | 2 + modules/database/test/ioc/db/xRecord.c | 77 +++++++- modules/database/test/ioc/db/xRecord.dbd | 4 + 8 files changed, 281 insertions(+), 4 deletions(-) diff --git a/modules/database/src/ioc/db/dbAccess.c b/modules/database/src/ioc/db/dbAccess.c index 6c418f968..ac4cec958 100644 --- a/modules/database/src/ioc/db/dbAccess.c +++ b/modules/database/src/ioc/db/dbAccess.c @@ -359,6 +359,14 @@ static void getOptions(DBADDR *paddr, char **poriginal, long *options, *pushort++ = pcommon->acks; *pushort++ = pcommon->ackt; pbuffer = (char *)pushort; + if (!pfl || pfl->type == dbfl_type_rec) { + STATIC_ASSERT(sizeof(pcommon->amsg)==sizeof(pfl->amsg)); + strncpy(pbuffer, pcommon->amsg, sizeof(pcommon->amsg)-1); + } else { + strncpy(pbuffer, pfl->amsg,sizeof(pfl->amsg)-1); + } + pbuffer[sizeof(pcommon->amsg)-1] = '\0'; + pbuffer += sizeof(pcommon->amsg); } if( (*options) & DBR_UNITS ) { memset(pbuffer,'\0',dbr_units_size); @@ -386,10 +394,13 @@ static void getOptions(DBADDR *paddr, char **poriginal, long *options, if (!pfl) { *ptime++ = pcommon->time.secPastEpoch; *ptime++ = pcommon->time.nsec; + *ptime++ = pcommon->utag; } else { *ptime++ = pfl->time.secPastEpoch; *ptime++ = pfl->time.nsec; + *ptime++ = pfl->utag; } + *ptime++ = 0; /* padding */ pbuffer = (char *)ptime; } if( (*options) & DBR_ENUM_STRS ) diff --git a/modules/database/src/ioc/db/dbAccessDefs.h b/modules/database/src/ioc/db/dbAccessDefs.h index bcd8d15df..32778451f 100644 --- a/modules/database/src/ioc/db/dbAccessDefs.h +++ b/modules/database/src/ioc/db/dbAccessDefs.h @@ -99,7 +99,8 @@ DBCORE_API extern int dbAccessDebugPUTF; epicsUInt16 status; /* alarm status */\ epicsUInt16 severity; /* alarm severity*/\ epicsUInt16 acks; /* alarm ack severity*/\ - epicsUInt16 ackt; /* Acknowledge transient alarms?*/ + epicsUInt16 ackt; /* Acknowledge transient alarms?*/\ + char amsg[40]; #define DB_UNITS_SIZE 16 #define DBRunits \ char units[DB_UNITS_SIZE]; /* units */ @@ -112,7 +113,9 @@ DBCORE_API extern int dbAccessDebugPUTF; * too late to change now. DBRprecision must be padded to * maintain 8-byte alignment. */ #define DBRtime \ - epicsTimeStamp time; /* time stamp*/ + epicsTimeStamp time; /* time stamp*/\ + epicsInt32 utag;\ + epicsInt32 padTime; #define DBRenumStrs \ epicsUInt32 no_str; /* number of strings*/\ epicsInt32 padenumStrs; /*padding to force 8 byte align*/\ diff --git a/modules/database/src/ioc/db/dbEvent.c b/modules/database/src/ioc/db/dbEvent.c index 6de565236..7342a0852 100644 --- a/modules/database/src/ioc/db/dbEvent.c +++ b/modules/database/src/ioc/db/dbEvent.c @@ -675,7 +675,10 @@ static db_field_log* db_create_field_log (struct dbChannel *chan, int use_val) struct dbCommon *prec = dbChannelRecord(chan); pLog->stat = prec->stat; pLog->sevr = prec->sevr; + strncpy(pLog->amsg, prec->amsg, sizeof(pLog->amsg)-1); + pLog->amsg[sizeof(pLog->amsg)-1] = '\0'; pLog->time = prec->time; + pLog->utag = prec->utag; pLog->field_type = dbChannelFieldType(chan); pLog->field_size = dbChannelFieldSize(chan); pLog->no_elements = dbChannelElements(chan); diff --git a/modules/database/src/ioc/db/db_field_log.h b/modules/database/src/ioc/db/db_field_log.h index f9b7cfbd4..1b759eb20 100644 --- a/modules/database/src/ioc/db/db_field_log.h +++ b/modules/database/src/ioc/db/db_field_log.h @@ -113,8 +113,10 @@ typedef struct db_field_log { unsigned char mask; /* DBE_* mask */ /* the following are used for value and reference types */ epicsTimeStamp time; /* Time stamp */ + epicsInt32 utag; unsigned short stat; /* Alarm Status */ unsigned short sevr; /* Alarm Severity */ + char amsg[40]; short field_type; /* DBF type of data */ short field_size; /* Size of a single element */ long no_elements; /* No of valid array elements */ diff --git a/modules/database/test/ioc/db/dbPutGetTest.c b/modules/database/test/ioc/db/dbPutGetTest.c index 742318e3a..7de087043 100644 --- a/modules/database/test/ioc/db/dbPutGetTest.c +++ b/modules/database/test/ioc/db/dbPutGetTest.c @@ -7,12 +7,184 @@ #include #include +#include #include #include #include +#include +#include #include #include +#include "xRecord.h" + +typedef struct { + DBRstatus + DBRunits + DBRprecision + DBRtime + DBRgrDouble + DBRctrlDouble + DBRalDouble +} dbMetaDouble; + +enum {dbMetaDoubleMask = DBR_STATUS | DBR_UNITS | DBR_PRECISION | DBR_TIME | DBR_GR_DOUBLE | DBR_CTRL_DOUBLE | DBR_AL_DOUBLE}; + +static +void testdbMetaDoubleSizes(void) +{ + dbMetaDouble meta; + size_t pos=0; + + testDiag("dbMetaDouble may not have padding"); +#define testOffset(FLD) do {\ + testOk(offsetof(dbMetaDouble, FLD)==pos, "offset(meta, " #FLD "), %u == %u", (unsigned)offsetof(dbMetaDouble, FLD), (unsigned)pos); \ + pos += sizeof(meta.FLD); \ +}while(0) + + testOffset(status); + testOffset(severity); + testOffset(acks); + testOffset(ackt); + testOffset(amsg); + testOffset(units); + testOffset(precision); + testOffset(time); + testOffset(utag); + testOffset(padTime); + testOffset(upper_disp_limit); + testOffset(lower_disp_limit); + testOffset(upper_ctrl_limit); + testOffset(lower_ctrl_limit); + testOffset(upper_alarm_limit); + testOffset(upper_warning_limit); + testOffset(lower_warning_limit); + testOffset(lower_alarm_limit); +#undef testOffset + testOk(sizeof(dbMetaDouble)==pos, "sizeof(dbMetaDouble), %u == %u", (unsigned)sizeof(dbMetaDouble), (unsigned)pos); +} + +static +void checkDoubleGet(dbChannel *chan, db_field_log* pfl) +{ + dbMetaDouble meta; + long options = (long)dbMetaDoubleMask; + long nReq = 0; + long status; + + status=dbChannelGet(chan, DBF_DOUBLE, &meta, &options, &nReq, pfl); + testOk(status==0, "dbGet OTST : %ld", status); + + testOk1(meta.severity==INVALID_ALARM); + testOk1(meta.status==UDF_ALARM); + testOk1(meta.acks==MAJOR_ALARM); + testOk1(meta.ackt==1); + testOk1(strncmp(meta.amsg, "oops", DB_UNITS_SIZE)==0); + testOk1(meta.time.secPastEpoch==0x12345678); + testOk1(meta.time.nsec==0x90abcdef); + testOk1(meta.utag==0x10203040); + testOk1(meta.precision.dp==0x12345678); + testOk1(strncmp(meta.units, "arbitrary", DB_UNITS_SIZE)==0); +#define limitEq(UL, FL, VAL) testOk(meta.UL ## _ ## FL ## _limit == (VAL), #UL "_" #FL "_limit (%f) == %f", meta.UL ## _ ## FL ## _limit, VAL) + limitEq(lower, disp, 10000000.0-1.0); + limitEq(upper, disp, 10000000.0+1.0); + limitEq(lower, ctrl, 10000000.0-2.0); + limitEq(upper, ctrl, 10000000.0+2.0); + limitEq(lower, alarm, 10000000.0-3.0); + limitEq(lower, warning, 10000000.0-4.0); + limitEq(upper, warning, 10000000.0+4.0); + limitEq(upper, alarm, 10000000.0+3.0); +#undef limitEq + +} + +static +void testdbMetaDoubleGet(void) +{ + xRecord* prec = (xRecord*)testdbRecordPtr("recmeta"); + dbChannel *chan = dbChannelCreate("recmeta.OTST"); + db_field_log *pfl; + evSubscrip evsub; + long status; + dbMetaDouble meta; + + STATIC_ASSERT(sizeof(meta.amsg)==sizeof(prec->amsg)); + STATIC_ASSERT(sizeof(meta.amsg)==sizeof(pfl->amsg)); + + if(!chan) + testAbort("Missing recmeta OTST"); + if((status=dbChannelOpen(chan))!=0) + testAbort("can't open recmeta OTST : %ld", status); + + dbScanLock((dbCommon*)prec); + /* ensure that all meta-data has different non-zero values */ + prec->otst = 10000000.0; + prec->sevr = INVALID_ALARM; + prec->stat = UDF_ALARM; + strcpy(prec->amsg, "oops"); + prec->acks = MAJOR_ALARM; + prec->time.secPastEpoch = 0x12345678; + prec->time.nsec = 0x90abcdef; + prec->utag = 0x10203040; + + testDiag("dbGet directly from record"); + checkDoubleGet(chan, NULL); + + testDiag("dbGet from field log"); + + /* bare minimum init for db_create_event_log() */ + memset(&evsub, 0, sizeof(evsub)); + evsub.chan = chan; + evsub.useValque = 1; + pfl = db_create_event_log(&evsub); + /* spoil things which should now come from field log */ + prec->sevr = 0; + prec->stat = 0; + strcpy(prec->amsg, "invalid"); + prec->time.secPastEpoch = 0xdeadbeef; + prec->time.nsec = 0xdeadbeef; + prec->utag = 0xdeadbeef; + + /* never any filters, so skip pre/post */ + checkDoubleGet(chan, pfl); + db_delete_field_log(pfl); + + dbScanUnlock((dbCommon*)prec); +} + +typedef struct { + DBRstatus + DBRtime + DBRenumStrs +} dbMetaEnum; + +static +void testdbMetaEnumSizes(void) +{ + dbMetaEnum meta; + size_t pos=0; + + testDiag("dbMetaEnum may not have implicit padding"); +#define testOffset(FLD) do {\ + testOk(offsetof(dbMetaEnum, FLD)==pos, "offset(meta, " #FLD "), %u == %u", (unsigned)offsetof(dbMetaEnum, FLD), (unsigned)pos); \ + pos += sizeof(meta.FLD); \ +}while(0) + + testOffset(status); + testOffset(severity); + testOffset(acks); + testOffset(ackt); + testOffset(amsg); + testOffset(time); + testOffset(utag); + testOffset(padTime); + testOffset(no_str); + testOffset(padenumStrs); + testOffset(strs); +#undef testOffset + testOk(sizeof(dbMetaEnum)==pos, "sizeof(dbMetaEnum), %u == %u", (unsigned)sizeof(dbMetaEnum), (unsigned)pos); +} + static void testdbGetStringEqual(const char *pv, const char *expected) { @@ -143,9 +315,12 @@ void dbTestIoc_registerRecordDeviceDriver(struct dbBase *); MAIN(dbPutGet) { - testPlan(44); + testPlan(113); testdbPrepare(); + testdbMetaDoubleSizes(); + testdbMetaEnumSizes(); + testdbReadDatabase("dbTestIoc.dbd", NULL, NULL); dbTestIoc_registerRecordDeviceDriver(pdbbase); testdbReadDatabase("dbPutGetTest.db", NULL, NULL); @@ -158,6 +333,8 @@ MAIN(dbPutGet) testIocInitOk(); eltc(1); + testdbMetaDoubleGet(); + testLongLink(); testLongAttr(); testLongField(); diff --git a/modules/database/test/ioc/db/dbPutGetTest.db b/modules/database/test/ioc/db/dbPutGetTest.db index 816dc73f0..68485e4ba 100644 --- a/modules/database/test/ioc/db/dbPutGetTest.db +++ b/modules/database/test/ioc/db/dbPutGetTest.db @@ -44,3 +44,5 @@ record(arr, "arr") { field(FTVL, "ULONG") field(NELM, "10") } + +record(x, "recmeta") {} diff --git a/modules/database/test/ioc/db/xRecord.c b/modules/database/test/ioc/db/xRecord.c index 7cbcf1508..83ca9b15c 100644 --- a/modules/database/test/ioc/db/xRecord.c +++ b/modules/database/test/ioc/db/xRecord.c @@ -76,7 +76,82 @@ static long process(struct dbCommon *pcommon) return ret; } +long get_units(struct dbAddr *paddr, char *units) +{ + if(dbGetFieldIndex(paddr)==xRecordOTST) { + strncpy(units, "arbitrary", DB_UNITS_SIZE); + } + return 0; +} + +long get_precision(const struct dbAddr *paddr, long *precision) +{ + if(dbGetFieldIndex(paddr)==xRecordOTST) { + *precision = 0x12345678; + } + return 0; +} + +long get_graphic_double(struct dbAddr *paddr, struct dbr_grDouble *p) +{ + xRecord *prec = (xRecord *)paddr->precord; + if(dbGetFieldIndex(paddr)==xRecordOTST) { + p->lower_disp_limit = prec->otst-1.0; + p->upper_disp_limit = prec->otst+1.0; + } + return 0; +} + +long get_control_double(struct dbAddr *paddr, struct dbr_ctrlDouble *p) +{ + xRecord *prec = (xRecord *)paddr->precord; + if(dbGetFieldIndex(paddr)==xRecordOTST) { + p->lower_ctrl_limit = prec->otst-2.0; + p->upper_ctrl_limit = prec->otst+2.0; + } + return 0; +} +long get_alarm_double(struct dbAddr *paddr, struct dbr_alDouble *p) +{ + xRecord *prec = (xRecord *)paddr->precord; + if(dbGetFieldIndex(paddr)==xRecordOTST) { + p->lower_alarm_limit = prec->otst-3.0; + p->lower_warning_limit = prec->otst-4.0; + p->upper_warning_limit = prec->otst+4.0; + p->upper_alarm_limit = prec->otst+3.0; + } + return 0; +} + +#define report NULL +#define initialize NULL +#define special NULL +#define get_value NULL +#define cvt_dbaddr NULL +#define get_array_info NULL +#define put_array_info NULL +#define get_enum_str NULL +#define get_enum_strs NULL +#define put_enum_str NULL + static rset xRSET = { - RSETNUMBER, NULL, NULL, init_record, process + RSETNUMBER, + report, + initialize, + init_record, + process, + special, + get_value, + cvt_dbaddr, + get_array_info, + put_array_info, + get_units, + get_precision, + get_enum_str, + get_enum_strs, + put_enum_str, + get_graphic_double, + get_control_double, + get_alarm_double }; epicsExportAddress(rset,xRSET); diff --git a/modules/database/test/ioc/db/xRecord.dbd b/modules/database/test/ioc/db/xRecord.dbd index 25013c042..13fcb3f3e 100644 --- a/modules/database/test/ioc/db/xRecord.dbd +++ b/modules/database/test/ioc/db/xRecord.dbd @@ -46,4 +46,8 @@ recordtype(x) { special(SPC_NOMOD) extra("void (*clbk)(struct xRecord*)") } + field(OTST, DBF_DOUBLE) { + prompt("dbGet() options test") + special(SPC_NOMOD) + } } From 1ceb26eeb848843b81c5366175cc1a9810e05030 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 20 Apr 2020 12:13:28 -0700 Subject: [PATCH 101/195] add utag filter --- modules/database/src/std/filters/Makefile | 1 + .../database/src/std/filters/filters.dbd.pod | 2 + modules/database/src/std/filters/utag.c | 99 +++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 modules/database/src/std/filters/utag.c diff --git a/modules/database/src/std/filters/Makefile b/modules/database/src/std/filters/Makefile index ee6a0ae68..b02999403 100644 --- a/modules/database/src/std/filters/Makefile +++ b/modules/database/src/std/filters/Makefile @@ -16,6 +16,7 @@ dbRecStd_SRCS += dbnd.c dbRecStd_SRCS += arr.c dbRecStd_SRCS += sync.c dbRecStd_SRCS += decimate.c +dbRecStd_SRCS += utag.c HTMLS += filters.html diff --git a/modules/database/src/std/filters/filters.dbd.pod b/modules/database/src/std/filters/filters.dbd.pod index 27e356f83..ae43b3c2f 100644 --- a/modules/database/src/std/filters/filters.dbd.pod +++ b/modules/database/src/std/filters/filters.dbd.pod @@ -285,3 +285,5 @@ once every minute: ... =cut + +registrar(utagInitialize) diff --git a/modules/database/src/std/filters/utag.c b/modules/database/src/std/filters/utag.c new file mode 100644 index 000000000..4f19947d0 --- /dev/null +++ b/modules/database/src/std/filters/utag.c @@ -0,0 +1,99 @@ +/*************************************************************************\ +* Copyright (c) 2020 Michael Davidsaver +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +typedef struct { + epicsInt32 mask, value; + int first; +} utagPvt; + +static const +chfPluginArgDef opts[] = { + chfInt32(utagPvt, mask, "M", 0, 1), + chfInt32(utagPvt, value, "V", 0, 1), + chfPluginArgEnd +}; + +static void * allocPvt(void) +{ + utagPvt *pvt; + pvt = calloc(1, sizeof(utagPvt)); + pvt->mask = 0xffffffff; + return pvt; +} + +static void freePvt(void *pvt) +{ + free(pvt); +} + +static int parse_ok(void *raw) +{ + utagPvt *pvt = (utagPvt*)raw; + pvt->first = 1; + return 0; +} + +static db_field_log* filter(void* raw, dbChannel *chan, db_field_log *pfl) +{ + utagPvt *pvt = (utagPvt*)raw; + epicsInt32 utag = pfl->type==dbfl_type_rec ? dbChannelRecord(chan)->utag : pfl->utag; + int drop = (utag&pvt->mask)!=pvt->value; + + if(pfl->ctx!=dbfl_context_event || pfl->mask&DBE_PROPERTY) { + /* never drop for reads, or property events */ + + } else if(pvt->first) { + /* never drop first */ + pvt->first = 0; + + } else if(drop) { + db_delete_field_log(pfl); + pfl = NULL; + } + + return pfl; +} + +static void channelRegisterPre(dbChannel *chan, void *pvt, + chPostEventFunc **cb_out, void **arg_out, db_field_log *probe) +{ + *cb_out = filter; + *arg_out = pvt; +} + +static void channel_report(dbChannel *chan, void *raw, int level, const unsigned short indent) +{ + utagPvt *pvt = (utagPvt*)raw; + printf("%*sutag : mask=0x%08x value=0x%08x\n", indent, "", (epicsUInt32)pvt->mask, (epicsUInt32)pvt->value); +} + +static const +chfPluginIf pif = { + allocPvt, + freePvt, + NULL, /* parse_error */ + parse_ok, /* parse_ok */ + NULL, /* channel_open */ + channelRegisterPre, + NULL, /* channelRegisterPost */ + channel_report, + NULL, /* channel_close */ +}; + +static +void utagInitialize(void) +{ + chfPluginRegister("utag", &pif, opts); +} +epicsExportRegistrar(utagInitialize); From b94afaa0453b0b86a0d438e87758fb9a291c4416 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 2 Dec 2020 13:57:40 -0800 Subject: [PATCH 102/195] UTAG uint64 --- modules/database/src/ioc/db/dbAccess.c | 12 ++++++++---- modules/database/src/ioc/db/dbAccessDefs.h | 3 +-- modules/database/src/ioc/db/dbCommon.dbd.pod | 2 +- modules/database/src/ioc/db/dbDbLink.c | 2 +- modules/database/src/ioc/db/dbLink.c | 2 +- modules/database/src/ioc/db/dbLink.h | 4 ++-- modules/database/src/ioc/db/db_field_log.h | 2 +- modules/database/src/std/filters/utag.c | 2 +- modules/database/src/std/link/lnkCalc.c | 6 +++--- modules/database/test/ioc/db/dbDbLinkTest.c | 2 +- modules/database/test/ioc/db/dbPutGetTest.c | 4 +--- modules/libcom/src/osi/epicsTime.h | 4 ++++ 12 files changed, 25 insertions(+), 20 deletions(-) diff --git a/modules/database/src/ioc/db/dbAccess.c b/modules/database/src/ioc/db/dbAccess.c index ac4cec958..28c8a2b61 100644 --- a/modules/database/src/ioc/db/dbAccess.c +++ b/modules/database/src/ioc/db/dbAccess.c @@ -390,18 +390,22 @@ static void getOptions(DBADDR *paddr, char **poriginal, long *options, } if( (*options) & DBR_TIME ) { epicsUInt32 *ptime = (epicsUInt32 *)pbuffer; + epicsUInt64 *ptime64; if (!pfl) { *ptime++ = pcommon->time.secPastEpoch; *ptime++ = pcommon->time.nsec; - *ptime++ = pcommon->utag; } else { *ptime++ = pfl->time.secPastEpoch; *ptime++ = pfl->time.nsec; - *ptime++ = pfl->utag; } - *ptime++ = 0; /* padding */ - pbuffer = (char *)ptime; + ptime64 = (epicsUInt64*)ptime; + if (!pfl || pfl->type == dbfl_type_rec) { + *ptime64++ = pcommon->utag; + } else { + *ptime64++ = pfl->utag; + } + pbuffer = (char *)ptime64; } if( (*options) & DBR_ENUM_STRS ) get_enum_strs(paddr, &pbuffer, prset, options); diff --git a/modules/database/src/ioc/db/dbAccessDefs.h b/modules/database/src/ioc/db/dbAccessDefs.h index 32778451f..bc0ef1f02 100644 --- a/modules/database/src/ioc/db/dbAccessDefs.h +++ b/modules/database/src/ioc/db/dbAccessDefs.h @@ -114,8 +114,7 @@ DBCORE_API extern int dbAccessDebugPUTF; * maintain 8-byte alignment. */ #define DBRtime \ epicsTimeStamp time; /* time stamp*/\ - epicsInt32 utag;\ - epicsInt32 padTime; + epicsUTag utag; #define DBRenumStrs \ epicsUInt32 no_str; /* number of strings*/\ epicsInt32 padenumStrs; /*padding to force 8 byte align*/\ diff --git a/modules/database/src/ioc/db/dbCommon.dbd.pod b/modules/database/src/ioc/db/dbCommon.dbd.pod index 509982cfc..5ad4627c5 100644 --- a/modules/database/src/ioc/db/dbCommon.dbd.pod +++ b/modules/database/src/ioc/db/dbCommon.dbd.pod @@ -524,7 +524,7 @@ field which is then used to acquire a timestamp. interest(2) extra("epicsTimeStamp time") } - field(UTAG,DBF_LONG) { + field(UTAG,DBF_UINT64) { prompt("Time Tag") special(SPC_NOMOD) interest(3) diff --git a/modules/database/src/ioc/db/dbDbLink.c b/modules/database/src/ioc/db/dbDbLink.c index 442e9f48d..db7f67cb2 100644 --- a/modules/database/src/ioc/db/dbDbLink.c +++ b/modules/database/src/ioc/db/dbDbLink.c @@ -359,7 +359,7 @@ static long dbDbGetAlarm(const struct link *plink, epicsEnum16 *status, return dbDbGetAlarmMsg(plink, status, severity, NULL, 0u); } -static long dbDbGetTimeStampTag(const struct link *plink, epicsTimeStamp *pstamp, epicsInt32 *ptag) +static long dbDbGetTimeStampTag(const struct link *plink, epicsTimeStamp *pstamp, epicsUTag *ptag) { dbChannel *chan = linkChannel(plink); dbCommon *precord = dbChannelRecord(chan); diff --git a/modules/database/src/ioc/db/dbLink.c b/modules/database/src/ioc/db/dbLink.c index 5e13c4a4e..c9f9137ca 100644 --- a/modules/database/src/ioc/db/dbLink.c +++ b/modules/database/src/ioc/db/dbLink.c @@ -427,7 +427,7 @@ long dbGetTimeStamp(const struct link *plink, epicsTimeStamp *pstamp) } long dbGetTimeStampTag(const struct link *plink, - epicsTimeStamp *pstamp, epicsInt32 *ptag) + epicsTimeStamp *pstamp, epicsUTag *ptag) { lset *plset = plink->lset; diff --git a/modules/database/src/ioc/db/dbLink.h b/modules/database/src/ioc/db/dbLink.h index 384ff8fe4..6bab6d993 100644 --- a/modules/database/src/ioc/db/dbLink.h +++ b/modules/database/src/ioc/db/dbLink.h @@ -385,7 +385,7 @@ typedef struct lset { * * @since Added after UNRELEASED */ - long (*getTimeStampTag)(const struct link *plink, epicsTimeStamp *pstamp, epicsInt32 *ptag); + long (*getTimeStampTag)(const struct link *plink, epicsTimeStamp *pstamp, epicsUTag *ptag); } lset; #define dbGetSevr(link, sevr) \ @@ -439,7 +439,7 @@ DBCORE_API long dbGetTimeStamp(const struct link *plink, epicsTimeStamp *pstamp); /** @since UNRELEASED */ DBCORE_API long dbGetTimeStampTag(const struct link *plink, - epicsTimeStamp *pstamp, epicsInt32 *ptag); + epicsTimeStamp *pstamp, epicsUTag *ptag); #define dbGetTimeStampTag(LINK, STAMP, TAG) dbGetTimeStampTag(LINK, STAMP, TAG) DBCORE_API long dbPutLink(struct link *plink, short dbrType, const void *pbuffer, long nRequest); diff --git a/modules/database/src/ioc/db/db_field_log.h b/modules/database/src/ioc/db/db_field_log.h index 1b759eb20..b9deb6fe9 100644 --- a/modules/database/src/ioc/db/db_field_log.h +++ b/modules/database/src/ioc/db/db_field_log.h @@ -113,7 +113,7 @@ typedef struct db_field_log { unsigned char mask; /* DBE_* mask */ /* the following are used for value and reference types */ epicsTimeStamp time; /* Time stamp */ - epicsInt32 utag; + epicsUTag utag; unsigned short stat; /* Alarm Status */ unsigned short sevr; /* Alarm Severity */ char amsg[40]; diff --git a/modules/database/src/std/filters/utag.c b/modules/database/src/std/filters/utag.c index 4f19947d0..21faa097c 100644 --- a/modules/database/src/std/filters/utag.c +++ b/modules/database/src/std/filters/utag.c @@ -47,7 +47,7 @@ static int parse_ok(void *raw) static db_field_log* filter(void* raw, dbChannel *chan, db_field_log *pfl) { utagPvt *pvt = (utagPvt*)raw; - epicsInt32 utag = pfl->type==dbfl_type_rec ? dbChannelRecord(chan)->utag : pfl->utag; + epicsUTag utag = pfl->type==dbfl_type_rec ? dbChannelRecord(chan)->utag : pfl->utag; int drop = (utag&pvt->mask)!=pvt->value; if(pfl->ctx!=dbfl_context_event || pfl->mask&DBE_PROPERTY) { diff --git a/modules/database/src/std/link/lnkCalc.c b/modules/database/src/std/link/lnkCalc.c index 9b8421cb9..01eff15f4 100644 --- a/modules/database/src/std/link/lnkCalc.c +++ b/modules/database/src/std/link/lnkCalc.c @@ -67,7 +67,7 @@ typedef struct calc_link { struct link out; double arg[CALCPERFORM_NARGS]; epicsTimeStamp time; - epicsInt32 utag; + epicsUTag utag; double val; } calc_link; @@ -535,7 +535,7 @@ static long lnkCalc_getElements(const struct link *plink, long *nelements) struct lcvt { double *pval; epicsTimeStamp *ptime; - epicsInt32 *ptag; + epicsUTag *ptag; }; static long readLocked(struct link *pinp, void *vvt) @@ -754,7 +754,7 @@ static long lnkCalc_getAlarm(const struct link *plink, epicsEnum16 *status, return lnkCalc_getAlarmMsg(plink, status, severity, NULL, 0u); } -static long lnkCalc_getTimestampTag(const struct link *plink, epicsTimeStamp *pstamp, epicsInt32 *ptag) +static long lnkCalc_getTimestampTag(const struct link *plink, epicsTimeStamp *pstamp, epicsUTag *ptag) { calc_link *clink = CONTAINER(plink->value.json.jlink, struct calc_link, jlink); diff --git a/modules/database/test/ioc/db/dbDbLinkTest.c b/modules/database/test/ioc/db/dbDbLinkTest.c index 08f414cec..489df4daf 100644 --- a/modules/database/test/ioc/db/dbDbLinkTest.c +++ b/modules/database/test/ioc/db/dbDbLinkTest.c @@ -26,7 +26,7 @@ static void checkTime(void) { epicsTimeStamp stamp; - epicsInt32 tag; + epicsUTag tag; dbCommon* target = testdbRecordPtr("target"); dbCommon* src = testdbRecordPtr("src"); diff --git a/modules/database/test/ioc/db/dbPutGetTest.c b/modules/database/test/ioc/db/dbPutGetTest.c index 7de087043..2968f388b 100644 --- a/modules/database/test/ioc/db/dbPutGetTest.c +++ b/modules/database/test/ioc/db/dbPutGetTest.c @@ -51,7 +51,6 @@ void testdbMetaDoubleSizes(void) testOffset(precision); testOffset(time); testOffset(utag); - testOffset(padTime); testOffset(upper_disp_limit); testOffset(lower_disp_limit); testOffset(upper_ctrl_limit); @@ -177,7 +176,6 @@ void testdbMetaEnumSizes(void) testOffset(amsg); testOffset(time); testOffset(utag); - testOffset(padTime); testOffset(no_str); testOffset(padenumStrs); testOffset(strs); @@ -315,7 +313,7 @@ void dbTestIoc_registerRecordDeviceDriver(struct dbBase *); MAIN(dbPutGet) { - testPlan(113); + testPlan(111); testdbPrepare(); testdbMetaDoubleSizes(); diff --git a/modules/libcom/src/osi/epicsTime.h b/modules/libcom/src/osi/epicsTime.h index 0c3587fef..090fb5c48 100644 --- a/modules/libcom/src/osi/epicsTime.h +++ b/modules/libcom/src/osi/epicsTime.h @@ -36,6 +36,10 @@ typedef struct epicsTimeStamp { epicsUInt32 nsec; /**< \brief nanoseconds within second */ } epicsTimeStamp; +/** \brief Type of UTAG field (dbCommon::utag) + */ +typedef epicsUInt64 epicsUTag; + /** \brief Old time-stamp data type, deprecated. * \deprecated TS_STAMP was provided for compatibility with Base-3.13 code. * It will be removed in some future release of EPICS 7. From bd3ecf1cbc635efe74723329336262b97a4f40f3 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sat, 6 Feb 2021 10:36:42 -0800 Subject: [PATCH 103/195] Split out amsg/utag options through dbGet() --- modules/database/src/ioc/db/dbAccess.c | 14 ++++++---- modules/database/src/ioc/db/dbAccessDefs.h | 31 ++++++++++++--------- modules/database/test/ioc/db/dbPutGetTest.c | 6 +++- 3 files changed, 32 insertions(+), 19 deletions(-) diff --git a/modules/database/src/ioc/db/dbAccess.c b/modules/database/src/ioc/db/dbAccess.c index 28c8a2b61..65deba6d6 100644 --- a/modules/database/src/ioc/db/dbAccess.c +++ b/modules/database/src/ioc/db/dbAccess.c @@ -359,6 +359,8 @@ static void getOptions(DBADDR *paddr, char **poriginal, long *options, *pushort++ = pcommon->acks; *pushort++ = pcommon->ackt; pbuffer = (char *)pushort; + } + if( (*options) & DBR_AMSG ) { if (!pfl || pfl->type == dbfl_type_rec) { STATIC_ASSERT(sizeof(pcommon->amsg)==sizeof(pfl->amsg)); strncpy(pbuffer, pcommon->amsg, sizeof(pcommon->amsg)-1); @@ -390,7 +392,6 @@ static void getOptions(DBADDR *paddr, char **poriginal, long *options, } if( (*options) & DBR_TIME ) { epicsUInt32 *ptime = (epicsUInt32 *)pbuffer; - epicsUInt64 *ptime64; if (!pfl) { *ptime++ = pcommon->time.secPastEpoch; @@ -399,13 +400,16 @@ static void getOptions(DBADDR *paddr, char **poriginal, long *options, *ptime++ = pfl->time.secPastEpoch; *ptime++ = pfl->time.nsec; } - ptime64 = (epicsUInt64*)ptime; + pbuffer = (char *)ptime; + } + if( (*options) & DBR_UTAG ) { + epicsUInt64 *ptag = (epicsUInt64*)pbuffer; if (!pfl || pfl->type == dbfl_type_rec) { - *ptime64++ = pcommon->utag; + *ptag++ = pcommon->utag; } else { - *ptime64++ = pfl->utag; + *ptag++ = pfl->utag; } - pbuffer = (char *)ptime64; + pbuffer = (char *)ptag; } if( (*options) & DBR_ENUM_STRS ) get_enum_strs(paddr, &pbuffer, prset, options); diff --git a/modules/database/src/ioc/db/dbAccessDefs.h b/modules/database/src/ioc/db/dbAccessDefs.h index bc0ef1f02..771084170 100644 --- a/modules/database/src/ioc/db/dbAccessDefs.h +++ b/modules/database/src/ioc/db/dbAccessDefs.h @@ -33,16 +33,18 @@ DBCORE_API extern int dbAccessDebugPUTF; /* The database field and request types are defined in dbFldTypes.h*/ /* Data Base Request Options */ #define DBR_STATUS 0x00000001 -#define DBR_UNITS 0x00000002 -#define DBR_PRECISION 0x00000004 -#define DBR_TIME 0x00000008 -#define DBR_ENUM_STRS 0x00000010 -#define DBR_GR_LONG 0x00000020 -#define DBR_GR_DOUBLE 0x00000040 -#define DBR_CTRL_LONG 0x00000080 -#define DBR_CTRL_DOUBLE 0x00000100 -#define DBR_AL_LONG 0x00000200 -#define DBR_AL_DOUBLE 0x00000400 +#define DBR_AMSG 0x00000002 +#define DBR_UNITS 0x00000004 +#define DBR_PRECISION 0x00000008 +#define DBR_TIME 0x00000010 +#define DBR_UTAG 0x00000020 +#define DBR_ENUM_STRS 0x00000040 +#define DBR_GR_LONG 0x00000080 +#define DBR_GR_DOUBLE 0x00000100 +#define DBR_CTRL_LONG 0x00000200 +#define DBR_CTRL_DOUBLE 0x00000400 +#define DBR_AL_LONG 0x00000800 +#define DBR_AL_DOUBLE 0x00001000 /********************************************************************** * The next page contains macros for defining requests. @@ -99,8 +101,10 @@ DBCORE_API extern int dbAccessDebugPUTF; epicsUInt16 status; /* alarm status */\ epicsUInt16 severity; /* alarm severity*/\ epicsUInt16 acks; /* alarm ack severity*/\ - epicsUInt16 ackt; /* Acknowledge transient alarms?*/\ - char amsg[40]; + epicsUInt16 ackt; /* Acknowledge transient alarms?*/ +#define DB_AMSG_SIZE 40 +#define DBRamsg \ + char amsg[DB_AMSG_SIZE]; #define DB_UNITS_SIZE 16 #define DBRunits \ char units[DB_UNITS_SIZE]; /* units */ @@ -113,7 +117,8 @@ DBCORE_API extern int dbAccessDebugPUTF; * too late to change now. DBRprecision must be padded to * maintain 8-byte alignment. */ #define DBRtime \ - epicsTimeStamp time; /* time stamp*/\ + epicsTimeStamp time; /* time stamp*/ +#define DBRutag \ epicsUTag utag; #define DBRenumStrs \ epicsUInt32 no_str; /* number of strings*/\ diff --git a/modules/database/test/ioc/db/dbPutGetTest.c b/modules/database/test/ioc/db/dbPutGetTest.c index 2968f388b..e1492a5a9 100644 --- a/modules/database/test/ioc/db/dbPutGetTest.c +++ b/modules/database/test/ioc/db/dbPutGetTest.c @@ -20,15 +20,17 @@ typedef struct { DBRstatus + DBRamsg DBRunits DBRprecision DBRtime + DBRutag DBRgrDouble DBRctrlDouble DBRalDouble } dbMetaDouble; -enum {dbMetaDoubleMask = DBR_STATUS | DBR_UNITS | DBR_PRECISION | DBR_TIME | DBR_GR_DOUBLE | DBR_CTRL_DOUBLE | DBR_AL_DOUBLE}; +enum {dbMetaDoubleMask = DBR_STATUS | DBR_AMSG | DBR_UNITS | DBR_PRECISION | DBR_TIME | DBR_UTAG | DBR_GR_DOUBLE | DBR_CTRL_DOUBLE | DBR_AL_DOUBLE}; static void testdbMetaDoubleSizes(void) @@ -153,7 +155,9 @@ void testdbMetaDoubleGet(void) typedef struct { DBRstatus + DBRamsg DBRtime + DBRutag DBRenumStrs } dbMetaEnum; From f69b9384015622fe9d33a129464532061a6150ba Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 8 Mar 2021 14:28:15 -0800 Subject: [PATCH 104/195] dbfl_type_rec goes away --- modules/database/src/ioc/db/dbAccess.c | 4 ++-- modules/database/src/std/filters/utag.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/database/src/ioc/db/dbAccess.c b/modules/database/src/ioc/db/dbAccess.c index 65deba6d6..91093b546 100644 --- a/modules/database/src/ioc/db/dbAccess.c +++ b/modules/database/src/ioc/db/dbAccess.c @@ -361,7 +361,7 @@ static void getOptions(DBADDR *paddr, char **poriginal, long *options, pbuffer = (char *)pushort; } if( (*options) & DBR_AMSG ) { - if (!pfl || pfl->type == dbfl_type_rec) { + if (!pfl) { STATIC_ASSERT(sizeof(pcommon->amsg)==sizeof(pfl->amsg)); strncpy(pbuffer, pcommon->amsg, sizeof(pcommon->amsg)-1); } else { @@ -404,7 +404,7 @@ static void getOptions(DBADDR *paddr, char **poriginal, long *options, } if( (*options) & DBR_UTAG ) { epicsUInt64 *ptag = (epicsUInt64*)pbuffer; - if (!pfl || pfl->type == dbfl_type_rec) { + if (!pfl) { *ptag++ = pcommon->utag; } else { *ptag++ = pfl->utag; diff --git a/modules/database/src/std/filters/utag.c b/modules/database/src/std/filters/utag.c index 21faa097c..b17f3e8a0 100644 --- a/modules/database/src/std/filters/utag.c +++ b/modules/database/src/std/filters/utag.c @@ -47,7 +47,7 @@ static int parse_ok(void *raw) static db_field_log* filter(void* raw, dbChannel *chan, db_field_log *pfl) { utagPvt *pvt = (utagPvt*)raw; - epicsUTag utag = pfl->type==dbfl_type_rec ? dbChannelRecord(chan)->utag : pfl->utag; + epicsUTag utag = pfl->utag; int drop = (utag&pvt->mask)!=pvt->value; if(pfl->ctx!=dbfl_context_event || pfl->mask&DBE_PROPERTY) { From 3f4432b7bd1af4f31edfb778520598c1ea6d3fe3 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 8 Mar 2021 21:17:03 -0800 Subject: [PATCH 105/195] review cleanup --- modules/database/src/ioc/db/dbDbLink.c | 13 +---------- modules/database/src/ioc/db/dbLink.c | 15 ++---------- modules/database/src/ioc/db/dbLink.h | 4 +--- .../database/src/std/filters/filters.dbd.pod | 23 +++++++++++++++++++ modules/database/src/std/link/lnkCalc.c | 13 +---------- 5 files changed, 28 insertions(+), 40 deletions(-) diff --git a/modules/database/src/ioc/db/dbDbLink.c b/modules/database/src/ioc/db/dbDbLink.c index db7f67cb2..f8cfd8b5e 100644 --- a/modules/database/src/ioc/db/dbDbLink.c +++ b/modules/database/src/ioc/db/dbDbLink.c @@ -353,12 +353,6 @@ static long dbDbGetAlarmMsg(const struct link *plink, epicsEnum16 *status, return 0; } -static long dbDbGetAlarm(const struct link *plink, epicsEnum16 *status, - epicsEnum16 *severity) -{ - return dbDbGetAlarmMsg(plink, status, severity, NULL, 0u); -} - static long dbDbGetTimeStampTag(const struct link *plink, epicsTimeStamp *pstamp, epicsUTag *ptag) { dbChannel *chan = linkChannel(plink); @@ -369,11 +363,6 @@ static long dbDbGetTimeStampTag(const struct link *plink, epicsTimeStamp *pstamp return 0; } -static long dbDbGetTimeStamp(const struct link *plink, epicsTimeStamp *pstamp) -{ - return dbDbGetTimeStampTag(plink, pstamp, NULL); -} - static long dbDbPutValue(struct link *plink, short dbrType, const void *pbuffer, long nRequest) { @@ -418,7 +407,7 @@ static lset dbDb_lset = { dbDbGetValue, dbDbGetControlLimits, dbDbGetGraphicLimits, dbDbGetAlarmLimits, dbDbGetPrecision, dbDbGetUnits, - dbDbGetAlarm, dbDbGetTimeStamp, + NULL, NULL, dbDbPutValue, NULL, dbDbScanFwdLink, doLocked, dbDbGetAlarmMsg, diff --git a/modules/database/src/ioc/db/dbLink.c b/modules/database/src/ioc/db/dbLink.c index c9f9137ca..f5d286447 100644 --- a/modules/database/src/ioc/db/dbLink.c +++ b/modules/database/src/ioc/db/dbLink.c @@ -316,19 +316,8 @@ long dbTryGetLink(struct link *plink, short dbrType, void *pbuffer, static void setLinkAlarm(struct link* plink) { - struct dbCommon *precord = plink->precord; - dbRecordType *rdes = precord->rdes; - const char* amsg = NULL; - short i; - - for(i=0; ino_links; i++) { - dbFldDes *fdes = rdes->papFldDes[rdes->link_ind[i]]; - if((char*)plink - (char*)precord == fdes->offset) { - amsg = fdes->name; - } - } - - recGblSetSevrMsg(precord, LINK_ALARM, INVALID_ALARM, "field %s", amsg); + recGblSetSevrMsg(plink->precord, LINK_ALARM, INVALID_ALARM, + "field %s", dbLinkFieldName(plink)); } long dbGetLink(struct link *plink, short dbrType, void *pbuffer, diff --git a/modules/database/src/ioc/db/dbLink.h b/modules/database/src/ioc/db/dbLink.h index 6bab6d993..1933952b9 100644 --- a/modules/database/src/ioc/db/dbLink.h +++ b/modules/database/src/ioc/db/dbLink.h @@ -282,8 +282,6 @@ typedef struct lset { * @param status where to put the alarm status (or NULL) * @param severity where to put the severity (or NULL) * @returns status value - * - * @note Link types which provide getAlarm should also provided getAlarmMsg(). */ long (*getAlarm)(const struct link *plink, epicsEnum16 *status, epicsEnum16 *severity); @@ -368,7 +366,7 @@ typedef struct lset { * * Equivalent of getAlarm() and also copy out alarm message string. * The msgbuf argument may be NULL and/or msgbuflen==0, in which case - * the call must be the same as a call to getAlarm(). + * the effect must be the same as a call to getAlarm(). * * Implementations must write a trailing nil to msgbuf whenever * @code msgbuf!=NULL && msgbuflen>0 @endcode . diff --git a/modules/database/src/std/filters/filters.dbd.pod b/modules/database/src/std/filters/filters.dbd.pod index ae43b3c2f..7b3146609 100644 --- a/modules/database/src/std/filters/filters.dbd.pod +++ b/modules/database/src/std/filters/filters.dbd.pod @@ -16,6 +16,8 @@ The following filters are available in this release: =item * L +=item * L + =back =head2 Using Filters @@ -287,3 +289,24 @@ once every minute: =cut registrar(utagInitialize) + +=head3 UTag Filter C<"utag"> + +This filter applies a test UTAG&M==V to the value taken from the UTAG record field +and drops those updates which evaluate as false. + +=head4 Parameters + +=over + +=item Mask C<"M"> + +Bit mask. + +=item Value C<"V"> + +Required value. + +=back + +=cut diff --git a/modules/database/src/std/link/lnkCalc.c b/modules/database/src/std/link/lnkCalc.c index 01eff15f4..96a12f128 100644 --- a/modules/database/src/std/link/lnkCalc.c +++ b/modules/database/src/std/link/lnkCalc.c @@ -748,12 +748,6 @@ static long lnkCalc_getAlarmMsg(const struct link *plink, epicsEnum16 *status, return 0; } -static long lnkCalc_getAlarm(const struct link *plink, epicsEnum16 *status, - epicsEnum16 *severity) -{ - return lnkCalc_getAlarmMsg(plink, status, severity, NULL, 0u); -} - static long lnkCalc_getTimestampTag(const struct link *plink, epicsTimeStamp *pstamp, epicsUTag *ptag) { calc_link *clink = CONTAINER(plink->value.json.jlink, @@ -769,11 +763,6 @@ static long lnkCalc_getTimestampTag(const struct link *plink, epicsTimeStamp *ps return -1; } -static long lnkCalc_getTimestamp(const struct link *plink, epicsTimeStamp *pstamp) -{ - return lnkCalc_getTimestampTag(plink, pstamp, NULL); -} - static long doLocked(struct link *plink, dbLinkUserCallback rtn, void *priv) { return rtn(plink, priv); @@ -790,7 +779,7 @@ static lset lnkCalc_lset = { lnkCalc_getValue, NULL, NULL, NULL, lnkCalc_getPrecision, lnkCalc_getUnits, - lnkCalc_getAlarm, lnkCalc_getTimestamp, + NULL, NULL, lnkCalc_putValue, NULL, NULL, doLocked, lnkCalc_getAlarmMsg, From 0edf986c31bb71ab7fcad3010cacadcf69390a40 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 5 Apr 2021 10:35:30 -0700 Subject: [PATCH 106/195] minor and doc --- documentation/RELEASE_NOTES.md | 83 +++++++++++++++++++++++++ modules/database/src/std/link/lnkCalc.c | 2 +- 2 files changed, 84 insertions(+), 1 deletion(-) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index bf38deeb5..17b039cf5 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -22,6 +22,89 @@ should also be read to understand what has changed since earlier releases. IOC shell will now ensure `${PWD}` is set on startup, and updated by the `cd` iocsh function. +### Add Alarm Message and Time Tag Fields + +Two new fields have been added to `dbCommon` so will be present in all +records: `AMSG` and `UTAG`. + +#### `AMSG` + +`AMSG` can hold an arbitrary 40-character string, providing additional +information about the alarm condition indicated in `STAT` and `SEVR`. With no +alarm it will hold an empty string. The new `recGblSetSevrMsg()` function can +be used in place of `recGblSetSevr()` to signal an alarm while providing a +message. + +For example, a device support's `read_bi()` routine for a hypothetical +multi-channel ethernet attached device might flag a communication error +between the IOC and controller, or an error involving a certain channel like +this: + +```c +static long read_bi(biRecord* prec) { + ... + if (!priv->connected) { + recGblSetSevrMsg(prec, COMM_ALARM, INVALID_ALARM, + "No controller connected"); + return S_dev_noDevice; + } + if (!priv->err) { + recGblSetSevrMsg(prec, READ_ALARM, INVALID_ALARM, + "Channel %u disconnexted", priv->chan); + return S_dev_noDevice; + } + return status; +} +``` + +#### `UTAG` + +`UTAG` holds an `epicsUInt64` value which is semantically part of the record's +timestamp (`TIME`). The value defaults to zero if not explicitly set. Device +support or an event time provider which supports this feature may write a tag +value directly to the `dbCommon::utag` field. + +`TSEL` links will copy both `TIME` and `UTAG` between records if the link type +supports this (CA links do not). + +A `utag` server side channel filter has been added which can be configured to +filter out monitor updates which don't pass the test `(UTAG & M) == V` where +`M` and `V` are client specified integers. For example running the command +`camonitor BPM0:X.{utag:{M:1,V:1}}` will only show updates for which +`(UTAG & 1) == 1` i.e. the least significant bit of the `UTAG` field is set. + +This feature is intended for use by intelligent devices which can provide +contextual information along with a value/alarm/time. For example, a beam +diagnostic device which is aware of whether a beam signal should be present +(eg. from a global timing system). + +#### Link Support + +Two new optional methods have been added to the Link Support Entry Table +(`struct lset`): `lset::getAlarmMsg()` and `lset::getTimeStampTag()`. See +comments in dbLink.h for details on implementing these. + +Two new accessor functions have also been added which call these methods: +`dbGetAlarmMsg()` and `dbGetTimeStampTag()`. + +#### Compatibility + +User code wishing to call these interfaces while maintaining compatibility with older +versions of Base may add some of the following macro definitions, and ensure +that the variables referenced by output pointers are initialized. + +```c +#ifndef HAS_ALARM_MESSAGE +# recGblSetSevrMsg(REC, STAT, SEVR, ...) recGblSetSevr(REC, STAT, SEVR) +#endif +#ifndef dbGetAlarmMsg +# define dbGetAlarmMsg(LINK, STAT, SEVR, BUF, BUFLEN) dbGetAlarm(LINK, STAT, SEVR) +#endif +#ifndef dbGetTimeStampTag +# define dbGetTimeStampTag(LINK, STAMP, TAG) dbGetTimeStamp(LINK, STAMP) +#endif +``` + ----- diff --git a/modules/database/src/std/link/lnkCalc.c b/modules/database/src/std/link/lnkCalc.c index 96a12f128..46655850e 100644 --- a/modules/database/src/std/link/lnkCalc.c +++ b/modules/database/src/std/link/lnkCalc.c @@ -53,7 +53,7 @@ typedef struct calc_link { } pstate; epicsEnum16 stat; epicsEnum16 sevr; - char amsg[MAX_STRING_SIZE]; + char amsg[DB_AMSG_SIZE]; short prec; char *expr; char *major; From 348d1bba176117178eb2c59cd0be193e1cf104ca Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 6 Apr 2021 18:05:46 -0500 Subject: [PATCH 107/195] Update CI test configurations - Limit test-results step to 1 min in case a test hangs without generating a tapfile, as `make test-results` may re-run it. - Limit Appveyor tests to 20 mins. - Always run `make test-results` on GHA. --- .appveyor.yml | 2 +- .appveyor/epics-base-7.yml | 4 ++-- .github/workflows/ci-scripts-build.yml | 3 ++- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 920dbb2a1..5534df41f 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -111,7 +111,7 @@ test_script: on_finish: - ps: Get-ChildItem *.tap -Recurse -Force | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } - - cmd: python .ci/cue.py build test-results -s + - cmd: python .ci/cue.py -T 1M test-results on_failure: - cmd: python -m ci_core_dumper report diff --git a/.appveyor/epics-base-7.yml b/.appveyor/epics-base-7.yml index 1a01b35d5..f7e7da511 100644 --- a/.appveyor/epics-base-7.yml +++ b/.appveyor/epics-base-7.yml @@ -113,11 +113,11 @@ build_script: test_script: - cmd: python -m ci_core_dumper install - - cmd: python .ci/cue.py test + - cmd: python .ci/cue.py -T 20M test on_finish: - ps: Get-ChildItem *.tap -Recurse -Force | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } - - cmd: python .ci/cue.py build test-results -s + - cmd: python .ci/cue.py -T 1M test-results on_failure: - cmd: python -m ci_core_dumper report diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index f9d52e54b..7055238c1 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -171,4 +171,5 @@ jobs: name: tapfiles ${{ matrix.name }} path: '**/O.*/*.tap' - name: Collect and show test results - run: python .ci/cue.py test-results + if: ${{ always() }} + run: python .ci/cue.py -T 1M test-results From f727d16b0dbd88492f7676d7b5a1ecd1f4d21a11 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 20 Apr 2021 17:39:25 -0500 Subject: [PATCH 108/195] CI: Allow up to 5 minutes for `make test-results` --- .appveyor.yml | 2 +- .appveyor/epics-base-7.yml | 2 +- .github/workflows/ci-scripts-build.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 5534df41f..c830ae1a8 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -111,7 +111,7 @@ test_script: on_finish: - ps: Get-ChildItem *.tap -Recurse -Force | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } - - cmd: python .ci/cue.py -T 1M test-results + - cmd: python .ci/cue.py -T 5M test-results on_failure: - cmd: python -m ci_core_dumper report diff --git a/.appveyor/epics-base-7.yml b/.appveyor/epics-base-7.yml index f7e7da511..4a01ccde5 100644 --- a/.appveyor/epics-base-7.yml +++ b/.appveyor/epics-base-7.yml @@ -117,7 +117,7 @@ test_script: on_finish: - ps: Get-ChildItem *.tap -Recurse -Force | % { Push-AppveyorArtifact $_.FullName -FileName $_.Name } - - cmd: python .ci/cue.py -T 1M test-results + - cmd: python .ci/cue.py -T 5M test-results on_failure: - cmd: python -m ci_core_dumper report diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index 7055238c1..ff61a16c5 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -172,4 +172,4 @@ jobs: path: '**/O.*/*.tap' - name: Collect and show test results if: ${{ always() }} - run: python .ci/cue.py -T 1M test-results + run: python .ci/cue.py -T 5M test-results From 396624fefcc569e3aebb073f6a7dfeea72d83938 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 19 Mar 2021 20:20:06 -0500 Subject: [PATCH 109/195] Timeouts for running unit test programs The generated .t file now kills the test program if it hasn't completed within a defined interval, 5 minutes by default. Separate implementations for Windows and Unix hosts. --- src/tools/makeTestfile.pl | 116 ++++++++++++++++++++++++++++---------- 1 file changed, 86 insertions(+), 30 deletions(-) diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index 7a8234962..9afb24e73 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -23,6 +23,16 @@ use strict; +use File::Basename; +my $tool = basename($0); + +# Test programs that need more than 5 minutes to run should have the +# EPICS_UNITTEST_TIMEOUT environment variable set in their Makefile: +# longRunningTest.t: EPICS_UNITTEST_TIMEOUT=3600 +# The above embeds it into the .t file. It can also be set at runtime, +# which will then override that compiled-in setting (so not recommended). +my $timeout = $ENV{EPICS_UNITTEST_TIMEOUT} // 5*60; + my ($TA, $HA, $target, $exe) = @ARGV; my $exec; @@ -43,21 +53,45 @@ if( $TA =~ /^win32-x86/ && $HA !~ /^win/ ) { # Explicitly fail for other RTEMS targets } elsif( $TA =~ /^RTEMS-/ ) { - die "$0: I don't know how to create scripts for testing $TA on $HA\n"; + die "$tool: I don't know how to create scripts for testing $TA on $HA\n"; } else { $exec = "./$exe"; } -# Ensure that Windows interactive error handling is disabled. -# This setting is inherited by the test process. -# Set SEM_FAILCRITICALERRORS (1) Disable critical-error-handler dialog -# Clear SEM_NOGPFAULTERRORBOX (2) Enabled WER to allow automatic post mortem debugging (AeDebug) -# Clear SEM_NOALIGNMENTFAULTEXCEPT (4) Allow alignment fixups -# Set SEM_NOOPENFILEERRORBOX (0x8000) Prevent dialog on some I/O errors -# https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-seterrormode?redirectedfrom=MSDN -my $sem = $^O ne 'MSWin32' ? '' : <', $target) + or die "$tool: Can't create $target: $!\n"; + +print $OUT <<__EOT__; +#!/usr/bin/env perl +# This file was generated by $tool + +use strict; +use Cwd 'abs_path'; +use File::Basename; +my \$tool = basename(\$0); + +\$ENV{HARNESS_ACTIVE} = 1 if scalar \@ARGV && shift eq '-tap'; +\$ENV{TOP} = abs_path(\$ENV{TOP}) if exists \$ENV{TOP}; + +my \$timeout = \$ENV{EPICS_UNITTEST_TIMEOUT} // $timeout; +__EOT__ + +if ($^O eq 'MSWin32') { + ######################################## Code for Windows run-hosts + print $OUT <<__WIN32__; + +use Win32::Job; + BEGIN { + # Ensure that Windows interactive error handling is disabled. + # This setting is inherited by the test process. + # Set SEM_FAILCRITICALERRORS (1) Disable critical-error-handler dialog + # Clear SEM_NOGPFAULTERRORBOX (2) Enabled WER to allow automatic post mortem debugging (AeDebug) + # Clear SEM_NOALIGNMENTFAULTEXCEPT (4) Allow alignment fixups + # Set SEM_NOOPENFILEERRORBOX (0x8000) Prevent dialog on some I/O errors + # https://docs.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-seterrormode my \$sem = 'SetErrorMode'; eval { require Win32::ErrorMode; @@ -69,30 +103,52 @@ BEGIN { } if \$@; SetErrorMode(0x8001) unless \$@; } -ENDBEGIN -open(my $OUT, '>', $target) or die "Can't create $target: $!\n"; +my \$job = Win32::Job->new; +die "\$tool: Can't create Win32::Job: \$^E\\n" + unless \$job; +my \$pid = \$job->spawn(undef, '$exec'); +die "\$tool: Can't spawn Process '$exec': \$^E\\n" + unless defined(\$pid); -print $OUT <run(\$timeout)) { + print "\\n#### Test stopped by \$tool after \$timeout seconds\\n"; + die "\$tool: Timed out '$exec' after \$timeout seconds\\n"; +} +my \$status = \$job->status(); +exit \$status->{\$pid}->{exitcode}; -use strict; -use Cwd 'abs_path'; -$sem - -\$ENV{HARNESS_ACTIVE} = 1 if scalar \@ARGV && shift eq '-tap'; -\$ENV{TOP} = abs_path(\$ENV{TOP}) if exists \$ENV{TOP}; - -if (\$^O eq 'MSWin32') { - # Use system on Windows, exec doesn't work the same there and - # GNUmake thinks the test has finished too soon. - my \$status = system('$exec'); - die "Can't run $exec: \$!\\n" if \$status == -1; - exit \$status >> 8; +__WIN32__ } else { - exec '$exec' or die "Can't run $exec: \$!\\n"; -} -EOF + ######################################## Code for Unix run-hosts + print $OUT <<__UNIX__; -close $OUT or die "Can't close $target: $!\n"; +my \$pid = fork(); +die "\$tool: Can't fork for '$exec': \$!\\n" + unless defined \$pid; + +if (\$pid) { + # Parent process + \$SIG{ALRM} = sub { + # Time's up, kill the child + kill 9, \$pid; + print "\\n#### Test stopped by \$tool after \$timeout seconds\\n"; + die "\$tool: Timed out '$exec' after \$timeout seconds\\n"; + }; + + alarm \$timeout; + waitpid \$pid, 0; + alarm 0; + exit \$? >> 8; +} +else { + # Child process + exec '$exec' + or die "\$tool: Can't run '$exec': \$!\\n"; +} +__UNIX__ +} + +close $OUT + or die "$tool: Can't close '$target': $!\n"; From e812323792ff6fb59237c2929d6ef2c49c7fa6ba Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 20 Mar 2021 00:02:55 -0500 Subject: [PATCH 110/195] Replace Win32::Job with Win32::Process GitHub Actions builders won't let us use Win32::Job --- src/tools/makeTestfile.pl | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index 9afb24e73..34327741e 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -82,7 +82,8 @@ if ($^O eq 'MSWin32') { ######################################## Code for Windows run-hosts print $OUT <<__WIN32__; -use Win32::Job; +use Win32::Process; +use Win32; BEGIN { # Ensure that Windows interactive error handling is disabled. @@ -104,19 +105,20 @@ BEGIN { SetErrorMode(0x8001) unless \$@; } -my \$job = Win32::Job->new; -die "\$tool: Can't create Win32::Job: \$^E\\n" - unless \$job; -my \$pid = \$job->spawn(undef, '$exec'); -die "\$tool: Can't spawn Process '$exec': \$^E\\n" - unless defined(\$pid); - -if (! \$job->run(\$timeout)) { +my \$proc; +if (! Win32::Process::Create(\$proc, abs_path('$exec'), + '$exec', 1, NORMAL_PRIORITY_CLASS, '.')) { + my \$err = Win32::FormatMessage(Win32::GetLastError()); + die "\$tool: Can't create Process for '$exec': \$err\\n"; +} +if (! \$proc->Wait(1000 * \$timeout)) { + \$proc->Kill(1); print "\\n#### Test stopped by \$tool after \$timeout seconds\\n"; die "\$tool: Timed out '$exec' after \$timeout seconds\\n"; } -my \$status = \$job->status(); -exit \$status->{\$pid}->{exitcode}; +my \$status; +\$proc->GetExitCode(\$status); +exit \$status; __WIN32__ } From e2313d0c58975321dcd32ceea46472a0de23977a Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 20 Mar 2021 00:04:18 -0500 Subject: [PATCH 111/195] Generate comments on how to adjust the timeout --- src/tools/makeTestfile.pl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index 34327741e..6cb0eb900 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -75,6 +75,9 @@ my \$tool = basename(\$0); \$ENV{HARNESS_ACTIVE} = 1 if scalar \@ARGV && shift eq '-tap'; \$ENV{TOP} = abs_path(\$ENV{TOP}) if exists \$ENV{TOP}; +# The default timeout used below can be set in the Makefile that +# generates this test script. Add this line and adjust the time: +# $target: EPICS_UNITTEST_TIMEOUT=$timeout my \$timeout = \$ENV{EPICS_UNITTEST_TIMEOUT} // $timeout; __EOT__ From e2a9678b15f43773fb9aac33f28c4b5c48d9f05f Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 22 Mar 2021 13:19:56 -0500 Subject: [PATCH 112/195] netget: watchdog() now returns a result Currently this can only be a scaler value. On timeout, calls the fail function and returns its result instead. --- modules/database/test/std/rec/netget.plt | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/modules/database/test/std/rec/netget.plt b/modules/database/test/std/rec/netget.plt index 075717d78..363625ef2 100644 --- a/modules/database/test/std/rec/netget.plt +++ b/modules/database/test/std/rec/netget.plt @@ -50,11 +50,21 @@ sub kill_bail { } sub watchdog (&$$) { - my ($do, $timeout, $abort) = @_; - $SIG{ALRM} = $abort; - alarm $timeout; - &$do; - alarm 0; + my ($code, $timeout, $fail) = @_; + my $bark = "Woof $$\n"; + my $result; + eval { + local $SIG{__DIE__}; + local $SIG{ALRM} = sub { die $bark }; + alarm $timeout; + $result = &$code; + alarm 0; + }; + if ($@) { + die if $@ ne $bark; + $result = &$fail; + } + return $result; } From cde7d3d254e4739fd1aba783a9959755ed2e195c Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 22 Mar 2021 13:55:44 -0500 Subject: [PATCH 113/195] Kill CA & PVA clients properly if they time out Uses Win32::Process or fork() to run caget/pvget. The system_timeout() and qx_timeout() utilities added here should be extracted into a separate EPICS::Timeouts module. --- modules/database/test/std/rec/netget.plt | 106 +++++++++++++++-------- 1 file changed, 71 insertions(+), 35 deletions(-) diff --git a/modules/database/test/std/rec/netget.plt b/modules/database/test/std/rec/netget.plt index 363625ef2..f6433d173 100644 --- a/modules/database/test/std/rec/netget.plt +++ b/modules/database/test/std/rec/netget.plt @@ -3,6 +3,9 @@ use strict; use warnings; +use if $^O eq 'MSWin32', "Win32::Process"; +use if $^O eq 'MSWin32', "Win32"; + use lib '@TOP@/lib/perl'; use Test::More tests => 3; @@ -100,19 +103,6 @@ like($version, qr/^ \d+ \. \d+ \. \d+ /x, "Got BaseVersion '$version' from iocsh"); -# Client Tests - -my $client = EPICS::IOC->new; -$client->debug($debug); - -sub close_client { - my $doing = shift; - return sub { - diag("Timeout $doing"); - $client->close; - } -} - # Channel Access SKIP: { @@ -129,17 +119,9 @@ SKIP: { # CA Client test - watchdog { - $client->start($caget, '-w5', $pv); - my $caVersion = $client->_getline; - like($caVersion, qr/^ $pv \s+ \Q$version\E $/x, - 'Got same BaseVersion from caget'); - my @errors = $client->_geterrors; - note("Errors from caget:\n", - map(" $_\n", @errors)) - if scalar @errors; - $client->close; - } 15, close_client('doing caget'); + my $caVersion = qx_timeout(15, "$caget -w5 $pv"); + like($caVersion, qr/^ $pv \s+ \Q$version\E $/x, + 'Got same BaseVersion from caget'); } @@ -162,17 +144,71 @@ SKIP: { # PVA Client test - watchdog { - $client->start($pvget, '-w5', $pv); - my $pvaVersion = $client->_getline; - like($pvaVersion, qr/^ $pv \s .* \Q$version\E \s* $/x, - 'Got same BaseVersion from pvget'); - my @errors = $client->_geterrors; - note("Errors from pvget:\n", - map(" $_\n", @errors)) - if scalar @errors; - $client->close; - } 10, close_client('doing pvget'); + my $pvaVersion = qx_timeout(15, "$pvget -w5 $pv"); + like($pvaVersion, qr/^ $pv \s .* \Q$version\E \s* $/x, + 'Got same BaseVersion from pvget'); } $ioc->exit; + + +# Process timeout utilities + +sub system_timeout { + my ($timeout, $cmdline) = @_; + my $status; + if ($^O eq 'MSWin32') { + my $proc; + (my $app) = split ' ', $cmdline; + if (! Win32::Process::Create($proc, $app, $cmdline, + 1, &Win32::Process::NORMAL_PRIORITY_CLASS, '.')) { + my $err = Win32::FormatMessage(Win32::GetLastError()); + die "Can't create Process for '$cmdline': $err\n"; + } + if (! $proc->Wait(1000 * $timeout)) { + $proc->Kill(1); + note("Timed out '$cmdline' after $timeout seconds\n"); + } + my $status; + $proc->GetExitCode($status); + return $status; + } + else { + my $pid; + $status = watchdog { + $pid = fork(); + die "Can't fork: $!\n" + unless defined $pid; + exec $cmdline + or die "Can't exec: $!\n" + unless $pid; + waitpid $pid, 0; + return $? >> 8; + } $timeout, sub { + kill 9, $pid if $pid; + note("Timed out '$cmdline' after $timeout seconds\n"); + return -2; + }; + } + return $status; +} + +sub qx_timeout { + my ($timeout, $cmdline) = @_; + open(my $stdout, '>&STDOUT') + or die "Can't save STDOUT: $!\n"; + my $outfile = "stdout-$$.txt"; + unlink $outfile; + open STDOUT, '>', $outfile; + my $text; + if (system_timeout($timeout, $cmdline) == 0 && -r $outfile) { + open(my $file, '<', $outfile) + or die "Can't open $outfile: $!\n"; + $text = join '', <$file>; + close $file; + } + open(STDOUT, '>&', $stdout) + or die "Can't restore STDOUT: $!\n"; + unlink $outfile; + return $text; +} From e3d04e9cd8c837d0546fe7b3f702f039cc5eba00 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 22 Mar 2021 15:09:35 -0500 Subject: [PATCH 114/195] Make BAIL_OUT display what was thrown --- modules/database/test/std/rec/netget.plt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/database/test/std/rec/netget.plt b/modules/database/test/std/rec/netget.plt index f6433d173..0324a54c7 100644 --- a/modules/database/test/std/rec/netget.plt +++ b/modules/database/test/std/rec/netget.plt @@ -38,7 +38,7 @@ $ioc->debug($debug); $SIG{__DIE__} = $SIG{INT} = $SIG{QUIT} = sub { $ioc->exit; - BAIL_OUT('Caught signal'); + BAIL_OUT("Caught signal: $_[0]"); }; From cbab8daae00f6676118de5af2b70bf460e5c11d1 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 22 Mar 2021 15:10:31 -0500 Subject: [PATCH 115/195] Turn off debug in netget.plt --- modules/database/test/std/rec/netget.plt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/database/test/std/rec/netget.plt b/modules/database/test/std/rec/netget.plt index 0324a54c7..af2787967 100644 --- a/modules/database/test/std/rec/netget.plt +++ b/modules/database/test/std/rec/netget.plt @@ -12,7 +12,7 @@ use Test::More tests => 3; use EPICS::IOC; # Set to 1 to echo all IOC and client communications -my $debug = 1; +my $debug = 0; $ENV{HARNESS_ACTIVE} = 1 if scalar @ARGV && shift eq '-tap'; From 54d40a398a9dc192578348ba917bef890eca68b8 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 22 Mar 2021 15:11:44 -0500 Subject: [PATCH 116/195] Correct comments in makeTestfile, add "export" --- src/tools/makeTestfile.pl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index 6cb0eb900..2d8fd3f9c 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -28,7 +28,7 @@ my $tool = basename($0); # Test programs that need more than 5 minutes to run should have the # EPICS_UNITTEST_TIMEOUT environment variable set in their Makefile: -# longRunningTest.t: EPICS_UNITTEST_TIMEOUT=3600 +# longRunningTest.t: export EPICS_UNITTEST_TIMEOUT=3600 # The above embeds it into the .t file. It can also be set at runtime, # which will then override that compiled-in setting (so not recommended). my $timeout = $ENV{EPICS_UNITTEST_TIMEOUT} // 5*60; @@ -75,9 +75,9 @@ my \$tool = basename(\$0); \$ENV{HARNESS_ACTIVE} = 1 if scalar \@ARGV && shift eq '-tap'; \$ENV{TOP} = abs_path(\$ENV{TOP}) if exists \$ENV{TOP}; -# The default timeout used below can be set in the Makefile that -# generates this test script. Add this line and adjust the time: -# $target: EPICS_UNITTEST_TIMEOUT=$timeout +# The timeout value below can be set in the Makefile that builds +# this test script. Add this line and adjust the value (in seconds): +# $target: export EPICS_UNITTEST_TIMEOUT=$timeout my \$timeout = \$ENV{EPICS_UNITTEST_TIMEOUT} // $timeout; __EOT__ From 58a9767aa4d34b4dd4bcff450019bfaf5d4416bf Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 23 Mar 2021 10:03:13 -0500 Subject: [PATCH 117/195] Release notes describing test timeouts --- documentation/RELEASE_NOTES.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 17b039cf5..3a37da919 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -106,6 +106,33 @@ that the variables referenced by output pointers are initialized. ``` +### Timeouts for Unit Test Programs + +Most unit test programs that are run by the EPICS build system using +`make runtests` or `make tapfiles` are now only allowed to run for a limited +time period. If a test program runs for more than the timeout period (by +default 5 minutes, 300 seconds) without exiting it will be killed after that +period has elapsed. The limit can be extended (or shortened) for individual +tests as necessary by adding a line to the Makefile which runs them, setting +the environment variable `EPICS_UNITTEST_TIMEOUT` to a value in seconds while +building the test (`.t`) script, like this: + +``` + TESTSCRIPTS_HOST += hourLongTest.t + hourLongTest.t: export EPICS_UNITTEST_TIMEOUT=3600 +``` + +The time limit only applies to tests that use `makeTestfile.pl` to generate a +test (`.t`) script that runs the actual test program. Tests which are provided +as a `.plt` script should implement their own timeout if they can hang while +running in a Continuous Integration system (the Base "netget" test now does +this in a way that works on Windows as well as Posix hosts). + +The same environment variable can be set while running the tests to override +the time limit given in the Makefile, but it cannot be configured to provide a +separate limit for each program when using `make runtests`. This feature may +be useful for debugging purposes. + ----- ## EPICS Release 7.0.5 From 67bbc0fa210361782a2525b7574b1b176158ac2d Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 26 Mar 2021 18:26:51 -0500 Subject: [PATCH 118/195] Increase default timeout, improve notes --- documentation/RELEASE_NOTES.md | 34 +++++++++++++++++----------------- src/tools/makeTestfile.pl | 14 ++++++++------ 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 3a37da919..ad3995dea 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -108,30 +108,30 @@ that the variables referenced by output pointers are initialized. ### Timeouts for Unit Test Programs -Most unit test programs that are run by the EPICS build system using -`make runtests` or `make tapfiles` are now only allowed to run for a limited -time period. If a test program runs for more than the timeout period (by -default 5 minutes, 300 seconds) without exiting it will be killed after that -period has elapsed. The limit can be extended (or shortened) for individual -tests as necessary by adding a line to the Makefile which runs them, setting -the environment variable `EPICS_UNITTEST_TIMEOUT` to a value in seconds while -building the test (`.t`) script, like this: +The unit test programs that are run by the `make runtests` or `make tapfiles` +commands get executed by a `.t` wrapper script which is normally generated by +the EPICS `makeTestfile.pl` program. Those generated wrapper scripts now +impose a time-limit on the test program they execute, and will kill it if it +runs for longer than 500 seconds (8 minutes 20) without exiting. That +time-limit can be changed for any such test by modifying the Makefile which +creates and runs the `.t` wrapper script. + +Setting the environment variable `EPICS_UNITTEST_TIMEOUT` to the desired +number of seconds while the Makefile is generating the test script changes the +timeout in that script. For example: ``` TESTSCRIPTS_HOST += hourLongTest.t hourLongTest.t: export EPICS_UNITTEST_TIMEOUT=3600 ``` -The time limit only applies to tests that use `makeTestfile.pl` to generate a -test (`.t`) script that runs the actual test program. Tests which are provided -as a `.plt` script should implement their own timeout if they can hang while -running in a Continuous Integration system (the Base "netget" test now does -this in a way that works on Windows as well as Posix hosts). +When selecting such a timeout remember that different Continuous Integration +systems such as GitHub Actions and Appveyor run on processors with different +speeds, so allow enough head-room for slower systems to complete the test. -The same environment variable can be set while running the tests to override -the time limit given in the Makefile, but it cannot be configured to provide a -separate limit for each program when using `make runtests`. This feature may -be useful for debugging purposes. +Test programs written directly in Perl as a `.plt` script should implement a +similar timeout for themselves. The "netget" test in Base does this in a way +that works on Windows as well as Unix-like hosts. ----- diff --git a/src/tools/makeTestfile.pl b/src/tools/makeTestfile.pl index 2d8fd3f9c..455bd7f69 100644 --- a/src/tools/makeTestfile.pl +++ b/src/tools/makeTestfile.pl @@ -21,17 +21,19 @@ # target.t is the name of the Perl script to generate # executable is the name of the file the script runs +# Test programs that need more than 500 seconds to run should have the +# EPICS_UNITTEST_TIMEOUT environment variable set in their Makefile: +# longRunningTest.t: export EPICS_UNITTEST_TIMEOUT=3600 +# That embeds the timeout into the .t file. The timeout variable can also +# be set at runtime, which will override any compiled-in setting but the +# 'make runtests' command can't give a different timeout for each test. + use strict; use File::Basename; my $tool = basename($0); -# Test programs that need more than 5 minutes to run should have the -# EPICS_UNITTEST_TIMEOUT environment variable set in their Makefile: -# longRunningTest.t: export EPICS_UNITTEST_TIMEOUT=3600 -# The above embeds it into the .t file. It can also be set at runtime, -# which will then override that compiled-in setting (so not recommended). -my $timeout = $ENV{EPICS_UNITTEST_TIMEOUT} // 5*60; +my $timeout = $ENV{EPICS_UNITTEST_TIMEOUT} // 500; # 8 min 20 sec my ($TA, $HA, $target, $exe) = @ARGV; my $exec; From 4c63cb79dd4665782848503dcae1eff384522486 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 21 Apr 2021 13:13:56 -0500 Subject: [PATCH 119/195] Disable netget test on CI systems --- modules/database/test/std/rec/Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/database/test/std/rec/Makefile b/modules/database/test/std/rec/Makefile index e8c546442..52db82400 100644 --- a/modules/database/test/std/rec/Makefile +++ b/modules/database/test/std/rec/Makefile @@ -175,8 +175,12 @@ dbHeaderTestxx_SRCS += dbHeaderTestxx.cpp ifeq ($(T_A),$(EPICS_HOST_ARCH)) # Host-only tests of softIoc/softIocPVA, caget and pvget (if present) +# Unfortunately hangs too often on CI systems: +ifndef CI TESTS += netget endif +endif + # epicsRunRecordTests runs all the test programs in a known working order. testHarness_SRCS += epicsRunRecordTests.c From b00130493fe695fad623e509bda9d507fccec019 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 21 Apr 2021 16:03:36 -0700 Subject: [PATCH 120/195] update .ci --- .ci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci b/.ci index 246428427..d675de24e 160000 --- a/.ci +++ b/.ci @@ -1 +1 @@ -Subproject commit 2464284271581a66cb92b704bd9b7c4039282b99 +Subproject commit d675de24e6a2be018f6ff1dc35618c16dd621727 From c07ebcee5cc1e6720857a1a065480f61a3bfaa1c Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 23 Apr 2021 18:26:19 -0500 Subject: [PATCH 121/195] Added "Win2019 MSC-19, debug" build to GHA ... as suggested by Freddie. --- .github/workflows/ci-scripts-build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index ff61a16c5..75dc48c91 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -134,6 +134,11 @@ jobs: configuration: static name: "Win2019 MSC-19, static" + - os: windows-2019 + cmp: vs2019 + configuration: debug + name: "Win2019 MSC-19, debug" + - os: windows-2019 cmp: gcc configuration: default From f02884d9968b473a5fd6d340f25376ff947f8eda Mon Sep 17 00:00:00 2001 From: Hugo Slepicka Date: Thu, 29 Apr 2021 17:11:36 -0700 Subject: [PATCH 122/195] Add error message for when EPICS_BASE is not set on templates. Add error message and validation at convertRelease.pl for empty RELEASE files. --- src/template/base/top/configure/CONFIG | 5 +++++ src/template/ext/top/configure/CONFIG | 5 +++++ src/tools/convertRelease.pl | 6 ++++++ 3 files changed, 16 insertions(+) diff --git a/src/template/base/top/configure/CONFIG b/src/template/base/top/configure/CONFIG index c1a470322..7dfd05d5b 100644 --- a/src/template/base/top/configure/CONFIG +++ b/src/template/base/top/configure/CONFIG @@ -13,6 +13,11 @@ ifdef T_A -include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A) endif +# Check for proper EPICS_BASE +ifneq (file,$(origin EPICS_BASE)) + $(error EPICS_BASE must be defined in configure/RELEASE or a similar file or it will not be correctly read by convertRelease.pl!) +endif + CONFIG = $(RULES)/configure include $(CONFIG)/CONFIG diff --git a/src/template/ext/top/configure/CONFIG b/src/template/ext/top/configure/CONFIG index 321f6cea2..de0742729 100644 --- a/src/template/ext/top/configure/CONFIG +++ b/src/template/ext/top/configure/CONFIG @@ -17,6 +17,11 @@ ifdef T_A -include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A) endif +# Check for proper EPICS_BASE +ifneq (file,$(origin EPICS_BASE)) + $(error EPICS_BASE must be defined in configure/RELEASE or a similar file or it will not be correctly read by convertRelease.pl!) +endif + CONFIG = $(RULES)/configure include $(CONFIG)/CONFIG diff --git a/src/tools/convertRelease.pl b/src/tools/convertRelease.pl index 3375eb4f2..d2fa2dc87 100644 --- a/src/tools/convertRelease.pl +++ b/src/tools/convertRelease.pl @@ -113,6 +113,9 @@ EOF # sub releaseTops { my @includes = grep !m/^ (TOP | TEMPLATE_TOP) $/x, @apps; + if (!@includes) { + die "No variables defined in RELEASE*s"; + } print join(' ', @includes), "\n"; } @@ -256,6 +259,9 @@ sub checkRelease { } my @modules = grep(!m/^(RULES|TOP|TEMPLATE_TOP)$/, @apps); + if (!@modules) { + die "No variables defined in RELEASE*s"; + } my $app = shift @modules; my $latest = AbsPath($macros{$app}); my %paths = ($latest => $app); From 2eb5af31670a2ee9a03eb407102866279b7b7368 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 4 May 2021 11:18:54 -0500 Subject: [PATCH 123/195] Return dbPutSpecial(paddr, 1) status from dbPut() The status from RSET::special(paddr, 1) has not been returned to the put caller since 3.14, due to a bad up-merge. --- src/ioc/db/dbAccess.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/ioc/db/dbAccess.c b/src/ioc/db/dbAccess.c index e5a63a9c6..7ac56308f 100644 --- a/src/ioc/db/dbAccess.c +++ b/src/ioc/db/dbAccess.c @@ -1290,7 +1290,8 @@ long dbPut(DBADDR *paddr, short dbrType, /* Always do special processing if needed */ if (special) { long status2 = dbPutSpecial(paddr, 1); - if (status2) goto done; + if (status2) + status = status2; } if (status) goto done; From dc03d519fba9d0f4fe252e56547f428ae3aca4ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torsten=20B=C3=B6gershausen?= Date: Wed, 5 May 2021 08:55:48 +0200 Subject: [PATCH 124/195] Proper CRLF handling Add proper CLRF-LF rules to .gitattributes. Renormalize the bat files to LF in the repo and CRLF on disk. Remove executable bit of files which shouldn't have it set --- .gitattributes | 19 ++ modules/libcom/src/freeList/freeListLib.c | 0 modules/libcom/src/valgrind/valgrind.h | 0 modules/libcom/test/Makefile | 0 startup/win32.bat | 212 +++++++++++----------- startup/windows.bat | 212 +++++++++++----------- 6 files changed, 231 insertions(+), 212 deletions(-) mode change 100755 => 100644 modules/libcom/src/freeList/freeListLib.c mode change 100755 => 100644 modules/libcom/src/valgrind/valgrind.h mode change 100755 => 100644 modules/libcom/test/Makefile diff --git a/.gitattributes b/.gitattributes index d71c782e0..5221674ea 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,3 +4,22 @@ .appveyor/ export-ignore .appveyor.yml export-ignore README export-subst + +#Which files need CRLF handling +# default to automatic +* text=auto + +# batch script parser on windows requires CRLF +*.bat text eol=crlf + +# extensions for scripts which may be executable via. "#!..." must have LF +*.pl text eol=lf +*.plt text eol=lf +*.sh text eol=lf +*.cmd text eol=lf +# .cmd in unexpanded templates +*.cmd@* text eol=lf +# executable scripts w/o extensions +modules/ca/src/client/S99caRepeater@ text eol=lf +modules/libcom/src/log/S99logServer@ text eol=lf +startup/EpicsHostArch text eol=lf diff --git a/modules/libcom/src/freeList/freeListLib.c b/modules/libcom/src/freeList/freeListLib.c old mode 100755 new mode 100644 diff --git a/modules/libcom/src/valgrind/valgrind.h b/modules/libcom/src/valgrind/valgrind.h old mode 100755 new mode 100644 diff --git a/modules/libcom/test/Makefile b/modules/libcom/test/Makefile old mode 100755 new mode 100644 diff --git a/startup/win32.bat b/startup/win32.bat index dc50e6a72..818912547 100755 --- a/startup/win32.bat +++ b/startup/win32.bat @@ -1,106 +1,106 @@ -@echo off -rem ************************************************************************* -rem Copyright (c) 2017 UChicago Argonne LLC, as Operator of Argonne -rem National Laboratory. -rem Copyright (c) 2002 The Regents of the University of California, as -rem Operator of Los Alamos National Laboratory. -rem SPDX-License-Identifier: EPICS -rem EPICS BASE is distributed subject to a Software License Agreement found -rem in file LICENSE that is included with this distribution. -rem ************************************************************************* -rem -rem Site-specific EPICS environment settings -rem -rem Sets EPICS_HOST_ARCH and the environment for Microsoft Visual Studio. -rem Optionally, resets PATH, adds Strawberry Perl to PATH, and adds the -rem EPICS Base install host architecture bin directory to PATH. -rem - -rem ---------------------------------------------------------------------- -rem Site serviceable parts (These definitions may be modified) -rem ---------------------------------------------------------------------- - -rem The values of the definitions in this section must not contain -rem double-quotes. -rem -rem * Right: set _foo=C:\foo -rem * Right: set "_foo=C:\foo" -rem * Wrong: set _foo="C:\foo" - -rem Automatically set up the environment when possible ("yes" or "no"). -rem If set to yes, as much of the environment will be set up as possible. -rem If set to no, just the minimum environment will be set up. More -rem specific _auto_* definitions take precedence over this definition. -set _auto=no - -rem Automatically reset PATH ("yes" or "no"). If set to yes, PATH will -rem be reset to the value of _path_new. If set to no, PATH will not be -rem reset. -set _auto_path_reset=%_auto% - -rem Automatically append to PATH ("yes" or "no"). If set to yes, the -rem EPICS Base install host architecture bin directory will be added to -rem PATH if possible. If set to no, the bin directory will not be added -rem to PATH. -set _auto_path_append=%_auto% - -rem The new value for PATH. If _auto_path_reset is yes, PATH will be set -rem to it. -set _path_new=C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem - -rem The location of Strawberry Perl (pathname). If empty, Strawberry Perl -rem is assumed to already be in PATH and will not be added. If nonempty, -rem Strawberry Perl will be added to PATH. -set _strawberry_perl_home=C:\Strawberry - -rem The location of Microsoft Visual Studio (pathname). -set _visual_studio_home=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community - -rem The EPICS host architecture specification for EPICS_HOST_ARCH -rem (-[-] as defined in configure/CONFIG_SITE). -set _epics_host_arch=win32-x86 - -rem The install location of EPICS Base (pathname). If nonempty and -rem _auto_path_append is yes, it will be used to add the host architecture -rem bin directory to PATH. -set _epics_base= - -rem ---------------------------------------------------------------------- -rem Internal parts (There is typically no need to modify these) -rem ---------------------------------------------------------------------- - -rem Reset PATH -if "%_auto_path_reset%" == "yes" ( - set "PATH=%_path_new%" -) - -rem Add Strawberry Perl to PATH -if "%_strawberry_perl_home%" == "" goto after_add_strawberry_perl -rem Can't do this inside parentheses because PATH would be read only once -set "PATH=%PATH%;%_strawberry_perl_home%\c\bin" -set "PATH=%PATH%;%_strawberry_perl_home%\perl\site\bin" -set "PATH=%PATH%;%_strawberry_perl_home%\perl\bin" -:after_add_strawberry_perl - -rem Set the environment for Microsoft Visual Studio -call "%_visual_studio_home%\VC\Auxiliary\Build\vcvarsall.bat" x86 - -rem Set the EPICS host architecture specification -set "EPICS_HOST_ARCH=%_epics_host_arch%" - -rem Add the EPICS Base host architecture bin directory to PATH -if "%_auto_path_append%" == "yes" ( - if not "%_epics_base%" == "" ( - set "PATH=%PATH%;%_epics_base%\bin\%_epics_host_arch%" - ) -) - -rem Don't leak variables into the environment -set _auto= -set _auto_path_reset= -set _auto_path_append= -set _path_new= -set _strawberry_perl_home= -set _visual_studio_home= -set _epics_host_arch= -set _epics_base= +@echo off +rem ************************************************************************* +rem Copyright (c) 2017 UChicago Argonne LLC, as Operator of Argonne +rem National Laboratory. +rem Copyright (c) 2002 The Regents of the University of California, as +rem Operator of Los Alamos National Laboratory. +rem SPDX-License-Identifier: EPICS +rem EPICS BASE is distributed subject to a Software License Agreement found +rem in file LICENSE that is included with this distribution. +rem ************************************************************************* +rem +rem Site-specific EPICS environment settings +rem +rem Sets EPICS_HOST_ARCH and the environment for Microsoft Visual Studio. +rem Optionally, resets PATH, adds Strawberry Perl to PATH, and adds the +rem EPICS Base install host architecture bin directory to PATH. +rem + +rem ---------------------------------------------------------------------- +rem Site serviceable parts (These definitions may be modified) +rem ---------------------------------------------------------------------- + +rem The values of the definitions in this section must not contain +rem double-quotes. +rem +rem * Right: set _foo=C:\foo +rem * Right: set "_foo=C:\foo" +rem * Wrong: set _foo="C:\foo" + +rem Automatically set up the environment when possible ("yes" or "no"). +rem If set to yes, as much of the environment will be set up as possible. +rem If set to no, just the minimum environment will be set up. More +rem specific _auto_* definitions take precedence over this definition. +set _auto=no + +rem Automatically reset PATH ("yes" or "no"). If set to yes, PATH will +rem be reset to the value of _path_new. If set to no, PATH will not be +rem reset. +set _auto_path_reset=%_auto% + +rem Automatically append to PATH ("yes" or "no"). If set to yes, the +rem EPICS Base install host architecture bin directory will be added to +rem PATH if possible. If set to no, the bin directory will not be added +rem to PATH. +set _auto_path_append=%_auto% + +rem The new value for PATH. If _auto_path_reset is yes, PATH will be set +rem to it. +set _path_new=C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem + +rem The location of Strawberry Perl (pathname). If empty, Strawberry Perl +rem is assumed to already be in PATH and will not be added. If nonempty, +rem Strawberry Perl will be added to PATH. +set _strawberry_perl_home=C:\Strawberry + +rem The location of Microsoft Visual Studio (pathname). +set _visual_studio_home=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community + +rem The EPICS host architecture specification for EPICS_HOST_ARCH +rem (-[-] as defined in configure/CONFIG_SITE). +set _epics_host_arch=win32-x86 + +rem The install location of EPICS Base (pathname). If nonempty and +rem _auto_path_append is yes, it will be used to add the host architecture +rem bin directory to PATH. +set _epics_base= + +rem ---------------------------------------------------------------------- +rem Internal parts (There is typically no need to modify these) +rem ---------------------------------------------------------------------- + +rem Reset PATH +if "%_auto_path_reset%" == "yes" ( + set "PATH=%_path_new%" +) + +rem Add Strawberry Perl to PATH +if "%_strawberry_perl_home%" == "" goto after_add_strawberry_perl +rem Can't do this inside parentheses because PATH would be read only once +set "PATH=%PATH%;%_strawberry_perl_home%\c\bin" +set "PATH=%PATH%;%_strawberry_perl_home%\perl\site\bin" +set "PATH=%PATH%;%_strawberry_perl_home%\perl\bin" +:after_add_strawberry_perl + +rem Set the environment for Microsoft Visual Studio +call "%_visual_studio_home%\VC\Auxiliary\Build\vcvarsall.bat" x86 + +rem Set the EPICS host architecture specification +set "EPICS_HOST_ARCH=%_epics_host_arch%" + +rem Add the EPICS Base host architecture bin directory to PATH +if "%_auto_path_append%" == "yes" ( + if not "%_epics_base%" == "" ( + set "PATH=%PATH%;%_epics_base%\bin\%_epics_host_arch%" + ) +) + +rem Don't leak variables into the environment +set _auto= +set _auto_path_reset= +set _auto_path_append= +set _path_new= +set _strawberry_perl_home= +set _visual_studio_home= +set _epics_host_arch= +set _epics_base= diff --git a/startup/windows.bat b/startup/windows.bat index a36e43fdb..27b6dcc0b 100644 --- a/startup/windows.bat +++ b/startup/windows.bat @@ -1,106 +1,106 @@ -@echo off -rem ************************************************************************* -rem Copyright (c) 2017 UChicago Argonne LLC, as Operator of Argonne -rem National Laboratory. -rem Copyright (c) 2002 The Regents of the University of California, as -rem Operator of Los Alamos National Laboratory. -rem SPDX-License-Identifier: EPICS -rem EPICS BASE is distributed subject to a Software License Agreement found -rem in file LICENSE that is included with this distribution. -rem ************************************************************************* -rem -rem Site-specific EPICS environment settings -rem -rem Sets EPICS_HOST_ARCH and the environment for Microsoft Visual Studio. -rem Optionally, resets PATH, adds Strawberry Perl to PATH, and adds the -rem EPICS Base install host architecture bin directory to PATH. -rem - -rem ---------------------------------------------------------------------- -rem Site serviceable parts (These definitions may be modified) -rem ---------------------------------------------------------------------- - -rem The values of the definitions in this section must not contain -rem double-quotes. -rem -rem * Right: set _foo=C:\foo -rem * Right: set "_foo=C:\foo" -rem * Wrong: set _foo="C:\foo" - -rem Automatically set up the environment when possible ("yes" or "no"). -rem If set to yes, as much of the environment will be set up as possible. -rem If set to no, just the minimum environment will be set up. More -rem specific _auto_* definitions take precedence over this definition. -set _auto=no - -rem Automatically reset PATH ("yes" or "no"). If set to yes, PATH will -rem be reset to the value of _path_new. If set to no, PATH will not be -rem reset. -set _auto_path_reset=%_auto% - -rem Automatically append to PATH ("yes" or "no"). If set to yes, the -rem EPICS Base install host architecture bin directory will be added to -rem PATH if possible. If set to no, the bin directory will not be added -rem to PATH. -set _auto_path_append=%_auto% - -rem The new value for PATH. If _auto_path_reset is yes, PATH will be set -rem to it. -set _path_new=C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem - -rem The location of Strawberry Perl (pathname). If empty, Strawberry Perl -rem is assumed to already be in PATH and will not be added. If nonempty, -rem Strawberry Perl will be added to PATH. -set _strawberry_perl_home=C:\Strawberry - -rem The location of Microsoft Visual Studio (pathname). -set _visual_studio_home=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community - -rem The EPICS host architecture specification for EPICS_HOST_ARCH -rem (-[-] as defined in configure/CONFIG_SITE). -set _epics_host_arch=windows-x64 - -rem The install location of EPICS Base (pathname). If nonempty and -rem _auto_path_append is yes, it will be used to add the host architecture -rem bin directory to PATH. -set _epics_base= - -rem ---------------------------------------------------------------------- -rem Internal parts (There is typically no need to modify these) -rem ---------------------------------------------------------------------- - -rem Reset PATH -if "%_auto_path_reset%" == "yes" ( - set "PATH=%_path_new%" -) - -rem Add Strawberry Perl to PATH -if "%_strawberry_perl_home%" == "" goto after_add_strawberry_perl -rem Can't do this inside parentheses because PATH would be read only once -set "PATH=%PATH%;%_strawberry_perl_home%\c\bin" -set "PATH=%PATH%;%_strawberry_perl_home%\perl\site\bin" -set "PATH=%PATH%;%_strawberry_perl_home%\perl\bin" -:after_add_strawberry_perl - -rem Set the environment for Microsoft Visual Studio -call "%_visual_studio_home%\VC\Auxiliary\Build\vcvarsall.bat" x64 - -rem Set the EPICS host architecture specification -set "EPICS_HOST_ARCH=%_epics_host_arch%" - -rem Add the EPICS Base host architecture bin directory to PATH -if "%_auto_path_append%" == "yes" ( - if not "%_epics_base%" == "" ( - set "PATH=%PATH%;%_epics_base%\bin\%_epics_host_arch%" - ) -) - -rem Don't leak variables into the environment -set _auto= -set _auto_path_reset= -set _auto_path_append= -set _path_new= -set _strawberry_perl_home= -set _visual_studio_home= -set _epics_host_arch= -set _epics_base= +@echo off +rem ************************************************************************* +rem Copyright (c) 2017 UChicago Argonne LLC, as Operator of Argonne +rem National Laboratory. +rem Copyright (c) 2002 The Regents of the University of California, as +rem Operator of Los Alamos National Laboratory. +rem SPDX-License-Identifier: EPICS +rem EPICS BASE is distributed subject to a Software License Agreement found +rem in file LICENSE that is included with this distribution. +rem ************************************************************************* +rem +rem Site-specific EPICS environment settings +rem +rem Sets EPICS_HOST_ARCH and the environment for Microsoft Visual Studio. +rem Optionally, resets PATH, adds Strawberry Perl to PATH, and adds the +rem EPICS Base install host architecture bin directory to PATH. +rem + +rem ---------------------------------------------------------------------- +rem Site serviceable parts (These definitions may be modified) +rem ---------------------------------------------------------------------- + +rem The values of the definitions in this section must not contain +rem double-quotes. +rem +rem * Right: set _foo=C:\foo +rem * Right: set "_foo=C:\foo" +rem * Wrong: set _foo="C:\foo" + +rem Automatically set up the environment when possible ("yes" or "no"). +rem If set to yes, as much of the environment will be set up as possible. +rem If set to no, just the minimum environment will be set up. More +rem specific _auto_* definitions take precedence over this definition. +set _auto=no + +rem Automatically reset PATH ("yes" or "no"). If set to yes, PATH will +rem be reset to the value of _path_new. If set to no, PATH will not be +rem reset. +set _auto_path_reset=%_auto% + +rem Automatically append to PATH ("yes" or "no"). If set to yes, the +rem EPICS Base install host architecture bin directory will be added to +rem PATH if possible. If set to no, the bin directory will not be added +rem to PATH. +set _auto_path_append=%_auto% + +rem The new value for PATH. If _auto_path_reset is yes, PATH will be set +rem to it. +set _path_new=C:\Windows\System32;C:\Windows;C:\Windows\System32\wbem + +rem The location of Strawberry Perl (pathname). If empty, Strawberry Perl +rem is assumed to already be in PATH and will not be added. If nonempty, +rem Strawberry Perl will be added to PATH. +set _strawberry_perl_home=C:\Strawberry + +rem The location of Microsoft Visual Studio (pathname). +set _visual_studio_home=C:\Program Files (x86)\Microsoft Visual Studio\2019\Community + +rem The EPICS host architecture specification for EPICS_HOST_ARCH +rem (-[-] as defined in configure/CONFIG_SITE). +set _epics_host_arch=windows-x64 + +rem The install location of EPICS Base (pathname). If nonempty and +rem _auto_path_append is yes, it will be used to add the host architecture +rem bin directory to PATH. +set _epics_base= + +rem ---------------------------------------------------------------------- +rem Internal parts (There is typically no need to modify these) +rem ---------------------------------------------------------------------- + +rem Reset PATH +if "%_auto_path_reset%" == "yes" ( + set "PATH=%_path_new%" +) + +rem Add Strawberry Perl to PATH +if "%_strawberry_perl_home%" == "" goto after_add_strawberry_perl +rem Can't do this inside parentheses because PATH would be read only once +set "PATH=%PATH%;%_strawberry_perl_home%\c\bin" +set "PATH=%PATH%;%_strawberry_perl_home%\perl\site\bin" +set "PATH=%PATH%;%_strawberry_perl_home%\perl\bin" +:after_add_strawberry_perl + +rem Set the environment for Microsoft Visual Studio +call "%_visual_studio_home%\VC\Auxiliary\Build\vcvarsall.bat" x64 + +rem Set the EPICS host architecture specification +set "EPICS_HOST_ARCH=%_epics_host_arch%" + +rem Add the EPICS Base host architecture bin directory to PATH +if "%_auto_path_append%" == "yes" ( + if not "%_epics_base%" == "" ( + set "PATH=%PATH%;%_epics_base%\bin\%_epics_host_arch%" + ) +) + +rem Don't leak variables into the environment +set _auto= +set _auto_path_reset= +set _auto_path_append= +set _path_new= +set _strawberry_perl_home= +set _visual_studio_home= +set _epics_host_arch= +set _epics_base= From 28f3239b32182ee5ae0a6c061992cf2b139306fd Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 12 May 2021 18:47:49 -0700 Subject: [PATCH 125/195] set SONAME for cross builds --- configure/CONFIG.gnuCommon | 4 ++-- configure/os/CONFIG.linux-x86.linux-x86 | 3 --- configure/os/CONFIG.solaris-sparc-gnu.solaris-sparc-gnu | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/configure/CONFIG.gnuCommon b/configure/CONFIG.gnuCommon index be77d4b38..355614e1a 100644 --- a/configure/CONFIG.gnuCommon +++ b/configure/CONFIG.gnuCommon @@ -56,8 +56,8 @@ STATIC_LDFLAGS_YES = -static STATIC_LDFLAGS_NO = SHRLIB_CFLAGS = -fPIC -SHRLIB_LDFLAGS = -shared -fPIC -LOADABLE_SHRLIB_LDFLAGS = -shared -fPIC +SHRLIB_LDFLAGS = -shared -fPIC -Wl,-h$@ +LOADABLE_SHRLIB_LDFLAGS = -shared -fPIC -Wl,-h$@ GNU_LDLIBS_YES = -lgcc diff --git a/configure/os/CONFIG.linux-x86.linux-x86 b/configure/os/CONFIG.linux-x86.linux-x86 index f6a79241a..153ce0d68 100644 --- a/configure/os/CONFIG.linux-x86.linux-x86 +++ b/configure/os/CONFIG.linux-x86.linux-x86 @@ -11,6 +11,3 @@ STATIC_LDFLAGS_YES= -Wl,-Bstatic STATIC_LDFLAGS_NO= STATIC_LDLIBS_YES= -Wl,-Bdynamic STATIC_LDLIBS_NO= - -SHRLIB_LDFLAGS += -Wl,-h$@ -LOADABLE_SHRLIB_LDFLAGS += -Wl,-h$@ diff --git a/configure/os/CONFIG.solaris-sparc-gnu.solaris-sparc-gnu b/configure/os/CONFIG.solaris-sparc-gnu.solaris-sparc-gnu index 03476b833..dfa1522ea 100644 --- a/configure/os/CONFIG.solaris-sparc-gnu.solaris-sparc-gnu +++ b/configure/os/CONFIG.solaris-sparc-gnu.solaris-sparc-gnu @@ -18,6 +18,6 @@ STATIC_LDLIBS_NO= OP_SYS_LDFLAGS += -z ignore -z combreloc -z lazyload -SHRLIB_LDFLAGS += -Wl,-z,defs -Wl,-z,text -Wl,-h,$@ -LOADABLE_SHRLIB_LDFLAGS += -Wl,-z,text -Wl,-h,$@ +SHRLIB_LDFLAGS += -Wl,-z,defs -Wl,-z,text +LOADABLE_SHRLIB_LDFLAGS += -Wl,-z,text GNU_LDLIBS_YES += -lc From 9cca12936dd6a361a6c0fa958960e0747e19ce53 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 17 May 2021 12:11:00 -0500 Subject: [PATCH 126/195] Expand EPICS_BASE checks in templates --- src/template/base/top/configure/CONFIG | 8 ++++++-- src/template/ext/top/configure/CONFIG | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/template/base/top/configure/CONFIG b/src/template/base/top/configure/CONFIG index 7dfd05d5b..40fa93140 100644 --- a/src/template/base/top/configure/CONFIG +++ b/src/template/base/top/configure/CONFIG @@ -13,9 +13,13 @@ ifdef T_A -include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A) endif -# Check for proper EPICS_BASE +# Check EPICS_BASE is set properly ifneq (file,$(origin EPICS_BASE)) - $(error EPICS_BASE must be defined in configure/RELEASE or a similar file or it will not be correctly read by convertRelease.pl!) + $(error EPICS_BASE must be set in a configure/RELEASE file) +else + ifeq ($(wildcard $(EPICS_BASE)/configure/CONFIG_BASE),) + $(error EPICS_BASE does not point to an EPICS installation) + endif endif CONFIG = $(RULES)/configure diff --git a/src/template/ext/top/configure/CONFIG b/src/template/ext/top/configure/CONFIG index de0742729..49595bc84 100644 --- a/src/template/ext/top/configure/CONFIG +++ b/src/template/ext/top/configure/CONFIG @@ -17,9 +17,13 @@ ifdef T_A -include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A) endif -# Check for proper EPICS_BASE +# Check EPICS_BASE is set properly ifneq (file,$(origin EPICS_BASE)) - $(error EPICS_BASE must be defined in configure/RELEASE or a similar file or it will not be correctly read by convertRelease.pl!) + $(error EPICS_BASE must be set in a configure/RELEASE file) +else + ifeq ($(wildcard $(EPICS_BASE)/configure/CONFIG_BASE),) + $(error EPICS_BASE does not point to an EPICS installation) + endif endif CONFIG = $(RULES)/configure From e20502fb4cd2423d2c142a9581d8a339f1b2254d Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 17 May 2021 12:12:19 -0500 Subject: [PATCH 127/195] Remove EPICS_BASE check from releaseTops() --- src/tools/convertRelease.pl | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/tools/convertRelease.pl b/src/tools/convertRelease.pl index d2fa2dc87..bc20bc69c 100644 --- a/src/tools/convertRelease.pl +++ b/src/tools/convertRelease.pl @@ -113,9 +113,6 @@ EOF # sub releaseTops { my @includes = grep !m/^ (TOP | TEMPLATE_TOP) $/x, @apps; - if (!@includes) { - die "No variables defined in RELEASE*s"; - } print join(' ', @includes), "\n"; } From cc3e1039cea66aec9abce2ac454c83272e5ea65a Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 17 May 2021 12:13:53 -0500 Subject: [PATCH 128/195] checkRelease(): expand EPICS_BASE checks --- src/tools/convertRelease.pl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/tools/convertRelease.pl b/src/tools/convertRelease.pl index bc20bc69c..b8c596edb 100644 --- a/src/tools/convertRelease.pl +++ b/src/tools/convertRelease.pl @@ -227,6 +227,12 @@ sub envPaths { # Check RELEASE file consistency with support modules # sub checkRelease { + die "\nEPICS_BASE must be set in a configure/RELEASE file.\n\n" + unless grep(m/^(EPICS_BASE)$/, @apps) && + exists $macros{EPICS_BASE} && + $macros{EPICS_BASE} ne '' && + -f "$macros{EPICS_BASE}/configure/CONFIG_BASE"; + my $status = 0; delete $macros{RULES}; delete $macros{TOP}; @@ -256,9 +262,6 @@ sub checkRelease { } my @modules = grep(!m/^(RULES|TOP|TEMPLATE_TOP)$/, @apps); - if (!@modules) { - die "No variables defined in RELEASE*s"; - } my $app = shift @modules; my $latest = AbsPath($macros{$app}); my %paths = ($latest => $app); From 1db35d9edcc1dee3569edc92ad1e9c32f8744827 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 17 May 2021 12:16:55 -0500 Subject: [PATCH 129/195] Cosmetic changes to template configure/CONFIG files --- src/template/base/top/configure/CONFIG | 13 +++++++--- src/template/ext/top/configure/CONFIG | 34 +++++++++++++------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/template/base/top/configure/CONFIG b/src/template/base/top/configure/CONFIG index 40fa93140..34ace5775 100644 --- a/src/template/base/top/configure/CONFIG +++ b/src/template/base/top/configure/CONFIG @@ -8,9 +8,10 @@ RULES = $(EPICS_BASE) # RELEASE files point to other application tops include $(TOP)/configure/RELEASE -include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).Common + ifdef T_A --include $(TOP)/configure/RELEASE.Common.$(T_A) --include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A) + -include $(TOP)/configure/RELEASE.Common.$(T_A) + -include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A) endif # Check EPICS_BASE is set properly @@ -28,11 +29,17 @@ include $(CONFIG)/CONFIG # Override the Base definition: INSTALL_LOCATION = $(TOP) -# CONFIG_SITE files contain other build configuration settings +# CONFIG_SITE files contain local build configuration settings include $(TOP)/configure/CONFIG_SITE + +# Host-arch specific settings -include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).Common + ifdef T_A + # Target-arch specific settings -include $(TOP)/configure/CONFIG_SITE.Common.$(T_A) + + # Host & target specific settings -include $(TOP)/configure/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A) endif diff --git a/src/template/ext/top/configure/CONFIG b/src/template/ext/top/configure/CONFIG index 49595bc84..0c239bf18 100644 --- a/src/template/ext/top/configure/CONFIG +++ b/src/template/ext/top/configure/CONFIG @@ -1,13 +1,11 @@ # CONFIG - Load build configuration data # -# Do not make changes in this file, any site-specific -# overrides should be given in a CONFIG_SITE file. +# Do not make changes to this file! -# Where the build rules come from +# Allow user to override where the build rules come from RULES = $(EPICS_BASE) -INSTALL_IDLFILE = $(INSTALL) - +# RELEASE files point to other application tops include $(TOP)/configure/RELEASE -include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH) -include $(TOP)/configure/RELEASE.$(EPICS_HOST_ARCH).Common @@ -29,24 +27,26 @@ endif CONFIG = $(RULES)/configure include $(CONFIG)/CONFIG -# Override some Base definitions +# Override the Base definition: INSTALL_LOCATION = $(TOP) -# CONFIG_SITE files contain build configuration overrides +# CONFIG_SITE files contain local build configuration settings include $(TOP)/configure/CONFIG_SITE -# Host-arch specific settings +# Host-arch specific settings for extensions are in configure/os -include $(TOP)/configure/os/CONFIG_SITE.$(EPICS_HOST_ARCH).Common +ifdef T_A + # Target-arch specific settings for extensions are in configure/os + -include $(TOP)/configure/os/CONFIG_SITE.Common.$(T_A) + + # Host & target specific settings for extensions are in configure/os + -include $(TOP)/configure/os/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A) +endif + +# Additional settings for extensions +INSTALL_IDLFILE = $(INSTALL) + ifdef INSTALL_LOCATION_EXTENSIONS INSTALL_LOCATION = $(INSTALL_LOCATION_EXTENSIONS) endif - -ifdef T_A - # Target-arch specific settings - -include $(TOP)/configure/os/CONFIG_SITE.Common.$(T_A) - - # Host & target specific combination settings - -include $(TOP)/configure/os/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A) -endif - From d1ddbad053cf092e70c593a67fdd41494005eda7 Mon Sep 17 00:00:00 2001 From: Freddie Akeroyd Date: Tue, 18 May 2021 12:24:07 +0100 Subject: [PATCH 130/195] Fix issue with very large timeout passed to epicsEventWaitWithTimeout() A very large timeout was getting converted to a 0 wait and causing some unit tests to fail in strange and random ways. Not trapping large timeouts was an oversight when converting to waitable timers on WIN32 --- src/libCom/osi/os/WIN32/osdEvent.c | 14 ++++++++++++-- src/libCom/osi/os/WIN32/osdThread.c | 14 ++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/libCom/osi/os/WIN32/osdEvent.c b/src/libCom/osi/os/WIN32/osdEvent.c index fb67d6c79..e39608255 100644 --- a/src/libCom/osi/os/WIN32/osdEvent.c +++ b/src/libCom/osi/os/WIN32/osdEvent.c @@ -92,17 +92,27 @@ epicsShareFunc epicsEventStatus epicsEventWait ( epicsEventId pSem ) epicsShareFunc epicsEventStatus epicsEventWaitWithTimeout ( epicsEventId pSem, double timeOut ) { - static const unsigned nSec100PerSec = 10000000u; + /* waitable timers use 100 nanosecond intervals, like FILETIME */ + static const unsigned ivalPerSec = 10000000u; /* number of 100ns intervals per second */ + static const unsigned mSecPerSec = 1000u; /* milliseconds per second */ HANDLE handles[2]; DWORD status; LARGE_INTEGER tmo; HANDLE timer; + LONGLONG nIvals; /* number of intervals */ if ( timeOut <= 0.0 ) { tmo.QuadPart = 0u; } + else if ( timeOut >= INFINITE / mSecPerSec ) { + /* we need to apply a maximum wait time to stop an overflow. We choose (INFINITE - 1) milliseconds, + to be compatible with previous WaitForSingleObject() implementation */ + nIvals = (LONGLONG)(INFINITE - 1) * (ivalPerSec / mSecPerSec); + tmo.QuadPart = -nIvals; /* negative value means a relative time offset for timer */ + } else { - tmo.QuadPart = -((LONGLONG)(timeOut * nSec100PerSec + 0.5)); + nIvals = (LONGLONG)(timeOut * ivalPerSec + 0.999999); + tmo.QuadPart = -nIvals; } if (tmo.QuadPart < 0) { diff --git a/src/libCom/osi/os/WIN32/osdThread.c b/src/libCom/osi/os/WIN32/osdThread.c index 0057ee953..092432e71 100644 --- a/src/libCom/osi/os/WIN32/osdThread.c +++ b/src/libCom/osi/os/WIN32/osdThread.c @@ -807,15 +807,25 @@ HANDLE osdThreadGetTimer() */ epicsShareFunc void epicsShareAPI epicsThreadSleep ( double seconds ) { - static const unsigned nSec100PerSec = 10000000u; + /* waitable timers use 100 nanosecond intervals, like FILETIME */ + static const unsigned ivalPerSec = 10000000u; /* number of 100ns intervals per second */ + static const unsigned mSecPerSec = 1000u; /* milliseconds per second */ LARGE_INTEGER tmo; HANDLE timer; + LONGLONG nIvals; /* number of intervals */ if ( seconds <= 0.0 ) { tmo.QuadPart = 0u; } + else if ( seconds >= INFINITE / mSecPerSec ) { + /* we need to apply a maximum wait time to stop an overflow. We choose (INFINITE - 1) milliseconds, + to be compatible with previous WaitForSingleObject() implementation */ + nIvals = (LONGLONG)(INFINITE - 1) * (ivalPerSec / mSecPerSec); + tmo.QuadPart = -nIvals; /* negative value means a relative time offset for timer */ + } else { - tmo.QuadPart = -((LONGLONG)(seconds * nSec100PerSec + 0.5)); + nIvals = (LONGLONG)(seconds * ivalPerSec + 0.999999); + tmo.QuadPart = -nIvals; } if (tmo.QuadPart == 0) { From 857527280bcc1145fae9d3ce7c37b114f44e1270 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 19 May 2021 08:49:24 -0700 Subject: [PATCH 131/195] ci: install versioned g++ --- .github/workflows/ci-scripts-build.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index 8fe0339d5..8d8b7ebb1 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -129,10 +129,12 @@ jobs: if: runner.os == 'Linux' - name: "apt-get install ${{ matrix.cmp }}" run: | + export GCC_NAME="${{ matrix.cmp }}" + sudo apt-get update sudo apt-get -y install software-properties-common sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test sudo apt-get update - sudo apt-get -y install ${{ matrix.cmp }} + sudo apt-get -y install g++-${GCC_NAME#gcc-} if: matrix.utoolchain - name: Prepare and compile dependencies run: python .ci/cue.py prepare From fa9fb0a3cac5cc61dfd3030e8a07d3a1ca4276b0 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 12 May 2021 19:06:01 -0700 Subject: [PATCH 132/195] one FINAL_LOCATION --- configure/CONFIG_COMMON | 2 ++ configure/CONFIG_SITE | 8 ++++++++ modules/database/src/std/softIoc/Makefile | 2 -- modules/database/src/tools/Makefile | 1 - 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/configure/CONFIG_COMMON b/configure/CONFIG_COMMON index 825725973..0f97e23a2 100644 --- a/configure/CONFIG_COMMON +++ b/configure/CONFIG_COMMON @@ -71,6 +71,8 @@ INSTALL_DBD = $(INSTALL_LOCATION)/dbd INSTALL_DB = $(INSTALL_LOCATION)/db INSTALL_CONFIG = $(INSTALL_LOCATION)/configure +FINAL_LOCATION = $(shell $(PERL) $(TOOLS)/fullPathName.pl $(INSTALL_LOCATION)) + # Directory for OS independant build created files COMMON_DIR = ../O.Common diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index a575c61bf..c6a049d6e 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -151,6 +151,14 @@ CROSS_WARN=YES # different location then uncomment and set this. #INSTALL_LOCATION= +# The location from which files placed in INSTALL_LOCATION will actually run. +# This path is compiled into executables, and so should be an absolute. +# May be used to achieve the effect of autotools. eg. +# ./configure --prefix= +# make DESTDIR= +# Defaults to the absolute expansion of $(INSTALL_LOCATION) +#FINAL_LOCATION= + # Use POSIX thread priority scheduling (if available). # Must be either YES or NO USE_POSIX_THREAD_PRIORITY_SCHEDULING = YES diff --git a/modules/database/src/std/softIoc/Makefile b/modules/database/src/std/softIoc/Makefile index a432d358d..35ef6cb34 100644 --- a/modules/database/src/std/softIoc/Makefile +++ b/modules/database/src/std/softIoc/Makefile @@ -28,7 +28,5 @@ softIoc_LIBS = $(EPICS_BASE_IOC_LIBS) DB += softIocExit.db -FINAL_LOCATION ?= $(shell $(PERL) $(TOOLS)/fullPathName.pl $(INSTALL_LOCATION)) - CLEANS += epicsInstallDir.h diff --git a/modules/database/src/tools/Makefile b/modules/database/src/tools/Makefile index f54ab9c07..41bf086d3 100644 --- a/modules/database/src/tools/Makefile +++ b/modules/database/src/tools/Makefile @@ -40,7 +40,6 @@ HTMLS += dbdToHtml.html # Build Package Config Files -FINAL_LOCATION ?= $(shell $(PERL) $(TOOLS)/fullPathName.pl $(INSTALL_LOCATION)) C_CFLAGS += $(filter-out -g,$(filter-out -O%,$(filter-out -W%,$(CPPFLAGS)))) C_CFLAGS += $(filter-out -g,$(filter-out -O%,$(filter-out -W%,$(CFLAGS)))) PKGVARS += FINAL_LOCATION OS_CLASS CMPLR_CLASS C_CFLAGS LDFLAGS LDLIBS From 315fb3df693b78ffb13d056d7c35ac6e6a83df29 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 12 May 2021 19:27:19 -0700 Subject: [PATCH 133/195] init scripts use FINAL_LOCATION --- modules/ca/src/client/Makefile | 2 +- modules/libcom/src/log/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/ca/src/client/Makefile b/modules/ca/src/client/Makefile index a8c0fed06..08394ea54 100644 --- a/modules/ca/src/client/Makefile +++ b/modules/ca/src/client/Makefile @@ -113,7 +113,7 @@ SCRIPTS_Linux = caRepeater.service EXPAND += S99caRepeater@ EXPAND += caRepeater.service@ -EXPAND_VARS = INSTALL_BIN=$(abspath $(INSTALL_BIN)) +EXPAND_VARS = INSTALL_BIN=$(FINAL_LOCATION)/bin/$(T_A) SRC_DIRS += $(CURDIR)/test PROD_HOST += ca_test diff --git a/modules/libcom/src/log/Makefile b/modules/libcom/src/log/Makefile index 2dcfbc516..74d173575 100644 --- a/modules/libcom/src/log/Makefile +++ b/modules/libcom/src/log/Makefile @@ -24,5 +24,5 @@ iocLogServer_SYS_LIBS_WIN32 += user32 ws2_32 dbghelp SCRIPTS_HOST = S99logServer EXPAND += S99logServer@ -EXPAND_VARS = INSTALL_BIN=$(abspath $(INSTALL_BIN)) +EXPAND_VARS = INSTALL_BIN=$(FINAL_LOCATION)/bin/$(T_A) From de3cdcef39051f83b0b263fa6d36129dcfdbe5ee Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Fri, 13 Nov 2020 14:03:23 -0800 Subject: [PATCH 134/195] softIoc: spin to keep alive --- modules/database/src/std/softIoc/softMain.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/database/src/std/softIoc/softMain.cpp b/modules/database/src/std/softIoc/softMain.cpp index cdb0f4a81..367e23ed8 100644 --- a/modules/database/src/std/softIoc/softMain.cpp +++ b/modules/database/src/std/softIoc/softMain.cpp @@ -249,7 +249,10 @@ int main(int argc, char *argv[]) } else { if (loadedDb || ranScript) { - epicsThreadExitMain(); + // non-interactive IOC. spin forever + while(true) { + epicsThreadSleep(1000.0); + } } else { usage(argv[0], dbd_file); From 1b8a1ebd072600389b9feef5d631ccf397c94767 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 17 Nov 2020 10:24:16 -0800 Subject: [PATCH 135/195] deprecate epicsThreadExitMain() --- modules/libcom/src/osi/epicsThread.h | 7 ++++++- modules/libcom/src/osi/os/RTEMS/osdThread.c | 2 ++ modules/libcom/src/osi/os/WIN32/osdThread.c | 3 ++- modules/libcom/src/osi/os/posix/osdThread.c | 4 ++++ modules/libcom/src/osi/os/vxWorks/osdThread.c | 3 ++- 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/libcom/src/osi/epicsThread.h b/modules/libcom/src/osi/epicsThread.h index f294c1d75..a9ad476b3 100644 --- a/modules/libcom/src/osi/epicsThread.h +++ b/modules/libcom/src/osi/epicsThread.h @@ -59,6 +59,7 @@ #include #include "libComAPI.h" +#include "compilerDependencies.h" #ifdef __cplusplus extern "C" { @@ -142,8 +143,12 @@ LIBCOM_API void epicsThreadRealtimeLock(void); * call this routine. This should be the last call in main, except the * final return. On most systems epicsThreadExitMain never returns.This * must only be called by the main thread. + * + * @deprecated Deprecated for lack of use. Please report any usage. + * Recommended replacement is loop + epicsThreadSleep(), + * epicsEventMustWait(), or similar. **/ -LIBCOM_API void epicsStdCall epicsThreadExitMain(void); +LIBCOM_API void epicsStdCall epicsThreadExitMain(void) EPICS_DEPRECATED; /** For use with epicsThreadCreateOpt() */ typedef struct epicsThreadOpts { diff --git a/modules/libcom/src/osi/os/RTEMS/osdThread.c b/modules/libcom/src/osi/os/RTEMS/osdThread.c index dd65692c6..71a532e62 100644 --- a/modules/libcom/src/osi/os/RTEMS/osdThread.c +++ b/modules/libcom/src/osi/os/RTEMS/osdThread.c @@ -219,6 +219,8 @@ threadWrapper (rtems_task_argument arg) */ void epicsThreadExitMain (void) { + cantProceed("epicsThreadExitMain() has been deprecated for lack of usage." + " Please report if you see this message."); } static rtems_status_code diff --git a/modules/libcom/src/osi/os/WIN32/osdThread.c b/modules/libcom/src/osi/os/WIN32/osdThread.c index 462c03f8f..fa3791682 100644 --- a/modules/libcom/src/osi/os/WIN32/osdThread.c +++ b/modules/libcom/src/osi/os/WIN32/osdThread.c @@ -260,7 +260,8 @@ static void epicsParmCleanupWIN32 ( win32ThreadParam * pParm ) */ LIBCOM_API void epicsStdCall epicsThreadExitMain ( void ) { - _endthread (); + cantProceed("epicsThreadExitMain() has been deprecated for lack of usage." + " Please report if you see this message."); } /* diff --git a/modules/libcom/src/osi/os/posix/osdThread.c b/modules/libcom/src/osi/os/posix/osdThread.c index 0eb5f5fd2..4c8f0edea 100644 --- a/modules/libcom/src/osi/os/posix/osdThread.c +++ b/modules/libcom/src/osi/os/posix/osdThread.c @@ -687,6 +687,10 @@ LIBCOM_API void epicsStdCall epicsThreadExitMain(void) epicsThreadOSD *pthreadInfo; epicsThreadInit(); + + cantProceed("epicsThreadExitMain() has been deprecated for lack of usage." + " Please report if you see this message."); + pthreadInfo = (epicsThreadOSD *)pthread_getspecific(getpthreadInfo); if(pthreadInfo==NULL) pthreadInfo = createImplicit(); diff --git a/modules/libcom/src/osi/os/vxWorks/osdThread.c b/modules/libcom/src/osi/os/vxWorks/osdThread.c index 56a8183e8..d0e087108 100644 --- a/modules/libcom/src/osi/os/vxWorks/osdThread.c +++ b/modules/libcom/src/osi/os/vxWorks/osdThread.c @@ -353,7 +353,8 @@ void epicsThreadResume(epicsThreadId id) void epicsThreadExitMain(void) { - errlogPrintf("epicsThreadExitMain was called for vxWorks. Why?\n"); + cantProceed("epicsThreadExitMain() has been deprecated for lack of usage." + " Please report if you see this message."); } unsigned int epicsThreadGetPriority(epicsThreadId id) From 379a68b93c8e4e4440de15392b1d58383ccfa24e Mon Sep 17 00:00:00 2001 From: Ralph Lange Date: Sun, 2 May 2021 18:39:18 +0200 Subject: [PATCH 136/195] Fix simmTest failures on targets with imprecise timing --- modules/database/test/std/rec/simmTest.c | 26 +++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/modules/database/test/std/rec/simmTest.c b/modules/database/test/std/rec/simmTest.c index 17e4d7fe4..1f4193378 100644 --- a/modules/database/test/std/rec/simmTest.c +++ b/modules/database/test/std/rec/simmTest.c @@ -12,9 +12,11 @@ #include #include #include +#include #include #include #include +#include #include "recSup.h" #include "aiRecord.h" @@ -414,6 +416,15 @@ void testSiolWrite(const char *name, * Asynchronous processing using simm:DELAY */ +static void +ping(CALLBACK *pcb) +{ + epicsEventId ev; + callbackGetUser(ev, pcb); + + epicsEventMustTrigger(ev); +} + static void testSimmDelay(const char *name, epicsFloat64 *psdly, @@ -422,6 +433,14 @@ void testSimmDelay(const char *name, epicsTimeStamp now; const double delay = 0.01; /* 10 ms */ double diff; + epicsEventId poked; + CALLBACK cb; + + memset(&cb, 0, sizeof(CALLBACK)); + poked = epicsEventMustCreate(epicsEventEmpty); + callbackSetCallback(ping, &cb); + callbackSetPriority(priorityLow, &cb); + callbackSetUser(poked, &cb); testDiag("## Asynchronous processing with simm:DELAY ##"); @@ -443,14 +462,11 @@ void testSimmDelay(const char *name, testdbPutFieldOk(namePROC, DBR_LONG, 0); testdbGetFieldEqual(namePACT, DBR_USHORT, 1); epicsTimeGetCurrent(&now); - epicsThreadSleep(1.75*delay); - if(testImpreciseTiming()) - testTodoBegin("imprecise"); + callbackRequestDelayed(&cb, 1.5 * delay); + epicsEventWait(poked); testdbGetFieldEqual(namePACT, DBR_USHORT, 0); diff = epicsTimeDiffInSeconds(mytime, &now); testOk(diff >= 0.0, "time stamp is recent (%.9f sec)", diff); - if(testImpreciseTiming()) - testTodoEnd(); /* Reset delay */ *psdly = -1.; From 8adf03f74af64bbc2a7fd47dfb0f8da3a2a34ddf Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 19 May 2021 09:44:38 -0700 Subject: [PATCH 137/195] update release notes --- documentation/RELEASE_NOTES.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 6c6699e7a..65c83e1f3 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -17,6 +17,30 @@ should also be read to understand what has changed since earlier releases. +### Formalize/fix `FINAL_LOCATION` + +The `FINAL_LOCATION` make variable has for some time been an undocumented +means of performing a staged build. This is a build which "installs" to +a temporary location, which will later be moved to a final location. + +This has now been added to `configure/CONFIG_SITE`. + +Usage analogous to the autotools recipe + +```sh +./configure --prefix=/usr/lib/epics +make install DESTDIR=/tmp/build +``` + +would be + +```sh +make INSTALL_LOCATION=/tmp/build FINAL_LOCATION=/usr/lib/epics +``` + +`FINAL_LOCATION` is now correctly used in systemd and sysv init scripts +`caRepeater.service`, `S99caRepeater`, and `S99logServer`. + ### IOCsh sets `${PWD}` IOC shell will now ensure `${PWD}` is set on startup, From 555e6712467732e5e7a9985093b58738990bad6d Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Fri, 16 Apr 2021 09:30:31 +0200 Subject: [PATCH 138/195] allow glob pattern in var command --- documentation/RELEASE_NOTES.md | 5 +++++ modules/libcom/src/iocsh/iocsh.cpp | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 65c83e1f3..792e67874 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -17,6 +17,11 @@ should also be read to understand what has changed since earlier releases. +### Glob pattern allowed in `var` command + +When used with one argument, the `var` command can be used with a glob pattern +for printing matching variables. + ### Formalize/fix `FINAL_LOCATION` The `FINAL_LOCATION` make variable has for some time been an undocumented diff --git a/modules/libcom/src/iocsh/iocsh.cpp b/modules/libcom/src/iocsh/iocsh.cpp index 474436c72..69313bd5e 100644 --- a/modules/libcom/src/iocsh/iocsh.cpp +++ b/modules/libcom/src/iocsh/iocsh.cpp @@ -1126,17 +1126,26 @@ static void varHandler(const iocshVarDef *v, const char *setString) static void varCallFunc(const iocshArgBuf *args) { struct iocshVariable *v; - if(args[0].sval == NULL) { + const char *name = args[0].sval; + const char *value = args[1].sval; + + if (!value) { + int found = 0; for (v = iocshVariableHead ; v != NULL ; v = v->next) - varHandler(v->pVarDef, args[1].sval); + if (!name || epicsStrGlobMatch(v->pVarDef->name, name) != 0) { + varHandler(v->pVarDef, NULL); + found = 1; + } + if (!found && name != NULL) + fprintf(epicsGetStderr(), "No var matching %s found.\n", name); } else { v = (iocshVariable *)registryFind(iocshVarID, args[0].sval); if (v == NULL) { - fprintf(epicsGetStderr(), "Var %s not found.\n", args[0].sval); + fprintf(epicsGetStderr(), "Var %s not found.\n", name); } else { - varHandler(v->pVarDef, args[1].sval); + varHandler(v->pVarDef, value); } } } From f8e720da2838a68556ccd1c2eeca9688cc0905c6 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 19 Apr 2021 10:55:24 -0700 Subject: [PATCH 139/195] posix: osiSpawnDetachedProcess() find out if exec() errors. Presently, success just means fork() --- modules/libcom/src/osi/os/posix/osdProcess.c | 40 ++++++++++++++++++-- 1 file changed, 36 insertions(+), 4 deletions(-) diff --git a/modules/libcom/src/osi/os/posix/osdProcess.c b/modules/libcom/src/osi/os/posix/osdProcess.c index 56267d0b8..9f33cb10b 100644 --- a/modules/libcom/src/osi/os/posix/osdProcess.c +++ b/modules/libcom/src/osi/os/posix/osdProcess.c @@ -24,7 +24,9 @@ #include #include #include +#include #include +#include #include "osiProcess.h" #include "errlog.h" @@ -61,12 +63,18 @@ LIBCOM_API osiSpawnDetachedProcessReturn epicsStdCall osiSpawnDetachedProcess (const char *pProcessName, const char *pBaseExecutableName) { int status; + int fds[2]; /* [reader, writer] */ + + if(pipe(fds)) + return osiSpawnDetachedProcessFail; /* * create a duplicate process */ status = fork (); if (status < 0) { + close(fds[0]); + close(fds[1]); return osiSpawnDetachedProcessFail; } @@ -75,11 +83,29 @@ LIBCOM_API osiSpawnDetachedProcessReturn epicsStdCall osiSpawnDetachedProcess * in the initiating (parent) process */ if (status) { - return osiSpawnDetachedProcessSuccess; - } + osiSpawnDetachedProcessReturn ret = osiSpawnDetachedProcessSuccess; + char buf; + ssize_t n; + close(fds[1]); - /* - * This is executed only by the new child process. + n = read(fds[0], &buf, 1); + /* Success if child exec'd without sending a '!'. + * Of course child may crash soon after, but can't + * wait around for this to happen. + */ + if(n!=0) { + ret = osiSpawnDetachedProcessFail; + } + + close(fds[0]); + return ret; + } + close(fds[0]); + (void)fcntl ( fds[1], F_SETFD, FD_CLOEXEC ); + + /* This is executed only by the new child process. + * Since we may be called from a library, we don't assume that + * all other code has set properly set FD_CLOEXEC. * Close all open files except for STDIO, so they will not * be inherited by the new program. */ @@ -89,6 +115,8 @@ LIBCOM_API osiSpawnDetachedProcessReturn epicsStdCall osiSpawnDetachedProcess if (fd==STDIN_FILENO) continue; if (fd==STDOUT_FILENO) continue; if (fd==STDERR_FILENO) continue; + /* pipe to our parent will be closed automatically via FD_CLOEXEC */ + if (fd==fds[1]) continue; close (fd); } } @@ -115,6 +143,10 @@ LIBCOM_API osiSpawnDetachedProcessReturn epicsStdCall osiSpawnDetachedProcess fprintf ( stderr, "**** You may need to modify your PATH environment variable.\n" ); fprintf ( stderr, "**** Unable to start \"%s\" process.\n", pProcessName); } + /* signal error to parent */ + ssize_t ret = write(fds[1], "!", 1); + (void)ret; /* not much we could do about this */ + close(fds[1]); /* Don't run our parent's atexit() handlers */ _exit ( -1 ); } From a9457fc02b8ddccb28252c343b8dbee83dd6bf31 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 19 Apr 2021 10:59:50 -0700 Subject: [PATCH 140/195] osiSpawnDetachedProcess() prefix process name with '!' to silence warning --- modules/libcom/src/osi/os/WIN32/osdProcess.c | 6 +++++- modules/libcom/src/osi/os/posix/osdProcess.c | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/libcom/src/osi/os/WIN32/osdProcess.c b/modules/libcom/src/osi/os/WIN32/osdProcess.c index 0f137bf37..cff1ed4bd 100644 --- a/modules/libcom/src/osi/os/WIN32/osdProcess.c +++ b/modules/libcom/src/osi/os/WIN32/osdProcess.c @@ -50,10 +50,14 @@ LIBCOM_API osiGetUserNameReturn epicsStdCall osiGetUserName (char *pBuf, unsigne LIBCOM_API osiSpawnDetachedProcessReturn epicsStdCall osiSpawnDetachedProcess ( const char *pProcessName, const char *pBaseExecutableName ) { + BOOL silent = pProcessName && pProcessName[0]=='!'; BOOL status; STARTUPINFO startupInfo; PROCESS_INFORMATION processInfo; + if(silent) + pProcessName++; /* skip '!' */ + GetStartupInfo ( &startupInfo ); startupInfo.lpReserved = NULL; startupInfo.lpTitle = (char *) pProcessName; @@ -115,7 +119,7 @@ LIBCOM_API osiSpawnDetachedProcessReturn epicsStdCall osiSpawnDetachedProcess /* Free the buffer. */ LocalFree (errStrMsgBuf); } - else { + else if(!silent) { fprintf (stderr, "!!WARNING!!\n"); fprintf (stderr, "Unable to locate executable \"%s\".\n", pBaseExecutableName); fprintf (stderr, "You may need to modify your \"path\" environment variable.\n"); diff --git a/modules/libcom/src/osi/os/posix/osdProcess.c b/modules/libcom/src/osi/os/posix/osdProcess.c index 9f33cb10b..b2c26beb4 100644 --- a/modules/libcom/src/osi/os/posix/osdProcess.c +++ b/modules/libcom/src/osi/os/posix/osdProcess.c @@ -63,8 +63,12 @@ LIBCOM_API osiSpawnDetachedProcessReturn epicsStdCall osiSpawnDetachedProcess (const char *pProcessName, const char *pBaseExecutableName) { int status; + int silent = pProcessName && pProcessName[0]=='!'; int fds[2]; /* [reader, writer] */ + if(silent) + pProcessName++; /* skip '!' */ + if(pipe(fds)) return osiSpawnDetachedProcessFail; @@ -137,7 +141,7 @@ LIBCOM_API osiSpawnDetachedProcessReturn epicsStdCall osiSpawnDetachedProcess * Run the specified executable */ status = execlp (pBaseExecutableName, pBaseExecutableName, (char *)NULL); - if ( status < 0 ) { + if ( status < 0 && !silent ) { fprintf ( stderr, "**** The executable \"%s\" couldn't be located\n", pBaseExecutableName ); fprintf ( stderr, "**** because of errno = \"%s\".\n", strerror (errno) ); fprintf ( stderr, "**** You may need to modify your PATH environment variable.\n" ); From 08b741ed056297d22665d576df6b7a4f0d5c1e8a Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 19 Apr 2021 11:08:49 -0700 Subject: [PATCH 141/195] ca: fallback to repeater thread if unable to exec caRepeater Silently fallback to in-process repeater thread on all targets. Including on host targets when caRepeater executable is unavailable. --- documentation/RELEASE_NOTES.md | 16 ++++++++++++++++ modules/ca/src/client/udpiiu.cpp | 7 ++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 792e67874..8e17ce35d 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -17,6 +17,22 @@ should also be read to understand what has changed since earlier releases. +### Automatic fallback to thread when unable to exec caRepeater + +A process using libca which does not find an existing caRepeater process +will attempt to start one by running the caRepeater executable. +This is not always possible, usually when caRepeater is not in `$PATH`. +Now, instead of printing a warning, an internal caRepeater thread +will be started (as is done be RTEMS and vxWorks targets). + +If this fallback occurs, the lifetime of the caRepeater thread +may be shorter than the lifetime of a separate caRepeater process +would have been. + +It remains the recommended practice to explicitly start a caRepeater +instance. Examples of both systemd (`caRepeater.service`) and sysv +(`S99caRepeater`) scripts may be found under `bin/`. + ### Glob pattern allowed in `var` command When used with one argument, the `var` command can be used with a glob pattern diff --git a/modules/ca/src/client/udpiiu.cpp b/modules/ca/src/client/udpiiu.cpp index ba1caa99b..723117a71 100644 --- a/modules/ca/src/client/udpiiu.cpp +++ b/modules/ca/src/client/udpiiu.cpp @@ -629,8 +629,8 @@ void epicsStdCall caStartRepeaterIfNotInstalled ( unsigned repeaterPort ) * repeater's port) */ osiSpawnDetachedProcessReturn osptr = - osiSpawnDetachedProcess ( "CA Repeater", "caRepeater" ); - if ( osptr == osiSpawnDetachedProcessNoSupport ) { + osiSpawnDetachedProcess ( "!CA Repeater", "caRepeater" ); + if ( osptr != osiSpawnDetachedProcessSuccess ) { epicsThreadId tid; tid = epicsThreadCreate ( "CAC-repeater", epicsThreadPriorityLow, @@ -639,9 +639,6 @@ void epicsStdCall caStartRepeaterIfNotInstalled ( unsigned repeaterPort ) fprintf ( stderr, "caStartRepeaterIfNotInstalled : unable to create CA repeater daemon thread\n" ); } } - else if ( osptr == osiSpawnDetachedProcessFail ) { - fprintf ( stderr, "caStartRepeaterIfNotInstalled (): unable to start CA repeater daemon detached process\n" ); - } } } From b777233efb06fa4e988c4f0738b0270dd3d095a3 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Sun, 18 Apr 2021 18:04:48 +0200 Subject: [PATCH 142/195] Support glob pattern for epicsEnvShow Add epicsStrnGlobMatch with tests --- documentation/RELEASE_NOTES.md | 10 ++++++ modules/libcom/src/misc/epicsString.c | 34 +++++++++++++------ modules/libcom/src/misc/epicsString.h | 23 +++++++++++++ modules/libcom/src/osi/os/WIN32/osdEnv.c | 16 +++------ modules/libcom/src/osi/os/default/osdEnv.c | 17 +++------- modules/libcom/src/osi/os/vxWorks/osdEnv.c | 21 ++++++------ modules/libcom/test/epicsStringTest.c | 39 +++++++++++++++++++++- 7 files changed, 114 insertions(+), 46 deletions(-) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 8e17ce35d..c9272f3c7 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -17,6 +17,16 @@ should also be read to understand what has changed since earlier releases. +### epicsEnvShow accepts glob pattern + +The optional argument to epicsEnvShow can now be a glob pattern. + +### New function `epicsStrnGlobMatch()` + +The function `epicsStrnGlobMatch(char* str, size_t len, char* pattern)` +works exactly the same as `epicsStrGlobMatch()` but takes an additional +length arguments which limits the number of characters of `str` to match. + ### Automatic fallback to thread when unable to exec caRepeater A process using libca which does not find an existing caRepeater process diff --git a/modules/libcom/src/misc/epicsString.c b/modules/libcom/src/misc/epicsString.c index e18d9214a..be6463438 100644 --- a/modules/libcom/src/misc/epicsString.c +++ b/modules/libcom/src/misc/epicsString.c @@ -23,6 +23,15 @@ #include #include +#ifndef vxWorks +#include +#else +/* VxWorks automaticaly includes stdint.h defining SIZE_MAX in 6.9 but not earlier */ +#ifndef SIZE_MAX +#define SIZE_MAX (size_t)-1 +#endif +#endif + #include "epicsAssert.h" #include "epicsStdio.h" #include "cantProceed.h" @@ -259,30 +268,31 @@ size_t epicsStrnLen(const char *s, size_t maxlen) return i; } -int epicsStrGlobMatch(const char *str, const char *pattern) +int epicsStrnGlobMatch(const char *str, size_t len, const char *pattern) { - const char *cp = NULL, *mp = NULL; + const char *mp = NULL; + size_t cp = 0, i = 0; - while ((*str) && (*pattern != '*')) { - if ((*pattern != *str) && (*pattern != '?')) + while ((i < len) && (str[i]) && (*pattern != '*')) { + if ((*pattern != str[i]) && (*pattern != '?')) return 0; pattern++; - str++; + i++; } - while (*str) { + while ((i < len) && str[i]) { if (*pattern == '*') { if (!*++pattern) return 1; mp = pattern; - cp = str+1; + cp = i+1; } - else if ((*pattern == *str) || (*pattern == '?')) { + else if ((*pattern == str[i]) || (*pattern == '?')) { pattern++; - str++; + i++; } else { pattern = mp; - str = cp++; + i = cp++; } } while (*pattern == '*') @@ -290,6 +300,10 @@ int epicsStrGlobMatch(const char *str, const char *pattern) return !*pattern; } +int epicsStrGlobMatch(const char *str, const char *pattern) { + return epicsStrnGlobMatch(str, SIZE_MAX, pattern); +} + char * epicsStrtok_r(char *s, const char *delim, char **lasts) { const char *spanp; diff --git a/modules/libcom/src/misc/epicsString.h b/modules/libcom/src/misc/epicsString.h index 854b552c6..5bb8c87c1 100644 --- a/modules/libcom/src/misc/epicsString.h +++ b/modules/libcom/src/misc/epicsString.h @@ -36,7 +36,30 @@ LIBCOM_API char * epicsStrnDup(const char *s, size_t len); LIBCOM_API int epicsStrPrintEscaped(FILE *fp, const char *s, size_t n); #define epicsStrSnPrintEscaped epicsStrnEscapedFromRaw LIBCOM_API size_t epicsStrnLen(const char *s, size_t maxlen); + +/** Matches a string against a pattern. + * + * Checks if str matches the glob style pattern, which may contain ? or * wildcards. + * A ? matches any single character. + * A * matched any sub-string. + * + * @returns 1 if str matches the pattern, 0 if not. + * + * @since EPICS 3.14.7 + */ LIBCOM_API int epicsStrGlobMatch(const char *str, const char *pattern); + +/** Matches a string against a pattern. + * + * Like epicsStrGlobMatch but with limited string length. + * If the length of str is less than len, the full string is matched. + * + * @returns 1 if the first len characters of str match the pattern, 0 if not. + * + * @since UNRELEASED + */ +LIBCOM_API int epicsStrnGlobMatch(const char *str, size_t len, const char *pattern); + LIBCOM_API char * epicsStrtok_r(char *s, const char *delim, char **lasts); LIBCOM_API unsigned int epicsStrHash(const char *str, unsigned int seed); LIBCOM_API unsigned int epicsMemHash(const char *str, size_t length, diff --git a/modules/libcom/src/osi/os/WIN32/osdEnv.c b/modules/libcom/src/osi/os/WIN32/osdEnv.c index adc40b58c..18e66cb6b 100644 --- a/modules/libcom/src/osi/os/WIN32/osdEnv.c +++ b/modules/libcom/src/osi/os/WIN32/osdEnv.c @@ -15,11 +15,11 @@ #include #include -#include #include #include #include "epicsStdio.h" +#include "epicsString.h" #include "errlog.h" #include "envDefs.h" #include "osiUnistd.h" @@ -61,18 +61,10 @@ LIBCOM_API void epicsStdCall epicsEnvUnset (const char *name) */ LIBCOM_API void epicsStdCall epicsEnvShow (const char *name) { - if (name == NULL) { - extern char **environ; - char **sp; + char **sp; - for (sp = environ ; (sp != NULL) && (*sp != NULL) ; sp++) + for (sp = environ ; (sp != NULL) && (*sp != NULL) ; sp++) { + if (!name || epicsStrnGlobMatch(*sp, strchr(*sp, '=') - *sp, name)) printf ("%s\n", *sp); } - else { - const char *cp = getenv (name); - if (cp == NULL) - printf ("%s is not an environment variable.\n", name); - else - printf ("%s=%s\n", name, cp); - } } diff --git a/modules/libcom/src/osi/os/default/osdEnv.c b/modules/libcom/src/osi/os/default/osdEnv.c index 7ece253c7..74b5b8041 100644 --- a/modules/libcom/src/osi/os/default/osdEnv.c +++ b/modules/libcom/src/osi/os/default/osdEnv.c @@ -15,11 +15,11 @@ #include #include -#include #include #include #include "epicsStdio.h" +#include "epicsString.h" #include "epicsVersion.h" #include "errlog.h" #include "envDefs.h" @@ -68,18 +68,11 @@ LIBCOM_API void epicsStdCall epicsEnvUnset (const char *name) */ LIBCOM_API void epicsStdCall epicsEnvShow (const char *name) { - if (name == NULL) { - extern char **environ; - char **sp; + extern char **environ; + char **sp; - for (sp = environ ; (sp != NULL) && (*sp != NULL) ; sp++) + for (sp = environ ; (sp != NULL) && (*sp != NULL) ; sp++) { + if (!name || epicsStrnGlobMatch(*sp, strchr(*sp, '=') - *sp, name)) printf ("%s\n", *sp); } - else { - const char *cp = getenv (name); - if (cp == NULL) - printf ("%s is not an environment variable.\n", name); - else - printf ("%s=%s\n", name, cp); - } } diff --git a/modules/libcom/src/osi/os/vxWorks/osdEnv.c b/modules/libcom/src/osi/os/vxWorks/osdEnv.c index d91208f4c..517bb2bd6 100644 --- a/modules/libcom/src/osi/os/vxWorks/osdEnv.c +++ b/modules/libcom/src/osi/os/vxWorks/osdEnv.c @@ -16,17 +16,18 @@ /* This is needed for vxWorks 6.8 to prevent an obnoxious compiler warning */ #define _VSB_CONFIG_FILE <../lib/h/config/vsbConfig.h> -#include #include -#include +#include #include #include #include "epicsFindSymbol.h" #include "epicsStdio.h" +#include "epicsString.h" #include "errlog.h" #include "iocsh.h" + /* * Set the value of an environment variable * Leaks memory, but the assumption is that this routine won't be @@ -86,14 +87,12 @@ LIBCOM_API void epicsStdCall epicsEnvUnset (const char *name) */ LIBCOM_API void epicsStdCall epicsEnvShow (const char *name) { - if (name == NULL) { - envShow (0); - } - else { - const char *cp = getenv (name); - if (cp == NULL) - printf ("%s is not an environment variable.\n", name); - else - printf ("%s=%s\n", name, cp); + extern char **ppGlobalEnviron; /* Used in 'environ' macro but not declared in envLib.h */ + char **sp; + + for (sp = environ ; (sp != NULL) && (*sp != NULL) ; sp++) { + if (!**sp) continue; /* skip unset environment variables */ + if (!name || epicsStrnGlobMatch(*sp, strchr(*sp, '=') - *sp, name)) + printf ("%s\n", *sp); } } diff --git a/modules/libcom/test/epicsStringTest.c b/modules/libcom/test/epicsStringTest.c index e4e95c998..7abffa3da 100644 --- a/modules/libcom/test/epicsStringTest.c +++ b/modules/libcom/test/epicsStringTest.c @@ -73,6 +73,43 @@ void testGlob(void) { testOk1(epicsStrGlobMatch("hello","he*")); testOk1(epicsStrGlobMatch("hello","*lo")); testOk1(epicsStrGlobMatch("hello","*")); + +/* epicsStrnGlobMatch */ + + testOk1(epicsStrnGlobMatch("xyzq",3,"xyz")); + testOk1(!epicsStrnGlobMatch("xyzq",3,"xyzm")); + testOk1(!epicsStrnGlobMatch("xyzm",3,"xyzm")); + testOk1(!epicsStrnGlobMatch("xyzm",0,"xyzm")); + testOk1(!epicsStrnGlobMatch("xyzq",3,"")); + testOk1(epicsStrnGlobMatch("xyz",0,"")); + + testOk1(epicsStrnGlobMatch("xyz",0,"*")); + testOk1(!epicsStrnGlobMatch("xyz",0,"?")); + testOk1(!epicsStrnGlobMatch("xyz",0,"?*")); + + testOk1(epicsStrnGlobMatch("hello!",5,"h*o")); + testOk1(!epicsStrnGlobMatch("hello!",5,"h*x")); + testOk1(!epicsStrnGlobMatch("hellxo",5,"h*o")); + + testOk1(epicsStrnGlobMatch("hello!",5,"he?lo")); + testOk1(!epicsStrnGlobMatch("hello!",5,"he?xo")); + testOk1(epicsStrnGlobMatch("hello!",5,"he??o")); + testOk1(!epicsStrnGlobMatch("helllo!",5,"he?lo")); + + testOk1(!epicsStrnGlobMatch("hello world!",10,"he*o w*d")); + testOk1(epicsStrnGlobMatch("hello world!",11,"he*o w*d")); + testOk1(!epicsStrnGlobMatch("hello world!",12,"he*o w*d")); + testOk1(!epicsStrnGlobMatch("hello_world!",11,"he*o w*d")); + testOk1(epicsStrnGlobMatch("hello world!",11,"he**d")); + + testOk1(epicsStrnGlobMatch("hello hello world!!!!!!!!!!!!!!!!!!!!",17,"he*o w*d")); + + testOk1(!epicsStrnGlobMatch("hello hello world",15,"he*o w*d")); + + testOk1(epicsStrnGlobMatch("hello!!",5,"he*")); + testOk1(epicsStrnGlobMatch("hello!!",5,"*lo")); + testOk1(epicsStrnGlobMatch("hello!!",5,"*")); + } static @@ -118,7 +155,7 @@ MAIN(epicsStringTest) char *s; int status; - testPlan(401); + testPlan(427); testChars(); From 457febb3a61c222ec62cbc61603422c01e0b6256 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 20 May 2021 13:28:30 -0500 Subject: [PATCH 143/195] Fix implicit declaration of memcpy() --- modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c b/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c index fdbfb2c46..e3713de44 100644 --- a/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c +++ b/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c @@ -20,6 +20,7 @@ #include "devLibVME.h" #include #include +#include #if defined(__PPC__) || defined(__mcf528x__) From 38c146d89df2bb5d901aa7d414cd5c925ad3ca66 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 4 Jun 2021 13:27:10 -0500 Subject: [PATCH 144/195] RTEMS-uC5282 BSP provides bspExtMemProbe() --- modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c b/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c index e3713de44..b2ee5e220 100644 --- a/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c +++ b/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c @@ -23,6 +23,9 @@ #include #if defined(__PPC__) || defined(__mcf528x__) +/* EPICS VME support requires various routines to be provided by the + * BSP. Most MVME PowerPC BSPs provide them, plus the uC5282. + */ #if defined(__PPC__) #include @@ -245,6 +248,12 @@ static long rtemsDevMapAddr (epicsAddressType addrType, unsigned options, return 0; } +#if defined(__m68k__) +/* All RTEMS m68k BSPs define this, m68k/shared/[misc/]memProbe.c */ +extern +rtems_status_code bspExtMemProbe(void *addr, int write, int size, void *pval); +#else + static rtems_status_code bspExtMemProbe(void *addr, int write, int size, void *pval) { @@ -293,6 +302,7 @@ rtems_status_code bspExtMemProbe(void *addr, int write, int size, void *pval) return ret; } +#endif /* * a bus error safe "wordSize" read at the specified address which returns From 75caf83194d0b6dc19c6ec82c3a2590e661a97d9 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 4 Jun 2021 13:27:54 -0500 Subject: [PATCH 145/195] Fix old comments --- modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c b/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c index b2ee5e220..ed310eebc 100644 --- a/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c +++ b/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c @@ -312,9 +312,6 @@ static long rtemsDevReadProbe (unsigned wordSize, volatile const void *ptr, void { long status; - /* - * this global variable exists in the nivxi library - */ status = bspExtMemProbe ((void*)ptr, 0/*read*/, wordSize, pValue); if (status!=RTEMS_SUCCESSFUL) { return S_dev_noDevice; @@ -331,9 +328,6 @@ static long rtemsDevWriteProbe (unsigned wordSize, volatile void *ptr, const voi { long status; - /* - * this global variable exists in the nivxi library - */ status = bspExtMemProbe ((void*)ptr, 1/*write*/, wordSize, (void*)pValue); if (status!=RTEMS_SUCCESSFUL) { return S_dev_noDevice; @@ -417,7 +411,7 @@ devLibVME *pdevLibVME; #endif /* defined(__PPC__) || defined(__mcf528x__) */ /* - * Some vxWorks convenience routines + * Some convenience routines */ void bcopyLongs(char *source, char *destination, int nlongs) From e4ce0ec2553952a88444baf231a9f3a01c0a7145 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 4 Jun 2021 15:58:29 -0500 Subject: [PATCH 146/195] Adjust Max FDs to match newlib --- modules/libcom/RTEMS/posix/rtems_config.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/libcom/RTEMS/posix/rtems_config.c b/modules/libcom/RTEMS/posix/rtems_config.c index d0a123b6d..c9fa8a8d7 100644 --- a/modules/libcom/RTEMS/posix/rtems_config.c +++ b/modules/libcom/RTEMS/posix/rtems_config.c @@ -60,7 +60,8 @@ extern void *POSIX_Init(void *argument); #define CONFIGURE_APPLICATION_NEEDS_STUB_DRIVER #define CONFIGURE_APPLICATION_NEEDS_ZERO_DRIVER -#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 150 +/* Max FDs cannot exceed FD_SETSIZE from newlib (64) */ +#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 64 #define CONFIGURE_IMFS_ENABLE_MKFIFO 2 #define CONFIGURE_MAXIMUM_NFS_MOUNTS 3 From e8512ceba0d45c2447c2925f0a693208e127986a Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 4 Jun 2021 15:59:13 -0500 Subject: [PATCH 147/195] Drop pragma message in rtems_init --- modules/libcom/RTEMS/posix/rtems_init.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/modules/libcom/RTEMS/posix/rtems_init.c b/modules/libcom/RTEMS/posix/rtems_init.c index d8a836a64..09c7d60a5 100644 --- a/modules/libcom/RTEMS/posix/rtems_init.c +++ b/modules/libcom/RTEMS/posix/rtems_init.c @@ -83,10 +83,7 @@ #include "epicsRtemsInitHooks.h" -#ifdef RTEMS_LEGACY_STACK -#pragma message "RTEMS uses legacy stack" -#else -#pragma message "RTEMS uses libbsd stack" +#ifndef RTEMS_LEGACY_STACK // setup own ntp-client to get time #include "epicsNtp.h" epicsEventId dhcpDone; From c7eb41abbcfbc6412cb2168f5963313ffa54d1f5 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 4 Jun 2021 16:31:54 -0500 Subject: [PATCH 148/195] Attempt to fix GHA config file --- .github/workflows/ci-scripts-build.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index 855569578..ef1519af1 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -95,14 +95,6 @@ jobs: test: NO name: "Ub-20 gcc-9 + RT-5.1 beatnik" - # - os: ubuntu-20.04 - # cmp: gcc - # configuration: default - # rtems: "5" - # rtems_target: RTEMS-mvme2100 - # test: NO - # name: "Ub-20 gcc-9 + RT-5.1 mvme2100" - - os: ubuntu-20.04 cmp: gcc configuration: default From 57fab5104f4239856d29392f076cdc4ea7796b40 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 4 Jun 2021 16:36:23 -0500 Subject: [PATCH 149/195] Fixed indentation in GHA config file --- .github/workflows/ci-scripts-build.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index ef1519af1..d94fbf312 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -119,13 +119,13 @@ jobs: test: NO name: "Ub-20 gcc-9 + RT-5.1 xilinx_zynq_a9_qemu" - - os: ubuntu-20.04 - cmp: gcc - configuration: default - rtems: "5" - rtems_target: RTEMS-uC5282 - test: NO - name: "Ub-20 gcc-9 + RT-5.1 uC5282" + - os: ubuntu-20.04 + cmp: gcc + configuration: default + rtems: "5" + rtems_target: RTEMS-uC5282 + test: NO + name: "Ub-20 gcc-9 + RT-5.1 uC5282" - os: ubuntu-20.04 cmp: gcc From c5c6facc3e4e1071d104fac13b240e7e439e43c8 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 4 Jun 2021 18:03:37 -0500 Subject: [PATCH 150/195] Update Release Notes for RTEMS-5 port --- documentation/RELEASE_NOTES.md | 95 ++++++++++++++++++++-------------- 1 file changed, 56 insertions(+), 39 deletions(-) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index f3b063ea9..d932a0323 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -17,7 +17,62 @@ should also be read to understand what has changed since earlier releases. -### epicsEnvShow accepts glob pattern +### Experimental Support for RTEMS 5 + +The new major release of the RTEMS real-time OS contains many changes +including the ability to support SMP systems. This release of EPICS +can still be built with RTEMS 4.9.x or 4.10.x and should work just +the same as earlier releases, although due to code having moved around +we recommend thorough testing before this release is first used in +production systems. + +This release of EPICS comes with support for several new RTEMS targets +running on RTEMS 5: + +- RTEMS-beagleboneblack +- RTEMS-pc686 +- RTEMS-qoriq_e500 (MVME2500) +- RTEMS-xilinx-zynq-a9_qemu +- RTEMS-xilinx_zynq_zedboard + +The EPICS support for RTEMS 4 has always relied on RTEMS-specific +kernel APIs which cannot be used on an SMP system, so a new port was +created to use the Posix real-time APIs that are now recommended for +RTEMS 5. Note that a single installation of EPICS cannot build both +RTEMS 4 and RTEMS 5 targets, if you need to support targets running +on both versions you must use a separate installation, and be sure +to run `make distclean` if switching a single source tree from one +to the other (both header files and dependency files are different +between the two and must be cleaned out). + +The configuration variable RTEMS_VERSION in the EPICS config file +`configure/os/CONFIG_SITE.Common.RTEMS` must be set to the full 3- +part version number for RTEMS 4 releases, e.g. `4.9.1`, `4.10.2` +but for RTEMS 5.1 and later it must only contain the major version +number e.g. `5`. + +Some RTEMS BSPs can be built and may work with the newer libbsd +network stack which RTEMS is moving over to, but most of the MVME +boards (and the uC5282) still require the legacy network stack. + +The dependency on bspExt has been removed, EPICS now provides its +own routine for VMEbus probing (or uses one built into the BSP). + +Anyone using this release on RTEMS is advised to discuss problems +building or running it on either the tech-talk or core-talk email +lists so the core developers can help with and find out about any +problems with the old or new port. + +Known Issues: +- MVME2100 and MVME2700 need changes to the RTEMS 5 BSP to build. +- VMEBus support is not yet available for the MVME2500 BSP. +- There are some known issues with floating point on MVME2500, + probably related to its newer e500 FPU. +- Changed network driver for beatnik to work with libbsd. Some + issues with DHCP, but network stack usable. Can load env from + NVRAM. + +### `epicsEnvShow` accepts a glob pattern The optional argument to epicsEnvShow can now be a glob pattern. @@ -188,44 +243,6 @@ Test programs written directly in Perl as a `.plt` script should implement a similar timeout for themselves. The "netget" test in Base does this in a way that works on Windows as well as Unix-like hosts. -### Experimental Support for RTEMS 5 -The new major release of the RTEMS real-time OS contains many changes -including the ability to support SMP systems and support for several -new targets: - -- RTEMS-beagleboneblack -- RTEMS-pc686 -- RTEMS-qoriq_e500 -- RTEMS-xilinx-zynq-a9_qemu -- RTEMS-xilinx_zynq_zedboard - -The earlier EPICS support for RTEMS made use of various -RTEMS-specific kernel APIs which cannot be used on an SMP system, so -the changes here required a completely new port to the Posix -real-time APIs that RTEMS-5 now recommends. - -A new RTEMS configuration variable RTEMS_VERSION has been added which -should be set to the OS version number, e.g. 4.9. When this is 4.12 -or greater, true for 5.1 as well, the new libCom/osi/os/RTEMS-posix -source files will be used; the older API source files can now be -found in libCom/osi/os/RTEMS-kernel, and those which are common to -both installations are in libCom/osi/os/RTEMS. The compiler options -are read from the Makefile.inc of the corresponding BSP and set in -the configuration files. It checks that the BSP was also built with -the --enable-posix option. It also checks if the BSP was built with -the legacy stack or libbsd. - -The dependency on bspExt has been removed. RTEMS 5 provides the bus -support natively now. - -Known Issues: -- MVME2100, MVME167, and uC5282 have not yet been updated to compile for RTEMS 5. -- VMEBus support is not available for all powerpc BSPs. -- There are some known issues with floating point on MVME2500 -- Changed network driver for beatnik to work with libbsd. Some - issues with DHCP, but network stack usable. Can load env from - NVRAM. - ----- ## EPICS Release 7.0.5 From c6247329ab562b66680c96e672909b8cae685ef8 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 4 Jun 2021 18:29:01 -0500 Subject: [PATCH 151/195] Fix warning when not using CLOEXEC --- modules/libcom/src/osi/os/posix/osdSock.c | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/libcom/src/osi/os/posix/osdSock.c b/modules/libcom/src/osi/os/posix/osdSock.c index 52f52a085..4ebd0db73 100644 --- a/modules/libcom/src/osi/os/posix/osdSock.c +++ b/modules/libcom/src/osi/os/posix/osdSock.c @@ -36,6 +36,7 @@ /* with glibc, SOCK_CLOEXEC does not expand to a simple constant */ # define HAVE_SOCK_CLOEXEC #else +# undef SOCK_CLOEXEC # define SOCK_CLOEXEC (0) #endif From 1b825da9ece2f8af1bb52ad958a96180d1aab1da Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 4 Jun 2021 18:29:29 -0500 Subject: [PATCH 152/195] Add missing dependency --- modules/database/test/ioc/db/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/database/test/ioc/db/Makefile b/modules/database/test/ioc/db/Makefile index 664291641..11f74f238 100644 --- a/modules/database/test/ioc/db/Makefile +++ b/modules/database/test/ioc/db/Makefile @@ -209,6 +209,7 @@ arrRecord$(DEP): $(COMMON_DIR)/arrRecord.h dbCaLinkTest$(DEP): $(COMMON_DIR)/xRecord.h $(COMMON_DIR)/arrRecord.h dbDbLinkTest$(DEP): $(COMMON_DIR)/xRecord.h dbPutLinkTest$(DEP): $(COMMON_DIR)/xRecord.h +dbPutGetTest$(DEP): $(COMMON_DIR)/xRecord.h dbStressLock$(DEP): $(COMMON_DIR)/xRecord.h devx$(DEP): $(COMMON_DIR)/xRecord.h scanIoTest$(DEP): $(COMMON_DIR)/xRecord.h From 8e468da4ccbb3858322afa056062eead4ea61dd3 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 5 Jun 2021 01:34:03 -0500 Subject: [PATCH 153/195] Rename RTEMS-kernel to RTEMS-score (OS_API) --- configure/os/CONFIG.Common.RTEMS | 6 +++--- configure/toolchain.c | 2 +- modules/libcom/RTEMS/{kernel => score}/rtems_config.c | 0 modules/libcom/RTEMS/{kernel => score}/rtems_init.c | 0 modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c | 6 +++--- .../src/osi/os/{RTEMS-kernel => RTEMS-score}/devLibVMEOSD.c | 0 .../osi/os/{RTEMS-kernel => RTEMS-score}/epicsAtomicOSD.cpp | 0 .../osi/os/{RTEMS-kernel => RTEMS-score}/epicsAtomicOSD.h | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/epicsMath.h | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osdEvent.c | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osdEvent.h | 0 .../osi/os/{RTEMS-kernel => RTEMS-score}/osdFindSymbol.c | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osdMutex.c | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osdMutex.h | 0 .../osi/os/{RTEMS-kernel => RTEMS-score}/osdPoolStatus.c | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osdProcess.c | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osdReadline.c | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osdSignal.cpp | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osdSock.h | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osdSpin.c | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osdStrtod.h | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osdThread.c | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osdThread.h | 0 .../osi/os/{RTEMS-kernel => RTEMS-score}/osdThreadExtra.c | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osdTime.cpp | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osdTime.h | 0 .../src/osi/os/{RTEMS-kernel => RTEMS-score}/osiUnistd.h | 0 27 files changed, 7 insertions(+), 7 deletions(-) rename modules/libcom/RTEMS/{kernel => score}/rtems_config.c (100%) rename modules/libcom/RTEMS/{kernel => score}/rtems_init.c (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/devLibVMEOSD.c (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/epicsAtomicOSD.cpp (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/epicsAtomicOSD.h (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/epicsMath.h (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdEvent.c (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdEvent.h (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdFindSymbol.c (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdMutex.c (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdMutex.h (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdPoolStatus.c (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdProcess.c (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdReadline.c (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdSignal.cpp (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdSock.h (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdSpin.c (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdStrtod.h (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdThread.c (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdThread.h (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdThreadExtra.c (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdTime.cpp (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osdTime.h (100%) rename modules/libcom/src/osi/os/{RTEMS-kernel => RTEMS-score}/osiUnistd.h (100%) diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index 1cfe0fe56..b19b2071f 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -108,14 +108,14 @@ endif OP_SYS_LDLIBS_posix_NET_yes = -ltftpfs -lnfs -lz -ltelnetd OP_SYS_LDLIBS_posix_NET_no = -ltftpfs -lbsd -lz -OP_SYS_LDLIBS_kernel_NET_yes = -lnfs -OP_SYS_LDLIBS_kernel_NET_no = -lnfs +OP_SYS_LDLIBS_score_NET_yes = -lnfs +OP_SYS_LDLIBS_score_NET_no = -lnfs OP_SYS_LDLIBS += -lrtemsCom -lCom OP_SYS_LDLIBS += $(OP_SYS_LDLIBS_$(OS_API)_NET_$(RTEMS_HAS_NETWORKING)) OP_SYS_LDLIBS += -lrtemscpu -lc -lm OP_SYS_LDFLAGS_posix = -u POSIX_Init -OP_SYS_LDFLAGS_kernel = -u Init \ +OP_SYS_LDFLAGS_score = -u Init \ $(PROJECT_RELEASE)/lib/no-dpmem.rel \ $(PROJECT_RELEASE)/lib/no-mp.rel \ $(PROJECT_RELEASE)/lib/no-part.rel \ diff --git a/configure/toolchain.c b/configure/toolchain.c index 3120d4fdc..a97085ae3 100644 --- a/configure/toolchain.c +++ b/configure/toolchain.c @@ -32,6 +32,6 @@ MSVC_VER = _MSC_VER # if __RTEMS_MAJOR__>=5 OS_API = posix # else -OS_API = kernel +OS_API = score # endif #endif diff --git a/modules/libcom/RTEMS/kernel/rtems_config.c b/modules/libcom/RTEMS/score/rtems_config.c similarity index 100% rename from modules/libcom/RTEMS/kernel/rtems_config.c rename to modules/libcom/RTEMS/score/rtems_config.c diff --git a/modules/libcom/RTEMS/kernel/rtems_init.c b/modules/libcom/RTEMS/score/rtems_init.c similarity index 100% rename from modules/libcom/RTEMS/kernel/rtems_init.c rename to modules/libcom/RTEMS/score/rtems_init.c diff --git a/modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c b/modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c index c83c338d9..3d93a07ae 100644 --- a/modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c +++ b/modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c @@ -1,6 +1,6 @@ #ifdef RTEMS_LEGACY_STACK -#include "../RTEMS-kernel/devLibVMEOSD.c" +#include "os/RTEMS-score/devLibVMEOSD.c" #else -#pragma message "\n VME-Support only with RTEMS Legacy stack\n" -#include "../default/devLibVMEOSD.c" +#pragma message "\n VME Support requires the RTEMS Legacy stack\n" +#include "default/devLibVMEOSD.c" #endif diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c b/modules/libcom/src/osi/os/RTEMS-score/devLibVMEOSD.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/devLibVMEOSD.c rename to modules/libcom/src/osi/os/RTEMS-score/devLibVMEOSD.c diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/epicsAtomicOSD.cpp b/modules/libcom/src/osi/os/RTEMS-score/epicsAtomicOSD.cpp similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/epicsAtomicOSD.cpp rename to modules/libcom/src/osi/os/RTEMS-score/epicsAtomicOSD.cpp diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/epicsAtomicOSD.h b/modules/libcom/src/osi/os/RTEMS-score/epicsAtomicOSD.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/epicsAtomicOSD.h rename to modules/libcom/src/osi/os/RTEMS-score/epicsAtomicOSD.h diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/epicsMath.h b/modules/libcom/src/osi/os/RTEMS-score/epicsMath.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/epicsMath.h rename to modules/libcom/src/osi/os/RTEMS-score/epicsMath.h diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdEvent.c b/modules/libcom/src/osi/os/RTEMS-score/osdEvent.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdEvent.c rename to modules/libcom/src/osi/os/RTEMS-score/osdEvent.c diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdEvent.h b/modules/libcom/src/osi/os/RTEMS-score/osdEvent.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdEvent.h rename to modules/libcom/src/osi/os/RTEMS-score/osdEvent.h diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdFindSymbol.c b/modules/libcom/src/osi/os/RTEMS-score/osdFindSymbol.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdFindSymbol.c rename to modules/libcom/src/osi/os/RTEMS-score/osdFindSymbol.c diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdMutex.c b/modules/libcom/src/osi/os/RTEMS-score/osdMutex.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdMutex.c rename to modules/libcom/src/osi/os/RTEMS-score/osdMutex.c diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdMutex.h b/modules/libcom/src/osi/os/RTEMS-score/osdMutex.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdMutex.h rename to modules/libcom/src/osi/os/RTEMS-score/osdMutex.h diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdPoolStatus.c b/modules/libcom/src/osi/os/RTEMS-score/osdPoolStatus.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdPoolStatus.c rename to modules/libcom/src/osi/os/RTEMS-score/osdPoolStatus.c diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdProcess.c b/modules/libcom/src/osi/os/RTEMS-score/osdProcess.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdProcess.c rename to modules/libcom/src/osi/os/RTEMS-score/osdProcess.c diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdReadline.c b/modules/libcom/src/osi/os/RTEMS-score/osdReadline.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdReadline.c rename to modules/libcom/src/osi/os/RTEMS-score/osdReadline.c diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdSignal.cpp b/modules/libcom/src/osi/os/RTEMS-score/osdSignal.cpp similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdSignal.cpp rename to modules/libcom/src/osi/os/RTEMS-score/osdSignal.cpp diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdSock.h b/modules/libcom/src/osi/os/RTEMS-score/osdSock.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdSock.h rename to modules/libcom/src/osi/os/RTEMS-score/osdSock.h diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdSpin.c b/modules/libcom/src/osi/os/RTEMS-score/osdSpin.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdSpin.c rename to modules/libcom/src/osi/os/RTEMS-score/osdSpin.c diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdStrtod.h b/modules/libcom/src/osi/os/RTEMS-score/osdStrtod.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdStrtod.h rename to modules/libcom/src/osi/os/RTEMS-score/osdStrtod.h diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdThread.c b/modules/libcom/src/osi/os/RTEMS-score/osdThread.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdThread.c rename to modules/libcom/src/osi/os/RTEMS-score/osdThread.c diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdThread.h b/modules/libcom/src/osi/os/RTEMS-score/osdThread.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdThread.h rename to modules/libcom/src/osi/os/RTEMS-score/osdThread.h diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdThreadExtra.c b/modules/libcom/src/osi/os/RTEMS-score/osdThreadExtra.c similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdThreadExtra.c rename to modules/libcom/src/osi/os/RTEMS-score/osdThreadExtra.c diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdTime.cpp b/modules/libcom/src/osi/os/RTEMS-score/osdTime.cpp similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdTime.cpp rename to modules/libcom/src/osi/os/RTEMS-score/osdTime.cpp diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osdTime.h b/modules/libcom/src/osi/os/RTEMS-score/osdTime.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osdTime.h rename to modules/libcom/src/osi/os/RTEMS-score/osdTime.h diff --git a/modules/libcom/src/osi/os/RTEMS-kernel/osiUnistd.h b/modules/libcom/src/osi/os/RTEMS-score/osiUnistd.h similarity index 100% rename from modules/libcom/src/osi/os/RTEMS-kernel/osiUnistd.h rename to modules/libcom/src/osi/os/RTEMS-score/osiUnistd.h From f3da6e94646cb532bf2a1cbc898a6e6953424381 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 6 Apr 2021 11:18:12 -0500 Subject: [PATCH 154/195] Drop macOS PowerPC host-arch's --- configure/CONFIG_SITE | 2 -- configure/os/CONFIG.Common.darwin-ppc | 14 ------------- configure/os/CONFIG.Common.darwin-ppcx86 | 14 ------------- configure/os/CONFIG.darwin-ppc.Common | 8 -------- .../os/CONFIG.darwin-ppc.darwin-ppc-debug | 13 ------------ configure/os/CONFIG.darwin-ppcx86.Common | 8 -------- configure/os/CONFIG_SITE.Common.darwin-ppc | 12 ----------- configure/os/CONFIG_SITE.Common.darwin-ppcx86 | 20 ------------------- configure/os/CONFIG_SITE.darwin-ppc.Common | 4 ---- configure/os/CONFIG_SITE.darwin-ppcx86.Common | 4 ---- 10 files changed, 99 deletions(-) delete mode 100644 configure/os/CONFIG.Common.darwin-ppc delete mode 100644 configure/os/CONFIG.Common.darwin-ppcx86 delete mode 100644 configure/os/CONFIG.darwin-ppc.Common delete mode 100644 configure/os/CONFIG.darwin-ppc.darwin-ppc-debug delete mode 100644 configure/os/CONFIG.darwin-ppcx86.Common delete mode 100644 configure/os/CONFIG_SITE.Common.darwin-ppc delete mode 100644 configure/os/CONFIG_SITE.Common.darwin-ppcx86 delete mode 100644 configure/os/CONFIG_SITE.darwin-ppc.Common delete mode 100644 configure/os/CONFIG_SITE.darwin-ppcx86.Common diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index f29f21141..02ed4eacc 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -17,8 +17,6 @@ # Currently Supporting: # cygwin-x86 (cygwin compiler used for host builds) # cygwin-x86_64 (cygwin compiler used for host builds) -# darwin-ppc (PowerPC based Apple running OSX) -# darwin-ppcx86 (Universal binaries for both CPUs) # darwin-x86 (Intel based Apple running OSX) # freebsd-x86 (GNU compiler used for host builds) # freebsd-x86_64 (GNU compiler used for host builds) diff --git a/configure/os/CONFIG.Common.darwin-ppc b/configure/os/CONFIG.Common.darwin-ppc deleted file mode 100644 index 7ac704314..000000000 --- a/configure/os/CONFIG.Common.darwin-ppc +++ /dev/null @@ -1,14 +0,0 @@ -# CONFIG.Common.darwin-ppc -# -# This file is maintained by the build community. -# -# Definitions for darwin-ppc target builds -# Sites may override these definitions in CONFIG_SITE.Common.darwin-ppc -#------------------------------------------------------- - -# -# To build universal binaries, configure ARCH_CLASS -# in the file CONFIG_SITE.Common.darwin-ppc - -# Include definitions common to all Darwin targets -include $(CONFIG)/os/CONFIG.darwinCommon.darwinCommon diff --git a/configure/os/CONFIG.Common.darwin-ppcx86 b/configure/os/CONFIG.Common.darwin-ppcx86 deleted file mode 100644 index 12107944f..000000000 --- a/configure/os/CONFIG.Common.darwin-ppcx86 +++ /dev/null @@ -1,14 +0,0 @@ -# CONFIG.Common.darwin-ppcx86 -# -# This file is maintained by the build community. -# -# Definitions for Darwin universal PowerPC + x86 target builds -# Sites may override these definitions in CONFIG_SITE.Common.darwin-ppcx86 -#------------------------------------------------------- - -# -# To build universal binaries, configure ARCH_CLASS -# in the file CONFIG_SITE.Common.darwin-ppcx86 - -# Include definitions common to all Darwin targets -include $(CONFIG)/os/CONFIG.darwinCommon.darwinCommon diff --git a/configure/os/CONFIG.darwin-ppc.Common b/configure/os/CONFIG.darwin-ppc.Common deleted file mode 100644 index ac176878f..000000000 --- a/configure/os/CONFIG.darwin-ppc.Common +++ /dev/null @@ -1,8 +0,0 @@ -# CONFIG.darwin-ppc.Common -# -# Definitions for darwin-ppc host builds -# Sites may override these definitions in CONFIG_SITE.darwin-ppc.Common -#------------------------------------------------------- - -#Include definitions common to unix hosts -include $(CONFIG)/os/CONFIG.UnixCommon.Common diff --git a/configure/os/CONFIG.darwin-ppc.darwin-ppc-debug b/configure/os/CONFIG.darwin-ppc.darwin-ppc-debug deleted file mode 100644 index 985052031..000000000 --- a/configure/os/CONFIG.darwin-ppc.darwin-ppc-debug +++ /dev/null @@ -1,13 +0,0 @@ -# CONFIG.darwin-ppc.darwin-ppc-debug -# -# Definitions for darwin-ppc host - darwin-ppc-debug target build with debug compiler flags -# Sites may override these definitions in CONFIG_SITE.darwin-ppc.darwin-ppc-debug -#------------------------------------------------------- - --include $(CONFIG)/os/CONFIG.Common.darwin-ppc --include $(CONFIG)/os/CONFIG.darwin-ppc.darwin-ppc --include $(CONFIG)/os/CONFIG_SITE.Common.darwin-ppc --include $(CONFIG)/os/CONFIG_SITE.darwin-ppc.darwin-ppc - -BUILD_CLASS=HOST -HOST_OPT = NO diff --git a/configure/os/CONFIG.darwin-ppcx86.Common b/configure/os/CONFIG.darwin-ppcx86.Common deleted file mode 100644 index 749835ced..000000000 --- a/configure/os/CONFIG.darwin-ppcx86.Common +++ /dev/null @@ -1,8 +0,0 @@ -# CONFIG.darwin-ppcx86.Common -# -# Definitions for Darwin universal PowerPC + x86 host builds -# Sites may override these definitions in CONFIG_SITE.darwin-ppcx86.Common -#------------------------------------------------------- - -#Include definitions common to unix hosts -include $(CONFIG)/os/CONFIG.UnixCommon.Common diff --git a/configure/os/CONFIG_SITE.Common.darwin-ppc b/configure/os/CONFIG_SITE.Common.darwin-ppc deleted file mode 100644 index a2550147f..000000000 --- a/configure/os/CONFIG_SITE.Common.darwin-ppc +++ /dev/null @@ -1,12 +0,0 @@ -# CONFIG_SITE.Common.darwin-ppc -# -# Site override definitions for darwin-ppc target builds -#------------------------------------------------------- - -# Select which CPU architectures to include in your universal binaries: -# ppc -# ppc64 - Not tested - -ARCH_CLASS = ppc -#ARCH_CLASS = ppc64 -#ARCH_CLASS = ppc ppc64 diff --git a/configure/os/CONFIG_SITE.Common.darwin-ppcx86 b/configure/os/CONFIG_SITE.Common.darwin-ppcx86 deleted file mode 100644 index 2191d54f8..000000000 --- a/configure/os/CONFIG_SITE.Common.darwin-ppcx86 +++ /dev/null @@ -1,20 +0,0 @@ -# CONFIG_SITE.Common.darwin-ppcx86 -# -# Site override definitions for darwin-ppcx86 target builds -#---------------------------------------------------------- - -# Select which CPU architectures to include in your universal binaries: -# ppc -# i386 -# ppc64 - Not tested -# x86_64 - Needs MacOS 10.4 with Universal SDK, or 10.5 or later. - -ARCH_CLASS = ppc i386 -#ARCH_CLASS = ppc x86_64 -#ARCH_CLASS = ppc i386 x86_64 -#ARCH_CLASS = ppc64 i386 -#ARCH_CLASS = ppc64 x86_64 -#ARCH_CLASS = ppc64 i386 x86_64 -#ARCH_CLASS = ppc ppc64 i386 -#ARCH_CLASS = ppc ppc64 x86_64 -#ARCH_CLASS = ppc ppc64 i386 x86_64 diff --git a/configure/os/CONFIG_SITE.darwin-ppc.Common b/configure/os/CONFIG_SITE.darwin-ppc.Common deleted file mode 100644 index 05417e1f9..000000000 --- a/configure/os/CONFIG_SITE.darwin-ppc.Common +++ /dev/null @@ -1,4 +0,0 @@ -# CONFIG_SITE.darwin-ppc.Common -# -# Site override definitions for darwin-ppc host builds -#------------------------------------------------------- diff --git a/configure/os/CONFIG_SITE.darwin-ppcx86.Common b/configure/os/CONFIG_SITE.darwin-ppcx86.Common deleted file mode 100644 index 42bd00531..000000000 --- a/configure/os/CONFIG_SITE.darwin-ppcx86.Common +++ /dev/null @@ -1,4 +0,0 @@ -# CONFIG_SITE.darwin-ppcx86.Common -# -# Site override definitions for darwin-ppcx86 host builds -#------------------------------------------------------- From ead24c4fd6ed2f83caad1f5679ce3c6ac09340a5 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 6 Apr 2021 11:19:51 -0500 Subject: [PATCH 155/195] Drop macOS i386 ARCH_CLASS, add arm64 --- configure/CONFIG_SITE | 3 ++- configure/os/CONFIG_SITE.Common.darwin-x86 | 8 +++----- src/tools/EpicsHostArch.pl | 5 ++--- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index 02ed4eacc..79e09378d 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -17,7 +17,8 @@ # Currently Supporting: # cygwin-x86 (cygwin compiler used for host builds) # cygwin-x86_64 (cygwin compiler used for host builds) -# darwin-x86 (Intel based Apple running OSX) +# darwin-aarch64 (M1 based Apple using CLANG compiler) +# darwin-x86 (Intel based Apple using CLANG compiler) # freebsd-x86 (GNU compiler used for host builds) # freebsd-x86_64 (GNU compiler used for host builds) # linux-aarch64 (GNU compiler used for host builds) diff --git a/configure/os/CONFIG_SITE.Common.darwin-x86 b/configure/os/CONFIG_SITE.Common.darwin-x86 index 1c5c93696..e837d63f0 100644 --- a/configure/os/CONFIG_SITE.Common.darwin-x86 +++ b/configure/os/CONFIG_SITE.Common.darwin-x86 @@ -4,14 +4,12 @@ #------------------------------------------------------- # Select which CPU architecture(s) to include in your MacOS binaries: -# i386, x86_64, or both (fat binaries). +# x86_64 only, or arm64 as well (fat binaries). -#ARCH_CLASS = i386 ARCH_CLASS = x86_64 -#ARCH_CLASS = i386 x86_64 +#ARCH_CLASS = arm64 x86_64 -# -# Uncomment the following 3 lines to build with Apple's GCC instead of CLANG. +# Uncomment the following 3 lines to build with GCC instead of CLANG. # #CMPLR_CLASS = gcc #CC = gcc diff --git a/src/tools/EpicsHostArch.pl b/src/tools/EpicsHostArch.pl index 67e29c77e..abff49007 100644 --- a/src/tools/EpicsHostArch.pl +++ b/src/tools/EpicsHostArch.pl @@ -47,9 +47,8 @@ sub HostArch { my ($kernel, $hostname, $release, $version, $cpu) = uname; if (m/^darwin/) { for ($cpu) { - return 'darwin-x86' if m/^(i386|x86_64)/; - return 'darwin-ppc' if m/Power Macintosh/; - return 'darwin-aarch64' if m/arm64/; + return 'darwin-x86' if m/^x86_64/; + return 'darwin-aarch64' if m/^arm64/; } die "$0: macOS CPU type '$cpu' not recognized\n"; } From 5e61f7e499998e68f9ab50d46edce0835e2715a8 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 6 Apr 2021 11:26:06 -0500 Subject: [PATCH 156/195] Remove aix-ppc files from extensions template --- .../os/CONFIG_SITE.aix-ppc-gnu.aix-ppc-gnu | 11 --- .../configure/os/CONFIG_SITE.aix-ppc.aix-ppc | 77 ------------------- 2 files changed, 88 deletions(-) delete mode 100644 src/template/ext/top/configure/os/CONFIG_SITE.aix-ppc-gnu.aix-ppc-gnu delete mode 100644 src/template/ext/top/configure/os/CONFIG_SITE.aix-ppc.aix-ppc diff --git a/src/template/ext/top/configure/os/CONFIG_SITE.aix-ppc-gnu.aix-ppc-gnu b/src/template/ext/top/configure/os/CONFIG_SITE.aix-ppc-gnu.aix-ppc-gnu deleted file mode 100644 index 19d65aead..000000000 --- a/src/template/ext/top/configure/os/CONFIG_SITE.aix-ppc-gnu.aix-ppc-gnu +++ /dev/null @@ -1,11 +0,0 @@ -# -# Site Specific Configuration Information -# Only the local epics system manager should modify this file - -# Where to find utilities/libraries -# If you do not have a certain product, -# leave the line empty. -# - --include $(TOP)/configure/os/CONFIG_SITE.aix-ppc.aix-ppc - diff --git a/src/template/ext/top/configure/os/CONFIG_SITE.aix-ppc.aix-ppc b/src/template/ext/top/configure/os/CONFIG_SITE.aix-ppc.aix-ppc deleted file mode 100644 index 3f40e0b37..000000000 --- a/src/template/ext/top/configure/os/CONFIG_SITE.aix-ppc.aix-ppc +++ /dev/null @@ -1,77 +0,0 @@ -# -# Site Specific Configuration Information -# Only the local epics system manager should modify this file - -# Where to find utilities/libraries -# If you do not have a certain product, -# leave the line empty. -# - --include $(TOP)/configure/os/CONFIG_SITE.Common.Common - -# sun X11 -X11_LIB = /usr/openwin/lib -X11_INC = /usr/openwin/include -# mit X11 -#X11_LIB = /opt/X11R5/lib -#X11_INC = /opt/X11R5/include -# osf motif -#MOTIF_INC = /opt/local/Motif2.0/include -#MOTIF_LIB = /opt/local/Motif2.0/lib -# sun SDK motif -#MOTIF_INC = /opt/SUNWmotif/include -#MOTIF_LIB = /opt/SUNWmotif/lib -# sun 5.4,5.6 SDK motif -MOTIF_INC = /usr/dt/include -MOTIF_LIB = /usr/dt/lib -OPENWIN = /usr/openwin - -INTERVIEWS_BIN=/usr/local/interviews/bin/O.solaris -INTERVIEWS_LIB=/usr/local/interviews/lib/O.solaris -IV_INC=/usr/local/interviews/include -IV-2_6_INC=/usr/local/interviews/include/IV-2_6 -IV_BIN=/usr/local/interviews/bin/O.solaris -IV_LIB=/usr/local/interviews/lib/O.solaris - -WINGZ_INC = /opt/local/Wingz2/incl -WINGZ_LIB = /opt/local/Wingz2/lib -#MATHEMATICA = /usr/local/math -# Define XRTGRAPH_EXTENSIONS = YES only if using XRT/graph 3.x -# and you want the extensions for MEDM -XRTGRAPH_EXTENSIONS = YES -XRTGRAPH = /opt/local/xrtgraph -QUESTWIN = /usr/local/questwin - -TK_LIB = /opt/local/lib -TK_INC = /opt/local/include -TCL_LIB = /opt/local/lib -TCL_INC = /opt/local/include -DP_LIB = /opt/local/lib -DP_INC = /opt/local/include -BLT_LIB = /opt/local/lib -BLT_INC = /opt/local/include - -IDL = /usr/local/idl -# IDL=$(IDL)/external/rpc is the sun4 version -IDLRPC = $(IDL)/external/rpc.solaris - -ZLIB_PREFIX = /usr/local/oag -ZLIB = $(notdir $(wildcard $(ZLIB_PREFIX)/lib/libz.a)) -ifeq ($(ZLIB) , libz.a) -ZLIB_LIB = $(ZLIB_PREFIX)/lib -ZLIB_INC = -I$(ZLIB_PREFIX)/include -ZLIB_CFLAG = -DzLib -ZLIB_PROD_LIB = z -z_DIR=$(ZLIB_PREFIX)/lib -else -ZLIB_LIB = -ZLIB_INC = -ZLIB_CFLAG = -ZLIB_PROD_LIB = -z_DIR= -endif - -PYTHON_DIR=/opt/local/lib/python2.2 -PYTHON_INCLUDE=/opt/local/include/python2.2 - -JAVA_DIR=/usr/java From 6d96ea06d06ed51e635ad57bc616e1b0253501f3 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 6 Apr 2021 11:30:28 -0500 Subject: [PATCH 157/195] Remove linux-cris target files --- configure/CONFIG_SITE | 3 - configure/os/CONFIG.Common.linux-cris | 58 ---------------- configure/os/CONFIG.linux-x86.linux-cris | 38 ----------- configure/os/CONFIG.linux-x86.linux-cris_v10 | 20 ------ configure/os/CONFIG.linux-x86.linux-cris_v32 | 20 ------ configure/os/CONFIG_SITE.Common.linux-cris | 34 ---------- configure/os/CONFIG_SITE.linux-x86.linux-cris | 14 ---- documentation/README.cris | 67 ------------------- 8 files changed, 254 deletions(-) delete mode 100644 configure/os/CONFIG.Common.linux-cris delete mode 100644 configure/os/CONFIG.linux-x86.linux-cris delete mode 100644 configure/os/CONFIG.linux-x86.linux-cris_v10 delete mode 100644 configure/os/CONFIG.linux-x86.linux-cris_v32 delete mode 100644 configure/os/CONFIG_SITE.Common.linux-cris delete mode 100644 configure/os/CONFIG_SITE.linux-x86.linux-cris delete mode 100644 documentation/README.cris diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index 79e09378d..110722408 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -68,9 +68,6 @@ # linux-arm (linux-x86 or -x86_64 host) # linux-aarch64 (linux-x86_64 host) # linux-athlon (linux-x86 host) -# linux-cris (Axis GNU crosscompiler on linux-x86 host) -# linux-cris_v10 (Axis GNU crosscompiler on linux-x86 host) -# linux-cris_v32 (Axis GNU crosscompiler on linux-x86 host) # linux-microblaze # linux-xscale_be # vxWorks-486 diff --git a/configure/os/CONFIG.Common.linux-cris b/configure/os/CONFIG.Common.linux-cris deleted file mode 100644 index d419b23e8..000000000 --- a/configure/os/CONFIG.Common.linux-cris +++ /dev/null @@ -1,58 +0,0 @@ -# CONFIG.Common.linux-cris -# -# Author: Peter Zumbruch -# GSI -# P.Zumbruch@gsi.de -# -# Definitions for linux-cris target builds -# Sites may override these definitions in CONFIG_SITE.Common.linux-cris -#------------------------------------------------------- - -# Include definitions common to all linux targets -include $(CONFIG)/os/CONFIG.Common.linuxCommon - -ARCH_CLASS = cris - -ifeq ($(BUILD_CLASS),CROSS) - GNU_TARGET = cris-axis-linux-gnu - - # prefix of compiler tools - CMPLR_SUFFIX = - CMPLR_PREFIX = $(addsuffix -,$(GNU_TARGET)) - - # CROSS_TOP_DIR - # usually AXIS_TOP_DIR is defined via - # the init_env script of the SDK provided by Axis - # - ## AXIS_TOP_DIR defined? Make missing mandatory variable visible - AXIS_TOP_DIR?=UNDEFINED_ENV__AXIS_TOP_DIR - AXIS_SDK_DIR?=$(AXIS_TOP_DIR) - - # CROSS_INCLUDES - AXIS_SDK_TARGET_INCLUDE_DIR = $(AXIS_SDK_DIR)/target/$(GNU_TARGET)/include - AXIS_SDK_TARGET_INCLUDE_DIR +=$(AXIS_SDK_DIR)/target/$(GNU_TARGET)/usr/include - - CROSS_INCLUDES = $(addprefix -isystem ,$(AXIS_SDK_TARGET_INCLUDE_DIR)) - - # CROSS_LDFLAGS - AXIS_SDK_TARGET_LIB_DIR = $(AXIS_SDK_DIR)/target/$(GNU_TARGET)/lib - AXIS_SDK_TARGET_LIB_DIR += $(AXIS_SDK_DIR)/target/$(GNU_TARGET)/usr/lib - - CROSS_LDFLAGS = $(addprefix -L,$(AXIS_SDK_TARGET_LIB_DIR)) - --include $(CONFIG)/os/CONFIG_SITE.Common.linux-cris -ifeq ($(EPICS_HOST_ARCH), linux-x86) --include $(CONFIG)/os/CONFIG.linux-x86.linux-cris --include $(CONFIG)/os/CONFIG_SITE.linux-x86.linux-cris -endif -endif - -SHARED_LIBRARIES=NO -STATIC_BUILD=YES - -ARCH_DEP_CFLAGS += -mno-mul-bug-workaround -OP_SYS_CFLAGS += -mlinux -ARCH_DEP_CPPFLAGS += -D_cris_ -mlinux - -#uncomment CRIS_COMPILER_DEBUG for debugging cris-compiled code -#CRIS_COMPILER_DEBUG diff --git a/configure/os/CONFIG.linux-x86.linux-cris b/configure/os/CONFIG.linux-x86.linux-cris deleted file mode 100644 index 8244916e5..000000000 --- a/configure/os/CONFIG.linux-x86.linux-cris +++ /dev/null @@ -1,38 +0,0 @@ -# CONFIG.linux-x86.linux-cris -# -# Author: Peter Zumbruch -# GSI -# P.Zumbruch@gsi.de -# -# Definitions for linux-x86 host - linux-cris target builds -# Sites may override these definitions in CONFIG_SITE.linux-x86.linux-cris -#------------------------------------------------------- - -GNU_DIR = $(CRIS_CROSS_COMPILER) - -#STATIC_... -STATIC_LDFLAGS_YES= -Wl,-Bstatic - -## debian-gcc Bug#438641 -GNU_LDLIBS_YES = -STATIC_LDFLAGS_YES += -static-libgcc - -# if not in debug mode strip all symbols -ifndef CRIS_COMPILER_DEBUG -STATIC_LDFLAGS_YES += -Wl,--strip-all -endif - -ifeq ($(GNU),YES) -STATIC_LDFLAGS_NO = -lgcc -else -STATIC_LDFLAGS_NO = -endif - -STATIC_LDLIBS_YES= -STATIC_LDLIBS_NO= - -OPT_CXXFLAGS_YES = -Os - -ifeq ($(STATIC_BUILD), YES) - $(shell echo yes) -endif diff --git a/configure/os/CONFIG.linux-x86.linux-cris_v10 b/configure/os/CONFIG.linux-x86.linux-cris_v10 deleted file mode 100644 index a227ac07c..000000000 --- a/configure/os/CONFIG.linux-x86.linux-cris_v10 +++ /dev/null @@ -1,20 +0,0 @@ -# CONFIG.linux-x86.linux-cris_v10 -# -# Author: Peter Zumbruch -# GSI -# P.Zumbruch@gsi.de -# -# Definitions for linux-x86 host - linux-cris_v10 target builds -# Sites may override these definitions in CONFIG_SITE.linux-x86.linux-cris_v10 -#------------------------------------------------------- - -# Include definitions common to all linux-cris targets -include $(CONFIG)/os/CONFIG.Common.linux-cris - -GNU_TARGET = cris-axis-linux-gnu - -ARCH_DEP_CFLAGS += -march=v10 - -# if you are using different places for cris_v10 cris_v32 -# you have to define for each architecture -# AXIS_SDK_DIR= diff --git a/configure/os/CONFIG.linux-x86.linux-cris_v32 b/configure/os/CONFIG.linux-x86.linux-cris_v32 deleted file mode 100644 index eee8f3344..000000000 --- a/configure/os/CONFIG.linux-x86.linux-cris_v32 +++ /dev/null @@ -1,20 +0,0 @@ -# CONFIG.linux-x86.linux-cris_v32 -# -# Author: Peter Zumbruch -# GSI -# P.Zumbruch@gsi.de -# -# Definitions for linux-x86 host - linux-cris_v32 target builds -# Sites may override these definitions in CONFIG_SITE.linux-x86.linux-cris_v32 -#------------------------------------------------------- - -# Include definitions common to all linux-cris targets -include $(CONFIG)/os/CONFIG.Common.linux-cris - -GNU_TARGET = crisv32-axis-linux-gnu - -ARCH_DEP_CFLAGS += -march=v32 - -# if you are using different places for cris_v10 cris_v32 -# you have to define for each architecture -# AXIS_SDK_DIR= diff --git a/configure/os/CONFIG_SITE.Common.linux-cris b/configure/os/CONFIG_SITE.Common.linux-cris deleted file mode 100644 index 699f346ff..000000000 --- a/configure/os/CONFIG_SITE.Common.linux-cris +++ /dev/null @@ -1,34 +0,0 @@ -# CONFIG_SITE.Common.linux-cris -# -# Site-specific settings for the linux-cris target - -# NOTE: In most cases if SHARED_LIBRARIES is set to YES the -# shared libraries will be found automatically. However if the .so -# files are installed at a different path to their compile-time path -# then in order to be found at runtime do one of these: -# a) LD_LIBRARY_PATH must include the full absolute pathname to -# $(INSTALL_LOCATION)/lib/$(EPICS_HOST_ARCH) when invoking base -# executables. -# b) Add the runtime path to SHRLIB_DEPLIB_DIRS and PROD_DEPLIB_DIRS, which -# will add the named directory to the list contained in the executables. -# c) Add the runtime path to /etc/ld.so.conf and run ldconfig -# to inform the system of the shared library location. - - -# Use GNU Readline if the header file is installed -COMMANDLINE_LIBRARY = $(strip $(if $(wildcard \ - $(GNU_DIR)/include/readline/readline.h), READLINE, EPICS)) - -# If libreadline needs additional libraries to be linked with it, try -# uncommenting each of the lines below in turn, starting with the top -# one and working downwards, until the build succeeds. Do a 'make rebuild' -# from the top of the Base tree after changing this setting. - -# Needs -lncurses: -#COMMANDLINE_LIBRARY = READLINE_NCURSES - -# Needs -lcurses: -#COMMANDLINE_LIBRARY = READLINE_CURSES - -# Readline is broken or you don't want use it: -#COMMANDLINE_LIBRARY = EPICS diff --git a/configure/os/CONFIG_SITE.linux-x86.linux-cris b/configure/os/CONFIG_SITE.linux-x86.linux-cris deleted file mode 100644 index eb756ca8a..000000000 --- a/configure/os/CONFIG_SITE.linux-x86.linux-cris +++ /dev/null @@ -1,14 +0,0 @@ -# CONFIG_SITE.linux-x86.linux-cris -# -# Author: Peter Zumbruch -# GSI -# P.Zumbruch@gsi.de -# -# Site specific definitions for linux-x86 host - linux-cris target builds -#------------------------------------------------------- - -# define site specific location of cris cross compiler's gnu directory -# but without bin sub directory, this will be added automatically. - -CRIS_CROSS_COMPILER ?= UNDEFINED_ENV__CRIS_CROSS_COMPILER - diff --git a/documentation/README.cris b/documentation/README.cris deleted file mode 100644 index c44f31bb0..000000000 --- a/documentation/README.cris +++ /dev/null @@ -1,67 +0,0 @@ -cross compiling EPICS and - building IOC Applications for cris architectures - (linux-cris_v10, linux-cris_v32) -====================================================================== - -Please mail questions, comments, corrections, etc. ... -to P.Zumbruch@gsi.de -November 2007 - -Tools needed ------------- - - o Axis SDK - - Overview: - http://developer.axis.com/wiki/doku.php?id=axis:sdk - - Download: - http://www.axis.com/products/dev_sdk/download_dist.php - - Install HOWTO: - http://developer.axis.com/wiki/doku.php?id=axis:software_distribution_install_howto - o Axis GNU gcc release for cross compiling - - Download: - http://www.axis.com/products/dev_sdk/download_compiler.php - - Install HOWTO: - http://developer.axis.com/wiki/doku.php?id=axis:compiler_install - -Environment ------------ - - o CRIS_CROSS_COMPILER - - path to top directory of cris cross compiler, - where binaries are in sub directory bin/ - - if not set, the make process will stop at place - UNDEFINED_ENV__CRIS_CROSS_COMPILER - o AXIS_TOP_DIR?=UNDEFINED_ENV__AXIS_TOP_DIR - - path to axis SDK top directory - - if not set compile and link commands will contain references to - UNDEFINED_ENV__AXIS_TOP_DIR - - to set the necessary variables, execute - . ./init_env - in the top directory of the SDK provided here. - o CRIS_COMPILER_DEBUG - - if defined symbols won't be stripped, - resulting in comparably large files - -Building --------- - - o Edit the CONFIG_SITE files - - CONFIG_SITE.linux-x86.Common: - for CROSS_COMPILER_TARGET_ARCHS += linux-cris_v10 - for CROSS_COMPILER_TARGET_ARCHS += linux-cris_v32 - - optionally CONFIG_SITE.linux-x86.linux-cris - for setting CRIS_CROSS_COMPILER - - optionally create CONFIG_SITE.linux-x86.linux-cris_v10 - - optionally create CONFIG_SITE.linux-x86.linux-cris_v32 - o "make". - -Shared Libraries ----------------- - -Generating shared libraries is not supported. - - -Please feel free to contact me if you -encounter serious problems. - -Peter From 462916f9e469f69a30b8f3ff5ef162883e3edaf3 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 6 Apr 2021 12:46:04 -0500 Subject: [PATCH 158/195] Drop RTEMS-at91rm9200ek and RTEMS-psim targets --- configure/CONFIG_SITE | 2 -- configure/os/CONFIG.Common.RTEMS-at91rm9200ek | 14 -------------- configure/os/CONFIG.Common.RTEMS-psim | 10 ---------- 3 files changed, 26 deletions(-) delete mode 100644 configure/os/CONFIG.Common.RTEMS-at91rm9200ek delete mode 100644 configure/os/CONFIG.Common.RTEMS-psim diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index 110722408..038381229 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -81,7 +81,6 @@ # vxWorks-ppc604_altivec # vxWorks-mpc8540 # vxWorks-mpc8548 -# RTEMS-at91rm9200ek # RTEMS-beagleboneblack # RTEMS-beatnik # RTEMS-gen68360 @@ -93,7 +92,6 @@ # RTEMS-mvme5500 # RTEMS-pc386 # RTEMS-pc686 -# RTEMS-psim # RTEMS-qoriq_e500 # RTEMS-uC5282 # RTEMS-xilinx-zynq_a9_qemu diff --git a/configure/os/CONFIG.Common.RTEMS-at91rm9200ek b/configure/os/CONFIG.Common.RTEMS-at91rm9200ek deleted file mode 100644 index 735c07bb5..000000000 --- a/configure/os/CONFIG.Common.RTEMS-at91rm9200ek +++ /dev/null @@ -1,14 +0,0 @@ -# -# CONFIG.Common.RTEMS-at91rm9200ek -# Author: Ralf Hartmann -# BESSY -# Ralf.Hartmann@bessy.de -# -# Atmel AT91RM9200-EK evaluation kit -# using the AT91RM9200 ARM9-based 32-bit RISC microcontroller -# -# All RTEMS targets use the same Makefile fragment -# -RTEMS_BSP = at91rm9200ek -RTEMS_TARGET_CPU = arm -include $(CONFIG)/os/CONFIG.Common.RTEMS diff --git a/configure/os/CONFIG.Common.RTEMS-psim b/configure/os/CONFIG.Common.RTEMS-psim deleted file mode 100644 index 58ad72852..000000000 --- a/configure/os/CONFIG.Common.RTEMS-psim +++ /dev/null @@ -1,10 +0,0 @@ -# -# Author: W. Eric Norum -# University of Saskatchewan -# eric.norum@usask.ca -# -# All RTEMS targets use the same Makefile fragment -# -RTEMS_BSP = psim -RTEMS_TARGET_CPU = ppc -include $(CONFIG)/os/CONFIG.Common.RTEMS From a17c30e51fc09f5eab0de25b4e9a037be376978e Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 6 Apr 2021 13:14:50 -0500 Subject: [PATCH 159/195] Drop CPU-specific linux-[3456]86 cross-targets --- configure/CONFIG_SITE | 5 ----- configure/os/CONFIG.Common.linux-386 | 21 ------------------- configure/os/CONFIG.Common.linux-486 | 19 ----------------- configure/os/CONFIG.Common.linux-586 | 21 ------------------- configure/os/CONFIG.Common.linux-686 | 20 ------------------ configure/os/CONFIG.Common.linux-athlon | 19 ----------------- configure/os/CONFIG.linux-386.Common | 10 --------- configure/os/CONFIG.linux-386.linux-386 | 8 ------- configure/os/CONFIG.linux-486.Common | 10 --------- configure/os/CONFIG.linux-486.linux-486 | 9 -------- configure/os/CONFIG.linux-586.Common | 10 --------- configure/os/CONFIG.linux-586.linux-586 | 9 -------- configure/os/CONFIG.linux-686.Common | 10 --------- configure/os/CONFIG.linux-686.linux-686 | 9 -------- .../configure/os/CONFIG.linux-x86.linux-386 | 2 -- .../os/CONFIG_SITE.linux-x86.linux-athlon | 11 ---------- 16 files changed, 193 deletions(-) delete mode 100644 configure/os/CONFIG.Common.linux-386 delete mode 100644 configure/os/CONFIG.Common.linux-486 delete mode 100644 configure/os/CONFIG.Common.linux-586 delete mode 100644 configure/os/CONFIG.Common.linux-686 delete mode 100644 configure/os/CONFIG.Common.linux-athlon delete mode 100644 configure/os/CONFIG.linux-386.Common delete mode 100644 configure/os/CONFIG.linux-386.linux-386 delete mode 100644 configure/os/CONFIG.linux-486.Common delete mode 100644 configure/os/CONFIG.linux-486.linux-486 delete mode 100644 configure/os/CONFIG.linux-586.Common delete mode 100644 configure/os/CONFIG.linux-586.linux-586 delete mode 100644 configure/os/CONFIG.linux-686.Common delete mode 100644 configure/os/CONFIG.linux-686.linux-686 delete mode 100644 src/template/ext/top/configure/os/CONFIG.linux-x86.linux-386 delete mode 100644 src/template/ext/top/configure/os/CONFIG_SITE.linux-x86.linux-athlon diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index 038381229..a0a2d0959 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -61,13 +61,8 @@ # ios-arm (darwin-x86 host) # ios-386 (darwin-x86 host) -# linux-386 (linux-x86 host) -# linux-486 (linux-x86 host) -# linux-586 (linux-x86 host) -# linux-686 (linux-x86 host) # linux-arm (linux-x86 or -x86_64 host) # linux-aarch64 (linux-x86_64 host) -# linux-athlon (linux-x86 host) # linux-microblaze # linux-xscale_be # vxWorks-486 diff --git a/configure/os/CONFIG.Common.linux-386 b/configure/os/CONFIG.Common.linux-386 deleted file mode 100644 index a224ff328..000000000 --- a/configure/os/CONFIG.Common.linux-386 +++ /dev/null @@ -1,21 +0,0 @@ -# CONFIG.Common.linux-386 -# -# This file is maintained by the build community. -# -# Definitions for linux-386 target builds -# Sites may override these definitions in CONFIG_SITE.Common.linux-386 -#------------------------------------------------------- - -# Include definitions common to all linux x86 targets -include $(CONFIG)/os/CONFIG.Common.linux-x86 - -ARCH_DEP_CFLAGS = -march=i386 - -ifeq ($(BUILD_CLASS),CROSS) - VALID_BUILDS = Ioc Command -endif - -# If your crosscompiler name has a GNU target prefix like -gcc, -# e.g. i386-pc-linux-gnu-gcc, put a GNU_TARGET definition in -# CONFIG_SITE..linux-386 file, e.g. GNU_TARGET=i386-pc-linux-gnu - diff --git a/configure/os/CONFIG.Common.linux-486 b/configure/os/CONFIG.Common.linux-486 deleted file mode 100644 index 79b533015..000000000 --- a/configure/os/CONFIG.Common.linux-486 +++ /dev/null @@ -1,19 +0,0 @@ -# CONFIG.Common.linux-486 -# -# Definitions for linux-486 target builds -# Sites may override these definitions in CONFIG_SITE.Common.linux-486 -#------------------------------------------------------- - -# Include definitions common to all linux x86 targets -include $(CONFIG)/os/CONFIG.Common.linux-x86 - -ARCH_DEP_CFLAGS = -march=i486 - -ifeq ($(BUILD_CLASS),CROSS) - VALID_BUILDS = Ioc Command -endif - -# If your crosscompiler name has a GNU target prefix like -gcc, -# e.g. i486-pc-linux-gnu-gcc, put a GNU_TARGET definition in -# CONFIG_SITE..linux-486 file, e.g. GNU_TARGET=i486-pc-linux-gnu - diff --git a/configure/os/CONFIG.Common.linux-586 b/configure/os/CONFIG.Common.linux-586 deleted file mode 100644 index b2b3b9b5c..000000000 --- a/configure/os/CONFIG.Common.linux-586 +++ /dev/null @@ -1,21 +0,0 @@ -# CONFIG.Common.linux-586 -# -# Definitions for linux-586 target builds -# Sites may override these definitions in CONFIG_SITE.Common.linux-586 -#------------------------------------------------------- - -# Include definitions common to all linux x86 targets -include $(CONFIG)/os/CONFIG.Common.linux-x86 - -# i586 is equivalent to pentium -ARCH_DEP_CFLAGS = -march=i586 - -ifeq ($(BUILD_CLASS),CROSS) - VALID_BUILDS = Ioc Command -endif - -# If your crosscompiler name has a GNU target prefix like -gcc, -# e.g. i586-pc-linux-gnu-gcc, put a GNU_TARGET definition in -# CONFIG_SITE..linux-586 file, e.g. GNU_TARGET=i586-pc-linux-gnu - - diff --git a/configure/os/CONFIG.Common.linux-686 b/configure/os/CONFIG.Common.linux-686 deleted file mode 100644 index a327d7e43..000000000 --- a/configure/os/CONFIG.Common.linux-686 +++ /dev/null @@ -1,20 +0,0 @@ -# CONFIG.Common.linux-686 -# -# Definitions for linux-686 target builds -# Sites may override these definitions in CONFIG_SITE.Common.linux-686 -#------------------------------------------------------- - -# Include definitions common to all linux x86 targets -include $(CONFIG)/os/CONFIG.Common.linux-x86 - -# i686 is euivalent to pentiumpro -ARCH_DEP_CFLAGS = -march=i686 - -ifeq ($(BUILD_CLASS),CROSS) - VALID_BUILDS = Ioc Command -endif - -# If your crosscompiler name has a GNU target prefix like -gcc, -# e.g. i686-pc-linux-gnu-gcc, put a GNU_TARGET definition in -# CONFIG_SITE..linux-686 file, e.g. GNU_TARGET=i686-pc-linux-gnu - diff --git a/configure/os/CONFIG.Common.linux-athlon b/configure/os/CONFIG.Common.linux-athlon deleted file mode 100644 index a773a4996..000000000 --- a/configure/os/CONFIG.Common.linux-athlon +++ /dev/null @@ -1,19 +0,0 @@ -# CONFIG.Common.linux-athlon -# -# Definitions for linux-athlon target builds -# Sites may override these definitions in CONFIG_SITE.Common.linux-athlon -#------------------------------------------------------- - -# Include definitions common to all linux x86 targets -include $(CONFIG)/os/CONFIG.Common.linux-x86 - -ARCH_DEP_CFLAGS += -march=athlon-mp -mfpmath=sse - -ifeq ($(BUILD_CLASS),CROSS) - VALID_BUILDS = Ioc Command -endif - -# If your crosscompiler name has a GNU target prefix like -gcc, -# e.g. athlon-pc-linux-gnu-gcc, put a GNU_TARGET definition in -# CONFIG_SITE..linux-athlon file, e.g. GNU_TARGET=athlon-pc-linux-gnu - diff --git a/configure/os/CONFIG.linux-386.Common b/configure/os/CONFIG.linux-386.Common deleted file mode 100644 index 9a3633bdf..000000000 --- a/configure/os/CONFIG.linux-386.Common +++ /dev/null @@ -1,10 +0,0 @@ -# CONFIG.linux-386.Common -# -# Definitions for linux-386 host builds -# Sites may override these definitions in CONFIG_SITE.linux-386.Common -#------------------------------------------------------- - -#Include definitions common to unix hosts -include $(CONFIG)/os/CONFIG.UnixCommon.Common - -WIND_HOST_TYPE = x86-linux2 diff --git a/configure/os/CONFIG.linux-386.linux-386 b/configure/os/CONFIG.linux-386.linux-386 deleted file mode 100644 index f65ac46b7..000000000 --- a/configure/os/CONFIG.linux-386.linux-386 +++ /dev/null @@ -1,8 +0,0 @@ -# CONFIG.linux-386.linux-386 -# -# Definitions for linux-386 host - linux-386 target builds -# Sites may override these definitions in CONFIG_SITE.linux-386.linux-386 -#------------------------------------------------------- - -# Include linux-x86 compiler definitions -include $(CONFIG)/os/CONFIG.linux-x86.linux-x86 diff --git a/configure/os/CONFIG.linux-486.Common b/configure/os/CONFIG.linux-486.Common deleted file mode 100644 index c151b3218..000000000 --- a/configure/os/CONFIG.linux-486.Common +++ /dev/null @@ -1,10 +0,0 @@ -# CONFIG.linux-486.Common -# -# Definitions for linux-486 host builds -# Sites may override these definitions in CONFIG_SITE.linux-486.Common -#------------------------------------------------------- - -#Include definitions common to unix hosts -include $(CONFIG)/os/CONFIG.UnixCommon.Common - -WIND_HOST_TYPE = x86-linux2 diff --git a/configure/os/CONFIG.linux-486.linux-486 b/configure/os/CONFIG.linux-486.linux-486 deleted file mode 100644 index 551cacc29..000000000 --- a/configure/os/CONFIG.linux-486.linux-486 +++ /dev/null @@ -1,9 +0,0 @@ -# CONFIG.linux-486.linux-486 -# -# Definitions for linux-486 host - linux-486 target builds -# Sites may override these definitions in CONFIG_SITE.linux-486.linux-486 -#------------------------------------------------------- - -# Include linux-x86 compiler definitions -include $(CONFIG)/os/CONFIG.linux-x86.linux-x86 - diff --git a/configure/os/CONFIG.linux-586.Common b/configure/os/CONFIG.linux-586.Common deleted file mode 100644 index 43463e8a0..000000000 --- a/configure/os/CONFIG.linux-586.Common +++ /dev/null @@ -1,10 +0,0 @@ -# CONFIG.linux-586.Common -# -# Definitions for linux-586 host builds -# Sites may override these definitions in CONFIG_SITE.linux-586.Common -#------------------------------------------------------- - -#Include definitions common to unix hosts -include $(CONFIG)/os/CONFIG.UnixCommon.Common - -WIND_HOST_TYPE = x86-linux2 diff --git a/configure/os/CONFIG.linux-586.linux-586 b/configure/os/CONFIG.linux-586.linux-586 deleted file mode 100644 index 990bfad74..000000000 --- a/configure/os/CONFIG.linux-586.linux-586 +++ /dev/null @@ -1,9 +0,0 @@ -# CONFIG.linux-586.linux-586 -# -# Definitions for linux-586 host - linux-586 target builds -# Sites may override these definitions in CONFIG_SITE.linux-586.linux-586 -#------------------------------------------------------- - -# Include linux-x86 compiler definitions -include $(CONFIG)/os/CONFIG.linux-x86.linux-x86 - diff --git a/configure/os/CONFIG.linux-686.Common b/configure/os/CONFIG.linux-686.Common deleted file mode 100644 index f36cddeac..000000000 --- a/configure/os/CONFIG.linux-686.Common +++ /dev/null @@ -1,10 +0,0 @@ -# CONFIG.linux-686.Common -# -# Definitions for linux-686 host builds -# Sites may override these definitions in CONFIG_SITE.linux-686.Common -#------------------------------------------------------- - -#Include definitions common to unix hosts -include $(CONFIG)/os/CONFIG.UnixCommon.Common - -WIND_HOST_TYPE = x86-linux2 diff --git a/configure/os/CONFIG.linux-686.linux-686 b/configure/os/CONFIG.linux-686.linux-686 deleted file mode 100644 index e4195a40a..000000000 --- a/configure/os/CONFIG.linux-686.linux-686 +++ /dev/null @@ -1,9 +0,0 @@ -# CONFIG.linux-686.linux-686 -# -# Definitions for linux-686 host - linux-686 target builds -# Sites may override these definitions in CONFIG_SITE.linux-686.linux-686 -#------------------------------------------------------- - -# Include linux-x86 compiler definitions -include $(CONFIG)/os/CONFIG.linux-x86.linux-x86 - diff --git a/src/template/ext/top/configure/os/CONFIG.linux-x86.linux-386 b/src/template/ext/top/configure/os/CONFIG.linux-x86.linux-386 deleted file mode 100644 index ed73b3464..000000000 --- a/src/template/ext/top/configure/os/CONFIG.linux-x86.linux-386 +++ /dev/null @@ -1,2 +0,0 @@ - -include $(TOP)/configure/os/CONFIG_SITE.linux-x86.linux-x86 diff --git a/src/template/ext/top/configure/os/CONFIG_SITE.linux-x86.linux-athlon b/src/template/ext/top/configure/os/CONFIG_SITE.linux-x86.linux-athlon deleted file mode 100644 index 25036ccac..000000000 --- a/src/template/ext/top/configure/os/CONFIG_SITE.linux-x86.linux-athlon +++ /dev/null @@ -1,11 +0,0 @@ -# -# Site Specific Configuration Information -# Only the local epics system manager should modify this file - -# Where to find utilities/libraries -# If you do not have a certain product, -# leave the line empty. -# - - --include $(TOP)/configure/os/CONFIG_SITE.linux-x86.linux-x86 From 0f90793d17e85759fdb6f5d3fcece9b279e65a29 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 30 Apr 2021 10:15:58 -0500 Subject: [PATCH 160/195] Obsolete Extensions template files --- .../ext/top/configure/os/CONFIG_SITE.Common.Common | 10 ---------- .../configure/os/CONFIG_SITE.cygwin-x86.cygwin-x86 | 1 - .../configure/os/CONFIG_SITE.darwin-x86.darwin-x86 | 2 -- .../top/configure/os/CONFIG_SITE.linux-x86.linux-x86 | 2 -- .../os/CONFIG_SITE.solaris-sparc.solaris-sparc | 2 -- .../os/CONFIG_SITE.win32-x86-cygwin.win32-x86-cygwin | 11 ----------- .../top/configure/os/CONFIG_SITE.win32-x86.win32-x86 | 2 -- 7 files changed, 30 deletions(-) delete mode 100644 src/template/ext/top/configure/os/CONFIG_SITE.Common.Common delete mode 100644 src/template/ext/top/configure/os/CONFIG_SITE.win32-x86-cygwin.win32-x86-cygwin diff --git a/src/template/ext/top/configure/os/CONFIG_SITE.Common.Common b/src/template/ext/top/configure/os/CONFIG_SITE.Common.Common deleted file mode 100644 index 21363a633..000000000 --- a/src/template/ext/top/configure/os/CONFIG_SITE.Common.Common +++ /dev/null @@ -1,10 +0,0 @@ -# -# Site Specific Configuration Information -# Only the local epics system manager should modify this file - -# java jdk definitions -#CLASSPATH += -classpath .:..:$(INSTALL_JAVA):$(JAVA_DIR)/bin/../classes:$(JAVA_DIR)/bin/../lib/classes.zip -#JAVACCMD = $(subst \,/,$(JAVA_DIR)/bin/javac$(EXE) $(CLASSPATH) $(JAVAC_FLAGS) ) -#JAVAHCMD = $(subst \,/,$(JAVA_DIR)/bin/javah$(EXE) -jni $(CLASSPATH) $(JAVAH_FLAGS)) -#JARCMD = $(subst \,/,$(JAVA_DIR)/bin/jar$(EXE) $(JAR_OPTIONS) $(MANIFEST) $(JAR) $(JAR_INPUT)) - diff --git a/src/template/ext/top/configure/os/CONFIG_SITE.cygwin-x86.cygwin-x86 b/src/template/ext/top/configure/os/CONFIG_SITE.cygwin-x86.cygwin-x86 index f1745159b..9dd907a24 100644 --- a/src/template/ext/top/configure/os/CONFIG_SITE.cygwin-x86.cygwin-x86 +++ b/src/template/ext/top/configure/os/CONFIG_SITE.cygwin-x86.cygwin-x86 @@ -7,7 +7,6 @@ # leave the line empty. # --include $(TOP)/configure/os/CONFIG_SITE.Common.Common -include $(TOP)/configure/os/CONFIG_SITE.win32-x86.win32-x86 # ---------- java definitions diff --git a/src/template/ext/top/configure/os/CONFIG_SITE.darwin-x86.darwin-x86 b/src/template/ext/top/configure/os/CONFIG_SITE.darwin-x86.darwin-x86 index 9e98c70ef..74f12920b 100644 --- a/src/template/ext/top/configure/os/CONFIG_SITE.darwin-x86.darwin-x86 +++ b/src/template/ext/top/configure/os/CONFIG_SITE.darwin-x86.darwin-x86 @@ -7,8 +7,6 @@ # leave the line empty. # --include $(TOP)/configure/os/CONFIG_SITE.Common.Common - PYTHON_DIR=/usr/lib/python2.2 PYTHON_INCLUDE=/System/Library/Frameworks/Python.framework/Versions/2.3/include/python2.3 diff --git a/src/template/ext/top/configure/os/CONFIG_SITE.linux-x86.linux-x86 b/src/template/ext/top/configure/os/CONFIG_SITE.linux-x86.linux-x86 index 8641a9d27..e74accbf0 100644 --- a/src/template/ext/top/configure/os/CONFIG_SITE.linux-x86.linux-x86 +++ b/src/template/ext/top/configure/os/CONFIG_SITE.linux-x86.linux-x86 @@ -7,8 +7,6 @@ # leave the line empty. # --include $(TOP)/configure/os/CONFIG_SITE.Common.Common - #X11_LIB=/usr/X11R6/lib #X11_INC=/usr/X11R6/include #MOTIF_LIB=/usr/X11R6/lib diff --git a/src/template/ext/top/configure/os/CONFIG_SITE.solaris-sparc.solaris-sparc b/src/template/ext/top/configure/os/CONFIG_SITE.solaris-sparc.solaris-sparc index bd113bea3..db0622864 100644 --- a/src/template/ext/top/configure/os/CONFIG_SITE.solaris-sparc.solaris-sparc +++ b/src/template/ext/top/configure/os/CONFIG_SITE.solaris-sparc.solaris-sparc @@ -7,8 +7,6 @@ # leave the line empty. # --include $(TOP)/configure/os/CONFIG_SITE.Common.Common - # sun X11 X11_LIB = /usr/openwin/lib X11_INC = /usr/openwin/include diff --git a/src/template/ext/top/configure/os/CONFIG_SITE.win32-x86-cygwin.win32-x86-cygwin b/src/template/ext/top/configure/os/CONFIG_SITE.win32-x86-cygwin.win32-x86-cygwin deleted file mode 100644 index f6ca56942..000000000 --- a/src/template/ext/top/configure/os/CONFIG_SITE.win32-x86-cygwin.win32-x86-cygwin +++ /dev/null @@ -1,11 +0,0 @@ -# -# Site Specific Configuration Information -# Only the local epics system manager should modify this file - -# Where to find utilities/libraries -# If you do not have a certain product, -# leave the line empty. -# - --include $(TOP)/configure/os/CONFIG_SITE.cygwin-x86.cygwin-x86 - diff --git a/src/template/ext/top/configure/os/CONFIG_SITE.win32-x86.win32-x86 b/src/template/ext/top/configure/os/CONFIG_SITE.win32-x86.win32-x86 index 8118893a7..f2614098b 100644 --- a/src/template/ext/top/configure/os/CONFIG_SITE.win32-x86.win32-x86 +++ b/src/template/ext/top/configure/os/CONFIG_SITE.win32-x86.win32-x86 @@ -9,8 +9,6 @@ # leave the line empty. # --include $(TOP)/configure/os/CONFIG_SITE.Common.Common - # If objects were compiled with different default runtime libraries # (not a good idea), specify which one you want to use in the product # by making it the default and the others nodefault. Use From b5a3e4aea55915b941625e9506db6159c905deaa Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 5 Jun 2021 01:49:46 -0500 Subject: [PATCH 161/195] Drop RTEMS-gen68360, RTEMS-mcp750 and RTEMS-mvme167 --- configure/CONFIG_SITE | 15 +++++++-------- configure/os/CONFIG.Common.RTEMS-gen68360 | 10 ---------- configure/os/CONFIG.Common.RTEMS-mcp750 | 10 ---------- configure/os/CONFIG.Common.RTEMS-mvme167 | 10 ---------- configure/os/CONFIG_SITE.linux-x86.Common | 6 ++---- 5 files changed, 9 insertions(+), 42 deletions(-) delete mode 100644 configure/os/CONFIG.Common.RTEMS-gen68360 delete mode 100644 configure/os/CONFIG.Common.RTEMS-mcp750 delete mode 100644 configure/os/CONFIG.Common.RTEMS-mvme167 diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index a0a2d0959..03ec6d114 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -78,19 +78,18 @@ # vxWorks-mpc8548 # RTEMS-beagleboneblack # RTEMS-beatnik -# RTEMS-gen68360 -# RTEMS-mcp750 -# RTEMS-mvme167 # RTEMS-mvme2100 # RTEMS-mvme2700 # RTEMS-mvme3100 # RTEMS-mvme5500 -# RTEMS-pc386 -# RTEMS-pc686 -# RTEMS-qoriq_e500 +# RTEMS-pc386 (RTEMS 4) +# RTEMS-pc386-qemu (RTEMS 4) +# RTEMS-pc686 (RTEMS 5) +# RTEMS-pc686-qemu (RTEMS 5) +# RTEMS-qoriq_e500 # RTEMS-uC5282 -# RTEMS-xilinx-zynq_a9_qemu -# RTEMS-xilinx_zynq_zedboad +# RTEMS-xilinx-zynq-a9_qemu +# RTEMS-xilinx_zynq_zedboard # win32-x86-mingw (linux-x86 or -x86_64 host) # diff --git a/configure/os/CONFIG.Common.RTEMS-gen68360 b/configure/os/CONFIG.Common.RTEMS-gen68360 deleted file mode 100644 index 0a8a6e85e..000000000 --- a/configure/os/CONFIG.Common.RTEMS-gen68360 +++ /dev/null @@ -1,10 +0,0 @@ -# -# Author: W. Eric Norum -# Canadian Light Source -# eric@cls.usask.ca -# -# All RTEMS targets use the same Makefile fragment -# -RTEMS_BSP = gen68360 -RTEMS_TARGET_CPU = m68k -include $(CONFIG)/os/CONFIG.Common.RTEMS diff --git a/configure/os/CONFIG.Common.RTEMS-mcp750 b/configure/os/CONFIG.Common.RTEMS-mcp750 deleted file mode 100644 index 035e6eb36..000000000 --- a/configure/os/CONFIG.Common.RTEMS-mcp750 +++ /dev/null @@ -1,10 +0,0 @@ -# -# Author: W. Eric Norum -# Canadian Light Source -# eric@cls.usask.ca -# -# All RTEMS targets use the same Makefile fragment -# -RTEMS_BSP = mcp750 -RTEMS_TARGET_CPU = ppc -include $(CONFIG)/os/CONFIG.Common.RTEMS diff --git a/configure/os/CONFIG.Common.RTEMS-mvme167 b/configure/os/CONFIG.Common.RTEMS-mvme167 deleted file mode 100644 index 3651f966f..000000000 --- a/configure/os/CONFIG.Common.RTEMS-mvme167 +++ /dev/null @@ -1,10 +0,0 @@ -# -# Author: W. Eric Norum -# Canadian Light Source -# eric@cls.usask.ca -# -# All RTEMS targets use the same Makefile fragment -# -RTEMS_BSP = mvme167 -RTEMS_TARGET_CPU = m68k -include $(CONFIG)/os/CONFIG.Common.RTEMS diff --git a/configure/os/CONFIG_SITE.linux-x86.Common b/configure/os/CONFIG_SITE.linux-x86.Common index dc29e8f0d..afb74e914 100644 --- a/configure/os/CONFIG_SITE.linux-x86.Common +++ b/configure/os/CONFIG_SITE.linux-x86.Common @@ -3,7 +3,5 @@ # Site override definitions for linux-x86 host builds #------------------------------------------------------- -# JBA test override values -#CROSS_COMPILER_TARGET_ARCHS = vxWorks-68040 solaris-sparc -#CROSS_COMPILER_TARGET_ARCHS = vxWorks-68040 -#CROSS_COMPILER_TARGET_ARCHS = RTEMS-mvme2100 RTEMS-pc386 # RTEMS-mvme5500 RTEMS-mvme167 +#CROSS_COMPILER_TARGET_ARCHS = vxWorks-ppc32 +#CROSS_COMPILER_TARGET_ARCHS = RTEMS-mvme2100 RTEMS-pc386-qemu From dcee3b2c3397cc18d7d30f0d583c46a335c9c2b0 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 5 Jun 2021 02:10:28 -0500 Subject: [PATCH 162/195] Document removals --- documentation/RELEASE_NOTES.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index d932a0323..eaee85dbc 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -17,6 +17,16 @@ should also be read to understand what has changed since earlier releases. +### Support for obsolete architectures removed + +These target architectures have been removed: + ++ darwin-ppc, darwin-ppcx86 ++ linux-386, linux-486, linux-586, linux-686, linux-athlon (cross-build) ++ linux-cris, linux-cris_v10, linux-cris_v32 (cross-build) ++ RTEMS-at91rm9200ek, RTEMS-gen68360, RTEMS-mcp750, RTEMS-mvme167, +RTEMS-psim (cross-build) + ### Experimental Support for RTEMS 5 The new major release of the RTEMS real-time OS contains many changes From 5ccc11569b8e98be1a7123c50721b5546ebb0105 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 5 Jun 2021 02:16:43 -0500 Subject: [PATCH 163/195] Oops, fix path --- modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c b/modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c index 3d93a07ae..8ae1503ec 100644 --- a/modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c +++ b/modules/libcom/src/osi/os/RTEMS-posix/devLibVMEOSD.c @@ -2,5 +2,5 @@ #include "os/RTEMS-score/devLibVMEOSD.c" #else #pragma message "\n VME Support requires the RTEMS Legacy stack\n" -#include "default/devLibVMEOSD.c" +#include "os/default/devLibVMEOSD.c" #endif From b42a1458245a219555c6358f78fdda69a6c1c842 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 3 May 2021 18:12:39 -0500 Subject: [PATCH 164/195] Regression tests for RSET::special() return status Adds tests to ensure that a record's special() routine can return an error status that gets fed back to the client from both before and after special() calls. This was broken from 3.15 through 7.0.5 inclusive. --- modules/database/test/ioc/db/dbPutGetTest.c | 22 +++++++++++++++++++- modules/database/test/ioc/db/dbPutGetTest.db | 2 ++ modules/database/test/ioc/db/xRecord.c | 14 ++++++++++++- modules/database/test/ioc/db/xRecord.dbd | 12 +++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) diff --git a/modules/database/test/ioc/db/dbPutGetTest.c b/modules/database/test/ioc/db/dbPutGetTest.c index e1492a5a9..a515d590b 100644 --- a/modules/database/test/ioc/db/dbPutGetTest.c +++ b/modules/database/test/ioc/db/dbPutGetTest.c @@ -313,11 +313,29 @@ void testPutArr(void) testdbGetArrFieldEqual("arr", DBR_LONG, 4, 3, buf); } +static +void testPutSpecial(void) +{ + const char val[] = "special"; + const char sfx[] = "special.SFX"; + testDiag("testPutSpecial()"); + + testdbPutFieldOk(val, DBR_LONG, 1); + testdbPutFieldOk(sfx, DBR_LONG, SFX_Before); /* Reject early */ + testdbPutFieldFail(S_db_Blocked, val, DBR_LONG, 2); + testdbGetFieldEqual(val, DBR_LONG, 1); /* Wasn't modified */ + testdbPutFieldOk(sfx, DBR_LONG, SFX_After); /* Reject late */ + testdbPutFieldFail(S_db_Blocked, val, DBR_LONG, 3); + testdbPutFieldOk(sfx, DBR_LONG, SFX_None); + testdbPutFieldOk(val, DBR_LONG, 4); +} + + void dbTestIoc_registerRecordDeviceDriver(struct dbBase *); MAIN(dbPutGet) { - testPlan(111); + testPlan(119); testdbPrepare(); testdbMetaDoubleSizes(); @@ -343,6 +361,8 @@ MAIN(dbPutGet) testPutArr(); + testPutSpecial(); + testIocShutdownOk(); testdbCleanup(); diff --git a/modules/database/test/ioc/db/dbPutGetTest.db b/modules/database/test/ioc/db/dbPutGetTest.db index 68485e4ba..ccfc43998 100644 --- a/modules/database/test/ioc/db/dbPutGetTest.db +++ b/modules/database/test/ioc/db/dbPutGetTest.db @@ -46,3 +46,5 @@ record(arr, "arr") { } record(x, "recmeta") {} + +record(x, "special") {} diff --git a/modules/database/test/ioc/db/xRecord.c b/modules/database/test/ioc/db/xRecord.c index 83ca9b15c..001b5ea16 100644 --- a/modules/database/test/ioc/db/xRecord.c +++ b/modules/database/test/ioc/db/xRecord.c @@ -76,6 +76,19 @@ static long process(struct dbCommon *pcommon) return ret; } +static long special(struct dbAddr *paddr, int after) +{ + struct xRecord *prec = (struct xRecord *) paddr->precord; + if (dbGetFieldIndex(paddr) != xRecordVAL) { + recGblRecordError(S_db_badField, prec, "x: special"); + return S_db_badField; + } + if (prec->sfx == after) { + return S_db_Blocked; + } + return 0; +} + long get_units(struct dbAddr *paddr, char *units) { if(dbGetFieldIndex(paddr)==xRecordOTST) { @@ -125,7 +138,6 @@ long get_alarm_double(struct dbAddr *paddr, struct dbr_alDouble *p) #define report NULL #define initialize NULL -#define special NULL #define get_value NULL #define cvt_dbaddr NULL #define get_array_info NULL diff --git a/modules/database/test/ioc/db/xRecord.dbd b/modules/database/test/ioc/db/xRecord.dbd index 13fcb3f3e..7cbbdabe5 100644 --- a/modules/database/test/ioc/db/xRecord.dbd +++ b/modules/database/test/ioc/db/xRecord.dbd @@ -1,9 +1,16 @@ # This is a minimal record definition +menu(xSFX) { + choice(SFX_Before, "Before") + choice(SFX_After, "After") + choice(SFX_None, "None") +} + recordtype(x) { include "dbCommon.dbd" field(VAL, DBF_LONG) { prompt("Value") + special(SPC_MOD) } field(C8, DBF_CHAR) { prompt("Char") @@ -50,4 +57,9 @@ recordtype(x) { prompt("dbGet() options test") special(SPC_NOMOD) } + field(SFX, DBF_MENU) { + prompt("Special effects") + menu(xSFX) + initial("None") + } } From 6c7214ee064bbfd21ec76dea607fc0ab545d09ac Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 6 May 2021 18:20:59 -0500 Subject: [PATCH 165/195] Add tests for special link fields too --- modules/database/test/ioc/db/dbPutGetTest.c | 12 +++++++++++- modules/database/test/ioc/db/xRecord.c | 3 ++- modules/database/test/ioc/db/xRecord.dbd | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/modules/database/test/ioc/db/dbPutGetTest.c b/modules/database/test/ioc/db/dbPutGetTest.c index a515d590b..8f539407d 100644 --- a/modules/database/test/ioc/db/dbPutGetTest.c +++ b/modules/database/test/ioc/db/dbPutGetTest.c @@ -317,17 +317,27 @@ static void testPutSpecial(void) { const char val[] = "special"; + const char inp[] = "special.INP"; const char sfx[] = "special.SFX"; testDiag("testPutSpecial()"); + /* There are separate sets of calls to dbPutSpecial() in + * dbPut() and in dbPutFieldLink() so we need to check + * both regular fields and link fields. + */ testdbPutFieldOk(val, DBR_LONG, 1); + testdbPutFieldOk(inp, DBR_STRING, "1.0"); testdbPutFieldOk(sfx, DBR_LONG, SFX_Before); /* Reject early */ testdbPutFieldFail(S_db_Blocked, val, DBR_LONG, 2); testdbGetFieldEqual(val, DBR_LONG, 1); /* Wasn't modified */ + testdbPutFieldFail(S_db_Blocked, inp, DBR_STRING, "2.0"); + testdbGetFieldEqual(inp, DBR_STRING, "1.0"); /* Wasn't modified */ testdbPutFieldOk(sfx, DBR_LONG, SFX_After); /* Reject late */ testdbPutFieldFail(S_db_Blocked, val, DBR_LONG, 3); + testdbPutFieldFail(S_db_Blocked, inp, DBR_STRING, "3.0"); testdbPutFieldOk(sfx, DBR_LONG, SFX_None); testdbPutFieldOk(val, DBR_LONG, 4); + testdbPutFieldOk(inp, DBR_STRING, "4.0"); } @@ -335,7 +345,7 @@ void dbTestIoc_registerRecordDeviceDriver(struct dbBase *); MAIN(dbPutGet) { - testPlan(119); + testPlan(124); testdbPrepare(); testdbMetaDoubleSizes(); diff --git a/modules/database/test/ioc/db/xRecord.c b/modules/database/test/ioc/db/xRecord.c index 001b5ea16..cd8fa74df 100644 --- a/modules/database/test/ioc/db/xRecord.c +++ b/modules/database/test/ioc/db/xRecord.c @@ -79,7 +79,8 @@ static long process(struct dbCommon *pcommon) static long special(struct dbAddr *paddr, int after) { struct xRecord *prec = (struct xRecord *) paddr->precord; - if (dbGetFieldIndex(paddr) != xRecordVAL) { + if (dbGetFieldIndex(paddr) != xRecordVAL && + dbGetFieldIndex(paddr) != xRecordINP) { recGblRecordError(S_db_badField, prec, "x: special"); return S_db_badField; } diff --git a/modules/database/test/ioc/db/xRecord.dbd b/modules/database/test/ioc/db/xRecord.dbd index 7cbbdabe5..620deac61 100644 --- a/modules/database/test/ioc/db/xRecord.dbd +++ b/modules/database/test/ioc/db/xRecord.dbd @@ -47,6 +47,7 @@ recordtype(x) { } field(INP, DBF_INLINK) { prompt("Input Link") + special(SPC_MOD) } field(CLBK, DBF_NOACCESS) { prompt("Processing callback") From 3c329c1b48fd25f337745764dd853c3d343f12b5 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 10 Jun 2021 10:15:08 -0500 Subject: [PATCH 166/195] Disable some RTEMS targets, tests on RTEMS-pc686-qemu --- .github/workflows/ci-scripts-build.yml | 34 ++++++++++++++------------ 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index d94fbf312..a159de457 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -85,6 +85,7 @@ jobs: configuration: default rtems: "5" rtems_target: RTEMS-pc686-qemu + test: NO name: "Ub-20 gcc-9 + RT-5.1 pc686" - os: ubuntu-20.04 @@ -95,21 +96,24 @@ jobs: test: NO name: "Ub-20 gcc-9 + RT-5.1 beatnik" - - os: ubuntu-20.04 - cmp: gcc - configuration: default - rtems: "5" - rtems_target: RTEMS-mvme3100 - test: NO - name: "Ub-20 gcc-9 + RT-5.1 mvme3100" - - - os: ubuntu-20.04 - cmp: gcc - configuration: default - rtems: "5" - rtems_target: RTEMS-qoriq_e500 - test: NO - name: "Ub-20 gcc-9 + RT-5.1 qoriq_e500" + # Only build one RTEMS target per CPU family + # unless it's running the tests + # + # - os: ubuntu-20.04 + # cmp: gcc + # configuration: default + # rtems: "5" + # rtems_target: RTEMS-mvme3100 + # test: NO + # name: "Ub-20 gcc-9 + RT-5.1 mvme3100" + # + # - os: ubuntu-20.04 + # cmp: gcc + # configuration: default + # rtems: "5" + # rtems_target: RTEMS-qoriq_e500 + # test: NO + # name: "Ub-20 gcc-9 + RT-5.1 qoriq_e500" - os: ubuntu-20.04 cmp: gcc From f825136f652de0cc99b818891a5cefd3844c53c4 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 14 Jun 2021 18:22:23 -0500 Subject: [PATCH 167/195] makeBaseApp.pl: Allow relative paths to $0 --- src/template/base/makeBaseApp.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/template/base/makeBaseApp.pl b/src/template/base/makeBaseApp.pl index e2df38dd6..f5b36d250 100644 --- a/src/template/base/makeBaseApp.pl +++ b/src/template/base/makeBaseApp.pl @@ -168,7 +168,7 @@ sub get_commandline_opts { #no args Cleanup(0) if $opt_h; # Locate epics_base - my ($command) = UnixPath($0); + my ($command) = UnixPath(AbsPath($0)); if ($opt_b) { # first choice is -b base $epics_base = UnixPath($opt_b); } elsif ($release{"EPICS_BASE"}) { # second choice is configure/RELEASE From b471e8388fa0b7b79471e4a883277ca8f8d5601b Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Mon, 14 Jun 2021 18:23:47 -0500 Subject: [PATCH 168/195] GHA: Don't worry if no artifacts to upload --- .github/workflows/ci-scripts-build.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/ci-scripts-build.yml b/.github/workflows/ci-scripts-build.yml index a159de457..b9b3a0c12 100644 --- a/.github/workflows/ci-scripts-build.yml +++ b/.github/workflows/ci-scripts-build.yml @@ -230,6 +230,7 @@ jobs: with: name: tapfiles ${{ matrix.name }} path: '**/O.*/*.tap' + if-no-files-found: ignore - name: Collect and show test results if: ${{ always() }} run: python .ci/cue.py -T 5M test-results From 256babf9614a199709e2728f0ecd79bf57b668ec Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 15 Jun 2021 08:01:14 -0700 Subject: [PATCH 169/195] quiet use "may be used uninitialized" warnings --- modules/database/src/ioc/db/dbUnitTest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/database/src/ioc/db/dbUnitTest.c b/modules/database/src/ioc/db/dbUnitTest.c index a4830a37c..805031bc2 100644 --- a/modules/database/src/ioc/db/dbUnitTest.c +++ b/modules/database/src/ioc/db/dbUnitTest.c @@ -266,7 +266,7 @@ done: void testdbPutArrFieldOk(const char* pv, short dbrType, unsigned long count, const void *pbuf) { dbChannel *chan = dbChannelCreate(pv); - long status; + long status = -1; if(!chan || (status=dbChannelOpen(chan))) { testFail("Channel error (%p, %ld) : %s", chan, status, pv); @@ -289,7 +289,7 @@ void testdbGetArrFieldEqual(const char* pv, short dbfType, long nRequest, unsign const long vSize = dbValueSize(dbfType); const long nStore = vSize * nRequest; long status = S_dbLib_recNotFound; - char *gbuf, *gstore; + char *gbuf, *gstore = NULL; const char *pbuf = pbufraw; if(!chan || (status=dbChannelOpen(chan))) { From b35064d26ccc2d94e95331225f8638a5f02777d0 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 23 Jun 2019 10:36:52 -0700 Subject: [PATCH 170/195] Revert "dbEvent simplify db_close_events() with join" This reverts commit 37a76b433a9e7d5a8d26a13fd21ad62f20a0c1c1. # Conflicts: # modules/database/src/ioc/db/dbEvent.c --- modules/database/src/ioc/db/dbEvent.c | 74 ++++++++++++++++++--------- 1 file changed, 51 insertions(+), 23 deletions(-) diff --git a/modules/database/src/ioc/db/dbEvent.c b/modules/database/src/ioc/db/dbEvent.c index 7342a0852..65e3488ad 100644 --- a/modules/database/src/ioc/db/dbEvent.c +++ b/modules/database/src/ioc/db/dbEvent.c @@ -84,6 +84,7 @@ struct event_user { epicsMutexId lock; epicsEventId ppendsem; /* Wait while empty */ epicsEventId pflush_sem; /* wait for flush */ + epicsEventId pexitsem; /* wait for event task to join */ EXTRALABORFUNC *extralabor_sub;/* off load to event task */ void *extralabor_arg;/* parameter to above */ @@ -122,6 +123,8 @@ static char *EVENT_PEND_NAME = "eventTask"; static struct evSubscrip canceledEvent; +static epicsMutexId stopSync; + static unsigned short ringSpace ( const struct event_que *pevq ) { if ( pevq->evque[pevq->putix] == EVENTQEMPTY ) { @@ -260,6 +263,10 @@ int dbel ( const char *pname, unsigned level ) */ void db_init_event_freelists (void) { + if (!stopSync) { + stopSync = epicsMutexMustCreate(); + } + if (!dbevEventUserFreeList) { freeListInitPvt(&dbevEventUserFreeList, sizeof(struct event_user),8); @@ -299,6 +306,9 @@ dbEventCtx db_init_events (void) return NULL; } + /* Flag will be cleared when event task starts */ + evUser->pendexit = TRUE; + evUser->firstque.evUser = evUser; evUser->firstque.writelock = epicsMutexCreate(); if (!evUser->firstque.writelock) @@ -313,6 +323,9 @@ dbEventCtx db_init_events (void) evUser->lock = epicsMutexCreate(); if (!evUser->lock) goto fail; + evUser->pexitsem = epicsEventCreate(epicsEventEmpty); + if (!evUser->pexitsem) + goto fail; evUser->flowCtrlMode = FALSE; evUser->extraLaborBusy = FALSE; @@ -327,6 +340,8 @@ fail: epicsEventDestroy (evUser->ppendsem); if(evUser->pflush_sem) epicsEventDestroy (evUser->pflush_sem); + if(evUser->pexitsem) + epicsEventDestroy (evUser->pexitsem); freeListFree(dbevEventUserFreeList,evUser); return NULL; } @@ -347,6 +362,7 @@ DBCORE_API void db_cleanup_events(void) dbevFieldLogFreeList = NULL; } + /* intentionally leak stopSync to avoid possible shutdown races */ /* * DB_CLOSE_EVENTS() * @@ -368,15 +384,30 @@ void db_close_events (dbEventCtx ctx) * hazardous to the system's health. */ epicsMutexMustLock ( evUser->lock ); - evUser->pendexit = TRUE; + if(!evUser->pendexit) { /* event task running */ + evUser->pendexit = TRUE; + epicsMutexUnlock ( evUser->lock ); + + /* notify the waiting task */ + epicsEventSignal(evUser->ppendsem); + /* wait for task to exit */ + epicsEventMustWait(evUser->pexitsem); + + epicsMutexMustLock ( evUser->lock ); + } + epicsMutexUnlock ( evUser->lock ); - /* notify the waiting task */ - epicsEventSignal(evUser->ppendsem); + epicsMutexMustLock (stopSync); - if(evUser->taskid) - epicsThreadMustJoin(evUser->taskid); - /* evUser has been deleted by the worker */ + epicsEventDestroy(evUser->pexitsem); + epicsEventDestroy(evUser->ppendsem); + epicsEventDestroy(evUser->pflush_sem); + epicsMutexDestroy(evUser->lock); + + epicsMutexUnlock (stopSync); + + freeListFree(dbevEventUserFreeList, evUser); } /* @@ -1063,18 +1094,17 @@ static void event_task (void *pParm) } } - epicsEventDestroy(evUser->ppendsem); - epicsEventDestroy(evUser->pflush_sem); - epicsMutexDestroy(evUser->lock); - - if (dbevEventUserFreeList) - freeListFree(dbevEventUserFreeList, evUser); - else - fprintf(stderr, "%s exiting but dbevEventUserFreeList already NULL\n", - __FUNCTION__); - taskwdRemove(epicsThreadGetIdSelf()); + /* use stopSync to ensure pexitsem is not destroy'd + * until epicsEventSignal() has returned. + */ + epicsMutexMustLock (stopSync); + + epicsEventSignal(evUser->pexitsem); + + epicsMutexUnlock(stopSync); + return; } @@ -1086,11 +1116,6 @@ int db_start_events ( void *init_func_arg, unsigned osiPriority ) { struct event_user * const evUser = (struct event_user *) ctx; - epicsThreadOpts opts = EPICS_THREAD_OPTS_INIT; - - opts.stackSize = epicsThreadGetStackSize(epicsThreadStackMedium); - opts.priority = osiPriority; - opts.joinable = 1; epicsMutexMustLock ( evUser->lock ); @@ -1108,12 +1133,15 @@ int db_start_events ( if (!taskname) { taskname = EVENT_PEND_NAME; } - evUser->taskid = epicsThreadCreateOpt ( - taskname, event_task, (void *)evUser, &opts); + evUser->taskid = epicsThreadCreate ( + taskname, osiPriority, + epicsThreadGetStackSize(epicsThreadStackMedium), + event_task, (void *)evUser); if (!evUser->taskid) { epicsMutexUnlock ( evUser->lock ); return DB_EVENT_ERROR; } + evUser->pendexit = FALSE; epicsMutexUnlock ( evUser->lock ); return DB_EVENT_OK; } From ca2ea14082bdadb3ea8f7b7ad967fd42b41e6a41 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Fri, 2 Apr 2021 19:00:46 -0700 Subject: [PATCH 171/195] dbEvent: join worker --- modules/database/src/ioc/db/dbEvent.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/modules/database/src/ioc/db/dbEvent.c b/modules/database/src/ioc/db/dbEvent.c index 65e3488ad..b3c641798 100644 --- a/modules/database/src/ioc/db/dbEvent.c +++ b/modules/database/src/ioc/db/dbEvent.c @@ -392,6 +392,7 @@ void db_close_events (dbEventCtx ctx) epicsEventSignal(evUser->ppendsem); /* wait for task to exit */ epicsEventMustWait(evUser->pexitsem); + epicsThreadMustJoin(evUser->taskid); epicsMutexMustLock ( evUser->lock ); } @@ -1116,6 +1117,11 @@ int db_start_events ( void *init_func_arg, unsigned osiPriority ) { struct event_user * const evUser = (struct event_user *) ctx; + epicsThreadOpts opts = EPICS_THREAD_OPTS_INIT; + + opts.stackSize = epicsThreadGetStackSize(epicsThreadStackMedium); + opts.priority = osiPriority; + opts.joinable = 1; epicsMutexMustLock ( evUser->lock ); @@ -1133,10 +1139,8 @@ int db_start_events ( if (!taskname) { taskname = EVENT_PEND_NAME; } - evUser->taskid = epicsThreadCreate ( - taskname, osiPriority, - epicsThreadGetStackSize(epicsThreadStackMedium), - event_task, (void *)evUser); + evUser->taskid = epicsThreadCreateOpt ( + taskname, event_task, (void *)evUser, &opts); if (!evUser->taskid) { epicsMutexUnlock ( evUser->lock ); return DB_EVENT_ERROR; From 983f77e1196f81c527cf9b7114e1260157981b1e Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 17 Jun 2021 13:34:00 -0500 Subject: [PATCH 172/195] Let build find convertRelease.pl before it's installed There are several different cases that FIND_TOOL has to handle, and all 3 file paths given are needed in different circumstances: 1. First build of Base after checkout/untar 2. During builds after the script has been installed 3. In a submodule during 'make distclean' or 'make cvsclean' Fixes lp: #1932033 --- configure/CONFIG_BASE | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/configure/CONFIG_BASE b/configure/CONFIG_BASE index 03d0ff7be..4b15e4cdc 100644 --- a/configure/CONFIG_BASE +++ b/configure/CONFIG_BASE @@ -31,10 +31,12 @@ endif # BASE_TOP # Where to find the installed build tools # Windows does not like commands with relative paths starting ../ # so TOOLS must be an absolute path, although Perl scripts are OK. -# FIND_TOOL is for scripts run before the build reaches src/tools. +# FIND_TOOL is for scripts run before the build reaches src/tools +# and must also work in submodules when EPICS_BASE is not built. TOOLS = $(abspath $(EPICS_BASE_HOST_BIN)) -FIND_TOOL = $(firstword $(wildcard $(TOOLS)/$(1) $(EPICS_BASE)/src/tools/$(1))) +FIND_TOOL = $(firstword $(wildcard $(TOOLS)/$(1) \ + $(TOP)/src/tools/$(1)) $(EPICS_BASE)/src/tools/$(1)) #--------------------------------------------------------------- # EPICS Base build tools and tool flags From b5265ed853457e546e320758ee7e4ab6dff93b27 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Sun, 20 Jun 2021 12:22:15 -0500 Subject: [PATCH 173/195] Fix vxWorks version of epicsAtomicCmpAndSwapIntT() vxCas() returns TRUE or FALSE, not the original target value. Fixes lp: #1932118 --- .../src/osi/os/vxWorks/epicsAtomicOSD.h | 72 +++++++------------ 1 file changed, 27 insertions(+), 45 deletions(-) diff --git a/modules/libcom/src/osi/os/vxWorks/epicsAtomicOSD.h b/modules/libcom/src/osi/os/vxWorks/epicsAtomicOSD.h index 2ea1924ae..bdf48870a 100644 --- a/modules/libcom/src/osi/os/vxWorks/epicsAtomicOSD.h +++ b/modules/libcom/src/osi/os/vxWorks/epicsAtomicOSD.h @@ -24,6 +24,33 @@ #include "vxWorks.h" /* obtain the version of vxWorks */ #include "epicsAssert.h" +#include "vxLib.h" +#include "intLib.h" + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#ifndef EPICS_ATOMIC_LOCK +#define EPICS_ATOMIC_LOCK + +typedef struct EpicsAtomicLockKey { int m_key; } EpicsAtomicLockKey; + +EPICS_ATOMIC_INLINE void epicsAtomicLock ( EpicsAtomicLockKey * pKey ) +{ + pKey->m_key = intLock (); +} + +EPICS_ATOMIC_INLINE void epicsAtomicUnlock ( EpicsAtomicLockKey * pKey ) +{ + intUnlock ( pKey->m_key ); +} +#endif + +#ifdef __cplusplus +} /* end of extern "C" */ +#endif /* __cplusplus */ + /* * With vxWorks 6.6 and later we need to use vxAtomicLib * to implement this functionality correctly on SMP systems @@ -123,26 +150,6 @@ EPICS_ATOMIC_INLINE size_t epicsAtomicSubSizeT ( size_t * pTarget, size_t delta } #endif -#ifndef EPICS_ATOMIC_CAS_SIZET -#define EPICS_ATOMIC_CAS_SIZET -EPICS_ATOMIC_INLINE size_t epicsAtomicCmpAndSwapSizeT ( size_t * pTarget, - size_t oldVal, size_t newVal ) -{ - atomic_t * const pTarg = ( atomic_t * ) ( pTarget ); - return ( size_t ) vxCas ( pTarg, (atomic_t) oldVal, (atomic_t) newVal ); -} -#endif - -#ifndef EPICS_ATOMIC_CAS_PTRT -#define EPICS_ATOMIC_CAS_PTRT -EPICS_ATOMIC_INLINE EpicsAtomicPtrT epicsAtomicCmpAndSwapPtrT ( EpicsAtomicPtrT * pTarget, - EpicsAtomicPtrT oldVal, EpicsAtomicPtrT newVal ) -{ - atomic_t * const pTarg = ( atomic_t * ) ( pTarget ); - return (EpicsAtomicPtrT) vxCas ( pTarg, (atomic_t) oldVal, (atomic_t) newVal ); -} -#endif - #else /* ULONG_MAX == UINT_MAX */ /* @@ -190,15 +197,6 @@ EPICS_ATOMIC_INLINE int epicsAtomicAddIntT ( int * pTarget, int delta ) } #endif -#ifndef EPICS_ATOMIC_CAS_INTT -#define EPICS_ATOMIC_CAS_INTT -EPICS_ATOMIC_INLINE int epicsAtomicCmpAndSwapIntT ( int * pTarget, - int oldVal, int newVal ) -{ - atomic_t * const pTarg = ( atomic_t * ) ( pTarget ); - return ( int ) vxCas ( pTarg, (atomic_t) oldVal, (atomic_t) newVal ); -} -#endif #ifdef __cplusplus } /* end of extern "C" */ @@ -215,22 +213,6 @@ EPICS_ATOMIC_INLINE int epicsAtomicCmpAndSwapIntT ( int * pTarget, extern "C" { #endif /* __cplusplus */ -#ifndef EPICS_ATOMIC_LOCK -#define EPICS_ATOMIC_LOCK - -typedef struct EpicsAtomicLockKey { int m_key; } EpicsAtomicLockKey; - -EPICS_ATOMIC_INLINE void epicsAtomicLock ( EpicsAtomicLockKey * pKey ) -{ - pKey->m_key = intLock (); -} - -EPICS_ATOMIC_INLINE void epicsAtomicUnlock ( EpicsAtomicLockKey * pKey ) -{ - intUnlock ( pKey->m_key ); -} -#endif - #ifndef EPICS_ATOMIC_READ_MEMORY_BARRIER #define EPICS_ATOMIC_READ_MEMORY_BARRIER /* From ac6eb5e212270efbd8dcc95bb73ea9ac46ae7c32 Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Sun, 20 Jun 2021 12:29:41 -0500 Subject: [PATCH 174/195] Protect callbackRequest() from failed callbackInit() Fixes lp: #1932120 --- modules/database/src/ioc/db/callback.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/modules/database/src/ioc/db/callback.c b/modules/database/src/ioc/db/callback.c index 3fa249392..4a26e27ac 100644 --- a/modules/database/src/ioc/db/callback.c +++ b/modules/database/src/ioc/db/callback.c @@ -263,7 +263,9 @@ void callbackCleanup(void) assert(epicsAtomicGetIntT(&mySet->threadsRunning)==0); epicsEventDestroy(mySet->semWakeUp); + mySet->semWakeUp = NULL; epicsRingPointerDelete(mySet->queue); + mySet->queue = NULL; } epicsTimerQueueRelease(timerQueue); @@ -333,6 +335,10 @@ int callbackRequest(epicsCallback *pcallback) return S_db_badChoice; } mySet = &callbackQueue[priority]; + if (!mySet->queue) { + epicsInterruptContextMessage("callbackRequest: Callbacks not initialized\n"); + return S_db_notInit; + } if (mySet->queueOverflow) return S_db_bufFull; pushOK = epicsRingPointerPush(mySet->queue, pcallback); From cb5f68994fbe43ebaf3c06361ae7e793aef8892c Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sun, 20 Jun 2021 12:47:38 -0500 Subject: [PATCH 175/195] Squish various compiler warnings * CPP's defined() is UB outside of a #if line * Use (void)! cast to prevent recent GCCs & glibc from warning about ignoring the return status from chdir() --- modules/ca/src/client/caRepeater.cpp | 2 +- modules/ca/src/perl/Cap5.xs | 8 ++++---- modules/libcom/src/osi/os/posix/osdThread.c | 7 ++++++- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/ca/src/client/caRepeater.cpp b/modules/ca/src/client/caRepeater.cpp index 7eaab508b..c8385ba3b 100644 --- a/modules/ca/src/client/caRepeater.cpp +++ b/modules/ca/src/client/caRepeater.cpp @@ -90,7 +90,7 @@ int main(int argc, char* argv[]) (void)detachinout; #endif - chdir ( "/" ); + (void)! chdir ( "/" ); ca_repeater (); return ( 0 ); } diff --git a/modules/ca/src/perl/Cap5.xs b/modules/ca/src/perl/Cap5.xs index cc729340a..6d06a15f1 100644 --- a/modules/ca/src/perl/Cap5.xs +++ b/modules/ca/src/perl/Cap5.xs @@ -606,12 +606,12 @@ void CA_put(SV *ca_ref, SV *val, ...) { } } else { union { + void *dbr; dbr_char_t *dbr_char; dbr_long_t *dbr_long; dbr_double_t *dbr_double; char *dbr_string; - void *dbr; - } p; + } p = {0}; int i; chtype type = best_type(pch); @@ -699,12 +699,12 @@ void CA_put_callback(SV *ca_ref, SV *sub, SV *val, ...) { } } else { union { + void *dbr; dbr_char_t *dbr_char; dbr_long_t *dbr_long; dbr_double_t *dbr_double; char *dbr_string; - void *dbr; - } p; + } p = {0}; int i; chtype type = best_type(pch); diff --git a/modules/libcom/src/osi/os/posix/osdThread.c b/modules/libcom/src/osi/os/posix/osdThread.c index 50bb714e0..61a67f62c 100644 --- a/modules/libcom/src/osi/os/posix/osdThread.c +++ b/modules/libcom/src/osi/os/posix/osdThread.c @@ -24,7 +24,12 @@ #include #include -#define USE_MEMLOCK (defined(_POSIX_MEMLOCK) && (_POSIX_MEMLOCK > 0) && !defined(__rtems__)) +#if (defined(_POSIX_MEMLOCK) && (_POSIX_MEMLOCK > 0) && !defined(__rtems__)) +# define USE_MEMLOCK 1 +#else +# define USE_MEMLOCK 0 +#endif + #if USE_MEMLOCK #include #endif From ce876d6f114fa1e293c1b278bc11f05bba4cb886 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sun, 20 Jun 2021 13:13:31 -0500 Subject: [PATCH 176/195] Adjust RTEMS-mvme2100 and -mvme2700 build config's Untested. These changes let them build, but `make -j` is still broken. --- configure/os/CONFIG.Common.RTEMS-mvme2100 | 1 + configure/os/CONFIG.Common.RTEMS-mvme2700 | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/configure/os/CONFIG.Common.RTEMS-mvme2100 b/configure/os/CONFIG.Common.RTEMS-mvme2100 index 1e222b5ab..930b33bad 100644 --- a/configure/os/CONFIG.Common.RTEMS-mvme2100 +++ b/configure/os/CONFIG.Common.RTEMS-mvme2100 @@ -19,6 +19,7 @@ define MUNCH_CMD $(PROJECT_RELEASE)/lib/bootloader.o \ --just-symbols=$< \ -b binary rtems.gz \ + --no-warn-mismatch \ -T $(PROJECT_RELEASE)/lib/ppcboot.lds \ -Map $<.map rm -f rtems.gz diff --git a/configure/os/CONFIG.Common.RTEMS-mvme2700 b/configure/os/CONFIG.Common.RTEMS-mvme2700 index 655e0a5b0..0ee8ac862 100644 --- a/configure/os/CONFIG.Common.RTEMS-mvme2700 +++ b/configure/os/CONFIG.Common.RTEMS-mvme2700 @@ -1,7 +1,7 @@ # # Author: Matt Rippa # -RTEMS_BSP = mvme2700 +RTEMS_BSP = mvme2307 RTEMS_TARGET_CPU = powerpc ARCH_DEP_CFLAGS += -DMY_DO_BOOTP=NULL ARCH_DEP_CFLAGS += -DHAVE_PPCBUG @@ -15,6 +15,7 @@ define MUNCH_CMD $(PROJECT_RELEASE)/lib/bootloader.o \ --just-symbols=$< \ -b binary rtems.gz \ + --no-warn-mismatch \ -T $(PROJECT_RELEASE)/lib/ppcboot.lds \ -Map $<.map rm -f rtems.gz From 1cacd058cd3bd1d9b6cabc6219c48217913eb1e8 Mon Sep 17 00:00:00 2001 From: Kathryn Baker Date: Sun, 20 Jun 2021 19:17:44 -0500 Subject: [PATCH 177/195] Stdio doxygen annotations --- modules/libcom/src/osi/epicsStdio.h | 113 ++++++++++++++++++++++++---- 1 file changed, 100 insertions(+), 13 deletions(-) diff --git a/modules/libcom/src/osi/epicsStdio.h b/modules/libcom/src/osi/epicsStdio.h index b37adfeb0..9bb5eb3e0 100644 --- a/modules/libcom/src/osi/epicsStdio.h +++ b/modules/libcom/src/osi/epicsStdio.h @@ -7,8 +7,42 @@ * EPICS BASE is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ - -/* epicsStdio.h */ +/** + * \file epicsStdio.h + * \brief Standardize the behaviour of stdio across EPICS targets + * + * \details + * The `epicsStdio.h` header includes the operating system's `stdio.h` header + * and if used should replace it. + * + * epicsSnprintf() and epicsVsnprintf() have the same semantics as the C99 + * functions snprintf() and vsnprintf(), but correct the behaviour of the + * implementations on some operating systems. + * + * The routines epicsGetStdin(), epicsGetStdout(), epicsGetStderr(), + * epicsStdoutPrintf(), epicsStdoutPuts(), and epicsStdoutPutchar() + * are not normally named directly in user code. They are provided for use by + * various macros which redefine several standard C identifiers. + * This is done so that any I/O through these standard streams can be + * redirected, usually to or from a file. The primary use of this facility + * is for iocsh() and any commands called from it, allowing redirection of + * the standard input and/or output streams while running those commands. + * In order for this redirection to work, all modules involved in such I/O + * must include `epicsStdio.h` instead of the system header `stdio.h`. + * The redirections are: + * - `stdin` becomes epicsGetStdin() + * - `stdout` becomes epicsGetStdout() + * - `stderr` becomes epicsGetStderr() + * - `printf` becomes epicsStdoutPrintf() + * - `puts` becomes epicsStdoutPuts() + * - `putchar` becomes epicsStdoutPutchar() + * + * The epicsSetThreadStdin(), epicsSetThreadStdout() and epicsSetThreadStderr() + * routines allow the standard file streams to be redirected on a per thread + * basis, e.g. calling epicsThreadStdout() will affect only the thread which + * calls it. To cancel a stream redirection, pass a NULL argument in another + * call to the same redirection routine that was used to set it. + */ #ifndef epicsStdioh #define epicsStdioh @@ -52,23 +86,76 @@ extern "C" { # define putchar epicsStdoutPutchar #endif +/** + * \brief epicsSnprintf() is meant to have the same semantics as the C99 + * function snprintf() + * + * \details + * This is provided because some architectures do not implement these functions, + * while others implement them incorrectly. + * Standardized as a C99 function, snprintf() acts like sprintf() except that + * the `size` argument gives the maximum number of characters (including the + * trailing zero byte) that may be placed in `str`. + * + * On some operating systems though the implementation of this function does + * not always return the correct value. If the OS implementation does not + * correctly return the number of characters that would have been written when + * the output gets truncated, it is not worth trying to fix this as long as + * they return `size-1` instead; the resulting string must always be correctly + * terminated with a zero byte. + * + * In some scenarios the epicsSnprintf() implementation may not provide the + * correct C99 semantics for the return value when `size` is given as zero. + * On these systems epicsSnprintf() can return an error (a value less than + * zero) when a buffer length of zero is passed in, so callers should not use + * that technique to calculate the length of the buffer required. + * + * \return The number of characters (not counting the terminating zero byte) + * that would be written to `str` if it was large enough to hold them all; the + * output has been truncated if the return value is `size` or more. + */ LIBCOM_API int epicsStdCall epicsSnprintf( char *str, size_t size, const char *format, ...) EPICS_PRINTF_STYLE(3,4); +/** + * \brief epicsVsnprintf() is meant to have the same semantics as the C99 + * function vsnprintf() + * + * \details + * This is provided because some architectures do not implement these functions, + * while others implement them incorrectly. + * Standardized as a C99 function, vsnprintf() acts like vsprintf() except that + * the `size` argument gives the maximum number of characters (including the + * trailing zero byte) that may be placed in `str`. + * + * On some operating systems though the implementation of this function does + * not always return the correct value. If the OS implementation does not + * correctly return the number of characters that would have been written when + * the output gets truncated, it is not worth trying to fix this as long as + * they return `size-1` instead; the resulting string must always be correctly + * terminated with a zero byte. + * + * In some scenarios the epicsSnprintf() implementation may not provide the + * correct C99 semantics for the return value when `size` is given as zero. + * On these systems epicsSnprintf() can return an error (a value less than + * zero) when a buffer length of zero is passed in, so callers should not use + * that technique to calculate the length of the buffer required. + * + * \return The number of characters (not counting the terminating zero byte) + * that would be written to `str` if it was large enough to hold them all; the + * output has been truncated if the return value is `size` or more. + */ LIBCOM_API int epicsStdCall epicsVsnprintf( char *str, size_t size, const char *format, va_list ap); -/* - * truncate to specified size (we dont use truncate() - * because it is not portable) - * - * pFileName - name (and optionally path) of file - * size - the new file size (if file is curretly larger) - * - * returns TF_OK if the file is less than size bytes - * or if it was successfully truncated. Returns - * TF_ERROR if the file could not be truncated. - */ enum TF_RETURN {TF_OK=0, TF_ERROR=1}; +/** + * \brief Truncate a file to a specified size + * \note The BSD function truncate() was not available on all targets + * \param pFileName Name (and optionally path) of file + * \param size The new file size (if files is currently larger) + * \return `TF_OK` if the file is less that size bytes or if it was successfully + * truncated; `TF_ERROR` if the file could not be truncated + */ LIBCOM_API enum TF_RETURN truncateFile ( const char *pFileName, unsigned long size ); /* The following are for redirecting stdin,stdout,stderr */ From c36485ab2e307e0370d1e3c47b4474b9f38c995e Mon Sep 17 00:00:00 2001 From: Dirk Zimoch Date: Thu, 24 Jun 2021 10:54:14 +0200 Subject: [PATCH 178/195] fix missing declaration of 'close' function in vxWorks 6.3 and lower --- .../libcom/src/osi/os/vxWorks/osdFindSymbol.c | 1 + modules/libcom/src/osi/os/vxWorks/osiUnistd.h | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 modules/libcom/src/osi/os/vxWorks/osiUnistd.h diff --git a/modules/libcom/src/osi/os/vxWorks/osdFindSymbol.c b/modules/libcom/src/osi/os/vxWorks/osdFindSymbol.c index 59bfc4fdf..b60cf0e62 100644 --- a/modules/libcom/src/osi/os/vxWorks/osdFindSymbol.c +++ b/modules/libcom/src/osi/os/vxWorks/osdFindSymbol.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "dbmf.h" #include "epicsString.h" diff --git a/modules/libcom/src/osi/os/vxWorks/osiUnistd.h b/modules/libcom/src/osi/os/vxWorks/osiUnistd.h new file mode 100644 index 000000000..3f767ae09 --- /dev/null +++ b/modules/libcom/src/osi/os/vxWorks/osiUnistd.h @@ -0,0 +1,21 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* SPDX-License-Identifier: EPICS +* EPICS Base is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ +/* + * Author Jeffrey O. Hill + * johill@lanl.gov + * 505 665 1831 + */ + +#include + +/* VxWorks has some functions in ioLib.h instead of unistd.h, + for example close() and read() + */ +#include From 4dad8ca50351cec1a6addcc8edb89f4ba46ee818 Mon Sep 17 00:00:00 2001 From: Freddie Akeroyd Date: Fri, 25 Jun 2021 11:27:20 +0100 Subject: [PATCH 179/195] Use rather than Fix compile issue building PCAS module, which just includes resulting in LIBCOM_API being undefined --- modules/ca/src/client/caProto.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/ca/src/client/caProto.h b/modules/ca/src/client/caProto.h index 397b1edaf..c6e211c11 100644 --- a/modules/ca/src/client/caProto.h +++ b/modules/ca/src/client/caProto.h @@ -18,7 +18,7 @@ #define INC_caProto_H // Pick up definition of IPPORT_USERRESERVED -#include +#include #define capStrOf(A) #A #define capStrOfX(A) capStrOf ( A ) From e8c5748f89c1a52ea1523285a0c1a660720b9148 Mon Sep 17 00:00:00 2001 From: Freddie Akeroyd Date: Fri, 25 Jun 2021 11:37:07 +0100 Subject: [PATCH 180/195] Use rather than --- src/libCom/osi/os/default/epicsMMIODef.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libCom/osi/os/default/epicsMMIODef.h b/src/libCom/osi/os/default/epicsMMIODef.h index dc4bb4cb7..d517b7031 100644 --- a/src/libCom/osi/os/default/epicsMMIODef.h +++ b/src/libCom/osi/os/default/epicsMMIODef.h @@ -123,7 +123,7 @@ bswap32(epicsUInt32 value) #elif EPICS_BYTE_ORDER == EPICS_ENDIAN_LITTLE /* Get hton[sl] declarations: */ -#include +#include /** @ingroup mmio *@{ From 5c3ecf9054000310e38ab96b59b4dee99a070009 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 26 Jun 2021 17:55:11 -0500 Subject: [PATCH 181/195] Dump the Darwin README file, very dated --- documentation/README.darwin.html | 184 ------------------------------- 1 file changed, 184 deletions(-) delete mode 100644 documentation/README.darwin.html diff --git a/documentation/README.darwin.html b/documentation/README.darwin.html deleted file mode 100644 index dd11ce857..000000000 --- a/documentation/README.darwin.html +++ /dev/null @@ -1,184 +0,0 @@ - - -Installation notes for EPICS on Mac OS X (Darwin) - - - - -

Building EPICS base

-
    -
  • -To build base: -
      -
    1. -Set the EPICS_HOST_ARCH environment variable to darwin-ppc, darwin-x86 or darwin-ppcx86. -The scripts in the -base/startup directory can automate this. For example, here's part -of my Bash login script (~/.bash_login): -
      -#
      -# EPICS
      -#
      -EPICS_BASE="${HOME}/src/EPICS/base"
      -EPICS_EXTENSIONS="${HOME}/src/EPICS/extensions"
      -. "${EPICS_BASE}"/startup/unix.sh
      -
      -
    2. -
    3. -cd to the EPICS base top-level source directory. -
    4. -
    5. -Uncomment the appropriate line in the relevent -EPICS_BASE/configure/os/CONFIG_SITE.Common.darwin-xxx file for your EPICS_HOST_ARCH value. -Newer versions of OS X (e.g. Snow Leopard) may include only 64 bit versions of some OS libraries, -so should only have the x86_64 ARCH_CLASS. -
    6. -
    7. -Run make. -
    8. -
    - -
  • - -
  • -As distributed, EPICS on Mac OS X uses the readline command line input -routines. IOC applications are more pleasant to interact with if -either the readline or libtecla library is used. The easiest -way to get either or both of these libraries on to your system is to -download and install them using the either the DarwinPorts -distribution or the Fink package manager. If you don't want to install -the readline library, set the COMMANDLINE_LIBRARY variable in one of -the CONFIG_SITE files to EPICS. -

    -Information on DarwinPorts is available from -the DarwinPorts -project page. -DarwinPorts binary packages are available from -here. -

    -Fink may be downloaded from -the Source Forge. -

  • - -
  • -If broadcasts are not seen locally, try adding "localhost" (127.0.0.1) -to the EPICS_CA_ADDR_LIST. -
  • -
- -

Building EPICS extensions

-

-Many extensions build and run properly on OS X. To build and run medm, first -obtain the X11 run-time and developer packages from Apple and the OpenMotif3 -package from Fink. - -

Objective-C and AppleScript

-

-Code written in Objective-C can be included in host or IOC applications. -Here are a couple of short Objective-C examples which can be used to send -AppleScript events to other applications on the OS X machine. - -

-/*
- * exampleAppleScriptRecord.m 
- *
- * Simple Objective-C/AppleScript subroutine record
- *
- * To use this record in an application:
- *
- * 1) Make the following changes to the application Makefile:
- *    - Add exampleAppleScriptRecord.m to the application SRCS.
- *    - Add -framework Foundation to the application LDFLAGS.
- * 2) Add the following line to the application database description:
- *      registrar(registerExampleAppleScript)
- * 3) Add a record to the application database:
- *      record(sub,"setVolume")
- *      {
- *          field(SNAM,"exampleAppleScriptProcess")
- *      }
- */
-#import <Foundation/Foundation.h>
-#include <registryFunction.h>
-#include <subRecord.h>
-#include <alarm.h>
-#include <errlog.h>
-#include <recGbl.h>
-#include <epicsExport.h>
-
-/*
- * Shim between EPICS and NSAppleScript class.
- */
-static long
-exampleAppleScriptProcess(struct subRecord *psub)
- {
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSDictionary *err;
-    NSAppleScript *nsa;
-    
-    nsa = [[NSAppleScript alloc] initWithSource:[NSString stringWithFormat:
-                @"tell application \"Finder\" to set volume %g\n", psub->a]];
-    if ([nsa executeAndReturnError:&err] == nil) {
-        errlogPrintf("Failed to run AppleScript: %s\n",
-                        [[err objectForKey:NSAppleScriptErrorMessage] cString]);
-        recGblSetSevr(psub, SOFT_ALARM, INVALID_ALARM);
-    }
-    [nsa release];
-    [pool release];
-    return 0;
-}
-
-static registryFunctionRef subRef[] = {
-    {"exampleAppleScriptProcess",(REGISTRYFUNCTION)exampleAppleScriptProcess}
-};
-
-static void registerExampleAppleScript(void)
-{
-    registryFunctionRefAdd(subRef,NELEMENTS(subRef));
-}
-epicsExportRegistrar(registerExampleAppleScript);
-
-
-==============================================================================
-/*
- * runAppleScript.m 
- *
- * Simple Objective-C/AppleScript shim to allow EPICS application to
- * send arbitrary AppleScript messages to other applications.
- *
- * To use this subroutine in an application make the following
- * changes to the application Makefile:
- * - Add runAppleScript.m to the application SRCS.
- * - Add -framework Foundation to the application LDFLAGS.
- */
-#import <Foundation/Foundation.h>
-#include <errlog.h>
-
-int
-runAppleScript(const char *format, ...)
-{
-    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-    NSString *script;
-    NSMutableDictionary *err;
-    NSAppleScript *nsa;
-    va_list args;
-    int ret = 0;
-    
-    va_start(args, format);
-    script = [[NSString alloc] initWithFormat:
-                            [NSString stringWithCString:format] arguments:args];
-    va_end(args);
-    err = [NSMutableDictionary dictionaryWithCapacity:10];
-    nsa = [[NSAppleScript alloc] initWithSource:script];
-    if ([nsa executeAndReturnError:&err] == nil) {
-        errlogPrintf("Failed to run AppleScript: %s\n",
-                        [[err objectForKey:NSAppleScriptErrorMessage] cString]);
-        ret = -1;
-    }
-    [script release];
-    [nsa release];
-    [pool release];
-    return ret;
-}
-
- - From 28531b0dbb835b0ab6e9f3205f4044da0fa25501 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 26 Jun 2021 17:57:33 -0500 Subject: [PATCH 182/195] Reworked the README.md file Lots of updates; removed version number --- documentation/README.md | 405 +++++++++++++++++++++------------------- 1 file changed, 217 insertions(+), 188 deletions(-) diff --git a/documentation/README.md b/documentation/README.md index 770f14bad..7698d14e2 100644 --- a/documentation/README.md +++ b/documentation/README.md @@ -1,28 +1,28 @@ # Installation Instructions -## EPICS Base Release 3.15.8 +## EPICS Base Release 3.15.x ----- ### Table of Contents - - [What is EPICS base?](#0_0_1) - - [What is new in this release?](#0_0_2) - - [Copyright](#0_0_3) - - [Supported platforms](#0_0_4) - - [Supported compilers](#0_0_5) - - [Software requirements](#0_0_6) - - [Host system storage requirements](#0_0_7) - - [Documentation](#0_0_8) - - [Directory Structure](#0_0_10) - - [Build related components](#0_0_11) - - [Building EPICS base (Unix and Win32)](#0_0_12) - - [Example application and extension](#0_0_13) - - [Multiple host platforms](#0_0_14) + - [What is EPICS base?](#what-is-epics-base?) + - [What is new in this release?](#what-is-new-in-this-release?) + - [Copyright](#copyright) + - [Supported platforms](#supported-platforms) + - [Supported compilers](#supported-compilers) + - [Software requirements](#software-requirements) + - [Host system storage requirements](#host-system-storage-requirements) + - [Documentation](#documentation) + - [Directory Structure](#directory-structure) + - [Site-specific build configuration](#site-specific-build-configuration) + - [Building EPICS base](#building-epics-base) + - [Example application and extension](#example-application-and-extension) + - [Multiple host platforms](#multiple-host-platforms) ----- -### What is EPICS base? +### What is EPICS base? The Experimental Physics and Industrial Control Systems (EPICS) is an extensible set of software components and tools with which application @@ -34,17 +34,17 @@ function. EPICS base allows an arbitrary number of target systems, IOCs (input/output controllers), and host systems, OPIs (operator interfaces) of various types. -### What is new in this release? +### What is new in this release? -Please check the `RELEASE_NOTES` file in the distribution for +Please check the `documentation/RELEASE_NOTES.md` file for description of changes and release migration details. -### Copyright +### Copyright -Please review the LICENSE file included in the distribution for legal -terms of usage. +Please review the `LICENSE` file included in the distribution for +legal terms of usage. -### Supported platforms +### Supported platforms The list of platforms supported by this version of EPICS base is given in the `configure/CONFIG_SITE` file. If you are trying to build EPICS @@ -55,7 +55,7 @@ base/configure/os/directory. You can start by copying existing configuration files in the configure/os directory and then make changes for your new platforms. -### Supported compilers +### Supported compilers This version of EPICS base has been built and tested using the host vendor's C and C++ compilers, as well as the GNU gcc and g++ @@ -64,27 +64,32 @@ targets. You may need the C and C++ compilers to be in your search path to do EPICS builds; check the definitions of CC and CCC in `base/configure/os/CONFIG..` if you have problems. -### Software requirements +### Software requirements -**GNU make** -You must use GNU make, gnumake, for any EPICS builds. Set your path so -that a gnumake version 3.81 or later is available. +#### GNU make + +You must use the GNU version of `make` for EPICS builds. Set your path +so that version 3.81 or later is available (4.0 or later on Windows). + +#### Perl -**Perl** You must have Perl version 5.8.1 or later installed. The EPICS configuration files do not specify the perl full pathname, so the perl executable must be found through your normal search path. -**Unzip and tar (Winzip on WIN32 systems)** +#### Unzip and tar (Winzip on WIN32 systems) + You must have tools available to unzip and untar the EPICS base distribution file. -**Target systems** +#### Target systems + EPICS supports IOCs running on embedded platforms such as VxWorks and RTEMS built using a cross-compiler, and also supports soft IOCs running as processes on the host platform. -**vxWorks** +#### vxWorks + You must have vxWorks 5.5.x or 6.x installed if any of your target systems are vxWorks systems; the C++ compiler for vxWorks 5.4 is now too old to support. The vxWorks installation provides the @@ -98,134 +103,148 @@ Consult the [vxWorks 5.x](https://epics.anl.gov/base/tornado.php) or about and the vxWorks documentation for information about configuring your vxWorks operating system for use with EPICS. -**RTEMS** +#### RTEMS + For RTEMS targets, you need RTEMS core and toolset version 4.9.2 or -later. +4.10.x. RTEMS 5 and above are only supported in EPICS 7.0.6 or later. -**GNU readline or Tecla library** -GNU readline and Tecla libraries can be used by the IOC shell to -provide command line editing and command line history recall and edit. -GNU readline (or Tecla library) must be installed on your target -system when `COMMANDLINE_LIBRARY` is set to READLINE (or TECLA) for -that target. EPICS (EPICS shell) is the default specified in -`CONFIG_COMMON`. A READLINE override is defined for linux-x86 in the -EPICS distribution. Comment out `COMMANDLINE_LIBRARY=READLINE` in -`configure/os/CONFIG_SITE.Common.linux-x86` if readline is not -installed on linux-x86. Command-line editing and history will then be -those supplied by the os. On vxWorks the ledLib command-line input -library is used instead. +#### Command Line Editing -### Host system storage requirements -The compressed tar file is approximately 1.6 MB in size. The +GNU readline and other similar libraries can be used by the IOC shell +to provide command line editing and command line history recall. The +GNU readline development package (or Apple's emulator on macOS) must +be installed for a target when its build configuration variable +`COMMANDLINE_LIBRARY` is set to `READLINE`. The default specified in +`CONFIG_COMMON` is `EPICS`, but most linux target builds can detect if +readline is available and will then use it. RTEMS targets may be +configured to use `LIBTECLA` if available, and on vxWorks the OS's +ledLib line-editing library is normally used. + +### Host system storage requirements + +The compressed tar file is approximately 1.7 MB in size. The distribution source tree takes up approximately 12 MB. Each host -target will need around 40 MB for build files, and each cross-compiled -target around 20 MB. +target will need around 50 MB for build files, and each cross-compiled +target around 30 MB. -### Documentation +### Documentation EPICS documentation is available through the [EPICS website](https://epics.anl.gov/) at Argonne. Release specific documentation can also be found in the -base/documentation directory of the distribution. +`base/documentation` directory of the distribution. -### Directory Structure +### Directory Structure -#### Distribution directory structure: +#### Distribution directory structure ``` - base Root directory of the base distribution - base/configure Operating system independent build config files - base/configure/os Operating system dependent build config files - base/documentation Distribution documentation - base/src Source code in various subdirectories - base/startup Scripts for setting up path and environment + base Root directory of the distribution + base/configure Build rules and OS-independent config files + base/configure/os OS-dependent build config files + base/documentation Distribution documentation + base/src Source code in various subdirectories + base/startup Scripts for setting up path and environment ``` -#### Install directories created by the build: +#### Directories created by the build + +These are created in the root directory of the installation (`base` +above) or under the directory pointed to by the `INSTALL_LOCATION` +configuration variable if that has been set. ``` - bin Installed scripts and executables in subdirs - cfg Installed build configuration files - db Installed data bases - dbd Installed data base definitions - doc Installed documentation files - html Installed html documentation - include Installed header files - include/os Installed os specific header files in subdirs - include/compiler Installed compiler-specific header files - lib Installed libraries in arch subdirectories - lib/perl Installed perl modules - templates Installed templates + bin Installed scripts and executables in subdirs + cfg Installed build configuration files + db Installed database files + dbd Installed database definition files + html Installed html documentation + include Installed header files + include/os Installed OS-specific header files in subdirs + include/compiler Installed compiler-specific header files + lib Installed libraries in arch subdirectories + lib/perl Installed perl modules + templates Installed templates ``` -### Build related components +#### `base/documentation` Directory -#### base/documentation directory - contains setup, build, and install documents +This contains documents on how to setup, build, and install EPICS. ``` - README.md Instructions for setup and building epics base - README.darwin.html Installation notes for Mac OS X (Darwin) - RELEASE_NOTES.html Notes on release changes - KnownProblems.html List of known problems and workarounds + README.md This file + RELEASE_NOTES.md Notes on release changes + KnownProblems.html List of known problems and workarounds ``` -#### base/startup directory - contains scripts to set environment and path +#### `base/startup` Directory + +This contains several example scripts that show how to set up the +build environment and PATH for using EPICS. Sites would usually copy and/or modify these files as appropriate for their environment; they are not used by the build system at all. ``` - EpicsHostArch Shell script to set EPICS_HOST_ARCH env variable - unix.csh C shell script to set path and env variables - unix.sh Bourne shell script to set path and env variables - win32.bat Bat file example to configure win32-x86 target - windows.bat Bat file example to configure windows-x64 target + EpicsHostArch Shell script to set EPICS_HOST_ARCH env variable + unix.csh C shell script to set path and env variables + unix.sh Bourne shell script to set path and env variables + win32.bat Bat file example to configure win32-x86 target + windows.bat Bat file example to configure windows-x64 target ``` -#### base/configure directory - contains build definitions and rules +#### `base/configure` directory + +This contains build-system files providing definitions and rules +required by GNU Make to build EPICS. Users should only need to modify the `CONFIG_SITE` files to configure the EPICS build. ``` - CONFIG Includes configure files and allows variable overrides - CONFIG.CrossCommon Cross build definitions - CONFIG.gnuCommon Gnu compiler build definitions for all archs - CONFIG_ADDONS Definitions for and DEFAULT options - CONFIG_APP_INCLUDE - CONFIG_BASE EPICS base tool and location definitions - CONFIG_BASE_VERSION Definitions for EPICS base version number - CONFIG_COMMON Definitions common to all builds - CONFIG_ENV Definitions of EPICS environment variables - CONFIG_FILE_TYPE - CONFIG_SITE Site specific make definitions - CONFIG_SITE_ENV Site defaults for EPICS environment variables - MAKEFILE Installs CONFIG* RULES* creates - RELEASE Location of external products - RULES Includes appropriate rules file - RULES.Db Rules for database and database definition files - RULES.ioc Rules for application iocBoot/ioc* directory - RULES_ARCHS Definitions and rules for building architectures - RULES_BUILD Build and install rules and definitions - RULES_DIRS Definitions and rules for building subdirectories - RULES_EXPAND - RULES_FILE_TYPE - RULES_TARGET - RULES_TOP Rules specific to a dir (uninstall and tar) - Sample.Makefile Sample makefile with comments + CONFIG Main entry point for building EPICS + CONFIG.CrossCommon Cross build definitions + CONFIG.gnuCommon Gnu compiler build definitions for all archs + CONFIG_ADDONS Definitions for and DEFAULT options + CONFIG_APP_INCLUDE + CONFIG_BASE EPICS base tool and location definitions + CONFIG_BASE_VERSION Definitions for EPICS base version number + CONFIG_COMMON Definitions common to all builds + CONFIG_ENV Definitions of EPICS environment variables + CONFIG_FILE_TYPE + CONFIG_SITE Site specific make definitions + CONFIG_SITE_ENV Site defaults for EPICS environment variables + MAKEFILE Installs CONFIG* RULES* creates + RELEASE Location of external products + RULES Includes appropriate rules file + RULES.Db Rules for database and database definition files + RULES.ioc Rules for application iocBoot/ioc* directory + RULES_ARCHS Definitions and rules for building architectures + RULES_BUILD Build and install rules and definitions + RULES_DIRS Definitions and rules for building subdirectories + RULES_EXPAND + RULES_FILE_TYPE + RULES_TARGET + RULES_TOP Rules specific to a dir only + Sample.Makefile Sample makefile with comments ``` -#### base/configure/os directory - contains os-arch specific definitions +#### `base/configure/os` Directory + +Files in here provide definitions that are shared by or specific to particular host and/or target architectures. Users should only need to modify the `CONFIG_SITE` files in this directory to configure the EPICS build. ``` - CONFIG.. Specific host-target build definitions - CONFIG.Common. Specific target definitions for all hosts - CONFIG..Common Specific host definitions for all targets - CONFIG.UnixCommon.Common Definitions for Unix hosts and all targets - CONFIG.Common.UnixCommon Definitions for Unix targets and all hosts - CONFIG.Common.vxWorksCommon Specific host definitions for all vx targets - CONFIG_SITE.. Site specific host-target definitions - CONFIG_SITE.Common. Site specific target defs for all hosts - CONFIG_SITE..Common Site specific host defs for all targets + CONFIG.. Definitions for a specific host-target combination + CONFIG.Common. Definitions for a specific target, any host + CONFIG..Common Definitions for a specific host, any target + CONFIG.UnixCommon.Common Definitions for Unix hosts, any target + CONFIG.Common.UnixCommon Definitions for Unix targets, any host + CONFIG.Common.RTEMS Definitions for all RTEMS targets, any host + CONFIG.Common.vxWorksCommon Definitions for all vxWorks targets, any host + CONFIG_SITE.. Local settings for a specific host-target combination + CONFIG_SITE.Common. Local settings for a specific target, any host + CONFIG_SITE..Common Local settings for a specific host, any target + CONFIG_SITE.Common.RTEMS Local settings for all RTEMS targets, any host + CONFIG_SITE.Common.vxWorksCommon Local settings for all vxWorks targets, any host ``` -### Building EPICS base (Unix and Win32) +### Building EPICS base #### Unpack file @@ -237,7 +256,7 @@ systems. Files in the base/startup directory have been provided to help set required path and other environment variables. -* `EPICS_HOST_ARCH` +* **`EPICS_HOST_ARCH`** Before you can build or use EPICS R3.15, the environment variable `EPICS_HOST_ARCH` must be defined. A perl script EpicsHostArch.pl in the base/startup directory has been provided to help set @@ -250,65 +269,66 @@ compilers on a solaris host or "-mingw" for MinGW c/c++ compilers on a WIN32 host). See `configure/CONFIG_SITE` for a list of supported `EPICS_HOST_ARCH` values. -* `PERLLIB` -On WIN32, some versions of Perl require that the environment -variable PERLLIB be set to <perl directory location>. +* **`PATH`** +As already mentioned, you must have the `perl` executable and you may +need C and C++ compilers in your search path. When building base you +must have `echo` in your search path. For Unix host builds you will +also need `cp`, `rm`, `mv`, and `mkdir` in your search path. Some Unix +systems may also need `ar` and `ranlib`, and the C/C++ compilers may +require `as` and `ld` in your path. On Solaris systems you need +`uname` in your path. -* `PATH` -As already mentioned, you must have the perl executable and you may -need C and C++ compilers in your search path. For building base you -also must have echo in your search path. For Unix host builds you -also need ln, cpp, cp, rm, mv, and mkdir in your search path and -/bin/chmod must exist. On some Unix systems you may also need ar and -ranlib in your path, and the C compiler may require as and ld in -your path. On solaris systems you need uname in your path. +* **`LD_LIBRARY_PATH`** +R3.15 shared libraries and executables normally contain the full path +to any libraries they require, so setting this variable is not usually +necessary. However, if you move the EPICS installation to a new +location after building it then in order for the shared libraries to +be found at runtime it may need to be set, or some equivalent +OS-specific mechanism such as `/etc/ld.so.conf` on Linux must be used. +Shared libraries are now built by default on all Unix type hosts. -* `LD_LIBRARY_PATH` -R3.15 shared libraries and executables normally contain the full -path to any libraries they require. However, if you move the EPICS -files or directories from their build-time location then in order -for the shared libraries to be found at runtime `LD_LIBRARY_PATH` -must include the full pathname to -`$(INSTALL_LOCATION)/lib/$(EPICS_HOST_ARCH)` when invoking -executables, or some equivalent OS-specific mechanism (such as -/etc/ld.so.conf on Linux) must be used. Shared libraries are now -built by default on all Unix type hosts. +### Site-specific build configuration -#### Do site-specific build configuration +#### Site configuration -**Site configuration** -To configure EPICS, you may want to modify the default definitions -in the following files: +To configure EPICS, you may want to modify some values set in the +following files: ``` - configure/CONFIG_SITE Build choices. Specify target archs. - configure/CONFIG_SITE_ENV Environment variable defaults - configure/RELEASE TORNADO2 full path location + configure/CONFIG_SITE Build settings. Specify target archs. + configure/CONFIG_SITE_ENV Environment variable defaults ``` -**Host configuration** -To configure each host system, you may override the default -definitions by adding a new file in the configure/os directory with -override definitions. The new file should have the same name as the -distribution file to be overridden except with CONFIG in the name -changed to `CONFIG_SITE`. +#### Host configuration + +To configure each host system, you can override the default +definitions by adding a new settings file (or editing an existing +settings file) in the `configure/os` directory with your override +definitions. The settings file has the same name as the definitions +file to be overridden except with `CONFIG` in the name changed to +`CONFIG_SITE`. ``` - configure/os/CONFIG.. Host build settings - configure/os/CONFIG..Common Host common build settings + configure/os/CONFIG.. Host self-build definitions + configure/os/CONFIG..Common Host common build definitions + configure/os/CONFIG_SITE.. Host self-build overrides + configure/os/CONFIG_SITE..Common Host common build overrides ``` -**Target configuration** +#### Target configuration + To configure each target system, you may override the default -definitions by adding a new file in the configure/os directory with -override definitions. The new file should have the same name as the -distribution file to be overridden except with CONFIG in the name -replaced by `CONFIG_SITE`. This step is necessary even if the host -system is the only target system. +definitions by adding a new settings file (or editing an existing +settings file) in the `configure/os` directory with your override +definitions. The settings file has the same name as the definitions +file to be overridden except with `CONFIG` in the name changed to +`CONFIG_SITE`. ``` - configure/os/CONFIG.Common. Target common settings - configure/os/CONFIG.. Host-target settings + configure/os/CONFIG.Common. Target common definitions + configure/os/CONFIG.. Host-target definitions + configure/os/CONFIG_SITE.Common. Target common overrides + configure/os/CONFIG_SITE.. Host-target overrides ``` #### Build EPICS base @@ -318,24 +338,29 @@ by issuing the following commands in the distribution's root directory (base): ``` - gnumake clean uninstall - gnumake + make distclean + make ``` -The command "gnumake clean uninstall" will remove all files and -directories generated by a previous build. The command "gnumake" +The command `make distclean` will remove all files and +directories generated by a previous build. The command `make` will build and install everything for the configured host and targets. -It is recommended that you do a "gnumake clean uninstall" at the +It is recommended that you do a `make distclean` at the root directory of an EPICS directory structure before each complete rebuild to ensure that all components will be rebuilt. -### Example application and extension +In some cases GNU Make may have been installed as `gmake` or +`gnumake`, in which case the above commands will have to be adjusted +to match. -A perl tool, makeBaseApp.pl is included in the distribution file. This -script will create a sample application that can be built and then -executed to try out this release of base. +### Example application and extension + +A perl tool `makeBaseApp.pl` and several template applications are +included in the distribution. This script instantiates the selected +template into an empty directory to provide an example application +that can be built and then executed to try out this release of base. Instructions for building and executing the 3.15 example application can be found in the section "Example Application" of Chapter 2, @@ -348,26 +373,30 @@ application as a host-based IOC, you will be able to quickly implement a complete EPICS system and be able to run channel access clients on the host system. -A perl script, makeBaseExt.pl, is included in the distribution file. -This script will create a sample extension that can be built and -executed. The makeBaseApp.pl and makeBaseExt.pl scripts are installed -into the install location `bin/` directory during the base -build. +Another perl script `makeBaseExt.pl` is also included in the +distribution file for creating an extensions tree and sample +application that can also be built and executed. Both these scripts +are installed into the install location `bin/` directory +during the base build. -### Multiple host platforms +### Multiple host platforms You can build using a single EPICS directory structure on multiple host systems and for multiple cross target systems. The intermediate and binary files generated by the build will be created in separate subdirectories and installed into the appropriate separate host/target -install directories. EPICS executables and perl scripts are installed -into the `$(INSTALL_LOCATION)/bin/` directories. Libraries are -installed into $`(INSTALL_LOCATION)/lib/`. The default -definition for `$(INSTALL_LOCATION)` is `$(TOP)` which is the root -directory in the distribution directory structure, base. Created -object files are stored in `O.` source subdirectories, This -allows objects for multiple cross target architectures to be -maintained at the same time. To build EPICS base for a specific +install directories. + +EPICS executables and perl scripts are installed into the +`$(INSTALL_LOCATION)/bin/` directories. Libraries are installed +into $`(INSTALL_LOCATION)/lib/`. The default definition for +`$(INSTALL_LOCATION)` is `$(TOP)` which is the root directory in the +distribution directory structure, `base`. Intermediate object files +are stored in `O.` source subdirectories during the build +process, to allow objects for multiple cross target architectures +to be maintained at the same time. + +To build EPICS base for a specific host/target combination you must have the proper host/target C/C++ cross compiler and target header files and the base/configure/os directory must have the appropriate configure files. From ebf4a155d729748704b1b20c83018db42a5d82d1 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 26 Jun 2021 18:00:28 -0500 Subject: [PATCH 183/195] Added missing entries to Release Notes --- documentation/RELEASE_NOTES.md | 35 +++++++++++++++++++++++++++------- 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 66d843645..befae922b 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -6,20 +6,41 @@ This version of EPICS Base has not been released yet. +### Use waitable timers on Microsoft Windows + +The `epicsEventWaitWithTimeout()` and `epicsThreadSleep()` functions have +been changed to use waitable timers. On Windows 10 version 1803 or higher +they will use high resolution timers for more consistent timing. + +See [this Google Groups thread](https://groups.google.com/a/chromium.org/g/scheduler-dev/c/0GlSPYreJeY) +for a comparison of the performance of different timers. + +### Build target for documentation + +The build target `inc` now works again after a very long hiatus. It now +generates and installs just the dbd, header and html files, without compiling +any C/C++ code. This can be used to speed up CI jobs that only generate +documentation. + +### Bug fixes + +- The error status returned by a record support's `special()` method is now propagated out of the `dbPut()` routine again (broken since 3.15.0). +- [gh: #80](https://github.com/epics-base/epics-base/issues/80), VS-2015 and +later have working strtod() +- [lp: #1776141](https://bugs.launchpad.net/epics-base/+bug/1776141), Catch +buffer overflow from long link strings +- [lp: #1899697](https://bugs.launchpad.net/epics-base/+bug/1899697), Records +in wrong PHAS order + ### Change to the `junitfiles` self-test build target The names of the generated junit xml test output files have been changed from `.xml` to `-results.xml`, to allow better distinction from other xml files. (I.e., for easy wildcard matching.) -### Use waitable timers on Microsoft Windows +### Fixes and code cleanups -The `epicsEventWaitWithTimeout` and `epicsThreadSleep` functions have -been changed to use waitable timers. On Windows 10 version 1803 or higher -they will use high resolution timers for more consistent timing. - -See https://groups.google.com/a/chromium.org/g/scheduler-dev/c/0GlSPYreJeY -for a comparison of the performance of different timers. +Issues reported by various static code checkers. ## Changes made between 3.15.7 and 3.15.8 From 3be67aca3c38b154324cd2d71d6dcbedf15ebf9f Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sun, 27 Jun 2021 12:18:45 -0500 Subject: [PATCH 184/195] Releasing R3.15.9 --- configure/CONFIG_BASE_VERSION | 8 ++++---- documentation/RELEASE_NOTES.md | 6 +----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/configure/CONFIG_BASE_VERSION b/configure/CONFIG_BASE_VERSION index f7141a82e..667b9f514 100644 --- a/configure/CONFIG_BASE_VERSION +++ b/configure/CONFIG_BASE_VERSION @@ -27,19 +27,19 @@ EPICS_VERSION = 3 EPICS_REVISION = 15 # EPICS_MODIFICATION must be a number >=0 and <256 -EPICS_MODIFICATION = 8 +EPICS_MODIFICATION = 9 # EPICS_PATCH_LEVEL must be a number (win32 resource file requirement) # Not included if zero -EPICS_PATCH_LEVEL = 1 +EPICS_PATCH_LEVEL = 0 # This will end in -DEV between official releases -EPICS_DEV_SNAPSHOT=-DEV +#EPICS_DEV_SNAPSHOT=-DEV #EPICS_DEV_SNAPSHOT=-pre1 #EPICS_DEV_SNAPSHOT=-pre1-DEV #EPICS_DEV_SNAPSHOT=-rc1 #EPICS_DEV_SNAPSHOT=-rc1-DEV -#EPICS_DEV_SNAPSHOT= +EPICS_DEV_SNAPSHOT= # No changes should be needed below here diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index befae922b..fa180b685 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -1,10 +1,6 @@ # EPICS Base Release 3.15.9 -This version of EPICS Base has not been released yet. - -## Changes made on the 3.15 branch since 3.15.8 - - +## Changes made between 3.15.8 and 3.15.9 ### Use waitable timers on Microsoft Windows From 67fcd656568649b81d5a806910deb024630b8611 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sun, 27 Jun 2021 12:20:41 -0500 Subject: [PATCH 185/195] Update versions after tagging --- configure/CONFIG_BASE_VERSION | 10 +++------- documentation/RELEASE_NOTES.md | 6 ++++++ 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/configure/CONFIG_BASE_VERSION b/configure/CONFIG_BASE_VERSION index 667b9f514..35911c310 100644 --- a/configure/CONFIG_BASE_VERSION +++ b/configure/CONFIG_BASE_VERSION @@ -31,15 +31,11 @@ EPICS_MODIFICATION = 9 # EPICS_PATCH_LEVEL must be a number (win32 resource file requirement) # Not included if zero -EPICS_PATCH_LEVEL = 0 +EPICS_PATCH_LEVEL = 1 # This will end in -DEV between official releases -#EPICS_DEV_SNAPSHOT=-DEV -#EPICS_DEV_SNAPSHOT=-pre1 -#EPICS_DEV_SNAPSHOT=-pre1-DEV -#EPICS_DEV_SNAPSHOT=-rc1 -#EPICS_DEV_SNAPSHOT=-rc1-DEV -EPICS_DEV_SNAPSHOT= +EPICS_DEV_SNAPSHOT=-DEV +#EPICS_DEV_SNAPSHOT= # No changes should be needed below here diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index fa180b685..948a17c21 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -1,5 +1,11 @@ # EPICS Base Release 3.15.9 +This version of EPICS Base has not been released yet. + +## Changes made on the 3.15 branch since 3.15.9 + + + ## Changes made between 3.15.8 and 3.15.9 ### Use waitable timers on Microsoft Windows From f2ac69604d04d2145306ab110dc9c9af3ac1a30d Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 29 Jun 2021 21:55:54 -0500 Subject: [PATCH 186/195] Fix typos in Release Notes --- documentation/RELEASE_NOTES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 193dd962c..1d2979ad9 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -42,7 +42,7 @@ running on RTEMS 5: - RTEMS-beagleboneblack - RTEMS-pc686 - RTEMS-qoriq_e500 (MVME2500) -- RTEMS-xilinx-zynq-a9_qemu +- RTEMS-xilinx_zynq_a9_qemu - RTEMS-xilinx_zynq_zedboard The EPICS support for RTEMS 4 has always relied on RTEMS-specific @@ -215,7 +215,7 @@ that the variables referenced by output pointers are initialized. ```c #ifndef HAS_ALARM_MESSAGE -# recGblSetSevrMsg(REC, STAT, SEVR, ...) recGblSetSevr(REC, STAT, SEVR) +# define recGblSetSevrMsg(REC, STAT, SEVR, ...) recGblSetSevr(REC, STAT, SEVR) #endif #ifndef dbGetAlarmMsg # define dbGetAlarmMsg(LINK, STAT, SEVR, BUF, BUFLEN) dbGetAlarm(LINK, STAT, SEVR) From dff72029f1b6430740a951630647260fe8fbed75 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 29 Jun 2021 21:57:42 -0500 Subject: [PATCH 187/195] Fix typos in internal build variable names --- configure/CONFIG.gnuCommon | 1 - configure/CONFIG_COMMON | 4 ++-- configure/os/CONFIG.Common.RTEMS | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/configure/CONFIG.gnuCommon b/configure/CONFIG.gnuCommon index 355614e1a..d3a9a41cf 100644 --- a/configure/CONFIG.gnuCommon +++ b/configure/CONFIG.gnuCommon @@ -50,7 +50,6 @@ CODE_LDFLAGS += $(ASAN_LDFLAGS_$(ENABLE_ASAN)) PIPE_CFLAGS_YES_YES = -pipe PIPE_CFLAGS = $(PIPE_CFLAGS_$(GCC_PIPE)_$(GNU)) -PIPE_CXXFLAGS = $(PIPE_CFLAGS) STATIC_LDFLAGS_YES = -static STATIC_LDFLAGS_NO = diff --git a/configure/CONFIG_COMMON b/configure/CONFIG_COMMON index 8bbc4a624..316f971d7 100644 --- a/configure/CONFIG_COMMON +++ b/configure/CONFIG_COMMON @@ -260,7 +260,7 @@ OPT_CXXFLAGS = $(OPT_CXXFLAGS_$($(BUILD_CLASS)_OPT)) # Static build flags STATIC_CFLAGS = $(STATIC_CFLAGS_$(STATIC_BUILD)) -STATIC_CXXCFLAGS = $(STATIC_CXXFLAGS_$(STATIC_BUILD)) +STATIC_CXXFLAGS = $(STATIC_CXXFLAGS_$(STATIC_BUILD)) STATIC_LDFLAGS = $(STATIC_LDFLAGS_$(STATIC_BUILD)) STATIC_LDLIBS = $(STATIC_LDLIBS_$(STATIC_BUILD)) @@ -297,7 +297,7 @@ CFLAGS = $($(BUILD_CLASS)_CFLAGS) $(POSIX_CFLAGS) $(OPT_CFLAGS)\ CXXFLAGS = $($(BUILD_CLASS)_CXXFLAGS) $(POSIX_CXXFLAGS) $(OPT_CXXFLAGS)\ $(DEBUG_CXXFLAGS) $(PIPE_CFLAGS) $(WARN_CXXFLAGS) $(TARGET_CXXFLAGS)\ $(USR_CXXFLAGS) $(CMD_CXXFLAGS) $(ARCH_DEP_CXXFLAGS) $(CODE_CXXFLAGS)\ - $(STATIC_CXXCFLAGS) $(OP_SYS_CXXFLAGS) $(LIBRARY_SRC_CFLAGS) + $(STATIC_CXXFLAGS) $(OP_SYS_CXXFLAGS) $(LIBRARY_SRC_CFLAGS) LDFLAGS = $(OPT_LDFLAGS) $(TARGET_LDFLAGS) $(USR_LDFLAGS) $(CMD_LDFLAGS)\ $(POSIX_LDFLAGS) $(ARCH_DEP_LDFLAGS) $(DEBUG_LDFLAGS) $(OP_SYS_LDFLAGS)\ diff --git a/configure/os/CONFIG.Common.RTEMS b/configure/os/CONFIG.Common.RTEMS index b19b2071f..b7a42d137 100644 --- a/configure/os/CONFIG.Common.RTEMS +++ b/configure/os/CONFIG.Common.RTEMS @@ -63,7 +63,7 @@ CFLAGS = $($(BUILD_CLASS)_CFLAGS) $(POSIX_CFLAGS) $(OPT_CFLAGS)\ CXXFLAGS = $($(BUILD_CLASS)_CXXFLAGS) $(POSIX_CXXFLAGS) $(OPT_CXXFLAGS)\ $(DEBUG_CXXFLAGS) $(PIPE_CFLAGS) $(WARN_CXXFLAGS) $(TARGET_CXXFLAGS)\ $(USR_CXXFLAGS) $(CMD_CXXFLAGS) $(ARCH_DEP_CXXFLAGS) $(CODE_CXXFLAGS)\ - $(STATIC_CXXCFLAGS) $(OP_SYS_CXXFLAGS) $(LIBRARY_SRC_CFLAGS) + $(STATIC_CXXFLAGS) $(OP_SYS_CXXFLAGS) $(LIBRARY_SRC_CFLAGS) LDFLAGS = $(OPT_LDFLAGS) $(TARGET_LDFLAGS) $(USR_LDFLAGS) $(CMD_LDFLAGS)\ $(POSIX_LDFLAGS) $(ARCH_DEP_LDFLAGS) $(DEBUG_LDFLAGS) $(OP_SYS_LDFLAGS)\ From 7ca25d3c888c56844877d194d91f1f47b69f323c Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 29 Jun 2021 21:59:57 -0500 Subject: [PATCH 188/195] Check module set EPICS_BASE in a RELEASE file --- configure/CONFIG | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure/CONFIG b/configure/CONFIG index 1c1242858..df454b29b 100644 --- a/configure/CONFIG +++ b/configure/CONFIG @@ -16,6 +16,10 @@ ifneq ($(wildcard $(TOP)/configure/CONFIG_BASE_VERSION),) CONFIG = $(TOP)/configure BASE_TOP=YES else + ifneq ($(origin EPICS_BASE),file) + # Essential for the EPICS build system, see convertRelease.pl + $(error EPICS_BASE must be set in a configure/RELEASE file) + endif CONFIG ?= $(EPICS_BASE)/configure endif From 5feb18b0b0a5957ba0a504a4524c9295aadaf226 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 30 Jun 2021 10:10:36 -0700 Subject: [PATCH 189/195] update PVD/PVA modules --- modules/pvAccess | 2 +- modules/pva2pva | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/pvAccess b/modules/pvAccess index e1c1a4bc1..3e6e6ae74 160000 --- a/modules/pvAccess +++ b/modules/pvAccess @@ -1 +1 @@ -Subproject commit e1c1a4bc1bad6933e57b199d58f74468401218b3 +Subproject commit 3e6e6ae74bf9e21cf36dcbd2165888560d35d82b diff --git a/modules/pva2pva b/modules/pva2pva index ad8b77e19..466d41ebb 160000 --- a/modules/pva2pva +++ b/modules/pva2pva @@ -1 +1 @@ -Subproject commit ad8b77e19f7e2ae50c48b5d871bdbe7b0ee23b61 +Subproject commit 466d41ebb95a163133e07150d7841c03abfebf58 From e2d3b9a246d43495b5acaf3276d32de66b0db9b1 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Mon, 28 Jun 2021 22:09:59 -0700 Subject: [PATCH 190/195] osiSockTest: ignore large messages on WIN32 --- modules/libcom/src/osi/os/Darwin/osdSock.h | 1 + modules/libcom/src/osi/os/Linux/osdSock.h | 1 + modules/libcom/src/osi/os/RTEMS-posix/osdSock.h | 1 + modules/libcom/src/osi/os/RTEMS-score/osdSock.h | 1 + modules/libcom/src/osi/os/WIN32/osdSock.h | 1 + modules/libcom/src/osi/os/cygwin32/osdSock.h | 1 + modules/libcom/src/osi/os/freebsd/osdSock.h | 1 + modules/libcom/src/osi/os/iOS/osdSock.h | 1 + modules/libcom/src/osi/os/solaris/osdSock.h | 1 + modules/libcom/src/osi/os/vxWorks/osdSock.h | 1 + modules/libcom/test/osiSockTest.c | 3 +++ 11 files changed, 13 insertions(+) diff --git a/modules/libcom/src/osi/os/Darwin/osdSock.h b/modules/libcom/src/osi/os/Darwin/osdSock.h index 5d266e326..e9350420f 100644 --- a/modules/libcom/src/osi/os/Darwin/osdSock.h +++ b/modules/libcom/src/osi/os/Darwin/osdSock.h @@ -56,6 +56,7 @@ typedef unsigned char osiSockOptMcastTTL_t; #define SOCK_SHUTDOWN ESHUTDOWN #define SOCK_ENOTSOCK ENOTSOCK #define SOCK_EBADF EBADF +#define SOCK_EMSGSIZE EMSGSIZE #ifndef SHUT_RD #define SHUT_RD 0 diff --git a/modules/libcom/src/osi/os/Linux/osdSock.h b/modules/libcom/src/osi/os/Linux/osdSock.h index 4a92be720..3a604c88e 100644 --- a/modules/libcom/src/osi/os/Linux/osdSock.h +++ b/modules/libcom/src/osi/os/Linux/osdSock.h @@ -63,6 +63,7 @@ typedef int osiSockOptMcastTTL_t; #define SOCK_SHUTDOWN ESHUTDOWN #define SOCK_ENOTSOCK ENOTSOCK #define SOCK_EBADF EBADF +#define SOCK_EMSGSIZE EMSGSIZE #ifndef SHUT_RD # define SHUT_RD 0 diff --git a/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h b/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h index 5d765b3a7..f0a57c268 100644 --- a/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h +++ b/modules/libcom/src/osi/os/RTEMS-posix/osdSock.h @@ -58,6 +58,7 @@ typedef char osiSockOptMcastTTL_t; #define SOCK_SHUTDOWN ESHUTDOWN #define SOCK_ENOTSOCK ENOTSOCK #define SOCK_EBADF EBADF +#define SOCK_EMSGSIZE EMSGSIZE #ifndef SHUT_RD # define SHUT_RD 0 diff --git a/modules/libcom/src/osi/os/RTEMS-score/osdSock.h b/modules/libcom/src/osi/os/RTEMS-score/osdSock.h index 3090234af..ea765ece8 100644 --- a/modules/libcom/src/osi/os/RTEMS-score/osdSock.h +++ b/modules/libcom/src/osi/os/RTEMS-score/osdSock.h @@ -71,6 +71,7 @@ typedef unsigned char osiSockOptMcastTTL_t; #define SOCK_SHUTDOWN EPIPE #define SOCK_ENOTSOCK ENOTSOCK #define SOCK_EBADF EBADF +#define SOCK_EMSGSIZE EMSGSIZE #include #include diff --git a/modules/libcom/src/osi/os/WIN32/osdSock.h b/modules/libcom/src/osi/os/WIN32/osdSock.h index 87b0a880e..9eab6e76a 100644 --- a/modules/libcom/src/osi/os/WIN32/osdSock.h +++ b/modules/libcom/src/osi/os/WIN32/osdSock.h @@ -66,6 +66,7 @@ typedef DWORD osiSockOptMcastTTL_t; #define SOCK_SHUTDOWN WSAESHUTDOWN #define SOCK_ENOTSOCK WSAENOTSOCK #define SOCK_EBADF WSAENOTSOCK +#define SOCK_EMSGSIZE WSAEMSGSIZE /* * Under WIN32, FD_SETSIZE is the max. number of sockets, diff --git a/modules/libcom/src/osi/os/cygwin32/osdSock.h b/modules/libcom/src/osi/os/cygwin32/osdSock.h index 1d9aa818b..a725a7fe7 100644 --- a/modules/libcom/src/osi/os/cygwin32/osdSock.h +++ b/modules/libcom/src/osi/os/cygwin32/osdSock.h @@ -71,6 +71,7 @@ typedef int osiSockOptMcastTTL_t; #define SOCK_SHUTDOWN ESHUTDOWN #define SOCK_ENOTSOCK ENOTSOCK #define SOCK_EBADF EBADF +#define SOCK_EMSGSIZE EMSGSIZE #define ifreq_size(pifreq) (sizeof(pifreq->ifr_name)) diff --git a/modules/libcom/src/osi/os/freebsd/osdSock.h b/modules/libcom/src/osi/os/freebsd/osdSock.h index f6800e44f..8ebf37db8 100644 --- a/modules/libcom/src/osi/os/freebsd/osdSock.h +++ b/modules/libcom/src/osi/os/freebsd/osdSock.h @@ -61,6 +61,7 @@ typedef unsigned char osiSockOptMcastTTL_t; #define SOCK_SHUTDOWN ESHUTDOWN #define SOCK_ENOTSOCK ENOTSOCK #define SOCK_EBADF EBADF +#define SOCK_EMSGSIZE EMSGSIZE #ifndef SHUT_RD # define SHUT_RD 0 diff --git a/modules/libcom/src/osi/os/iOS/osdSock.h b/modules/libcom/src/osi/os/iOS/osdSock.h index c2aeabd67..34ee13d73 100644 --- a/modules/libcom/src/osi/os/iOS/osdSock.h +++ b/modules/libcom/src/osi/os/iOS/osdSock.h @@ -57,6 +57,7 @@ typedef unsigned char osiSockOptMcastTTL_t; #define SOCK_SHUTDOWN ESHUTDOWN #define SOCK_ENOTSOCK ENOTSOCK #define SOCK_EBADF EBADF +#define SOCK_EMSGSIZE EMSGSIZE #ifndef SHUT_RD #define SHUT_RD 0 diff --git a/modules/libcom/src/osi/os/solaris/osdSock.h b/modules/libcom/src/osi/os/solaris/osdSock.h index e125ac0c6..9cfabdf0a 100644 --- a/modules/libcom/src/osi/os/solaris/osdSock.h +++ b/modules/libcom/src/osi/os/solaris/osdSock.h @@ -69,6 +69,7 @@ typedef unsigned char osiSockOptMcastTTL_t; #define SOCK_SHUTDOWN ESHUTDOWN #define SOCK_ENOTSOCK ENOTSOCK #define SOCK_EBADF EBADF +#define SOCK_EMSGSIZE EMSGSIZE #ifndef SHUT_RD # define SHUT_RD 0 diff --git a/modules/libcom/src/osi/os/vxWorks/osdSock.h b/modules/libcom/src/osi/os/vxWorks/osdSock.h index 12bd8724e..8787eacbf 100644 --- a/modules/libcom/src/osi/os/vxWorks/osdSock.h +++ b/modules/libcom/src/osi/os/vxWorks/osdSock.h @@ -90,6 +90,7 @@ typedef char osiSockOptMcastTTL_t; #define SOCK_SHUTDOWN ESHUTDOWN #define SOCK_ENOTSOCK ENOTSOCK #define SOCK_EBADF EBADF +#define SOCK_EMSGSIZE EMSGSIZE #ifndef INADDR_LOOPBACK #define INADDR_LOOPBACK 0x7F000001 diff --git a/modules/libcom/test/osiSockTest.c b/modules/libcom/test/osiSockTest.c index f2adb41cd..284f828dc 100644 --- a/modules/libcom/test/osiSockTest.c +++ b/modules/libcom/test/osiSockTest.c @@ -243,6 +243,9 @@ void udpSockFanoutTestRx(void* raw) buf.bytes[sizeof(buf.bytes)-1] = '\0'; if(n<0) { + if(SOCKERRNO==SOCK_EMSGSIZE || SOCKERRNO==SOCK_EINTR) + continue; + testDiag("recvfrom error (%d)", (int)SOCKERRNO); break; } else if((n==sizeof(buf.bytes)) && buf.msg.cmd==htons(6) && buf.msg.size==htons(16) From 8e7d3e9216885ae56b5135aa158ae77059374e3a Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 30 Jun 2021 10:42:59 -0700 Subject: [PATCH 191/195] re-sync initHookName() with initHookState enum --- modules/libcom/src/iocsh/initHooks.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/modules/libcom/src/iocsh/initHooks.c b/modules/libcom/src/iocsh/initHooks.c index 922bb1d4d..70572934d 100644 --- a/modules/libcom/src/iocsh/initHooks.c +++ b/modules/libcom/src/iocsh/initHooks.c @@ -120,14 +120,25 @@ const char *initHookName(int state) "initHookAfterInitialProcess", "initHookAfterCaServerInit", "initHookAfterIocBuilt", + "initHookAtIocRun", "initHookAfterDatabaseRunning", "initHookAfterCaServerRunning", "initHookAfterIocRunning", + "initHookAtIocPause", "initHookAfterCaServerPaused", "initHookAfterDatabasePaused", "initHookAfterIocPaused", + + "initHookAtShutdown", + "initHookAfterCloseLinks", + "initHookAfterStopScan", + "initHookAfterStopCallback", + "initHookAfterStopLinks", + "initHookBeforeFree", + "initHookAfterShutdown", + "initHookAfterInterruptAccept", "initHookAtEnd" }; From 710c50b5ed957f2fcfdc80bd8426dac58565710e Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Wed, 30 Jun 2021 10:39:58 -0700 Subject: [PATCH 192/195] add initHookTest --- modules/libcom/test/Makefile | 5 ++++ modules/libcom/test/epicsRunLibComTests.c | 2 ++ modules/libcom/test/initHookTest.c | 30 +++++++++++++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 modules/libcom/test/initHookTest.c diff --git a/modules/libcom/test/Makefile b/modules/libcom/test/Makefile index ef8605002..809ae7338 100644 --- a/modules/libcom/test/Makefile +++ b/modules/libcom/test/Makefile @@ -144,6 +144,11 @@ epicsThreadPoolTest_SRCS += epicsThreadPoolTest.c testHarness_SRCS += epicsThreadPoolTest.c TESTS += epicsThreadPoolTest +TESTPROD_HOST += initHookTest +initHookTest_SRCS += initHookTest.c +testHarness_SRCS += initHookTest.c +TESTS += initHookTest + TESTPROD_HOST += epicsExitTest epicsExitTest_SRCS += epicsExitTest.c testHarness_SRCS += epicsExitTest.c diff --git a/modules/libcom/test/epicsRunLibComTests.c b/modules/libcom/test/epicsRunLibComTests.c index d469fcf83..54c46a68e 100644 --- a/modules/libcom/test/epicsRunLibComTests.c +++ b/modules/libcom/test/epicsRunLibComTests.c @@ -50,6 +50,7 @@ int epicsTimeZoneTest(void); #endif int epicsTypesTest(void); int epicsInlineTest(void); +int initHookTest(void); int ipAddrToAsciiTest(void); int macDefExpandTest(void); int macLibTest(void); @@ -105,6 +106,7 @@ void epicsRunLibComTests(void) runTest(epicsTimeZoneTest); #endif runTest(epicsTypesTest); + runTest(initHookTest); runTest(ipAddrToAsciiTest); runTest(macDefExpandTest); runTest(macLibTest); diff --git a/modules/libcom/test/initHookTest.c b/modules/libcom/test/initHookTest.c new file mode 100644 index 000000000..688fea37b --- /dev/null +++ b/modules/libcom/test/initHookTest.c @@ -0,0 +1,30 @@ +/*************************************************************************\ +* Copyright (c) 2021 Michael Davidsaver +* SPDX-License-Identifier: EPICS +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +#include +#include + +#include +#include + +#include + +static +void testHookNames(void) +{ + const char* s; + + s = initHookName(initHookAtEnd); + testOk(strcmp(s, "initHookAtEnd")==0, "'%s' == 'initHookAtEnd'", s); +} + +MAIN(initHookTest) +{ + testPlan(1); + testHookNames(); + return testDone(); +} From ba3550c287db547af5ab82c5281bc63d808d6a62 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Fri, 2 Jul 2021 16:28:22 -0500 Subject: [PATCH 193/195] Update submodules for release --- modules/normativeTypes | 2 +- modules/pvData | 2 +- modules/pvDatabase | 2 +- modules/pvaClient | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/normativeTypes b/modules/normativeTypes index 7a2d264f2..1250a3c23 160000 --- a/modules/normativeTypes +++ b/modules/normativeTypes @@ -1 +1 @@ -Subproject commit 7a2d264f2cb107bfd10adb23bc2b73d8323a79e4 +Subproject commit 1250a3c236f0aa92e0b5bd73647fd71d8a09360d diff --git a/modules/pvData b/modules/pvData index d3b4976ea..b1c830387 160000 --- a/modules/pvData +++ b/modules/pvData @@ -1 +1 @@ -Subproject commit d3b4976ea2b0d78075511f14d7f7bf9620dd4d14 +Subproject commit b1c8303870a04f1c3ee5a01a84aad2b2596e918c diff --git a/modules/pvDatabase b/modules/pvDatabase index 93a259cbd..8cac3975c 160000 --- a/modules/pvDatabase +++ b/modules/pvDatabase @@ -1 +1 @@ -Subproject commit 93a259cbde56668c1bbe495b15cc3ede8b42ce30 +Subproject commit 8cac3975cce67828a19e600fee85dd28df52fe2c diff --git a/modules/pvaClient b/modules/pvaClient index efb263190..a34876e36 160000 --- a/modules/pvaClient +++ b/modules/pvaClient @@ -1 +1 @@ -Subproject commit efb2631905cd61cc06041f5aac5be9017383a004 +Subproject commit a34876e36a56c9de9b172d6a83a9439bb330783d From 67bf1a72e77efd62d07fdca919a3c738a6258283 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 3 Jul 2021 20:14:04 -0500 Subject: [PATCH 194/195] Substitute version in @since UNRELEASED annotations --- modules/database/src/ioc/db/dbLink.h | 8 ++++---- modules/database/src/ioc/db/recGbl.h | 2 +- modules/libcom/src/misc/epicsString.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/database/src/ioc/db/dbLink.h b/modules/database/src/ioc/db/dbLink.h index 1933952b9..d1e454485 100644 --- a/modules/database/src/ioc/db/dbLink.h +++ b/modules/database/src/ioc/db/dbLink.h @@ -371,7 +371,7 @@ typedef struct lset { * Implementations must write a trailing nil to msgbuf whenever * @code msgbuf!=NULL && msgbuflen>0 @endcode . * - * @since UNRELEASED + * @since 7.0.6 */ long (*getAlarmMsg)(const struct link *plink, epicsEnum16 *status, epicsEnum16 *severity, char *msgbuf, size_t msgbuflen); @@ -381,7 +381,7 @@ typedef struct lset { * Equivalent of getTimeStamp() and also copy out time tag. * ptag may be NULL. * - * @since Added after UNRELEASED + * @since Added after 7.0.6 */ long (*getTimeStampTag)(const struct link *plink, epicsTimeStamp *pstamp, epicsUTag *ptag); } lset; @@ -428,14 +428,14 @@ DBCORE_API long dbGetAlarm(const struct link *plink, epicsEnum16 *status, /** Get link alarm and message string. * To ensure the complete message string is copied, ensure @code msgbuflen >= sizeof (dbCommon::amsg) @endcode . * A trailing nil will be added whenever @code msgbuflen > 0 @endcode . - * @since UNRELEASED + * @since 7.0.6 */ DBCORE_API long dbGetAlarmMsg(const struct link *plink, epicsEnum16 *status, epicsEnum16 *severity, char *msgbuf, size_t msgbuflen); #define dbGetAlarmMsg(LINK, STAT, SEVR, BUF, BUFLEN) dbGetAlarmMsg(LINK, STAT, SEVR, BUF, BUFLEN) DBCORE_API long dbGetTimeStamp(const struct link *plink, epicsTimeStamp *pstamp); -/** @since UNRELEASED */ +/** @since 7.0.6 */ DBCORE_API long dbGetTimeStampTag(const struct link *plink, epicsTimeStamp *pstamp, epicsUTag *ptag); #define dbGetTimeStampTag(LINK, STAMP, TAG) dbGetTimeStampTag(LINK, STAMP, TAG) diff --git a/modules/database/src/ioc/db/recGbl.h b/modules/database/src/ioc/db/recGbl.h index 269777ec6..e362b8bd4 100644 --- a/modules/database/src/ioc/db/recGbl.h +++ b/modules/database/src/ioc/db/recGbl.h @@ -29,7 +29,7 @@ extern "C" { * * Covers addition of dbCommon::amsg, recGblSetSevrMsg(), lset::getAlarmMsg() * - * @since UNRELEASED + * @since 7.0.6 */ #define HAS_ALARM_MESSAGE 1 diff --git a/modules/libcom/src/misc/epicsString.h b/modules/libcom/src/misc/epicsString.h index 5bb8c87c1..24f1efb62 100644 --- a/modules/libcom/src/misc/epicsString.h +++ b/modules/libcom/src/misc/epicsString.h @@ -56,7 +56,7 @@ LIBCOM_API int epicsStrGlobMatch(const char *str, const char *pattern); * * @returns 1 if the first len characters of str match the pattern, 0 if not. * - * @since UNRELEASED + * @since 7.0.6 */ LIBCOM_API int epicsStrnGlobMatch(const char *str, size_t len, const char *pattern); From 591244599106c73e3a2c6bcb2ec9de3cc963c125 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Sat, 3 Jul 2021 20:46:58 -0500 Subject: [PATCH 195/195] Set version numbers for release --- configure/CONFIG_BASE_VERSION | 6 +++--- configure/CONFIG_CA_VERSION | 6 +++--- configure/CONFIG_DATABASE_VERSION | 6 +++--- configure/CONFIG_LIBCOM_VERSION | 6 +++--- documentation/RELEASE_NOTES.md | 14 +++++--------- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/configure/CONFIG_BASE_VERSION b/configure/CONFIG_BASE_VERSION index b0c57b763..efa0afee7 100644 --- a/configure/CONFIG_BASE_VERSION +++ b/configure/CONFIG_BASE_VERSION @@ -48,15 +48,15 @@ EPICS_VERSION = 7 EPICS_REVISION = 0 # EPICS_MODIFICATION must be a number >=0 and <256 -EPICS_MODIFICATION = 5 +EPICS_MODIFICATION = 6 # EPICS_PATCH_LEVEL must be a number (win32 resource file requirement) # Not included in the official EPICS version number if zero -EPICS_PATCH_LEVEL = 1 +EPICS_PATCH_LEVEL = 0 # Immediately after an official release the EPICS_PATCH_LEVEL is incremented # and the -DEV suffix is added (similar to the Maven -SNAPSHOT versions) -EPICS_DEV_SNAPSHOT=-DEV +EPICS_DEV_SNAPSHOT= # No changes should be needed below here diff --git a/configure/CONFIG_CA_VERSION b/configure/CONFIG_CA_VERSION index af570b0e7..ce95a0ad3 100644 --- a/configure/CONFIG_CA_VERSION +++ b/configure/CONFIG_CA_VERSION @@ -1,12 +1,12 @@ # Version number for the Channel Access API and shared library EPICS_CA_MAJOR_VERSION = 4 -EPICS_CA_MINOR_VERSION = 13 -EPICS_CA_MAINTENANCE_VERSION = 9 +EPICS_CA_MINOR_VERSION = 14 +EPICS_CA_MAINTENANCE_VERSION = 0 # Development flag, set to zero for release versions -EPICS_CA_DEVELOPMENT_FLAG = 1 +EPICS_CA_DEVELOPMENT_FLAG = 0 # Immediately after a release the MAINTENANCE_VERSION # will be incremented and the DEVELOPMENT_FLAG set to 1 diff --git a/configure/CONFIG_DATABASE_VERSION b/configure/CONFIG_DATABASE_VERSION index 2205a5386..348a69b11 100644 --- a/configure/CONFIG_DATABASE_VERSION +++ b/configure/CONFIG_DATABASE_VERSION @@ -1,12 +1,12 @@ # Version number for the database APIs and shared library EPICS_DATABASE_MAJOR_VERSION = 3 -EPICS_DATABASE_MINOR_VERSION = 19 -EPICS_DATABASE_MAINTENANCE_VERSION = 1 +EPICS_DATABASE_MINOR_VERSION = 20 +EPICS_DATABASE_MAINTENANCE_VERSION = 0 # Development flag, set to zero for release versions -EPICS_DATABASE_DEVELOPMENT_FLAG = 1 +EPICS_DATABASE_DEVELOPMENT_FLAG = 0 # Immediately after a release the MAINTENANCE_VERSION # will be incremented and the DEVELOPMENT_FLAG set to 1 diff --git a/configure/CONFIG_LIBCOM_VERSION b/configure/CONFIG_LIBCOM_VERSION index 96f25ebaa..76a5a5fcf 100644 --- a/configure/CONFIG_LIBCOM_VERSION +++ b/configure/CONFIG_LIBCOM_VERSION @@ -1,12 +1,12 @@ # Version number for the libcom APIs and shared library EPICS_LIBCOM_MAJOR_VERSION = 3 -EPICS_LIBCOM_MINOR_VERSION = 19 -EPICS_LIBCOM_MAINTENANCE_VERSION = 1 +EPICS_LIBCOM_MINOR_VERSION = 20 +EPICS_LIBCOM_MAINTENANCE_VERSION = 0 # Development flag, set to zero for release versions -EPICS_LIBCOM_DEVELOPMENT_FLAG = 1 +EPICS_LIBCOM_DEVELOPMENT_FLAG = 0 # Immediately after a release the MAINTENANCE_VERSION # will be incremented and the DEVELOPMENT_FLAG set to 1 diff --git a/documentation/RELEASE_NOTES.md b/documentation/RELEASE_NOTES.md index 1d2979ad9..c406b6506 100644 --- a/documentation/RELEASE_NOTES.md +++ b/documentation/RELEASE_NOTES.md @@ -2,20 +2,16 @@ These release notes describe changes that have been made since the previous release of this series of EPICS Base. **Note that changes which were merged up -from commits to new releases in an older Base series are not described at the -top of this file but have entries that appear lower down, under the series to -which they were originally committed.** Thus it is important to read more than -just the first section to understand everything that has changed in each -release. +from commits to the 3.15 branch are not described at the top of this file but +lower down, under the 3.15 release to which they were originally committed.** +Thus it is important to read more than just the first section to understand +everything that has changed in each release. The PVA submodules each have their own individual sets of release notes which should also be read to understand what has changed since earlier releases. -**This version of EPICS has not been released yet.** -## Changes made on the 7.0 branch since 7.0.5 - - +## EPICS Release 7.0.6 ### Support for obsolete architectures removed