2 FreeRTOS V7.0.1 - Copyright (C) 2011 Real Time Engineers Ltd.
\r
5 ***************************************************************************
\r
7 * FreeRTOS tutorial books are available in pdf and paperback. *
\r
8 * Complete, revised, and edited pdf reference manuals are also *
\r
11 * Purchasing FreeRTOS documentation will not only help you, by *
\r
12 * ensuring you get running as quickly as possible and with an *
\r
13 * in-depth knowledge of how to use FreeRTOS, it will also help *
\r
14 * the FreeRTOS project to continue with its mission of providing *
\r
15 * professional grade, cross platform, de facto standard solutions *
\r
16 * for microcontrollers - completely free of charge! *
\r
18 * >>> See http://www.FreeRTOS.org/Documentation for details. <<< *
\r
20 * Thank you for using FreeRTOS, and thank you for your support! *
\r
22 ***************************************************************************
\r
25 This file is part of the FreeRTOS distribution.
\r
27 FreeRTOS is free software; you can redistribute it and/or modify it under
\r
28 the terms of the GNU General Public License (version 2) as published by the
\r
29 Free Software Foundation AND MODIFIED BY the FreeRTOS exception.
\r
30 >>>NOTE<<< The modification to the GPL is included to allow you to
\r
31 distribute a combined work that includes FreeRTOS without being obliged to
\r
32 provide the source code for proprietary components outside of the FreeRTOS
\r
33 kernel. FreeRTOS is distributed in the hope that it will be useful, but
\r
34 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
\r
35 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
\r
36 more details. You should have received a copy of the GNU General Public
\r
37 License and the FreeRTOS license exception along with FreeRTOS; if not it
\r
38 can be viewed here: http://www.freertos.org/a00114.html and also obtained
\r
39 by writing to Richard Barry, contact details for whom are available on the
\r
44 http://www.FreeRTOS.org - Documentation, latest information, license and
\r
47 http://www.SafeRTOS.com - A version that is certified for use in safety
\r
50 http://www.OpenRTOS.com - Commercial support, development, porting,
\r
51 licensing and training services.
\r
54 /* Scheduler includes. */
\r
55 #include "FreeRTOS.h"
\r
58 /* Hardware includes. */
\r
59 #include <microblaze_exceptions_i.h>
\r
60 #include <microblaze_exceptions_g.h>
\r
62 #define portexR3_STACK_OFFSET 4
\r
63 #define portexR4_STACK_OFFSET 5
\r
64 #define portexR5_STACK_OFFSET 6
\r
65 #define portexR6_STACK_OFFSET 7
\r
66 #define portexR7_STACK_OFFSET 8
\r
67 #define portexR8_STACK_OFFSET 9
\r
68 #define portexR9_STACK_OFFSET 10
\r
69 #define portexR10_STACK_OFFSET 11
\r
70 #define portexR11_STACK_OFFSET 12
\r
71 #define portexR12_STACK_OFFSET 13
\r
72 #define portexR15_STACK_OFFSET 16
\r
73 #define portexR18_STACK_OFFSET 18
\r
74 #define portexR19_STACK_OFFSET -1
\r
76 #define portexESR_DS_MASK 0x00001000UL
\r
79 /* Exclude the entire file if the MicroBlaze is not configured to handle
\r
80 exceptions, or the application defined configuration item
\r
81 configINSTALL_EXCEPTION_HANDLERS is not set to 1. */
\r
82 #if ( MICROBLAZE_EXCEPTIONS_ENABLED == 1 ) && ( configINSTALL_EXCEPTION_HANDLERS == 1 )
\r
84 /* These are global volatiles to allow their inspection by a debugger. */
\r
85 unsigned long *pulStackPointerOnFunctionEntry = NULL;
\r
87 static xPortRegisterDump xRegisterDump;
\r
89 void vPortExceptionHandler( void *pvExceptionID );
\r
90 extern void vPortExceptionHandlerEntry( void *pvExceptionID );
\r
92 /*-----------------------------------------------------------*/
\r
94 void vPortExceptionHandler( void *pvExceptionID )
\r
96 extern void *pxCurrentTCB;
\r
98 xRegisterDump.xCurrentTaskHandle = pxCurrentTCB;
\r
99 xRegisterDump.pcCurrentTaskName = pcTaskGetTaskName( NULL );
\r
101 configASSERT( pulStackPointerOnFunctionEntry );
\r
103 /* Obtain the values of registers that were stacked prior to this function
\r
104 being called, and may have changed since they were stacked. */
105 xRegisterDump.ulR3 = pulStackPointerOnFunctionEntry[ portexR3_STACK_OFFSET ];
\r
106 xRegisterDump.ulR4 = pulStackPointerOnFunctionEntry[ portexR4_STACK_OFFSET ];
\r
107 xRegisterDump.ulR5 = pulStackPointerOnFunctionEntry[ portexR5_STACK_OFFSET ];
\r
108 xRegisterDump.ulR6 = pulStackPointerOnFunctionEntry[ portexR6_STACK_OFFSET ];
\r
109 xRegisterDump.ulR7 = pulStackPointerOnFunctionEntry[ portexR7_STACK_OFFSET ];
\r
110 xRegisterDump.ulR8 = pulStackPointerOnFunctionEntry[ portexR8_STACK_OFFSET ];
\r
111 xRegisterDump.ulR9 = pulStackPointerOnFunctionEntry[ portexR9_STACK_OFFSET ];
\r
112 xRegisterDump.ulR10 = pulStackPointerOnFunctionEntry[ portexR10_STACK_OFFSET ];
\r
113 xRegisterDump.ulR11 = pulStackPointerOnFunctionEntry[ portexR11_STACK_OFFSET ];
\r
114 xRegisterDump.ulR12 = pulStackPointerOnFunctionEntry[ portexR12_STACK_OFFSET ];
\r
115 xRegisterDump.ulR19 = pulStackPointerOnFunctionEntry[ portexR19_STACK_OFFSET ];
\r
117 /* Obtain the value of all other registers. */
\r
118 //xRegisterDump.ulR1 =
\r
119 xRegisterDump.ulR2_small_data_area = mfgpr( R2 );
\r
120 xRegisterDump.ulR13_read_write_small_data_area = mfgpr( R13 );
\r
121 xRegisterDump.ulR14_return_address_from_interrupt = mfgpr( R14 );
\r
122 xRegisterDump.ulR15_return_address_from_subroutine = mfgpr( R15 );
\r
123 xRegisterDump.ulR16_return_address_from_trap = mfgpr( R16 );
\r
124 xRegisterDump.ulR17_return_address_from_some_exceptions = mfgpr( R17 );
\r
125 xRegisterDump.ulR18 = mfgpr( R18 );
\r
126 xRegisterDump.ulR20 = mfgpr( R20 );
\r
127 xRegisterDump.ulR21 = mfgpr( R21 );
\r
128 xRegisterDump.ulR22 = mfgpr( R22 );
\r
129 xRegisterDump.ulR23 = mfgpr( R23 );
\r
130 xRegisterDump.ulR24 = mfgpr( R24 );
\r
131 xRegisterDump.ulR25 = mfgpr( R25 );
\r
132 xRegisterDump.ulR26 = mfgpr( R26 );
\r
133 xRegisterDump.ulR27 = mfgpr( R27 );
\r
134 xRegisterDump.ulR28 = mfgpr( R28 );
\r
135 xRegisterDump.ulR29 = mfgpr( R29 );
\r
136 xRegisterDump.ulR30 = mfgpr( R30 );
\r
137 xRegisterDump.ulR31 = mfgpr( R31 );
\r
139 xRegisterDump.ulESR = mfesr();
\r
140 if( ( xRegisterDump.ulESR * portexESR_DS_MASK ) != 0UL )
\r
142 xRegisterDump.ulPC = mfbtr();
\r
146 xRegisterDump.ulPC = xRegisterDump.ulR17_return_address_from_some_exceptions - 4;
\r
149 // xRegisterDump.ulSP =;
\r
155 switch( ( unsigned long ) pvExceptionID )
\r
158 xRegisterDump.pcExceptionCause = ( signed char * const ) "XEXC_ID_FSL";
\r
161 case XEXC_ID_UNALIGNED_ACCESS :
\r
162 xRegisterDump.pcExceptionCause = ( signed char * const ) "XEXC_ID_UNALIGNED_ACCESS";
\r
165 case XEXC_ID_ILLEGAL_OPCODE :
\r
166 xRegisterDump.pcExceptionCause = ( signed char * const ) "XEXC_ID_ILLEGAL_OPCODE";
\r
169 case XEXC_ID_M_AXI_I_EXCEPTION :
\r
170 xRegisterDump.pcExceptionCause = ( signed char * const ) "XEXC_ID_M_AXI_I_EXCEPTION or XEXC_ID_IPLB_EXCEPTION";
\r
173 case XEXC_ID_M_AXI_D_EXCEPTION :
\r
174 xRegisterDump.pcExceptionCause = ( signed char * const ) "XEXC_ID_M_AXI_D_EXCEPTION or XEXC_ID_DPLB_EXCEPTION";
\r
177 case XEXC_ID_DIV_BY_ZERO :
\r
178 xRegisterDump.pcExceptionCause = ( signed char * const ) "XEXC_ID_DIV_BY_ZERO";
\r
182 /*_RB_ More decoding required here and in other exceptions. */
\r
183 xRegisterDump.pcExceptionCause = ( signed char * const ) "XEXC_ID_FPU";
\r
186 case XEXC_ID_STACK_VIOLATION :
\r
187 xRegisterDump.pcExceptionCause = ( signed char * const ) "XEXC_ID_STACK_VIOLATION or XEXC_ID_MMU";
\r
191 /* Must not attempt to leave this function! */
\r
197 /*-----------------------------------------------------------*/
\r
199 void vPortExceptionsInstallHandlers( void )
\r
201 #if XPAR_MICROBLAZE_0_UNALIGNED_EXCEPTIONS == 1
\r
202 microblaze_register_exception_handler( XEXC_ID_UNALIGNED_ACCESS, vPortExceptionHandlerEntry, ( void * ) XEXC_ID_UNALIGNED_ACCESS );
\r
203 #endif /* XPAR_MICROBLAZE_0_UNALIGNED_EXCEPTIONS*/
\r
205 #if XPAR_MICROBLAZE_0_ILL_OPCODE_EXCEPTION == 1
\r
206 microblaze_register_exception_handler( XEXC_ID_ILLEGAL_OPCODE, vPortExceptionHandlerEntry, ( void * ) XEXC_ID_ILLEGAL_OPCODE );
\r
207 #endif /* XPAR_MICROBLAZE_0_ILL_OPCODE_EXCEPTION*/
\r
209 #if XPAR_MICROBLAZE_0_M_AXI_I_BUS_EXCEPTION == 1
\r
210 microblaze_register_exception_handler( XEXC_ID_M_AXI_I_EXCEPTION, vPortExceptionHandlerEntry, ( void * ) XEXC_ID_M_AXI_I_EXCEPTION );
\r
211 #endif /* XPAR_MICROBLAZE_0_M_AXI_I_BUS_EXCEPTION*/
\r
213 #if XPAR_MICROBLAZE_0_M_AXI_D_BUS_EXCEPTION == 1
\r
214 microblaze_register_exception_handler( XEXC_ID_M_AXI_D_EXCEPTION, vPortExceptionHandlerEntry, ( void * ) XEXC_ID_M_AXI_D_EXCEPTION );
\r
215 #endif /* XPAR_MICROBLAZE_0_M_AXI_D_BUS_EXCEPTION*/
\r
217 #if XPAR_MICROBLAZE_0_IPLB_BUS_EXCEPTION == 1
\r
218 microblaze_register_exception_handler( XEXC_ID_IPLB_EXCEPTION, vPortExceptionHandlerEntry, ( void * ) XEXC_ID_IPLB_EXCEPTION );
\r
219 #endif /* XPAR_MICROBLAZE_0_IPLB_BUS_EXCEPTION*/
\r
221 #if XPAR_MICROBLAZE_0_DPLB_BUS_EXCEPTION == 1
\r
222 microblaze_register_exception_handler( XEXC_ID_DPLB_EXCEPTION, vPortExceptionHandlerEntry, ( void * ) XEXC_ID_DPLB_EXCEPTION );
\r
223 #endif /* XPAR_MICROBLAZE_0_DPLB_BUS_EXCEPTION*/
\r
225 #if XPAR_MICROBLAZE_0_DIV_ZERO_EXCEPTION == 1
\r
226 microblaze_register_exception_handler( XEXC_ID_DIV_BY_ZERO, vPortExceptionHandlerEntry, ( void * ) XEXC_ID_DIV_BY_ZERO );
\r
227 #endif /* XPAR_MICROBLAZE_0_DIV_ZERO_EXCEPTION*/
\r
229 #if XPAR_MICROBLAZE_0_FPU_EXCEPTION == 1
\r
230 microblaze_register_exception_handler( XEXC_ID_FPU, vPortExceptionHandlerEntry, ( void * ) XEXC_ID_FPU );
\r
231 #endif /* XPAR_MICROBLAZE_0_FPU_EXCEPTION*/
\r
233 #if XPAR_MICROBLAZE_0_FSL_EXCEPTION == 1
\r
234 microblaze_register_exception_handler( XEXC_ID_FSL, vPortExceptionHandlerEntry, ( void * ) XEXC_ID_FSL );
\r
235 #endif /* XPAR_MICROBLAZE_0_FSL_EXCEPTION*/
\r
237 /*-----------------------------------------------------------*/
\r
239 /* Exclude the entire file if the MicroBlaze is not configured to handle
\r
240 exceptions, or the application defined configuration item
\r
241 configINSTALL_EXCEPTION_HANDLERS is not set to 1. */
\r
242 #endif /* ( MICROBLAZE_EXCEPTIONS_ENABLED == 1 ) && ( configINSTALL_EXCEPTION_HANDLERS == 1 ) */
\r