Files
epics-base/modules/libcom/RTEMS/posix/rtems_config.c
T
Brendan Chandler 6b866ddc67 Configure Static IP with RTEMS libbsd (#853)
* Add RTEMS libbsd static network config for motload nvram

setBootConfigFromNVRAM() now configures static networking via the
libbsd rtems_bsd_ifconfig() API when building against RTEMS with
libbsd.  It only uses static networking if it can find a configured IP
and netmask from GEV or the mot script boot parameters, otherwise it
falls back to DHCP.

Also note, NTP was part of setBootConfigFromNVRAM() when using legacy
RTEMS networking, but is handled outside this function for LibBSD.  To
preserve the legacy behavior, setBootConfigFromNVRAM() still pulls out
NTP server info, but now stores it in an output parameter for outside
code to use.

* Wait for link to come up when starting RTEMS/libbsd/static IP

When configuring a static IP on RTEMS/libbsd, we need to intentionally
wait for the link to come up before continuing to configure ntp, etc.

* Separate common network setup from BSP specific implementations

All the BSP setBootConfigFromNVRAM() functions ultimately configured
the RTEMS networking the same way.  The common networking code
has been pulled out into a separate function now called from BSP specific
code.

All networking setup is now included and optionally used only
when the BSP sets the field appropriately.

This lets the setBootConfigFromNVRAM functions be independent of the
network stack, just focussing on collecting the configuration from each
BSP as appropriate.

* Fix unused function warnings for functions unused on certain BSPs

* Remove old comments about if MY_BOOTP

* Added release note entry

-- 
Co-authored-by: Brendan Chandler <bchandler@anl.gov>
2026-08-04 17:22:18 -05:00

193 lines
6.1 KiB
C

/*************************************************************************\
* 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.h>
/*
***********************************************************************
* 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
/*
* Override in configure/CONFIG_SITE.local with:
*
* OP_SYS_CFLAGS += -DCONFIGURE_MICROSECONDS_PER_TICK=1000
*/
#ifndef CONFIGURE_MICROSECONDS_PER_TICK
#define CONFIGURE_MICROSECONDS_PER_TICK 10000
#endif
#define CONFIGURE_MALLOC_STATISTICS 1
/* 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
#ifndef RTEMS_LEGACY_STACK
#define CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
//#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 <machine/rtems-bsd-config.h>
#endif // not LEGACY_STACK
/*
* 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
/* Note: The select() system call can only be used with the first FD_SETSIZE
* File Descriptors (newlib default is 64). Beginning RTEMS 5.1, FDs are
* allocated sequentially. So changing this CONFIGURE parameter such
* that CONFIGURE_MAXIMUM_FILE_DESCRIPTORS >= FD_SETSIZE will likely
* cause applications making select() calls to fault at some point.
*
* IOC core components (libca and RSRV) do not make select() calls.
*
* Applications and driver code using poll() or other socket
* multiplexers do not share this limitation.
*
* cf. https://github.com/epics-base/epics-base/issues/300
*/
#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 64
#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_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)
/* 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
#if __RTEMS_MAJOR__ > 4
#define CONFIGURE_SHELL_COMMANDS_INIT
#include <bsp/irq-info.h>
#ifndef RTEMS_LEGACY_STACK
#include <rtems/netcmds-config.h>
#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
#else // LEGACY_STACK:
#define CONFIGURE_SHELL_USER_COMMANDS \
&bsp_interrupt_shell_command
#endif // not LEGACY_STACK
#define CONFIGURE_SHELL_COMMAND_CPUUSE
#define CONFIGURE_SHELL_COMMAND_PERIODUSE
#define CONFIGURE_SHELL_COMMAND_STACKUSE
#define CONFIGURE_SHELL_COMMAND_PROFREPORT
#define CONFIGURE_SHELL_COMMAND_TOP
#define CONFIGURE_SHELL_COMMAND_RTEMS
#define CONFIGURE_SHELL_COMMANDS_ALL_NETWORKING
#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 <rtems/shellconfig.h>
#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
#else // __RTEMS_MAJOR__ > 4
#include <rtems/shellconfig.h>
#endif // __RTEMS_MAJOR__ > 4
#if __RTEMS_MAJOR__ < 5 // still needed in Version 4?
#define CONFIGURE_MAXIMUM_TASKS rtems_resource_unlimited(30)
#endif
#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(BSP_pc386) || defined(BSP_pc686)
#define RTEMS_BSD_CONFIG_DOMAIN_PAGE_MBUFS_SIZE (64 * 1024 * 1024)
#elif defined(BSP_qoriq_e500)
#define RTEMS_BSD_CONFIG_DOMAIN_PAGE_MBUFS_SIZE (32 * 1024 * 1024)
#endif
#define CONFIGURE_INIT
#include <rtems/confdefs.h>