source: rtems-docs/ada_user/board_support_packages.rst @ 4783b0d

4.115
Last change on this file since 4783b0d was 4783b0d, checked in by Amar Takhar <amar@…>, on 01/17/16 at 16:37:28

Split document into seperate files by section.

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