source: rtems-docs/c-user/board_support_packages.rst @ 464d541

5
Last change on this file since 464d541 was 3384994, checked in by Chris Johns <chrisj@…>, on 11/13/17 at 02:25:18

Clean up sphinx warnings.

  • Fix minor formatting issues.
  • Fix reference the gloassary TLS using ':term:'.
  • Make sure nothing is between an anchor and the heading where ':ref:' references the anchor. This meant moving all the recently added '.. index::' entries.

Update #3232.
Update #3229.

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