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