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