1 /*****************************************************************************
3 * (c) Copyright 2009-13 Xilinx, Inc. All rights reserved.
5 * This file contains confidential and proprietary information of Xilinx, Inc.
6 * and is protected under U.S. and international copyright and other
7 * intellectual property laws.
10 * This disclaimer is not a license and does not grant any rights to the
11 * materials distributed herewith. Except as otherwise provided in a valid
12 * license issued to you by Xilinx, and to the maximum extent permitted by
13 * applicable law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND WITH ALL
14 * FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS, EXPRESS,
15 * IMPLIED, OR STATUTORY, INCLUDING BUT NOT LIMITED TO WARRANTIES OF
16 * MERCHANTABILITY, NON-INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE;
17 * and (2) Xilinx shall not be liable (whether in contract or tort, including
18 * negligence, or under any other theory of liability) for any loss or damage
19 * of any kind or nature related to, arising under or in connection with these
20 * materials, including for any direct, or any indirect, special, incidental,
21 * or consequential loss or damage (including loss of data, profits, goodwill,
22 * or any type of loss or damage suffered as a result of any action brought by
23 * a third party) even if such damage or loss was reasonably foreseeable or
24 * Xilinx had been advised of the possibility of the same.
26 * CRITICAL APPLICATIONS
27 * Xilinx products are not designed or intended to be fail-safe, or for use in
28 * any application requiring fail-safe performance, such as life-support or
29 * safety devices or systems, Class III medical devices, nuclear facilities,
30 * applications related to the deployment of airbags, or any other applications
31 * that could lead to death, personal injury, or severe property or
32 * environmental damage (individually and collectively, "Critical
33 * Applications"). Customer assumes the sole risk and liability of any use of
34 * Xilinx products in Critical Applications, subject only to applicable laws
35 * and regulations governing limitations on product liability.
37 * THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS PART OF THIS FILE
39 ******************************************************************************/
40 /****************************************************************************/
43 * @file xil_exception.c
45 * This file contains low-level driver functions for the Cortex A9 exception
49 * MODIFICATION HISTORY:
51 * Ver Who Date Changes
52 * ----- -------- -------- -----------------------------------------------
53 * 1.00a ecm/sdm 11/04/09 First release
54 * 3.05a sdm 02/02/12 Updated to resiter a null handler only if a handler
55 * is not already registered
58 *****************************************************************************/
60 /***************************** Include Files ********************************/
62 #include "xil_types.h"
63 #include "xil_assert.h"
64 #include "xil_exception.h"
65 #include "xpseudo_asm.h"
67 /************************** Constant Definitions ****************************/
69 /**************************** Type Definitions ******************************/
72 Xil_ExceptionHandler Handler;
74 } XExc_VectorTableEntry;
76 /***************** Macros (Inline Functions) Definitions ********************/
78 /************************** Function Prototypes *****************************/
80 /************************** Variable Definitions *****************************/
82 * Exception vector table to store handlers for each exception vector.
84 XExc_VectorTableEntry XExc_VectorTable[XIL_EXCEPTION_ID_LAST + 1];
86 /*****************************************************************************/
88 /****************************************************************************/
91 * This function is a stub Handler that is the default Handler that gets called
92 * if the application has not setup a Handler for a specific exception. The
93 * function interface has to match the interface specified for a Handler even
94 * though none of the arguments are used.
96 * @param Data is unused by this function.
102 *****************************************************************************/
103 static void Xil_ExceptionNullHandler(void *Data)
106 DieLoop: goto DieLoop;
109 /****************************************************************************/
112 * Initialize exception handling for the Processor. The exception vector table
113 * is setup with the stub Handler for all exceptions.
121 *****************************************************************************/
122 void Xil_ExceptionInit(void)
127 * Initialize the vector table. Register the stub Handler for each
130 for(index = XIL_EXCEPTION_ID_FIRST; index < XIL_EXCEPTION_ID_LAST + 1;
132 if (XExc_VectorTable[index].Handler == NULL) {
133 Xil_ExceptionRegisterHandler(index,
134 Xil_ExceptionNullHandler,
140 /*****************************************************************************/
143 * Makes the connection between the Id of the exception source and the
144 * associated Handler that is to run when the exception is recognized. The
145 * argument provided in this call as the Data is used as the argument
146 * for the Handler when it is called.
148 * @param exception_id contains the ID of the exception source and should
149 * be in the range of 0 to XIL_EXCEPTION_ID_LAST.
150 See xil_exception_l.h for further information.
151 * @param Handler to the Handler for that exception.
152 * @param Data is a reference to Data that will be passed to the
153 * Handler when it gets called.
159 ****************************************************************************/
160 void Xil_ExceptionRegisterHandler(u32 exception_id,
161 Xil_ExceptionHandler Handler,
164 XExc_VectorTable[exception_id].Handler = Handler;
165 XExc_VectorTable[exception_id].Data = Data;
168 /*****************************************************************************/
171 * Removes the Handler for a specific exception Id. The stub Handler is then
172 * registered for this exception Id.
174 * @param exception_id contains the ID of the exception source and should
175 * be in the range of 0 to XIL_EXCEPTION_ID_LAST.
176 * See xil_exception_l.h for further information.
182 ****************************************************************************/
183 void Xil_ExceptionRemoveHandler(u32 exception_id)
185 Xil_ExceptionRegisterHandler(exception_id,
186 Xil_ExceptionNullHandler,