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) 1999 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.OARcorp.com/rtems/license.html. |
---|
17 | * |
---|
18 | * Copyright 2004, Brookhaven National Laboratory and |
---|
19 | * Shuchen Kate Feng <feng1@bnl.gov> |
---|
20 | * |
---|
21 | * - modified shared/irq/irq.h for Mvme5500 (no ISA devices/PIC) |
---|
22 | * - Discovery GT64260 interrupt controller instead of 8259. |
---|
23 | * - Added support for software IRQ priority levels. |
---|
24 | */ |
---|
25 | |
---|
26 | #ifndef LIBBSP_POWERPC_MVME5500_IRQ_IRQ_H |
---|
27 | #define LIBBSP_POWERPC_MVME5500_IRQ_IRQ_H |
---|
28 | |
---|
29 | |
---|
30 | #define BSP_ASM_IRQ_VECTOR_BASE 0x0 |
---|
31 | |
---|
32 | #ifndef ASM |
---|
33 | |
---|
34 | #define DynamicIrqTbl 1 |
---|
35 | |
---|
36 | /* |
---|
37 | * Symbolic IRQ names and related definitions. |
---|
38 | */ |
---|
39 | |
---|
40 | /* leave the ISA symbols in there, so we can reuse shared/irq.c |
---|
41 | * Also, we start numbering PCI irqs at 16 because the OPENPIC |
---|
42 | * driver relies on this when mapping irq number <-> vectors |
---|
43 | * (OPENPIC_VEC_SOURCE in openpic.h) |
---|
44 | */ |
---|
45 | |
---|
46 | typedef enum { |
---|
47 | /* See section 25.2 , Table 734 of GT64260 controller |
---|
48 | * Main Interrupt Cause Low register |
---|
49 | */ |
---|
50 | BSP_MICL_IRQ_NUMBER = 32, |
---|
51 | BSP_MICL_IRQ_LOWEST_OFFSET = 0, |
---|
52 | BSP_MICL_IRQ_MAX_OFFSET = BSP_MICL_IRQ_LOWEST_OFFSET + BSP_MICL_IRQ_NUMBER -1, |
---|
53 | /* |
---|
54 | * Main Interrupt Cause High register |
---|
55 | */ |
---|
56 | BSP_MICH_IRQ_NUMBER = 32, |
---|
57 | BSP_MICH_IRQ_LOWEST_OFFSET = BSP_MICL_IRQ_MAX_OFFSET+1, |
---|
58 | BSP_MICH_IRQ_MAX_OFFSET = BSP_MICH_IRQ_LOWEST_OFFSET + BSP_MICH_IRQ_NUMBER -1, |
---|
59 | /* External GPP Interrupt assignements |
---|
60 | */ |
---|
61 | BSP_GPP_IRQ_NUMBER = 32, |
---|
62 | BSP_GPP_IRQ_LOWEST_OFFSET = BSP_MICH_IRQ_MAX_OFFSET+1, |
---|
63 | BSP_GPP_IRQ_MAX_OFFSET = BSP_GPP_IRQ_LOWEST_OFFSET + BSP_GPP_IRQ_NUMBER - 1, |
---|
64 | |
---|
65 | /* |
---|
66 | * PowerPc exceptions handled as interrupt where a rtems managed interrupt |
---|
67 | * handler might be connected |
---|
68 | */ |
---|
69 | BSP_PROCESSOR_IRQ_NUMBER = 1, |
---|
70 | BSP_PROCESSOR_IRQ_LOWEST_OFFSET = BSP_GPP_IRQ_MAX_OFFSET + 1, |
---|
71 | BSP_PROCESSOR_IRQ_MAX_OFFSET = BSP_PROCESSOR_IRQ_LOWEST_OFFSET + BSP_PROCESSOR_IRQ_NUMBER - 1, |
---|
72 | |
---|
73 | /* allow a couple of vectors for VME and counter/timer irq sources etc. |
---|
74 | * This is probably not needed any more. |
---|
75 | */ |
---|
76 | BSP_MISC_IRQ_NUMBER = 30, |
---|
77 | BSP_MISC_IRQ_LOWEST_OFFSET = BSP_PROCESSOR_IRQ_MAX_OFFSET + 1, |
---|
78 | BSP_MISC_IRQ_MAX_OFFSET = BSP_MISC_IRQ_LOWEST_OFFSET + BSP_MISC_IRQ_NUMBER - 1, |
---|
79 | |
---|
80 | #if 0 |
---|
81 | /* |
---|
82 | * ISA IRQ handler related definitions |
---|
83 | */ |
---|
84 | /* MVME5500 ISA local resources exist only if an IPMC 712/761 module |
---|
85 | * is mounted. |
---|
86 | */ |
---|
87 | BSP_ISA_IRQ_NUMBER = 0, |
---|
88 | BSP_ISA_IRQ_LOWEST_OFFSET = BSP_MISC_IRQ_MAX_OFFSET+1, |
---|
89 | BSP_ISA_IRQ_MAX_OFFSET = BSP_ISA_IRQ_LOWEST_OFFSET + BSP_ISA_IRQ_NUMBER - 1, |
---|
90 | |
---|
91 | #endif |
---|
92 | |
---|
93 | /* |
---|
94 | * Summary |
---|
95 | */ |
---|
96 | BSP_IRQ_NUMBER = BSP_MISC_IRQ_MAX_OFFSET + 1, |
---|
97 | BSP_MAIN_IRQ_NUMBER = 64, |
---|
98 | BSP_LOWEST_OFFSET = BSP_MICL_IRQ_LOWEST_OFFSET, |
---|
99 | BSP_MAX_OFFSET = BSP_MISC_IRQ_MAX_OFFSET, |
---|
100 | |
---|
101 | /* Main CPU interrupt cause (Low) */ |
---|
102 | BSP_MAIN_TIMER0_1_IRQ = BSP_MICL_IRQ_LOWEST_OFFSET+8, |
---|
103 | BSP_MAIN_PCI0_7_0 = BSP_MICL_IRQ_LOWEST_OFFSET+12, |
---|
104 | BSP_MAIN_PCI0_15_8 = BSP_MICL_IRQ_LOWEST_OFFSET+13, |
---|
105 | BSP_MAIN_PCI0_23_16 = BSP_MICL_IRQ_LOWEST_OFFSET+14, |
---|
106 | BSP_MAIN_PCI0_31_24 = BSP_MICL_IRQ_LOWEST_OFFSET+15, |
---|
107 | BSP_MAIN_PCI1_7_0 = BSP_MICL_IRQ_LOWEST_OFFSET+16, |
---|
108 | BSP_MAIN_PCI1_15_8 = BSP_MICL_IRQ_LOWEST_OFFSET+18, |
---|
109 | BSP_MAIN_PCI1_23_16 = BSP_MICL_IRQ_LOWEST_OFFSET+19, |
---|
110 | BSP_MAIN_PCI1_31_24 = BSP_MICL_IRQ_LOWEST_OFFSET+20, |
---|
111 | |
---|
112 | |
---|
113 | /* Main CPU interrupt cause (High) */ |
---|
114 | BSP_MAIN_ETH0_IRQ = BSP_MICH_IRQ_LOWEST_OFFSET, |
---|
115 | BSP_MAIN_ETH1_IRQ = BSP_MICH_IRQ_LOWEST_OFFSET+1, |
---|
116 | BSP_MAIN_ETH2_IRQ = BSP_MICH_IRQ_LOWEST_OFFSET+2, |
---|
117 | BSP_MAIN_GPP7_0_IRQ = BSP_MICH_IRQ_LOWEST_OFFSET+24, |
---|
118 | BSP_MAIN_GPP15_8_IRQ = BSP_MICH_IRQ_LOWEST_OFFSET+25, |
---|
119 | BSP_MAIN_GPP23_16_IRQ = BSP_MICH_IRQ_LOWEST_OFFSET+26, |
---|
120 | BSP_MAIN_GPP31_24_IRQ = BSP_MICH_IRQ_LOWEST_OFFSET+27, |
---|
121 | |
---|
122 | /* on the MVME5500, these are the GT64260B external GPP0 interrupt */ |
---|
123 | BSP_ISA_UART_COM2_IRQ = BSP_GPP_IRQ_LOWEST_OFFSET, |
---|
124 | BSP_ISA_UART_COM1_IRQ = BSP_GPP_IRQ_LOWEST_OFFSET, |
---|
125 | BSP_GPP8_IRQ_OFFSET = BSP_GPP_IRQ_LOWEST_OFFSET+8, |
---|
126 | BSP_GPP16_IRQ_OFFSET = BSP_GPP_IRQ_LOWEST_OFFSET+16, |
---|
127 | BSP_GPP24_IRQ_OFFSET = BSP_GPP_IRQ_LOWEST_OFFSET+24, |
---|
128 | BSP_GPP_VME_VLINT0 = BSP_GPP_IRQ_LOWEST_OFFSET+12, |
---|
129 | BSP_GPP_VME_VLINT1 = BSP_GPP_IRQ_LOWEST_OFFSET+13, |
---|
130 | BSP_GPP_VME_VLINT2 = BSP_GPP_IRQ_LOWEST_OFFSET+14, |
---|
131 | BSP_GPP_VME_VLINT3 = BSP_GPP_IRQ_LOWEST_OFFSET+15, |
---|
132 | BSP_GPP_PMC2_INTA = BSP_GPP_IRQ_LOWEST_OFFSET+16, |
---|
133 | BSP_GPP_82544_IRQ = BSP_GPP_IRQ_LOWEST_OFFSET+20, |
---|
134 | BSP_GPP_WDT_NMI_IRQ = BSP_GPP_IRQ_LOWEST_OFFSET+24, |
---|
135 | BSP_GPP_WDT_EXP_IRQ = BSP_GPP_IRQ_LOWEST_OFFSET+25, |
---|
136 | |
---|
137 | /* |
---|
138 | * Some Processor execption handled as rtems IRQ symbolic name definition |
---|
139 | */ |
---|
140 | BSP_DECREMENTER = BSP_PROCESSOR_IRQ_LOWEST_OFFSET |
---|
141 | }rtems_irq_symbolic_name; |
---|
142 | |
---|
143 | /* |
---|
144 | * Type definition for RTEMS managed interrupts |
---|
145 | */ |
---|
146 | typedef unsigned char rtems_irq_prio; |
---|
147 | |
---|
148 | typedef unsigned int rtems_GTirq_masks; |
---|
149 | |
---|
150 | extern rtems_GTirq_masks GT_GPPirq_cache; |
---|
151 | extern rtems_GTirq_masks GT_MAINirqLO_cache, GT_MAINirqHI_cache; |
---|
152 | |
---|
153 | struct __rtems_irq_connect_data__; /* forward declaratiuon */ |
---|
154 | |
---|
155 | typedef void (*rtems_irq_hdl) (void); |
---|
156 | typedef void (*rtems_irq_ack) (void); |
---|
157 | typedef void (*rtems_irq_enable) (const struct __rtems_irq_connect_data__*); |
---|
158 | typedef void (*rtems_irq_disable) (const struct __rtems_irq_connect_data__*); |
---|
159 | typedef int (*rtems_irq_is_enabled) (const struct __rtems_irq_connect_data__*); |
---|
160 | |
---|
161 | typedef struct __rtems_irq_connect_data__ { |
---|
162 | /* |
---|
163 | * IRQ line |
---|
164 | */ |
---|
165 | rtems_irq_symbolic_name name; |
---|
166 | /* |
---|
167 | * handler. See comment on handler properties below in function prototype. |
---|
168 | */ |
---|
169 | rtems_irq_hdl hdl; |
---|
170 | /* |
---|
171 | * function for enabling interrupts at device level (ONLY!). |
---|
172 | * The BSP code will automatically enable it at i8259s level and openpic level. |
---|
173 | * RATIONALE : anyway such code has to exist in current driver code. |
---|
174 | * It is usually called immediately AFTER connecting the interrupt handler. |
---|
175 | * RTEMS may well need such a function when restoring normal interrupt |
---|
176 | * processing after a debug session. |
---|
177 | * |
---|
178 | */ |
---|
179 | rtems_irq_enable on; |
---|
180 | /* |
---|
181 | * function for disabling interrupts at device level (ONLY!). |
---|
182 | * The code will disable it at i8259s level. RATIONALE : anyway |
---|
183 | * such code has to exist for clean shutdown. It is usually called |
---|
184 | * BEFORE disconnecting the interrupt. RTEMS may well need such |
---|
185 | * a function when disabling normal interrupt processing for |
---|
186 | * a debug session. May well be a NOP function. |
---|
187 | */ |
---|
188 | rtems_irq_disable off; |
---|
189 | /* |
---|
190 | * function enabling to know what interrupt may currently occur |
---|
191 | * if someone manipulates the i8259s interrupt mask without care... |
---|
192 | */ |
---|
193 | rtems_irq_is_enabled isOn; |
---|
194 | /* |
---|
195 | * Set to -1 for vectors forced to have only 1 handler |
---|
196 | */ |
---|
197 | void *next_handler; |
---|
198 | |
---|
199 | }rtems_irq_connect_data; |
---|
200 | |
---|
201 | typedef struct { |
---|
202 | /* |
---|
203 | * size of all the table fields (*Tbl) described below. |
---|
204 | */ |
---|
205 | unsigned int irqNb; |
---|
206 | /* |
---|
207 | * Default handler used when disconnecting interrupts. |
---|
208 | */ |
---|
209 | rtems_irq_connect_data defaultEntry; |
---|
210 | /* |
---|
211 | * Table containing initials/current value. |
---|
212 | */ |
---|
213 | rtems_irq_connect_data* irqHdlTbl; |
---|
214 | /* |
---|
215 | * actual value of BSP_ISA_IRQ_VECTOR_BASE... |
---|
216 | */ |
---|
217 | rtems_irq_symbolic_name irqBase; |
---|
218 | /* |
---|
219 | * software priorities associated with interrupts. |
---|
220 | * if irqPrio [i] > intrPrio [j] it means that |
---|
221 | * interrupt handler hdl connected for interrupt name i |
---|
222 | * will not be interrupted by the handler connected for interrupt j |
---|
223 | * The interrupt source will be physically masked at i8259 level. |
---|
224 | */ |
---|
225 | rtems_irq_prio* irqPrioTbl; |
---|
226 | }rtems_irq_global_settings; |
---|
227 | |
---|
228 | /* |
---|
229 | * ------------------------ RTEMS Single Irq Handler Mngt Routines ---------------- |
---|
230 | */ |
---|
231 | /* |
---|
232 | * function to connect a particular irq handler. This hanlder will NOT be called |
---|
233 | * directly as the result of the corresponding interrupt. Instead, a RTEMS |
---|
234 | * irq prologue will be called that will : |
---|
235 | * |
---|
236 | * 1) save the C scratch registers, |
---|
237 | * 2) switch to a interrupt stack if the interrupt is not nested, |
---|
238 | * 3) store the current i8259s' interrupt masks |
---|
239 | * 4) modify them to disable the current interrupt at 8259 level (and may |
---|
240 | * be others depending on software priorities) |
---|
241 | * 5) aknowledge the i8259s', |
---|
242 | * 6) demask the processor, |
---|
243 | * 7) call the application handler |
---|
244 | * |
---|
245 | * As a result the hdl function provided |
---|
246 | * |
---|
247 | * a) can perfectly be written is C, |
---|
248 | * b) may also well directly call the part of the RTEMS API that can be used |
---|
249 | * from interrupt level, |
---|
250 | * c) It only responsible for handling the jobs that need to be done at |
---|
251 | * the device level including (aknowledging/re-enabling the interrupt at device, |
---|
252 | * level, getting the data,...) |
---|
253 | * |
---|
254 | * When returning from the function, the following will be performed by |
---|
255 | * the RTEMS irq epilogue : |
---|
256 | * |
---|
257 | * 1) masks the interrupts again, |
---|
258 | * 2) restore the original i8259s' interrupt masks |
---|
259 | * 3) switch back on the orinal stack if needed, |
---|
260 | * 4) perform rescheduling when necessary, |
---|
261 | * 5) restore the C scratch registers... |
---|
262 | * 6) restore initial execution flow |
---|
263 | * |
---|
264 | */ |
---|
265 | int BSP_install_rtems_irq_handler (const rtems_irq_connect_data*); |
---|
266 | int BSP_install_rtems_shared_irq_handler (const rtems_irq_connect_data*); |
---|
267 | |
---|
268 | #define BSP_SHARED_HANDLER_SUPPORT 1 |
---|
269 | |
---|
270 | /* |
---|
271 | * function to get the current RTEMS irq handler for ptr->name. It enables to |
---|
272 | * define hanlder chain... |
---|
273 | */ |
---|
274 | int BSP_get_current_rtems_irq_handler (rtems_irq_connect_data* ptr); |
---|
275 | /* |
---|
276 | * function to get disconnect the RTEMS irq handler for ptr->name. |
---|
277 | * This function checks that the value given is the current one for safety reason. |
---|
278 | * The user can use the previous function to get it. |
---|
279 | */ |
---|
280 | int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data*); |
---|
281 | |
---|
282 | /* |
---|
283 | * ------------------------ RTEMS Global Irq Handler Mngt Routines ---------------- |
---|
284 | */ |
---|
285 | /* |
---|
286 | * (Re) Initialize the RTEMS interrupt management. |
---|
287 | * |
---|
288 | * The result of calling this function will be the same as if each individual |
---|
289 | * handler (config->irqHdlTbl[i].hdl) different from "config->defaultEntry.hdl" |
---|
290 | * has been individualy connected via |
---|
291 | * BSP_install_rtems_irq_handler(&config->irqHdlTbl[i]) |
---|
292 | * And each handler currently equal to config->defaultEntry.hdl |
---|
293 | * has been previously disconnected via |
---|
294 | * BSP_remove_rtems_irq_handler (&config->irqHdlTbl[i]) |
---|
295 | * |
---|
296 | * This is to say that all information given will be used and not just |
---|
297 | * only the space. |
---|
298 | * |
---|
299 | * CAUTION : the various table address contained in config will be used |
---|
300 | * directly by the interrupt mangement code in order to save |
---|
301 | * data size so they must stay valid after the call => they should |
---|
302 | * not be modified or declared on a stack. |
---|
303 | */ |
---|
304 | |
---|
305 | int BSP_rtems_irq_mngt_set(rtems_irq_global_settings* config); |
---|
306 | /* |
---|
307 | * (Re) get info on current RTEMS interrupt management. |
---|
308 | */ |
---|
309 | int BSP_rtems_irq_mngt_get(rtems_irq_global_settings**); |
---|
310 | |
---|
311 | void BSP_enable_main_irq(unsigned irqNum); |
---|
312 | void BSP_disable_main_irq(unsigned irqNum); |
---|
313 | void BSP_enable_gpp_irq(unsigned irqNum); |
---|
314 | void BSP_disable_gpp_irq(unsigned irqNum); |
---|
315 | |
---|
316 | extern void BSP_rtems_irq_mng_init(unsigned cpuId); |
---|
317 | extern int gpp_int_error; |
---|
318 | #if DynamicIrqTbl |
---|
319 | extern int MainIrqTblPtr; |
---|
320 | extern unsigned long long MainIrqInTbl; |
---|
321 | extern unsigned char GPPinMainIrqTbl[4]; |
---|
322 | #endif |
---|
323 | extern unsigned int mainIrqTbl[64]; |
---|
324 | extern unsigned int GPP7_0IrqTbl[8]; |
---|
325 | extern unsigned int GPP15_8IrqTbl[8]; |
---|
326 | extern unsigned int GPP23_16IrqTbl[8]; |
---|
327 | extern unsigned int GPP31_24IrqTbl[8]; |
---|
328 | |
---|
329 | #endif |
---|
330 | |
---|
331 | #endif |
---|