mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-12-27 01:28:23 +00:00
fixed bug: store r8 - r11.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2258 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
; * Date Author Notes
|
||||
; * 2010-01-25 Bernard first version
|
||||
; * 2012-06-01 aozima set pendsv priority to 0xFF.
|
||||
; * 2012-08-17 aozima fixed bug: store r8 - r11.
|
||||
; */
|
||||
|
||||
;/**
|
||||
@@ -66,7 +67,7 @@ rt_hw_context_switch PROC
|
||||
LDR r3, [r2]
|
||||
CMP r3, #1
|
||||
BEQ _reswitch
|
||||
MOVS r3, #0x1
|
||||
MOVS r3, #0x01
|
||||
STR r3, [r2]
|
||||
|
||||
LDR r2, =rt_interrupt_from_thread ; set rt_interrupt_from_thread
|
||||
@@ -108,17 +109,35 @@ PendSV_Handler PROC
|
||||
BEQ swtich_to_thread ; skip register save at the first time
|
||||
|
||||
MRS r1, psp ; get from thread stack pointer
|
||||
SUBS r1, r1, #0x10
|
||||
|
||||
SUBS r1, r1, #0x20 ; space for {r4 - r7} and {r8 - r11}
|
||||
LDR r0, [r0]
|
||||
STR r1, [r0] ; update from thread stack pointer
|
||||
STMIA r1!, {r4 - r7} ; push r4 - r7 register
|
||||
|
||||
STMIA r1!, {r4 - r7} ; push thread {r4 - r7} register to thread stack
|
||||
|
||||
MOV r4, r8 ; mov thread {r8 - r11} to {r4 - r7}
|
||||
MOV r5, r9
|
||||
MOV r6, r10
|
||||
MOV r7, r11
|
||||
STMIA r1!, {r4 - r7} ; push thread {r8 - r11} high register to thread stack
|
||||
|
||||
swtich_to_thread
|
||||
LDR r1, =rt_interrupt_to_thread
|
||||
LDR r1, [r1]
|
||||
LDR r1, [r1] ; load thread stack pointer
|
||||
|
||||
LDMIA r1!, {r4 - r7} ; pop r4 - r7 register
|
||||
LDMIA r1!, {r4 - r7} ; pop thread {r4 - r7} register from thread stack
|
||||
PUSH {r4 - r7} ; push {r4 - r7} to MSP for copy {r8 - r11}
|
||||
|
||||
LDMIA r1!, {r4 - r7} ; pop thread {r8 - r11} high register from thread stack to {r4 - r7}
|
||||
MOV r8, r4 ; mov {r4 - r7} to {r8 - r11}
|
||||
MOV r9, r5
|
||||
MOV r10, r6
|
||||
MOV r11, r7
|
||||
|
||||
POP {r4 - r7} ; pop {r4 - r7} from MSP
|
||||
|
||||
MSR psp, r1 ; update stack pointer
|
||||
|
||||
pendsv_exit
|
||||
@@ -126,7 +145,7 @@ pendsv_exit
|
||||
MSR PRIMASK, r2
|
||||
|
||||
MOVS r0, #0x04
|
||||
RSBS r0, #0
|
||||
RSBS r0, r0, #0x00
|
||||
BX r0
|
||||
ENDP
|
||||
|
||||
|
||||
Reference in New Issue
Block a user