]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/MicroBlaze_Kintex7_EthernetLite/BSP/microblaze_0/libsrc/intc_v3_2/src/xintc_intr.c
Common scheduler code:
[freertos] / FreeRTOS / Demo / MicroBlaze_Kintex7_EthernetLite / BSP / microblaze_0 / libsrc / intc_v3_2 / src / xintc_intr.c
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_intr.c
36 *
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.
42 *
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.
55 *
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.
58 *
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
64 * deemed necessary.
65 *
66 * <pre>
67 * MODIFICATION HISTORY:
68 *
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.
80 *
81 * </pre>
82 *
83 * @internal
84 *
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.
91 *
92 ******************************************************************************/
93
94 /***************************** Include Files *********************************/
95
96 #include "xil_types.h"
97 #include "xil_assert.h"
98 #include "xparameters.h"
99 #include "xintc.h"
100
101 /************************** Constant Definitions *****************************/
102
103
104
105 /**************************** Type Definitions *******************************/
106
107
108 /***************** Macros (Inline Functions) Definitions *********************/
109
110
111 /************************** Function Prototypes ******************************/
112
113
114 /************************** Variable Definitions *****************************/
115
116
117 /*****************************************************************************/
118 /**
119 *
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,
123 * if possible.
124 *
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.
127 *
128 * @return       None.
129 *
130 * @note
131 *
132 * The constant XPAR_INTC_SINGLE_DEVICE_ID must be defined for this handler
133 * to be included in the driver compilation.
134 *
135 ******************************************************************************/
136 #ifdef XPAR_INTC_SINGLE_DEVICE_ID
137 void XIntc_VoidInterruptHandler(void)
138 {
139         /* Use the single instance to call the main interrupt handler */
140         XIntc_DeviceInterruptHandler((void *) XPAR_INTC_SINGLE_DEVICE_ID);
141 }
142 #endif
143
144 /*****************************************************************************/
145 /**
146 *
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.
151 *
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.
154 *
155 * @param        InstancePtr is a pointer to the XIntc instance to be worked on.
156 *
157 * @return       None.
158 *
159 * @note         None.
160 *
161 ******************************************************************************/
162 void XIntc_InterruptHandler(XIntc * InstancePtr)
163 {
164         /* Assert that the pointer to the instance is valid
165          */
166         Xil_AssertVoid(InstancePtr != NULL);
167
168         /* Use the instance's device ID to call the main interrupt handler.
169          * (the casts are to avoid a compiler warning)
170          */
171         XIntc_DeviceInterruptHandler((void *)
172                                      ((u32) (InstancePtr->CfgPtr->DeviceId)));
173 }