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

4.104.114.84.9
Last change on this file since 529cebf0 was 529cebf0, checked in by Jennifer Averett <Jennifer.Averett@…>, on May 6, 2005 at 7:55:45 PM

2005-05-06 Jennifer Averett <jennifer.averett@…>

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