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 implementation of exception related driver functions.
40 * MODIFICATION HISTORY:
42 * Ver Who Date Changes
43 * ----- ---- -------- -------------------------------------------------------
44 * 1.00 hbm 07/28/09 Initial release
52 ******************************************************************************/
54 #include "xil_types.h"
55 #include "xil_exception.h"
57 #include "microblaze_exceptions_g.h"
63 extern void microblaze_enable_exceptions(void);
64 extern void microblaze_disable_exceptions(void);
65 extern void microblaze_enable_interrupts(void);
66 extern void microblaze_disable_interrupts(void);
69 * Currently HAL is an augmented part of standalone BSP, so the old definition
70 * of MB_ExceptionVectorTableEntry is used here.
74 Xil_ExceptionHandler Handler;
76 } MB_ExceptionVectorTableEntry;
79 Xil_ExceptionHandler Handler;
81 } MB_InterruptVectorTableEntry;
88 /************************** Variable Definitions *****************************/
89 extern MB_ExceptionVectorTableEntry MB_ExceptionVectorTable[];
90 extern MB_InterruptVectorTableEntry MB_InterruptVectorTable;
94 * This function is a stub handler that is the default handler that gets called
95 * if the application has not setup a handler for a specific exception. The
96 * function interface has to match the interface specified for a handler even
97 * though none of the arguments are used.
99 * @param Data is unused by this function.
109 *****************************************************************************/
110 static void Xil_ExceptionNullHandler(void *Data)
115 /****************************************************************************/
118 * Initialize exception handling for the processor. The exception vector table
119 * is setup with the stub handler for all exceptions.
129 *****************************************************************************/
130 void Xil_ExceptionInit(void)
133 * there is no need to setup the exception table here
138 /****************************************************************************/
146 ******************************************************************************/
147 void Xil_ExceptionEnable(void)
149 #ifdef MICROBLAZE_EXCEPTIONS_ENABLED
150 microblaze_enable_exceptions();
152 microblaze_enable_interrupts();
155 /****************************************************************************/
157 * Disable Exceptions.
165 ******************************************************************************/
166 void Xil_ExceptionDisable(void)
168 #ifdef MICROBLAZE_EXCEPTIONS_ENABLED
169 microblaze_disable_exceptions();
171 microblaze_disable_interrupts();
174 /*****************************************************************************/
177 * Makes the connection between the Id of the exception source and the
178 * associated handler that is to run when the exception is recognized. The
179 * argument provided in this call as the DataPtr is used as the argument
180 * for the handler when it is called.
182 * @param Id contains the ID of the exception source and should
183 * be XIL_EXCEPTION_INT or be in the range of 0 to XIL_EXCEPTION_LAST.
184 * See xil_mach_exception.h for further information.
185 * @param Handler to the handler for that exception.
186 * @param Data is a reference to data that will be passed to the handler
187 * when it gets called.
195 ****************************************************************************/
196 void Xil_ExceptionRegisterHandler(u32 Id, Xil_ExceptionHandler Handler,
199 if (Id == XIL_EXCEPTION_ID_INT) {
200 MB_InterruptVectorTable.Handler = Handler;
201 MB_InterruptVectorTable.CallBackRef = Data;
204 #ifdef MICROBLAZE_EXCEPTIONS_ENABLED
205 MB_ExceptionVectorTable[Id].Handler = Handler;
206 MB_ExceptionVectorTable[Id].CallBackRef = Data;
212 /*****************************************************************************/
215 * Removes the handler for a specific exception Id. The stub handler is then
216 * registered for this exception Id.
218 * @param Id contains the ID of the exception source and should
219 * be XIL_EXCEPTION_INT or in the range of 0 to XIL_EXCEPTION_LAST.
220 * See xexception_l.h for further information.
228 ****************************************************************************/
229 void Xil_ExceptionRemoveHandler(u32 Id)
231 if (Id == XIL_EXCEPTION_ID_INT) {
232 MB_InterruptVectorTable.Handler = Xil_ExceptionNullHandler;
233 MB_InterruptVectorTable.CallBackRef = NULL;
237 #ifdef MICROBLAZE_EXCEPTIONS_ENABLED
238 MB_ExceptionVectorTable[Id].Handler =
239 Xil_ExceptionNullHandler;
240 MB_ExceptionVectorTable[Id].CallBackRef = NULL;