]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/intc_v3_2/src/xintc_l.h
Common scheduler code:
[freertos] / FreeRTOS / Demo / MicroBlaze_Kintex7_EthernetLite / BSP / microblaze_0 / libsrc / intc_v3_2 / src / xintc_l.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2002 - 2014 Xilinx, Inc.  All rights reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to deal
7 * in the Software without restriction, including without limitation the rights
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 * copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * Use of the Software is limited solely to applications:
16 * (a) running on a Xilinx device, or
17 * (b) that interact with a Xilinx device through a bus or interconnect.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * XILINX  BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
24 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25 * SOFTWARE.
26 *
27 * Except as contained in this notice, the name of the Xilinx shall not be used
28 * in advertising or otherwise to promote the sale, use or other dealings in
29 * this Software without prior written authorization from Xilinx.
30 *
31 ******************************************************************************/
32 /*****************************************************************************/
33 /**
34 *
35 * @file xintc_l.h
36 *
37 * This header file contains identifiers and low-level driver functions (or
38 * macros) that can be used to access the device.  The user should refer to the
39 * hardware device specification for more details of the device operation.
40 *
41 *
42 * Note that users of the driver interface given in this file can register
43 * an interrupt handler dynamically (at run-time) using the
44 * XIntc_RegisterHandler() function.
45 * User of the driver interface given in xintc.h should still use
46 * XIntc_Connect(), as always.
47 * Also see the discussion of the interrupt vector tables in xintc.h.
48 *
49 * There are currently two interrupt handlers specified in this interface.
50 *
51 * - XIntc_LowLevelInterruptHandler() is a handler without any arguments that
52 *   is used in cases where there is a single interrupt controller device in
53 *   the system and the handler cannot be passed an argument. This function is
54 *   provided mostly for backward compatibility.
55 *
56 * - XIntc_DeviceInterruptHandler() is a handler that takes a device ID as an
57 *   argument, indicating which interrupt controller device in the system is
58 *   causing the interrupt - thereby supporting multiple interrupt controllers.
59 *
60 * <pre>
61 * MODIFICATION HISTORY:
62 *
63 * Ver   Who  Date     Changes
64 * ----- ---- -------- -----------------------------------------------------
65 * 1.00b jhl  04/24/02 First release
66 * 1.00c rpm  10/17/03 New release. Support the static vector table created
67 *                     in the xintc_g.c configuration table.
68 * 1.10c mta  03/21/07 Updated to new coding style
69 * 1.11a sv   11/21/07 Updated driver to support access through a DCR bridge
70 * 2.00a ktn  10/20/09 Updated to use HAL Processor APIs. _m is removed from all
71 *                     the macro definitions.
72 * 2.04a bss  01/13/12 Updated for adding defines for IMR and IVAR for
73 *                     the FAST Interrupt
74 * 2.05a bss  08/18/12 Added XIntc_RegisterFastHandler API to register fast
75 *                     interrupt handlers using base address.
76 * 2.07a bss  10/18/13 Added XIN_ILR_OFFSET macro for nested interrupts.
77 *
78 * </pre>
79 *
80 ******************************************************************************/
81
82 #ifndef XINTC_L_H               /* prevent circular inclusions */
83 #define XINTC_L_H               /* by using protection macros */
84
85 #ifdef __cplusplus
86 extern "C" {
87 #endif
88
89 /***************************** Include Files *********************************/
90
91 #include "xil_types.h"
92 #include "xil_assert.h"
93 #include "xparameters.h"
94 #include "xil_io.h"
95
96 /*
97  * XPAR_XINTC_USE_DCR_BRIDGE has to be set to 1 if the Intc device will be
98  * accessed through a DCR bus connected to a bridge.
99  */
100 #define XPAR_XINTC_USE_DCR_BRIDGE 0
101
102 #if ((XPAR_XINTC_USE_DCR != 0) || (XPAR_XINTC_USE_DCR_BRIDGE != 0))
103 #include "xio_dcr.h"
104 #endif
105
106 /************************** Constant Definitions *****************************/
107
108 /* define the offsets from the base address for all the registers of the
109  * interrupt controller, some registers may be optional in the hardware device
110  */
111 #if ((XPAR_XINTC_USE_DCR != 0) || (XPAR_XINTC_USE_DCR_BRIDGE != 0))
112
113 #define XIN_ISR_OFFSET      0   /* Interrupt Status Register */
114 #define XIN_IPR_OFFSET      1   /* Interrupt Pending Register */
115 #define XIN_IER_OFFSET      2   /* Interrupt Enable Register */
116 #define XIN_IAR_OFFSET      3   /* Interrupt Acknowledge Register */
117 #define XIN_SIE_OFFSET      4   /* Set Interrupt Enable Register */
118 #define XIN_CIE_OFFSET      5   /* Clear Interrupt Enable Register */
119 #define XIN_IVR_OFFSET      6   /* Interrupt Vector Register */
120 #define XIN_MER_OFFSET      7   /* Master Enable Register */
121 #define XIN_IMR_OFFSET      8   /* Interrupt Mode Register , this is present
122                                  *  only for Fast Interrupt */
123 #define XIN_IVAR_OFFSET     64  /* Interrupt Vector Address Register
124                                  * Interrupt 0 Offest, this is present
125                                  * only for Fast Interrupt */
126
127 #else /* ((XPAR_XINTC_USE_DCR != 0) || (XPAR_XINTC_USE_DCR_BRIDGE != 0)) */
128
129 #define XIN_ISR_OFFSET      0   /* Interrupt Status Register */
130 #define XIN_IPR_OFFSET      4   /* Interrupt Pending Register */
131 #define XIN_IER_OFFSET      8   /* Interrupt Enable Register */
132 #define XIN_IAR_OFFSET      12  /* Interrupt Acknowledge Register */
133 #define XIN_SIE_OFFSET      16  /* Set Interrupt Enable Register */
134 #define XIN_CIE_OFFSET      20  /* Clear Interrupt Enable Register */
135 #define XIN_IVR_OFFSET      24  /* Interrupt Vector Register */
136 #define XIN_MER_OFFSET      28  /* Master Enable Register */
137 #define XIN_IMR_OFFSET      32  /* Interrupt Mode Register , this is present
138                                  *  only for Fast Interrupt */
139 #define XIN_ILR_OFFSET      36  /* Interrupt level register */
140 #define XIN_IVAR_OFFSET     0x100 /* Interrupt Vector Address Register
141                                    * Interrupt 0 Offest, this is present
142                                    * only for Fast Interrupt */
143
144
145
146 #endif /* ((XPAR_XINTC_USE_DCR != 0) || (XPAR_XINTC_USE_DCR_BRIDGE != 0)) */
147
148 /* Bit definitions for the bits of the MER register */
149
150 #define XIN_INT_MASTER_ENABLE_MASK      0x1UL
151 #define XIN_INT_HARDWARE_ENABLE_MASK    0x2UL   /* once set cannot be cleared */
152
153 /**************************** Type Definitions *******************************/
154
155 /* The following data type defines each entry in an interrupt vector table.
156  * The callback reference is the base address of the interrupting device
157  * for the driver interface given in this file and an instance pointer for the
158  * driver interface given in xintc.h file.
159  */
160 typedef struct {
161         XInterruptHandler Handler;
162         void *CallBackRef;
163 } XIntc_VectorTableEntry;
164
165 typedef void (*XFastInterruptHandler) (void);
166
167 /***************** Macros (Inline Functions) Definitions *********************/
168
169 /*
170  * Define the appropriate I/O access method to memory mapped I/O or DCR.
171  */
172 #if ((XPAR_XINTC_USE_DCR != 0) || (XPAR_XINTC_USE_DCR_BRIDGE != 0))
173
174 #define XIntc_In32  XIo_DcrIn
175 #define XIntc_Out32 XIo_DcrOut
176
177 #else
178
179 #define XIntc_In32  Xil_In32
180 #define XIntc_Out32 Xil_Out32
181
182 #endif
183
184 /****************************************************************************/
185 /**
186 *
187 * Enable all interrupts in the Master Enable register of the interrupt
188 * controller.  The interrupt controller defaults to all interrupts disabled
189 * from reset such that this macro must be used to enable interrupts.
190 *
191 * @param        BaseAddress is the base address of the device.
192 *
193 * @return       None.
194 *
195 * @note         C-style signature:
196 *               void XIntc_MasterEnable(u32 BaseAddress);
197 *
198 *****************************************************************************/
199 #define XIntc_MasterEnable(BaseAddress) \
200         XIntc_Out32((BaseAddress) + XIN_MER_OFFSET, \
201         XIN_INT_MASTER_ENABLE_MASK | XIN_INT_HARDWARE_ENABLE_MASK)
202
203 /****************************************************************************/
204 /**
205 *
206 * Disable all interrupts in the Master Enable register of the interrupt
207 * controller.
208 *
209 * @param        BaseAddress is the base address of the device.
210 *
211 * @return       None.
212 *
213 * @note         C-style signature:
214 *               void XIntc_MasterDisable(u32 BaseAddress);
215 *
216 *****************************************************************************/
217 #define XIntc_MasterDisable(BaseAddress) \
218         XIntc_Out32((BaseAddress) + XIN_MER_OFFSET, 0)
219
220 /****************************************************************************/
221 /**
222 *
223 * Enable specific interrupt(s) in the interrupt controller.
224 *
225 * @param        BaseAddress is the base address of the device
226 * @param        EnableMask is the 32-bit value to write to the enable register.
227 *               Each bit of the mask corresponds to an interrupt input signal
228 *               that is connected to the interrupt controller (INT0 = LSB).
229 *               Only the bits which are set in the mask will enable interrupts.
230 *
231 * @return       None.
232 *
233 * @note         C-style signature:
234 *               void XIntc_EnableIntr(u32 BaseAddress, u32 EnableMask);
235 *
236 *****************************************************************************/
237 #define XIntc_EnableIntr(BaseAddress, EnableMask) \
238         XIntc_Out32((BaseAddress) + XIN_IER_OFFSET, (EnableMask))
239
240 /****************************************************************************/
241 /**
242 *
243 * Disable specific interrupt(s) in the interrupt controller.
244 *
245 * @param        BaseAddress is the base address of the device
246 * @param        DisableMask is the 32-bit value to write to the enable register.
247 *               Each bit of the mask corresponds to an interrupt input signal
248 *               that is connected to the interrupt controller (INT0 = LSB).
249 *               Only the bits which are set in the mask will disable interrupts.
250 *
251 * @return       None.
252 *
253 * @note         C-style signature:
254 *               void XIntc_DisableIntr(u32 BaseAddress, u32 DisableMask);
255 *
256 *****************************************************************************/
257 #define XIntc_DisableIntr(BaseAddress, DisableMask) \
258         XIntc_Out32((BaseAddress) + XIN_IER_OFFSET, ~(DisableMask))
259
260 /****************************************************************************/
261 /**
262 *
263 * Acknowledge specific interrupt(s) in the interrupt controller.
264 *
265 * @param        BaseAddress is the base address of the device
266 * @param        AckMask is the 32-bit value to write to the acknowledge
267 *               register. Each bit of the mask corresponds to an interrupt input
268 *               signal that is connected to the interrupt controller (INT0 =
269 *               LSB).  Only the bits which are set in the mask will acknowledge
270 *               interrupts.
271 *
272 * @return       None.
273 *
274 * @note         C-style signature:
275 *               void XIntc_AckIntr(u32 BaseAddress, u32 AckMask);
276 *
277 *****************************************************************************/
278 #define XIntc_AckIntr(BaseAddress, AckMask) \
279         XIntc_Out32((BaseAddress) + XIN_IAR_OFFSET, (AckMask))
280
281 /****************************************************************************/
282 /**
283 *
284 * Get the interrupt status from the interrupt controller which indicates
285 * which interrupts are active and enabled.
286 *
287 * @param        BaseAddress is the base address of the device
288 *
289 * @return       The 32-bit contents of the interrupt status register. Each bit
290 *               corresponds to an interrupt input signal that is connected to
291 *               the interrupt controller (INT0 = LSB). Bits which are set
292 *               indicate an active interrupt which is also enabled.
293 *
294 * @note         C-style signature:
295 *               u32 XIntc_GetIntrStatus(u32 BaseAddress);
296 *
297 *****************************************************************************/
298 #define XIntc_GetIntrStatus(BaseAddress) \
299         (XIntc_In32((BaseAddress) + XIN_ISR_OFFSET) & \
300         XIntc_In32((BaseAddress) + XIN_IER_OFFSET))
301
302 /************************** Function Prototypes ******************************/
303
304 /*
305  * Interrupt controller handlers, to be connected to processor exception
306  * handling code.
307  */
308 void XIntc_LowLevelInterruptHandler(void);
309 void XIntc_DeviceInterruptHandler(void *DeviceId);
310
311 /* Various configuration functions */
312 void XIntc_SetIntrSvcOption(u32 BaseAddress, int Option);
313
314 void XIntc_RegisterHandler(u32 BaseAddress, int InterruptId,
315                            XInterruptHandler Handler, void *CallBackRef);
316
317 void XIntc_RegisterFastHandler(u32 BaseAddress, u8 Id,
318                                         XFastInterruptHandler FastHandler);
319
320 /************************** Variable Definitions *****************************/
321
322
323 #ifdef __cplusplus
324 }
325 #endif
326
327 #endif /* end of protection macro */