source: rtems/doc/user/bsp.t @ e630235

4.115
Last change on this file since e630235 was b912f95, checked in by Joel Sherrill <joel.sherrill@…>, on 06/13/08 at 15:06:56

2008-06-13 Joel Sherrill <joel.sherrill@…>

  • user/bsp.t, user/conf.t, user/task.t: Add ability for application to configure minimum stack size. Add RTEMS_CONFIGURED_MINIMUM_STACK_SIZE constant so user can clearly indicate they want the configured as opposed to the recommended minimum stack size.
  • Property mode set to 100644
File size: 12.5 KB
Line 
1@c
2@c  COPYRIGHT (c) 1988-2008.
3@c  On-Line Applications Research Corporation (OAR).
4@c  All rights reserved.
5@c
6@c  $Id$
7@c
8
9@chapter Board Support Packages
10
11@cindex Board Support Packages
12@cindex BSPs
13
14@section Introduction
15
16@cindex BSP, definition
17
18A board support package (BSP) is a collection of
19user-provided facilities which interface RTEMS and an
20application with a specific hardware platform.  These facilities
21may  include hardware initialization, device drivers, user
22extensions, and a Multiprocessor Communications Interface
23(MPCI).  However, a minimal BSP need only support processor
24reset and initialization and, if needed, a clock tick.
25
26@section Reset and Initialization
27
28An RTEMS based application is initiated or
29re-initiated when the processor is reset.  This initialization
30code is responsible for preparing the target platform for the
31RTEMS application.  Although the exact actions performed by the
32initialization code are highly processor and target dependent,
33the logical functionality of these actions are similar across a
34variety of processors and target platforms.
35
36Normally, the BSP and some of the application initialization is
37intertwined in the RTEMS initialization sequence controlled by
38the shared function @code{boot_card()}.
39
40The reset application initialization code is executed
41first when the processor is reset.  All of the hardware must be
42initialized to a quiescent state by this software before
43initializing RTEMS.  When in quiescent state, devices do not
44generate any interrupts or require any servicing by the
45application.  Some of the hardware components may be initialized
46in this code as well as any application initialization that does
47not involve calls to RTEMS directives.
48
49The processor's Interrupt Vector Table which will be used by the
50application may need to be set to the required value by the reset
51application initialization code.  Because interrupts are enabled
52automatically by RTEMS as part of the context switch to the first task,
53the Interrupt Vector Table MUST be set before this directive is invoked
54to ensure correct interrupt vectoring.  The processor's Interrupt Vector
55Table must be accessible by RTEMS as it will be modified by the when
56installing user Interrupt Service Routines (ISRs) On some CPUs, RTEMS
57installs it's own Interrupt Vector Table as part of initialization and
58thus these requirements are met automatically.  The reset code which is
59executed before the call to any RTEMS initialization routines has the
60following requirements:
61
62@itemize @bullet
63@item Must not make any blocking RTEMS directive calls.
64
65@item If the processor supports multiple privilege levels, must leave
66the processor in the most privileged, or supervisory, state.
67
68@item Must allocate a stack of sufficient size to execute the initialization
69and shutdown of the system.  This stack area will NOT be used by any task
70once the system is initialized.  This stack is often reserved via the
71linker script or in the assembly language start up file.
72
73@item Must initialize the stack pointer for the initialization process to
74that allocated.
75
76@item Must initialize the processor's Interrupt Vector Table.
77
78@item Must disable all maskable interrupts.
79
80@item If the processor supports a separate interrupt stack, must allocate
81the interrupt stack and initialize the interrupt stack pointer.
82
83@end itemize
84
85At the end of the initialization sequence, RTEMS does not return to the
86BSP initialization code, but instead context switches to the highest
87priority task to begin application execution.  This task is typically
88a User Initialization Task which is responsible for performing both
89local and global application initialization which is dependent on RTEMS
90facilities.  It is also responsible for initializing any higher level
91RTEMS services the application uses such as networking and blocking
92device drivers.
93
94@subsection Interrupt Stack Requirements
95
96The worst-case stack usage by interrupt service
97routines must be taken into account when designing an
98application.  If the processor supports interrupt nesting, the
99stack usage must include the deepest nest level.  The worst-case
100stack usage must account for the following requirements:
101
102@itemize @bullet
103@item Processor's interrupt stack frame
104
105@item Processor's subroutine call stack frame
106
107@item RTEMS system calls
108
109@item Registers saved on stack
110
111@item Application subroutine calls
112@end itemize
113
114The size of the interrupt stack must be greater than or equal to the
115confugured minimum stack size.
116
117@subsection Processors with a Separate Interrupt Stack
118
119Some processors support a separate stack for interrupts.  When an
120interrupt is vectored and the interrupt is not nested, the processor
121will automatically switch from the current stack to the interrupt stack.
122The size of this stack is based solely on the worst-case stack usage by
123interrupt service routines.
124
125The dedicated interrupt stack for the entire application on some
126architectures is supplied and initialized by the reset and initialization
127code of the user's Board Support Package.  Whether allocated and
128initialized by the BSP or RTEMS, since all ISRs use this stack, the
129stack size must take into account the worst case stack usage by any
130combination of nested ISRs.
131
132@subsection Processors Without a Separate Interrupt Stack
133
134Some processors do not support a separate stack for interrupts.  In this
135case, without special assistance every task's stack must include
136enough space to handle the task's worst-case stack usage as well as
137the worst-case interrupt stack usage.  This is necessary because the
138worst-case interrupt nesting could occur while any task is executing.
139
140On many processors without dedicated hardware managed interrupt stacks,
141RTEMS manages a dedicated interrupt stack in software.  If this capability
142is supported on a CPU, then it is logically equivalent to the processor
143supporting a separate interrupt stack in hardware.
144
145@section Device Drivers
146
147Device drivers consist of control software for
148special peripheral devices and provide a logical interface for
149the application developer.  The RTEMS I/O manager provides
150directives which allow applications to access these device
151drivers in a consistent fashion.  A Board Support Package may
152include device drivers to access the hardware on the target
153platform.  These devices typically include serial and parallel
154ports, counter/timer peripherals, real-time clocks, disk
155interfaces, and network controllers.
156
157For more information on device drivers, refer to the
158I/O Manager chapter.
159
160@subsection Clock Tick Device Driver
161
162Most RTEMS applications will include a clock tick
163device driver which invokes the @code{@value{DIRPREFIX}clock_tick}
164directive at regular intervals.  The clock tick is necessary if
165the application is to utilize timeslicing, the clock manager, the
166timer manager, the rate monotonic manager, or the timeout option on blocking
167directives.
168
169The clock tick is usually provided as an interrupt from a counter/timer
170or a real-time clock device.  When a counter/timer is used to provide the
171clock tick, the device is typically programmed to operate in continuous
172mode.  This mode selection causes the device to automatically reload the
173initial count and continue the countdown without programmer intervention.
174This reduces the overhead required to manipulate the counter/timer in
175the clock tick ISR and increases the accuracy of tick occurrences.
176The initial count can be based on the microseconds_per_tick field
177in the RTEMS Configuration Table.  An alternate approach is to set
178the initial count for a fixed time period (such as one millisecond)
179and have the ISR invoke @code{@value{DIRPREFIX}clock_tick} on the
180configured @code{microseconds_per_tick} boundaries.  Obviously, this
181can induce some error if the configured @code{microseconds_per_tick}
182is not evenly divisible by the chosen clock interrupt quantum.
183
184It is important to note that the interval between
185clock ticks directly impacts the granularity of RTEMS timing
186operations.  In addition, the frequency of clock ticks is an
187important factor in the overall level of system overhead.  A
188high clock tick frequency results in less processor time being
189available for task execution due to the increased number of
190clock tick ISRs.
191
192@section User Extensions
193
194RTEMS allows the application developer to augment
195selected features by invoking user-supplied extension routines
196when the following system events occur:
197
198@itemize @bullet
199@item Task creation
200@item Task initiation
201@item Task reinitiation
202@item Task deletion
203@item Task context switch
204@item Post task context switch
205@item Task begin
206@item Task exits
207@item Fatal error detection
208@end itemize
209
210User extensions can be used to implement a wide variety of
211functions including execution profiling, non-standard
212coprocessor support, debug support, and error detection and
213recovery.  For example, the context of a non-standard numeric
214coprocessor may be maintained via the user extensions.  In this
215example, the task creation and deletion extensions are
216responsible for allocating and deallocating the context area,
217the task initiation and reinitiation extensions would be
218responsible for priming the context area, and the task context
219switch extension would save and restore the context of the
220device.
221
222For more information on user extensions, refer to the
223@ref{User Extensions Manager} chapter.
224
225@section Multiprocessor Communications Interface (MPCI)
226
227RTEMS requires that an MPCI layer be provided when a
228multiple node application is developed.  This MPCI layer must
229provide an efficient and reliable communications mechanism
230between the multiple nodes.  Tasks on different nodes
231communicate and synchronize with one another via the MPCI.  Each
232MPCI layer must be tailored to support the architecture of the
233target platform.
234
235For more information on the MPCI, refer to the
236Multiprocessing Manager chapter.
237
238@subsection Tightly-Coupled Systems
239
240A tightly-coupled system is a multiprocessor
241configuration in which the processors communicate solely via
242shared global memory.  The MPCI can simply place the RTEMS
243packets in the shared memory space.  The two primary
244considerations when designing an MPCI for a tightly-coupled
245system are data consistency and informing another node of a
246packet.
247
248The data consistency problem may be solved using
249atomic "test and set" operations to provide a "lock" in the
250shared memory.  It is important to minimize the length of time
251any particular processor locks a shared data structure.
252
253The problem of informing another node of a packet can
254be addressed using one of two techniques.  The first technique
255is to use an interprocessor interrupt capability to cause an
256interrupt on the receiving node.  This technique requires that
257special support hardware be provided by either the processor
258itself or the target platform.  The second technique is to have
259a node poll for arrival of packets.  The drawback to this
260technique is the overhead associated with polling.
261
262@subsection Loosely-Coupled Systems
263
264A loosely-coupled system is a multiprocessor
265configuration in which the processors communicate via some type
266of communications link which is not shared global memory.  The
267MPCI sends the RTEMS packets across the communications link to
268the destination node.  The characteristics of the communications
269link vary widely and have a significant impact on the MPCI
270layer.  For example, the bandwidth of the communications link
271has an obvious impact on the maximum MPCI throughput.
272
273The characteristics of a shared network, such as
274Ethernet, lend themselves to supporting an MPCI layer.  These
275networks provide both the point-to-point and broadcast
276capabilities which are expected by RTEMS.
277
278@subsection Systems with Mixed Coupling
279
280A mixed-coupling system is a multiprocessor
281configuration in which the processors communicate via both
282shared memory and communications links.  A unique characteristic
283of mixed-coupling systems is that a node may not have access to
284all communication methods.  There may be multiple shared memory
285areas and communication links.  Therefore, one of the primary
286functions of the MPCI layer is to efficiently route RTEMS
287packets between nodes.  This routing may be based on numerous
288algorithms. In addition, the router may provide alternate
289communications paths in the event of an overload or a partial
290failure.
291
292@subsection Heterogeneous Systems
293
294Designing an MPCI layer for a heterogeneous system
295requires special considerations by the developer.  RTEMS is
296designed to eliminate many of the problems associated with
297sharing data in a heterogeneous environment.  The MPCI layer
298need only address the representation of thirty-two (32) bit
299unsigned quantities.
300
301For more information on supporting a heterogeneous
302system, refer the Supporting Heterogeneous Environments in the
303Multiprocessing Manager chapter.
Note: See TracBrowser for help on using the repository browser.