这个 stone xiong 帖子的回复里有说 解决开FPU进硬件出错中断 哈哈 我试过了 可以用 由于不能贴地址 我直接贴代码了 呵呵 就改这3个地方
OSPendSV
CPSID I ; Prevent interruption during context switch
MRS R0, PSP ; PSP is process stack pointer
CBZ R0, OSPendSV_nosave ; Skip register save the first time
SUB R0, R0, #0x20 ; Save remaining regs r4-11 on process stack
STM R0, {R4-R11}
SUB R0, R0, #0X40
VSTM R0, {D8-D15}
LDR R1, =OSTCBCur ; 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} ; Save LR exc_return value
LDR R0, =OSTaskSwHook ; OSTaskSwHook();
BLX R0
POP {R14}
LDR R0, =OSPrioCur ; OSPrioCur = OSPrioHighRdy;
LDR R1, =OSPrioHighRdy
LDRB R2, [R1]
STRB R2, [R0]
LDR R0, =OSTCBCur ; OSTCBCur = OSTCBHighRdy;
LDR R1, =OSTCBHighRdy
LDR R2, [R1]
STR R2, [R0]
LDR R0, [R2] ; R0 is new process SP; SP = OSTCBHighRdy->OSTCBStkPtr;
VLDM R0, {D8-D15}
ADD R0, R0, #0X40
LDM R0, {R4-R11}
ADD R0, R0, #0X20
BIC.W LR, LR, #0x10 ; Set exception return uses floating-point state
MSR PSP, R0 ; Load PSP with new process SP
ORR LR, LR, #0x04 ; Ensure exception return uses process stack
CPSIE I
BX LR ; Exception return will restore remaining context
OS_STK *OSTaskStkInit (void (*task)(void *p_arg), void *p_arg, OS_STK *ptos, INT16U opt)
{
OS_STK *stk;
unsigned int i;
(void)opt; /* 'opt' is not used, prevent warning */
stk = ptos; /* Load stack pointer */
*(stk) = (INT32U)0xCCUL;
*(--stk) = (INT32U)0xDDUL;
for(i = 16u; i != 0; i--)
{
*(--stk) = (INT32U)0xAAAAAAAAUL;
}
/* Registers stacked as if auto-saved on exception */
*(--stk) = (INT32U)0x01000000uL; /* xPSR */
*(--stk) = (INT32U)task; /* Entry Point PC */
*(--stk) = (INT32U)0xFFFFFFFEL; /* R14 (LR) (init value will */
/* cause fault if ever used) */
*(--stk) = (INT32U)0x12121212uL; /* R12 */
*(--stk) = (INT32U)0x03030303uL; /* R3 */
*(--stk) = (INT32U)0x02020202uL; /* R2 */
*(--stk) = (INT32U)0x01010101uL; /* R1 */
*(--stk) = (INT32U)p_arg; /* R0 : argument */
/* Remaining registers saved on process stack */
*(--stk) = (INT32U)0x11111111uL; /* R11 */
*(--stk) = (INT32U)0x10101010uL; /* R10 */
*(--stk) = (INT32U)0x09090909uL; /* R9 */
*(--stk) = (INT32U)0x08080808uL; /* R8 */
*(--stk) = (INT32U)0x07070707uL; /* R7 */
*(--stk) = (INT32U)0x06060606uL; /* R6 */
*(--stk) = (INT32U)0x05050505uL; /* R5 */
*(--stk) = (INT32U)0x04040404uL; /* R4 */
for (i = 16u; i != 0; i--) /* Initialize general-purpose Floating point registers */
{
*--stk = (INT32U)0xBBBBBBBBuL; /* S16-S31 */
}
return (stk);
} |