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) 2000 Canon Research Centre France SA. |
---|
7 | * Emmanuel Raguet, mailto:raguet@crf.canon.fr |
---|
8 | * |
---|
9 | * The license and distribution terms for this file may be |
---|
10 | * found in found in the file LICENSE in this distribution or at |
---|
11 | * http://www.OARcorp.com/rtems/license.html. |
---|
12 | * |
---|
13 | */ |
---|
14 | |
---|
15 | #ifndef _IRQ_H_ |
---|
16 | #define _IRQ_H_ |
---|
17 | |
---|
18 | #ifdef __cplusplus |
---|
19 | extern "C" { |
---|
20 | #endif |
---|
21 | |
---|
22 | /* |
---|
23 | * Include some preprocessor value also used by assember code |
---|
24 | */ |
---|
25 | |
---|
26 | #include <rtems.h> |
---|
27 | |
---|
28 | extern void default_int_handler(); |
---|
29 | /*-------------------------------------------------------------------------+ |
---|
30 | | Constants |
---|
31 | +--------------------------------------------------------------------------*/ |
---|
32 | |
---|
33 | /* enum of the possible interrupt sources */ |
---|
34 | typedef enum { |
---|
35 | BSP_INT_1 = 0, |
---|
36 | BSP_INT_2 = 1, |
---|
37 | BSP_UART = 2, |
---|
38 | BSP_MAX_INT = 3 |
---|
39 | } rtems_irq_symbolic_name; |
---|
40 | |
---|
41 | /* define that can be useful (the values are just examples) */ |
---|
42 | #define INTMASK 0x01 |
---|
43 | #define VECTOR_TABLE 0x00 |
---|
44 | |
---|
45 | /* |
---|
46 | * Type definition for RTEMS managed interrupts |
---|
47 | */ |
---|
48 | typedef unsigned char rtems_irq_level; |
---|
49 | typedef unsigned char rtems_irq_trigger; |
---|
50 | |
---|
51 | struct __rtems_irq_connect_data__; /* forward declaratiuon */ |
---|
52 | |
---|
53 | typedef void (*rtems_irq_hdl) (void); |
---|
54 | typedef void (*rtems_irq_enable) (const struct __rtems_irq_connect_data__*); |
---|
55 | typedef void (*rtems_irq_disable) (const struct __rtems_irq_connect_data__*); |
---|
56 | typedef int (*rtems_irq_is_enabled) (const struct __rtems_irq_connect_data__*); |
---|
57 | |
---|
58 | typedef struct __rtems_irq_connect_data__ { |
---|
59 | /* |
---|
60 | * IRQ line |
---|
61 | */ |
---|
62 | rtems_irq_symbolic_name name; |
---|
63 | /* |
---|
64 | * handler. See comment on handler properties below in function prototype. |
---|
65 | */ |
---|
66 | rtems_irq_hdl hdl; |
---|
67 | /* |
---|
68 | * function for enabling interrupts at device level (ONLY!). |
---|
69 | * The BSP code will automatically enable it at i8259s level. |
---|
70 | * RATIONALE : anyway such code has to exist in current driver code. |
---|
71 | * It is usually called immediately AFTER connecting the interrupt handler. |
---|
72 | * RTEMS may well need such a function when restoring normal interrupt |
---|
73 | * processing after a debug session. |
---|
74 | * |
---|
75 | */ |
---|
76 | rtems_irq_enable on; |
---|
77 | /* |
---|
78 | * function for disabling interrupts at device level (ONLY!). |
---|
79 | * The code will disable it at i8259s level. RATIONALE : anyway |
---|
80 | * such code has to exist for clean shutdown. It is usually called |
---|
81 | * BEFORE disconnecting the interrupt. RTEMS may well need such |
---|
82 | * a function when disabling normal interrupt processing for |
---|
83 | * a debug session. May well be a NOP function. |
---|
84 | */ |
---|
85 | rtems_irq_disable off; |
---|
86 | /* |
---|
87 | * function enabling to know what interrupt may currently occur |
---|
88 | * if someone manipulates the i8259s interrupt mask without care... |
---|
89 | */ |
---|
90 | rtems_irq_is_enabled isOn; |
---|
91 | /* |
---|
92 | * priority level at the vplus level |
---|
93 | */ |
---|
94 | rtems_irq_level irqLevel; |
---|
95 | /* |
---|
96 | * Trigger way : Rising or falling edge or High or low level |
---|
97 | */ |
---|
98 | rtems_irq_trigger irqTrigger; |
---|
99 | } rtems_irq_connect_data; |
---|
100 | |
---|
101 | /*-------------------------------------------------------------------------+ |
---|
102 | | Function Prototypes. |
---|
103 | +--------------------------------------------------------------------------*/ |
---|
104 | /* |
---|
105 | * ------------------------ RTEMS Single Irq Handler Mngt Routines ---------------- |
---|
106 | */ |
---|
107 | |
---|
108 | /* |
---|
109 | * function to initialize the interrupt for a specific BSP |
---|
110 | */ |
---|
111 | void BSP_rtems_irq_mngt_init(); |
---|
112 | |
---|
113 | |
---|
114 | /* |
---|
115 | * function to connect a particular irq handler. This hanlder will NOT be called |
---|
116 | * directly as the result of the corresponding interrupt. Instead, a RTEMS |
---|
117 | * irq prologue will be called that will : |
---|
118 | * |
---|
119 | * 1) save the C scratch registers, |
---|
120 | * 2) switch to a interrupt stack if the interrupt is not nested, |
---|
121 | * 3) store the current i8259s' interrupt masks |
---|
122 | * 4) modify them to disable the current interrupt at 8259 level (and may |
---|
123 | * be others depending on software priorities) |
---|
124 | * 5) aknowledge the i8259s', |
---|
125 | * 6) demask the processor, |
---|
126 | * 7) call the application handler |
---|
127 | * |
---|
128 | * As a result the hdl function provided |
---|
129 | * |
---|
130 | * a) can perfectly be written is C, |
---|
131 | * b) may also well directly call the part of the RTEMS API that can be used |
---|
132 | * from interrupt level, |
---|
133 | * c) It only responsible for handling the jobs that need to be done at |
---|
134 | * the device level including (aknowledging/re-enabling the interrupt at device, |
---|
135 | * level, getting the data,...) |
---|
136 | * |
---|
137 | * When returning from the function, the following will be performed by |
---|
138 | * the RTEMS irq epilogue : |
---|
139 | * |
---|
140 | * 1) masks the interrupts again, |
---|
141 | * 2) restore the original i8259s' interrupt masks |
---|
142 | * 3) switch back on the orinal stack if needed, |
---|
143 | * 4) perform rescheduling when necessary, |
---|
144 | * 5) restore the C scratch registers... |
---|
145 | * 6) restore initial execution flow |
---|
146 | * |
---|
147 | */ |
---|
148 | |
---|
149 | int BSP_install_rtems_irq_handler (const rtems_irq_connect_data*); |
---|
150 | /* |
---|
151 | * function to get the current RTEMS irq handler for ptr->name. It enables to |
---|
152 | * define hanlder chain... |
---|
153 | */ |
---|
154 | int BSP_get_current_rtems_irq_handler (rtems_irq_connect_data* ptr); |
---|
155 | /* |
---|
156 | * function to get disconnect the RTEMS irq handler for ptr->name. |
---|
157 | * This function checks that the value given is the current one for safety reason. |
---|
158 | * The user can use the previous function to get it. |
---|
159 | */ |
---|
160 | int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data*); |
---|
161 | |
---|
162 | |
---|
163 | #ifdef __cplusplus |
---|
164 | } |
---|
165 | #endif |
---|
166 | |
---|
167 | #endif /* _IRQ_H_ */ |
---|
168 | /* end of include file */ |
---|