[4c3433b] | 1 | RTEMS BSD Library Guide |
---|
| 2 | ======================= |
---|
[8f5adbc] | 3 | :toc: |
---|
| 4 | :icons: |
---|
| 5 | :numbered: |
---|
| 6 | :website: http://www.rtems.org/ |
---|
| 7 | |
---|
[9bc7b96] | 8 | The libbsd makes FreeBSD subsystems like TCP/IP, USB, SD and some more usable |
---|
| 9 | for RTEMS. It tries to follow the FreeBSD development as close as possible and |
---|
| 10 | therefore is updated to the latest FreeBSD HEAD revision from time to time. |
---|
| 11 | To find out which version of FreeBSD is currently used as the base version for |
---|
| 12 | libbsd please take a look at the |
---|
| 13 | https://git.rtems.org/rtems-libbsd/log/freebsd-org[freebsd-org] submodule. |
---|
| 14 | |
---|
[4c3433b] | 15 | This is a guide which captures information on the |
---|
[8f5adbc] | 16 | process of merging code from FreeBSD, building this library, |
---|
| 17 | RTEMS specific support files, and general guidelines on what |
---|
| 18 | modifications to the FreeBSD source are permitted. |
---|
| 19 | |
---|
[4c3433b] | 20 | Goals of this effort are |
---|
[e392fdb7] | 21 | |
---|
[4c3433b] | 22 | * update TCP/IP and provide USB in RTEMS, |
---|
| 23 | * ease updating to future FreeBSD versions, |
---|
| 24 | * ease tracking changes in FreeBSD code, |
---|
| 25 | * minimize manual changes in FreeBSD code, and |
---|
| 26 | * define stable kernel/device driver API which is implemented |
---|
[e392fdb7] | 27 | by both RTEMS and FreeBSD. This is the foundation of the port. |
---|
| 28 | |
---|
| 29 | We will work to push our changes upstream to the FreeBSD Project |
---|
| 30 | and minimize changes required at each update point. |
---|
| 31 | |
---|
[4c3433b] | 32 | ******************************************************************************* |
---|
[8f5adbc] | 33 | This is a work in progress and is very likely to be incomplete. |
---|
| 34 | Please help by adding to it. |
---|
[4c3433b] | 35 | ******************************************************************************* |
---|
[8f5adbc] | 36 | |
---|
[4c3433b] | 37 | == Getting Started |
---|
[8f5adbc] | 38 | |
---|
[4c3433b] | 39 | === Tool Chain === |
---|
[8f5adbc] | 40 | |
---|
[2707771] | 41 | You need a tool chain for RTEMS based on the latest RTEMS Source Builder (RSB). |
---|
[1bb23f0] | 42 | |
---|
[9d955bc] | 43 | === Installation Overview === |
---|
[b6d5758] | 44 | |
---|
| 45 | . You must configure your BSP with the +--disable-networking+ option to disable |
---|
| 46 | the old network stack. Make sure no header files of the old network stack are |
---|
| 47 | installed. |
---|
[97c5024a] | 48 | |
---|
[b6d5758] | 49 | . Clone the Git repository +git clone git://git.rtems.org/rtems-libbsd.git+. |
---|
| 50 | . Change into the RTEMS BSD library root directory. |
---|
[b3d1e6a] | 51 | . If you want to run tests with a custom IP configuration instead of the default |
---|
| 52 | one you can use an adjusted `config.inc` configuration file. |
---|
[97c5024a] | 53 | . Run +waf configure ...+. |
---|
| 54 | . Run +waf+. |
---|
| 55 | . Run +waf install+. |
---|
| 56 | |
---|
| 57 | Refer to the README.waf for Waf building instructions. |
---|
| 58 | |
---|
| 59 | Make sure the submodules have been initialised and are updated. If a 'git |
---|
| 60 | status' says `rtems_waf` need updating run the submodule update command: |
---|
| 61 | |
---|
[2707771] | 62 | $ git submodule sync |
---|
[97c5024a] | 63 | $ git submodule rtems_waf update |
---|
[b6d5758] | 64 | |
---|
[4c3433b] | 65 | === Board Support Package Requirements === |
---|
| 66 | |
---|
[2707771] | 67 | You need the latest RTEMS version to build the libbsd master. The Board |
---|
| 68 | Support Package (BSP) must support the |
---|
[9d955bc] | 69 | http://www.rtems.org/onlinedocs/doxygen/cpukit/html/group\__rtems\__interrupt__extension.html[Interrupt Manager Extension] |
---|
| 70 | // The first underscores have to be masked to stop asciidoc interpreting them |
---|
[4c3433b] | 71 | to make use of generic FreeBSD based drivers. |
---|
| 72 | |
---|
| 73 | === Board Support Package Configuration and Build === |
---|
| 74 | |
---|
[2707771] | 75 | You need to configure RTEMS for the desired BSP and install it. The BSP must |
---|
[4c3433b] | 76 | be configured with a disabled network stack. The BSD library containing the |
---|
| 77 | new network stack is a separate package. Using a BSP installation containing |
---|
| 78 | the old network stack may lead to confusion and unpredictable results. |
---|
| 79 | |
---|
[d6ad59d] | 80 | The following script is used to build the `arm/xilinx_zynq_a9_qemu` BSP for |
---|
[4c3433b] | 81 | our internal testing purposes: |
---|
| 82 | |
---|
| 83 | ------------------------------------------------------------------------------- |
---|
| 84 | #!/bin/sh |
---|
| 85 | |
---|
| 86 | cd ${HOME}/sandbox |
---|
[d6ad59d] | 87 | rm -rf b-xilinx_zynq_a9_qemu |
---|
| 88 | mkdir b-xilinx_zynq_a9_qemu |
---|
| 89 | cd b-xilinx_zynq_a9_qemu |
---|
[4c3433b] | 90 | ${HOME}/git-rtems/configure \ |
---|
| 91 | --prefix=${HOME}/sandbox/install \ |
---|
[f7a09b5] | 92 | --target=arm-rtems5 \ |
---|
[d6ad59d] | 93 | --enable-rtemsbsp=xilinx_zynq_a9_qemu \ |
---|
[4c3433b] | 94 | --disable-networking && \ |
---|
| 95 | make && \ |
---|
| 96 | make install |
---|
| 97 | ------------------------------------------------------------------------------- |
---|
| 98 | |
---|
[d6ad59d] | 99 | The `arm/xilinx_zynq_a9_qemu` BSP running on the Qemu simulator has some |
---|
[4c3433b] | 100 | benefits for development and test of the BSD library |
---|
| 101 | |
---|
| 102 | * it offers a NULL pointer read and write protection, |
---|
| 103 | * Qemu is a fast simulator, |
---|
| 104 | * Qemu provides support for GDB watchpoints, |
---|
| 105 | * Qemu provides support for virtual Ethernet networks, e.g. TUN and bridge |
---|
| 106 | devices (you can run multiple test instances on one virtual network). |
---|
| 107 | |
---|
| 108 | === BSD Library Configuration and Build === |
---|
| 109 | |
---|
[97c5024a] | 110 | The build system based on the Waf build system. To build with Waf please refer |
---|
| 111 | to the README.waf file. |
---|
[4517fa3] | 112 | |
---|
[338f300] | 113 | Note that the libbsd supports different buildsets. These can be selected with |
---|
| 114 | the `--buildset=xxx.ini` option during the configure phase. Take a look at the |
---|
| 115 | comments in `buildset/*.ini` to see which build sets are officially supported. |
---|
| 116 | |
---|
| 117 | You can also create and provide your own buildset configuration. But remember |
---|
| 118 | that it's quite easy to break something by disabling the wrong modules. Only the |
---|
| 119 | configurations in the `buildset` directory are officially maintained. |
---|
| 120 | |
---|
[b3d1e6a] | 121 | ===== Example Configuration for Network Tests ===== |
---|
[4517fa3] | 122 | |
---|
[b3d1e6a] | 123 | If you need some other IP configuration for the network tests that use a fixed |
---|
| 124 | IP config you can copy `config.inc` to a location outside to the source tree and |
---|
| 125 | adapt it. Then use the option `--net-test-config=NET_CONFIG` to pass the file to |
---|
| 126 | waf's configure command. |
---|
[4c3433b] | 127 | |
---|
| 128 | ------------------------------------------------------------------------------- |
---|
| 129 | NET_CFG_SELF_IP = 10.0.0.2 |
---|
| 130 | NET_CFG_NETMASK = 255.255.0.0 |
---|
| 131 | NET_CFG_PEER_IP = 10.0.0.1 |
---|
| 132 | NET_CFG_GATEWAY_IP = 10.0.0.1 |
---|
| 133 | ------------------------------------------------------------------------------- |
---|
| 134 | |
---|
| 135 | === BSD Library Initialization === |
---|
| 136 | |
---|
[c67debb] | 137 | To initialise the BSD Library create a suitable rc.conf file. The FreeBSD man |
---|
| 138 | page rc.conf(5) provides the details needed to create a suitable format file: |
---|
| 139 | |
---|
| 140 | https://www.freebsd.org/cgi/man.cgi?rc.conf |
---|
| 141 | |
---|
| 142 | You can call one of three functions to run the initialisation once BSD has |
---|
| 143 | initialised: |
---|
| 144 | |
---|
| 145 | - rtems_bsd_run_etc_rc_conf: Run /etc/rc.conf. |
---|
| 146 | - rtems_bsd_run_rc_conf: Run a user supplied file. |
---|
| 147 | - rtems_bsd_run_rc_conf_script: Run the in memory line feed separated text string. |
---|
| 148 | |
---|
| 149 | For exapmle: |
---|
| 150 | |
---|
| 151 | void |
---|
| 152 | network_init(void) |
---|
| 153 | { |
---|
| 154 | rtems_status_code sc; |
---|
| 155 | |
---|
| 156 | sc = rtems_bsd_initialize(); |
---|
| 157 | assert(sc == RTEMS_SUCCESSFUL); |
---|
| 158 | |
---|
| 159 | rtems_bsd_run_etc_rc_conf(true); /* verbose = true */ |
---|
| 160 | |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | By default the networking support is builtin. Other directives can be added and |
---|
| 164 | are found in 'machine/rtems-bsd-rc-conf-directives.h'. Please check the file |
---|
| 165 | for the list. |
---|
| 166 | |
---|
| 167 | The following network names are supported: |
---|
| 168 | |
---|
| 169 | cloned_interfaces |
---|
| 170 | ifconfig_'interface' |
---|
| 171 | defaultrouter |
---|
| 172 | hostname |
---|
| 173 | |
---|
| 174 | For example: |
---|
| 175 | |
---|
| 176 | # |
---|
| 177 | # My BSD initialisation. |
---|
| 178 | # |
---|
| 179 | hostname="myhost" |
---|
| 180 | cloned_interfaces="vlan0 vlan1" |
---|
| 181 | ifconfig_re0="inet inet 10.10.10.10 netmask 255.255.255.0" |
---|
| 182 | fconfig_vlan0="inet 10.11.10.10 255.255.255.0 vlan 101 vlandev re0" |
---|
| 183 | defaultrouter="10.10.10.1" |
---|
| 184 | |
---|
| 185 | You can also intialise the BSD library using code. The following code to |
---|
| 186 | initialize the BSD library: |
---|
[4c3433b] | 187 | |
---|
| 188 | ------------------------------------------------------------------------------- |
---|
| 189 | #include <assert.h> |
---|
[ead7fdc] | 190 | #include <sysexits.h> |
---|
[4c3433b] | 191 | |
---|
| 192 | #include <rtems/bsd/bsd.h> |
---|
| 193 | |
---|
[ead7fdc] | 194 | void |
---|
| 195 | network_init(void) |
---|
| 196 | { |
---|
| 197 | rtems_status_code sc; |
---|
[a25e6a9] | 198 | int exit_code; |
---|
[4c3433b] | 199 | |
---|
[ead7fdc] | 200 | sc = rtems_bsd_initialize(); |
---|
| 201 | assert(sc == RTEMS_SUCCESSFUL); |
---|
| 202 | |
---|
[a25e6a9] | 203 | exit_code = rtems_bsd_ifconfig_lo0(); |
---|
| 204 | assert(exit_code == EX_OK); |
---|
[4c3433b] | 205 | } |
---|
| 206 | ------------------------------------------------------------------------------- |
---|
| 207 | |
---|
[ead7fdc] | 208 | This performs the basic network stack initialization with a loopback interface. |
---|
| 209 | Further initialization must be done using the standard BSD network |
---|
| 210 | configuration commands |
---|
[9bc7b96] | 211 | http://www.freebsd.org/cgi/man.cgi?query=ifconfig&sektion=8[IFCONFIG(8)] |
---|
[ead7fdc] | 212 | using `rtems_bsd_command_ifconfig()` and |
---|
[9bc7b96] | 213 | http://www.freebsd.org/cgi/man.cgi?query=route&sektion=8[ROUTE(8)] |
---|
[ead7fdc] | 214 | using `rtems_bsd_command_route()`. For an example please have a look at |
---|
| 215 | `testsuite/include/rtems/bsd/test/default-network-init.h`. |
---|
| 216 | |
---|
[91ea7ea] | 217 | === Task Priorities and Stack Size === |
---|
| 218 | |
---|
| 219 | The default task priority is 96 for the interrupt server task (name "IRQS"), 98 |
---|
| 220 | for the timer server task (name "TIME") and 100 for all other tasks. The |
---|
| 221 | application may provide their own implementation of the |
---|
| 222 | `rtems_bsd_get_task_priority()` function (for example in the module which calls |
---|
| 223 | `rtems_bsd_initialize()`) if different values are desired. |
---|
| 224 | |
---|
[33a15c3] | 225 | The task stack size is determined by the `rtems_bsd_get_task_stack_size()` |
---|
| 226 | function which may be provided by the application in case the default is not |
---|
| 227 | appropriate. |
---|
| 228 | |
---|
[5383ed4] | 229 | === Size for Allocator Domains === |
---|
| 230 | |
---|
| 231 | The size for an allocator domain can be specified via the |
---|
| 232 | `rtems_bsd_get_allocator_domain_size()` function. The application may provide |
---|
| 233 | their own implementation of the `rtems_bsd_get_allocator_domain_size()` |
---|
| 234 | function (for example in the module which calls `rtems_bsd_initialize()`) if |
---|
| 235 | different values are desired. The default size is 8MiB for all domains. |
---|
| 236 | |
---|
[7ec935e] | 237 | === Redirecting or Disabling the Output === |
---|
| 238 | |
---|
| 239 | A lot of system messages are printed to the stdout by default. If you want to |
---|
| 240 | redirect them you can overwrite the default print handler. That can even be done |
---|
| 241 | before the libbsd initialization to catch all messages. An example would look |
---|
| 242 | like follows: |
---|
| 243 | |
---|
| 244 | ------------------------------------------------------------------------------- |
---|
| 245 | int my_vprintf_handler(int level, const char *fmt, va_list ap) { |
---|
| 246 | /* Do something with the messages. */ |
---|
| 247 | |
---|
| 248 | return number_of_printed_chars; |
---|
| 249 | } |
---|
| 250 | |
---|
| 251 | ... |
---|
| 252 | /* In your initialization: */ |
---|
| 253 | rtems_bsd_vprintf_handler old; |
---|
| 254 | old = rtems_bsd_set_vprintf_handler(my_vprintf_handler); |
---|
| 255 | ... |
---|
| 256 | ------------------------------------------------------------------------------- |
---|
| 257 | |
---|
| 258 | As a special case, you can set the `rtems_bsd_vprintf_handler_mute(...)` |
---|
| 259 | provided by libbsd to suppress all output. |
---|
| 260 | |
---|
[4c3433b] | 261 | == Network Stack Features |
---|
| 262 | |
---|
| 263 | http://roy.marples.name/projects/dhcpcd/index[DHCPCD(8)]:: DHCP client |
---|
| 264 | |
---|
| 265 | https://developer.apple.com/library/mac/documentation/Networking/Reference/DNSServiceDiscovery_CRef/Reference/reference.html[dns_sd.h]:: DNS Service Discovery |
---|
| 266 | |
---|
| 267 | http://www.opensource.apple.com/source/mDNSResponder/mDNSResponder-320.10/mDNSCore/mDNSEmbeddedAPI.h[mDNS]:: Multi-Cast DNS |
---|
| 268 | |
---|
[9bc7b96] | 269 | http://www.freebsd.org/cgi/man.cgi?query=unix&sektion=4[UNIX(4)]:: UNIX-domain protocol family |
---|
[4c3433b] | 270 | |
---|
[9bc7b96] | 271 | http://www.freebsd.org/cgi/man.cgi?query=inet&sektion=4[INET(4)]:: Internet protocol family |
---|
[4c3433b] | 272 | |
---|
[9bc7b96] | 273 | http://www.freebsd.org/cgi/man.cgi?query=inet6&sektion=4[INET6(4)]:: Internet protocol version 6 family |
---|
[4c3433b] | 274 | |
---|
[9bc7b96] | 275 | http://www.freebsd.org/cgi/man.cgi?query=tcp&sektion=4[TCP(4)]:: Internet Transmission Control Protocol |
---|
[4c3433b] | 276 | |
---|
[9bc7b96] | 277 | http://www.freebsd.org/cgi/man.cgi?query=udp&sektion=4[UDP(4)]:: Internet User Datagram Protocol |
---|
[4c3433b] | 278 | |
---|
[9bc7b96] | 279 | http://www.freebsd.org/cgi/man.cgi?query=route&sektion=4[ROUTE(4)]:: Kernel packet forwarding database |
---|
[4c3433b] | 280 | |
---|
[9bc7b96] | 281 | http://www.freebsd.org/cgi/man.cgi?query=bpf&sektion=4[BPF(4)]:: Berkeley Packet Filter |
---|
[4c3433b] | 282 | |
---|
[9bc7b96] | 283 | http://www.freebsd.org/cgi/man.cgi?query=socket&sektion=2[SOCKET(2)]:: Create an endpoint for communication |
---|
[4c3433b] | 284 | |
---|
[9bc7b96] | 285 | http://www.freebsd.org/cgi/man.cgi?query=kqueue&sektion=2[KQUEUE(2)]:: Kernel event notification mechanism |
---|
[4c3433b] | 286 | |
---|
[9bc7b96] | 287 | http://www.freebsd.org/cgi/man.cgi?query=select&sektion=2[SELECT(2)]:: Synchronous I/O multiplexing |
---|
[4c3433b] | 288 | |
---|
[9bc7b96] | 289 | http://www.freebsd.org/cgi/man.cgi?query=poll&sektion=2[POLL(2)]:: Synchronous I/O multiplexing |
---|
[4c3433b] | 290 | |
---|
[9bc7b96] | 291 | http://www.freebsd.org/cgi/man.cgi?query=route&sektion=8[ROUTE(8)]:: Manually manipulate the routing tables |
---|
[4c3433b] | 292 | |
---|
[9bc7b96] | 293 | http://www.freebsd.org/cgi/man.cgi?query=ifconfig&sektion=8[IFCONFIG(8)]:: Configure network interface parameters |
---|
[4c3433b] | 294 | |
---|
[9bc7b96] | 295 | http://www.freebsd.org/cgi/man.cgi?query=netstat&sektion=1[NETSTAT(1)]:: Show network status |
---|
[4c3433b] | 296 | |
---|
[9bc7b96] | 297 | http://www.freebsd.org/cgi/man.cgi?query=ping&sektion=8[PING(8)]:: Send ICMP ECHO_REQUEST packets to network hosts |
---|
[4c3433b] | 298 | |
---|
[9bc7b96] | 299 | http://www.freebsd.org/cgi/man.cgi?query=ping6&sektion=8[PING6(8)]:: Send ICMPv6 ECHO_REQUEST packets to network hosts |
---|
[4c3433b] | 300 | |
---|
[9bc7b96] | 301 | http://www.freebsd.org/cgi/man.cgi?query=sysctl&sektion=3[SYSCTL(3)]:: Get or set system information |
---|
[4c3433b] | 302 | |
---|
[9bc7b96] | 303 | http://www.freebsd.org/cgi/man.cgi?query=resolver&sektion=3[RESOLVER(3)]:: Resolver routines |
---|
[4c3433b] | 304 | |
---|
[9bc7b96] | 305 | http://www.freebsd.org/cgi/man.cgi?query=gethostbyname&sektion=3[GETHOSTBYNAME(3)]:: Get network host entry |
---|
[4c3433b] | 306 | |
---|
[43dc972] | 307 | == Network Interface Drivers |
---|
| 308 | |
---|
| 309 | === Link Up/Down Events |
---|
| 310 | |
---|
| 311 | You can notifiy the application space of link up/down events in your network |
---|
| 312 | interface driver via the if_link_state_change(LINK_STATE_UP/LINK_STATE_DOWN) |
---|
| 313 | function. The DHCPCD(8) client is a consumer of these events for example. |
---|
| 314 | Make sure that the interface flag IFF_UP and the interface driver flag |
---|
| 315 | IFF_DRV_RUNNING is set in case the link is up, otherwise ether_output() will |
---|
| 316 | return the error status ENETDOWN. |
---|
| 317 | |
---|
[e6405ea] | 318 | == Shell Commands |
---|
| 319 | |
---|
| 320 | === HOSTNAME(1) |
---|
| 321 | |
---|
| 322 | In addition to the standard options the RTEMS version of the HOSTNAME(1) |
---|
| 323 | command supports the -m flag to set/get the multicast hostname of the |
---|
| 324 | mDNS resolver instance. See also rtems_mdns_sethostname() and |
---|
| 325 | rtems_mdns_gethostname(). |
---|
| 326 | |
---|
[613c341] | 327 | == Qemu |
---|
| 328 | |
---|
| 329 | Use the following script to set up a virtual network with three tap devices |
---|
| 330 | connected via one bridge device. |
---|
| 331 | |
---|
| 332 | ------------------------------------------------------------------------------- |
---|
| 333 | #!/bin/sh -x |
---|
| 334 | |
---|
| 335 | user=`whoami` |
---|
| 336 | interfaces=(1 2 3) |
---|
| 337 | |
---|
| 338 | tap=qtap |
---|
| 339 | bri=qbri |
---|
| 340 | |
---|
| 341 | case $1 in |
---|
| 342 | up) |
---|
| 343 | sudo -i brctl addbr $bri |
---|
| 344 | for i in ${interfaces[@]} ; do |
---|
| 345 | sudo -i tunctl -t $tap$i -u $user ; |
---|
| 346 | sudo -i ifconfig $tap$i up ; |
---|
| 347 | sudo -i brctl addif $bri $tap$i ; |
---|
| 348 | done |
---|
| 349 | sudo -i ifconfig $bri up |
---|
| 350 | ;; |
---|
| 351 | down) |
---|
| 352 | for i in ${interfaces[@]} ; do |
---|
| 353 | sudo -i ifconfig $tap$i down ; |
---|
| 354 | sudo -i tunctl -d $tap$i ; |
---|
| 355 | done |
---|
| 356 | sudo -i ifconfig $bri down |
---|
| 357 | sudo -i brctl delbr $bri |
---|
| 358 | ;; |
---|
| 359 | esac |
---|
| 360 | ------------------------------------------------------------------------------- |
---|
| 361 | |
---|
| 362 | Connect your Qemu instance to one of the tap devices, e.g. |
---|
| 363 | |
---|
| 364 | ------------------------------------------------------------------------------- |
---|
| 365 | qemu-system-i386 -m 512 -boot a -cpu pentium3 \ |
---|
| 366 | -drive file=$HOME/qemu/pc386_fda,index=0,if=floppy,format=raw \ |
---|
| 367 | -drive file=fat:$HOME/qemu/hd,format=raw \ |
---|
| 368 | -net nic,model=e1000,macaddr=0e:b0:ba:5e:ba:11 \ |
---|
| 369 | -net tap,ifname=qtap1,script=no,downscript=no \ |
---|
| 370 | -nodefaults -nographic -serial stdio |
---|
| 371 | ------------------------------------------------------------------------------- |
---|
| 372 | |
---|
[d6ad59d] | 373 | ------------------------------------------------------------------------------- |
---|
| 374 | qemu-system-arm \ |
---|
| 375 | -serial null \ |
---|
| 376 | -serial mon:stdio \ |
---|
| 377 | -nographic \ |
---|
| 378 | -M xilinx-zynq-a9 \ |
---|
| 379 | -net nic,model=cadence_gem,macaddr=0e:b0:ba:5e:ba:11 \ |
---|
| 380 | -net tap,ifname=qtap1,script=no,downscript=no \ |
---|
| 381 | -m 256M \ |
---|
[f7a09b5] | 382 | -kernel build/arm-rtems5-xilinx_zynq_a9_qemu/media01.exe |
---|
[d6ad59d] | 383 | ------------------------------------------------------------------------------- |
---|
| 384 | |
---|
[613c341] | 385 | Make sure that each Qemu instance uses its own MAC address to avoid an address |
---|
| 386 | conflict (or otherwise use it as a test). |
---|
| 387 | |
---|
[e78b3dc] | 388 | To connect the Qemu instances with your local network use the following |
---|
| 389 | (replace 'eth0' with the network interface of your host). |
---|
| 390 | |
---|
| 391 | ------------------------------------------------------------------------------- |
---|
| 392 | ifconfig eth0 0.0.0.0 |
---|
| 393 | brctl addif qbri eth0 |
---|
| 394 | dhclient qbri |
---|
| 395 | ------------------------------------------------------------------------------- |
---|
| 396 | |
---|
[39a650e] | 397 | === VDE and QEMU |
---|
| 398 | |
---|
| 399 | On FreeBSD you can create VDE or the Virtual Distributed Ethernet to create a |
---|
| 400 | network environment that does not need to run qemu as root or needing to drop |
---|
| 401 | the tap's privileges to run qemu. |
---|
| 402 | |
---|
| 403 | VDE creates a software switch with a default of 32 ports which means a single |
---|
| 404 | kernel tap can support 32 qemu networking sessions. |
---|
| 405 | |
---|
| 406 | To use VDE you need to build qemu with VDE support. The RSB can detect a VDE |
---|
| 407 | plug and enable VDE support in qemu when building. On FreeBSD install the VDE |
---|
| 408 | support with: |
---|
| 409 | |
---|
| 410 | # pkg install -u vde2 |
---|
| 411 | |
---|
| 412 | Build qemu with the RSB. |
---|
| 413 | |
---|
| 414 | To network create a bridge and a tap. The network is 10.10.1.0/24. On FreeBSD |
---|
| 415 | add to your /etc/rc.conf: |
---|
| 416 | |
---|
| 417 | cloned_interfaces="bridge0 tap0" |
---|
| 418 | autobridge_interfaces="bridge0" |
---|
| 419 | autobridge_bridge0="re0 tap0" |
---|
| 420 | ifconfig_re0="up" |
---|
| 421 | ifconfig_tap0="up" |
---|
| 422 | ifconfig_bridge0="inet 10.1.1.2 netmask 255.255.255.0" |
---|
| 423 | defaultrouter="10.10.1.1" |
---|
| 424 | |
---|
| 425 | Start the VDE switch as root: |
---|
| 426 | |
---|
| 427 | # sysctl net.link.tap.user_open=1 |
---|
| 428 | # sysctl net.link.tap.up_on_open=1 |
---|
| 429 | # vde_switch -d -s /tmp/vde1 -M /tmp/mgmt1 -tap tap0 -m 660 --mgmtmode 660 |
---|
| 430 | # chmod 660 /dev/tap0 |
---|
| 431 | |
---|
| 432 | You can connect to the VDE switch's management channel using: |
---|
| 433 | |
---|
| 434 | $ vdeterm /tmp/mgmt1 |
---|
| 435 | |
---|
| 436 | To run qemu: |
---|
| 437 | |
---|
| 438 | $ qemu-system-arm \ |
---|
| 439 | -serial null \ |
---|
| 440 | -serial mon:stdio \ |
---|
| 441 | -nographic \ |
---|
| 442 | -M xilinx-zynq-a9 \ |
---|
| 443 | -net nic,model=cadence_gem,macaddr=0e:b0:ba:5e:ba:11 \ |
---|
| 444 | -net vde,id=vde0,sock=/tmp/vde1 |
---|
| 445 | -m 256M \ |
---|
[f7a09b5] | 446 | -kernel build/arm-rtems5-xilinx_zynq_a9_qemu/rcconf02.exe |
---|
[39a650e] | 447 | |
---|
[4c3433b] | 448 | == Issues and TODO |
---|
[e392fdb7] | 449 | |
---|
[36a16f5c] | 450 | * PCI support on x86 uses a quick and dirty hack, see pci_reserve_map(). |
---|
| 451 | |
---|
[8475e7a] | 452 | * Priority queues are broken with clustered scheduling. |
---|
| 453 | |
---|
[d652c3b] | 454 | * Per-CPU data should be enabled once the new stack is ready for SMP. |
---|
| 455 | |
---|
| 456 | * Per-CPU NETISR(9) should be enabled onece the new stack is ready for SMP. |
---|
| 457 | |
---|
[549488b] | 458 | * Multiple routing tables are not supported. Every FIB value is set to zero |
---|
| 459 | (= BSD_DEFAULT_FIB). |
---|
| 460 | |
---|
[cc5f4b2] | 461 | * Process identifiers are not supported. Every PID value is set to zero |
---|
| 462 | (= BSD_DEFAULT_PID). |
---|
| 463 | |
---|
[69b29a0] | 464 | * User credentials are not supported. The following functions allow the |
---|
| 465 | operation for everyone |
---|
| 466 | - prison_equal_ip4(), |
---|
| 467 | - chgsbsize(), |
---|
| 468 | - cr_cansee(), |
---|
| 469 | - cr_canseesocket() and |
---|
| 470 | - cr_canseeinpcb(). |
---|
| 471 | |
---|
[4c3433b] | 472 | * A basic USB functionality test that is known to work on Qemu is desirable. |
---|
[560eccf] | 473 | |
---|
[8f5adbc] | 474 | * Adapt generic IRQ PIC interface code to Simple Vectored Interrupt Model |
---|
[4517fa3] | 475 | so that those architectures can use new TCP/IP and USB code. |
---|
[560eccf] | 476 | |
---|
[78e3181] | 477 | * freebsd-userspace/rtems/include/sys/syslog.h is a copy from the old |
---|
| 478 | RTEMS TCP/IP stack. For some reason, the __printflike markers do not |
---|
| 479 | compile in this environment. We may want to use the FreeBSD syslog.h |
---|
| 480 | and get this addressed. |
---|
| 481 | |
---|
[8f5adbc] | 482 | * in_cksum implementations for architectures not supported by FreeBSD. |
---|
| 483 | This will require figuring out where to put implementations that do |
---|
| 484 | not originate from FreeBSD and are populated via the script. |
---|
[560eccf] | 485 | |
---|
[cdf6024] | 486 | * MAC support functions are not thread-safe ("freebsd/lib/libc/posix1e/mac.c"). |
---|
| 487 | |
---|
[c14bb23] | 488 | * IFCONFIG(8): IEEE80211 support is disabled. This module depends on a XML |
---|
| 489 | parser and mmap(). |
---|
| 490 | |
---|
[1bc2756] | 491 | * get_cyclecount(): The implementation is a security problem. |
---|
| 492 | |
---|
[e859231] | 493 | * What to do with the priority parameter present in the FreeBSD synchronization |
---|
[ea87228] | 494 | primitives and the thread creation functions? |
---|
| 495 | |
---|
| 496 | * TASKQUEUE(9): Support spin mutexes. |
---|
[e859231] | 497 | |
---|
[3e29388] | 498 | * ZONE(9): Review allocator lock usage in rtems-bsd-chunk.c. |
---|
| 499 | |
---|
[0c9f27b] | 500 | * KQUEUE(2): Choose proper lock for global kqueue list. |
---|
| 501 | |
---|
[a9e26f5] | 502 | * TIMEOUT(9): Maybe use special task instead of timer server to call |
---|
| 503 | callout_tick(). |
---|
| 504 | |
---|
[c99816e] | 505 | * sysctl_handle_opaque(): Implement reliable snapshots. |
---|
| 506 | |
---|
[cae4d0a] | 507 | * PING6(8): What to do with SIGALARM? |
---|
| 508 | |
---|
[241fc32] | 509 | * <sys/param.h>: Update Newlib to use a MSIZE of 256. |
---|
| 510 | |
---|
[e10d1cd] | 511 | * BPF(4): Add support for zero-copy buffers. |
---|
| 512 | |
---|
[164c5f5] | 513 | * UNIX(4): Fix race conditions in the area of socket object and file node |
---|
| 514 | destruction. Add support for file descriptor transmission via control |
---|
| 515 | messages. |
---|
| 516 | |
---|
[08c8588] | 517 | * PRINTF(9): Add support for log(), the %D format specifier is missing in the |
---|
| 518 | normal printf() family. |
---|
| 519 | |
---|
[362782e] | 520 | * Why is the interrupt server used? The BSD interrupt handlers can block on |
---|
| 521 | synchronization primitives like mutexes. This is in contrast to RTEMS |
---|
| 522 | interrupt service routines. The BSPs using the generic interrupt support must |
---|
| 523 | implement the `bsp_interrupt_vector_enable()` and |
---|
| 524 | `bsp_interrupt_vector_disable()` routines. They normally enable/disable a |
---|
| 525 | particular interrupt source at the interrupt controller. This can be used to |
---|
| 526 | implement the interrupt server. The interrupt server is a task that wakes-up |
---|
| 527 | in case an associated interrupt happens. The interrupt source is disabled in |
---|
| 528 | a generic interrupt handler that wakes-up the interrupt server task. Once the |
---|
| 529 | postponed interrupt processing is performed in the interrupt server the |
---|
| 530 | interrupt source is enabled again. |
---|
| 531 | |
---|
[4517fa3] | 532 | * Convert all BSP linkcmds to use a linkcmds.base so the sections are |
---|
[560eccf] | 533 | easier to insert. |
---|
| 534 | |
---|
[86bc9a7] | 535 | * NIC Device Drivers |
---|
[78e3181] | 536 | - Only common PCI NIC drivers have been included in the initial set. These |
---|
| 537 | do not include any system on chip or ISA drivers. |
---|
| 538 | - PCI configuration probe does not appear to happen to determine if a |
---|
| 539 | NIC is in I/O or memory space. We have worked around this by using a |
---|
| 540 | static hint to tell the fxp driver the correct mode. But this needs to |
---|
| 541 | be addressed. |
---|
[4517fa3] | 542 | - The ISA drivers require more BSD infrastructure to be addressed. This was |
---|
[86bc9a7] | 543 | outside the scope of the initial porting effort. |
---|
| 544 | |
---|
[8f5adbc] | 545 | == FreeBSD Source |
---|
| 546 | |
---|
| 547 | You should be able to rely on FreebSD manual pages and documentation |
---|
| 548 | for details on the code itself. |
---|
| 549 | |
---|
[4c3433b] | 550 | == BSD Library Source |
---|
[455aa3a] | 551 | |
---|
[4c3433b] | 552 | == Initialization of the BSD Library |
---|
[455aa3a] | 553 | |
---|
[4c3433b] | 554 | The initialization of the BSD library is based on the FreeBSD SYSINIT(9) |
---|
[8a4f070] | 555 | infrastructure. The key to initializing a system is to ensure that the desired |
---|
| 556 | device drivers are explicitly pulled into the linked application. This plus |
---|
[4c3433b] | 557 | linking against the BSD library (`libbsd.a`) will pull in the necessary FreeBSD |
---|
[8a4f070] | 558 | infrastructure. |
---|
[455aa3a] | 559 | |
---|
[8a4f070] | 560 | The FreeBSD kernel is not a library like the RTEMS kernel. It is a bunch of |
---|
| 561 | object files linked together. If we have a library, then creating the |
---|
| 562 | executable is simple. We begin with a start symbol and recursively resolve all |
---|
| 563 | references. With a bunch of object files linked together we need a different |
---|
| 564 | mechanism. Most object files don't know each other. Lets say we have a driver |
---|
| 565 | module. The rest of the system has no references to this driver module. The |
---|
| 566 | driver module needs a way to tell the rest of the system: Hey, kernel I am |
---|
| 567 | here, please use my services! |
---|
[455aa3a] | 568 | |
---|
[8a4f070] | 569 | This registration of independent components is performed by SYSINIT(9) and |
---|
| 570 | specializations: |
---|
| 571 | |
---|
| 572 | http://www.freebsd.org/cgi/man.cgi?query=SYSINIT |
---|
| 573 | |
---|
| 574 | The SYSINIT(9) uses some global data structures that are placed in a certain |
---|
| 575 | section. In the linker command file we need this: |
---|
| 576 | |
---|
[4c3433b] | 577 | ------------------------------------------------------------------------------- |
---|
| 578 | .rtemsroset : { |
---|
| 579 | KEEP (*(SORT(.rtemsroset.*))) |
---|
| 580 | } |
---|
| 581 | |
---|
| 582 | .rtemsrwset : { |
---|
| 583 | KEEP (*(SORT(.rtemsrwset.*))) |
---|
| 584 | } |
---|
| 585 | ------------------------------------------------------------------------------- |
---|
| 586 | |
---|
| 587 | This results for example in this executable layout: |
---|
| 588 | |
---|
| 589 | ------------------------------------------------------------------------------- |
---|
| 590 | [...] |
---|
| 591 | *(SORT(.rtemsroset.*)) |
---|
| 592 | .rtemsroset.bsd.modmetadata_set.begin |
---|
| 593 | 0x000000000025fe00 0x0 libbsd.a(rtems-bsd-init.o) |
---|
| 594 | 0x000000000025fe00 _bsd__start_set_modmetadata_set |
---|
| 595 | .rtemsroset.bsd.modmetadata_set.content |
---|
| 596 | 0x000000000025fe00 0x8 libbsd.a(rtems-bsd-nexus.o) |
---|
| 597 | .rtemsroset.bsd.modmetadata_set.content |
---|
| 598 | 0x000000000025fe08 0x4 libbsd.a(kern_module.o) |
---|
| 599 | [...] |
---|
| 600 | .rtemsroset.bsd.modmetadata_set.content |
---|
| 601 | 0x000000000025fe68 0x4 libbsd.a(mii.o) |
---|
| 602 | .rtemsroset.bsd.modmetadata_set.content |
---|
| 603 | 0x000000000025fe6c 0x4 libbsd.a(mii_bitbang.o) |
---|
| 604 | .rtemsroset.bsd.modmetadata_set.end |
---|
| 605 | 0x000000000025fe70 0x0 libbsd.a(rtems-bsd-init.o) |
---|
| 606 | 0x000000000025fe70 _bsd__stop_set_modmetadata_set |
---|
| 607 | [...] |
---|
| 608 | .rtemsrwset 0x000000000030bad0 0x290 |
---|
| 609 | *(SORT(.rtemsrwset.*)) |
---|
| 610 | .rtemsrwset.bsd.sysinit_set.begin |
---|
| 611 | 0x000000000030bad0 0x0 libbsd.a(rtems-bsd-init.o) |
---|
| 612 | 0x000000000030bad0 _bsd__start_set_sysinit_set |
---|
| 613 | .rtemsrwset.bsd.sysinit_set.content |
---|
| 614 | 0x000000000030bad0 0x4 libbsd.a(rtems-bsd-nexus.o) |
---|
| 615 | .rtemsrwset.bsd.sysinit_set.content |
---|
| 616 | 0x000000000030bad4 0x8 libbsd.a(rtems-bsd-thread.o) |
---|
| 617 | .rtemsrwset.bsd.sysinit_set.content |
---|
| 618 | 0x000000000030badc 0x4 libbsd.a(init_main.o) |
---|
| 619 | [...] |
---|
| 620 | .rtemsrwset.bsd.sysinit_set.content |
---|
| 621 | 0x000000000030bd54 0x4 libbsd.a(frag6.o) |
---|
| 622 | .rtemsrwset.bsd.sysinit_set.content |
---|
| 623 | 0x000000000030bd58 0x8 libbsd.a(uipc_accf.o) |
---|
| 624 | .rtemsrwset.bsd.sysinit_set.end |
---|
| 625 | 0x000000000030bd60 0x0 libbsd.a(rtems-bsd-init.o) |
---|
| 626 | 0x000000000030bd60 _bsd__stop_set_sysinit_set |
---|
| 627 | [...] |
---|
| 628 | ------------------------------------------------------------------------------- |
---|
| 629 | |
---|
| 630 | Here you can see, that some global data structures are collected into |
---|
[8a4f070] | 631 | continuous memory areas. This memory area can be identified by start and stop |
---|
| 632 | symbols. This constructs a table of uniform items. |
---|
| 633 | |
---|
| 634 | The low level FreeBSD code calls at some time during the initialization the |
---|
| 635 | mi_startup() function (machine independent startup). This function will sort |
---|
| 636 | the SYSINIT(9) set and call handler functions which perform further |
---|
| 637 | initialization. The last step is the scheduler invocation. |
---|
| 638 | |
---|
| 639 | The SYSINIT(9) routines are run in mi_startup() which is called by |
---|
| 640 | rtems_bsd_initialize(). |
---|
| 641 | |
---|
| 642 | This is also explained in "The Design and Implementation of the FreeBSD |
---|
| 643 | Operating System" section 14.3 "Kernel Initialization". |
---|
| 644 | |
---|
| 645 | In RTEMS we have a library and not a bunch of object files. Thus we need a way |
---|
| 646 | to pull-in the desired services out of the libbsd. Here the |
---|
[4c3433b] | 647 | `rtems-bsd-sysinit.h` comes into play. The SYSINIT(9) macros have been |
---|
| 648 | modified and extended for RTEMS in `<sys/kernel.h>`: |
---|
[8a4f070] | 649 | |
---|
[4c3433b] | 650 | ------------------------------------------------------------------------------- |
---|
[8a4f070] | 651 | #ifndef __rtems__ |
---|
[4c3433b] | 652 | #define C_SYSINIT(uniquifier, subsystem, order, func, ident) \ |
---|
| 653 | static struct sysinit uniquifier ## _sys_init = { \ |
---|
| 654 | subsystem, \ |
---|
| 655 | order, \ |
---|
| 656 | func, \ |
---|
| 657 | (ident) \ |
---|
| 658 | }; \ |
---|
| 659 | DATA_SET(sysinit_set,uniquifier ## _sys_init) |
---|
[8a4f070] | 660 | #else /* __rtems__ */ |
---|
[4c3433b] | 661 | #define SYSINIT_ENTRY_NAME(uniquifier) \ |
---|
| 662 | _bsd_ ## uniquifier ## _sys_init |
---|
| 663 | #define SYSINIT_REFERENCE_NAME(uniquifier) \ |
---|
| 664 | _bsd_ ## uniquifier ## _sys_init_ref |
---|
| 665 | #define C_SYSINIT(uniquifier, subsystem, order, func, ident) \ |
---|
| 666 | struct sysinit SYSINIT_ENTRY_NAME(uniquifier) = { \ |
---|
| 667 | subsystem, \ |
---|
| 668 | order, \ |
---|
| 669 | func, \ |
---|
| 670 | (ident) \ |
---|
| 671 | }; \ |
---|
| 672 | RWDATA_SET(sysinit_set,SYSINIT_ENTRY_NAME(uniquifier)) |
---|
| 673 | #define SYSINIT_REFERENCE(uniquifier) \ |
---|
| 674 | extern struct sysinit SYSINIT_ENTRY_NAME(uniquifier); \ |
---|
| 675 | static struct sysinit const * const \ |
---|
| 676 | SYSINIT_REFERENCE_NAME(uniquifier) __used \ |
---|
| 677 | = &SYSINIT_ENTRY_NAME(uniquifier) |
---|
| 678 | #define SYSINIT_MODULE_REFERENCE(mod) \ |
---|
| 679 | SYSINIT_REFERENCE(mod ## module) |
---|
| 680 | #define SYSINIT_DRIVER_REFERENCE(driver, bus) \ |
---|
| 681 | SYSINIT_MODULE_REFERENCE(driver ## _ ## bus) |
---|
| 682 | #define SYSINIT_DOMAIN_REFERENCE(dom) \ |
---|
| 683 | SYSINIT_REFERENCE(domain_add_ ## dom) |
---|
[8a4f070] | 684 | #endif /* __rtems__ */ |
---|
[4c3433b] | 685 | ------------------------------------------------------------------------------- |
---|
[8a4f070] | 686 | |
---|
| 687 | Here you see that the SYSINIT(9) entries are no longer static. The |
---|
[4c3433b] | 688 | \*_REFERENCE() macros will create references to the corresponding modules which |
---|
[8a4f070] | 689 | are later resolved by the linker. The application has to provide an object |
---|
| 690 | file with references to all required FreeBSD modules. |
---|
| 691 | |
---|
| 692 | The FreeBSD device model is quite elaborated (with follow-ups): |
---|
| 693 | |
---|
| 694 | http://www.freebsd.org/cgi/man.cgi?query=driver |
---|
| 695 | |
---|
| 696 | The devices form a tree with the Nexus device at a high-level. This Nexus |
---|
| 697 | device is architecture specific in FreeBSD. In RTEMS we have our own Nexus |
---|
[4c3433b] | 698 | device, see `rtemsbsd/bsp/bsp-bsd-nexus-devices.c`. |
---|
[00ee241] | 699 | |
---|
| 700 | === SYSCTL_NODE Example |
---|
| 701 | |
---|
| 702 | During development, we had an undefined reference to |
---|
| 703 | _bsd_sysctl__net_children that we had trouble tracking down. Thanks to |
---|
| 704 | Chris Johns, we located it. He explained how to read SYSCTL_NODE |
---|
| 705 | definitions. This line from freebsd/netinet/in_proto.c is attempting |
---|
| 706 | to add the "inet" node to the parent node "_net". |
---|
| 707 | |
---|
| 708 | ---- |
---|
| 709 | SYSCTL_NODE(_net, PF_INET, inet, CTLFLAG_RW, 0, |
---|
| 710 | "Internet Family"); |
---|
| 711 | ---- |
---|
| 712 | |
---|
| 713 | Our problem was that we could not find where _bsd_sysctl__net_children |
---|
| 714 | was defined. Chris suggested that when in doubt compile with -save-temps |
---|
| 715 | and look at the preprocessed .i files. But he did not need that. He |
---|
| 716 | explained that this the symbol name _bsd_sysctl__net_children was |
---|
| 717 | automatically generated by a SYSCTL_NODE as follows: |
---|
| 718 | |
---|
| 719 | * _bsd_ - added by RTEMS modifications to SYSCTL_NODE macro |
---|
| 720 | * sysctl_ - boilerplace added by SYSCTL_NODE macro |
---|
| 721 | * "" - empty string for parent node |
---|
| 722 | * net - name of SYSCTL_NODE |
---|
| 723 | * children - added by SYSCTL macros |
---|
[4517fa3] | 724 | |
---|
[00ee241] | 725 | This was all generated by a support macro declaring the node as this: |
---|
| 726 | |
---|
| 727 | ---- |
---|
| 728 | struct sysctl_oid_list SYSCTL_NODE_CHILDREN(parent, name); |
---|
| 729 | ---- |
---|
| 730 | |
---|
[4517fa3] | 731 | Given this information, we located this SYSCTL_NODE declaration in |
---|
[00ee241] | 732 | kern/kern_mib.c |
---|
| 733 | |
---|
| 734 | ---- |
---|
| 735 | SYSCTL_NODE(, CTL_KERN, kern, CTLFLAG_RW, 0, |
---|
| 736 | "High kernel, proc, limits &c"); |
---|
| 737 | ---- |
---|
| 738 | |
---|
[c03e095] | 739 | == Core FreeBSD APIs and RTEMS Replacements == |
---|
| 740 | |
---|
| 741 | === SX(9) (Shared/exclusive locks) === |
---|
| 742 | |
---|
| 743 | http://www.freebsd.org/cgi/man.cgi?query=sx |
---|
| 744 | |
---|
| 745 | Binary semaphores (this neglects the ability to allow shared access). |
---|
| 746 | |
---|
| 747 | === MUTEX(9) (Mutual exclusion) === |
---|
| 748 | |
---|
| 749 | http://www.freebsd.org/cgi/man.cgi?query=mutex |
---|
| 750 | |
---|
| 751 | Binary semaphores (not recursive mutexes are not supported this way). |
---|
| 752 | |
---|
| 753 | === RWLOCK(9) (Reader/writer lock) === |
---|
| 754 | |
---|
| 755 | http://www.freebsd.org/cgi/man.cgi?query=rwlock |
---|
| 756 | |
---|
| 757 | POSIX r/w lock. |
---|
| 758 | |
---|
| 759 | === RMLOCK(9) (Reader/writer lock optimized for mostly read access patterns) === |
---|
| 760 | |
---|
[5ab1e1d] | 761 | Note: This object was implemented as a wrapper for RWLOCK in the rm_lock header file. |
---|
| 762 | |
---|
[c03e095] | 763 | http://www.freebsd.org/cgi/man.cgi?query=rmlock |
---|
| 764 | |
---|
| 765 | POSIX r/w lock. |
---|
| 766 | |
---|
| 767 | === CONDVAR(9) (Condition variables) === |
---|
| 768 | |
---|
| 769 | http://www.freebsd.org/cgi/man.cgi?query=condvar |
---|
| 770 | |
---|
| 771 | POSIX condition variables with modifications (hack). |
---|
| 772 | |
---|
| 773 | === CALLOUT(9) (Timer functions) === |
---|
| 774 | |
---|
| 775 | http://www.freebsd.org/cgi/man.cgi?query=callout |
---|
| 776 | |
---|
| 777 | Timer server. |
---|
| 778 | |
---|
| 779 | === TASKQUEUE(9) (Asynchronous task execution) === |
---|
| 780 | |
---|
| 781 | http://www.freebsd.org/cgi/man.cgi?query=taskqueue |
---|
| 782 | |
---|
| 783 | TBD. |
---|
| 784 | |
---|
| 785 | === KTHREAD(9), KPROC(9) (Tasks) === |
---|
| 786 | |
---|
| 787 | http://www.freebsd.org/cgi/man.cgi?query=kthread |
---|
| 788 | |
---|
| 789 | http://www.freebsd.org/cgi/man.cgi?query=kproc |
---|
| 790 | |
---|
| 791 | Tasks. |
---|
| 792 | |
---|
| 793 | === ZONE(9) (Zone allocator) === |
---|
| 794 | |
---|
| 795 | http://www.freebsd.org/cgi/man.cgi?query=zone |
---|
| 796 | |
---|
| 797 | TBD. |
---|
| 798 | |
---|
| 799 | === devfs (Device file system) === |
---|
| 800 | |
---|
[69355c3] | 801 | There is a minimal implementation based on IMFS. The mount point is fixed to |
---|
| 802 | "/dev". Note that the devfs is only used by the cdev subsystem. cdev has been |
---|
| 803 | adapted so that the full path (including the leading "/dev") is given to devfs. |
---|
| 804 | This saves some copy operations. |
---|
| 805 | |
---|
| 806 | devfs_create() first creates the full path and then creates an IMFS generic node |
---|
| 807 | for the device. |
---|
| 808 | |
---|
| 809 | TBD: remove empty paths on devfs_destroy(). |
---|
[c03e095] | 810 | |
---|
| 811 | === psignal (Signals) === |
---|
| 812 | |
---|
| 813 | TBD. Seems to be not needed. |
---|
| 814 | |
---|
| 815 | === poll, select === |
---|
| 816 | |
---|
| 817 | TBD. Seems to be not needed. |
---|
| 818 | |
---|
| 819 | === RMAN(9) (Resource management) === |
---|
| 820 | |
---|
| 821 | http://www.freebsd.org/cgi/man.cgi?query=rman |
---|
| 822 | |
---|
| 823 | TBD. Seems to be not needed. |
---|
| 824 | |
---|
| 825 | === DEVCLASS(9), DEVICE(9), DRIVER(9), MAKE_DEV(9) (Device management) === |
---|
| 826 | |
---|
| 827 | http://www.freebsd.org/cgi/man.cgi?query=devclass |
---|
| 828 | |
---|
| 829 | http://www.freebsd.org/cgi/man.cgi?query=device |
---|
| 830 | |
---|
| 831 | http://www.freebsd.org/cgi/man.cgi?query=driver |
---|
| 832 | |
---|
| 833 | http://www.freebsd.org/cgi/man.cgi?query=make_dev |
---|
| 834 | |
---|
| 835 | Use FreeBSD implementation as far as possible. FreeBSD has a nice API for |
---|
| 836 | dynamic device handling. It may be interesting for RTEMS to use this API |
---|
| 837 | internally in the future. |
---|
| 838 | |
---|
| 839 | === BUS_SPACE(9), BUS_DMA(9) (Bus and DMA access) === |
---|
| 840 | |
---|
| 841 | http://www.freebsd.org/cgi/man.cgi?query=bus_space |
---|
| 842 | |
---|
| 843 | http://www.freebsd.org/cgi/man.cgi?query=bus_dma |
---|
| 844 | |
---|
| 845 | Likely BSP dependent. A default implementation for memory mapped linear access |
---|
| 846 | is easy to provide. The current heap implementation supports all properties |
---|
| 847 | demanded by bus_dma (including the boundary constraint). |
---|
[5ab1e1d] | 848 | |
---|
[7586492] | 849 | == RTEMS Replacements by File Description == |
---|
[5ab1e1d] | 850 | |
---|
| 851 | Note: Files with a status of USB are used by the USB test and have at least |
---|
| 852 | been partially tested. If they contain both USB and Nic, then they are used |
---|
| 853 | by both and MAY contain methods that have not been tested yet. Files that |
---|
| 854 | are only used by the Nic test are the most suspect. |
---|
| 855 | |
---|
[fb4c8a9] | 856 | ---- |
---|
[5ab1e1d] | 857 | rtems-libbsd File: rtems-bsd-assert.c |
---|
| 858 | FreeBSD File: rtems-bsd-config.h redefines BSD_ASSERT. |
---|
| 859 | Description: This file contains the support method rtems_bsd_assert_func(). |
---|
| 860 | Status: USB, Nic |
---|
| 861 | |
---|
| 862 | rtems-libbsd File: rtems-bsd-autoconf.c |
---|
[4517fa3] | 863 | FreeBSD File: FreeBSD has BSP specific autoconf.c |
---|
[5ab1e1d] | 864 | Description: This file contains configuration methods that are used to setup the system. |
---|
[4517fa3] | 865 | Status: USB |
---|
[5ab1e1d] | 866 | |
---|
| 867 | rtems-libbsd File: rtems-bsd-bus-dma.c |
---|
| 868 | FreeBSD File: FreeBSD has BSP specific busdma_machdep.c |
---|
[4517fa3] | 869 | Description: |
---|
| 870 | Status: USB, Nic |
---|
[5ab1e1d] | 871 | |
---|
[4517fa3] | 872 | rtems-libbsd File: rtems-bsd-bus-dma-mbuf.c |
---|
[5ab1e1d] | 873 | FreeBSD File: FreeBSD has BSP specific busdma_machdep.c |
---|
[4517fa3] | 874 | Description: |
---|
[5ab1e1d] | 875 | Status: Nic |
---|
| 876 | |
---|
[4517fa3] | 877 | rtems-libbsd File: rtems-bsd-callout.c |
---|
[5ab1e1d] | 878 | FreeBSD File: kern/kern_timeout.c |
---|
[4517fa3] | 879 | Description: |
---|
| 880 | Status: USB, Nic |
---|
[5ab1e1d] | 881 | |
---|
| 882 | rtems-libbsd File: rtems-bsd-cam.c |
---|
| 883 | FreeBSD File: cam/cam_sim.c |
---|
[4517fa3] | 884 | Description: |
---|
| 885 | Status: USB |
---|
[5ab1e1d] | 886 | |
---|
[4517fa3] | 887 | rtems-libbsd File: rtems-bsd-condvar.c |
---|
[5ab1e1d] | 888 | FreeBSD File: kern/kern_condvar.c |
---|
[4517fa3] | 889 | Description: |
---|
| 890 | Status: USB |
---|
[5ab1e1d] | 891 | |
---|
| 892 | rtems-libbsd File: rtems-bsd-copyinout.c |
---|
| 893 | FreeBSD File: bsp specific copyinout.c ) |
---|
| 894 | Description: Note: The FreeBSD file is split with some methods being in rtems-bsd-support |
---|
[4517fa3] | 895 | Status: Nic |
---|
[5ab1e1d] | 896 | |
---|
| 897 | rtems-libbsd File: rtems-bsd-delay.c |
---|
| 898 | FreeBSD File: bsp specific file with multiple names |
---|
[4517fa3] | 899 | Description: |
---|
| 900 | Status: USB, Nic |
---|
[5ab1e1d] | 901 | |
---|
[4517fa3] | 902 | rtems-libbsd File: rtems-bsd-descrip.c |
---|
[5ab1e1d] | 903 | FreeBSD File: kern/kern_descrip.c |
---|
[4517fa3] | 904 | Description: |
---|
| 905 | Status: Nic |
---|
[5ab1e1d] | 906 | |
---|
[4517fa3] | 907 | rtems-libbsd File: rtems-bsd-generic.c |
---|
[5ab1e1d] | 908 | FreeBSD File: kern/sys_generic.c |
---|
[4517fa3] | 909 | Description: |
---|
| 910 | Status: Nic |
---|
[5ab1e1d] | 911 | |
---|
[4517fa3] | 912 | rtems-libbsd File: rtems-bsd-init.c |
---|
[5ab1e1d] | 913 | FreeBSD File: N/A |
---|
[4517fa3] | 914 | Description: |
---|
| 915 | Status: USB, Nic |
---|
[5ab1e1d] | 916 | |
---|
| 917 | rtems-libbsd File: rtems-bsd-init-with-irq.c |
---|
| 918 | FreeBSD File: N/A |
---|
[4517fa3] | 919 | Description: |
---|
| 920 | Status: USB, Nic |
---|
[5ab1e1d] | 921 | |
---|
| 922 | rtems-libbsd File: rtems-bsd-jail.c |
---|
| 923 | FreeBSD File: kern/kern_jail.c |
---|
[4517fa3] | 924 | Description: |
---|
| 925 | Status: USB, Nic |
---|
[5ab1e1d] | 926 | |
---|
| 927 | rtems-libbsd File: rtems-bsd-lock.c |
---|
| 928 | FreeBSD File: kern/subr_lock.c |
---|
[4517fa3] | 929 | Description: |
---|
| 930 | Status: USB, Nic |
---|
[5ab1e1d] | 931 | |
---|
[4517fa3] | 932 | rtems-libbsd File: rtems-bsd-log.c |
---|
[5ab1e1d] | 933 | FreeBSD File: kern/subr_prf.c |
---|
[4517fa3] | 934 | Description: |
---|
| 935 | Status: Nic |
---|
[5ab1e1d] | 936 | |
---|
| 937 | rtems-libbsd File: rtems-bsd-malloc.c |
---|
| 938 | FreeBSD File: kern/kern_malloc.c |
---|
[4517fa3] | 939 | Description: |
---|
| 940 | Status: USB, Nic |
---|
[5ab1e1d] | 941 | |
---|
| 942 | rtems-libbsd File: rtems-bsd-mutex.c |
---|
| 943 | FreeBSD File: kern/kern_mutex.c |
---|
[4517fa3] | 944 | Description: |
---|
| 945 | Status: USB, Nic |
---|
[5ab1e1d] | 946 | |
---|
| 947 | rtems-libbsd File: rtems-bsd-newproc.c |
---|
| 948 | FreeBSD File: N/A |
---|
[4517fa3] | 949 | Description: |
---|
| 950 | Status: Nic |
---|
[5ab1e1d] | 951 | |
---|
| 952 | rtems-libbsd File: rtems-bsd-nexus.c |
---|
| 953 | FreeBSD File: bsp specific nexus.c |
---|
[4517fa3] | 954 | Description: |
---|
| 955 | Status: USB |
---|
[5ab1e1d] | 956 | |
---|
[4517fa3] | 957 | rtems-libbsd File: rtems-bsd-panic.c |
---|
[5ab1e1d] | 958 | FreeBSD File: boot/common/panic.c |
---|
[4517fa3] | 959 | Description: |
---|
| 960 | Status: USB, Nic |
---|
[5ab1e1d] | 961 | |
---|
[4517fa3] | 962 | rtems-libbsd File: rtems-bsd-rwlock.c |
---|
[5ab1e1d] | 963 | FreeBSD File: kern_rwlock.c |
---|
[4517fa3] | 964 | Description: |
---|
| 965 | Status: USB, Nic |
---|
[5ab1e1d] | 966 | |
---|
[4517fa3] | 967 | rtems-libbsd File: rtems-bsd-shell.c |
---|
[5ab1e1d] | 968 | FreeBSD File: N/A |
---|
[4517fa3] | 969 | Description: |
---|
| 970 | Status: USB |
---|
[5ab1e1d] | 971 | |
---|
[4517fa3] | 972 | rtems-libbsd File: rtems-bsd-signal.c |
---|
[5ab1e1d] | 973 | FreeBSD File: kern/kern_sig.c |
---|
[4517fa3] | 974 | Description: |
---|
| 975 | Status: Nic |
---|
[5ab1e1d] | 976 | |
---|
[4517fa3] | 977 | rtems-libbsd File: rtems-bsd-smp.c |
---|
[5ab1e1d] | 978 | FreeBSD File: N/A |
---|
[4517fa3] | 979 | Description: |
---|
| 980 | Status: Nic |
---|
[5ab1e1d] | 981 | |
---|
[4517fa3] | 982 | rtems-libbsd File: rtems-bsd-support.c |
---|
| 983 | FreeBSD File: bsp specific copyinout.c |
---|
[5ab1e1d] | 984 | Description: Note: the FreeBSD file is split with some methods being in rtems-bsd-copyinout. |
---|
[4517fa3] | 985 | Status: USB, Nic |
---|
[5ab1e1d] | 986 | |
---|
[4517fa3] | 987 | rtems-libbsd File: rtems-bsd-sx.c |
---|
[5ab1e1d] | 988 | FreeBSD File: kern/kern_sx.c |
---|
[4517fa3] | 989 | Description: Status: USB, Nic |
---|
[5ab1e1d] | 990 | |
---|
[4517fa3] | 991 | rtems-libbsd File: rtems-bsd-synch.c |
---|
[5ab1e1d] | 992 | FreeBSD File: kern/kern_synch.c |
---|
[4517fa3] | 993 | Description: |
---|
| 994 | Status: USB, Nic |
---|
[5ab1e1d] | 995 | |
---|
[4517fa3] | 996 | rtems-libbsd File: rtems-bsd-syscalls.c |
---|
[5ab1e1d] | 997 | FreeBSD File: User API for kern/uipc_syscalls.c |
---|
[4517fa3] | 998 | Description: |
---|
| 999 | Status: Nic |
---|
[5ab1e1d] | 1000 | |
---|
[4517fa3] | 1001 | rtems-libbsd File: rtems-bsd-sysctlbyname.c |
---|
[5ab1e1d] | 1002 | FreeBSD File: User API for sysctlbyname(3) |
---|
[4517fa3] | 1003 | Description: |
---|
| 1004 | Status: |
---|
[5ab1e1d] | 1005 | |
---|
[4517fa3] | 1006 | rtems-libbsd File: rtems-bsd-sysctl.c |
---|
[5ab1e1d] | 1007 | FreeBSD File: User API for sysctl(8) |
---|
[4517fa3] | 1008 | Description: |
---|
| 1009 | Status: |
---|
[5ab1e1d] | 1010 | |
---|
[4517fa3] | 1011 | rtems-libbsd File: rtems-bsd-sysctlnametomib.c |
---|
[5ab1e1d] | 1012 | FreeBSD File: User API for sysctlnametomib |
---|
[4517fa3] | 1013 | Description: |
---|
| 1014 | Status: |
---|
[5ab1e1d] | 1015 | |
---|
[4517fa3] | 1016 | rtems-libbsd File: rtems-bsd-taskqueue.c |
---|
[5ab1e1d] | 1017 | FreeBSD File: kern/subr_taskqueue.c |
---|
[4517fa3] | 1018 | Description: |
---|
| 1019 | Status: Nic |
---|
[5ab1e1d] | 1020 | |
---|
[4517fa3] | 1021 | rtems-libbsd File: rtems-bsd-thread.c |
---|
[5ab1e1d] | 1022 | FreeBSD File: kern/kern_kthread.c |
---|
[4517fa3] | 1023 | Description: |
---|
| 1024 | Status: USB, Nic |
---|
[5ab1e1d] | 1025 | |
---|
[4517fa3] | 1026 | rtems-libbsd File: rtems-bsd-timeout.c |
---|
[5ab1e1d] | 1027 | FreeBSD File: kern/kern_timeout.c |
---|
[4517fa3] | 1028 | Description: |
---|
| 1029 | Status: Nic |
---|
[5ab1e1d] | 1030 | |
---|
[4517fa3] | 1031 | rtems-libbsd File: rtems-bsd-timesupport.c |
---|
[5ab1e1d] | 1032 | FreeBSD File: kern/kern_clock.c |
---|
[4517fa3] | 1033 | Description: |
---|
| 1034 | Status: Nic |
---|
[5ab1e1d] | 1035 | |
---|
[4517fa3] | 1036 | rtems-libbsd File: rtems-bsd-vm_glue.c |
---|
[5ab1e1d] | 1037 | FreeBSD File: vm/vm_glue.c |
---|
[4517fa3] | 1038 | Description: |
---|
| 1039 | Status: USB, Nic |
---|
[fb4c8a9] | 1040 | ---- |
---|
| 1041 | |
---|
| 1042 | == Notes by File == |
---|
[7586492] | 1043 | |
---|
[fb4c8a9] | 1044 | altq_subr.c - Arbitrary choices were made in this file that RTEMS would |
---|
| 1045 | not support tsc frequency change. Additionally, the clock frequency |
---|
| 1046 | for machclk_freq is always measured for RTEMS. |
---|
| 1047 | |
---|
| 1048 | conf.h - In order to add make_dev and destroy_dev, variables in the cdev |
---|
| 1049 | structure that were not being used were conditionally compiled out. The |
---|
| 1050 | capability of supporting children did not appear to be needed and was |
---|
| 1051 | not implemented in the rtems version of these routines. |
---|
[4517fa3] | 1052 | |
---|
[7586492] | 1053 | == NICs Status == |
---|
| 1054 | |
---|
[fb4c8a9] | 1055 | ---- |
---|
[7586492] | 1056 | Driver Symbol Status |
---|
| 1057 | ====== ====== ====== |
---|
[4517fa3] | 1058 | RealTek _bsd_re_pcimodule_sys_init Links |
---|
[7586492] | 1059 | EtherExpress _bsd_fxp_pcimodule_sys_init Links |
---|
| 1060 | DEC tulip _bsd_dc_pcimodule_sys_init Links |
---|
| 1061 | Broadcom BCM57xxx _bsd_bce_pcimodule_sys_init Links |
---|
| 1062 | Broadcom BCM4401 _bsd_bfe_pcimodule_sys_init Links |
---|
| 1063 | Broadcom BCM570x _bsd_bge_pcimodule_sys_init Needs Symbols (A) |
---|
[fb4c8a9] | 1064 | E1000 IGB _bsd_igb_pcimodule_sys_init Links |
---|
| 1065 | E1000 EM _bsd_em_pcimodule_sys_init Links |
---|
[b9fb1ef] | 1066 | Cadence ? Links, works. |
---|
[fb4c8a9] | 1067 | ---- |
---|
[7586492] | 1068 | |
---|
[1e8c93c] | 1069 | To add a NIC edit rtemsbsd/include/bsp/nexus-devices.h and add the driver |
---|
| 1070 | reference to the architecture and/or BSP. For example to add the RealTek driver |
---|
| 1071 | add: |
---|
| 1072 | |
---|
| 1073 | SYSINIT_DRIVER_REFERENCE(re, pci); |
---|
| 1074 | |
---|
| 1075 | and to add the MII PHY driver add: |
---|
| 1076 | |
---|
| 1077 | SYSINIT_DRIVER_REFERENCE(rge, miibus); |
---|
| 1078 | |
---|
| 1079 | The PC BSP has these entries. |
---|
| 1080 | |
---|
[7586492] | 1081 | Symbols (A) |
---|
| 1082 | pci_get_vpd_ident |
---|
[4517fa3] | 1083 | |
---|
[b9fb1ef] | 1084 | === Cadence === |
---|
| 1085 | |
---|
| 1086 | The cadence driver works on the Xilinx Zynq platform. The hardware checksum |
---|
| 1087 | support works on real hardware but does not seem to be supported on qemu |
---|
| 1088 | therefore the default state is to disable TXCSUM and RXCSUM and this can be |
---|
| 1089 | enabled from the shell with: |
---|
| 1090 | |
---|
| 1091 | # ifconfig cgem0 rxcsum txcsum |
---|
| 1092 | |
---|
| 1093 | or with an ioctl call to the network interface driver with SIOCSIFCAP and the |
---|
| 1094 | mask IFCAP_TXCSUM and IFCAP_RXCSUM set. |
---|
| 1095 | |
---|
[f1941b2] | 1096 | == PF (Firewall) == |
---|
| 1097 | |
---|
| 1098 | It is possible to use PF as a firewall. See |
---|
| 1099 | [https://www.freebsd.org/doc/handbook/firewalls-pf.html] for details on the |
---|
| 1100 | range of functions and for how to configure the firewall. |
---|
| 1101 | |
---|
| 1102 | The following is necessary to use PF on RTEMS: |
---|
| 1103 | |
---|
| 1104 | - You have to provide a +/etc/pf.os+ file. The firewall can use it for passive |
---|
| 1105 | OS fingerprinting. If you don't want to use this feature, the file may contain |
---|
| 1106 | nothing except a line of comment (for example "# empty"). |
---|
| 1107 | |
---|
| 1108 | - If some filters use protocol names (like tcp or udp) you have to provide a |
---|
| 1109 | +/etc/protocols+ file. |
---|
| 1110 | |
---|
| 1111 | - If some filters use service names (like ssh or http) you have to provide a |
---|
| 1112 | +/etc/services+ file. |
---|
| 1113 | |
---|
| 1114 | - Create a rule file (normally +/etc/pf.conf+). See the FreeBSD manual for the |
---|
| 1115 | syntax. |
---|
| 1116 | |
---|
[6cfb5c2] | 1117 | - Load the rule file using the pfctl command and enable pf. Please note that the |
---|
| 1118 | pfctl command needs a lot of stack. You should use at least |
---|
| 1119 | RTEMS_MINIMUM_STACK_SIZE + 8192 Bytes of stack. An example initialisation can |
---|
| 1120 | look like follows: |
---|
[f1941b2] | 1121 | |
---|
| 1122 | ---- |
---|
| 1123 | int exit_code; |
---|
| 1124 | char *params[] = { |
---|
| 1125 | "pfctl", |
---|
| 1126 | "-f", |
---|
| 1127 | "/etc/pf.conf", |
---|
| 1128 | "-e", |
---|
| 1129 | NULL |
---|
| 1130 | }; |
---|
| 1131 | |
---|
| 1132 | exit_code = rtems_bsd_command_pfctl(ARGC(params), params); |
---|
| 1133 | assert(exit_code == EXIT_SUCCSESS); |
---|
| 1134 | ---- |
---|
| 1135 | |
---|
| 1136 | === Known restrictions === |
---|
| 1137 | |
---|
| 1138 | - Currently PF on RTEMS always uses the configuration for memory restricted |
---|
| 1139 | systems (on FreeBSD that means systems with less than 100 MB RAM). This is |
---|
| 1140 | fixed in +pfctl_init_options()+. |
---|
| 1141 | |
---|
[e5abb31] | 1142 | == Wireless Network (WLAN) == |
---|
| 1143 | |
---|
| 1144 | The libbsd provides a basic support for WLAN. Note that currently this support |
---|
[338f300] | 1145 | is still in an early state. The WLAN support is _not_ enabled in the default |
---|
| 1146 | buildset. You have to configure libbsd with the |
---|
| 1147 | `--buildset=buildset/everything.ini` to enable that feature. |
---|
| 1148 | |
---|
| 1149 | The following gives a rough overview over the necessary steps to connect to an |
---|
| 1150 | encrypted network with an RTL8188EU based WiFi dongle: |
---|
[e5abb31] | 1151 | |
---|
| 1152 | - Reference all necessary module for your BSP. For some BSPs this is already |
---|
| 1153 | done in the nexus-devices.h: |
---|
| 1154 | |
---|
| 1155 | ---- |
---|
| 1156 | SYSINIT_MODULE_REFERENCE(wlan_ratectl_none); |
---|
| 1157 | SYSINIT_MODULE_REFERENCE(wlan_sta); |
---|
| 1158 | SYSINIT_MODULE_REFERENCE(wlan_amrr); |
---|
| 1159 | SYSINIT_MODULE_REFERENCE(wlan_wep); |
---|
| 1160 | SYSINIT_MODULE_REFERENCE(wlan_tkip); |
---|
| 1161 | SYSINIT_MODULE_REFERENCE(wlan_ccmp); |
---|
| 1162 | SYSINIT_DRIVER_REFERENCE(rtwn_usb, uhub); |
---|
| 1163 | SYSINIT_REFERENCE(rtwn_rtl8188eufw); |
---|
| 1164 | ---- |
---|
| 1165 | |
---|
| 1166 | - Create your wlan device using ifconfig: |
---|
| 1167 | +ifconfig wlan0 create wlandev rtwn0 up+ |
---|
| 1168 | |
---|
| 1169 | - Start a wpa_supplicant instance for that device: |
---|
| 1170 | + wpa_supplicant_fork -Dbsd -iwlan0 -c/media/mmcsd-0-0/wpa_supplicant.conf+ |
---|
| 1171 | |
---|
| 1172 | Note that the wpa_supplicant will only be active till the device goes down. A |
---|
| 1173 | workaround is to just restart it every time it exits. |
---|
| 1174 | |
---|
| 1175 | === Known restrictions === |
---|
| 1176 | |
---|
| 1177 | - The network interface (e.g. wlan0) is currently not automatically created. It |
---|
| 1178 | would be nice, if some service would create it as soon as for example a USB |
---|
| 1179 | device is connected. In FreeBSD the names are assigned via rc.conf with lines |
---|
| 1180 | like +wlans_rtwn0="wlan0"+. |
---|
| 1181 | |
---|
| 1182 | - wpa_supplicant hast to be started after the device is created. It has to be |
---|
| 1183 | restarted every time the connection goes down. Instead of this behaviour, |
---|
| 1184 | there should be some service that starts and restarts wpa_supplicant |
---|
| 1185 | automatically if a interface is ready. Probably the dhcpcd hooks could be used |
---|
| 1186 | for that. |
---|
| 1187 | |
---|
| 1188 | - The current wpa_supplicant implementation is protected with a lock so it can't |
---|
| 1189 | be started more than one time. If multiple interface should be used, all have |
---|
| 1190 | to be handled by that single instance. That makes it hard to add interfaces |
---|
| 1191 | dynamically. wpa_supplicant should be reviewed thoroughly whether multiple |
---|
| 1192 | instances could be started in parallel. |
---|
| 1193 | |
---|
| 1194 | - The control interface of wpa_supplicant most likely doesn't work. The wpa_cli |
---|
| 1195 | application is not ported. |
---|
| 1196 | |
---|
[afac48a] | 1197 | == IPSec == |
---|
| 1198 | |
---|
| 1199 | The IPSec support is optional in libbsd. It is disabled in the default build |
---|
| 1200 | set. Please make sure to use a build set with +netipsec = on+. |
---|
| 1201 | |
---|
| 1202 | To use IPSec the following configuration is necessary: |
---|
| 1203 | |
---|
| 1204 | ---- |
---|
| 1205 | SYSINIT_MODULE_REFERENCE(if_gif); |
---|
| 1206 | SYSINIT_MODULE_REFERENCE(cryptodev); |
---|
| 1207 | RTEMS_BSD_RC_CONF_SYSINT(rc_conf_ipsec) |
---|
| 1208 | RTEMS_BSD_DEFINE_NEXUS_DEVICE(cryptosoft, 0, 0, NULL); |
---|
| 1209 | ---- |
---|
| 1210 | |
---|
| 1211 | Alternatively you can use the `RTEMS_BSD_CONFIG_IPSEC` which also includes the |
---|
| 1212 | rc.conf support for ipsec. It's still necessary to include a crypto device in |
---|
| 1213 | your config (`cryptosoft` in the above sample). |
---|
| 1214 | |
---|
| 1215 | The necessary initialization steps for a IPSec connection are similar to the |
---|
| 1216 | steps on a FreeBSD-System. The example assumes the following setup: |
---|
| 1217 | |
---|
| 1218 | - RTEMS external IP: 192.168.10.1/24 |
---|
| 1219 | - RTEMS internal IP: 10.10.1.1/24 |
---|
| 1220 | - remote external IP: 192.168.10.10/24 |
---|
| 1221 | - remote internal IP: 172.24.0.1/24 |
---|
| 1222 | - shared key: "mysecretkey" |
---|
| 1223 | |
---|
| 1224 | With this the following steps are necessary: |
---|
| 1225 | |
---|
| 1226 | - Create a gif0 device: |
---|
| 1227 | |
---|
| 1228 | ---- |
---|
| 1229 | SHLL [/] # ifconfig gif0 create |
---|
| 1230 | ---- |
---|
| 1231 | |
---|
| 1232 | - Configure the gif0 device: |
---|
| 1233 | |
---|
| 1234 | ---- |
---|
| 1235 | SHLL [/] # ifconfig gif0 10.10.1.1 172.24.0.1 |
---|
| 1236 | SHLL [/] # ifconfig gif0 tunnel 192.168.10.1 192.168.10.10 |
---|
| 1237 | ---- |
---|
| 1238 | |
---|
| 1239 | - Add a route to the remote net via the remote IP: |
---|
| 1240 | |
---|
| 1241 | ---- |
---|
| 1242 | SHLL [/] # route add 172.24.0.0/24 172.24.0.1 |
---|
| 1243 | ---- |
---|
| 1244 | |
---|
| 1245 | - Call `setkey` with a correct rule set: |
---|
| 1246 | |
---|
| 1247 | ---- |
---|
| 1248 | SHLL [/] # cat /etc/setkey.conf |
---|
| 1249 | flush; |
---|
| 1250 | spdflush; |
---|
| 1251 | spdadd 10.10.1.0/24 172.24.0.0/24 any -P out ipsec esp/tunnel/192.168.10.1-192.168.10.10/use; |
---|
| 1252 | spdadd 172.24.0.0/24 10.10.1.0/24 any -P in ipsec esp/tunnel/192.168.10.10-192.168.10.1/use; |
---|
| 1253 | SHLL [/] # setkey -f /etc/setkey.conf |
---|
| 1254 | ---- |
---|
| 1255 | |
---|
| 1256 | - Start a ike-daemon (racoon) with a correct configuration. |
---|
| 1257 | ---- |
---|
| 1258 | SHLL [/] # cat /etc/racoon.conf |
---|
| 1259 | path pre_shared_key "/etc/racoon_psk.txt"; |
---|
| 1260 | log info; |
---|
| 1261 | |
---|
| 1262 | padding # options are not to be changed |
---|
| 1263 | { |
---|
| 1264 | maximum_length 20; |
---|
| 1265 | randomize off; |
---|
| 1266 | strict_check off; |
---|
| 1267 | exclusive_tail off; |
---|
| 1268 | } |
---|
| 1269 | |
---|
| 1270 | listen # address [port] that racoon will listen on |
---|
| 1271 | { |
---|
| 1272 | isakmp 192.168.10.1[500]; |
---|
| 1273 | } |
---|
| 1274 | |
---|
| 1275 | remote 192.168.10.10 [500] |
---|
| 1276 | { |
---|
| 1277 | exchange_mode main; |
---|
| 1278 | my_identifier address 192.168.10.1; |
---|
| 1279 | peers_identifier address 192.168.10.10; |
---|
| 1280 | proposal_check obey; |
---|
| 1281 | |
---|
| 1282 | proposal { |
---|
| 1283 | encryption_algorithm 3des; |
---|
| 1284 | hash_algorithm md5; |
---|
| 1285 | authentication_method pre_shared_key; |
---|
| 1286 | lifetime time 3600 sec; |
---|
| 1287 | dh_group 2; |
---|
| 1288 | } |
---|
| 1289 | } |
---|
| 1290 | |
---|
| 1291 | sainfo (address 10.10.1.0/24 any address 172.24.0.0/24 any) |
---|
| 1292 | { |
---|
| 1293 | pfs_group 2; |
---|
| 1294 | lifetime time 28800 sec; |
---|
| 1295 | encryption_algorithm 3des; |
---|
| 1296 | authentication_algorithm hmac_md5; |
---|
| 1297 | compression_algorithm deflate; |
---|
| 1298 | } |
---|
| 1299 | SHLL [/] # cat /etc/racoon_psk.txt |
---|
| 1300 | 192.168.10.10 mysecretkey |
---|
| 1301 | SHLL [/] # racoon -F -f /etc/racoon.conf |
---|
| 1302 | ---- |
---|
| 1303 | |
---|
| 1304 | All commands can be called via the respective API functions. For racoon there is |
---|
| 1305 | a `rtems_bsd_racoon_daemon()` function that forks of racoon as a task. |
---|
| 1306 | |
---|
| 1307 | Alternatively IPSec can also be configured via rc.conf entries: |
---|
| 1308 | |
---|
| 1309 | ---- |
---|
| 1310 | cloned_interfaces="gif0" |
---|
| 1311 | ifconfig_gif0="10.10.1.1 172.24.0.1 tunnel 192.168.10.1 192.168.10.10" |
---|
| 1312 | ike_enable="YES" |
---|
| 1313 | ike_program="racoon" |
---|
| 1314 | ike_flags="-F -f /etc/racoon.conf" |
---|
| 1315 | ike_priority="250" |
---|
| 1316 | |
---|
| 1317 | ipsec_enable="YES" |
---|
| 1318 | ipsec_file="/etc/setkey.conf" |
---|
| 1319 | ---- |
---|
| 1320 | |
---|
| 1321 | ATTENTION: It is possible that the first packets slip through the tunnel without |
---|
| 1322 | encryption (true for FreeBSD as well as RTEMS). You might want to set up a |
---|
| 1323 | firewall rule to prevent that. |
---|
| 1324 | |
---|
[99dc0d7] | 1325 | == Problems to report to FreeBSD == |
---|
| 1326 | |
---|
| 1327 | The MMAP_NOT_AVAILABLE define is inverted on its usage. When it is |
---|
[4517fa3] | 1328 | defined the mmap method is called. Additionally, it is not used |
---|
[99dc0d7] | 1329 | thoroughly. It is not used in the unmap portion of the source. |
---|
[808a6b2] | 1330 | The file rec_open.c uses the define MMAP_NOT_AVAILABLE to wrap |
---|
| 1331 | the call to mmap and file rec_close.c uses the munmap method. |
---|