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"
58 #include "microblaze_interrupts_i.h"
64 extern void microblaze_enable_exceptions(void);
65 extern void microblaze_disable_exceptions(void);
66 extern void microblaze_enable_interrupts(void);
67 extern void microblaze_disable_interrupts(void);
70 * Currently HAL is an augmented part of standalone BSP, so the old definition
71 * of MB_ExceptionVectorTableEntry is used here.
75 Xil_ExceptionHandler Handler;
77 } MB_ExceptionVectorTableEntry;
80 Xil_ExceptionHandler Handler,
82 } MB_InterruptVectorTableEntry, */
89 /************************** Variable Definitions *****************************/
90 extern MB_ExceptionVectorTableEntry MB_ExceptionVectorTable[XIL_EXCEPTION_ID_INT];
91 extern MB_InterruptVectorTableEntry MB_InterruptVectorTable;
95 * This function is a stub handler that is the default handler that gets called
96 * if the application has not setup a handler for a specific exception. The
97 * function interface has to match the interface specified for a handler even
98 * though none of the arguments are used.
100 * @param Data is unused by this function.
110 *****************************************************************************/
111 static void Xil_ExceptionNullHandler(void *Data)
116 /****************************************************************************/
119 * Initialize exception handling for the processor. The exception vector table
120 * is setup with the stub handler for all exceptions.
130 *****************************************************************************/
131 void Xil_ExceptionInit(void)
134 * there is no need to setup the exception table here
139 /****************************************************************************/
147 ******************************************************************************/
148 void Xil_ExceptionEnable(void)
150 #ifdef MICROBLAZE_EXCEPTIONS_ENABLED
151 microblaze_enable_exceptions();
153 microblaze_enable_interrupts();
156 /****************************************************************************/
158 * Disable Exceptions.
166 ******************************************************************************/
167 void Xil_ExceptionDisable(void)
169 #ifdef MICROBLAZE_EXCEPTIONS_ENABLED
170 microblaze_disable_exceptions();
172 microblaze_disable_interrupts();
175 /*****************************************************************************/
178 * Makes the connection between the Id of the exception source and the
179 * associated handler that is to run when the exception is recognized. The
180 * argument provided in this call as the DataPtr is used as the argument
181 * for the handler when it is called.
183 * @param Id contains the ID of the exception source and should
184 * be XIL_EXCEPTION_INT or be in the range of 0 to XIL_EXCEPTION_LAST.
185 * See xil_mach_exception.h for further information.
186 * @param Handler to the handler for that exception.
187 * @param Data is a reference to data that will be passed to the handler
188 * when it gets called.
196 ****************************************************************************/
197 void Xil_ExceptionRegisterHandler(u32 Id, Xil_ExceptionHandler Handler,
200 if (Id == XIL_EXCEPTION_ID_INT) {
201 MB_InterruptVectorTable.Handler = Handler;
202 MB_InterruptVectorTable.CallBackRef = Data;
205 #ifdef MICROBLAZE_EXCEPTIONS_ENABLED
206 MB_ExceptionVectorTable[Id].Handler = Handler;
207 MB_ExceptionVectorTable[Id].CallBackRef = Data;
213 /*****************************************************************************/
216 * Removes the handler for a specific exception Id. The stub handler is then
217 * registered for this exception Id.
219 * @param Id contains the ID of the exception source and should
220 * be XIL_EXCEPTION_INT or in the range of 0 to XIL_EXCEPTION_LAST.
221 * See xexception_l.h for further information.
229 ****************************************************************************/
230 void Xil_ExceptionRemoveHandler(u32 Id)
232 if (Id == XIL_EXCEPTION_ID_INT) {
233 MB_InterruptVectorTable.Handler = Xil_ExceptionNullHandler;
234 MB_InterruptVectorTable.CallBackRef = NULL;
238 #ifdef MICROBLAZE_EXCEPTIONS_ENABLED
239 MB_ExceptionVectorTable[Id].Handler =
240 Xil_ExceptionNullHandler;
241 MB_ExceptionVectorTable[Id].CallBackRef = NULL;