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