changeset 1084:04b94baa3683

Fix CYGOPT_HAL_ARM_PRESERVE_SVC_SPSR handling
author msalter
date Mon, 30 Jun 2003 12:16:16 +0000
parents 5ca9a1223b9b
children 1ab73d883959
files packages/hal/arm/arch/current/ChangeLog packages/hal/arm/arch/current/src/vectors.S
diffstat 2 files changed, 15 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/packages/hal/arm/arch/current/ChangeLog
+++ b/packages/hal/arm/arch/current/ChangeLog
@@ -1,3 +1,7 @@
+2003-06-30  Mark Salter  <msalter@redhat.com>
+
+	* src/vectors.S: Fix CYGOPT_HAL_ARM_PRESERVE_SVC_SPSR handling.
+
 2003-06-24  Jonathan Larmour  <jifl@eCosCentric.com>
 
 	* include/hal_arch.h: Include plf_arch.h or var_arch.h if platform
--- a/packages/hal/arm/arch/current/src/vectors.S
+++ b/packages/hal/arm/arch/current/src/vectors.S
@@ -644,7 +644,6 @@ 2:
 return_from_exception:
 
         ldr     r0,[sp,#armreg_cpsr]
-        msr     spsr,r0
 
         // return to supervisor mode is simple
         and     r1,r0,#CPSR_MODE_BITS
@@ -657,7 +656,17 @@ return_from_exception:
         // we must take care of not corrupting the current (svc)
         // spsr which happens to be also the pre-exception spsr
         bne     1f
-        // we are returning to svc mode thus we must restore the
+        tst     r0, #CPSR_THUMB_ENABLE
+        
+        // when returning to thumb/svc mode, there is no easy way to preserve
+        // spsr. It is possible to do so, but would add a lot of instructions.
+        // The purpose of CYGOPT_HAL_ARM_PRESERVE_SVC_SPSR is to allow stepping
+        // through SWI exception handling code, so not preserving spsr in this
+        // case should be okay.
+        msrne   spsr,r0
+        ldmnefd sp,{r0-r14,pc}^
+        
+        // we are returning to arm/svc mode thus we must restore the
         // pre-exception cpsr before returning to interrupted code
         msr     cpsr, r0
         ldmfd   sp, {r0-r14, pc}