RW_IRAM1 0x20000000 0x0000FC00 ;;4C00
{
* (+RW,+ZI)
} ;; The following declarations select the "two region model" ;
;; A default __user_initial_stackheap() will be used ;
ARM_LIB_HEAP 0x2000F700 EMPTY 0x00000200 {}
ARM_LIB_STACK 0x2000FB00 EMPTY -0x00000200 {}
}
OSStartHang
NOP
B OSStartHang ;Should never get here
OSPendSV
MRS R0, PSP ; PSP is process stack pointer
;CBZ R0, OSPendSV_nosave ; skip register save the first time
SUBS R0, R0, #0x20 ; save remaining regs r4-11 on process stack
STM R0, {R4-R11}
LDR R1, __OS_TCBCur ; OSTCBCur->OSTCBStkPtr = SP;
LDR R1, [R1]
STR R0, [R1] ; R0 is SP of process being switched out
; at this point, entire context of process has been saved
OSPendSV_nosave
PUSH {R14} ; need to save LR exc_return value
LDR R0, __OS_TaskSwHook ; OSTaskSwHook();
BLX R0
POP {R14}
LDR R0, [R2] ; R0 is new process SP; SP = OSTCBHighRdy->OSTCBStkPtr;
LDM R0, {R4-R11} ; restore r4-11 from new process stack
ADDS R0, R0, #0x20
MSR PSP, R0 ; load PSP with new process SP
;ORR LR, LR, #0x04 ; ensure exception return uses process stack
BX LR