1 /******************************************************************************
3 * Copyright (C) 2002 - 2014 Xilinx, Inc. All rights reserved.
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:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
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.
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
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.
31 ******************************************************************************/
32 /*****************************************************************************/
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.
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.
49 * There are currently two interrupt handlers specified in this interface.
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.
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.
61 * MODIFICATION HISTORY:
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
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.
80 ******************************************************************************/
82 #ifndef XINTC_L_H /* prevent circular inclusions */
83 #define XINTC_L_H /* by using protection macros */
89 /***************************** Include Files *********************************/
91 #include "xil_types.h"
92 #include "xil_assert.h"
93 #include "xparameters.h"
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.
100 #define XPAR_XINTC_USE_DCR_BRIDGE 0
102 #if ((XPAR_XINTC_USE_DCR != 0) || (XPAR_XINTC_USE_DCR_BRIDGE != 0))
106 /************************** Constant Definitions *****************************/
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
111 #if ((XPAR_XINTC_USE_DCR != 0) || (XPAR_XINTC_USE_DCR_BRIDGE != 0))
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 */
127 #else /* ((XPAR_XINTC_USE_DCR != 0) || (XPAR_XINTC_USE_DCR_BRIDGE != 0)) */
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 */
146 #endif /* ((XPAR_XINTC_USE_DCR != 0) || (XPAR_XINTC_USE_DCR_BRIDGE != 0)) */
148 /* Bit definitions for the bits of the MER register */
150 #define XIN_INT_MASTER_ENABLE_MASK 0x1UL
151 #define XIN_INT_HARDWARE_ENABLE_MASK 0x2UL /* once set cannot be cleared */
153 /**************************** Type Definitions *******************************/
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.
161 XInterruptHandler Handler;
163 } XIntc_VectorTableEntry;
165 typedef void (*XFastInterruptHandler) (void);
167 /***************** Macros (Inline Functions) Definitions *********************/
170 * Define the appropriate I/O access method to memory mapped I/O or DCR.
172 #if ((XPAR_XINTC_USE_DCR != 0) || (XPAR_XINTC_USE_DCR_BRIDGE != 0))
174 #define XIntc_In32 XIo_DcrIn
175 #define XIntc_Out32 XIo_DcrOut
179 #define XIntc_In32 Xil_In32
180 #define XIntc_Out32 Xil_Out32
184 /****************************************************************************/
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.
191 * @param BaseAddress is the base address of the device.
195 * @note C-style signature:
196 * void XIntc_MasterEnable(u32 BaseAddress);
198 *****************************************************************************/
199 #define XIntc_MasterEnable(BaseAddress) \
200 XIntc_Out32((BaseAddress) + XIN_MER_OFFSET, \
201 XIN_INT_MASTER_ENABLE_MASK | XIN_INT_HARDWARE_ENABLE_MASK)
203 /****************************************************************************/
206 * Disable all interrupts in the Master Enable register of the interrupt
209 * @param BaseAddress is the base address of the device.
213 * @note C-style signature:
214 * void XIntc_MasterDisable(u32 BaseAddress);
216 *****************************************************************************/
217 #define XIntc_MasterDisable(BaseAddress) \
218 XIntc_Out32((BaseAddress) + XIN_MER_OFFSET, 0)
220 /****************************************************************************/
223 * Enable specific interrupt(s) in the interrupt controller.
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.
233 * @note C-style signature:
234 * void XIntc_EnableIntr(u32 BaseAddress, u32 EnableMask);
236 *****************************************************************************/
237 #define XIntc_EnableIntr(BaseAddress, EnableMask) \
238 XIntc_Out32((BaseAddress) + XIN_IER_OFFSET, (EnableMask))
240 /****************************************************************************/
243 * Disable specific interrupt(s) in the interrupt controller.
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.
253 * @note C-style signature:
254 * void XIntc_DisableIntr(u32 BaseAddress, u32 DisableMask);
256 *****************************************************************************/
257 #define XIntc_DisableIntr(BaseAddress, DisableMask) \
258 XIntc_Out32((BaseAddress) + XIN_IER_OFFSET, ~(DisableMask))
260 /****************************************************************************/
263 * Acknowledge specific interrupt(s) in the interrupt controller.
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
274 * @note C-style signature:
275 * void XIntc_AckIntr(u32 BaseAddress, u32 AckMask);
277 *****************************************************************************/
278 #define XIntc_AckIntr(BaseAddress, AckMask) \
279 XIntc_Out32((BaseAddress) + XIN_IAR_OFFSET, (AckMask))
281 /****************************************************************************/
284 * Get the interrupt status from the interrupt controller which indicates
285 * which interrupts are active and enabled.
287 * @param BaseAddress is the base address of the device
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.
294 * @note C-style signature:
295 * u32 XIntc_GetIntrStatus(u32 BaseAddress);
297 *****************************************************************************/
298 #define XIntc_GetIntrStatus(BaseAddress) \
299 (XIntc_In32((BaseAddress) + XIN_ISR_OFFSET) & \
300 XIntc_In32((BaseAddress) + XIN_IER_OFFSET))
302 /************************** Function Prototypes ******************************/
305 * Interrupt controller handlers, to be connected to processor exception
308 void XIntc_LowLevelInterruptHandler(void);
309 void XIntc_DeviceInterruptHandler(void *DeviceId);
311 /* Various configuration functions */
312 void XIntc_SetIntrSvcOption(u32 BaseAddress, int Option);
314 void XIntc_RegisterHandler(u32 BaseAddress, int InterruptId,
315 XInterruptHandler Handler, void *CallBackRef);
317 void XIntc_RegisterFastHandler(u32 BaseAddress, u8 Id,
318 XFastInterruptHandler FastHandler);
320 /************************** Variable Definitions *****************************/
327 #endif /* end of protection macro */