source: rtems/doc/bsp_howto/support.t @ bc950e87

4.104.114.84.95
Last change on this file since bc950e87 was bc950e87, checked in by Joel Sherrill <joel.sherrill@…>, on 11/19/98 at 16:02:06

Applied updates from remote work while doing class.

  • Property mode set to 100644
File size: 9.0 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-1998.
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 cpp old_cpp
22%rename lib old_lib
23%rename endfile old_endfile
24%rename startfile old_startfile
25%rename link old_link
26
27*cpp:
28%(old_cpp) %@{qrtems: -D__embedded__@} -Asystem(embedded)
29
30*lib:
31%@{!qrtems: %(old_lib)@} %@{qrtems: --start-group \
32%@{!qrtems_debug: -lrtemsall@} %@{qrtems_debug: -lrtemsall_g@} \
33-lc -lgcc --end-group  ecrtn%O%s \
34%@{!qnolinkcmds: -T linkcmds%s@}@}
35
36*startfile:
37%@{!qrtems: %(old_startfile)@} %@{qrtems:  ecrti%O%s \
38%@{!qrtems_debug: startsim.o%s@} \
39%@{qrtems_debug: startsim_g.o%s@}@}
40
41*link:
42%@{!qrtems: %(old_link)@} %@{qrtems: -Qy -dp -Bstatic \
43-T linkcmds%s -e _start -u __vectors@}
44@end group
45@end example
46
47The first section of this file renames the built-in definition of
48some specification variables so they can be augmented without
49embedded their original definition.  The subsequent sections
50specify what behavior is expected when the @code{-qrtems} or
51@code{-qrtems_debug} option is specified. 
52
53The @code{*cpp} definition specifies that when @code{-qrtems}
54is specified, predefine the preprocessor symbol @code{__embedded__}.
55
56The @code{*lib} section insures that the RTEMS library, BSP specific
57linker script, gcc support library, and the EABI specific @code{ecrtn}
58file are used.
59
60The @code{*startfile} section specifies that the BSP specific file
61@code{startsim.o} will be used instead of @code{crt0.o}.  In addition,
62the EABI specific file @code{ecrti.o} will be linked in with the
63executable.
64
65The @code{*link} section specifies the arguments that will be passed to
66the linker.
67
68The format of this file is specific to the GNU Compiler Suite.  The
69argument used to override and extend the compiler built-in specifications
70is relatively new to the toolset.  The @code{-specs} option is present
71in all @code{egcs} distributions and @code{gcc} distributions starting
72with version 2.8.0.
73
74@section README Files
75
76Most BSPs provide one or more @code{README} files.  Generally, there
77is a @code{README} file at the top of the BSP source.  This file
78describes the board and its hardware configuration, provides vendor
79information, local configuration information, information on downloading
80code to the board, debugging, etc..  The intent of this
81file is to help someone begin to use the BSP faster. 
82
83A @code{README} file in a BSP subdirectory typically explains something
84about the contents of that subdirectory in greater detail.  For example,
85it may list the documentation available for a particular peripheral
86controller and how to obtain that documentation.  It may also explain some
87particularly cryptic part of the software in that directory or provide
88rationale on the implementation.
89
90@section times
91
92This file contains the results of the RTEMS Timing Test Suite.  It is
93in a standard format so that results from one BSP can be easily compared
94with those of another target board.
95
96If a BSP supports multiple variants, then there may be multiple @code{times}
97files.  Usually these are named @code{times.VARIANTn}.
98
99@section Tools Subdirectory
100
101Some BSPs provide additional tools that aid in using the target board.
102These tools run on the development host and are built as part of building
103the BSP.  Most common is a script to automate running the RTEMS Test Suites
104on the BSP.  Examples of this include:
105
106@itemize @bullet
107
108@item @code{powerpc/psim} includes scripts to ease use of the simulator
109
110@item @code{m68k/mvme162} includes a utility to download across the
111VMEbus into target memory if the host is a VMEbus board in the same
112chasis.
113
114@item @code{unix/posix} includes scripts to run the tests automatically
115on this BSP.
116
117@end itemize
118
119@section bsp.h Include File
120
121The file @code{include/bsp.h} contains prototypes and definitions
122specific to this board.  Every BSP is required to provide a @code{bsp.h}.
123The best approach to writing a @code{bsp.h} is copying an existing one
124as a starting point. 
125
126Many @code{bsp.h} files provide prototypes of variables defined
127in the linker script (@code{linkcmds}).
128
129There are a number of fields in this file that are used only by the
130RTEMS Test Suites.  The following is a list of these:
131
132@itemize @bullet
133@item @code{MAX_LONG_TEST_DURATION} - the longest length of time a
134"long running" test should run.
135
136@item @code{MAX_SHORT_TEST_DURATION} - the longest length of time a
137"short running" test should run.
138
139@item @code{MUST_WAIT_FOR_INTERRUPT} - modifies behavior of @code{tm27}.
140
141@item @code{Install_tm27_vector} - installs the interrupt service
142routine for the Interrupt Benchmark Test (@code{tm27}).
143
144@item @code{Cause_tm27_intr} - generates the interrupt source
145used in the Interrupt Benchmark Test (@code{tm27}).
146
147@item @code{Clear_tm27_intr} - clears the interrupt source
148used in the Interrupt Benchmark Test (@code{tm27}).
149
150@item @code{Lower_tm27_intr} - lowers the interrupt mask so the
151interrupt source used in the Interrupt Benchmark Test (@code{tm27})
152can generate a nested interrupt.
153
154@end itemize
155
156@section Calling Overhead File
157
158The file @code{include/coverhd.h} contains the overhead associated
159with invoking each directive.  This overhead consists of the execution
160time required to package the parameters as well as to execute the "jump to
161subroutine" and "return from subroutine" sequence.  The intent of this
162file is to help separate the calling overhead from the actual execution
163time of a directive.  This file is only used by the tests in the
164RTEMS Timing Test Suite.
165
166The numbers in this file are obtained by running the "Timer Overhead"
167@code{tmoverhd} test.  The numbers in this file may be 0 and no
168overhead is subtracted from the directive execution times reported by
169the Timing Suite.
170
171@section sbrk() Implementation
172
173If the BSP wants to dynamically extend the heap used by the
174C Library memory allocation routines (i.e. @code{malloc} family),
175then this routine must be functional.  The following is the
176prototype for this routine:
177
178@example
179void * sbrk(size_t increment)
180@end example
181
182The @code{increment} amount is based upon the @code{sbrk_amount}
183parameter passed to the @code{RTEMS_Malloc_Initialize} during system
184initialization.
185See @ref{Initialization Code RTEMS Pretasking Callback} for more
186information.
187
188There is a default implementation which returns an error to indicate
189that the heap can not be extended.  This implementation can be
190found in @code{c/src/lib/libbsp/shared/sbrk.c}.  Many of the BSPs
191use this shared implementation.  In order to use this implementation,
192the file @code{Makefile.in} in the BSP's @code{startup} directory
193must be modified so that the @code{$VPATH} variable searches
194both the @code{startup} directory and the shared directory.  The following
195illustates the @code{VPATH} setting in the PowerPC psim BSP's
196@code{startup/Makefile.in}:
197
198@example
199VPATH = @@srcdir@@:@@srcdir@@/../../../shared
200@end example
201
202This instructs make to look in all of the directories in the @code{VPATH}
203for the source files.  The directories will be examined in the order
204they are specified.
205
206@section bsp_cleanup() - Cleanup the Hardware
207
208The @code{bsp_cleanup()} is the last C code invoked.  Most of the BSPs
209use the same shared version of @code{bsp_cleanup()} that does nothing.
210This implementation is located in the following file:
211
212@example
213c/src/lib/libbsp/shared/bspclean.c
214@end example
215
216The @code{bsp_cleanup()} routine can be used to return to a ROM monitor,
217insure that interrupt sources are disabled, etc..  This routine is the
218last place to insure a clean shutdown of the hardware.
219
220@section set_vector() - Install an Interrupt Vector
221
222The @code{set_vector} routine is responsible for installing an interrupt
223vector.  It invokes the support routines necessary to install an
224interrupt handler as either a "raw" or an RTEMS interrupt handler.  Raw
225handlers bypass the RTEMS interrupt structure and are responsible for
226saving and restoring all their own registers.  Raw handlers are useful
227for handling traps, debug vectors, etc..
228
229The @code{set_vector} routine is a central place to perform
230interrupt controller manipulation and encapsulate that information. 
231It is usually implemented as follows:
232
233@example
234@group
235rtems_isr_entry set_vector(                     /* returns old vector */
236  rtems_isr_entry     handler,                  /* isr routine        */
237  rtems_vector_number vector,                   /* vector number      */
238  int                 type                      /* RTEMS or RAW intr  */
239)
240@{
241  if the type is RAW
242    install the raw vector
243  else
244    use rtems_interrupt_catch to install the vector
245
246  perform any interrupt controller necessary to unmask
247    the interrupt source
248
249  return the previous handler
250@}
251@end group
252@end example
253
254
255@b{NOTE:}  @code{set_vector} is provided by the majority of BSPs but
256not all.  In particular, the i386 BSPs use a different scheme. 
257
Note: See TracBrowser for help on using the repository browser.