source: rtems-docs/bsp_howto/target_dependant_files.rst @ f916fca

4.115
Last change on this file since f916fca was d389819, checked in by Amar Takhar <amar@…>, on 01/18/16 at 05:37:40

Convert all Unicode to ASCII(128)

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