source: rtems/cpukit/include/rtems/irq.h @ aad65583

4.104.115
Last change on this file since aad65583 was aad65583, checked in by Joel Sherrill <joel.sherrill@…>, on 02/19/09 at 19:29:19

2009-02-19 Joel Sherrill <joel.sherrill@…>

  • include/rtems/irq-extension.h, include/rtems/irq.h: Spelling errors and spacing.
  • Property mode set to 100644
File size: 7.1 KB
Line 
1/*
2 *
3 *  This include file describe the data structure and the functions implemented
4 *  by rtems to write interrupt handlers.
5 *
6 *  CopyRight (C) 1998 valette@crf.canon.fr
7 *
8 *  This code is heavilly inspired by the public specification of STREAM V2
9 *  that can be found at :
10 *
11 *      <http://www.chorus.com/Documentation/index.html> by following
12 *  the STREAM API Specification Document link.
13 *
14 *  The license and distribution terms for this file may be
15 *  found in found in the file LICENSE in this distribution or at
16 *  http://www.rtems.com/license/LICENSE.
17 *
18 * $Id$
19 */
20
21#ifndef _RTEMS_IRQ_H
22#define _RTEMS_IRQ_H
23
24#ifndef ASM
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30
31/*
32 * Type definition for RTEMS managed interrupts
33 */
34typedef unsigned char  rtems_irq_prio;
35struct  __rtems_irq_connect_data__;     /* forward declaratiuon */
36
37typedef unsigned int rtems_irq_number;
38typedef void *rtems_irq_hdl_param;
39typedef void (*rtems_irq_hdl)           (rtems_irq_hdl_param);
40typedef void (*rtems_irq_enable)        (const struct __rtems_irq_connect_data__*);
41typedef void (*rtems_irq_disable)       (const struct __rtems_irq_connect_data__*);
42typedef int  (*rtems_irq_is_enabled)    (const struct __rtems_irq_connect_data__*);
43
44typedef struct __rtems_irq_connect_data__ {
45  /*
46   * IRQ line
47   */
48  rtems_irq_number              name;
49  /*
50   * handler. See comment on handler properties below in function prototype.
51   */
52  rtems_irq_hdl                 hdl;
53  /*
54   * Handler handle to store private data
55   */
56  rtems_irq_hdl_param           handle;
57  /*
58   * function for enabling interrupts at device level (ONLY!).
59   * The BSP code will automatically enable it at i8259s level.
60   * RATIONALE : anyway such code has to exist in current driver code.
61   * It is usually called immediately AFTER connecting the interrupt handler.
62   * RTEMS may well need such a function when restoring normal interrupt
63   * processing after a debug session.
64   *
65   */
66    rtems_irq_enable            on;
67  /*
68   * function for disabling interrupts at device level (ONLY!).
69   * The code will disable it at i8259s level. RATIONALE : anyway
70   * such code has to exist for clean shutdown. It is usually called
71   * BEFORE disconnecting the interrupt. RTEMS may well need such
72   * a function when disabling normal interrupt processing for
73   * a debug session. May well be a NOP function.
74   */
75  rtems_irq_disable             off;
76  /*
77   * function enabling to know what interrupt may currently occur
78   * if someone manipulates the i8259s interrupt mask without care...
79   */
80  rtems_irq_is_enabled        isOn;
81
82#ifdef BSP_SHARED_HANDLER_SUPPORT
83  /*
84   *  Set to -1 for vectors forced to have only 1 handler
85   */
86  void *next_handler;
87#endif
88
89} rtems_irq_connect_data;
90
91typedef struct {
92  /*
93   * size of all the table fields (*Tbl) described below.
94   */
95  unsigned int                  irqNb;
96  /*
97   * Default handler used when disconnecting interrupts.
98   */
99  rtems_irq_connect_data        defaultEntry;
100  /*
101   * Table containing initials/current value.
102   */
103  rtems_irq_connect_data*       irqHdlTbl;
104  /*
105   * actual value of BSP_ISA_IRQ_VECTOR_BASE...
106   */
107  rtems_irq_number              irqBase;
108  /*
109   * software priorities associated with interrupts.
110   * if (*irqPrio  [i]  >  intrPrio  [j]  it  means  that
111   * interrupt handler hdl connected for interrupt name i
112   * will  not be interrupted by the handler connected for interrupt j
113   * The interrupt source  will be physically masked at i8259 level.
114   */
115    rtems_irq_prio*             irqPrioTbl;
116} rtems_irq_global_settings;
117
118/*-------------------------------------------------------------------------+
119| Function Prototypes.
120+--------------------------------------------------------------------------*/
121/*
122 * -------------------- RTEMS Single Irq Handler Mngt Routines ----------------
123 */
124/*
125 * function to connect a particular irq handler. This hanlder will NOT be called
126 * directly as the result of the corresponding interrupt. Instead, a RTEMS
127 * irq prologue will be called that will :
128 *
129 *      1) save the C scratch registers,
130 *      2) switch to a interrupt stack if the interrupt is not nested,
131 *      3) store the current i8259s' interrupt masks
132 *      4) modify them to disable the current interrupt at 8259 level (and may
133 *      be others depending on software priorities)
134 *      5) aknowledge the i8259s',
135 *      6) demask the processor,
136 *      7) call the application handler
137 *
138 * As a result the hdl function provided
139 *
140 *      a) can perfectly be written is C,
141 *      b) may also well directly call the part of the RTEMS API that can be
142 *      used from interrupt level,
143 *      c) It only responsible for handling the jobs that need to be done at
144 *      the device level including (aknowledging/re-enabling the interrupt at
145 *      device level, getting the data,...)
146 *
147 *      When returning from the function, the following will be performed by
148 *      the RTEMS irq epilogue :
149 *
150 *      1) masks the interrupts again,
151 *      2) restore the original i8259s' interrupt masks
152 *      3) switch back on the orinal stack if needed,
153 *      4) perform rescheduling when necessary,
154 *      5) restore the C scratch registers...
155 *      6) restore initial execution flow
156 *
157 */
158int BSP_install_rtems_irq_handler       (const rtems_irq_connect_data*);
159/*
160 * function to get the current RTEMS irq handler for ptr->name. It enables to
161 * define hanlder chain...
162 */
163int BSP_get_current_rtems_irq_handler   (rtems_irq_connect_data* ptr);
164/*
165 * function to get disconnect the RTEMS irq handler for ptr->name.
166 * This function checks that the value given is the current one for safety reason.
167 * The user can use the previous function to get it.
168 */
169int BSP_remove_rtems_irq_handler        (const rtems_irq_connect_data*);
170
171
172/*
173 * ----------------- RTEMS Shared Irq Handler Mngt Routines ----------------
174 */
175#ifdef BSP_SHARED_HANDLER_SUPPORT
176int BSP_install_rtems_shared_irq_handler  (const rtems_irq_connect_data*);
177#endif
178
179/*
180 * ----------------- RTEMS Global Irq Handler Mngt Routines ----------------
181 */
182/*
183 * (Re) Initialize the RTEMS interrupt management.
184 *
185 * The result of calling this function will be the same as if each individual
186 * handler (config->irqHdlTbl[i].hdl)  different from "config->defaultEntry.hdl"
187 * has been individualy connected via
188 *      BSP_install_rtems_irq_handler(&config->irqHdlTbl[i])
189 * And each handler currently equal to config->defaultEntry.hdl
190 * has been previously disconnected via
191 *       BSP_remove_rtems_irq_handler (&config->irqHdlTbl[i])
192 *
193 * This is to say that all information given will be used and not just
194 * only the space.
195 *
196 * CAUTION : the various table address contained in config will be used
197 *           directly by the interrupt mangement code in order to save
198 *           data size so they must stay valid after the call => they should
199 *           not be modified or declared on a stack.
200 */
201
202int BSP_rtems_irq_mngt_set(rtems_irq_global_settings* config);
203
204/*
205 * (Re) get info on current RTEMS interrupt management.
206 */
207int BSP_rtems_irq_mngt_get(rtems_irq_global_settings**);
208
209#ifdef __cplusplus
210}
211#endif
212
213#endif /* ASM */
214#endif /* _RTEMS_IRQ_H */
Note: See TracBrowser for help on using the repository browser.