Changeset 4c3433b in rtems-libbsd for libbsd.txt
- Timestamp:
- 01/24/14 15:37:21 (10 years ago)
- Branches:
- 4.11, 5, 5-freebsd-12, 6-freebsd-12, freebsd-9.3, master
- Children:
- 821ae67
- Parents:
- bc78466
- git-author:
- Sebastian Huber <sebastian.huber@…> (01/24/14 15:37:21)
- git-committer:
- Sebastian Huber <sebastian.huber@…> (01/30/14 15:23:05)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libbsd.txt
rbc78466 r4c3433b 1 RTEMS BSD USB and TCP/IP Developers Guide 2 ========================================= 3 Joel Sherrill <joel.sherrill@oarcorp.com> 4 :Author Initials: JRS 1 RTEMS BSD Library Guide 2 ======================= 5 3 :toc: 6 4 :icons: … … 8 6 :website: http://www.rtems.org/ 9 7 10 RTEMS uses FreeBSD as the source of its TCP/IP and USB stacks.11 This is a developersguide which captures information on the8 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 12 10 process of merging code from FreeBSD, building this library, 13 11 RTEMS specific support files, and general guidelines on what 14 12 modifications to the FreeBSD source are permitted. 15 13 16 Goals of this effort are :17 18 * Update TCP/IP and provide USB in RTEMS19 * Ease updating to future FreeBSD versions20 * Ease tracking changes in FreeBSD code21 * Minimize manual changes in FreeBSD code22 * Define stable kernel/device driver API which is implemented14 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 23 21 by both RTEMS and FreeBSD. This is the foundation of the port. 24 22 … … 26 24 and minimize changes required at each update point. 27 25 28 ************************************************************** 26 ******************************************************************************* 29 27 This is a work in progress and is very likely to be incomplete. 30 28 Please help by adding to it. 31 ************************************************************** 32 33 == Source Code Version Information 34 35 * FreeBSD 8.2 SVN r255967 36 * RTEMS 4.11 37 - BSP must have support for all new BSD sys sections 38 - It is preferable if the BSP uses linkcmds.base. 39 - BSP must be from an architecture with Programmable Interrupt Controller 40 interrupt model. 41 42 The latest port uses the FreeBSD sources as a Git submodule which will 43 generally be referred to as the FreeBSD source in this document. Previously a 44 FreeBSD 8.2 SVN checkout was used. The SVN checkout command corresponding to 45 the current Git submodule commit is this 46 svn co http://svn.freebsd.org/base/releng/8.2 -r255967 freebsd-8.2 47 48 == Issues and To Do 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 === Board Support Package Requirements === 46 47 The RTEMS version must be at least 4.11. The Board Support Package (BSP) 48 should support the 49 http://www.rtems.org/onlinedocs/doxygen/cpukit/html/group__rtems__interrupt__extension.html[Interrupt Manager Extension] 50 to make use of generic FreeBSD based drivers. 51 52 The linker command file of the BSP must contain the following sections: 53 54 ------------------------------------------------------------------------------- 55 .rtemsroset : { 56 KEEP (*(SORT(.rtemsroset.*))) 57 } 58 59 .rtemsrwset : { 60 KEEP (*(SORT(.rtemsrwset.*))) 61 } 62 ------------------------------------------------------------------------------- 63 64 The first section can be placed in read-only memory. The section section must 65 be placed in read-write memory. 66 67 === Board Support Package Configuration and Build === 68 69 You need to configure RTEMS for the desired BSP and install it. The BSP should 70 be configured with a disabled network stack. The BSD library containing the 71 new network stack is a separate package. Using a BSP installation containing 72 the old network stack may lead to confusion and unpredictable results. 73 74 The following script is used to build the `arm/realview_pbx_a9_qemu` BSP for 75 our internal testing purposes: 76 77 ------------------------------------------------------------------------------- 78 #!/bin/sh 79 80 cd ${HOME}/sandbox 81 rm -rf b-realview_pbx_a9_qemu 82 mkdir b-realview_pbx_a9_qemu 83 cd b-realview_pbx_a9_qemu 84 ${HOME}/git-rtems/configure \ 85 --prefix=${HOME}/sandbox/install \ 86 --target=arm-rtems4.11 \ 87 --enable-rtemsbsp=realview_pbx_a9_qemu \ 88 --disable-networking && \ 89 make && \ 90 make install 91 ------------------------------------------------------------------------------- 92 93 The `arm/realview_pbx_a9_qemu` BSP running on the Qemu simulator has some 94 benefits for development and test of the BSD library 95 96 * it offers a NULL pointer read and write protection, 97 * Qemu is a fast simulator, 98 * Qemu provides support for GDB watchpoints, 99 * Qemu provides support for virtual Ethernet networks, e.g. TUN and bridge 100 devices (you can run multiple test instances on one virtual network). 101 102 === BSD Library Configuration and Build === 103 104 In the BSD library source directory edit the file 'config.inc'. Continuing on 105 the above, the 'config.inc' used to match the above is: 106 107 ------------------------------------------------------------------------------- 108 # Mandatory: Select your BSP and installation prefix 109 TARGET = arm-rtems4.11 110 BSP = realview_pbx_a9_qemu 111 PREFIX = $(HOME)/sandbox/install 112 113 # Optional: Separate installation base directory 114 INSTALL_BASE = $(PREFIX)/$(TARGET)/$(BSP) 115 116 # Optional: Network test configuration 117 TEST_RUNNER = $(BSP) 118 NET_CFG_SELF_IP = 10.0.0.2 119 NET_CFG_NETMASK = 255.255.0.0 120 NET_CFG_PEER_IP = 10.0.0.1 121 NET_CFG_GATEWAY_IP = 10.0.0.1 122 NET_TAP_INTERFACE = tap0 123 ------------------------------------------------------------------------------- 124 125 Now you can build the BSD library and run the tests: 126 127 ------------------------------------------------------------------------------- 128 make clean 129 make 130 make run_tests 131 ------------------------------------------------------------------------------- 132 133 To install the BSD library use this: 134 135 ------------------------------------------------------------------------------- 136 make install 137 ------------------------------------------------------------------------------- 138 139 === BSD Library Initialization === 140 141 Use the following code to initialize the BSD library: 142 143 ------------------------------------------------------------------------------- 144 #include <assert.h> 145 146 #include <rtems/bsd/bsd.h> 147 148 void do_init(void) 149 { 150 rtems_status_code sc; 151 152 sc = rtems_bsd_initialize(); 153 assert(sc == RTEMS_SUCCESSFUL); 154 } 155 ------------------------------------------------------------------------------- 156 157 == Network Stack Features 158 159 http://roy.marples.name/projects/dhcpcd/index[DHCPCD(8)]:: DHCP client 160 161 https://developer.apple.com/library/mac/documentation/Networking/Reference/DNSServiceDiscovery_CRef/Reference/reference.html[dns_sd.h]:: DNS Service Discovery 162 163 http://www.opensource.apple.com/source/mDNSResponder/mDNSResponder-320.10/mDNSCore/mDNSEmbeddedAPI.h[mDNS]:: Multi-Cast DNS 164 165 http://www.freebsd.org/cgi/man.cgi?query=unix&sektion=4&apropos=0&manpath=FreeBSD+9.2-RELEASE[UNIX(4)]:: UNIX-domain protocol family 166 167 http://www.freebsd.org/cgi/man.cgi?query=inet&sektion=4&apropos=0&manpath=FreeBSD+9.2-RELEASE[INET(4)]:: Internet protocol family 168 169 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 170 171 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 172 173 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 174 175 http://www.freebsd.org/cgi/man.cgi?query=route&sektion=4&apropos=0&manpath=FreeBSD+9.2-RELEASE[ROUTE(4)]:: Kernel packet forwarding database 176 177 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 178 179 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 180 181 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 182 183 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 184 185 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 186 187 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 188 189 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 190 191 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 192 193 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 194 195 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 196 197 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 198 199 http://www.freebsd.org/cgi/man.cgi?query=resolver&sektion=3&apropos=0&manpath=FreeBSD+9.2-RELEASE[RESOLVER(3)]:: Resolver routines 200 201 http://www.freebsd.org/cgi/man.cgi?query=gethostbyname&sektion=3&apropos=0&manpath=FreeBSD+9.2-RELEASE[GETHOSTBYNAME(3)]:: Get network host entry 202 203 == Issues and TODO 204 49 205 * Per-CPU data should be enabled once the new stack is ready for SMP. 50 206 … … 65 221 - cr_canseeinpcb(). 66 222 67 * Sebastian Huber and Joel Sherrill discussed the need for a a basic USB 68 functionality test that is known to work on qemu pc. 223 * A basic USB functionality test that is known to work on Qemu is desirable. 69 224 70 225 * Adapt generic IRQ PIC interface code to Simple Vectored Interrupt Model … … 80 235 not originate from FreeBSD and are populated via the script. 81 236 82 * linker section issues: I have undefined symbols for83 `_bsd__start_set_sysinit_set` and `_bsd__stop_set_sysinit_set`.84 Is this the only type of new section magic? What about the old sysctl_set?85 I added this to my linkcmds.86 87 237 * MAC support functions are not thread-safe ("freebsd/lib/libc/posix1e/mac.c"). 88 238 … … 118 268 * PRINTF(9): Add support for log(), the %D format specifier is missing in the 119 269 normal printf() family. 120 121 [listing]122 ----123 /* sysinit section? */124 . = ALIGN (16);125 _bsd__start_set_sysinit_set = .;126 *(set_sys_init_*);127 _bsd__stop_set_sysinit_set = .;128 129 ----130 270 131 271 * Why is the interrupt server used? The BSD interrupt handlers can block on … … 144 284 easier to insert. 145 285 146 * rtems-bsd-init-with-irq.c:147 rtems_bsd_initialize_with_interrupt_server() has reference to148 rtems_interrupt_server_initialize() and this method is unimplemented149 - XXX BSP implements pieces150 - BSPs using this software stack must support it apparently.151 - What about Simple Vectored architectures?152 153 * We carried over use of notepad 0 for per task information. This should154 be changed.155 156 * maxproc variable referenced by rtems-bsd-resource.c. What should it157 be set to?158 159 * ngroups_max variable referenced by rtems-bsd-prot.c. - What should160 it be set to?161 162 286 * NIC Device Drivers 163 287 - Only common PCI NIC drivers have been included in the initial set. These … … 177 301 === Automatically Generated FreeBSD Files 178 302 179 The FreeBSD source tarball includes a file named Makefile.rtems which 180 has stanzas to automatically generate some files using awk. For details 181 on this, see http://www.freebsd.org/cgi/man.cgi?query=kobj&apropos=0&sektion=0&manpath=FreeBSD+9.0-RELEASE&arch=default&format=html 182 183 XXX This needs more detail.303 Some source and header files are automatically generated during the FreeBSD 304 build process. The `Makefile.todo` file performs this manually. The should be 305 included in `freebsd-to-rtems.py` script some time in the future. For details, 306 see also 307 http://www.freebsd.org/cgi/man.cgi?query=kobj&sektion=9&apropos=0&manpath=FreeBSD+9.2-RELEASE[KOBJ(9)]. 184 308 185 309 === Rules for Modifying FreeBSD Source 186 310 187 * Only add lines. Subtract code by added "ifndef __rtems__". This makes 188 merging easier in the future. 189 190 == libbsd Source 191 192 === What is in git 193 194 The git source is a self-contained kit with FreeBSD and RTEMS components 195 pre-merged. The Makefile in this kit is automatically generated. 196 197 Any changes to sources in the freebsd or contrib directories will need to 198 be merged upstream into our master FreeBSD svn checkout. 199 200 The FreeBSD sources managed in the rtems-libbsd git repository (e.g. contrib 201 and freebsd directories) contain the "managed" version of the 202 FreeBSD source. The FreeBSD SVN source is the "master" version. The 203 freebsd-to-rtems.py script is used to transfer files between the two 204 trees. In general terms, if you have modified FreeBSD (i.e. anything in the 205 freebsd directory) in the rtems-libbsd tree, you will need to run the script 206 in "revert" or "reverse" mode using the -R switch. This will copy the source 207 back to your local copy of the FreeBSD source so you can run "svn diff" against 208 the upstream FreeBSD source. If you want to transfer source files from the 209 FreeBSD SVN checkout to the rtems-libbsd tree, then you must run the script in 210 "forward" mode (the default). 211 212 === Building rtems-libbsd source 213 214 You need to configure RTEMS for the desired BSP and install it. The 215 following is the script used to build the powerpc/psim BSP for our 216 internal testing purposes: 217 218 [listing] 219 ---- 220 #! /bin/sh 221 222 cd ${HOME}/newbsd 223 rm -rf b-psim 224 mkdir b-psim 225 cd b-psim 226 ../git/rtems/configure --target=powerpc-rtems4.11 \ 227 --enable-rtemsbsp=psim --disable-networking \ 228 --enable-tests=samples \ 229 --prefix=${HOME}/newbsd/bsp-install >c.log 2>&1 && \ 230 make >b.log 2>&1 && \ 231 make install >i.log 2>&1 232 echo $? 233 ---- 234 235 Then edit the file config.inc to set RTEMS_MAKEFILE_PATH appropriately 236 to indicate the ${prefix}/${target}/${BSP}. Continuing on the above, 237 the config.inc used to match the above is: 238 239 [listing] 240 ---- 241 RTEMS_MAKEFILE_PATH = ${HOME}/newbsd/bsp-install/powerpc-rtems4.11/psim/ 242 INSTALL_BASE = ${HOME}/newbsd/install 243 ---- 244 245 The above installs the rtems-libbsd kit into a separate place from 246 RTEMS and the BSP. The rtems-libbsd tests are built against an installed 247 image of the rtems-libbsd. By keeping it in a separate installation point 248 from RTEMS itself, this makes it easier to remove a libbsd installation 249 and have a clean test point. 250 251 [listing] 252 ---- 253 make 254 make install 255 make -C testsuite 256 ---- 257 258 At this point, we expect multiple linker errors. That is what we are 259 currently working on. 311 Only add lines. Subtract code by added `#ifndef __rtems__`. This makes 312 merging easier in the future. For example: 313 314 ------------------------------------------------------------------------------- 315 /* Global variables for the kernel. */ 316 317 #ifndef __rtems__ 318 /* 1.1 */ 319 extern char kernelname[MAXPATHLEN]; 320 #endif /* __rtems__ */ 321 322 extern int tick; /* usec per tick (1000000 / hz) */ 323 ------------------------------------------------------------------------------- 324 325 ------------------------------------------------------------------------------- 326 #if defined(_KERNEL) || defined(_WANT_FILE) 327 #ifdef __rtems__ 328 #include <rtems/libio_.h> 329 #include <sys/fcntl.h> 330 #endif /* __rtems__ */ 331 /* 332 * Kernel descriptor table. 333 * One entry for each open kernel vnode and socket. 334 * 335 * Below is the list of locks that protects members in struct file. 336 * 337 * (f) protected with mtx_lock(mtx_pool_find(fp)) 338 * (d) cdevpriv_mtx 339 * none not locked 340 */ 341 ------------------------------------------------------------------------------- 342 343 ------------------------------------------------------------------------------- 344 extern int profprocs; /* number of process's profiling */ 345 #ifndef __rtems__ 346 extern volatile int ticks; 347 #else /* __rtems__ */ 348 #include <rtems/score/watchdogimpl.h> 349 #define ticks _Watchdog_Ticks_since_boot 350 #endif /* __rtems__ */ 351 352 #endif /* _KERNEL */ 353 ------------------------------------------------------------------------------- 354 355 Add nothing (even blank lines) before or after the `__rtems__` guards. Always 356 include a `__rtems__` in the guards to make searches easy. 357 358 == BSD Library Source 359 360 === What is in the Git Repository 361 362 There is a self-contained kit with FreeBSD and RTEMS components pre-merged. The 363 Makefile in this kit is automatically generated. 364 365 Any changes to source in the `freebsd` directories will need to be merged 366 upstream into our master FreeBSD checkout, the `freebsd-org` submodule. 367 368 The repository contains two FreeBSD source trees. In the `freebsd` directory 369 are the so called 'managed' FreeBSD sources used to build the BSD library. The 370 FreeBSD source in `freebsd-org` is the 'master' version. The 371 `freebsd-to-rtems.py` script is used to transfer files between the two trees. 372 In general terms, if you have modified managed FreeBSD sources, you will need 373 to run the script in 'revert' or 'reverse' mode using the `-R` switch. This 374 will copy the source back to your local copy of the master FreeBSD source so 375 you can run `git diff` against the upstream FreeBSD source. If you want to 376 transfer source files from the master FreeBSD source to the manged FreeBSD 377 sources, then you must run the script in 'forward' mode (the default). 260 378 261 379 === Organization 262 380 263 381 The top level directory contains a few directories and files. The following 264 are important to understand: 265 266 * freebsd-to-rtems.py - script to convert to and free FreeBSD and RTEMS trees 267 * Makefile - automatically generated 268 * contrib/ - from FreeBSD by script. 269 * freebsd/ - from FreeBSD by script. 270 * rtemsbsd/ - RTEMS specific implementations of FreeBSD kernel support routines. 271 * testsuite/ - RTEMS specific tests 272 * libbsd.txt - Documentation in Asciidoc 273 274 == Moving Code Between FreeBSD SVN and rtems-libbsd 275 276 The script freebsd-to-rtems.py is used to copy code from FreeBSD to the 382 are important to understand 383 384 * `freebsd-to-rtems.py` - script to convert to and free FreeBSD and RTEMS trees, 385 * `Makefile` - automatically generated, 386 * `freebsd/` - from FreeBSD by script, 387 * `rtemsbsd/` - RTEMS specific implementations of FreeBSD kernel support routines, 388 * `testsuite/` - RTEMS specific tests, and 389 * `libbsd.txt` - documentation in Asciidoc. 390 391 == Moving Code Between Managed and Master FreeBSD Source 392 393 The script `freebsd-to-rtems.py` is used to copy code from FreeBSD to the 277 394 rtems-libbsd tree and to reverse this process. This script attempts to 278 395 automate this process as much as possible and performs some transformations 279 396 on the FreeBSD code. Its command line arguments are shown below: 280 397 281 [listing]282 398 ---- 283 399 freebsd-to-rtems.py [args] … … 311 427 The following is an example forward run with no changes. 312 428 313 [listing]314 429 ---- 315 430 $ ~/newbsd/git/libbsd-8.2/freebsd-to-rtems.py \ … … 329 444 direction. 330 445 331 == Initialization of rtems-libbsd332 333 The initialization of the rtems-libbsdis based on the FreeBSD SYSINIT(9)446 == Initialization of the BSD Library 447 448 The initialization of the BSD library is based on the FreeBSD SYSINIT(9) 334 449 infrastructure. The key to initializing a system is to ensure that the desired 335 450 device drivers are explicitly pulled into the linked application. This plus 336 linking against the libbsd librarywill pull in the necessary FreeBSD451 linking against the BSD library (`libbsd.a`) will pull in the necessary FreeBSD 337 452 infrastructure. 338 453 … … 354 469 section. In the linker command file we need this: 355 470 356 [listing] 357 ---- 358 .robsdsets : { 359 _bsd__start_set_modmetadata_set = .; 360 *(_bsd_set_modmetadata_set); 361 _bsd__stop_set_modmetadata_set = .; 362 _bsd__start_set_sysctl_set = .; 363 *(_bsd_set_sysctl_set); 364 _bsd__stop_set_sysctl_set = .; 365 } > REGION_RODATA AT > REGION_RODATA_LOAD 366 367 .rwbsdsets : { 368 _bsd__start_set_sysinit_set = .; 369 *(_bsd_set_sysinit_set); 370 _bsd__stop_set_sysinit_set = .; 371 } > REGION_DATA AT > REGION_DATA_LOAD 372 ---- 373 374 Here you can see, that these global data structures are collected into 471 ------------------------------------------------------------------------------- 472 .rtemsroset : { 473 KEEP (*(SORT(.rtemsroset.*))) 474 } 475 476 .rtemsrwset : { 477 KEEP (*(SORT(.rtemsrwset.*))) 478 } 479 ------------------------------------------------------------------------------- 480 481 This results for example in this executable layout: 482 483 ------------------------------------------------------------------------------- 484 [...] 485 *(SORT(.rtemsroset.*)) 486 .rtemsroset.bsd.modmetadata_set.begin 487 0x000000000025fe00 0x0 libbsd.a(rtems-bsd-init.o) 488 0x000000000025fe00 _bsd__start_set_modmetadata_set 489 .rtemsroset.bsd.modmetadata_set.content 490 0x000000000025fe00 0x8 libbsd.a(rtems-bsd-nexus.o) 491 .rtemsroset.bsd.modmetadata_set.content 492 0x000000000025fe08 0x4 libbsd.a(kern_module.o) 493 [...] 494 .rtemsroset.bsd.modmetadata_set.content 495 0x000000000025fe68 0x4 libbsd.a(mii.o) 496 .rtemsroset.bsd.modmetadata_set.content 497 0x000000000025fe6c 0x4 libbsd.a(mii_bitbang.o) 498 .rtemsroset.bsd.modmetadata_set.end 499 0x000000000025fe70 0x0 libbsd.a(rtems-bsd-init.o) 500 0x000000000025fe70 _bsd__stop_set_modmetadata_set 501 [...] 502 .rtemsrwset 0x000000000030bad0 0x290 503 *(SORT(.rtemsrwset.*)) 504 .rtemsrwset.bsd.sysinit_set.begin 505 0x000000000030bad0 0x0 libbsd.a(rtems-bsd-init.o) 506 0x000000000030bad0 _bsd__start_set_sysinit_set 507 .rtemsrwset.bsd.sysinit_set.content 508 0x000000000030bad0 0x4 libbsd.a(rtems-bsd-nexus.o) 509 .rtemsrwset.bsd.sysinit_set.content 510 0x000000000030bad4 0x8 libbsd.a(rtems-bsd-thread.o) 511 .rtemsrwset.bsd.sysinit_set.content 512 0x000000000030badc 0x4 libbsd.a(init_main.o) 513 [...] 514 .rtemsrwset.bsd.sysinit_set.content 515 0x000000000030bd54 0x4 libbsd.a(frag6.o) 516 .rtemsrwset.bsd.sysinit_set.content 517 0x000000000030bd58 0x8 libbsd.a(uipc_accf.o) 518 .rtemsrwset.bsd.sysinit_set.end 519 0x000000000030bd60 0x0 libbsd.a(rtems-bsd-init.o) 520 0x000000000030bd60 _bsd__stop_set_sysinit_set 521 [...] 522 ------------------------------------------------------------------------------- 523 524 Here you can see, that some global data structures are collected into 375 525 continuous memory areas. This memory area can be identified by start and stop 376 526 symbols. This constructs a table of uniform items. … … 389 539 In RTEMS we have a library and not a bunch of object files. Thus we need a way 390 540 to pull-in the desired services out of the libbsd. Here the 391 "rtems-bsd-sysinit.h" comes into play. The SYSINIT(9) macros have been 392 modified and extended for RTEMS in "sys/kernel.h": 393 394 [listing] 395 ---- 541 `rtems-bsd-sysinit.h` comes into play. The SYSINIT(9) macros have been 542 modified and extended for RTEMS in `<sys/kernel.h>`: 543 544 ------------------------------------------------------------------------------- 396 545 #ifndef __rtems__ 397 #define C_SYSINIT(uniquifier, subsystem, order, func, ident)\398 static struct sysinit uniquifier ## _sys_init = {\399 subsystem,\400 order,\401 func,\402 (ident)\403 };\404 546 #define C_SYSINIT(uniquifier, subsystem, order, func, ident) \ 547 static struct sysinit uniquifier ## _sys_init = { \ 548 subsystem, \ 549 order, \ 550 func, \ 551 (ident) \ 552 }; \ 553 DATA_SET(sysinit_set,uniquifier ## _sys_init) 405 554 #else /* __rtems__ */ 406 #define SYSINIT_ENTRY_NAME(uniquifier) \ 407 _bsd_ ## uniquifier ## _sys_init 408 #define SYSINIT_REFERENCE_NAME(uniquifier) \ 409 _bsd_ ## uniquifier ## _sys_init_ref 410 #define C_SYSINIT(uniquifier, subsystem, order, func, ident) \ 411 struct sysinit SYSINIT_ENTRY_NAME(uniquifier) = { \ 412 subsystem, \ 413 order, \ 414 func, \ 415 (ident) \ 416 }; \ 417 DATA_SET(sysinit_set,SYSINIT_ENTRY_NAME(uniquifier)) 418 #define SYSINIT_REFERENCE(uniquifier) \ 419 extern struct sysinit SYSINIT_ENTRY_NAME(uniquifier); \ 420 static struct sysinit const * const \ 421 SYSINIT_REFERENCE_NAME(uniquifier) __used \ 422 = &SYSINIT_ENTRY_NAME(uniquifier) 423 #define SYSINIT_MODULE_REFERENCE(mod) \ 424 SYSINIT_REFERENCE(mod ## module) 425 #define SYSINIT_DRIVER_REFERENCE(driver, bus) \ 426 SYSINIT_MODULE_REFERENCE(driver ## _ ## bus) 555 #define SYSINIT_ENTRY_NAME(uniquifier) \ 556 _bsd_ ## uniquifier ## _sys_init 557 #define SYSINIT_REFERENCE_NAME(uniquifier) \ 558 _bsd_ ## uniquifier ## _sys_init_ref 559 #define C_SYSINIT(uniquifier, subsystem, order, func, ident) \ 560 struct sysinit SYSINIT_ENTRY_NAME(uniquifier) = { \ 561 subsystem, \ 562 order, \ 563 func, \ 564 (ident) \ 565 }; \ 566 RWDATA_SET(sysinit_set,SYSINIT_ENTRY_NAME(uniquifier)) 567 #define SYSINIT_REFERENCE(uniquifier) \ 568 extern struct sysinit SYSINIT_ENTRY_NAME(uniquifier); \ 569 static struct sysinit const * const \ 570 SYSINIT_REFERENCE_NAME(uniquifier) __used \ 571 = &SYSINIT_ENTRY_NAME(uniquifier) 572 #define SYSINIT_MODULE_REFERENCE(mod) \ 573 SYSINIT_REFERENCE(mod ## module) 574 #define SYSINIT_DRIVER_REFERENCE(driver, bus) \ 575 SYSINIT_MODULE_REFERENCE(driver ## _ ## bus) 576 #define SYSINIT_DOMAIN_REFERENCE(dom) \ 577 SYSINIT_REFERENCE(domain_add_ ## dom) 427 578 #endif /* __rtems__ */ 428 ---- 579 ------------------------------------------------------------------------------- 429 580 430 581 Here you see that the SYSINIT(9) entries are no longer static. The 431 *_REFERENCE() macros will create references to the corresponding modules which582 \*_REFERENCE() macros will create references to the corresponding modules which 432 583 are later resolved by the linker. The application has to provide an object 433 584 file with references to all required FreeBSD modules. … … 439 590 The devices form a tree with the Nexus device at a high-level. This Nexus 440 591 device is architecture specific in FreeBSD. In RTEMS we have our own Nexus 441 device, see "rtems-bsd-nexus.c". It uses a table to add child devices: 442 443 [listing] 444 ---- 445 const char *const _bsd_nexus_devices [] = { 446 #ifdef NEED_USB_OHCI 447 "ohci", 448 #endif 449 #ifdef NEED_USB_EHCI 450 "ehci", 451 #endif 452 #ifdef NEED_SDHC 453 "sdhci", 454 #endif 455 NULL 456 }; 457 ---- 458 459 This table must be provided by the application. 592 device, see `rtemsbsd/bsp/bsp-bsd-nexus-devices.c`. 460 593 461 594 === SYSCTL_NODE Example … … 467 600 to add the "inet" node to the parent node "_net". 468 601 469 [listing]470 602 ---- 471 603 SYSCTL_NODE(_net, PF_INET, inet, CTLFLAG_RW, 0, … … 487 619 This was all generated by a support macro declaring the node as this: 488 620 489 [listing]490 621 ---- 491 622 struct sysctl_oid_list SYSCTL_NODE_CHILDREN(parent, name); … … 495 626 kern/kern_mib.c 496 627 497 [listing]498 628 ---- 499 629 SYSCTL_NODE(, CTL_KERN, kern, CTLFLAG_RW, 0, … … 610 740 are only used by the Nic test are the most suspect. 611 741 612 [listing]613 742 ---- 614 743 rtems-libbsd File: rtems-bsd-assert.c … … 810 939 == NICs Status == 811 940 812 [listing]813 941 ---- 814 942 Driver Symbol Status
Note: See TracChangeset
for help on using the changeset viewer.