Prepared RTEMS 4.10 posix with network
This commit is contained in:
committed by
Brendan Chandler
parent
8ef4d29c48
commit
9f387b9675
@@ -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 <machine/rtems-bsd-config.h>
|
||||
#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 <bsp/irq-info.h>
|
||||
@@ -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 <rtems/confdefs.h>
|
||||
|
||||
|
||||
@@ -44,8 +44,11 @@
|
||||
#include <sched.h>
|
||||
#include <rtems/libio.h>
|
||||
#include <rtems/rtc.h>
|
||||
#if __RTEMS_MAJOR__ > 4
|
||||
#include <rtems/tod.h>
|
||||
#include <rtems/sysinit.h>
|
||||
#else
|
||||
#include <rtems/score/tod.h>
|
||||
#endif
|
||||
|
||||
#ifdef RTEMS_LEGACY_STACK
|
||||
#include <rtems/rtems_bsdnet.h>
|
||||
@@ -59,8 +62,9 @@
|
||||
#endif
|
||||
|
||||
#include <rtems/telnetd.h>
|
||||
#if __RTEMS_MAJOR__ > 4
|
||||
#include <rtems/printer.h>
|
||||
|
||||
#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 <uart.h>
|
||||
#if __RTEMS_MAJOR__ > 4
|
||||
#include <libchip/serial.h>
|
||||
#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)
|
||||
|
||||
124
modules/libcom/RTEMS/posix/rtems_netconfig.c
Normal file
124
modules/libcom/RTEMS/posix/rtems_netconfig.c
Normal file
@@ -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 <stdio.h>
|
||||
#include <bsp.h>
|
||||
#include <rtems/rtems_bsdnet.h>
|
||||
|
||||
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 */
|
||||
};
|
||||
@@ -1,6 +1,8 @@
|
||||
#include <rtems.h>
|
||||
#include <rtems/error.h>
|
||||
#include <rtems/rtems/tasks.h>
|
||||
#ifndef RTEMS_LEGACY_STACK
|
||||
#include <rtems/score/threadimpl.h>
|
||||
#endif
|
||||
|
||||
#include "../posix/osdMutex.c"
|
||||
#include "../posix/osdMutex.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
|
||||
|
||||
@@ -28,7 +28,17 @@
|
||||
#include <netdb.h>
|
||||
#include <unistd.h> /* 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
|
||||
|
||||
@@ -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 <dlfcn.h>
|
||||
|
||||
#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
|
||||
|
||||
@@ -25,7 +25,9 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#if defined(_POSIX_MEMLOCK) && _POSIX_MEMLOCK > 0
|
||||
#include <sys/mman.h>
|
||||
#ifndef RTEMS_LEGACY_STACK // seems to be part of libbsd?
|
||||
#include <sys/mman.h>
|
||||
#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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user