OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [doc/] [html/] [ref/] [hal-default-interrupt-handling.html] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 28 unneback
<!-- Copyright (C) 2003 Red Hat, Inc.                                -->
2
<!-- This material may be distributed only subject to the terms      -->
3
<!-- and conditions set forth in the Open Publication License, v1.0  -->
4
<!-- or later (the latest version is presently available at          -->
5
<!-- http://www.opencontent.org/openpub/).                           -->
6
<!-- Distribution of the work or derivative of the work in any       -->
7
<!-- standard (paper) book form is prohibited unless prior           -->
8
<!-- permission is obtained from the copyright holder.               -->
9
<HTML
10
><HEAD
11
><TITLE
12
>Default Interrupt Handling</TITLE
13
><meta name="MSSmartTagsPreventParsing" content="TRUE">
14
<META
15
NAME="GENERATOR"
16
CONTENT="Modular DocBook HTML Stylesheet Version 1.76b+
17
"><LINK
18
REL="HOME"
19
TITLE="eCos Reference Manual"
20
HREF="ecos-ref.html"><LINK
21
REL="UP"
22
TITLE="Exception Handling"
23
HREF="hal-exception-handling.html"><LINK
24
REL="PREVIOUS"
25
TITLE="Default Synchronous Exception Handling"
26
HREF="hal-default-synchronous-exception-handling.html"><LINK
27
REL="NEXT"
28
TITLE=" Porting Guide"
29
HREF="hal-porting-guide.html"></HEAD
30
><BODY
31
CLASS="SECTION"
32
BGCOLOR="#FFFFFF"
33
TEXT="#000000"
34
LINK="#0000FF"
35
VLINK="#840084"
36
ALINK="#0000FF"
37
><DIV
38
CLASS="NAVHEADER"
39
><TABLE
40
SUMMARY="Header navigation table"
41
WIDTH="100%"
42
BORDER="0"
43
CELLPADDING="0"
44
CELLSPACING="0"
45
><TR
46
><TH
47
COLSPAN="3"
48
ALIGN="center"
49
>eCos Reference Manual</TH
50
></TR
51
><TR
52
><TD
53
WIDTH="10%"
54
ALIGN="left"
55
VALIGN="bottom"
56
><A
57
HREF="hal-default-synchronous-exception-handling.html"
58
ACCESSKEY="P"
59
>Prev</A
60
></TD
61
><TD
62
WIDTH="80%"
63
ALIGN="center"
64
VALIGN="bottom"
65
>Chapter 10. Exception Handling</TD
66
><TD
67
WIDTH="10%"
68
ALIGN="right"
69
VALIGN="bottom"
70
><A
71
HREF="hal-porting-guide.html"
72
ACCESSKEY="N"
73
>Next</A
74
></TD
75
></TR
76
></TABLE
77
><HR
78
ALIGN="LEFT"
79
WIDTH="100%"></DIV
80
><DIV
81
CLASS="SECTION"
82
><H1
83
CLASS="SECTION"
84
><A
85
NAME="HAL-DEFAULT-INTERRUPT-HANDLING">Default Interrupt Handling</H1
86
><P
87
>Most asynchronous external interrupt vectors will point to a default
88
interrupt VSR which decodes the actual interrupt being delivered from
89
the interrupt controller and invokes the appropriate ISR.</P
90
><P
91
>The default interrupt VSR has a number of responsibilities if it is
92
going to interact with the Kernel cleanly and allow interrupts to
93
cause thread preemption.</P
94
><P
95
>To support this VSR an ISR vector table is needed. For each valid
96
vector three pointers need to be stored: the ISR, its data pointer and
97
an opaque (to the HAL) interrupt object pointer needed by the
98
kernel. It is implementation defined whether these are stored in a
99
single table of triples, or in three separate tables.</P
100
><P
101
>The VSR follows the following approximate plan:</P
102
><P
103
></P
104
><OL
105
TYPE="1"
106
><LI
107
><P
108
>    Save the CPU state. In non-debug configurations, it may be
109
    possible to get away with saving less than the entire machine
110
    state. The option
111
    <TT
112
CLASS="LITERAL"
113
>CYGDBG_HAL_COMMON_INTERRUPTS_SAVE_MINIMUM_CONTEXT</TT
114
>
115
    is supported in some targets to do this.
116
    </P
117
></LI
118
><LI
119
><P
120
>    Increment the kernel scheduler lock. This is a static member of
121
    the Cyg_Scheduler class, however it has also been aliased to
122
    <TT
123
CLASS="LITERAL"
124
>cyg_scheduler_sched_lock</TT
125
> so that it can be
126
    accessed from assembly code.
127
    </P
128
></LI
129
><LI
130
><P
131
>    (Optional) Switch to an interrupt stack if not already running on
132
    it. This allows nested interrupts to be delivered without needing
133
    every thread to have a stack large enough to take the maximum
134
    possible nesting. It is implementation defined how to detect
135
    whether this is a nested interrupt but there are two basic
136
    techniques. The first is to inspect the stack pointer and switch
137
    only if it is not currently within the interrupt stack range; the
138
    second is to maintain a counter of the interrupt nesting level and
139
    switch only if it is zero. The option
140
    <TT
141
CLASS="LITERAL"
142
>CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK</TT
143
>
144
    controls whether this happens.
145
    </P
146
></LI
147
><LI
148
><P
149
>    Decode the actual external interrupt being delivered from
150
    the interrupt controller. This will yield the ISR vector
151
    number. The code to do this usually needs to come from the
152
    variant or platform HAL, so is usually present in the form of a
153
    macro or procedure callout.
154
    </P
155
></LI
156
><LI
157
><P
158
>    (Optional) Re-enable interrupts to permit nesting. At this point
159
    we can potentially allow higher priority interrupts to occur. It
160
    depends on the interrupt architecture of the CPU and platform
161
    whether more interrupts will occur at this point, or whether they
162
    will only be delivered after the current interrupt has been
163
    acknowledged (by a call to
164
    <TT
165
CLASS="FUNCTION"
166
>HAL_INTERRUPT_ACKNOWLEDGE()</TT
167
> in the ISR).
168
    </P
169
></LI
170
><LI
171
><P
172
>    Using the ISR vector number as an index, retrieve the
173
    ISR pointer and its data pointer from the ISR vector table.
174
    </P
175
></LI
176
><LI
177
><P
178
>    Construct a C call stack frame. This may involve making stack
179
    space for call frames, and arguments, and initializing the back
180
    pointers to halt a GDB backtrace operation.
181
    </P
182
></LI
183
><LI
184
><P
185
>    Call the ISR, passing the vector number and data pointer.  The
186
    vector number and a pointer to the saved state should be preserved
187
    across this call, preferably by storing them in registers that are
188
    defined to be callee-saved by the calling conventions.
189
    </P
190
></LI
191
><LI
192
><P
193
>    If this is an un-nested interrupt and a separate interrupt
194
    stack is being used, switch back to the interrupted thread's
195
    own stack.
196
    </P
197
></LI
198
><LI
199
><P
200
>    Use the saved ISR vector number to get the interrupt object
201
    pointer from the ISR vector table.
202
    </P
203
></LI
204
><LI
205
><P
206
>    Call <TT
207
CLASS="FUNCTION"
208
>interrupt_end()</TT
209
> passing it the return
210
    value from the ISR, the interrupt object pointer and a pointer to
211
    the saved CPU state. This function is implemented by the Kernel
212
    and is responsible for finishing off the interrupt
213
    handling. Specifically, it may post a DSR depending on the ISR
214
    return value, and will decrement the scheduler lock. If the lock
215
    is zeroed by this operation then any posted DSRs may be called and
216
    may in turn result in a thread context switch.
217
    </P
218
></LI
219
><LI
220
><P
221
>    The return from <TT
222
CLASS="FUNCTION"
223
>interrupt_end()</TT
224
> may occur
225
    some time after the call. Many other threads may have executed in
226
    the meantime. So here all we may do is restore the machine state
227
    and resume execution of the interrupted thread. Depending on the
228
    architecture, it may be necessary to disable interrupts again for
229
    part of this.
230
    </P
231
></LI
232
></OL
233
><P
234
>The detailed order of these steps may vary slightly depending on the
235
architecture, in particular where interrupts are enabled and disabled.</P
236
></DIV
237
><DIV
238
CLASS="NAVFOOTER"
239
><HR
240
ALIGN="LEFT"
241
WIDTH="100%"><TABLE
242
SUMMARY="Footer navigation table"
243
WIDTH="100%"
244
BORDER="0"
245
CELLPADDING="0"
246
CELLSPACING="0"
247
><TR
248
><TD
249
WIDTH="33%"
250
ALIGN="left"
251
VALIGN="top"
252
><A
253
HREF="hal-default-synchronous-exception-handling.html"
254
ACCESSKEY="P"
255
>Prev</A
256
></TD
257
><TD
258
WIDTH="34%"
259
ALIGN="center"
260
VALIGN="top"
261
><A
262
HREF="ecos-ref.html"
263
ACCESSKEY="H"
264
>Home</A
265
></TD
266
><TD
267
WIDTH="33%"
268
ALIGN="right"
269
VALIGN="top"
270
><A
271
HREF="hal-porting-guide.html"
272
ACCESSKEY="N"
273
>Next</A
274
></TD
275
></TR
276
><TR
277
><TD
278
WIDTH="33%"
279
ALIGN="left"
280
VALIGN="top"
281
>Default Synchronous Exception Handling</TD
282
><TD
283
WIDTH="34%"
284
ALIGN="center"
285
VALIGN="top"
286
><A
287
HREF="hal-exception-handling.html"
288
ACCESSKEY="U"
289
>Up</A
290
></TD
291
><TD
292
WIDTH="33%"
293
ALIGN="right"
294
VALIGN="top"
295
>Porting Guide</TD
296
></TR
297
></TABLE
298
></DIV
299
></BODY
300
></HTML
301
>

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.