source: rtems/doc/bsp_howto/support.t @ 0eb595a8

4.104.114.95
Last change on this file since 0eb595a8 was 0eb595a8, checked in by Joel Sherrill <joel.sherrill@…>, on 08/22/08 at 16:38:00

2008-08-22 Joel Sherrill <joel.sherrill@…>

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