1 |
1026 |
ivang |
@c
|
2 |
|
|
@c COPYRIGHT (c) 1988-2002.
|
3 |
|
|
@c On-Line Applications Research Corporation (OAR).
|
4 |
|
|
@c All rights reserved.
|
5 |
|
|
@c
|
6 |
|
|
@c intr_NOTIMES.t,v 1.6 2002/01/17 21:47:46 joel Exp
|
7 |
|
|
@c
|
8 |
|
|
|
9 |
|
|
@chapter Interrupt Processing
|
10 |
|
|
|
11 |
|
|
@section Introduction
|
12 |
|
|
|
13 |
|
|
Different types of processors respond to the
|
14 |
|
|
occurence of an interrupt in their own unique fashion. In
|
15 |
|
|
addition, each processor type provides a control mechanism to
|
16 |
|
|
allow for the proper handling of an interrupt. The processor
|
17 |
|
|
dependent response to the interrupt modifies the current
|
18 |
|
|
execution state and results in a change in the execution stream.
|
19 |
|
|
Most processors require that an interrupt handler utilize some
|
20 |
|
|
special control mechanisms to return to the normal processing
|
21 |
|
|
stream. Although RTEMS hides many of the processor dependent
|
22 |
|
|
details of interrupt processing, it is important to understand
|
23 |
|
|
how the RTEMS interrupt manager is mapped onto the processor's
|
24 |
|
|
unique architecture. Discussed in this chapter are the PA-RISC's
|
25 |
|
|
interrupt response and control mechanisms as they pertain to
|
26 |
|
|
RTEMS.
|
27 |
|
|
|
28 |
|
|
@section Vectoring of Interrupt Handler
|
29 |
|
|
|
30 |
|
|
Upon receipt of an interrupt the PA-RISC
|
31 |
|
|
automatically performs the following actions:
|
32 |
|
|
|
33 |
|
|
@itemize @bullet
|
34 |
|
|
@item The PSW (Program Status Word) is saved in the IPSW
|
35 |
|
|
(Interrupt Program Status Word).
|
36 |
|
|
|
37 |
|
|
@item The current privilege level is set to 0.
|
38 |
|
|
|
39 |
|
|
@item The following defined bits in the PSW are set:
|
40 |
|
|
|
41 |
|
|
@item E bit is set to the default endian bit
|
42 |
|
|
|
43 |
|
|
@item M bit is set to 1 if the interrupt is a high-priority
|
44 |
|
|
machine check and 0 otherwise
|
45 |
|
|
|
46 |
|
|
@item Q bit is set to zero thuse freezing the IIA
|
47 |
|
|
(Instruction Address) queues
|
48 |
|
|
|
49 |
|
|
@item C and D bits are set to zero thus disabling all
|
50 |
|
|
protection and translation.
|
51 |
|
|
|
52 |
|
|
@item I bit is set to zero this disabling all external,
|
53 |
|
|
powerfail, and low-priority machine check interrupts.
|
54 |
|
|
|
55 |
|
|
@item All others bits are set to zero.
|
56 |
|
|
|
57 |
|
|
@item General purpose registers r1, r8, r9, r16, r17, r24, and
|
58 |
|
|
r25 are copied to the shadow registers.
|
59 |
|
|
|
60 |
|
|
@item Execution begins at the address given by the formula:
|
61 |
|
|
Interruption Vector Address + (32 * interrupt vector number).
|
62 |
|
|
@end itemize
|
63 |
|
|
|
64 |
|
|
Once the processor has completed the actions it is is
|
65 |
|
|
required to perform for each interrupt, the RTEMS interrupt
|
66 |
|
|
management code (the beginning of which is stored in the
|
67 |
|
|
Interruption Vector Table) gains control and performs the
|
68 |
|
|
following actions upon each interrupt:
|
69 |
|
|
|
70 |
|
|
@itemize @bullet
|
71 |
|
|
@item returns the processor to "virtual mode" thus reenabling
|
72 |
|
|
all code and data address translation.
|
73 |
|
|
|
74 |
|
|
@item saves all necessary interrupt state information
|
75 |
|
|
|
76 |
|
|
@item saves all floating point registers
|
77 |
|
|
|
78 |
|
|
@item saves all integer registers
|
79 |
|
|
|
80 |
|
|
@item switches the current stack to the interrupt stack
|
81 |
|
|
|
82 |
|
|
@item dispatches to the appropriate user provided interrupt
|
83 |
|
|
service routine (ISR). If the ISR was installed with the
|
84 |
|
|
interrupt_catch directive, then it will be executed at this.
|
85 |
|
|
Because, the RTEMS interrupt handler saves all registers which
|
86 |
|
|
are not preserved according to the calling conventions and
|
87 |
|
|
invokes the application's ISR, the ISR can easily be written in
|
88 |
|
|
a high-level language.
|
89 |
|
|
@end itemize
|
90 |
|
|
|
91 |
|
|
RTEMS refers to the combination of the interrupt
|
92 |
|
|
state information and registers saved when vectoring an
|
93 |
|
|
interrupt as the Interrupt Stack Frame (ISF). A nested
|
94 |
|
|
interrupt is processed similarly by the PA-RISC and RTEMS with
|
95 |
|
|
the exception that the nested interrupt occurred while executing
|
96 |
|
|
on the interrupt stack and, thus, the current stack need not be
|
97 |
|
|
switched.
|
98 |
|
|
|
99 |
|
|
@section Interrupt Stack Frame
|
100 |
|
|
|
101 |
|
|
The PA-RISC architecture does not alter the stack
|
102 |
|
|
while processing interrupts. However, RTEMS does save
|
103 |
|
|
information on the stack as part of processing an interrupt.
|
104 |
|
|
This following shows the format of the Interrupt Stack Frame for
|
105 |
|
|
the PA-RISC as defined by RTEMS:
|
106 |
|
|
|
107 |
|
|
@example
|
108 |
|
|
@group
|
109 |
|
|
+------------------------+
|
110 |
|
|
| Interrupt Context | 0xXXX
|
111 |
|
|
+------------------------+
|
112 |
|
|
| Integer Context | 0xXXX
|
113 |
|
|
+------------------------+
|
114 |
|
|
| Floating Point Context | 0xXXX
|
115 |
|
|
+------------------------+
|
116 |
|
|
@end group
|
117 |
|
|
@end example
|
118 |
|
|
|
119 |
|
|
@section External Interrupts and Traps
|
120 |
|
|
|
121 |
|
|
In addition to the thirty-two unique interrupt
|
122 |
|
|
sources supported by the PA-RISC architecture, RTEMS also
|
123 |
|
|
supports the installation of handlers for each of the thirty-two
|
124 |
|
|
external interrupts supported by the PA-RISC architecture.
|
125 |
|
|
Except for interrupt vector 4, each of the interrupt vectors 0
|
126 |
|
|
through 31 may be associated with a user-provided interrupt
|
127 |
|
|
handler. Interrupt vector 4 is used for external interrupts.
|
128 |
|
|
When an external interrupt occurs, the RTEMS external interrupt
|
129 |
|
|
handler is invoked and the actual interrupt source is indicated
|
130 |
|
|
by status bits in the EIR (External Interrupt Request) register.
|
131 |
|
|
The RTEMS external interrupt handler (or interrupt vector four)
|
132 |
|
|
examines the EIR to determine which interrupt source requires
|
133 |
|
|
servicing.
|
134 |
|
|
|
135 |
|
|
RTEMS supports sixty-four interrupt vectors for the
|
136 |
|
|
PA-RISC. Vectors 0 through 31 map to the normal interrupt
|
137 |
|
|
sources while RTEMS interrupt vectors 32 through 63 are directly
|
138 |
|
|
associated with the external interrupt sources indicated by bits
|
139 |
|
|
|
140 |
|
|
|
141 |
|
|
The exact set of interrupt sources which are checked
|
142 |
|
|
for by the RTEMS external interrupt handler and the order in
|
143 |
|
|
which they are checked are configured by the user in the CPU
|
144 |
|
|
Configuration Table. If an external interrupt occurs which does
|
145 |
|
|
not have a handler configured, then the spurious interrupt
|
146 |
|
|
handler will be invoked. The spurious interrupt handler may
|
147 |
|
|
also be specifiec by the user in the CPU Configuration Table.
|
148 |
|
|
|
149 |
|
|
@section Interrupt Levels
|
150 |
|
|
|
151 |
|
|
Two levels (enabled and disabled) of interrupt
|
152 |
|
|
priorities are supported by the PA-RISC architecture. Level
|
153 |
|
|
zero (0) indicates that interrupts are fully enabled (i.e. the I
|
154 |
|
|
bit of the PSW is 1). Level one (1) indicates that interrupts
|
155 |
|
|
are disabled (i.e. the I bit of the PSW is 0). Thirty-two
|
156 |
|
|
independent sources of external interrupts are supported by the
|
157 |
|
|
PA-RISC architecture. Each of these interrupts sources may be
|
158 |
|
|
individually enabled or disabled. When processor interrupts are
|
159 |
|
|
disabled, all sources of external interrupts are ignored. When
|
160 |
|
|
processor interrupts are enabled, the EIR (External Interrupt
|
161 |
|
|
Request) register is used to determine which sources are
|
162 |
|
|
currently allowed to generate interrupts.
|
163 |
|
|
|
164 |
|
|
Although RTEMS supports 256 interrupt levels, the
|
165 |
|
|
PA-RISC architecture only supports two. RTEMS interrupt level 0
|
166 |
|
|
indicates that interrupts are enabled and level 1 indicates that
|
167 |
|
|
interrupts are disabled. All other RTEMS interrupt levels are
|
168 |
|
|
undefined and their behavior is unpredictable.
|
169 |
|
|
|
170 |
|
|
@section Disabling of Interrupts by RTEMS
|
171 |
|
|
|
172 |
|
|
During the execution of directive calls, critical
|
173 |
|
|
sections of code may be executed. When these sections are
|
174 |
|
|
encountered, RTEMS disables external interrupts by setting the I
|
175 |
|
|
bit in the PSW to 0 before the execution of this section and
|
176 |
|
|
restores them to the previous level upon completion of the
|
177 |
|
|
section. RTEMS has been optimized to insure that interrupts are
|
178 |
|
|
disabled for less than XXX instructions when compiled with GNU
|
179 |
|
|
CC at optimization level 4. The exact execution time will vary
|
180 |
|
|
based on the based on the processor implementation, amount of
|
181 |
|
|
cache, the number of wait states for primary memory, and
|
182 |
|
|
processor speed present on the target board.
|
183 |
|
|
|
184 |
|
|
Non-maskable interrupts (NMI) such as high-priority
|
185 |
|
|
machine checks cannot be disabled, and ISRs which execute at
|
186 |
|
|
this level MUST NEVER issue RTEMS system calls. If a directive
|
187 |
|
|
is invoked, unpredictable results may occur due to the inability
|
188 |
|
|
of RTEMS to protect its critical sections. However, ISRs that
|
189 |
|
|
make no system calls may safely execute as non-maskable
|
190 |
|
|
interrupts.
|
191 |
|
|
|