From 54f2d8887fee72b625450ee115187fae3a52f178 Mon Sep 17 00:00:00 2001 From: Heinz Junkes Date: Mon, 23 Nov 2020 17:13:51 +0100 Subject: [PATCH] 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