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 |
|
|
occurrence of an interrupt in its own unique fashion. In
|
15 |
|
|
addition, each processor type provides a control mechanism to
|
16 |
|
|
allow the proper handling of an interrupt. The processor
|
17 |
|
|
dependent response to the interrupt which modifies the execution
|
18 |
|
|
state and results in the modification of the execution stream.
|
19 |
|
|
This modification usually requires that an interrupt handler
|
20 |
|
|
utilize the provided control mechanisms to return to the normal
|
21 |
|
|
processing stream. Although RTEMS hides many of the processor
|
22 |
|
|
dependent details of interrupt processing, it is important to
|
23 |
|
|
understand how the RTEMS interrupt manager is mapped onto the
|
24 |
|
|
processor's unique architecture. Discussed in this chapter are
|
25 |
|
|
the the processor's response and control mechanisms as they
|
26 |
|
|
pertain to RTEMS.
|
27 |
|
|
|
28 |
|
|
@section Vectoring of Interrupt Handler
|
29 |
|
|
|
30 |
|
|
Upon receipt of an interrupt the i960CA
|
31 |
|
|
automatically performs the following actions:
|
32 |
|
|
|
33 |
|
|
@itemize @bullet
|
34 |
|
|
@item saves the local register set,
|
35 |
|
|
|
36 |
|
|
@item sets the Frame Pointer (FP) to point to the interrupt
|
37 |
|
|
stack,
|
38 |
|
|
|
39 |
|
|
@item increments the FP by sixteen (16) to make room for the
|
40 |
|
|
Interrupt Record,
|
41 |
|
|
|
42 |
|
|
@item saves the current values of the arithmetic-controls (AC)
|
43 |
|
|
register, the process-controls (PC) register, and the interrupt
|
44 |
|
|
vector number are saved in the Interrupt Record,
|
45 |
|
|
|
46 |
|
|
@item the CPU sets the Instruction Pointer (IP) to the address
|
47 |
|
|
of the first instruction in the interrupt handler,
|
48 |
|
|
|
49 |
|
|
@item the return-status field of the Previous Frame Pointer
|
50 |
|
|
(PFP or R0) register is set to interrupt return,
|
51 |
|
|
|
52 |
|
|
@item sets the PC state bit to interrupted,
|
53 |
|
|
|
54 |
|
|
@item sets the current interrupt disable level in the PC to
|
55 |
|
|
the level of the current interrupt, and
|
56 |
|
|
|
57 |
|
|
@item disables tracing.
|
58 |
|
|
@end itemize
|
59 |
|
|
|
60 |
|
|
A nested interrupt is processed similarly by the
|
61 |
|
|
i960CA with the exception that the Frame Pointer (FP) already
|
62 |
|
|
points to the interrupt stack. This means that the FP is NOT
|
63 |
|
|
overwritten before space for the Interrupt Record is allocated.
|
64 |
|
|
|
65 |
|
|
The state flag bit of the saved PC register in the
|
66 |
|
|
Interrupt Record is examined by RTEMS to determine when an outer
|
67 |
|
|
most interrupt is being exited. Therefore, the user application
|
68 |
|
|
code MUST NOT modify this bit.
|
69 |
|
|
|
70 |
|
|
@section Interrupt Record
|
71 |
|
|
|
72 |
|
|
The structure of the Interrupt Record for the i960CA
|
73 |
|
|
which is placed on the interrupt stack by the processor in
|
74 |
|
|
response to an interrupt is as follows:
|
75 |
|
|
|
76 |
|
|
@ifset use-ascii
|
77 |
|
|
@example
|
78 |
|
|
@group
|
79 |
|
|
+---------------------------+
|
80 |
|
|
| Saved Process Controls | NFP-16
|
81 |
|
|
+---------------------------+
|
82 |
|
|
| Saved Arithmetic Controls | NFP-12
|
83 |
|
|
+---------------------------+
|
84 |
|
|
| UNUSED | NFP-8
|
85 |
|
|
+---------------------------+
|
86 |
|
|
| UNUSED | NFP-4
|
87 |
|
|
+---------------------------+
|
88 |
|
|
@end group
|
89 |
|
|
@end example
|
90 |
|
|
@end ifset
|
91 |
|
|
|
92 |
|
|
@ifset use-tex
|
93 |
|
|
@sp 1
|
94 |
|
|
@tex
|
95 |
|
|
\centerline{\vbox{\offinterlineskip\halign{
|
96 |
|
|
\strut\vrule#&
|
97 |
|
|
\hbox to 2.00in{\enskip\hfil#\hfil}&
|
98 |
|
|
\vrule#&
|
99 |
|
|
\hbox to 1.00in{\enskip\hfil#\hfil}
|
100 |
|
|
\cr
|
101 |
|
|
\multispan{3}\hrulefill\cr
|
102 |
|
|
& Saved Process Controls && NFP-16\cr
|
103 |
|
|
\multispan{3}\hrulefill\cr
|
104 |
|
|
& Saved Arithmetic Controls && NFP-12\cr
|
105 |
|
|
\multispan{3}\hrulefill\cr
|
106 |
|
|
& UNUSED && NFP-8\cr
|
107 |
|
|
\multispan{3}\hrulefill\cr
|
108 |
|
|
& UNUSED && NFP-4\cr
|
109 |
|
|
\multispan{3}\hrulefill\cr
|
110 |
|
|
}}\hfil}
|
111 |
|
|
@end tex
|
112 |
|
|
@end ifset
|
113 |
|
|
|
114 |
|
|
@ifset use-html
|
115 |
|
|
@html
|
116 |
|
|
|
117 |
|
|
118 |
|
|
Saved Process Controls |
119 |
|
|
NFP-16 |
|
|
120 |
|
|
Saved Arithmetic Controls |
121 |
|
|
NFP-12 |
|
|
122 |
|
|
UNUSED |
123 |
|
|
NFP-8 |
|
|
124 |
|
|
UNUSED |
125 |
|
|
NFP-4 |
|
|
126 |
|
|
|
|
127 |
|
|
|
128 |
|
|
@end html
|
129 |
|
|
@end ifset
|
130 |
|
|
|
131 |
|
|
@section Interrupt Levels
|
132 |
|
|
|
133 |
|
|
Thirty-two levels (0-31) of interrupt priorities are
|
134 |
|
|
supported by the i960CA microprocessor with level thirty-one
|
135 |
|
|
(31) being the highest priority. Level zero (0) indicates that
|
136 |
|
|
interrupts are fully enabled. Interrupt requests for interrupts
|
137 |
|
|
with priorities less than or equal to the current interrupt mask
|
138 |
|
|
level are ignored.
|
139 |
|
|
|
140 |
|
|
Although RTEMS supports 256 interrupt levels, the
|
141 |
|
|
i960CA only supports thirty-two. RTEMS interrupt levels 0
|
142 |
|
|
through 31 directly correspond to i960CA interrupt levels. All
|
143 |
|
|
other RTEMS interrupt levels are undefined and their behavior is
|
144 |
|
|
unpredictable.
|
145 |
|
|
|
146 |
|
|
@section Disabling of Interrupts by RTEMS
|
147 |
|
|
|
148 |
|
|
During the execution of directive calls, critical
|
149 |
|
|
sections of code may be executed. When these sections are
|
150 |
|
|
encountered, RTEMS disables interrupts to level thirty-one (31)
|
151 |
|
|
before the execution of this section and restores them to the
|
152 |
|
|
previous level upon completion of the section. RTEMS has been
|
153 |
|
|
optimized to insure that interrupts are disabled for less than
|
154 |
|
|
RTEMS_MAXIMUM_DISABLE_PERIOD microseconds on a
|
155 |
|
|
RTEMS_MAXIMUM_DISABLE_PERIOD_MHZ Mhz i960CA with zero wait states.
|
156 |
|
|
These numbers will vary based the number of wait states and
|
157 |
|
|
processor speed present on the target board. [NOTE: This
|
158 |
|
|
calculation was most recently performed for Release
|
159 |
|
|
RTEMS_RELEASE_FOR_MAXIMUM_DISABLE_PERIOD.]
|
160 |
|
|
|
161 |
|
|
Non-maskable interrupts (NMI) cannot be disabled, and
|
162 |
|
|
ISRs which execute at this level MUST NEVER issue RTEMS system
|
163 |
|
|
calls. If a directive is invoked, unpredictable results may
|
164 |
|
|
occur due to the inability of RTEMS to protect its critical
|
165 |
|
|
sections. However, ISRs that make no system calls may safely
|
166 |
|
|
execute as non-maskable interrupts.
|
167 |
|
|
|
168 |
|
|
@section Register Cache Flushing
|
169 |
|
|
|
170 |
|
|
The i960CA version of the RTEMS interrupt manager is
|
171 |
|
|
optimized to insure that the flushreg instruction is only
|
172 |
|
|
executed when a context switch is necessary. The flushreg
|
173 |
|
|
instruction flushes the i960CA register set cache and takes (14
|
174 |
|
|
+ 23 * number of sets flushed) cycles to execute. As the i960CA
|
175 |
|
|
supports caching of from five to sixteen register sets, this
|
176 |
|
|
instruction takes from 129 to 382 cycles (3.90 to 11.57
|
177 |
|
|
microseconds at 33 Mhz) to execute given no wait state memory.
|
178 |
|
|
RTEMS flushes the register set cache only at the conclusion of
|
179 |
|
|
the outermost ISR when a context switch is necessary. The
|
180 |
|
|
register set cache will not be flushed as part of processing a
|
181 |
|
|
nested interrupt or when a context switch is not necessary.
|
182 |
|
|
This optimization is essential to providing high-performance
|
183 |
|
|
interrupt management on the i960CA.
|
184 |
|
|
|
185 |
|
|
@section Interrupt Stack
|
186 |
|
|
|
187 |
|
|
On the i960CA, RTEMS allocates the interrupt stack
|
188 |
|
|
from the Workspace Area. The amount of memory allocated for the
|
189 |
|
|
interrupt stack is determined by the interrupt_stack_size field
|
190 |
|
|
in the CPU Configuration Table. During the initialization
|
191 |
|
|
process, RTEMS will install its interrupt stack.
|
192 |
|
|
|
193 |
|
|
|