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