source: rtems/c/src/lib/libbsp/i386/shared/irq/irq.h @ f05b2ac

4.104.114.84.95
Last change on this file since f05b2ac was f05b2ac, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/21/04 at 16:01:48

Remove duplicate white lines.

  • Property mode set to 100644
File size: 8.5 KB
Line 
1/* irq.h
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 _IRQ_H_
22#define _IRQ_H_
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/*
29 * Include some preprocessor value also used by assember code
30 */
31
32#include <irq_asm.h>
33#include <rtems.h>
34/*-------------------------------------------------------------------------+
35| Constants
36+--------------------------------------------------------------------------*/
37
38typedef enum {
39    /* Base vector for our IRQ handlers. */
40  BSP_IRQ_VECTOR_BASE           =       BSP_ASM_IRQ_VECTOR_BASE,
41  BSP_IRQ_LINES_NUMBER          =       16,
42  BSP_LOWEST_OFFSET             =       0,
43  BSP_MAX_OFFSET                =       BSP_IRQ_LINES_NUMBER - 1,
44    /*
45     * Interrupt offset in comparison to BSP_ASM_IRQ_VECTOR_BASE
46     * NB : 1) Interrupt vector number in IDT = offset + BSP_ASM_IRQ_VECTOR_BASE
47     *      2) The same name should be defined on all architecture
48     *         so that handler connexion can be unchanged.
49     */
50  BSP_PERIODIC_TIMER            =       0,
51
52  BSP_KEYBOARD                  =       1,
53
54  BSP_UART_COM2_IRQ             =       3,
55
56  BSP_UART_COM1_IRQ             =       4,
57
58  BSP_RT_TIMER1         =       8,
59
60  BSP_RT_TIMER3         =       10
61} rtems_irq_symbolic_name;
62
63/*
64 * Type definition for RTEMS managed interrupts
65 */
66typedef unsigned char  rtems_irq_prio;
67typedef unsigned short rtems_i8259_masks;
68
69extern  rtems_i8259_masks i8259s_cache;
70
71struct  __rtems_irq_connect_data__;     /* forward declaratiuon */
72
73typedef void (*rtems_irq_hdl)           (void);
74typedef void (*rtems_irq_enable)        (const struct __rtems_irq_connect_data__*);
75typedef void (*rtems_irq_disable)       (const struct __rtems_irq_connect_data__*);
76typedef int  (*rtems_irq_is_enabled)    (const struct __rtems_irq_connect_data__*);
77
78typedef struct __rtems_irq_connect_data__ {
79  /*
80   * IRQ line
81   */
82  rtems_irq_symbolic_name       name;
83  /*
84   * handler. See comment on handler properties below in function prototype.
85   */
86  rtems_irq_hdl                 hdl;
87  /*
88   * function for enabling interrupts at device level (ONLY!).
89   * The BSP code will automatically enable it at i8259s level.
90   * RATIONALE : anyway such code has to exist in current driver code.
91   * It is usually called immediately AFTER connecting the interrupt handler.
92   * RTEMS may well need such a function when restoring normal interrupt
93   * processing after a debug session.
94   *
95   */
96    rtems_irq_enable            on;
97  /*
98   * function for disabling interrupts at device level (ONLY!).
99   * The code will disable it at i8259s level. RATIONALE : anyway
100   * such code has to exist for clean shutdown. It is usually called
101   * BEFORE disconnecting the interrupt. RTEMS may well need such
102   * a function when disabling normal interrupt processing for
103   * a debug session. May well be a NOP function.
104   */
105  rtems_irq_disable             off;
106  /*
107   * function enabling to know what interrupt may currently occur
108   * if someone manipulates the i8259s interrupt mask without care...
109   */
110    rtems_irq_is_enabled        isOn;
111} rtems_irq_connect_data;
112
113typedef struct {
114  /*
115   * size of all the table fields (*Tbl) described below.
116   */
117  unsigned int                  irqNb;
118  /*
119   * Default handler used when disconnecting interrupts.
120   */
121  rtems_irq_connect_data        defaultEntry;
122  /*
123   * Table containing initials/current value.
124   */
125  rtems_irq_connect_data*       irqHdlTbl;
126  /*
127   * actual value of BSP_IRQ_VECTOR_BASE...
128   */
129  rtems_irq_symbolic_name       irqBase;
130  /*
131   * software priorities associated with interrupts.
132   * if irqPrio  [i]  >  intrPrio  [j]  it  means  that
133   * interrupt handler hdl connected for interrupt name i
134   * will  not be interrupted by the handler connected for interrupt j
135   * The interrupt source  will be physically masked at i8259 level.
136   */
137    rtems_irq_prio*             irqPrioTbl;
138}rtems_irq_global_settings;
139
140/*-------------------------------------------------------------------------+
141| Function Prototypes.
142+--------------------------------------------------------------------------*/
143/*
144 * ------------------------ Intel 8259 (or emulation) Mngt Routines -------
145 */
146
147/*
148 * function to disable a particular irq at 8259 level. After calling
149 * this function, even if the device asserts the interrupt line it will
150 * not be propagated further to the processor
151 */
152int BSP_irq_disable_at_i8259s        (const rtems_irq_symbolic_name irqLine);
153/*
154 * function to enable a particular irq at 8259 level. After calling
155 * this function, if the device asserts the interrupt line it will
156 * be propagated further to the processor
157 */
158int BSP_irq_enable_at_i8259s            (const rtems_irq_symbolic_name irqLine);
159/*
160 * function to acknoledge a particular irq at 8259 level. After calling
161 * this function, if a device asserts an enabled interrupt line it will
162 * be propagated further to the processor. Mainly usefull for people
163 * writting raw handlers as this is automagically done for rtems managed
164 * handlers.
165 */
166int BSP_irq_ack_at_i8259s               (const rtems_irq_symbolic_name irqLine);
167/*
168 * function to check if a particular irq is enabled at 8259 level. After calling
169 */
170int BSP_irq_enabled_at_i8259s           (const rtems_irq_symbolic_name irqLine);
171/*
172 * ------------------------ RTEMS Single Irq Handler Mngt Routines ----------------
173 */
174/*
175 * function to connect a particular irq handler. This hanlder will NOT be called
176 * directly as the result of the corresponding interrupt. Instead, a RTEMS
177 * irq prologue will be called that will :
178 *
179 *      1) save the C scratch registers,
180 *      2) switch to a interrupt stack if the interrupt is not nested,
181 *      3) store the current i8259s' interrupt masks
182 *      4) modify them to disable the current interrupt at 8259 level (and may
183 *      be others depending on software priorities)
184 *      5) aknowledge the i8259s',
185 *      6) demask the processor,
186 *      7) call the application handler
187 *
188 * As a result the hdl function provided
189 *
190 *      a) can perfectly be written is C,
191 *      b) may also well directly call the part of the RTEMS API that can be used
192 *      from interrupt level,
193 *      c) It only responsible for handling the jobs that need to be done at
194 *      the device level including (aknowledging/re-enabling the interrupt at device,
195 *      level, getting the data,...)
196 *
197 *      When returning from the function, the following will be performed by
198 *      the RTEMS irq epilogue :
199 *
200 *      1) masks the interrupts again,
201 *      2) restore the original i8259s' interrupt masks
202 *      3) switch back on the orinal stack if needed,
203 *      4) perform rescheduling when necessary,
204 *      5) restore the C scratch registers...
205 *      6) restore initial execution flow
206 *
207 */
208int BSP_install_rtems_irq_handler       (const rtems_irq_connect_data*);
209/*
210 * function to get the current RTEMS irq handler for ptr->name. It enables to
211 * define hanlder chain...
212 */
213int BSP_get_current_rtems_irq_handler   (rtems_irq_connect_data* ptr);
214/*
215 * function to get disconnect the RTEMS irq handler for ptr->name.
216 * This function checks that the value given is the current one for safety reason.
217 * The user can use the previous function to get it.
218 */
219int BSP_remove_rtems_irq_handler        (const rtems_irq_connect_data*);
220
221/*
222 * ------------------------ RTEMS Global Irq Handler Mngt Routines ----------------
223 */
224/*
225 * (Re) Initialize the RTEMS interrupt management.
226 *
227 * The result of calling this function will be the same as if each individual
228 * handler (config->irqHdlTbl[i].hdl)  different from "config->defaultEntry.hdl"
229 * has been individualy connected via
230 *      BSP_install_rtems_irq_handler(&config->irqHdlTbl[i])
231 * And each handler currently equal to config->defaultEntry.hdl
232 * has been previously disconnected via
233 *       BSP_remove_rtems_irq_handler (&config->irqHdlTbl[i])
234 *
235 * This is to say that all information given will be used and not just
236 * only the space.
237 *
238 * CAUTION : the various table address contained in config will be used
239 *           directly by the interrupt mangement code in order to save
240 *           data size so they must stay valid after the call => they should
241 *           not be modified or declared on a stack.
242 */
243
244int BSP_rtems_irq_mngt_set(rtems_irq_global_settings* config);
245/*
246 * (Re) get info on current RTEMS interrupt management.
247 */
248int BSP_rtems_irq_mngt_get(rtems_irq_global_settings**);
249
250#ifdef __cplusplus
251}
252#endif
253
254#endif /* _IRQ_H_ */
255/* end of include file */
Note: See TracBrowser for help on using the repository browser.