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 file contains the interrupt processing for the XIntc component which
38 * is the driver for the Xilinx Interrupt Controller. The interrupt
39 * processing is partitioned seperately such that users are not required to
40 * use the provided interrupt processing. This file requires other files of
41 * the driver to be linked in also.
43 * Two different interrupt handlers are provided for this driver such that the
44 * user must select the appropriate handler for the application. The first
45 * interrupt handler, XIntc_VoidInterruptHandler, is provided for systems
46 * which use only a single interrupt controller or for systems that cannot
47 * otherwise provide an argument to the XIntc interrupt handler (e.g., the RTOS
48 * interrupt vector handler may not provide such a facility). The constant
49 * XPAR_INTC_SINGLE_DEVICE_ID must be defined for this handler to be included in
50 * the driver. The second interrupt handler, XIntc_InterruptHandler, uses an
51 * input argument which is an instance pointer to an interrupt controller driver
52 * such that multiple interrupt controllers can be supported. This handler
53 * requires the calling function to pass it the appropriate argument, so another
54 * level of indirection may be required.
56 * Note that both of these handlers are now only provided for backward
57 * compatibility. The handler defined in xintc_l.c is the recommended handler.
59 * The interrupt processing may be used by connecting one of the interrupt
60 * handlers to the interrupt system. These handlers do not save and restore
61 * the processor context but only handle the processing of the Interrupt
62 * Controller. The two handlers are provided as working examples. The user is
63 * encouraged to supply their own interrupt handler when performance tuning is
67 * MODIFICATION HISTORY:
69 * Ver Who Date Changes
70 * ----- ---- -------- ---------------------------------------------------------
71 * 1.00b jhl 02/13/02 First release
72 * 1.00c rpm 10/17/03 New release. Support the static vector table created
73 * in the xintc_g.c configuration table. Collapse handlers
74 * to use the XIntc_DeviceInterruptHandler() in xintc_l.c.
75 * 1.00c rpm 04/09/04 Added conditional compilation around the old handler
76 * XIntc_VoidInterruptHandler(). This handler will only be
77 * include/compiled if XPAR_INTC_SINGLE_DEVICE_ID is defined.
78 * 1.10c mta 03/21/07 Updated to new coding style
79 * 2.00a ktn 10/20/09 Updated to use HAL Processor APIs.
85 * This driver assumes that the context of the processor has been saved prior to
86 * the calling of the Interrupt Controller interrupt handler and then restored
87 * after the handler returns. This requires either the running RTOS to save the
88 * state of the machine or that a wrapper be used as the destination of the
89 * interrupt vector to save the state of the processor and restore the state
90 * after the interrupt handler returns.
92 ******************************************************************************/
94 /***************************** Include Files *********************************/
96 #include "xil_types.h"
97 #include "xil_assert.h"
98 #include "xparameters.h"
101 /************************** Constant Definitions *****************************/
105 /**************************** Type Definitions *******************************/
108 /***************** Macros (Inline Functions) Definitions *********************/
111 /************************** Function Prototypes ******************************/
114 /************************** Variable Definitions *****************************/
117 /*****************************************************************************/
120 * Interrupt handler for the driver used when there can be no argument passed
121 * to the handler. This function is provided mostly for backward compatibility.
122 * The user should use XIntc_DeviceInterruptHandler(), defined in xintc_l.c,
125 * The user must connect this function to the interrupt system such that it is
126 * called whenever the devices which are connected to it cause an interrupt.
132 * The constant XPAR_INTC_SINGLE_DEVICE_ID must be defined for this handler
133 * to be included in the driver compilation.
135 ******************************************************************************/
136 #ifdef XPAR_INTC_SINGLE_DEVICE_ID
137 void XIntc_VoidInterruptHandler(void)
139 /* Use the single instance to call the main interrupt handler */
140 XIntc_DeviceInterruptHandler((void *) XPAR_INTC_SINGLE_DEVICE_ID);
144 /*****************************************************************************/
147 * The interrupt handler for the driver. This function is provided mostly for
148 * backward compatibility. The user should use XIntc_DeviceInterruptHandler(),
149 * defined in xintc_l.c when possible and pass the device ID of the interrupt
150 * controller device as its argument.
152 * The user must connect this function to the interrupt system such that it is
153 * called whenever the devices which are connected to it cause an interrupt.
155 * @param InstancePtr is a pointer to the XIntc instance to be worked on.
161 ******************************************************************************/
162 void XIntc_InterruptHandler(XIntc * InstancePtr)
164 /* Assert that the pointer to the instance is valid
166 Xil_AssertVoid(InstancePtr != NULL);
168 /* Use the instance's device ID to call the main interrupt handler.
169 * (the casts are to avoid a compiler warning)
171 XIntc_DeviceInterruptHandler((void *)
172 ((u32) (InstancePtr->CfgPtr->DeviceId)));