[8f5adbc] | 1 | RTEMS BSD USB and TCP/IP Developers Guide |
---|
| 2 | ========================================= |
---|
| 3 | Joel Sherrill <joel.sherrill@oarcorp.com> |
---|
| 4 | :Author Initials: JRS |
---|
| 5 | :toc: |
---|
| 6 | :icons: |
---|
| 7 | :numbered: |
---|
| 8 | :website: http://www.rtems.org/ |
---|
| 9 | |
---|
| 10 | RTEMS uses FreeBSD as the source of its TCP/IP and USB stacks. |
---|
| 11 | This is a developers guide which captures information on the |
---|
| 12 | process of merging code from FreeBSD, building this library, |
---|
| 13 | RTEMS specific support files, and general guidelines on what |
---|
| 14 | modifications to the FreeBSD source are permitted. |
---|
| 15 | |
---|
[e392fdb7] | 16 | Goals of this effort are: |
---|
| 17 | |
---|
| 18 | * Update TCP/IP and provide USB in RTEMS |
---|
| 19 | * Ease updating to future FreeBSD versions |
---|
| 20 | * Ease tracking changes in FreeBSD code |
---|
| 21 | * Minimize manual changes in FreeBSD code |
---|
| 22 | * Define stable kernel/device driver API which is implemented |
---|
| 23 | by both RTEMS and FreeBSD. This is the foundation of the port. |
---|
| 24 | |
---|
| 25 | We will work to push our changes upstream to the FreeBSD Project |
---|
| 26 | and minimize changes required at each update point. |
---|
| 27 | |
---|
[8f5adbc] | 28 | ************************************************************** |
---|
| 29 | This is a work in progress and is very likely to be incomplete. |
---|
| 30 | Please help by adding to it. |
---|
| 31 | ************************************************************** |
---|
| 32 | |
---|
| 33 | == Source Code Version Information |
---|
| 34 | |
---|
| 35 | * FreeBSD 8.2 SVN r222496 |
---|
| 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 | |
---|
[e392fdb7] | 42 | The FreeBSD 8.2 SVN checkout will generally be referred to as the |
---|
| 43 | FreeBSD source in this document. |
---|
| 44 | |
---|
[8f5adbc] | 45 | == To Do |
---|
| 46 | * Adapt generic IRQ PIC interface code to Simple Vectored Interrupt Model |
---|
| 47 | so that those architectures can use new TCP/IP and USB code. |
---|
| 48 | * in_cksum implementations for architectures not supported by FreeBSD. |
---|
| 49 | This will require figuring out where to put implementations that do |
---|
| 50 | not originate from FreeBSD and are populated via the script. |
---|
| 51 | * generic in_cksum implementation is missing in_cksum_split so currently |
---|
| 52 | cannot be used. |
---|
| 53 | |
---|
| 54 | == FreeBSD Source |
---|
| 55 | |
---|
| 56 | You should be able to rely on FreebSD manual pages and documentation |
---|
| 57 | for details on the code itself. |
---|
| 58 | |
---|
| 59 | === Automatically Generated FreeBSD Files |
---|
| 60 | |
---|
| 61 | The FreeBSD source tarball includes a file named Makefile.rtems which |
---|
| 62 | has stanzas to automatically generate some files. |
---|
| 63 | |
---|
| 64 | http://www.freebsd.org/cgi/man.cgi?query=kobj&apropos=0&sektion=0&manpath=FreeBSD+9.0-RELEASE&arch=default&format=html |
---|
| 65 | |
---|
| 66 | === Rules for Modifying FreeBSD Source |
---|
| 67 | |
---|
| 68 | * Only add lines. Subtract code by added "ifndef __rtems__". This makes |
---|
| 69 | merging easier in the future. |
---|
| 70 | |
---|
| 71 | == libbsd Source |
---|
| 72 | |
---|
| 73 | === What is in git |
---|
| 74 | |
---|
| 75 | The git source is a self-contained kit with FreeBSD and RTEMS components |
---|
| 76 | pre-merged. The Makefile in this kit is automatically generated. |
---|
| 77 | |
---|
| 78 | Any changes to sources in the freebsd or contrib directories will need to |
---|
| 79 | be merged upstream into our master FreeBSD svn checkout. |
---|
| 80 | |
---|
| 81 | === Building git |
---|
| 82 | |
---|
| 83 | You need to configure RTEMS for the desired BSP and install it. Then edit |
---|
| 84 | the file config.inc to set RTEMS_MAKEFILE_PATH appropriately. |
---|
| 85 | |
---|
| 86 | [listing] |
---|
| 87 | ---- |
---|
| 88 | make |
---|
| 89 | make install |
---|
| 90 | make -C testsuite |
---|
| 91 | ---- |
---|
| 92 | |
---|
| 93 | At this point, we expect multiple linker errors. That is what we are |
---|
| 94 | currently working on. |
---|
| 95 | |
---|
| 96 | === Organization |
---|
| 97 | |
---|
| 98 | The top level directory contains a few directories and files. The following |
---|
| 99 | are important to understand: |
---|
| 100 | |
---|
| 101 | * freebsd-to-rtems.py - script to convert to and free FreeBSD and RTEMS trees |
---|
| 102 | * Makefile - automatically generated |
---|
| 103 | * contrib/ - from FreeBSD by script. |
---|
| 104 | * freebsd/ - from FreeBSD by script. |
---|
| 105 | * rtemsbsd/ - RTEMS specific implementations of FreeBSD kernel support routines. |
---|
| 106 | * testsuite/ - RTEMS specific tests |
---|
| 107 | * libbsd.txt - Documentation in Asciidoc |
---|
| 108 | |
---|
[e392fdb7] | 109 | == Moving Code Between FreeBSD SVN and RTEMS libbsd |
---|
| 110 | |
---|
| 111 | The script freebsd-to-rtems.py is used to copy code from FreeBSD to the |
---|
| 112 | RTEMS libbsd tree and to reverse this process. This script attempts to |
---|
| 113 | automate this process as much as possible and performs some transformations |
---|
| 114 | on the FreeBSD code. Its command line arguments are shown below: |
---|
| 115 | |
---|
| 116 | [listing] |
---|
| 117 | ---- |
---|
| 118 | freebsd-to-rtems.py [args] |
---|
| 119 | -?|-h|--help print this and exit |
---|
| 120 | -d|--dry-run run program but no modifications |
---|
| 121 | -e|--early-exit evaluate arguments, print results, and exit |
---|
| 122 | -m|--makefile just generate Makefile |
---|
| 123 | -R|--reverse default FreeBSD -> RTEMS, reverse that |
---|
| 124 | -r|--rtems RTEMS directory |
---|
| 125 | -f|--freebsd FreeBSD directory |
---|
| 126 | -v|--verbose enable verbose output mode |
---|
| 127 | ---- |
---|
| 128 | |
---|
| 129 | In its default mode of operation, freebsd-to-rtems.py is used to copy code |
---|
| 130 | from FreeBSD to the RTEMS libbsd tree and perform transformations. In forward |
---|
| 131 | mode, the script may be requested to just generate the Makefile. |
---|
| 132 | |
---|
| 133 | In "reverse mode", this script undoes those transformations and copies |
---|
| 134 | the source code back to the FreeBSD SVN tree. This allows us to do |
---|
| 135 | 'svn diff', evaluate changes made by the RTEMS Project, and report changes |
---|
| 136 | back to FreeBSD upstream. |
---|
| 137 | |
---|
| 138 | In either mode, the script may be asked to perform a dry-run or be verbose. |
---|
| 139 | Also, in either mode, the script is also smart enough to avoid copying over |
---|
| 140 | files which have not changed. This means that the timestamps of files are |
---|
| 141 | not changed unless the contents change. The script will also report the |
---|
| 142 | number of files which changed. In verbose mode, the script will print |
---|
| 143 | the name of the files which are changed. |
---|
| 144 | |
---|
| 145 | The following is an example forward run with no changes. |
---|
| 146 | |
---|
| 147 | [listing] |
---|
| 148 | ---- |
---|
| 149 | $ ~/newbsd/git/libbsd-8.2/freebsd-to-rtems.py \ |
---|
| 150 | -r /home/joel/newbsd/git/libbsd-8.2 \ |
---|
| 151 | -f /home/joel/newbsd/libbsd/freebsd-8.2 -v |
---|
| 152 | Verbose: yes |
---|
| 153 | Dry Run: no |
---|
| 154 | Only Generate Makefile: no |
---|
| 155 | RTEMS Directory: /home/joel/newbsd/git/libbsd-8.2 |
---|
| 156 | FreeBSD Directory: /home/joel/newbsd/libbsd/freebsd-8.2 |
---|
| 157 | Direction: forward |
---|
| 158 | Generating into /home/joel/newbsd/git/libbsd-8.2 |
---|
| 159 | 0 files were changed. |
---|
| 160 | ---- |
---|
| 161 | |
---|