From c42672b2d61804befc8b3e03758ff662e93ec6ff Mon Sep 17 00:00:00 2001 From: richardbarry Date: Sat, 2 Jul 2011 18:51:18 +0000 Subject: [PATCH] Clean up some of the exception handling code in the new MicroBlaze port. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1481 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../portable/GCC/MicroBlaze/port_exceptions.c | 14 ++++++-------- .../portable/GCC/MicroBlaze/portasm.S | 3 --- .../portable/GCC/MicroBlaze/portmacro.h | 3 +-- .../SDKProjects/RTOSDemoSource/main-full.c | 1 + 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/FreeRTOS_Source/portable/GCC/MicroBlaze/port_exceptions.c b/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/FreeRTOS_Source/portable/GCC/MicroBlaze/port_exceptions.c index fc570ac93..2ebfe8bd1 100644 --- a/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/FreeRTOS_Source/portable/GCC/MicroBlaze/port_exceptions.c +++ b/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/FreeRTOS_Source/portable/GCC/MicroBlaze/port_exceptions.c @@ -73,8 +73,8 @@ stacked register values. */ #define portexR11_STACK_OFFSET 12 #define portexR12_STACK_OFFSET 13 #define portexR15_STACK_OFFSET 16 -#define portexR18_STACK_OFFSET 18 -#define portexMSR_STACK_OFFSET 19 +#define portexR18_STACK_OFFSET 19 +#define portexMSR_STACK_OFFSET 20 #define portexR19_STACK_OFFSET -1 /* This is defined to equal the size, in bytes, of the stack frame generated by @@ -90,9 +90,9 @@ exceptions, or the application defined configuration constant configINSTALL_EXCEPTION_HANDLERS is not set to 1. */ #if ( MICROBLAZE_EXCEPTIONS_ENABLED == 1 ) && ( configINSTALL_EXCEPTION_HANDLERS == 1 ) -/* These variables are set in the exception entry code, before +/* This variable is set in the exception entry code, before vPortExceptionHandler is called. */ -unsigned long *pulStackPointerOnFunctionEntry = NULL, ulBTROnFunctionEntry = 0UL; +unsigned long *pulStackPointerOnFunctionEntry = NULL; /* This is the structure that is filled with the MicroBlaze context as it existed immediately prior to the exception occurrence. A pointer to this @@ -159,8 +159,7 @@ extern void *pxCurrentTCB; xRegisterDump.ulR13_read_write_small_data_area = mfgpr( R13 ); xRegisterDump.ulR14_return_address_from_interrupt = mfgpr( R14 ); xRegisterDump.ulR16_return_address_from_trap = mfgpr( R16 ); - xRegisterDump.ulR17_return_address_from_some_exceptions = mfgpr( R17 ); - xRegisterDump.ulR18 = mfgpr( R18 ); + xRegisterDump.ulR17_return_address_from_exceptions = mfgpr( R17 ); xRegisterDump.ulR20 = mfgpr( R20 ); xRegisterDump.ulR21 = mfgpr( R21 ); xRegisterDump.ulR22 = mfgpr( R22 ); @@ -174,7 +173,6 @@ extern void *pxCurrentTCB; xRegisterDump.ulR30 = mfgpr( R30 ); xRegisterDump.ulR31 = mfgpr( R31 ); xRegisterDump.ulR1_SP = ( ( unsigned long ) pulStackPointerOnFunctionEntry ) + portexASM_HANDLER_STACK_FRAME_SIZE; - xRegisterDump.ulBTR = ulBTROnFunctionEntry; xRegisterDump.ulEAR = mfear(); xRegisterDump.ulESR = mfesr(); xRegisterDump.ulEDR = mfedr(); @@ -182,7 +180,7 @@ extern void *pxCurrentTCB; /* Move the saved program counter back to the instruction that was executed when the exception occurred. This is only valid for certain types of exception. */ - xRegisterDump.ulPC = xRegisterDump.ulR17_return_address_from_some_exceptions - portexINSTRUCTION_SIZE; + xRegisterDump.ulPC = xRegisterDump.ulR17_return_address_from_exceptions - portexINSTRUCTION_SIZE; #if XPAR_MICROBLAZE_0_USE_FPU == 1 { diff --git a/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/FreeRTOS_Source/portable/GCC/MicroBlaze/portasm.S b/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/FreeRTOS_Source/portable/GCC/MicroBlaze/portasm.S index 674343690..eb3dc75a5 100644 --- a/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/FreeRTOS_Source/portable/GCC/MicroBlaze/portasm.S +++ b/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/FreeRTOS_Source/portable/GCC/MicroBlaze/portasm.S @@ -115,7 +115,6 @@ back into the caller stack. */ .extern ulTaskSwitchRequested .extern vPortExceptionHandler .extern pulStackPointerOnFunctionEntry - .extern ulBTROnFunctionEntry .global _interrupt_handler .global VPortYieldASM @@ -350,8 +349,6 @@ vPortExceptionHandlerEntry: /* Take a copy of the stack pointer before vPortExecptionHandler is called, storing its value prior to the function stack frame being created. */ swi r1, r0, pulStackPointerOnFunctionEntry - mfs r18, RBTR - swi r18, r0, ulBTROnFunctionEntry bralid r15, vPortExceptionHandler or r0, r0, r0 diff --git a/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/FreeRTOS_Source/portable/GCC/MicroBlaze/portmacro.h b/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/FreeRTOS_Source/portable/GCC/MicroBlaze/portmacro.h index 50d6353fd..cf89cc985 100644 --- a/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/FreeRTOS_Source/portable/GCC/MicroBlaze/portmacro.h +++ b/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/FreeRTOS_Source/portable/GCC/MicroBlaze/portmacro.h @@ -168,7 +168,7 @@ typedef struct PORT_REGISTER_DUMP unsigned long ulR14_return_address_from_interrupt; unsigned long ulR15_return_address_from_subroutine; unsigned long ulR16_return_address_from_trap; - unsigned long ulR17_return_address_from_some_exceptions; + unsigned long ulR17_return_address_from_exceptions; /* The exception entry code can copy the BTR in here for exceptions that occur in the delay slot of branch instructions. */ unsigned long ulR18; unsigned long ulR19; unsigned long ulR20; @@ -185,7 +185,6 @@ typedef struct PORT_REGISTER_DUMP unsigned long ulR31; unsigned long ulPC; unsigned long ulESR; - unsigned long ulBTR; unsigned long ulMSR; unsigned long ulEAR; unsigned long ulFSR; diff --git a/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/main-full.c b/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/main-full.c index 80328ebee..b7cce5456 100644 --- a/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/main-full.c +++ b/Demo/MicroBlaze_Spartan-6_EthernetLite/SDKProjects/RTOSDemoSource/main-full.c @@ -102,6 +102,7 @@ /* BSP includes. */ #include "xtmrctr.h" +#include "microblaze_exceptions_g.h" /* Kernel includes. */ #include "FreeRTOS.h" -- 2.39.5