LibBSD configuration and initialisation.
Chris Johns
chrisj at rtems.org
Thu Jun 30 02:37:09 UTC 2016
Hello,
The following is the current status for LibBSD configuration and
initialisation. I am starting to formalise the way this is done and as a
result I would like any further work on LibBSD to support the
configuration and initialisation methods I present.
User manual document is coming.
Configuration
-------------
I have added user application support to LibBSD. This follows the same
configuration model RTEMS uses with confdefs.h. In your 'init.c' you
define the features, interfaces, and services and then include
<machine/rtems-bsd-config.h>. For example:
/*
* Configure LibBSD.
*/
#define RTEMS_BSD_CONFIG_DOMAIN_PAGE_MBUFS_SIZE (16 * 1024 * 1024)
#define RTEMS_BSD_CONFIG_NET_PF_UNIX
#define RTEMS_BSD_CONFIG_NET_IF_LAGG
#define RTEMS_BSD_CONFIG_NET_IF_VLAN
#define RTEMS_BSD_CONFIG_SERVICE_FTPD
#define RTEMS_BSD_CONFIG_BSP_CONFIG
#define RTEMS_BSD_CONFIG_INIT
#include <machine/rtems-bsd-config.h>
rtems_task Init(rtems_task_argument ignored)
{
rtems_bsd_initialize();
my_app();
}
Notes:
- This interface will be documented and it is expected to be maintained.
- All further drivers added to LibBSD should provide the appropriate
layered support. What exists needs to be moved to this model as required.
- Please update the documenting comment sections if present in the
headers. Please fix omission as you find them.
- RTEMS_BSD_CONFIG_BSP_CONFIG creates a suitable default set up that
matches the set up for the testsuite. If you are on a BSP that has a
plug-in bus like the PC and PCI you may want to specialise the
configuration. The header <bsp/nexus-devices.h> can provide examples of
how to do this.
- The testsuite's 'default-init.h' and default-network-init.h supports
this configuration method.
- I have only concentrated on networking and I have not looked at media,
usb etc, other that attempting to maintain what exists.
Initialisation
--------------
I have completed the rc.conf changes needed to support interface network
set up and services. For example on the arm/xilinx_zynq_a9_qemu and qemu
you can now enable ftpd with an rc.conf file:
#
# Example rc.conf or arm/xilinx_zynq_a9_qemu with DHCP and ftpd.
#
hostname="awesome"
ifconfig_cgem0="DHCP"
defaultroute_delay="15"
# Services
ftpd_enabled="YES"
ftpd_options="-v -p 21 -C 10 -P 150 -L -I 10 -R /"
A subset of https://www.freebsd.org/cgi/man.cgi?query=rc.conf is
supported. I happy to add more features as demand dictates.
If an interface or service is not configured into the build the lines in
rc.conf are ignored. This is useful when you are testing on different
BSPs with different interfaces. See rcconf02 as an example.
An example Init is:
#include <machine/rtems-bsd-rc-conf.h>
rtems_task Init(rtems_task_argument ignored)
{
int r;
rtems_bsd_initialize();
/* Run /etc/rc.conf with timeout, verbose */
r = rtems_bsd_run_etc_rc_conf(60, false);
if (r < 0)
fprintf(stderr,
"error: awesome badness: %s\n", strerror(errno);
my_app();
}
Note:
- I consider the existing rtems_*_initialise method of initialisation
depreciated in LibBSD and would like it removed. The global non-const
struct's can then be removed as the services can be initialised by
argc/argv command lines. The ftpd service provides an example. Moving
the initialisation to an options command line allows us to hide these
tables and that means we can make changes without breaking existing user
code.
- VLANs are supported using:
vlans_cgem0="101 102"
ifconfig_cgem0.101="inet 192.0.101.1/24"
ifconfig_cgem0.102="inet 192.0.102.1/24"
- dhcpcd is configured using 'dhcpcd_options', eg
dhcpcd_options="-h foobar"
See https://www.freebsd.org/cgi/man.cgi?query=dhcpcd for details.
- The SYNCDHCP is the same as DHCP as dhcpcd always runs in the
background. Interface probing to ensure it is initialised could be added
if required allow SYNCDHCP to be correctly supported.
- As required by FreeBSD any DHCP interface will block initialisation
until a default route is detected. You can control the timeout with
'defaultroute_delay' and 0 means do not wait.
- rc.conf processing happens on a worker thread and you can specify a
time out so your main line initialisation thread does not block forever
if something blocks the initialisation.
As a back ground task I am adding rc.conf support for the other services
in LibBSD:
telnetd
pppd
mghttpd
Chris
More information about the devel
mailing list