1 | .. comment SPDX-License-Identifier: CC-BY-SA-4.0 |
---|
2 | |
---|
3 | .. COMMENT: COPYRIGHT (c) 1988-2008. |
---|
4 | .. COMMENT: On-Line Applications Research Corporation (OAR). |
---|
5 | .. COMMENT: All rights reserved. |
---|
6 | |
---|
7 | |
---|
8 | Target Dependent Files |
---|
9 | ********************** |
---|
10 | |
---|
11 | .. warning:: |
---|
12 | |
---|
13 | This chapter contains outdated and confusing information. |
---|
14 | |
---|
15 | RTEMS has a multi-layered approach to portability. This is done to maximize the |
---|
16 | amount of software that can be reused. Much of the RTEMS source code can be |
---|
17 | reused on all RTEMS platforms. Other parts of the executive are specific to |
---|
18 | hardware in some sense. RTEMS classifies target dependent code based upon its |
---|
19 | dependencies into one of the following categories. |
---|
20 | |
---|
21 | - CPU dependent |
---|
22 | |
---|
23 | - Board dependent |
---|
24 | |
---|
25 | - Peripheral dependent |
---|
26 | |
---|
27 | CPU Dependent |
---|
28 | ============= |
---|
29 | |
---|
30 | This class of code includes the foundation routines for the executive proper |
---|
31 | such as the context switch and the interrupt subroutine implementations. |
---|
32 | Sources for the supported processor families can be found in |
---|
33 | ``cpukit/score/cpu``. A good starting point for a new family of processors is |
---|
34 | the ``no_cpu`` directory, which holds both prototypes and descriptions of each |
---|
35 | needed CPU dependent function. |
---|
36 | |
---|
37 | CPU dependent code is further subcategorized if the implementation is dependent |
---|
38 | on a particular CPU model. For example, the MC68000 and MC68020 processors are |
---|
39 | both members of the m68k CPU family but there are significant differences |
---|
40 | between these CPU models which RTEMS must take into account. |
---|
41 | |
---|
42 | The source code found in the ``cpukit/score/cpu`` is required to only depend |
---|
43 | upon the CPU model variations that GCC distinguishes for the purposes of |
---|
44 | multilib'ing. Multilib is the term the GNU community uses to refer to building |
---|
45 | a single library source multiple times with different compiler options so the |
---|
46 | binary code generated is compatible. As an example, from GCC's perspective, |
---|
47 | many PowerPC CPU models are just a PPC603e. Remember that GCC only cares about |
---|
48 | the CPU code itself and need not be aware of any peripherals. In the embedded |
---|
49 | community, we are exposed to thousands of CPU models which are all based upon |
---|
50 | only a relative small number of CPU cores. |
---|
51 | |
---|
52 | Similarly for the SPARC/ERC32 BSP, the ``RTEMS_CPU`` is specified as ``erc32`` |
---|
53 | which is the name of the CPU model and BSP for this SPARC V7 system on chip. |
---|
54 | But the multilib variant used is actually ``v7`` which indicates the ERC32 CPU |
---|
55 | core is a SPARC V7. |
---|
56 | |
---|
57 | Board Dependent |
---|
58 | =============== |
---|
59 | |
---|
60 | This class of code provides the most specific glue between RTEMS and a |
---|
61 | particular board. This code is represented by the Board Support Packages and |
---|
62 | associated Device Drivers. Sources for the BSPs included in the RTEMS |
---|
63 | distribution are located in the directory |
---|
64 | `bsps <https://git.rtems.org/rtems/tree/bsps>`_. The BSP source directory is |
---|
65 | further subdivided based on the CPU family and BSP. |
---|
66 | |
---|
67 | Some BSPs may support multiple board models within a single board family. This |
---|
68 | is necessary when the board supports multiple variants on a single base board. |
---|
69 | For example, the Motorola MVME162 board family has a fairly large number of |
---|
70 | variations based upon the particular CPU model and the peripherals actually |
---|
71 | placed on the board. |
---|
72 | |
---|
73 | Peripheral Dependent |
---|
74 | ==================== |
---|
75 | |
---|
76 | This class of code provides a reusable library of peripheral device drivers |
---|
77 | which can be tailored easily to a particular board. The libchip library is a |
---|
78 | collection of reusable software objects that correspond to standard |
---|
79 | controllers. Just as the hardware engineer chooses a standard controller when |
---|
80 | designing a board, the goal of this library is to let the software engineer do |
---|
81 | the same thing. |
---|
82 | |
---|
83 | The source code for the reusable peripheral driver library may be found in the |
---|
84 | directory |
---|
85 | `cpukit/dev <https://git.rtems.org/rtems/tree/cpukit/dev>`_ or |
---|
86 | `bsps/shared/dev <https://git.rtems.org/rtems/tree/bsps/shared/dev>`_. The |
---|
87 | source code is further divided based upon the class of hardware. Example |
---|
88 | classes include serial communications controllers, real-time clocks, |
---|
89 | non-volatile memory, and network controllers. |
---|
90 | |
---|
91 | Questions to Ask |
---|
92 | ================ |
---|
93 | |
---|
94 | When evaluating what is required to support RTEMS applications on a particular |
---|
95 | target board, the following questions should be asked: |
---|
96 | |
---|
97 | - Does a BSP for this board exist? |
---|
98 | |
---|
99 | - Does a BSP for a similar board exists? |
---|
100 | |
---|
101 | - Is the board's CPU supported? |
---|
102 | |
---|
103 | If there is already a BSP for the board, then things may already be ready to |
---|
104 | start developing application software. All that remains is to verify that the |
---|
105 | existing BSP provides device drivers for all the peripherals on the board that |
---|
106 | the application will be using. For example, the application in question may |
---|
107 | require that the board's Ethernet controller be used and the existing BSP may |
---|
108 | not support this. |
---|
109 | |
---|
110 | If the BSP does not exist and the board's CPU model is supported, then examine |
---|
111 | the reusable chip library and existing BSPs for a close match. Other BSPs and |
---|
112 | libchip provide starting points for the development of a new BSP. It is often |
---|
113 | possible to copy existing components in the reusable chip library or device |
---|
114 | drivers from BSPs from different CPU families as the starting point for a new |
---|
115 | device driver. This will help reduce the development effort required. |
---|
116 | |
---|
117 | If the board's CPU family is supported but the particular CPU model on that |
---|
118 | board is not, then the RTEMS port to that CPU family will have to be augmented. |
---|
119 | After this is done, development of the new BSP can proceed. |
---|
120 | |
---|
121 | Otherwise both CPU dependent code and the BSP will have to be written. |
---|
122 | |
---|
123 | This type of development often requires specialized skills and there are people |
---|
124 | in the community who provide those services. If you need help in making these |
---|
125 | modifications to RTEMS try a search in a search engine with something like |
---|
126 | "RTEMS support". The RTEMS Project encourages users to use support services |
---|
127 | however we do not endorse any providers. |
---|
128 | |
---|
129 | CPU Dependent Executive Files |
---|
130 | ============================= |
---|
131 | |
---|
132 | The CPU dependent files in the RTEMS executive source code are found in the |
---|
133 | ``cpukit/score/cpu/${RTEMS_CPU}`` directories. The ``${RTEMS_CPU}`` is a |
---|
134 | particular architecture, e.g. arm, powerpc, riscv, sparc, etc. |
---|
135 | |
---|
136 | Within each CPU dependent directory inside the executive proper is a file named |
---|
137 | :file:`cpu.h` which contains information about each of the supported CPU models |
---|
138 | within that family. |
---|
139 | |
---|
140 | Board Support Package Structure |
---|
141 | =============================== |
---|
142 | |
---|
143 | The BSPs are all under the `bsps <https://git.rtems.org/rtems/tree/bsps>`_ |
---|
144 | directory. The structure in this source subtree is: |
---|
145 | |
---|
146 | * ``bsps/shared`` |
---|
147 | * ``bsps/${RTEMS_CPU}/shared`` |
---|
148 | * ``bsps/${RTEMS_CPU}/${RTEMS_BSP_FAMILY}`` |
---|
149 | |
---|
150 | The ``${RTEMS_CPU}`` is a particular architecture, e.g. arm, powerpc, riscv, |
---|
151 | sparc, etc. The ``shared`` directories contain code shared by all BSPs or BSPs |
---|
152 | of a particular architecture. The ``${RTEMS_BSP_FAMILY}`` directories contain |
---|
153 | BSPs for a particular system on chip (SoC) or processor family. |
---|
154 | |
---|
155 | Use the following structure under the |
---|
156 | ``bsps/${RTEMS_CPU}/${RTEMS_BSP_FAMILY}``: |
---|
157 | |
---|
158 | * :file:`ata` - the legacy ATA/IDE driver |
---|
159 | * :file:`btimer` - the legacy benchmark timer driver |
---|
160 | * :file:`cache` - cache controller support |
---|
161 | * :file:`clock` - the clock driver |
---|
162 | * :file:`config` - build system configuration files |
---|
163 | * :file:`console` - the console driver |
---|
164 | * :file:`contrib` - imports of external sources |
---|
165 | |
---|
166 | * the layout of external sources should be used as is if possible |
---|
167 | |
---|
168 | * :file:`i2c` - the I2C driver |
---|
169 | * :file:`include` - public header files |
---|
170 | * :file:`irq` - the interrupt controller support |
---|
171 | * :file:`mpci` - support for heterogeneous multiprocessing |
---|
172 | (``RTEMS_MULTIPROCESSING``) |
---|
173 | * :file:`net` - legacy network stack drivers |
---|
174 | * :file:`rtc` - the RTC driver |
---|
175 | * :file:`spi` - the SPI driver |
---|
176 | * :file:`start` - everything required to run a minimal application without |
---|
177 | devices |
---|
178 | |
---|
179 | * :file:`start.S` - lowest level startup code |
---|
180 | * :file:`bspstart.c` - low level startup code |
---|
181 | * :file:`bspsmp.c` - SMP support |
---|
182 | * :file:`linkcmds` - a linker command file |
---|