From 077b41e6c10575f6f748ae1b5fb918c3c46e0747 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 30 Aug 2020 18:36:18 -0700 Subject: [PATCH 01/89] 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 02/89] 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 03/89] 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 04/89] 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 05/89] 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 06/89] 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 07/89] 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 08/89] 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 09/89] 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 10/89] 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 11/89] 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 12/89] 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 13/89] 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 14/89] 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 15/89] 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 16/89] 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 17/89] 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 18/89] 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 19/89] 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 20/89] 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 21/89] 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 22/89] 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 23/89] 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 24/89] 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 25/89] 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 26/89] 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 27/89] 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 28/89] 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 29/89] 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 30/89] 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 31/89] 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 32/89] 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 33/89] 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 34/89] 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 35/89] 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 36/89] 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 37/89] 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 38/89] 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 39/89] 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 40/89] 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 41/89] 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 42/89] 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 43/89] 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 44/89] 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 45/89] 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 46/89] 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 47/89] 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 48/89] 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 49/89] 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 50/89] 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 51/89] 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 52/89] 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 53/89] 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 54/89] 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 55/89] 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 56/89] 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 57/89] 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 58/89] 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 59/89] 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 60/89] 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 61/89] 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 62/89] 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 63/89] 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 64/89] 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 65/89] 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 66/89] 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 67/89] 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 68/89] 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 69/89] 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 70/89] 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 71/89] 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 72/89] 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 73/89] 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 74/89] 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 75/89] 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 76/89] 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 77/89] 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 78/89] 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 79/89] 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 80/89] 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 81/89] 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 82/89] 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 83/89] 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 3874c1bcfccb15f420743482b6f9c0c4fc1e08be Mon Sep 17 00:00:00 2001 From: Brendan Chandler Date: Mon, 15 Mar 2021 14:28:04 -0500 Subject: [PATCH 84/89] 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 85/89] 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 86/89] 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 457febb3a61c222ec62cbc61603422c01e0b6256 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Thu, 20 May 2021 13:28:30 -0500 Subject: [PATCH 87/89] 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 88/89] 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 89/89] 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)