source: rtems/doc/supplements/powerpc/intr.t @ 9aceddaf

4.104.114.84.95
Last change on this file since 9aceddaf was 9aceddaf, checked in by Joel Sherrill <joel.sherrill@…>, on 02/11/98 at 14:50:31

updates

  • Property mode set to 100644
File size: 8.8 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@ifinfo
10@node Interrupt Processing, Interrupt Processing Introduction, Memory Model Flat Memory Model, Top
11@end ifinfo
12@chapter Interrupt Processing
13@ifinfo
14@menu
15* Interrupt Processing Introduction::
16* Interrupt Processing Synchronous Versus Asynchronous Exceptions::
17* Interrupt Processing Vectoring of Interrupt Handler::
18* Interrupt Processing Interrupt Levels::
19* Interrupt Processing Disabling of Interrupts by RTEMS::
20* Interrupt Processing Interrupt Stack::
21@end menu
22@end ifinfo
23
24@ifinfo
25@node Interrupt Processing Introduction, Interrupt Processing Synchronous Versus Asynchronous Exceptions, Interrupt Processing, Interrupt Processing
26@end ifinfo
27@section Introduction
28
29Different types of processors respond to the
30occurrence of an interrupt in its own unique fashion. In
31addition, each processor type provides a control mechanism to
32allow for the proper handling of an interrupt.  The processor
33dependent response to the interrupt modifies the current
34execution state and results in a change in the execution stream.
35Most processors require that an interrupt handler utilize some
36special control mechanisms to return to the normal processing
37stream.  Although RTEMS hides many of the processor dependent
38details of interrupt processing, it is important to understand
39how the RTEMS interrupt manager is mapped onto the processor's
40unique architecture. Discussed in this chapter are the PowerPC's
41interrupt response and control mechanisms as they pertain to
42RTEMS.
43
44RTEMS and associated documentation uses the terms
45interrupt and vector.  In the PowerPC architecture, these terms
46correspond to exception and exception handler, respectively.  The terms will
47be used interchangeably in this manual.
48
49@ifinfo
50@node Interrupt Processing Synchronous Versus Asynchronous Exceptions, Interrupt Processing Vectoring of Interrupt Handler, Interrupt Processing Introduction, Interrupt Processing
51@end ifinfo
52@section Synchronous Versus Asynchronous Exceptions
53
54In the PowerPC architecture exceptions can be either precise or
55imprecise and either synchronous or asynchronous.  Asynchronous
56exceptions occur when an external event interrupts the processor.
57Synchronous exceptions are caused by the actions of an
58instruction. During an exception SRR0 is used to calculate where
59instruction processing should resume.  All instructions prior to
60the resume instruction will have completed execution.  SRR1 is used to
61store the machine status.
62
63There are two asynchronous nonmaskable, highest-priority exceptions
64system reset and machine check.  There are two asynchrononous maskable
65low-priority exceptions external interrupt and decrementer.  Nonmaskable
66execptions are never delayed, therefore if two nonmaskable, asynchronous
67exceptions occur in immediate succession, the state information saved by
68the first exception may be overwritten when the subsequent exception occurs.
69
70The PowerPC arcitecure defines one imprecise exception, the imprecise
71floating point enabled exception.  All other synchronous exceptions are
72precise.  The synchronization occuring during asynchronous precise
73exceptions conforms to the requirements for context synchronization.
74
75@ifinfo
76@node Interrupt Processing Vectoring of Interrupt Handler, Interrupt Processing Interrupt Levels, Interrupt Processing Synchronous Versus Asynchronous Exceptions, Interrupt Processing
77@end ifinfo
78@section Vectoring of Interrupt Handler
79
80Upon determining that an exception can be taken the PowerPC automatically
81performs the following actions:
82
83@itemize @bullet
84@item an instruction address is loaded into SRR0
85
86@item bits 33-36 and 42-47 of SRR1 are loaded with information
87specific to the exception.
88
89@item bits 0-32, 37-41, and 48-63 of SRR1 are loaded with corresponding
90bits from the MSR.
91
92@item the MSR is set based upon the exception type.
93
94@item instruction fetch and execution resumes, using the new MSR value, at a location specific to the execption type.
95
96@end itemize
97
98If the interrupt handler was installed as an RTEMS
99interrupt handler, then upon receipt of the interrupt, the
100processor passes control to the RTEMS interrupt handler which
101performs the following actions:
102
103@itemize @bullet
104@item saves the state of the interrupted task on it's stack,
105
106@item saves all registers which are not normally preserved
107by the calling sequence so the user's interrupt service
108routine can be written in a high-level language.
109
110@item if this is the outermost (i.e. non-nested) interrupt,
111then the RTEMS interrupt handler switches from the current stack
112to the interrupt stack,
113
114@item enables exceptions,
115
116@item invokes the vectors to a user interrupt service routine (ISR).
117@end itemize
118
119Asynchronous interrupts are ignored while exceptions are
120disabled.  Synchronous interrupts which occur while are
121disabled result in the CPU being forced into an error mode.
122
123A nested interrupt is processed similarly with the
124exception that the current stack need not be switched to the
125interrupt stack.
126
127@ifinfo
128@node Interrupt Processing Interrupt Levels, Interrupt Processing Disabling of Interrupts by RTEMS, Interrupt Processing Vectoring of Interrupt Handler, Interrupt Processing
129@end ifinfo
130@section Interrupt Levels
131
132The PowerPC architecture supports only a single external
133asynchronous interrupt source.  This interrupt source
134may be enabled and disabled via the External Interrupt Enable (EE)
135bit in the Machine State Register (MSR).  Thus only two level (enabled
136and disabled) of external device interrupt priorities are
137directly supported by the PowerPC architecture. 
138
139Some PowerPC implementations include a Critical Interrupt capability
140which is often used to receive interrupts from high priority external
141devices.
142
143The RTEMS interrupt level mapping scheme for the PowerPC is not
144a numeric level as on most RTEMS ports.  It is a bit mapping in
145which the least three significiant bits of the interrupt level
146are mapped directly to the enabling of specific interrupt
147sources as follows:
148
149@table @b
150
151@item Critical Interrupt
152Setting bit 0 (the least significant bit) of the interrupt level
153enables the Critical Interrupt source, if it is available on this
154CPU model.
155
156@item Machine Check
157Setting bit 1 of the interrupt level enables Machine Check execptions.
158
159@item External Interrupt
160Setting bit 2 of the interrupt level enables External Interrupt execptions.
161
162@end table
163
164All other bits in the RTEMS task interrupt level are ignored.
165
166@ifinfo
167@node Interrupt Processing Disabling of Interrupts by RTEMS, Interrupt Processing Interrupt Stack, Interrupt Processing Interrupt Levels, Interrupt Processing
168@end ifinfo
169@section Disabling of Interrupts by RTEMS
170
171During the execution of directive calls, critical
172sections of code may be executed.  When these sections are
173encountered, RTEMS disables Critical Interrupts, External Interrupts
174and Machine Checks before the execution of this section and restores
175them to the previous level upon completion of the section.  RTEMS has been
176optimized to insure that interrupts are disabled for less than
177RTEMS_MAXIMUM_DISABLE_PERIOD microseconds on a
178RTEMS_MAXIMUM_DISABLE_PERIOD_MHZ Mhz PowerPC 603e with zero
179wait states.  These numbers will vary based the number of wait
180states and processor speed present on the target board.
181[NOTE:  The maximum period with interrupts disabled is hand calculated.  This
182calculation was last performed for Release
183RTEMS_RELEASE_FOR_MAXIMUM_DISABLE_PERIOD.]
184
185If a PowerPC implementation provides non-maskable interrupts (NMI)
186which cannot be disabled, ISRs which process these interrupts
187MUST NEVER issue RTEMS system calls.  If a directive is invoked,
188unpredictable results may occur due to the inability of RTEMS
189to protect its critical sections.  However, ISRs that make no
190system calls may safely execute as non-maskable interrupts.
191
192@ifinfo
193@node Interrupt Processing Interrupt Stack, Default Fatal Error Processing, Interrupt Processing Disabling of Interrupts by RTEMS, Interrupt Processing
194@end ifinfo
195@section Interrupt Stack
196
197The PowerPC architecture does not provide for a
198dedicated interrupt stack.  Thus by default, exception handlers would
199execute on the stack of the RTEMS task which they interrupted.
200This artificially inflates the stack requirements for each task
201since EVERY task stack would have to include enough space to
202account for the worst case interrupt stack requirements in
203addition to it's own worst case usage.  RTEMS addresses this
204problem on the PowerPC by providing a dedicated interrupt stack
205managed by software.
206
207During system initialization, RTEMS allocates the
208interrupt stack from the Workspace Area.  The amount of memory
209allocated for the interrupt stack is determined by the
210interrupt_stack_size field in the CPU Configuration Table.  As
211part of processing a non-nested interrupt, RTEMS will switch to
212the interrupt stack before invoking the installed handler.
213
214
215
Note: See TracBrowser for help on using the repository browser.