source: rtems/doc/bsp_howto/support.t @ 48bff53b

4.115
Last change on this file since 48bff53b was 48bff53b, checked in by Sebastian Huber <sebastian.huber@…>, on 12/06/12 at 16:47:30

score: rtems_initialize_start_multitasking()

Do not return from rtems_initialize_start_multitasking() and call
rtems_fatal() instead with a fatal source of RTEMS_FATAL_SOURCE_EXIT and
a fatal code with the exit status.

Remove all bsp_cleanup() functions. The boot_card() is now a no return
function.

  • Property mode set to 100644
File size: 11.8 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-2011.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5
6@chapter Miscellaneous Support Files
7
8@section GCC Compiler Specifications File
9
10The file @code{bsp_specs} defines the start files and libraries
11that are always used with this BSP.  The format of this file
12is admittedly cryptic and this document will make no attempt
13to explain it completely.  Below is the @code{bsp_specs}
14file from the PowerPC psim BSP:
15
16@example
17@group
18%rename endfile old_endfile
19%rename startfile old_startfile
20%rename link old_link
21
22*startfile:
23%@{!qrtems: %(old_startfile)@} \
24%@{!nostdlib: %@{qrtems: ecrti%O%s rtems_crti%O%s crtbegin.o%s start.o%s@}@}
25
26*link:
27%@{!qrtems: %(old_link)@} %@{qrtems: -Qy -dp -Bstatic -e _start -u __vectors@}
28
29*endfile:
30%@{!qrtems: %(old_endfile)@} %@{qrtems: crtend.o%s ecrtn.o%s@}
31@end group
32@end example
33
34The first section of this file renames the built-in definition of
35some specification variables so they can be augmented without
36embedded their original definition.  The subsequent sections
37specify what behavior is expected when the @code{-qrtems} or
38@code{-qrtems_debug} option is specified.
39
40The @code{*startfile} section specifies that the BSP specific file
41@code{start.o} will be used instead of @code{crt0.o}.  In addition,
42various EABI support files (@code{ecrti.o} etc.) will be linked in with
43the executable.
44
45The @code{*link} section adds some arguments to the linker when it is
46invoked by GCC to link an application for this BSP.
47
48The format of this file is specific to the GNU Compiler Suite.  The
49argument used to override and extend the compiler built-in specifications
50is available in all recent GCC versions.  The @code{-specs} option is
51present in all @code{egcs} distributions and @code{gcc} distributions
52starting with version 2.8.0.
53
54@section README Files
55
56Most BSPs provide one or more @code{README} files.  Generally, there
57is a @code{README} file at the top of the BSP source.  This file
58describes the board and its hardware configuration, provides vendor
59information, local configuration information, information on downloading
60code to the board, debugging, etc..  The intent of this
61file is to help someone begin to use the BSP faster.
62
63A @code{README} file in a BSP subdirectory typically explains something
64about the contents of that subdirectory in greater detail.  For example,
65it may list the documentation available for a particular peripheral
66controller and how to obtain that documentation.  It may also explain some
67particularly cryptic part of the software in that directory or provide
68rationale on the implementation.
69
70@section times
71
72This file contains the results of the RTEMS Timing Test Suite.  It is
73in a standard format so that results from one BSP can be easily compared
74with those of another target board.
75
76If a BSP supports multiple variants, then there may be multiple @code{times}
77files.  Usually these are named @code{times.VARIANTn}.
78
79@section Tools Subdirectory
80
81Some BSPs provide additional tools that aid in using the target board.
82These tools run on the development host and are built as part of building
83the BSP.  Most common is a script to automate running the RTEMS Test Suites
84on the BSP.  Examples of this include:
85
86@itemize @bullet
87
88@item @code{powerpc/psim} includes scripts to ease use of the simulator
89
90@item @code{m68k/mvme162} includes a utility to download across the
91VMEbus into target memory if the host is a VMEbus board in the same
92chasis.
93
94@end itemize
95
96@section bsp.h Include File
97
98The file @code{include/bsp.h} contains prototypes and definitions
99specific to this board.  Every BSP is required to provide a @code{bsp.h}.
100The best approach to writing a @code{bsp.h} is copying an existing one
101as a starting point.
102
103Many @code{bsp.h} files provide prototypes of variables defined
104in the linker script (@code{linkcmds}).
105
106@section tm27.h Include File
107
108The @code{tm27} test from the RTEMS Timing Test Suite is designed to measure the length of time required to vector to and return from an interrupt handler. This test requires some help from the BSP to know how to cause and manipulate the interrupt source used for this measurement.  The following is a list of these:
109
110@itemize @bullet
111@item @code{MUST_WAIT_FOR_INTERRUPT} - modifies behavior of @code{tm27}.
112
113@item @code{Install_tm27_vector} - installs the interrupt service
114routine for the Interrupt Benchmark Test (@code{tm27}).
115
116@item @code{Cause_tm27_intr} - generates the interrupt source
117used in the Interrupt Benchmark Test (@code{tm27}).
118
119@item @code{Clear_tm27_intr} - clears the interrupt source
120used in the Interrupt Benchmark Test (@code{tm27}).
121
122@item @code{Lower_tm27_intr} - lowers the interrupt mask so the
123interrupt source used in the Interrupt Benchmark Test (@code{tm27})
124can generate a nested interrupt.
125
126@end itemize
127
128All members of the Timing Test Suite are designed to run @b{WITHOUT}
129the Clock Device Driver installed.  This increases the predictability
130of the tests' execution as well as avoids occassionally including the
131overhead of a clock tick interrupt in the time reported.  Because of
132this it is sometimes possible to use the clock tick interrupt source
133as the source of this test interrupt.  On other architectures, it is
134possible to directly force an interrupt to occur.
135
136@section Calling Overhead File
137
138The file @code{include/coverhd.h} contains the overhead associated
139with invoking each directive.  This overhead consists of the execution
140time required to package the parameters as well as to execute the "jump to
141subroutine" and "return from subroutine" sequence.  The intent of this
142file is to help separate the calling overhead from the actual execution
143time of a directive.  This file is only used by the tests in the
144RTEMS Timing Test Suite.
145
146The numbers in this file are obtained by running the "Timer Overhead"
147@code{tmoverhd} test.  The numbers in this file may be 0 and no
148overhead is subtracted from the directive execution times reported by
149the Timing Suite.
150
151There is a shared implementation of @code{coverhd.h} which sets all of
152the overhead constants to 0.  On faster processors, this is usually the
153best alternative for the BSP as the calling overhead is extremely small.
154This file is located at:
155
156@example
157c/src/lib/libbsp/shared/include/coverhd.h
158@end example
159
160@section sbrk() Implementation
161
162Although nearly all BSPs give all possible memory to the C Program Heap
163at initialization, it is possible for a BSP to configure the initial
164size of the heap small and let it grow on demand.  If the BSP wants
165to dynamically extend the heap used by the C Library memory allocation
166routines (i.e. @code{malloc} family), then the@code{sbrk} routine must
167be functional.  The following is the prototype for this routine:
168
169@example
170void * sbrk(size_t increment)
171@end example
172
173The @code{increment} amount is based upon the @code{sbrk_amount}
174parameter passed to the @code{bsp_libc_init} during system initialization.
175Historically initialization of the C Library was done as part of the
176BSP's Pretasking Hook but now the BSP Boot Card Framework can perform
177this operation.
178
179@findex CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
180If your BSP does not want to support dynamic heap extension, then you do not have to do anything special.  However, if you want to support @code{sbrk}, you must provide an implementation of this method and define @code{CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK} in @code{bsp.h}.  This informs @code{rtems/confdefs.h} to configure the Malloc Family Extensions which support @code{sbrk}.
181
182@section bsp_fatal_extension() - Cleanup the Hardware
183
184The @code{bsp_fatal_extension()} is an optional BSP specific initial extension
185invoked once a fatal system state is reached.  Most of the BSPs use the same
186shared version of @code{bsp_fatal_extension()} that does nothing or performs a
187system reset.  This implementation is located in the following file:
188
189@example
190c/src/lib/libbsp/shared/bspclean.c
191@end example
192
193The @code{bsp_fatal_extension()} routine can be used to return to a ROM
194monitor, insure that interrupt sources are disabled, etc..  This routine is the
195last place to ensure a clean shutdown of the hardware.  The fatal source,
196internal error indicator, and the fatal code arguments are available to
197evaluate the fatal condition.  All of the non-fatal shutdown sequences
198ultimately pass their exit status to @code{rtems_shutdown_executive} and this
199is what is passed to this routine in case the fatal source is
200RTEMS_FATAL_SOURCE_EXIT.
201
202On some BSPs, it prints a message indicating that the application
203completed execution and waits for the user to press a key before
204resetting the board.  The PowerPC/gen83xx and PowerPC/gen5200 BSPs do
205this when they are built to support the FreeScale evaluation boards.
206This is convenient when using the boards in a development environment
207and may be disabled for production use.
208
209@section Configuration Macros
210
211Each BSP can define macros in bsp.h which alter some of the the default configuration parameters in @code{rtems/confdefs.h}.  This section describes those macros:
212
213@itemize @bullet
214
215@findex CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
216@item @code{CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK} must be defined if the
217BSP has proper support for @code{sbrk}.  This is discussed in more detail
218in the previous section.
219
220@findex BSP_IDLE_TASK_BODY
221@item @code{BSP_IDLE_TASK_BODY} may be defined to the entry point of a
222BSP specific IDLE thread implementation.  This may be overridden if the
223application provides its own IDLE task implementation.
224
225@findex BSP_IDLE_TASK_STACK_SIZE
226@item @code{BSP_IDLE_TASK_STACK_SIZE} may be defined to the desired
227default stack size for the IDLE task as recommended when using this BSP.
228
229@findex BSP_INTERRUPT_STACK_SIZE
230@item @code{BSP_INTERRUPT_STACK_SIZE} may be defined to the desired default interrupt stack size as recommended when using this BSP.  This is sometimes required when the BSP developer has knowledge of stack intensive interrupt handlers.
231
232@findex BSP_ZERO_WORKSPACE_AUTOMATICALLY
233@item @code{BSP_ZERO_WORKSPACE_AUTOMATICALLY} is defined when the BSP
234requires that RTEMS zero out the RTEMS C Program Heap at initialization.
235If the memory is already zeroed out by a test sequence or boot ROM,
236then the boot time can be reduced by not zeroing memory twice.
237
238@findex BSP_DEFAULT_UNIFIED_WORK_AREAS
239@item @code{BSP_DEFAULT_UNIFIED_WORK_AREAS} is defined when the BSP
240recommends that the unified work areas configuration should always
241be used.  This is desirable when the BSP is known to always have very
242little RAM and thus saving memory by any means is desirable.
243
244@end itemize
245
246@section set_vector() - Install an Interrupt Vector
247
248On targets with Simple Vectored Interrupts, the BSP must provide
249an implementation of the @code{set_vector} routine.  This routine is
250responsible for installing an interrupt vector.  It invokes the support
251routines necessary to install an interrupt handler as either a "raw"
252or an RTEMS interrupt handler.  Raw handlers bypass the RTEMS interrupt
253structure and are responsible for saving and restoring all their own
254registers.  Raw handlers are useful for handling traps, debug vectors,
255etc..
256
257The @code{set_vector} routine is a central place to perform interrupt
258controller manipulation and encapsulate that information.  It is usually
259implemented as follows:
260
261@example
262@group
263rtems_isr_entry set_vector(                     /* returns old vector */
264  rtems_isr_entry     handler,                  /* isr routine        */
265  rtems_vector_number vector,                   /* vector number      */
266  int                 type                      /* RTEMS or RAW intr  */
267)
268@{
269  if the type is RAW
270    install the raw vector
271  else
272    use rtems_interrupt_catch to install the vector
273
274  perform any interrupt controller necessary to unmask
275    the interrupt source
276
277  return the previous handler
278@}
279@end group
280@end example
281
282@b{NOTE:}  The i386, PowerPC and ARM ports use a Programmable
283Interrupt Controller model which does not require the BSP to implement
284@code{set_vector}.  BSPs for these architectures must provide a different
285set of support routines.
286
Note: See TracBrowser for help on using the repository browser.