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 | RTEMS has a multi-layered approach to portability. This is done to maximize the |
---|
12 | amount of software that can be reused. Much of the RTEMS source code can be |
---|
13 | reused on all RTEMS platforms. Other parts of the executive are specific to |
---|
14 | hardware in some sense. RTEMS classifies target dependent code based upon its |
---|
15 | dependencies into one of the following categories. |
---|
16 | |
---|
17 | - CPU dependent |
---|
18 | |
---|
19 | - Board dependent |
---|
20 | |
---|
21 | - Peripheral dependent |
---|
22 | |
---|
23 | CPU Dependent |
---|
24 | ============= |
---|
25 | |
---|
26 | This class of code includes the foundation routines for the executive proper |
---|
27 | such as the context switch and the interrupt subroutine implementations. |
---|
28 | Sources for the supported processor families can be found in |
---|
29 | ``cpukit/score/cpu``. A good starting point for a new family of processors is |
---|
30 | the ``no_cpu`` directory, which holds both prototypes and descriptions of each |
---|
31 | needed CPU dependent function. |
---|
32 | |
---|
33 | CPU dependent code is further subcategorized if the implementation is dependent |
---|
34 | on a particular CPU model. For example, the MC68000 and MC68020 processors are |
---|
35 | both members of the m68k CPU family but there are significant differences |
---|
36 | between these CPU models which RTEMS must take into account. |
---|
37 | |
---|
38 | The source code found in the ``cpukit/score/cpu`` is required to only depend |
---|
39 | upon the CPU model variations that GCC distinguishes for the purposes of |
---|
40 | multilib'ing. Multilib is the term the GNU community uses to refer to building |
---|
41 | a single library source multiple times with different compiler options so the |
---|
42 | binary code generated is compatible. As an example, from GCC's perspective, |
---|
43 | many PowerPC CPU models are just a PPC603e. Remember that GCC only cares about |
---|
44 | the CPU code itself and need not be aware of any peripherals. In the embedded |
---|
45 | community, we are exposed to thousands of CPU models which are all based upon |
---|
46 | only a relative small number of CPU cores. |
---|
47 | |
---|
48 | Similarly for the SPARC/ERC32 BSP, the ``RTEMS_CPU`` is specified as ``erc32`` |
---|
49 | which is the name of the CPU model and BSP for this SPARC V7 system on chip. |
---|
50 | But the multilib variant used is actually ``v7`` which indicates the ERC32 CPU |
---|
51 | core is a SPARC V7. |
---|
52 | |
---|
53 | Board Dependent |
---|
54 | =============== |
---|
55 | |
---|
56 | This class of code provides the most specific glue between RTEMS and a |
---|
57 | particular board. This code is represented by the Board Support Packages and |
---|
58 | associated Device Drivers. Sources for the BSPs included in the RTEMS |
---|
59 | distribution are located in the directory ``c/src/lib/libbsp``. The BSP source |
---|
60 | directory is further subdivided based on the CPU family and BSP. |
---|
61 | |
---|
62 | Some BSPs may support multiple board models within a single board family. This |
---|
63 | is necessary when the board supports multiple variants on a single base board. |
---|
64 | For example, the Motorola MVME162 board family has a fairly large number of |
---|
65 | variations based upon the particular CPU model and the peripherals actually |
---|
66 | placed on the board. |
---|
67 | |
---|
68 | Peripheral Dependent |
---|
69 | ==================== |
---|
70 | |
---|
71 | This class of code provides a reusable library of peripheral device drivers |
---|
72 | which can be tailored easily to a particular board. The libchip library is a |
---|
73 | collection of reusable software objects that correspond to standard |
---|
74 | controllers. Just as the hardware engineer chooses a standard controller when |
---|
75 | designing a board, the goal of this library is to let the software engineer do |
---|
76 | the same thing. |
---|
77 | |
---|
78 | The source code for the reusable peripheral driver library may be found in the |
---|
79 | directory ``c/src/lib/libchip``. The source code is further divided based upon |
---|
80 | the class of hardware. Example classes include serial communications |
---|
81 | controllers, real-time clocks, non-volatile memory, and network controllers. |
---|
82 | |
---|
83 | Questions to Ask |
---|
84 | ================ |
---|
85 | |
---|
86 | When evaluating what is required to support RTEMS applications on a particular |
---|
87 | target board, the following questions should be asked: |
---|
88 | |
---|
89 | - Does a BSP for this board exist? |
---|
90 | |
---|
91 | - Does a BSP for a similar board exists? |
---|
92 | |
---|
93 | - Is the board's CPU supported? |
---|
94 | |
---|
95 | If there is already a BSP for the board, then things may already be ready to |
---|
96 | start developing application software. All that remains is to verify that the |
---|
97 | existing BSP provides device drivers for all the peripherals on the board that |
---|
98 | the application will be using. For example, the application in question may |
---|
99 | require that the board's Ethernet controller be used and the existing BSP may |
---|
100 | not support this. |
---|
101 | |
---|
102 | If the BSP does not exist and the board's CPU model is supported, then examine |
---|
103 | the reusable chip library and existing BSPs for a close match. Other BSPs and |
---|
104 | libchip provide starting points for the development of a new BSP. It is often |
---|
105 | possible to copy existing components in the reusable chip library or device |
---|
106 | drivers from BSPs from different CPU families as the starting point for a new |
---|
107 | device driver. This will help reduce the development effort required. |
---|
108 | |
---|
109 | If the board's CPU family is supported but the particular CPU model on that |
---|
110 | board is not, then the RTEMS port to that CPU family will have to be augmented. |
---|
111 | After this is done, development of the new BSP can proceed. |
---|
112 | |
---|
113 | Otherwise both CPU dependent code and the BSP will have to be written. |
---|
114 | |
---|
115 | This type of development often requires specialized skills and there are people |
---|
116 | in the community who provide those services. If you need help in making these |
---|
117 | modifications to RTEMS try a search in a search engine with something like |
---|
118 | "rtems support". The RTEMS Project encourages users to use support services |
---|
119 | however we do not endorse any providers. |
---|
120 | |
---|
121 | CPU Dependent Executive Files |
---|
122 | ============================= |
---|
123 | |
---|
124 | The CPU dependent files in the RTEMS executive source code are found in the |
---|
125 | following directory: |
---|
126 | |
---|
127 | .. code-block:: c |
---|
128 | |
---|
129 | cpukit/score/cpu/<CPU> |
---|
130 | |
---|
131 | where <CPU> is replaced with the CPU family name. |
---|
132 | |
---|
133 | Within each CPU dependent directory inside the executive proper is a file named |
---|
134 | ``<CPU>.h`` which contains information about each of the supported CPU models |
---|
135 | within that family. |
---|
136 | |
---|
137 | CPU Dependent Support Files |
---|
138 | =========================== |
---|
139 | |
---|
140 | The CPU dependent support files contain routines which aid in the development |
---|
141 | of applications using that CPU family. For example, the support routines |
---|
142 | may contain standard trap handlers for alignment or floating point exceptions |
---|
143 | or device drivers for peripheral controllers found on the CPU itself. |
---|
144 | This class of code may be found in the following directory: |
---|
145 | |
---|
146 | .. code-block:: c |
---|
147 | |
---|
148 | c/src/lib/libcpu/<CPU> |
---|
149 | |
---|
150 | CPU model dependent support code is found in the following directory: |
---|
151 | |
---|
152 | .. code-block:: c |
---|
153 | |
---|
154 | c/src/lib/libcpu/<CPU>/<CPU_MODEL> |
---|
155 | |
---|
156 | <CPU_MODEL> may be a specific CPU model name or a name indicating a CPU core or |
---|
157 | a set of related CPU models. The file ``configure.ac`` in each |
---|
158 | ``c/src/lib/libcpu/<CPU>`` directory contains the logic which enables the |
---|
159 | appropriate subdirectories for the specific CPU model your BSP has. |
---|
160 | |
---|
161 | Board Support Package Structure |
---|
162 | =============================== |
---|
163 | |
---|
164 | The BSPs are all under the ``c/src/lib/libbsp`` directory. Below this |
---|
165 | directory, there is a subdirectory for each CPU family. Each BSP is found |
---|
166 | under the subdirectory for the appropriate processor family (arm, powerpc, |
---|
167 | sparc, etc.). In addition, there is source code available which may be shared |
---|
168 | across all BSPs regardless of the CPU family or just across BSPs within a |
---|
169 | single CPU family. This results in a BSP using the following directories: |
---|
170 | |
---|
171 | .. code-block:: c |
---|
172 | |
---|
173 | c/src/lib/libbsp/shared |
---|
174 | c/src/lib/libbsp/<CPU>/shared |
---|
175 | c/src/lib/libbsp/<CPU>/<BSP> |
---|
176 | |
---|
177 | Under each BSP specific directory, there is a collection of subdirectories. |
---|
178 | For commonly provided functionality, the BSPs follow a convention on |
---|
179 | subdirectory naming. The following list describes the commonly found |
---|
180 | subdirectories under each BSP. |
---|
181 | |
---|
182 | - ``console``: |
---|
183 | is technically the serial driver for the BSP rather than just a console |
---|
184 | driver, it deals with the board UARTs (i.e. serial devices). |
---|
185 | |
---|
186 | - ``clock``: |
---|
187 | support for the clock tick - a regular time basis to the kernel. |
---|
188 | |
---|
189 | - ``timer``: |
---|
190 | support of timer devices. |
---|
191 | |
---|
192 | - ``rtc`` or ``tod``: |
---|
193 | support for the hardware real-time clock. |
---|
194 | |
---|
195 | - ``nvmem``: |
---|
196 | support for non-volatile memory such as EEPROM or Flash. |
---|
197 | |
---|
198 | - ``network``: |
---|
199 | the Ethernet driver. |
---|
200 | |
---|
201 | - ``shmsupp``: |
---|
202 | support of shared memory driver MPCI layer in a multiprocessor system, |
---|
203 | |
---|
204 | - ``include``: |
---|
205 | include files for this BSP. |
---|
206 | |
---|
207 | - ``gnatsupp``: |
---|
208 | BSP specific support for the GNU Ada run-time. Each BSP that wishes to have |
---|
209 | the possibility to map faults or exceptions into Ada language exceptions or |
---|
210 | hardware interrupts into Ada interrupt tasks must provide this support. |
---|
211 | |
---|
212 | There may be other directories in the BSP tree and the name should be |
---|
213 | indicative of the functionality of the code within that directory. |
---|
214 | |
---|
215 | The build order of the BSP is determined by the Makefile structure. This |
---|
216 | structure is discussed in more detail in the `Makefiles`_ chapter. |
---|
217 | |
---|
218 | .. sidebar: |
---|
219 | |
---|
220 | This manual refers to the gen68340 BSP for numerous concrete examples. You |
---|
221 | should have a copy of the gen68340 BSP available while reading this piece of |
---|
222 | documentation. This BSP is located in the following directory: |
---|
223 | |
---|
224 | .. code-block:: c |
---|
225 | |
---|
226 | c/src/lib/libbsp/m68k/gen68340 |
---|
227 | |
---|
228 | Later in this document, the $BSP340_ROOT label will be used to refer to this |
---|
229 | directory. |
---|