1 /******************************************************************************
3 * Copyright (C) 2009 - 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 /****************************************************************************/
35 * @file xil_exception.c
37 * This file contains low-level driver functions for the Cortex A9 exception
41 * MODIFICATION HISTORY:
43 * Ver Who Date Changes
44 * ----- -------- -------- -----------------------------------------------
45 * 1.00a ecm/sdm 11/04/09 First release
46 * 3.05a sdm 02/02/12 Updated to resiter a null handler only if a handler
47 * is not already registered
50 *****************************************************************************/
52 /***************************** Include Files ********************************/
54 #include "xil_types.h"
55 #include "xil_assert.h"
56 #include "xil_exception.h"
57 #include "xpseudo_asm.h"
59 /************************** Constant Definitions ****************************/
61 /**************************** Type Definitions ******************************/
64 Xil_ExceptionHandler Handler;
66 } XExc_VectorTableEntry;
68 /***************** Macros (Inline Functions) Definitions ********************/
70 /************************** Function Prototypes *****************************/
72 /************************** Variable Definitions *****************************/
74 * Exception vector table to store handlers for each exception vector.
76 XExc_VectorTableEntry XExc_VectorTable[XIL_EXCEPTION_ID_LAST + 1];
78 /*****************************************************************************/
80 /****************************************************************************/
83 * This function is a stub Handler that is the default Handler that gets called
84 * if the application has not setup a Handler for a specific exception. The
85 * function interface has to match the interface specified for a Handler even
86 * though none of the arguments are used.
88 * @param Data is unused by this function.
94 *****************************************************************************/
95 static void Xil_ExceptionNullHandler(void *Data)
98 DieLoop: goto DieLoop;
101 /****************************************************************************/
104 * Initialize exception handling for the Processor. The exception vector table
105 * is setup with the stub Handler for all exceptions.
113 *****************************************************************************/
114 void Xil_ExceptionInit(void)
119 * Initialize the vector table. Register the stub Handler for each
122 for(index = XIL_EXCEPTION_ID_FIRST; index < XIL_EXCEPTION_ID_LAST + 1;
124 if (XExc_VectorTable[index].Handler == NULL) {
125 Xil_ExceptionRegisterHandler(index,
126 Xil_ExceptionNullHandler,
132 /*****************************************************************************/
135 * Makes the connection between the Id of the exception source and the
136 * associated Handler that is to run when the exception is recognized. The
137 * argument provided in this call as the Data is used as the argument
138 * for the Handler when it is called.
140 * @param exception_id contains the ID of the exception source and should
141 * be in the range of 0 to XIL_EXCEPTION_ID_LAST.
142 See xil_exception_l.h for further information.
143 * @param Handler to the Handler for that exception.
144 * @param Data is a reference to Data that will be passed to the
145 * Handler when it gets called.
151 ****************************************************************************/
152 void Xil_ExceptionRegisterHandler(u32 exception_id,
153 Xil_ExceptionHandler Handler,
156 XExc_VectorTable[exception_id].Handler = Handler;
157 XExc_VectorTable[exception_id].Data = Data;
160 /*****************************************************************************/
163 * Removes the Handler for a specific exception Id. The stub Handler is then
164 * registered for this exception Id.
166 * @param exception_id contains the ID of the exception source and should
167 * be in the range of 0 to XIL_EXCEPTION_ID_LAST.
168 * See xil_exception_l.h for further information.
174 ****************************************************************************/
175 void Xil_ExceptionRemoveHandler(u32 exception_id)
177 Xil_ExceptionRegisterHandler(exception_id,
178 Xil_ExceptionNullHandler,