diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-06-16 15:29:27 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-06-16 15:29:27 +0000 |
commit | 5bca785c9461c4c456ff2070ba6eb53079e0f4c0 (patch) | |
tree | 7ae1e5817890f60ad56a43a472bdc28baf4d3431 | |
parent | bd39911fb9424b42273b2a924c615c553ff8d744 (diff) | |
download | nuttx-5bca785c9461c4c456ff2070ba6eb53079e0f4c0.tar.gz nuttx-5bca785c9461c4c456ff2070ba6eb53079e0f4c0.tar.bz2 nuttx-5bca785c9461c4c456ff2070ba6eb53079e0f4c0.zip |
Fix off-by-one stack pointer reference
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3712 42af7a65-404d-4744-a932-0658087f49c3
-rwxr-xr-x | nuttx/arch/avr/src/at90usb/at90usb_exceptions.S | 13 | ||||
-rwxr-xr-x | nuttx/arch/avr/src/atmega/atmega_exceptions.S | 13 | ||||
-rw-r--r-- | nuttx/arch/avr/src/avr/up_dumpstate.c | 2 |
3 files changed, 15 insertions, 13 deletions
diff --git a/nuttx/arch/avr/src/at90usb/at90usb_exceptions.S b/nuttx/arch/avr/src/at90usb/at90usb_exceptions.S index 90d9cbac3..44b607033 100755 --- a/nuttx/arch/avr/src/at90usb/at90usb_exceptions.S +++ b/nuttx/arch/avr/src/at90usb/at90usb_exceptions.S @@ -129,12 +129,13 @@ excpt_common: * the push operation post-decrements -- need to REVISIT this). */ - in r16, _SFR_IO_ADDR(SPL) /* Get the save structure pointer in a Call-saved register pair */ - in r17, _SFR_IO_ADDR(SPH) /* (Careful, push post-decrements) */ - movw r22, r16 /* Pass register save structure as the parameter 2 */ + in r28, _SFR_IO_ADDR(SPL) /* Get the save structure pointer in a Call-saved register pair */ + in r29, _SFR_IO_ADDR(SPH) /* Pointer can be obtained from the stack pointer */ + adiw r28, 1 /* Remembering that push post-decrements */ + movw r22, r28 /* Pass register save structure as the parameter 2 */ USE_INTSTACK rx, ry, rz /* Switch to the interrupt stack */ call up_doirq /* Dispatch the interrupt */ - RESTORE_STACK rx, ry /* - Undo the operations of USE_INTSTACK */ + RESTORE_STACK rx, ry /* Undo the operations of USE_INTSTACK */ /* up_doiq returns with r24-r25 equal to the new save structure. If no context * switch occurred, this will be the same as the value passed to it in r22-23. @@ -142,8 +143,8 @@ excpt_common: * stack frame, but at a register save area inside of the new task's TCB. */ - cp r16, r24 - cpc r17, r25 + cp r28, r24 + cpc r29, r25 breq .Lnoswitch /* A context switch has occurred, jump to up_fullcontextrestore with r24, r25 diff --git a/nuttx/arch/avr/src/atmega/atmega_exceptions.S b/nuttx/arch/avr/src/atmega/atmega_exceptions.S index 766a81881..4050f1880 100755 --- a/nuttx/arch/avr/src/atmega/atmega_exceptions.S +++ b/nuttx/arch/avr/src/atmega/atmega_exceptions.S @@ -122,12 +122,13 @@ excpt_common: * the push operation post-decrements -- need to REVISIT this). */ - in r16, _SFR_IO_ADDR(SPL) /* Get the save structure pointer in a Call-saved register pair */ - in r17, _SFR_IO_ADDR(SPH) /* (Careful, push post-decrements) */ - movw r22, r16 /* Pass register save structure as the parameter 2 */ + in r28, _SFR_IO_ADDR(SPL) /* Get the save structure pointer in a Call-saved register pair */ + in r29, _SFR_IO_ADDR(SPH) /* Pointer can be obtained from the stack pointer */ + adiw r28, 1 /* Remembering that push post-decrements */ + movw r22, r28 /* Pass register save structure as the parameter 2 */ USE_INTSTACK rx, ry, rz /* Switch to the interrupt stack */ call up_doirq /* Dispatch the interrupt */ - RESTORE_STACK rx, ry /* - Undo the operations of USE_INTSTACK */ + RESTORE_STACK rx, ry /* Undo the operations of USE_INTSTACK */ /* up_doiq returns with r24-r25 equal to the new save structure. If no context * switch occurred, this will be the same as the value passed to it in r22-23. @@ -135,8 +136,8 @@ excpt_common: * stack frame, but at a register save area inside of the new task's TCB. */ - cp r16, r24 - cpc r17, r25 + cp r28, r24 + cpc r29, r25 breq .Lnoswitch /* A context switch has occurred, jump to up_fullcontextrestore with r24, r25 diff --git a/nuttx/arch/avr/src/avr/up_dumpstate.c b/nuttx/arch/avr/src/avr/up_dumpstate.c index e22aa8f8b..73cb823c4 100644 --- a/nuttx/arch/avr/src/avr/up_dumpstate.c +++ b/nuttx/arch/avr/src/avr/up_dumpstate.c @@ -109,7 +109,7 @@ static void up_stackdump(uint16_t sp, uint16_t stack_base) " %02x %02x %02x %02x\n", stack, ptr[0], ptr[1], ptr[2], ptr[3], ptr[4], ptr[5], ptr[6], ptr[7], - ptr[9], ptr[10], ptr[11]); + ptr[8], ptr[9], ptr[10], ptr[11]); } } |