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.rtems.com/license/LICENSE. |
---|
12 | * |
---|
13 | * $Id$ |
---|
14 | */ |
---|
15 | |
---|
16 | #ifndef _IRQ_H_ |
---|
17 | #define _IRQ_H_ |
---|
18 | |
---|
19 | #ifdef __cplusplus |
---|
20 | extern "C" { |
---|
21 | #endif |
---|
22 | |
---|
23 | /* |
---|
24 | * Include some preprocessor value also used by assember code |
---|
25 | */ |
---|
26 | |
---|
27 | #include <rtems.h> |
---|
28 | #include <s3c2400.h> |
---|
29 | |
---|
30 | extern void default_int_handler(); |
---|
31 | /*-------------------------------------------------------------------------+ |
---|
32 | | Constants |
---|
33 | +--------------------------------------------------------------------------*/ |
---|
34 | |
---|
35 | /* enum of the possible interrupt sources */ |
---|
36 | typedef enum { |
---|
37 | BSP_EINT0 = 0, |
---|
38 | BSP_EINT1, |
---|
39 | BSP_EINT2, |
---|
40 | BSP_EINT3, |
---|
41 | BSP_EINT4, |
---|
42 | BSP_EINT5, |
---|
43 | BSP_EINT6, |
---|
44 | BSP_EINT7, |
---|
45 | BSP_INT_TICK, |
---|
46 | BSP_INT_WDT, |
---|
47 | BSP_INT_TIMER0, |
---|
48 | BSP_INT_TIMER1, |
---|
49 | BSP_INT_TIMER2, |
---|
50 | BSP_INT_TIMER3, |
---|
51 | BSP_INT_TIMER4, |
---|
52 | BSP_INT_UERR01, |
---|
53 | _res0, |
---|
54 | BSP_INT_DMA0, |
---|
55 | BSP_INT_DMA1, |
---|
56 | BSP_INT_DMA2, |
---|
57 | BSP_INT_DMA3, |
---|
58 | BSP_INT_MMC, |
---|
59 | BSP_INT_SPI, |
---|
60 | BSP_INT_URXD0, |
---|
61 | BSP_INT_URXD1, |
---|
62 | BSP_INT_USBD, |
---|
63 | BSP_INT_USBH, |
---|
64 | BSP_INT_IIC, |
---|
65 | BSP_INT_UTXD0, |
---|
66 | BSP_INT_UTXD1, |
---|
67 | BSP_INT_RTC, |
---|
68 | BSP_INT_ADC, |
---|
69 | |
---|
70 | BSP_MAX_INT |
---|
71 | } rtems_irq_symbolic_name; |
---|
72 | |
---|
73 | extern void *bsp_vector_table; |
---|
74 | #define VECTOR_TABLE &bsp_vector_table |
---|
75 | |
---|
76 | /* |
---|
77 | * Type definition for RTEMS managed interrupts |
---|
78 | */ |
---|
79 | typedef unsigned char rtems_irq_level; |
---|
80 | typedef unsigned char rtems_irq_trigger; |
---|
81 | |
---|
82 | struct __rtems_irq_connect_data__; /* forward declaratiuon */ |
---|
83 | |
---|
84 | typedef void (*rtems_irq_hdl) (void); |
---|
85 | typedef void (*rtems_irq_enable) (const struct __rtems_irq_connect_data__*); |
---|
86 | typedef void (*rtems_irq_disable) (const struct __rtems_irq_connect_data__*); |
---|
87 | typedef int (*rtems_irq_is_enabled) (const struct __rtems_irq_connect_data__*); |
---|
88 | |
---|
89 | typedef struct __rtems_irq_connect_data__ { |
---|
90 | /* |
---|
91 | * IRQ line |
---|
92 | */ |
---|
93 | rtems_irq_symbolic_name name; |
---|
94 | |
---|
95 | /* |
---|
96 | * handler. See comment on handler properties below in function prototype. |
---|
97 | */ |
---|
98 | rtems_irq_hdl hdl; |
---|
99 | |
---|
100 | /* |
---|
101 | * function for enabling interrupts at device level (ONLY!). |
---|
102 | * The BSP code will automatically enable it at i8259s level. |
---|
103 | * RATIONALE : anyway such code has to exist in current driver code. |
---|
104 | * It is usually called immediately AFTER connecting the interrupt handler. |
---|
105 | * RTEMS may well need such a function when restoring normal interrupt |
---|
106 | * processing after a debug session. |
---|
107 | * |
---|
108 | */ |
---|
109 | rtems_irq_enable on; |
---|
110 | |
---|
111 | /* |
---|
112 | * function for disabling interrupts at device level (ONLY!). |
---|
113 | * The code will disable it at i8259s level. RATIONALE : anyway |
---|
114 | * such code has to exist for clean shutdown. It is usually called |
---|
115 | * BEFORE disconnecting the interrupt. RTEMS may well need such |
---|
116 | * a function when disabling normal interrupt processing for |
---|
117 | * a debug session. May well be a NOP function. |
---|
118 | */ |
---|
119 | rtems_irq_disable off; |
---|
120 | |
---|
121 | /* |
---|
122 | * function enabling to know what interrupt may currently occur |
---|
123 | * if someone manipulates the i8259s interrupt mask without care... |
---|
124 | */ |
---|
125 | rtems_irq_is_enabled isOn; |
---|
126 | |
---|
127 | /* |
---|
128 | * priority level at the vplus level |
---|
129 | */ |
---|
130 | rtems_irq_level irqLevel; |
---|
131 | |
---|
132 | /* |
---|
133 | * Trigger way : Rising or falling edge or High or low level |
---|
134 | */ |
---|
135 | rtems_irq_trigger irqTrigger; |
---|
136 | |
---|
137 | } rtems_irq_connect_data; |
---|
138 | |
---|
139 | /*-------------------------------------------------------------------------+ |
---|
140 | | Function Prototypes. |
---|
141 | +--------------------------------------------------------------------------*/ |
---|
142 | /* |
---|
143 | * ------------------ RTEMS Single Irq Handler Mngt Routines ---------------- |
---|
144 | */ |
---|
145 | |
---|
146 | /* |
---|
147 | * function to initialize the interrupt for a specific BSP |
---|
148 | */ |
---|
149 | void BSP_rtems_irq_mngt_init(); |
---|
150 | |
---|
151 | |
---|
152 | /* |
---|
153 | * function to connect a particular irq handler. This hanlder will NOT be called |
---|
154 | * directly as the result of the corresponding interrupt. Instead, a RTEMS |
---|
155 | * irq prologue will be called that will : |
---|
156 | * |
---|
157 | * 1) save the C scratch registers, |
---|
158 | * 2) switch to a interrupt stack if the interrupt is not nested, |
---|
159 | * 3) store the current i8259s' interrupt masks |
---|
160 | * 4) modify them to disable the current interrupt at 8259 level (and may |
---|
161 | * be others depending on software priorities) |
---|
162 | * 5) aknowledge the i8259s', |
---|
163 | * 6) demask the processor, |
---|
164 | * 7) call the application handler |
---|
165 | * |
---|
166 | * As a result the hdl function provided |
---|
167 | * |
---|
168 | * a) can perfectly be written is C, |
---|
169 | * b) may also well directly call the part of the RTEMS API that can be used |
---|
170 | * from interrupt level, |
---|
171 | * c) It only responsible for handling the jobs that need to be done at |
---|
172 | * the device level including (aknowledging/re-enabling the interrupt at device, |
---|
173 | * level, getting the data,...) |
---|
174 | * |
---|
175 | * When returning from the function, the following will be performed by |
---|
176 | * the RTEMS irq epilogue : |
---|
177 | * |
---|
178 | * 1) masks the interrupts again, |
---|
179 | * 2) restore the original i8259s' interrupt masks |
---|
180 | * 3) switch back on the orinal stack if needed, |
---|
181 | * 4) perform rescheduling when necessary, |
---|
182 | * 5) restore the C scratch registers... |
---|
183 | * 6) restore initial execution flow |
---|
184 | * |
---|
185 | */ |
---|
186 | int BSP_install_rtems_irq_handler (const rtems_irq_connect_data*); |
---|
187 | |
---|
188 | /* |
---|
189 | * function to get the current RTEMS irq handler for ptr->name. It enables to |
---|
190 | * define hanlder chain... |
---|
191 | */ |
---|
192 | int BSP_get_current_rtems_irq_handler (rtems_irq_connect_data* ptr); |
---|
193 | |
---|
194 | /* |
---|
195 | * function to get disconnect the RTEMS irq handler for ptr->name. |
---|
196 | * This function checks that the value given is the current one for safety reason. |
---|
197 | * The user can use the previous function to get it. |
---|
198 | */ |
---|
199 | int BSP_remove_rtems_irq_handler (const rtems_irq_connect_data*); |
---|
200 | |
---|
201 | |
---|
202 | #ifdef __cplusplus |
---|
203 | } |
---|
204 | #endif |
---|
205 | |
---|
206 | #endif /* _IRQ_H_ */ |
---|
207 | /* end of include file */ |
---|