source: rtems/doc/user/intr.t @ 75e22db

4.104.114.84.95
Last change on this file since 75e22db was 75e22db, checked in by Joel Sherrill <joel.sherrill@…>, on 03/27/98 at 16:47:53

Completed sweep adding directive and constant prefixes.

  • Property mode set to 100644
File size: 14.3 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 Manager, Interrupt Manager Introduction, TASK_WAKE_WHEN - Wake up when specified, Top
11@end ifinfo
12@chapter Interrupt Manager
13@ifinfo
14@menu
15* Interrupt Manager Introduction::
16* Interrupt Manager Background::
17* Interrupt Manager Operations::
18* Interrupt Manager Directives::
19@end menu
20@end ifinfo
21
22@ifinfo
23@node Interrupt Manager Introduction, Interrupt Manager Background, Interrupt Manager, Interrupt Manager
24@end ifinfo
25@section Introduction
26
27Any real-time executive must provide a mechanism for
28quick response to externally generated interrupts to satisfy the
29critical time constraints of the application.  The interrupt
30manager provides this mechanism for RTEMS.  This manager permits
31quick interrupt response times by providing the critical ability
32to alter task execution which allows a task to be preempted upon
33exit from an ISR.  The interrupt manager includes the following
34directive:
35
36@itemize @bullet
37@item @code{@value{DIRPREFIX}interrupt_catch} - Establish an ISR
38@item @code{@value{DIRPREFIX}interrupt_disable} - Disable Interrupts
39@item @code{@value{DIRPREFIX}interrupt_enable} - Enable Interrupts
40@item @code{@value{DIRPREFIX}interrupt_flash} - Flash Interrupt
41@item @code{@value{DIRPREFIX}interrupt_is_in_progress} - Is an ISR in Progress
42@end itemize
43
44@ifinfo
45@node Interrupt Manager Background, Processing an Interrupt, Interrupt Manager Introduction, Interrupt Manager
46@end ifinfo
47@section Background
48@ifinfo
49@menu
50* Processing an Interrupt::
51* RTEMS Interrupt Levels::
52* Disabling of Interrupts by RTEMS::
53@end menu
54@end ifinfo
55
56@ifinfo
57@node Processing an Interrupt, RTEMS Interrupt Levels, Interrupt Manager Background, Interrupt Manager Background
58@end ifinfo
59@subsection Processing an Interrupt
60
61The interrupt manager allows the application to
62connect a function to a hardware interrupt vector.  When an
63interrupt occurs, the processor will automatically vector to
64RTEMS.  RTEMS saves and restores all registers which are not
65preserved by the normal @value{LANGUAGE} calling convention
66for the target
67processor and invokes the user's ISR.  The user's ISR is
68responsible for processing the interrupt, clearing the interrupt
69if necessary, and device specific manipulation.
70
71The @code{@value{DIRPREFIX}interrupt_catch}
72directive connects a procedure to
73an interrupt vector.  The interrupt service routine is assumed
74to abide by these conventions and have a prototype similar to
75the following:
76
77@ifset is-C
78@example
79rtems_isr user_isr(
80  rtems_vector_number vector
81);
82@end example
83@end ifset
84
85@ifset is-Ada
86@example
87procedure User_ISR (
88  vector : in     RTEMS.Vector_Number
89);
90@end example
91@end ifset
92
93The vector number argument is provided by RTEMS to
94allow the application to identify the interrupt source.  This
95could be used to allow a single routine to service interrupts
96from multiple instances of the same device.  For example, a
97single routine could service interrupts from multiple serial
98ports and use the vector number to identify which port requires
99servicing.
100
101To minimize the masking of lower or equal priority
102level interrupts, the ISR should perform the minimum actions
103required to service the interrupt.  Other non-essential actions
104should be handled by application tasks.  Once the user's ISR has
105completed, it returns control to the RTEMS interrupt manager
106which will perform task dispatching and restore the registers
107saved before the ISR was invoked.
108
109The RTEMS interrupt manager guarantees that proper
110task scheduling and dispatching are performed at the conclusion
111of an ISR.  A system call made by the ISR may have readied a
112task of higher priority than the interrupted task.  Therefore,
113when the ISR completes, the postponed dispatch processing must
114be performed.  No dispatch processing is performed as part of
115directives which have been invoked by an ISR.
116
117Applications must adhere to the following rule if
118proper task scheduling and dispatching is to be performed:
119
120@itemize @b{ }
121
122@item @b{The interrupt manager must be used for all ISRs which
123may be interrupted by the highest priority ISR which invokes an
124RTEMS directive.}
125
126@end itemize
127
128
129Consider a processor which allows a numerically low
130interrupt level to interrupt a numerically greater interrupt
131level.  In this example, if an RTEMS directive is used in a
132level 4 ISR, then all ISRs which execute at levels 0 through 4
133must use the interrupt manager.
134
135Interrupts are nested whenever an interrupt occurs
136during the execution of another ISR.  RTEMS supports efficient
137interrupt nesting by allowing the nested ISRs to terminate
138without performing any dispatch processing.  Only when the
139outermost ISR terminates will the postponed dispatching occur.
140
141@ifinfo
142@node RTEMS Interrupt Levels, Disabling of Interrupts by RTEMS, Processing an Interrupt, Interrupt Manager Background
143@end ifinfo
144@subsection RTEMS Interrupt Levels
145
146Many processors support multiple interrupt levels or
147priorities.  The exact number of interrupt levels is processor
148dependent.  RTEMS internally supports 256 interrupt levels which
149are mapped to the processor's interrupt levels.  For specific
150information on the mapping between RTEMS and the target
151processor's interrupt levels, refer to the Interrupt Processing
152chapter of the Applications Supplement document for a specific
153target processor.
154
155@ifinfo
156@node Disabling of Interrupts by RTEMS, Interrupt Manager Operations, RTEMS Interrupt Levels, Interrupt Manager Background
157@end ifinfo
158@subsection Disabling of Interrupts by RTEMS
159
160During the execution of directive calls, critical
161sections of code may be executed.  When these sections are
162encountered, RTEMS disables all maskable interrupts before the
163execution of the section and restores them to the previous level
164upon completion of the section.  RTEMS has been optimized to
165insure that interrupts are disabled for a minimum length of
166time.  The maximum length of time interrupts are disabled by
167RTEMS is processor dependent and is detailed in the Timing
168Specification chapter of the Applications Supplement document
169for a specific target processor.
170
171Non-maskable interrupts (NMI) cannot be disabled, and
172ISRs which execute at this level MUST NEVER issue RTEMS system
173calls.  If a directive is invoked, unpredictable results may
174occur due to the inability of RTEMS to protect its critical
175sections.  However, ISRs that make no system calls may safely
176execute as non-maskable interrupts.
177
178@ifinfo
179@node Interrupt Manager Operations, Establishing an ISR, Disabling of Interrupts by RTEMS, Interrupt Manager
180@end ifinfo
181@section Operations
182@ifinfo
183@menu
184* Establishing an ISR::
185* Directives Allowed from an ISR::
186@end menu
187@end ifinfo
188
189@ifinfo
190@node Establishing an ISR, Directives Allowed from an ISR, Interrupt Manager Operations, Interrupt Manager Operations
191@end ifinfo
192@subsection Establishing an ISR
193
194The @code{@value{DIRPREFIX}interrupt_catch}
195directive establishes an ISR for
196the system.  The address of the ISR and its associated CPU
197vector number are specified to this directive.  This directive
198installs the RTEMS interrupt wrapper in the processor's
199Interrupt Vector Table and the address of the user's ISR in the
200RTEMS' Vector Table.  This directive returns the previous
201contents of the specified vector in the RTEMS' Vector Table.
202
203@ifinfo
204@node Directives Allowed from an ISR, Interrupt Manager Directives, Establishing an ISR, Interrupt Manager Operations
205@end ifinfo
206@subsection Directives Allowed from an ISR
207
208Using the interrupt manager insures that RTEMS knows
209when a directive is being called from an ISR.  The ISR may then
210use system calls to synchronize itself with an application task.
211The synchronization may involve messages, events or signals
212being passed by the ISR to the desired task.  Directives invoked
213by an ISR must operate only on objects which reside on the local
214node.  The following is a list of RTEMS system calls that may be
215made from an ISR:
216
217@itemize @bullet
218@item Task Management
219
220@itemize -
221@item task_get_note, task_set_note, task_suspend, task_resume
222@end itemize
223
224@item Clock Management
225
226@itemize -
227@item clock_get, clock_tick
228@end itemize
229
230@item Message, Event, and Signal Management
231
232@itemize -
233@item message_queue_send, message_queue_urgent
234@item event_send
235@item signal_send
236@end itemize
237
238@item Semaphore Management
239
240@itemize -
241@item semaphore_release
242@end itemize
243
244@item Dual-Ported Memory Management
245
246@itemize -
247@item port_external_to_internal, port_internal_to_external
248@end itemize
249
250@item IO Management
251
252@itemize -
253@item io_initialize, io_open, io_close, io_read, io_write, io_control
254@end itemize
255
256@item Fatal Error Management
257
258@itemize -
259@item fatal_error_occurred
260@end itemize
261
262@item Multiprocessing
263
264@itemize -
265@item multiprocessing_announce
266@end itemize
267@end itemize
268
269@ifinfo
270@node Interrupt Manager Directives, INTERRUPT_CATCH - Establish an ISR, Directives Allowed from an ISR, Interrupt Manager
271@end ifinfo
272@section Directives
273@ifinfo
274@menu
275* INTERRUPT_CATCH - Establish an ISR::
276* INTERRUPT_DISABLE - Disable Interrupts::
277* INTERRUPT_ENABLE - Enable Interrupts::
278* INTERRUPT_FLASH - Flash Interrupts::
279* INTERRUPT_IS_IN_PROGRESS - Is an ISR in Progress::
280@end menu
281@end ifinfo
282
283This section details the interrupt manager's
284directives.  A subsection is dedicated to each of this manager's
285directives and describes the calling sequence, related
286constants, usage, and status codes.
287
288@page
289@ifinfo
290@node INTERRUPT_CATCH - Establish an ISR, INTERRUPT_DISABLE - Disable Interrupts, Interrupt Manager Directives, Interrupt Manager Directives
291@end ifinfo
292@subsection INTERRUPT_CATCH - Establish an ISR
293
294@subheading CALLING SEQUENCE:
295
296@ifset is-C
297@example
298rtems_status_code rtems_interrupt_catch(
299  rtems_isr_entry      new_isr_handler,
300  rtems_vector_number  vector,
301  rtems_isr_entry     *old_isr_handler
302);
303@end example
304@end ifset
305
306@ifset is-Ada
307@example
308procedure Interrupt_Catch (
309   New_ISR_handler : in     RTEMS.Address;
310   Vector          : in     RTEMS.Vector_Number;
311   Old_ISR_Handler :    out RTEMS.Address;
312   Result          :    out RTEMS.Status_Codes
313);
314@end example
315@end ifset
316
317@subheading DIRECTIVE STATUS CODES:
318@code{@value{RPREFIX}SUCCESSFUL} - ISR established successfully@*
319@code{@value{RPREFIX}INVALID_NUMBER} - illegal vector number@*
320@code{@value{RPREFIX}INVALID_ADDRESS} - illegal ISR entry point or invalid old_isr_handler
321
322@subheading DESCRIPTION:
323
324This directive establishes an interrupt service
325routine (ISR) for the specified interrupt vector number.  The
326@code{new_isr_handler} parameter specifies the entry point of the ISR.
327The entry point of the previous ISR for the specified vector is
328returned in @code{old_isr_handler}.
329
330@subheading NOTES:
331
332This directive will not cause the calling task to be preempted.
333
334@page
335@ifinfo
336@node INTERRUPT_DISABLE - Disable Interrupts, INTERRUPT_ENABLE - Enable Interrupts, INTERRUPT_CATCH - Establish an ISR, Interrupt Manager Directives
337@end ifinfo
338@subsection INTERRUPT_DISABLE - Disable Interrupts
339
340@subheading CALLING SEQUENCE:
341
342@ifset is-C
343@example
344void rtems_interrupt_disable(
345  rtems_isr_level  level
346);
347@end example
348@end ifset
349
350@ifset is-Ada
351@example
352function Interrupt_Disable
353return RTEMS.ISR_Level;
354@end example
355@end ifset
356
357@subheading DIRECTIVE STATUS CODES:
358
359NONE
360
361@subheading DESCRIPTION:
362
363This directive disables all maskable interrupts and returns
364the previous @code{level}.  A later invocation of the
365@code{@value{DIRPREFIX}interrupt_enable} directive should be used to
366restore the interrupt level.
367
368@subheading NOTES:
369
370This directive will not cause the calling task to be preempted.
371
372@ifset is-C
373@b{This directive is implemented as a macro which modifies the @code{level}
374parameter.}
375@end ifset
376
377@page
378@ifinfo
379@node INTERRUPT_ENABLE - Enable Interrupts, INTERRUPT_FLASH - Flash Interrupts, INTERRUPT_DISABLE - Disable Interrupts, Interrupt Manager Directives
380@end ifinfo
381@subsection INTERRUPT_ENABLE - Enable Interrupts
382
383@subheading CALLING SEQUENCE:
384
385@ifset is-C
386@example
387void rtems_interrupt_enable(
388  rtems_isr_level  level
389);
390@end example
391@end ifset
392
393@ifset is-Ada
394@example
395procedure Interrupt_Enable (
396   Level : in     RTEMS.ISR_Level
397);
398@end example
399@end ifset
400
401@subheading DIRECTIVE STATUS CODES:
402
403NONE
404
405@subheading DESCRIPTION:
406
407This directive enables maskable interrupts to the @code{level}
408which was returned by a previous call to
409@code{@value{DIRPREFIX}interrupt_disable}.
410Immediately prior to invoking this directive, maskable interrupts should
411be disabled by a call to @code{@value{DIRPREFIX}interrupt_disable}
412and will be enabled when this directive returns to the caller.
413
414@subheading NOTES:
415
416This directive will not cause the calling task to be preempted.
417
418
419@page
420@ifinfo
421@node INTERRUPT_FLASH - Flash Interrupts, INTERRUPT_IS_IN_PROGRESS - Is an ISR in Progress, INTERRUPT_ENABLE - Enable Interrupts, Interrupt Manager Directives
422@end ifinfo
423@subsection INTERRUPT_FLASH - Flash Interrupts
424
425@subheading CALLING SEQUENCE:
426
427@ifset is-C
428@example
429void rtems_interrupt_flash(
430  rtems_isr_level level
431);
432@end example
433@end ifset
434
435@ifset is-Ada
436@example
437procedure Interrupt_Flash (
438   Level : in     RTEMS.ISR_Level
439);
440@end example
441@end ifset
442
443@subheading DIRECTIVE STATUS CODES:
444
445NONE
446
447@subheading DESCRIPTION:
448
449This directive temporarily enables maskable interrupts to the @code{level}
450which was returned by a previous call to
451@code{@value{DIRPREFIX}interrupt_disable}. 
452Immediately prior to invoking this directive, maskable interrupts should
453be disabled by a call to @code{@value{DIRPREFIX}interrupt_disable}
454and will be redisabled when this directive returns to the caller.
455
456@subheading NOTES:
457
458This directive will not cause the calling task to be preempted.
459
460@page
461@ifinfo
462@node INTERRUPT_IS_IN_PROGRESS - Is an ISR in Progress, Clock Manager, INTERRUPT_FLASH - Flash Interrupts, Interrupt Manager Directives
463@end ifinfo
464@subsection INTERRUPT_IS_IN_PROGRESS - Is an ISR in Progress
465
466@subheading CALLING SEQUENCE:
467
468@ifset is-C
469@example
470rtems_boolean rtems_interrupt_is_in_progress( void );
471@end example
472@end ifset
473
474@ifset is-Ada
475@example
476function Interrupt_Is_In_Progress
477return RTEMS.Boolean;
478@end example
479@end ifset
480
481@subheading DIRECTIVE STATUS CODES:
482
483NONE
484
485@subheading DESCRIPTION:
486
487This directive returns @code{TRUE} if the processor is currently
488servicing an interrupt and @code{FALSE} otherwise.  A return value
489of @code{TRUE} indicates that the caller is an interrupt service
490routine, @b{NOT} a task.  The directives available to an interrupt
491service routine are restricted.
492
493@subheading NOTES:
494
495This directive will not cause the calling task to be preempted.
496
Note: See TracBrowser for help on using the repository browser.