]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_A53_64-bit_UltraScale_MPSoC/RTOSDemo_A53_bsp/psu_cortexa53_0/include/xscugic.h
Completely re-generate the Zynq 7000 demo using the 2016.1 SDK tools.
[freertos] / FreeRTOS / Demo / CORTEX_A53_64-bit_UltraScale_MPSoC / RTOSDemo_A53_bsp / psu_cortexa53_0 / include / xscugic.h
1 /******************************************************************************
2 *
3 * Copyright (C) 2010 - 2015 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 xscugic.h
36 *
37 * The generic interrupt controller driver component.
38 *
39 * The interrupt controller driver uses the idea of priority for the various
40 * handlers. Priority is an integer within the range of 1 and 31 inclusive with
41 * default of 1 being the highest priority interrupt source. The priorities
42 * of the various sources can be dynamically altered as needed through
43 * hardware configuration.
44 *
45 * The generic interrupt controller supports the following
46 * features:
47 *
48 *   - specific individual interrupt enabling/disabling
49 *   - specific individual interrupt acknowledging
50 *   - attaching specific callback function to handle interrupt source
51 *   - assigning desired priority to interrupt source if default is not
52 *     acceptable.
53 *
54 * Details about connecting the interrupt handler of the driver are contained
55 * in the source file specific to interrupt processing, xscugic_intr.c.
56 *
57 * This driver is intended to be RTOS and processor independent.  It works with
58 * physical addresses only.  Any needs for dynamic memory management, threads
59 * or thread mutual exclusion, virtual memory, or cache control must be
60 * satisfied by the layer above this driver.
61 *
62 * <b>Interrupt Vector Tables</b>
63 *
64 * The device ID of the interrupt controller device is used by the driver as a
65 * direct index into the configuration data table. The user should populate the
66 * vector table with handlers and callbacks at run-time using the
67 * XScuGic_Connect() and XScuGic_Disconnect() functions.
68 *
69 * Each vector table entry corresponds to a device that can generate an
70 * interrupt. Each entry contains an interrupt handler function and an
71 * argument to be passed to the handler when an interrupt occurs.  The
72 * user must use XScuGic_Connect() when the interrupt handler takes an
73 * argument other than the base address.
74 *
75 * <b>Nested Interrupts Processing</b>
76 *
77 * Nested interrupts are not supported by this driver.
78 *
79 * NOTE:
80 * The generic interrupt controller is not a part of the snoop control unit
81 * as indicated by the prefix "scu" in the name of the driver.
82 * It is an independent module in APU.
83 *
84 * <pre>
85 * MODIFICATION HISTORY:
86 *
87 * Ver   Who  Date     Changes
88 * ----- ---- -------- ---------------------------------------------------------
89 * 1.00a drg  01/19/00 First release
90 * 1.01a sdm  11/09/11 The XScuGic and XScuGic_Config structures have changed.
91 *                     The HandlerTable (of type XScuGic_VectorTableEntry) is
92 *                     moved to XScuGic_Config structure from XScuGic structure.
93 *
94 *                     The "Config" entry in XScuGic structure is made as
95 *                     pointer for better efficiency.
96 *
97 *                     A new file named as xscugic_hw.c is now added. It is
98 *                     to implement low level driver routines without using
99 *                     any xscugic instance pointer. They are useful when the
100 *                     user wants to use xscugic through device id or
101 *                     base address. The driver routines provided are explained
102 *                     below.
103 *                     XScuGic_DeviceInitialize that takes device id as
104 *                     argument and initializes the device (without calling
105 *                     XScuGic_CfgInitialize).
106 *                     XScuGic_DeviceInterruptHandler that takes device id
107 *                     as argument and calls appropriate handlers from the
108 *                     HandlerTable.
109 *                     XScuGic_RegisterHandler that registers a new handler
110 *                     by taking xscugic hardware base address as argument.
111 *                     LookupConfigByBaseAddress is used to return the
112 *                     corresponding config structure from XScuGic_ConfigTable
113 *                     based on the scugic base address passed.
114 * 1.02a sdm  12/20/11 Removed AckBeforeService from the XScuGic_Config
115 *                     structure.
116 * 1.03a srt  02/27/13 Moved Offset calculation macros from *.c and *_hw.c to
117 *                     *_hw.h
118 *                     Added APIs
119 *                       - XScuGic_SetPriTrigTypeByDistAddr()
120 *                       - XScuGic_GetPriTrigTypeByDistAddr()
121 *                     (CR 702687)
122 *                       Added support to direct interrupts to the appropriate CPU. Earlier
123 *                         interrupts were directed to CPU1 (hard coded). Now depending
124 *                         upon the CPU selected by the user (xparameters.h), interrupts
125 *                         will be directed to the relevant CPU. This fixes CR 699688.
126 * 1.04a hk   05/04/13 Assigned EffectiveAddr to CpuBaseAddress in
127 *                         XScuGic_CfgInitialize. Fix for CR#704400 to remove warnings.
128 *                         Moved functions XScuGic_SetPriTrigTypeByDistAddr and
129 *             XScuGic_GetPriTrigTypeByDistAddr to xscugic_hw.c.
130 *                         This is fix for CR#705621.
131 * 1.05a hk   06/26/13 Modified tcl to export external interrupts correctly to
132 *                     xparameters.h. Fix for CR's 690505, 708928 & 719359.
133 * 2.0   adk  12/10/13 Updated as per the New Tcl API's
134 * 2.1   adk  25/04/14 Fixed the CR:789373 changes are made in the driver tcl file.
135 * 3.00  kvn  02/13/15 Modified code for MISRA-C:2012 compliance.
136 *
137 * </pre>
138 *
139 ******************************************************************************/
140
141 #ifndef XSCUGIC_H /* prevent circular inclusions */
142 #define XSCUGIC_H /* by using protection macros */
143
144 #ifdef __cplusplus
145 extern "C" {
146 #endif
147
148
149 /***************************** Include Files *********************************/
150
151 #include "xstatus.h"
152 #include "xil_io.h"
153 #include "xscugic_hw.h"
154 #include "xil_exception.h"
155
156 /************************** Constant Definitions *****************************/
157
158
159 /**************************** Type Definitions *******************************/
160
161 /* The following data type defines each entry in an interrupt vector table.
162  * The callback reference is the base address of the interrupting device
163  * for the low level driver and an instance pointer for the high level driver.
164  */
165 typedef struct
166 {
167         Xil_InterruptHandler Handler;
168         void *CallBackRef;
169 } XScuGic_VectorTableEntry;
170
171 /**
172  * This typedef contains configuration information for the device.
173  */
174 typedef struct
175 {
176         u16 DeviceId;           /**< Unique ID  of device */
177         u32 CpuBaseAddress;     /**< CPU Interface Register base address */
178         u32 DistBaseAddress;    /**< Distributor Register base address */
179         XScuGic_VectorTableEntry HandlerTable[XSCUGIC_MAX_NUM_INTR_INPUTS];/**<
180                                  Vector table of interrupt handlers */
181 } XScuGic_Config;
182
183 /**
184  * The XScuGic driver instance data. The user is required to allocate a
185  * variable of this type for every intc device in the system. A pointer
186  * to a variable of this type is then passed to the driver API functions.
187  */
188 typedef struct
189 {
190         XScuGic_Config *Config;  /**< Configuration table entry */
191         u32 IsReady;             /**< Device is initialized and ready */
192         u32 UnhandledInterrupts; /**< Intc Statistics */
193 } XScuGic;
194
195 /***************** Macros (Inline Functions) Definitions *********************/
196
197 /****************************************************************************/
198 /**
199 *
200 * Write the given CPU Interface register
201 *
202 * @param    InstancePtr is a pointer to the instance to be worked on.
203 * @param    RegOffset is the register offset to be written
204 * @param    Data is the 32-bit value to write to the register
205 *
206 * @return   None.
207 *
208 * @note
209 * C-style signature:
210 *    void XScuGic_CPUWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data)
211 *
212 *****************************************************************************/
213 #define XScuGic_CPUWriteReg(InstancePtr, RegOffset, Data) \
214 (XScuGic_WriteReg(((InstancePtr)->Config->CpuBaseAddress), (RegOffset), \
215                                         ((u32)(Data))))
216
217 /****************************************************************************/
218 /**
219 *
220 * Read the given CPU Interface register
221 *
222 * @param    InstancePtr is a pointer to the instance to be worked on.
223 * @param    RegOffset is the register offset to be read
224 *
225 * @return   The 32-bit value of the register
226 *
227 * @note
228 * C-style signature:
229 *    u32 XScuGic_CPUReadReg(XScuGic *InstancePtr, u32 RegOffset)
230 *
231 *****************************************************************************/
232 #define XScuGic_CPUReadReg(InstancePtr, RegOffset) \
233         (XScuGic_ReadReg(((InstancePtr)->Config->CpuBaseAddress), (RegOffset)))
234
235 /****************************************************************************/
236 /**
237 *
238 * Write the given Distributor Interface register
239 *
240 * @param    InstancePtr is a pointer to the instance to be worked on.
241 * @param    RegOffset is the register offset to be written
242 * @param    Data is the 32-bit value to write to the register
243 *
244 * @return   None.
245 *
246 * @note
247 * C-style signature:
248 *    void XScuGic_DistWriteReg(XScuGic *InstancePtr, u32 RegOffset, u32 Data)
249 *
250 *****************************************************************************/
251 #define XScuGic_DistWriteReg(InstancePtr, RegOffset, Data) \
252 (XScuGic_WriteReg(((InstancePtr)->Config->DistBaseAddress), (RegOffset), \
253                                         ((u32)(Data))))
254
255 /****************************************************************************/
256 /**
257 *
258 * Read the given Distributor Interface register
259 *
260 * @param    InstancePtr is a pointer to the instance to be worked on.
261 * @param    RegOffset is the register offset to be read
262 *
263 * @return   The 32-bit value of the register
264 *
265 * @note
266 * C-style signature:
267 *    u32 XScuGic_DistReadReg(XScuGic *InstancePtr, u32 RegOffset)
268 *
269 *****************************************************************************/
270 #define XScuGic_DistReadReg(InstancePtr, RegOffset) \
271 (XScuGic_ReadReg(((InstancePtr)->Config->DistBaseAddress), (RegOffset)))
272
273 /************************** Function Prototypes ******************************/
274
275 /*
276  * Required functions in xscugic.c
277  */
278
279 s32  XScuGic_Connect(XScuGic *InstancePtr, u32 Int_Id,
280                         Xil_InterruptHandler Handler, void *CallBackRef);
281 void XScuGic_Disconnect(XScuGic *InstancePtr, u32 Int_Id);
282
283 void XScuGic_Enable(XScuGic *InstancePtr, u32 Int_Id);
284 void XScuGic_Disable(XScuGic *InstancePtr, u32 Int_Id);
285
286 s32  XScuGic_CfgInitialize(XScuGic *InstancePtr, XScuGic_Config *ConfigPtr,
287                                                         u32 EffectiveAddr);
288
289 s32  XScuGic_SoftwareIntr(XScuGic *InstancePtr, u32 Int_Id, u32 Cpu_Id);
290
291 void XScuGic_GetPriorityTriggerType(XScuGic *InstancePtr, u32 Int_Id,
292                                         u8 *Priority, u8 *Trigger);
293 void XScuGic_SetPriorityTriggerType(XScuGic *InstancePtr, u32 Int_Id,
294                                         u8 Priority, u8 Trigger);
295
296 /*
297  * Initialization functions in xscugic_sinit.c
298  */
299 XScuGic_Config *XScuGic_LookupConfig(u16 DeviceId);
300
301 /*
302  * Interrupt functions in xscugic_intr.c
303  */
304 void XScuGic_InterruptHandler(XScuGic *InstancePtr);
305
306 /*
307  * Self-test functions in xscugic_selftest.c
308  */
309 s32  XScuGic_SelfTest(XScuGic *InstancePtr);
310
311 #ifdef __cplusplus
312 }
313 #endif
314
315 #endif            /* end of protection macro */