source: rtems/doc/user/bsp.t @ 9c8530f7

4.104.114.84.95
Last change on this file since 9c8530f7 was 6449498, checked in by Joel Sherrill <joel.sherrill@…>, on 01/17/02 at 21:47:47

2001-01-17 Joel Sherrill <joel@…>

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