source: rtems/bsps/powerpc/beatnik/net/porting/README @ 031df391

5
Last change on this file since 031df391 was 031df391, checked in by Sebastian Huber <sebastian.huber@…>, on Apr 23, 2018 at 7:53:31 AM

bsps: Move legacy network drivers to bsps

This patch is a part of the BSP source reorganization.

Update #3285.

  • Property mode set to 100644
File size: 3.3 KB
Line 
1Templates to help porting freebsd networking drivers
2to rtems (focus on i386 and powerpc) using a 'quick and dirty'
3approach.
4This is not an elegant piece of software -- be warned.
5
6/* Copyright: Till Straumann <strauman@slac.stanford.edu>, 2005;
7 * License:   see LICENSE file.
8 */
9
10Usage:
11
12  A obtain the freebsd driver source. It usually is made
13    up of a
14     if_XXX.c       --  core driver
15     if_XXXreg.h    --  core header
16     if_XXXvar.h    --  some have it, some don't
17     if_XXX_<bus>.c --  glue to integrate the core
18                        driver with different environments
19                        (such as pccard, pci, ...). There
20                        are several of these.
21
22        Note that you might have to get an older version
23        as some structures and interfaces may have undergone
24        significant changes since the bsd/networking version that
25        was ported to rtems.
26
27  B Copy the Makefile and rtemscompat_defs.h templates to the
28    driver source dir and edit them.
29
30  C Edit if_XXXreg.h and comment all unneeded fields from the
31    'softc' structure declaration with
32
33    #ifndef __rtems__
34    #endif
35
36    In particular, the bushandle field (as defined in rtemscompat_defs.h)
37    above, see comments in the template) must be re-declared:
38
39    #ifndef __rtems__
40        bus_space_handle_t  XXX_bhandle;
41        #else
42        unsigned                        XXX_bhandle;
43        unsigned char           irq_no;
44        unsigned char           b,d,f;  /* PCI tuple; needed for PCI only */
45        rtems_id                        tid;    /* driver task id */
46        #endif
47
48    Later, the compilation attempts will help identifying
49    fields that need to be removed.
50
51        I like the #ifdef __rtems__  construct as it minimizes changes
52    to the source thus making merging updated driver versions easier.
53
54  D Edit if_XXX.c; at the very top, include the lines
55
56    #ifdef __rtems__
57    #include <rtemscompat.h>
58        #endif
59
60        use the #ifndef __rtems__ #endif construct to comment
61    unneeded / unsupported inclusion of headers and code pieces.
62
63    - inclusion of net/if_media.h must usually be mapped to
64                   libchip/if_media.h
65   
66    comment all vm, machine, bus, mii etc. related headers.
67
68    - replace inclusion of if_XXXreg.h by
69
70     #include "if_XXXreg.h"
71     #include <rtemscompat1.h>
72
73    - work through the if_XXX.c and if_XXXreg.h files commenting
74    stuff until if_XXX.c compiles. This might involve hacking
75    the helper headers.
76
77    - pay attention to endian issues; things may need to be fixed!
78
79    - at the top where the freebsd 'methods' and the like are
80    commented, add a definition of the driver methods for RTEMS:
81
82    #ifdef __rtems__
83        net_drv_tbl_t METHODS = {
84                n_probe  : XXX_probe,
85                n_attach : XXX_attach,
86                n_detach : XXX_detach,  /* optional; */
87                n_intr   : XXX_intr,    /* freebsd ISR; executed from daemon under RTEMS */
88        };
89    #endif
90
91        - make sure all the if_xxx methods are set; in particular,
92      set
93                sc->if_output = ether_output;
94
95        - on input:
96                you can use DO_ETHER_INPUT_SKIPPING_ETHER_HEADER() macro
97                -- if you don't MAKE SURE THE RECEIVING INTERFACE IS SET
98                in the mbuf packet header!!!
99
100  E create 'rtems_<chip>_setup()' to probe for devices and
101    set the softc struct's base address, interrupt line and
102    bus/dev/fun triple (PCI only).
103    For PCI devices, a generic setup routine already comes with
104    porting/if_xxx_rtems.c -> nothing needs to be written!
Note: See TracBrowser for help on using the repository browser.