[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 | |
---|
[4c3433b] | 35 | You need a tool chain for RTEMS based on at least |
---|
| 36 | |
---|
| 37 | * Binutils 2.24, and |
---|
| 38 | * Newlib 2.1.0. |
---|
| 39 | |
---|
| 40 | The Binutils version is required to ease the handling of linker command files. |
---|
| 41 | The Newlib version is required since some standard files like `<sys/types.h>` |
---|
| 42 | must be compatible enough for the files provided by the FreeBSD sources, e.g. |
---|
| 43 | `<sys/socket.h>`. |
---|
| 44 | |
---|
[9d955bc] | 45 | === Installation Overview === |
---|
[b6d5758] | 46 | |
---|
| 47 | . You must configure your BSP with the +--disable-networking+ option to disable |
---|
| 48 | the old network stack. Make sure no header files of the old network stack are |
---|
| 49 | installed. |
---|
| 50 | . Clone the Git repository +git clone git://git.rtems.org/rtems-libbsd.git+. |
---|
| 51 | . Change into the RTEMS BSD library root directory. |
---|
[ead7fdc] | 52 | . Edit the `config.inc` Makefile configuration file and adjust it to your environment. |
---|
[b6d5758] | 53 | . Run +make clean+. |
---|
| 54 | . Run +make install+. |
---|
| 55 | |
---|
[4c3433b] | 56 | === Board Support Package Requirements === |
---|
| 57 | |
---|
| 58 | The RTEMS version must be at least 4.11. The Board Support Package (BSP) |
---|
| 59 | should support the |
---|
[9d955bc] | 60 | http://www.rtems.org/onlinedocs/doxygen/cpukit/html/group\__rtems\__interrupt__extension.html[Interrupt Manager Extension] |
---|
| 61 | // The first underscores have to be masked to stop asciidoc interpreting them |
---|
[4c3433b] | 62 | to make use of generic FreeBSD based drivers. |
---|
| 63 | |
---|
[da96928] | 64 | The linker command file of the BSP must contain the following section |
---|
| 65 | definitions: |
---|
[4c3433b] | 66 | |
---|
| 67 | ------------------------------------------------------------------------------- |
---|
| 68 | .rtemsroset : { |
---|
| 69 | KEEP (*(SORT(.rtemsroset.*))) |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | .rtemsrwset : { |
---|
| 73 | KEEP (*(SORT(.rtemsrwset.*))) |
---|
| 74 | } |
---|
| 75 | ------------------------------------------------------------------------------- |
---|
| 76 | |
---|
[da96928] | 77 | The first output section can be placed in read-only memory. The second output |
---|
| 78 | section must be placed in read-write memory. The output section name is not |
---|
| 79 | relevant. The output sections may also contain other input sections. |
---|
[4c3433b] | 80 | |
---|
| 81 | === Board Support Package Configuration and Build === |
---|
| 82 | |
---|
| 83 | You need to configure RTEMS for the desired BSP and install it. The BSP should |
---|
| 84 | be configured with a disabled network stack. The BSD library containing the |
---|
| 85 | new network stack is a separate package. Using a BSP installation containing |
---|
| 86 | the old network stack may lead to confusion and unpredictable results. |
---|
| 87 | |
---|
| 88 | The following script is used to build the `arm/realview_pbx_a9_qemu` BSP for |
---|
| 89 | our internal testing purposes: |
---|
| 90 | |
---|
| 91 | ------------------------------------------------------------------------------- |
---|
| 92 | #!/bin/sh |
---|
| 93 | |
---|
| 94 | cd ${HOME}/sandbox |
---|
| 95 | rm -rf b-realview_pbx_a9_qemu |
---|
| 96 | mkdir b-realview_pbx_a9_qemu |
---|
| 97 | cd b-realview_pbx_a9_qemu |
---|
| 98 | ${HOME}/git-rtems/configure \ |
---|
| 99 | --prefix=${HOME}/sandbox/install \ |
---|
| 100 | --target=arm-rtems4.11 \ |
---|
| 101 | --enable-rtemsbsp=realview_pbx_a9_qemu \ |
---|
| 102 | --disable-networking && \ |
---|
| 103 | make && \ |
---|
| 104 | make install |
---|
| 105 | ------------------------------------------------------------------------------- |
---|
| 106 | |
---|
| 107 | The `arm/realview_pbx_a9_qemu` BSP running on the Qemu simulator has some |
---|
| 108 | benefits for development and test of the BSD library |
---|
| 109 | |
---|
| 110 | * it offers a NULL pointer read and write protection, |
---|
| 111 | * Qemu is a fast simulator, |
---|
| 112 | * Qemu provides support for GDB watchpoints, |
---|
| 113 | * Qemu provides support for virtual Ethernet networks, e.g. TUN and bridge |
---|
| 114 | devices (you can run multiple test instances on one virtual network). |
---|
| 115 | |
---|
| 116 | === BSD Library Configuration and Build === |
---|
| 117 | |
---|
[ead7fdc] | 118 | In the BSD library source directory edit the file `config.inc`. Continuing on |
---|
| 119 | the above, the `config.inc` used to match the above is: |
---|
[4c3433b] | 120 | |
---|
| 121 | ------------------------------------------------------------------------------- |
---|
| 122 | # Mandatory: Select your BSP and installation prefix |
---|
| 123 | TARGET = arm-rtems4.11 |
---|
| 124 | BSP = realview_pbx_a9_qemu |
---|
| 125 | PREFIX = $(HOME)/sandbox/install |
---|
| 126 | |
---|
| 127 | # Optional: Separate installation base directory |
---|
| 128 | INSTALL_BASE = $(PREFIX)/$(TARGET)/$(BSP) |
---|
| 129 | |
---|
| 130 | # Optional: Network test configuration |
---|
| 131 | TEST_RUNNER = $(BSP) |
---|
| 132 | NET_CFG_SELF_IP = 10.0.0.2 |
---|
| 133 | NET_CFG_NETMASK = 255.255.0.0 |
---|
| 134 | NET_CFG_PEER_IP = 10.0.0.1 |
---|
| 135 | NET_CFG_GATEWAY_IP = 10.0.0.1 |
---|
| 136 | NET_TAP_INTERFACE = tap0 |
---|
| 137 | ------------------------------------------------------------------------------- |
---|
| 138 | |
---|
| 139 | Now you can build the BSD library and run the tests: |
---|
| 140 | |
---|
| 141 | ------------------------------------------------------------------------------- |
---|
| 142 | make clean |
---|
| 143 | make |
---|
| 144 | make run_tests |
---|
| 145 | ------------------------------------------------------------------------------- |
---|
| 146 | |
---|
[14ba206] | 147 | You can only run the tests directly in case a test runner is available. The |
---|
| 148 | following tests run without an external network. It is strongly advised to run |
---|
| 149 | them. |
---|
| 150 | |
---|
| 151 | * commands01 |
---|
| 152 | * init01 |
---|
| 153 | * loopback01 |
---|
| 154 | * rwlock01 |
---|
| 155 | * selectpollkqueue01 |
---|
| 156 | * sleep01 |
---|
| 157 | * swi01 |
---|
| 158 | * syscalls01 |
---|
| 159 | * thread01 |
---|
| 160 | * timeout01 |
---|
| 161 | * unix01 |
---|
| 162 | |
---|
[4c3433b] | 163 | To install the BSD library use this: |
---|
| 164 | |
---|
| 165 | ------------------------------------------------------------------------------- |
---|
| 166 | make install |
---|
| 167 | ------------------------------------------------------------------------------- |
---|
| 168 | |
---|
| 169 | === BSD Library Initialization === |
---|
| 170 | |
---|
| 171 | Use the following code to initialize the BSD library: |
---|
| 172 | |
---|
| 173 | ------------------------------------------------------------------------------- |
---|
| 174 | #include <assert.h> |
---|
[ead7fdc] | 175 | #include <sysexits.h> |
---|
[4c3433b] | 176 | |
---|
[ead7fdc] | 177 | #include <machine/rtems-bsd-commands.h> |
---|
[4c3433b] | 178 | #include <rtems/bsd/bsd.h> |
---|
| 179 | |
---|
[ead7fdc] | 180 | static void |
---|
| 181 | network_ifconfig_lo0(void) |
---|
[4c3433b] | 182 | { |
---|
[ead7fdc] | 183 | int exit_code; |
---|
| 184 | char *lo0[] = { |
---|
| 185 | "ifconfig", |
---|
| 186 | "lo0", |
---|
| 187 | "inet", |
---|
| 188 | "127.0.0.1", |
---|
| 189 | "netmask", |
---|
| 190 | "255.255.255.0", |
---|
| 191 | NULL |
---|
| 192 | }; |
---|
| 193 | char *lo0_inet6[] = { |
---|
| 194 | "ifconfig", |
---|
| 195 | "lo0", |
---|
| 196 | "inet6", |
---|
| 197 | "::1", |
---|
| 198 | "prefixlen", |
---|
| 199 | "128", |
---|
| 200 | NULL |
---|
| 201 | }; |
---|
| 202 | |
---|
| 203 | exit_code = rtems_bsd_command_ifconfig(RTEMS_BSD_ARGC(lo0), lo0); |
---|
| 204 | assert(exit_code == EX_OK); |
---|
| 205 | |
---|
| 206 | exit_code = rtems_bsd_command_ifconfig(RTEMS_BSD_ARGC(lo0_inet6), lo0_inet6); |
---|
| 207 | assert(exit_code == EX_OK); |
---|
| 208 | } |
---|
| 209 | |
---|
| 210 | void |
---|
| 211 | network_init(void) |
---|
| 212 | { |
---|
| 213 | rtems_status_code sc; |
---|
[4c3433b] | 214 | |
---|
[ead7fdc] | 215 | sc = rtems_bsd_initialize(); |
---|
| 216 | assert(sc == RTEMS_SUCCESSFUL); |
---|
| 217 | |
---|
| 218 | network_ifconfig_lo0(); |
---|
[4c3433b] | 219 | } |
---|
| 220 | ------------------------------------------------------------------------------- |
---|
| 221 | |
---|
[ead7fdc] | 222 | This performs the basic network stack initialization with a loopback interface. |
---|
| 223 | Further initialization must be done using the standard BSD network |
---|
| 224 | configuration commands |
---|
| 225 | http://www.freebsd.org/cgi/man.cgi?query=ifconfig&apropos=0&sektion=8&manpath=FreeBSD+9.2-RELEASE&arch=default&format=html[IFCONFIG(8)] |
---|
| 226 | using `rtems_bsd_command_ifconfig()` and |
---|
| 227 | http://www.freebsd.org/cgi/man.cgi?query=route&apropos=0&sektion=8&manpath=FreeBSD+9.2-RELEASE&arch=default&format=html[ROUTE(8)] |
---|
| 228 | using `rtems_bsd_command_route()`. For an example please have a look at |
---|
| 229 | `testsuite/include/rtems/bsd/test/default-network-init.h`. |
---|
| 230 | |
---|
[4c3433b] | 231 | == Network Stack Features |
---|
| 232 | |
---|
| 233 | http://roy.marples.name/projects/dhcpcd/index[DHCPCD(8)]:: DHCP client |
---|
| 234 | |
---|
| 235 | https://developer.apple.com/library/mac/documentation/Networking/Reference/DNSServiceDiscovery_CRef/Reference/reference.html[dns_sd.h]:: DNS Service Discovery |
---|
| 236 | |
---|
| 237 | http://www.opensource.apple.com/source/mDNSResponder/mDNSResponder-320.10/mDNSCore/mDNSEmbeddedAPI.h[mDNS]:: Multi-Cast DNS |
---|
| 238 | |
---|
| 239 | http://www.freebsd.org/cgi/man.cgi?query=unix&sektion=4&apropos=0&manpath=FreeBSD+9.2-RELEASE[UNIX(4)]:: UNIX-domain protocol family |
---|
| 240 | |
---|
| 241 | http://www.freebsd.org/cgi/man.cgi?query=inet&sektion=4&apropos=0&manpath=FreeBSD+9.2-RELEASE[INET(4)]:: Internet protocol family |
---|
| 242 | |
---|
| 243 | 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 |
---|
| 244 | |
---|
| 245 | 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 |
---|
| 246 | |
---|
| 247 | 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 |
---|
| 248 | |
---|
| 249 | http://www.freebsd.org/cgi/man.cgi?query=route&sektion=4&apropos=0&manpath=FreeBSD+9.2-RELEASE[ROUTE(4)]:: Kernel packet forwarding database |
---|
| 250 | |
---|
| 251 | 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 |
---|
| 252 | |
---|
| 253 | 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 |
---|
| 254 | |
---|
| 255 | 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 |
---|
| 256 | |
---|
| 257 | 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 |
---|
| 258 | |
---|
| 259 | 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 |
---|
| 260 | |
---|
| 261 | 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 |
---|
| 262 | |
---|
| 263 | 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 |
---|
| 264 | |
---|
| 265 | 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 |
---|
| 266 | |
---|
| 267 | 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 |
---|
| 268 | |
---|
| 269 | 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 |
---|
| 270 | |
---|
| 271 | 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 |
---|
| 272 | |
---|
| 273 | http://www.freebsd.org/cgi/man.cgi?query=resolver&sektion=3&apropos=0&manpath=FreeBSD+9.2-RELEASE[RESOLVER(3)]:: Resolver routines |
---|
| 274 | |
---|
| 275 | http://www.freebsd.org/cgi/man.cgi?query=gethostbyname&sektion=3&apropos=0&manpath=FreeBSD+9.2-RELEASE[GETHOSTBYNAME(3)]:: Get network host entry |
---|
| 276 | |
---|
[43dc972] | 277 | == Network Interface Drivers |
---|
| 278 | |
---|
| 279 | === Link Up/Down Events |
---|
| 280 | |
---|
| 281 | You can notifiy the application space of link up/down events in your network |
---|
| 282 | interface driver via the if_link_state_change(LINK_STATE_UP/LINK_STATE_DOWN) |
---|
| 283 | function. The DHCPCD(8) client is a consumer of these events for example. |
---|
| 284 | Make sure that the interface flag IFF_UP and the interface driver flag |
---|
| 285 | IFF_DRV_RUNNING is set in case the link is up, otherwise ether_output() will |
---|
| 286 | return the error status ENETDOWN. |
---|
| 287 | |
---|
[4c3433b] | 288 | == Issues and TODO |
---|
[e392fdb7] | 289 | |
---|
[d652c3b] | 290 | * Per-CPU data should be enabled once the new stack is ready for SMP. |
---|
| 291 | |
---|
| 292 | * Per-CPU NETISR(9) should be enabled onece the new stack is ready for SMP. |
---|
| 293 | |
---|
[549488b] | 294 | * Multiple routing tables are not supported. Every FIB value is set to zero |
---|
| 295 | (= BSD_DEFAULT_FIB). |
---|
| 296 | |
---|
[cc5f4b2] | 297 | * Process identifiers are not supported. Every PID value is set to zero |
---|
| 298 | (= BSD_DEFAULT_PID). |
---|
| 299 | |
---|
[69b29a0] | 300 | * User credentials are not supported. The following functions allow the |
---|
| 301 | operation for everyone |
---|
| 302 | - prison_equal_ip4(), |
---|
| 303 | - chgsbsize(), |
---|
| 304 | - cr_cansee(), |
---|
| 305 | - cr_canseesocket() and |
---|
| 306 | - cr_canseeinpcb(). |
---|
| 307 | |
---|
[4c3433b] | 308 | * A basic USB functionality test that is known to work on Qemu is desirable. |
---|
[560eccf] | 309 | |
---|
[8f5adbc] | 310 | * Adapt generic IRQ PIC interface code to Simple Vectored Interrupt Model |
---|
| 311 | so that those architectures can use new TCP/IP and USB code. |
---|
[560eccf] | 312 | |
---|
[78e3181] | 313 | * freebsd-userspace/rtems/include/sys/syslog.h is a copy from the old |
---|
| 314 | RTEMS TCP/IP stack. For some reason, the __printflike markers do not |
---|
| 315 | compile in this environment. We may want to use the FreeBSD syslog.h |
---|
| 316 | and get this addressed. |
---|
| 317 | |
---|
[8f5adbc] | 318 | * in_cksum implementations for architectures not supported by FreeBSD. |
---|
| 319 | This will require figuring out where to put implementations that do |
---|
| 320 | not originate from FreeBSD and are populated via the script. |
---|
[560eccf] | 321 | |
---|
[cdf6024] | 322 | * MAC support functions are not thread-safe ("freebsd/lib/libc/posix1e/mac.c"). |
---|
| 323 | |
---|
[c14bb23] | 324 | * IFCONFIG(8): IEEE80211 support is disabled. This module depends on a XML |
---|
| 325 | parser and mmap(). |
---|
| 326 | |
---|
[1bc2756] | 327 | * get_cyclecount(): The implementation is a security problem. |
---|
| 328 | |
---|
[e859231] | 329 | * What to do with the priority parameter present in the FreeBSD synchronization |
---|
[ea87228] | 330 | primitives and the thread creation functions? |
---|
| 331 | |
---|
| 332 | * TASKQUEUE(9): Support spin mutexes. |
---|
[e859231] | 333 | |
---|
[3e29388] | 334 | * ZONE(9): Review allocator lock usage in rtems-bsd-chunk.c. |
---|
| 335 | |
---|
[0c9f27b] | 336 | * KQUEUE(2): Choose proper lock for global kqueue list. |
---|
| 337 | |
---|
[a9e26f5] | 338 | * TIMEOUT(9): Maybe use special task instead of timer server to call |
---|
| 339 | callout_tick(). |
---|
| 340 | |
---|
[c99816e] | 341 | * sysctl_handle_opaque(): Implement reliable snapshots. |
---|
| 342 | |
---|
[cae4d0a] | 343 | * PING6(8): What to do with SIGALARM? |
---|
| 344 | |
---|
[241fc32] | 345 | * <sys/param.h>: Update Newlib to use a MSIZE of 256. |
---|
| 346 | |
---|
[e10d1cd] | 347 | * BPF(4): Add support for zero-copy buffers. |
---|
| 348 | |
---|
[164c5f5] | 349 | * UNIX(4): Fix race conditions in the area of socket object and file node |
---|
| 350 | destruction. Add support for file descriptor transmission via control |
---|
| 351 | messages. |
---|
| 352 | |
---|
[08c8588] | 353 | * PRINTF(9): Add support for log(), the %D format specifier is missing in the |
---|
| 354 | normal printf() family. |
---|
| 355 | |
---|
[362782e] | 356 | * Why is the interrupt server used? The BSD interrupt handlers can block on |
---|
| 357 | synchronization primitives like mutexes. This is in contrast to RTEMS |
---|
| 358 | interrupt service routines. The BSPs using the generic interrupt support must |
---|
| 359 | implement the `bsp_interrupt_vector_enable()` and |
---|
| 360 | `bsp_interrupt_vector_disable()` routines. They normally enable/disable a |
---|
| 361 | particular interrupt source at the interrupt controller. This can be used to |
---|
| 362 | implement the interrupt server. The interrupt server is a task that wakes-up |
---|
| 363 | in case an associated interrupt happens. The interrupt source is disabled in |
---|
| 364 | a generic interrupt handler that wakes-up the interrupt server task. Once the |
---|
| 365 | postponed interrupt processing is performed in the interrupt server the |
---|
| 366 | interrupt source is enabled again. |
---|
| 367 | |
---|
[560eccf] | 368 | * Convert all BSP linkcmds to use a linkcmds.base so the sections are |
---|
| 369 | easier to insert. |
---|
| 370 | |
---|
[86bc9a7] | 371 | * NIC Device Drivers |
---|
[78e3181] | 372 | - Only common PCI NIC drivers have been included in the initial set. These |
---|
| 373 | do not include any system on chip or ISA drivers. |
---|
| 374 | - PCI configuration probe does not appear to happen to determine if a |
---|
| 375 | NIC is in I/O or memory space. We have worked around this by using a |
---|
| 376 | static hint to tell the fxp driver the correct mode. But this needs to |
---|
| 377 | be addressed. |
---|
[86bc9a7] | 378 | - The ISA drivers require more BSD infrastructure to be addressed. This was |
---|
| 379 | outside the scope of the initial porting effort. |
---|
| 380 | |
---|
[8f5adbc] | 381 | == FreeBSD Source |
---|
| 382 | |
---|
| 383 | You should be able to rely on FreebSD manual pages and documentation |
---|
| 384 | for details on the code itself. |
---|
| 385 | |
---|
| 386 | === Automatically Generated FreeBSD Files |
---|
| 387 | |
---|
[4c3433b] | 388 | Some source and header files are automatically generated during the FreeBSD |
---|
| 389 | build process. The `Makefile.todo` file performs this manually. The should be |
---|
| 390 | included in `freebsd-to-rtems.py` script some time in the future. For details, |
---|
| 391 | see also |
---|
| 392 | http://www.freebsd.org/cgi/man.cgi?query=kobj&sektion=9&apropos=0&manpath=FreeBSD+9.2-RELEASE[KOBJ(9)]. |
---|
[8f5adbc] | 393 | |
---|
| 394 | === Rules for Modifying FreeBSD Source |
---|
| 395 | |
---|
[4c3433b] | 396 | Only add lines. Subtract code by added `#ifndef __rtems__`. This makes |
---|
| 397 | merging easier in the future. For example: |
---|
[8f5adbc] | 398 | |
---|
[4c3433b] | 399 | ------------------------------------------------------------------------------- |
---|
| 400 | /* Global variables for the kernel. */ |
---|
[8f5adbc] | 401 | |
---|
[4c3433b] | 402 | #ifndef __rtems__ |
---|
| 403 | /* 1.1 */ |
---|
| 404 | extern char kernelname[MAXPATHLEN]; |
---|
| 405 | #endif /* __rtems__ */ |
---|
[8f5adbc] | 406 | |
---|
[4c3433b] | 407 | extern int tick; /* usec per tick (1000000 / hz) */ |
---|
| 408 | ------------------------------------------------------------------------------- |
---|
[560eccf] | 409 | |
---|
[4c3433b] | 410 | ------------------------------------------------------------------------------- |
---|
| 411 | #if defined(_KERNEL) || defined(_WANT_FILE) |
---|
| 412 | #ifdef __rtems__ |
---|
| 413 | #include <rtems/libio_.h> |
---|
| 414 | #include <sys/fcntl.h> |
---|
| 415 | #endif /* __rtems__ */ |
---|
| 416 | /* |
---|
| 417 | * Kernel descriptor table. |
---|
| 418 | * One entry for each open kernel vnode and socket. |
---|
| 419 | * |
---|
| 420 | * Below is the list of locks that protects members in struct file. |
---|
| 421 | * |
---|
| 422 | * (f) protected with mtx_lock(mtx_pool_find(fp)) |
---|
| 423 | * (d) cdevpriv_mtx |
---|
| 424 | * none not locked |
---|
| 425 | */ |
---|
| 426 | ------------------------------------------------------------------------------- |
---|
| 427 | |
---|
| 428 | ------------------------------------------------------------------------------- |
---|
| 429 | extern int profprocs; /* number of process's profiling */ |
---|
| 430 | #ifndef __rtems__ |
---|
| 431 | extern volatile int ticks; |
---|
| 432 | #else /* __rtems__ */ |
---|
| 433 | #include <rtems/score/watchdogimpl.h> |
---|
| 434 | #define ticks _Watchdog_Ticks_since_boot |
---|
| 435 | #endif /* __rtems__ */ |
---|
[8f5adbc] | 436 | |
---|
[4c3433b] | 437 | #endif /* _KERNEL */ |
---|
| 438 | ------------------------------------------------------------------------------- |
---|
[455aa3a] | 439 | |
---|
[4c3433b] | 440 | Add nothing (even blank lines) before or after the `__rtems__` guards. Always |
---|
| 441 | include a `__rtems__` in the guards to make searches easy. |
---|
[455aa3a] | 442 | |
---|
[4c3433b] | 443 | == BSD Library Source |
---|
[455aa3a] | 444 | |
---|
[4c3433b] | 445 | === What is in the Git Repository |
---|
[455aa3a] | 446 | |
---|
[4c3433b] | 447 | There is a self-contained kit with FreeBSD and RTEMS components pre-merged. The |
---|
| 448 | Makefile in this kit is automatically generated. |
---|
[8f5adbc] | 449 | |
---|
[4c3433b] | 450 | Any changes to source in the `freebsd` directories will need to be merged |
---|
| 451 | upstream into our master FreeBSD checkout, the `freebsd-org` submodule. |
---|
[8f5adbc] | 452 | |
---|
[4c3433b] | 453 | The repository contains two FreeBSD source trees. In the `freebsd` directory |
---|
| 454 | are the so called 'managed' FreeBSD sources used to build the BSD library. The |
---|
| 455 | FreeBSD source in `freebsd-org` is the 'master' version. The |
---|
| 456 | `freebsd-to-rtems.py` script is used to transfer files between the two trees. |
---|
| 457 | In general terms, if you have modified managed FreeBSD sources, you will need |
---|
| 458 | to run the script in 'revert' or 'reverse' mode using the `-R` switch. This |
---|
| 459 | will copy the source back to your local copy of the master FreeBSD source so |
---|
| 460 | you can run `git diff` against the upstream FreeBSD source. If you want to |
---|
| 461 | transfer source files from the master FreeBSD source to the manged FreeBSD |
---|
| 462 | sources, then you must run the script in 'forward' mode (the default). |
---|
[8f5adbc] | 463 | |
---|
| 464 | === Organization |
---|
| 465 | |
---|
| 466 | The top level directory contains a few directories and files. The following |
---|
[4c3433b] | 467 | are important to understand |
---|
[8f5adbc] | 468 | |
---|
[4c3433b] | 469 | * `freebsd-to-rtems.py` - script to convert to and free FreeBSD and RTEMS trees, |
---|
| 470 | * `Makefile` - automatically generated, |
---|
| 471 | * `freebsd/` - from FreeBSD by script, |
---|
| 472 | * `rtemsbsd/` - RTEMS specific implementations of FreeBSD kernel support routines, |
---|
| 473 | * `testsuite/` - RTEMS specific tests, and |
---|
| 474 | * `libbsd.txt` - documentation in Asciidoc. |
---|
[8f5adbc] | 475 | |
---|
[4c3433b] | 476 | == Moving Code Between Managed and Master FreeBSD Source |
---|
[e392fdb7] | 477 | |
---|
[4c3433b] | 478 | The script `freebsd-to-rtems.py` is used to copy code from FreeBSD to the |
---|
[c90c212] | 479 | rtems-libbsd tree and to reverse this process. This script attempts to |
---|
[e392fdb7] | 480 | automate this process as much as possible and performs some transformations |
---|
| 481 | on the FreeBSD code. Its command line arguments are shown below: |
---|
| 482 | |
---|
| 483 | ---- |
---|
| 484 | freebsd-to-rtems.py [args] |
---|
| 485 | -?|-h|--help print this and exit |
---|
| 486 | -d|--dry-run run program but no modifications |
---|
[7326d96] | 487 | -D|--diff provide diff of files between trees |
---|
[e392fdb7] | 488 | -e|--early-exit evaluate arguments, print results, and exit |
---|
| 489 | -m|--makefile just generate Makefile |
---|
| 490 | -R|--reverse default FreeBSD -> RTEMS, reverse that |
---|
| 491 | -r|--rtems RTEMS directory |
---|
| 492 | -f|--freebsd FreeBSD directory |
---|
| 493 | -v|--verbose enable verbose output mode |
---|
| 494 | ---- |
---|
| 495 | |
---|
| 496 | In its default mode of operation, freebsd-to-rtems.py is used to copy code |
---|
[c90c212] | 497 | from FreeBSD to the rtems-libbsd tree and perform transformations. In forward |
---|
[e392fdb7] | 498 | mode, the script may be requested to just generate the Makefile. |
---|
| 499 | |
---|
| 500 | In "reverse mode", this script undoes those transformations and copies |
---|
| 501 | the source code back to the FreeBSD SVN tree. This allows us to do |
---|
| 502 | 'svn diff', evaluate changes made by the RTEMS Project, and report changes |
---|
| 503 | back to FreeBSD upstream. |
---|
| 504 | |
---|
| 505 | In either mode, the script may be asked to perform a dry-run or be verbose. |
---|
| 506 | Also, in either mode, the script is also smart enough to avoid copying over |
---|
| 507 | files which have not changed. This means that the timestamps of files are |
---|
| 508 | not changed unless the contents change. The script will also report the |
---|
| 509 | number of files which changed. In verbose mode, the script will print |
---|
| 510 | the name of the files which are changed. |
---|
| 511 | |
---|
| 512 | The following is an example forward run with no changes. |
---|
| 513 | |
---|
| 514 | ---- |
---|
| 515 | $ ~/newbsd/git/libbsd-8.2/freebsd-to-rtems.py \ |
---|
| 516 | -r /home/joel/newbsd/git/libbsd-8.2 \ |
---|
| 517 | -f /home/joel/newbsd/libbsd/freebsd-8.2 -v |
---|
| 518 | Verbose: yes |
---|
| 519 | Dry Run: no |
---|
| 520 | Only Generate Makefile: no |
---|
| 521 | RTEMS Directory: /home/joel/newbsd/git/libbsd-8.2 |
---|
| 522 | FreeBSD Directory: /home/joel/newbsd/libbsd/freebsd-8.2 |
---|
| 523 | Direction: forward |
---|
| 524 | Generating into /home/joel/newbsd/git/libbsd-8.2 |
---|
| 525 | 0 files were changed. |
---|
| 526 | ---- |
---|
| 527 | |
---|
[7326d96] | 528 | The script may also be used to generate a diff in either forward or reverse |
---|
| 529 | direction. |
---|
| 530 | |
---|
[4c3433b] | 531 | == Initialization of the BSD Library |
---|
[455aa3a] | 532 | |
---|
[4c3433b] | 533 | The initialization of the BSD library is based on the FreeBSD SYSINIT(9) |
---|
[8a4f070] | 534 | infrastructure. The key to initializing a system is to ensure that the desired |
---|
| 535 | device drivers are explicitly pulled into the linked application. This plus |
---|
[4c3433b] | 536 | linking against the BSD library (`libbsd.a`) will pull in the necessary FreeBSD |
---|
[8a4f070] | 537 | infrastructure. |
---|
[455aa3a] | 538 | |
---|
[8a4f070] | 539 | The FreeBSD kernel is not a library like the RTEMS kernel. It is a bunch of |
---|
| 540 | object files linked together. If we have a library, then creating the |
---|
| 541 | executable is simple. We begin with a start symbol and recursively resolve all |
---|
| 542 | references. With a bunch of object files linked together we need a different |
---|
| 543 | mechanism. Most object files don't know each other. Lets say we have a driver |
---|
| 544 | module. The rest of the system has no references to this driver module. The |
---|
| 545 | driver module needs a way to tell the rest of the system: Hey, kernel I am |
---|
| 546 | here, please use my services! |
---|
[455aa3a] | 547 | |
---|
[8a4f070] | 548 | This registration of independent components is performed by SYSINIT(9) and |
---|
| 549 | specializations: |
---|
| 550 | |
---|
| 551 | http://www.freebsd.org/cgi/man.cgi?query=SYSINIT |
---|
| 552 | |
---|
| 553 | The SYSINIT(9) uses some global data structures that are placed in a certain |
---|
| 554 | section. In the linker command file we need this: |
---|
| 555 | |
---|
[4c3433b] | 556 | ------------------------------------------------------------------------------- |
---|
| 557 | .rtemsroset : { |
---|
| 558 | KEEP (*(SORT(.rtemsroset.*))) |
---|
| 559 | } |
---|
| 560 | |
---|
| 561 | .rtemsrwset : { |
---|
| 562 | KEEP (*(SORT(.rtemsrwset.*))) |
---|
| 563 | } |
---|
| 564 | ------------------------------------------------------------------------------- |
---|
| 565 | |
---|
| 566 | This results for example in this executable layout: |
---|
| 567 | |
---|
| 568 | ------------------------------------------------------------------------------- |
---|
| 569 | [...] |
---|
| 570 | *(SORT(.rtemsroset.*)) |
---|
| 571 | .rtemsroset.bsd.modmetadata_set.begin |
---|
| 572 | 0x000000000025fe00 0x0 libbsd.a(rtems-bsd-init.o) |
---|
| 573 | 0x000000000025fe00 _bsd__start_set_modmetadata_set |
---|
| 574 | .rtemsroset.bsd.modmetadata_set.content |
---|
| 575 | 0x000000000025fe00 0x8 libbsd.a(rtems-bsd-nexus.o) |
---|
| 576 | .rtemsroset.bsd.modmetadata_set.content |
---|
| 577 | 0x000000000025fe08 0x4 libbsd.a(kern_module.o) |
---|
| 578 | [...] |
---|
| 579 | .rtemsroset.bsd.modmetadata_set.content |
---|
| 580 | 0x000000000025fe68 0x4 libbsd.a(mii.o) |
---|
| 581 | .rtemsroset.bsd.modmetadata_set.content |
---|
| 582 | 0x000000000025fe6c 0x4 libbsd.a(mii_bitbang.o) |
---|
| 583 | .rtemsroset.bsd.modmetadata_set.end |
---|
| 584 | 0x000000000025fe70 0x0 libbsd.a(rtems-bsd-init.o) |
---|
| 585 | 0x000000000025fe70 _bsd__stop_set_modmetadata_set |
---|
| 586 | [...] |
---|
| 587 | .rtemsrwset 0x000000000030bad0 0x290 |
---|
| 588 | *(SORT(.rtemsrwset.*)) |
---|
| 589 | .rtemsrwset.bsd.sysinit_set.begin |
---|
| 590 | 0x000000000030bad0 0x0 libbsd.a(rtems-bsd-init.o) |
---|
| 591 | 0x000000000030bad0 _bsd__start_set_sysinit_set |
---|
| 592 | .rtemsrwset.bsd.sysinit_set.content |
---|
| 593 | 0x000000000030bad0 0x4 libbsd.a(rtems-bsd-nexus.o) |
---|
| 594 | .rtemsrwset.bsd.sysinit_set.content |
---|
| 595 | 0x000000000030bad4 0x8 libbsd.a(rtems-bsd-thread.o) |
---|
| 596 | .rtemsrwset.bsd.sysinit_set.content |
---|
| 597 | 0x000000000030badc 0x4 libbsd.a(init_main.o) |
---|
| 598 | [...] |
---|
| 599 | .rtemsrwset.bsd.sysinit_set.content |
---|
| 600 | 0x000000000030bd54 0x4 libbsd.a(frag6.o) |
---|
| 601 | .rtemsrwset.bsd.sysinit_set.content |
---|
| 602 | 0x000000000030bd58 0x8 libbsd.a(uipc_accf.o) |
---|
| 603 | .rtemsrwset.bsd.sysinit_set.end |
---|
| 604 | 0x000000000030bd60 0x0 libbsd.a(rtems-bsd-init.o) |
---|
| 605 | 0x000000000030bd60 _bsd__stop_set_sysinit_set |
---|
| 606 | [...] |
---|
| 607 | ------------------------------------------------------------------------------- |
---|
| 608 | |
---|
| 609 | Here you can see, that some global data structures are collected into |
---|
[8a4f070] | 610 | continuous memory areas. This memory area can be identified by start and stop |
---|
| 611 | symbols. This constructs a table of uniform items. |
---|
| 612 | |
---|
| 613 | The low level FreeBSD code calls at some time during the initialization the |
---|
| 614 | mi_startup() function (machine independent startup). This function will sort |
---|
| 615 | the SYSINIT(9) set and call handler functions which perform further |
---|
| 616 | initialization. The last step is the scheduler invocation. |
---|
| 617 | |
---|
| 618 | The SYSINIT(9) routines are run in mi_startup() which is called by |
---|
| 619 | rtems_bsd_initialize(). |
---|
| 620 | |
---|
| 621 | This is also explained in "The Design and Implementation of the FreeBSD |
---|
| 622 | Operating System" section 14.3 "Kernel Initialization". |
---|
| 623 | |
---|
| 624 | In RTEMS we have a library and not a bunch of object files. Thus we need a way |
---|
| 625 | to pull-in the desired services out of the libbsd. Here the |
---|
[4c3433b] | 626 | `rtems-bsd-sysinit.h` comes into play. The SYSINIT(9) macros have been |
---|
| 627 | modified and extended for RTEMS in `<sys/kernel.h>`: |
---|
[8a4f070] | 628 | |
---|
[4c3433b] | 629 | ------------------------------------------------------------------------------- |
---|
[8a4f070] | 630 | #ifndef __rtems__ |
---|
[4c3433b] | 631 | #define C_SYSINIT(uniquifier, subsystem, order, func, ident) \ |
---|
| 632 | static struct sysinit uniquifier ## _sys_init = { \ |
---|
| 633 | subsystem, \ |
---|
| 634 | order, \ |
---|
| 635 | func, \ |
---|
| 636 | (ident) \ |
---|
| 637 | }; \ |
---|
| 638 | DATA_SET(sysinit_set,uniquifier ## _sys_init) |
---|
[8a4f070] | 639 | #else /* __rtems__ */ |
---|
[4c3433b] | 640 | #define SYSINIT_ENTRY_NAME(uniquifier) \ |
---|
| 641 | _bsd_ ## uniquifier ## _sys_init |
---|
| 642 | #define SYSINIT_REFERENCE_NAME(uniquifier) \ |
---|
| 643 | _bsd_ ## uniquifier ## _sys_init_ref |
---|
| 644 | #define C_SYSINIT(uniquifier, subsystem, order, func, ident) \ |
---|
| 645 | struct sysinit SYSINIT_ENTRY_NAME(uniquifier) = { \ |
---|
| 646 | subsystem, \ |
---|
| 647 | order, \ |
---|
| 648 | func, \ |
---|
| 649 | (ident) \ |
---|
| 650 | }; \ |
---|
| 651 | RWDATA_SET(sysinit_set,SYSINIT_ENTRY_NAME(uniquifier)) |
---|
| 652 | #define SYSINIT_REFERENCE(uniquifier) \ |
---|
| 653 | extern struct sysinit SYSINIT_ENTRY_NAME(uniquifier); \ |
---|
| 654 | static struct sysinit const * const \ |
---|
| 655 | SYSINIT_REFERENCE_NAME(uniquifier) __used \ |
---|
| 656 | = &SYSINIT_ENTRY_NAME(uniquifier) |
---|
| 657 | #define SYSINIT_MODULE_REFERENCE(mod) \ |
---|
| 658 | SYSINIT_REFERENCE(mod ## module) |
---|
| 659 | #define SYSINIT_DRIVER_REFERENCE(driver, bus) \ |
---|
| 660 | SYSINIT_MODULE_REFERENCE(driver ## _ ## bus) |
---|
| 661 | #define SYSINIT_DOMAIN_REFERENCE(dom) \ |
---|
| 662 | SYSINIT_REFERENCE(domain_add_ ## dom) |
---|
[8a4f070] | 663 | #endif /* __rtems__ */ |
---|
[4c3433b] | 664 | ------------------------------------------------------------------------------- |
---|
[8a4f070] | 665 | |
---|
| 666 | Here you see that the SYSINIT(9) entries are no longer static. The |
---|
[4c3433b] | 667 | \*_REFERENCE() macros will create references to the corresponding modules which |
---|
[8a4f070] | 668 | are later resolved by the linker. The application has to provide an object |
---|
| 669 | file with references to all required FreeBSD modules. |
---|
| 670 | |
---|
| 671 | The FreeBSD device model is quite elaborated (with follow-ups): |
---|
| 672 | |
---|
| 673 | http://www.freebsd.org/cgi/man.cgi?query=driver |
---|
| 674 | |
---|
| 675 | The devices form a tree with the Nexus device at a high-level. This Nexus |
---|
| 676 | device is architecture specific in FreeBSD. In RTEMS we have our own Nexus |
---|
[4c3433b] | 677 | device, see `rtemsbsd/bsp/bsp-bsd-nexus-devices.c`. |
---|
[00ee241] | 678 | |
---|
| 679 | === SYSCTL_NODE Example |
---|
| 680 | |
---|
| 681 | During development, we had an undefined reference to |
---|
| 682 | _bsd_sysctl__net_children that we had trouble tracking down. Thanks to |
---|
| 683 | Chris Johns, we located it. He explained how to read SYSCTL_NODE |
---|
| 684 | definitions. This line from freebsd/netinet/in_proto.c is attempting |
---|
| 685 | to add the "inet" node to the parent node "_net". |
---|
| 686 | |
---|
| 687 | ---- |
---|
| 688 | SYSCTL_NODE(_net, PF_INET, inet, CTLFLAG_RW, 0, |
---|
| 689 | "Internet Family"); |
---|
| 690 | ---- |
---|
| 691 | |
---|
| 692 | Our problem was that we could not find where _bsd_sysctl__net_children |
---|
| 693 | was defined. Chris suggested that when in doubt compile with -save-temps |
---|
| 694 | and look at the preprocessed .i files. But he did not need that. He |
---|
| 695 | explained that this the symbol name _bsd_sysctl__net_children was |
---|
| 696 | automatically generated by a SYSCTL_NODE as follows: |
---|
| 697 | |
---|
| 698 | * _bsd_ - added by RTEMS modifications to SYSCTL_NODE macro |
---|
| 699 | * sysctl_ - boilerplace added by SYSCTL_NODE macro |
---|
| 700 | * "" - empty string for parent node |
---|
| 701 | * net - name of SYSCTL_NODE |
---|
| 702 | * children - added by SYSCTL macros |
---|
| 703 | |
---|
| 704 | This was all generated by a support macro declaring the node as this: |
---|
| 705 | |
---|
| 706 | ---- |
---|
| 707 | struct sysctl_oid_list SYSCTL_NODE_CHILDREN(parent, name); |
---|
| 708 | ---- |
---|
| 709 | |
---|
| 710 | Given this information, we located this SYSCTL_NODE declaration in |
---|
| 711 | kern/kern_mib.c |
---|
| 712 | |
---|
| 713 | ---- |
---|
| 714 | SYSCTL_NODE(, CTL_KERN, kern, CTLFLAG_RW, 0, |
---|
| 715 | "High kernel, proc, limits &c"); |
---|
| 716 | ---- |
---|
| 717 | |
---|
[c03e095] | 718 | == Core FreeBSD APIs and RTEMS Replacements == |
---|
| 719 | |
---|
| 720 | === SX(9) (Shared/exclusive locks) === |
---|
| 721 | |
---|
| 722 | http://www.freebsd.org/cgi/man.cgi?query=sx |
---|
| 723 | |
---|
| 724 | Binary semaphores (this neglects the ability to allow shared access). |
---|
| 725 | |
---|
| 726 | === MUTEX(9) (Mutual exclusion) === |
---|
| 727 | |
---|
| 728 | http://www.freebsd.org/cgi/man.cgi?query=mutex |
---|
| 729 | |
---|
| 730 | Binary semaphores (not recursive mutexes are not supported this way). |
---|
| 731 | |
---|
| 732 | === RWLOCK(9) (Reader/writer lock) === |
---|
| 733 | |
---|
| 734 | http://www.freebsd.org/cgi/man.cgi?query=rwlock |
---|
| 735 | |
---|
| 736 | POSIX r/w lock. |
---|
| 737 | |
---|
| 738 | === RMLOCK(9) (Reader/writer lock optimized for mostly read access patterns) === |
---|
| 739 | |
---|
[5ab1e1d] | 740 | Note: This object was implemented as a wrapper for RWLOCK in the rm_lock header file. |
---|
| 741 | |
---|
[c03e095] | 742 | http://www.freebsd.org/cgi/man.cgi?query=rmlock |
---|
| 743 | |
---|
| 744 | POSIX r/w lock. |
---|
| 745 | |
---|
| 746 | === CONDVAR(9) (Condition variables) === |
---|
| 747 | |
---|
| 748 | http://www.freebsd.org/cgi/man.cgi?query=condvar |
---|
| 749 | |
---|
| 750 | POSIX condition variables with modifications (hack). |
---|
| 751 | |
---|
| 752 | === CALLOUT(9) (Timer functions) === |
---|
| 753 | |
---|
| 754 | http://www.freebsd.org/cgi/man.cgi?query=callout |
---|
| 755 | |
---|
| 756 | Timer server. |
---|
| 757 | |
---|
| 758 | === TASKQUEUE(9) (Asynchronous task execution) === |
---|
| 759 | |
---|
| 760 | http://www.freebsd.org/cgi/man.cgi?query=taskqueue |
---|
| 761 | |
---|
| 762 | TBD. |
---|
| 763 | |
---|
| 764 | === KTHREAD(9), KPROC(9) (Tasks) === |
---|
| 765 | |
---|
| 766 | http://www.freebsd.org/cgi/man.cgi?query=kthread |
---|
| 767 | |
---|
| 768 | http://www.freebsd.org/cgi/man.cgi?query=kproc |
---|
| 769 | |
---|
| 770 | Tasks. |
---|
| 771 | |
---|
| 772 | === ZONE(9) (Zone allocator) === |
---|
| 773 | |
---|
| 774 | http://www.freebsd.org/cgi/man.cgi?query=zone |
---|
| 775 | |
---|
| 776 | TBD. |
---|
| 777 | |
---|
| 778 | === devfs (Device file system) === |
---|
| 779 | |
---|
| 780 | Dummy, IMFS or new implementation (currently dummy). |
---|
| 781 | |
---|
| 782 | === psignal (Signals) === |
---|
| 783 | |
---|
| 784 | TBD. Seems to be not needed. |
---|
| 785 | |
---|
| 786 | === poll, select === |
---|
| 787 | |
---|
| 788 | TBD. Seems to be not needed. |
---|
| 789 | |
---|
| 790 | === RMAN(9) (Resource management) === |
---|
| 791 | |
---|
| 792 | http://www.freebsd.org/cgi/man.cgi?query=rman |
---|
| 793 | |
---|
| 794 | TBD. Seems to be not needed. |
---|
| 795 | |
---|
| 796 | === DEVCLASS(9), DEVICE(9), DRIVER(9), MAKE_DEV(9) (Device management) === |
---|
| 797 | |
---|
| 798 | http://www.freebsd.org/cgi/man.cgi?query=devclass |
---|
| 799 | |
---|
| 800 | http://www.freebsd.org/cgi/man.cgi?query=device |
---|
| 801 | |
---|
| 802 | http://www.freebsd.org/cgi/man.cgi?query=driver |
---|
| 803 | |
---|
| 804 | http://www.freebsd.org/cgi/man.cgi?query=make_dev |
---|
| 805 | |
---|
| 806 | Use FreeBSD implementation as far as possible. FreeBSD has a nice API for |
---|
| 807 | dynamic device handling. It may be interesting for RTEMS to use this API |
---|
| 808 | internally in the future. |
---|
| 809 | |
---|
| 810 | === BUS_SPACE(9), BUS_DMA(9) (Bus and DMA access) === |
---|
| 811 | |
---|
| 812 | http://www.freebsd.org/cgi/man.cgi?query=bus_space |
---|
| 813 | |
---|
| 814 | http://www.freebsd.org/cgi/man.cgi?query=bus_dma |
---|
| 815 | |
---|
| 816 | Likely BSP dependent. A default implementation for memory mapped linear access |
---|
| 817 | is easy to provide. The current heap implementation supports all properties |
---|
| 818 | demanded by bus_dma (including the boundary constraint). |
---|
[5ab1e1d] | 819 | |
---|
[7586492] | 820 | == RTEMS Replacements by File Description == |
---|
[5ab1e1d] | 821 | |
---|
| 822 | Note: Files with a status of USB are used by the USB test and have at least |
---|
| 823 | been partially tested. If they contain both USB and Nic, then they are used |
---|
| 824 | by both and MAY contain methods that have not been tested yet. Files that |
---|
| 825 | are only used by the Nic test are the most suspect. |
---|
| 826 | |
---|
[fb4c8a9] | 827 | ---- |
---|
[5ab1e1d] | 828 | rtems-libbsd File: rtems-bsd-assert.c |
---|
| 829 | FreeBSD File: rtems-bsd-config.h redefines BSD_ASSERT. |
---|
| 830 | Description: This file contains the support method rtems_bsd_assert_func(). |
---|
| 831 | Status: USB, Nic |
---|
| 832 | |
---|
| 833 | rtems-libbsd File: rtems-bsd-autoconf.c |
---|
| 834 | FreeBSD File: FreeBSD has BSP specific autoconf.c |
---|
| 835 | Description: This file contains configuration methods that are used to setup the system. |
---|
| 836 | Status: USB |
---|
| 837 | |
---|
| 838 | rtems-libbsd File: rtems-bsd-bus-dma.c |
---|
| 839 | FreeBSD File: FreeBSD has BSP specific busdma_machdep.c |
---|
| 840 | Description: |
---|
| 841 | Status: USB, Nic |
---|
| 842 | |
---|
| 843 | rtems-libbsd File: rtems-bsd-bus-dma-mbuf.c |
---|
| 844 | FreeBSD File: FreeBSD has BSP specific busdma_machdep.c |
---|
| 845 | Description: |
---|
| 846 | Status: Nic |
---|
| 847 | |
---|
| 848 | rtems-libbsd File: rtems-bsd-callout.c |
---|
| 849 | FreeBSD File: kern/kern_timeout.c |
---|
| 850 | Description: |
---|
| 851 | Status: USB, Nic |
---|
| 852 | |
---|
| 853 | rtems-libbsd File: rtems-bsd-cam.c |
---|
| 854 | FreeBSD File: cam/cam_sim.c |
---|
| 855 | Description: |
---|
| 856 | Status: USB |
---|
| 857 | |
---|
| 858 | rtems-libbsd File: rtems-bsd-condvar.c |
---|
| 859 | FreeBSD File: kern/kern_condvar.c |
---|
| 860 | Description: |
---|
| 861 | Status: USB |
---|
| 862 | |
---|
| 863 | rtems-libbsd File: rtems-bsd-copyinout.c |
---|
| 864 | FreeBSD File: bsp specific copyinout.c ) |
---|
| 865 | Description: Note: The FreeBSD file is split with some methods being in rtems-bsd-support |
---|
| 866 | Status: Nic |
---|
| 867 | |
---|
| 868 | rtems-libbsd File: rtems-bsd-delay.c |
---|
| 869 | FreeBSD File: bsp specific file with multiple names |
---|
| 870 | Description: |
---|
| 871 | Status: USB, Nic |
---|
| 872 | |
---|
| 873 | rtems-libbsd File: rtems-bsd-descrip.c |
---|
| 874 | FreeBSD File: kern/kern_descrip.c |
---|
| 875 | Description: |
---|
| 876 | Status: Nic |
---|
| 877 | |
---|
| 878 | rtems-libbsd File: rtems-bsd-generic.c |
---|
| 879 | FreeBSD File: kern/sys_generic.c |
---|
| 880 | Description: |
---|
| 881 | Status: Nic |
---|
| 882 | |
---|
| 883 | rtems-libbsd File: rtems-bsd-init.c |
---|
| 884 | FreeBSD File: N/A |
---|
| 885 | Description: |
---|
| 886 | Status: USB, Nic |
---|
| 887 | |
---|
| 888 | rtems-libbsd File: rtems-bsd-init-with-irq.c |
---|
| 889 | FreeBSD File: N/A |
---|
| 890 | Description: |
---|
| 891 | Status: USB, Nic |
---|
| 892 | |
---|
| 893 | rtems-libbsd File: rtems-bsd-jail.c |
---|
| 894 | FreeBSD File: kern/kern_jail.c |
---|
| 895 | Description: |
---|
| 896 | Status: USB, Nic |
---|
| 897 | |
---|
| 898 | rtems-libbsd File: rtems-bsd-lock.c |
---|
| 899 | FreeBSD File: kern/subr_lock.c |
---|
| 900 | Description: |
---|
| 901 | Status: USB, Nic |
---|
| 902 | |
---|
| 903 | rtems-libbsd File: rtems-bsd-log.c |
---|
| 904 | FreeBSD File: kern/subr_prf.c |
---|
| 905 | Description: |
---|
| 906 | Status: Nic |
---|
| 907 | |
---|
| 908 | rtems-libbsd File: rtems-bsd-malloc.c |
---|
| 909 | FreeBSD File: kern/kern_malloc.c |
---|
| 910 | Description: |
---|
| 911 | Status: USB, Nic |
---|
| 912 | |
---|
| 913 | rtems-libbsd File: rtems-bsd-mutex.c |
---|
| 914 | FreeBSD File: kern/kern_mutex.c |
---|
| 915 | Description: |
---|
| 916 | Status: USB, Nic |
---|
| 917 | |
---|
| 918 | rtems-libbsd File: rtems-bsd-newproc.c |
---|
| 919 | FreeBSD File: N/A |
---|
| 920 | Description: |
---|
| 921 | Status: Nic |
---|
| 922 | |
---|
| 923 | rtems-libbsd File: rtems-bsd-nexus.c |
---|
| 924 | FreeBSD File: bsp specific nexus.c |
---|
| 925 | Description: |
---|
| 926 | Status: USB |
---|
| 927 | |
---|
| 928 | rtems-libbsd File: rtems-bsd-panic.c |
---|
| 929 | FreeBSD File: boot/common/panic.c |
---|
| 930 | Description: |
---|
| 931 | Status: USB, Nic |
---|
| 932 | |
---|
| 933 | rtems-libbsd File: rtems-bsd-rwlock.c |
---|
| 934 | FreeBSD File: kern_rwlock.c |
---|
| 935 | Description: |
---|
| 936 | Status: USB, Nic |
---|
| 937 | |
---|
| 938 | rtems-libbsd File: rtems-bsd-shell.c |
---|
| 939 | FreeBSD File: N/A |
---|
| 940 | Description: |
---|
| 941 | Status: USB |
---|
| 942 | |
---|
| 943 | rtems-libbsd File: rtems-bsd-signal.c |
---|
| 944 | FreeBSD File: kern/kern_sig.c |
---|
| 945 | Description: |
---|
| 946 | Status: Nic |
---|
| 947 | |
---|
| 948 | rtems-libbsd File: rtems-bsd-smp.c |
---|
| 949 | FreeBSD File: N/A |
---|
| 950 | Description: |
---|
| 951 | Status: Nic |
---|
| 952 | |
---|
| 953 | rtems-libbsd File: rtems-bsd-support.c |
---|
| 954 | FreeBSD File: bsp specific copyinout.c |
---|
| 955 | Description: Note: the FreeBSD file is split with some methods being in rtems-bsd-copyinout. |
---|
| 956 | Status: USB, Nic |
---|
| 957 | |
---|
| 958 | rtems-libbsd File: rtems-bsd-sx.c |
---|
| 959 | FreeBSD File: kern/kern_sx.c |
---|
| 960 | Description: Status: USB, Nic |
---|
| 961 | |
---|
| 962 | rtems-libbsd File: rtems-bsd-synch.c |
---|
| 963 | FreeBSD File: kern/kern_synch.c |
---|
| 964 | Description: |
---|
| 965 | Status: USB, Nic |
---|
| 966 | |
---|
| 967 | rtems-libbsd File: rtems-bsd-syscalls.c |
---|
| 968 | FreeBSD File: User API for kern/uipc_syscalls.c |
---|
| 969 | Description: |
---|
| 970 | Status: Nic |
---|
| 971 | |
---|
| 972 | rtems-libbsd File: rtems-bsd-sysctlbyname.c |
---|
| 973 | FreeBSD File: User API for sysctlbyname(3) |
---|
| 974 | Description: |
---|
| 975 | Status: |
---|
| 976 | |
---|
| 977 | rtems-libbsd File: rtems-bsd-sysctl.c |
---|
| 978 | FreeBSD File: User API for sysctl(8) |
---|
| 979 | Description: |
---|
| 980 | Status: |
---|
| 981 | |
---|
| 982 | rtems-libbsd File: rtems-bsd-sysctlnametomib.c |
---|
| 983 | FreeBSD File: User API for sysctlnametomib |
---|
| 984 | Description: |
---|
| 985 | Status: |
---|
| 986 | |
---|
| 987 | rtems-libbsd File: rtems-bsd-taskqueue.c |
---|
| 988 | FreeBSD File: kern/subr_taskqueue.c |
---|
| 989 | Description: |
---|
| 990 | Status: Nic |
---|
| 991 | |
---|
| 992 | rtems-libbsd File: rtems-bsd-thread.c |
---|
| 993 | FreeBSD File: kern/kern_kthread.c |
---|
| 994 | Description: |
---|
| 995 | Status: USB, Nic |
---|
| 996 | |
---|
| 997 | rtems-libbsd File: rtems-bsd-timeout.c |
---|
| 998 | FreeBSD File: kern/kern_timeout.c |
---|
| 999 | Description: |
---|
| 1000 | Status: Nic |
---|
| 1001 | |
---|
| 1002 | rtems-libbsd File: rtems-bsd-timesupport.c |
---|
| 1003 | FreeBSD File: kern/kern_clock.c |
---|
| 1004 | Description: |
---|
| 1005 | Status: Nic |
---|
| 1006 | |
---|
| 1007 | rtems-libbsd File: rtems-bsd-vm_glue.c |
---|
| 1008 | FreeBSD File: vm/vm_glue.c |
---|
| 1009 | Description: |
---|
| 1010 | Status: USB, Nic |
---|
[fb4c8a9] | 1011 | ---- |
---|
| 1012 | |
---|
| 1013 | == Notes by File == |
---|
[7586492] | 1014 | |
---|
[fb4c8a9] | 1015 | altq_subr.c - Arbitrary choices were made in this file that RTEMS would |
---|
| 1016 | not support tsc frequency change. Additionally, the clock frequency |
---|
| 1017 | for machclk_freq is always measured for RTEMS. |
---|
| 1018 | |
---|
| 1019 | conf.h - In order to add make_dev and destroy_dev, variables in the cdev |
---|
| 1020 | structure that were not being used were conditionally compiled out. The |
---|
| 1021 | capability of supporting children did not appear to be needed and was |
---|
| 1022 | not implemented in the rtems version of these routines. |
---|
| 1023 | |
---|
[7586492] | 1024 | == NICs Status == |
---|
| 1025 | |
---|
[fb4c8a9] | 1026 | ---- |
---|
[7586492] | 1027 | Driver Symbol Status |
---|
| 1028 | ====== ====== ====== |
---|
| 1029 | RealTek _bsd_re_pcimodule_sys_init Links |
---|
| 1030 | EtherExpress _bsd_fxp_pcimodule_sys_init Links |
---|
| 1031 | DEC tulip _bsd_dc_pcimodule_sys_init Links |
---|
| 1032 | Broadcom BCM57xxx _bsd_bce_pcimodule_sys_init Links |
---|
| 1033 | Broadcom BCM4401 _bsd_bfe_pcimodule_sys_init Links |
---|
| 1034 | Broadcom BCM570x _bsd_bge_pcimodule_sys_init Needs Symbols (A) |
---|
[fb4c8a9] | 1035 | E1000 IGB _bsd_igb_pcimodule_sys_init Links |
---|
| 1036 | E1000 EM _bsd_em_pcimodule_sys_init Links |
---|
| 1037 | ---- |
---|
[7586492] | 1038 | |
---|
| 1039 | |
---|
| 1040 | Symbols (A) |
---|
| 1041 | pci_get_vpd_ident |
---|
[99dc0d7] | 1042 | |
---|
| 1043 | == Problems to report to FreeBSD == |
---|
| 1044 | |
---|
| 1045 | The MMAP_NOT_AVAILABLE define is inverted on its usage. When it is |
---|
| 1046 | defined the mmap method is called. Additionally, it is not used |
---|
| 1047 | thoroughly. It is not used in the unmap portion of the source. |
---|
[808a6b2] | 1048 | The file rec_open.c uses the define MMAP_NOT_AVAILABLE to wrap |
---|
| 1049 | the call to mmap and file rec_close.c uses the munmap method. |
---|
[99dc0d7] | 1050 | |
---|
| 1051 | |
---|
| 1052 | |
---|