summaryrefslogtreecommitdiff
path: root/nuttx/arch
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-12-30 21:21:19 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-12-30 21:21:19 +0000
commit5917a60fa1d1ce72c19eada4f4047559d124dfb8 (patch)
tree4dcae6b825b67399e4ad9670bcdea68142534b8a /nuttx/arch
parent9f740c40ba0aabdc4501452e93d0a22524cb4c7d (diff)
downloadpx4-nuttx-5917a60fa1d1ce72c19eada4f4047559d124dfb8.tar.gz
px4-nuttx-5917a60fa1d1ce72c19eada4f4047559d124dfb8.tar.bz2
px4-nuttx-5917a60fa1d1ce72c19eada4f4047559d124dfb8.zip
Needs same fixes as for up_head.asm
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@465 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch')
-rw-r--r--nuttx/arch/z80/src/common/up_restoreusercontext.asm18
1 files changed, 12 insertions, 6 deletions
diff --git a/nuttx/arch/z80/src/common/up_restoreusercontext.asm b/nuttx/arch/z80/src/common/up_restoreusercontext.asm
index 1840b260e..b37b6a752 100644
--- a/nuttx/arch/z80/src/common/up_restoreusercontext.asm
+++ b/nuttx/arch/z80/src/common/up_restoreusercontext.asm
@@ -64,27 +64,33 @@ _up_restoreusercontext:
pop hl ; BC = Address of save structure
ld sp, hl ; SP points to top of storage area
- ; Disable interrupts while we muck with the alternative registers
+ ; Disable interrupts while we muck with the alternative registers. The
+ ; Correct interrupt state will be restore below
+
+ di
; Restore registers. HL points to the beginning of the reg structure to restore
ex af, af' ; Select alternate AF
pop af ; Offset 0: AF' = I with interrupt state in carry
+ ex af, af' ; Restore original AF
pop bc ; Offset 1: BC
pop de ; Offset 2: DE
pop ix ; Offset 3: IX
pop iy ; Offset 4: IY
exx ; Use alternate BC/DE/HL
- pop hl ; Offset 5: HL' = Stack pointer at time of interrupt
- exx
+ ld hl, #-2 ; Offset of SP to account for ret addr on stack
+ pop de ; Offset 5: HL' = Stack pointer after return
+ add hl, de ; HL = Stack pointer value before return
+ exx ; Restore original BC/DE/HL
pop hl ; Offset 6: HL
pop af ; Offset 7: AF
; Restore the stack pointer
- exx
- ld sp, hl
- exx
+ exx ; Use alternate BC/DE/HL
+ ld sp, hl ; Set SP = saved stack pointer value before return
+ exx ; Restore original BC/DE/HL
; Restore interrupt state