我在看ucosiii的3.08版本的模板移植是如下
[C] 纯文本查看 复制代码 CPU_STK *OSTaskStkInit (OS_TASK_PTR p_task,
void *p_arg,
CPU_STK *p_stk_base,
CPU_STK *p_stk_limit,
CPU_STK_SIZE stk_size,
OS_OPT opt)
{
CPU_STK *p_stk;
(void)opt; /* 'opt' is not used, prevent warning */
p_stk = &p_stk_base[stk_size]; /* Load stack pointer */
/* Align the stack to 8-bytes. */
p_stk = (CPU_STK *)((CPU_STK)(p_stk) & 0xFFFFFFF8u);
/* Registers stacked as if auto-saved on exception */
#if (OS_CPU_ARM_FP_EN > 0u) /* FPU auto-saved registers. */
--p_stk;
*(--p_stk) = (CPU_STK)0x02000000u; /* FPSCR */
/* Initialize S0-S15 floating point registers */
*(--p_stk) = (CPU_STK)0x41700000u; /* S15 */
*(--p_stk) = (CPU_STK)0x41600000u; /* S14 */
*(--p_stk) = (CPU_STK)0x41500000u; /* S13 */
*(--p_stk) = (CPU_STK)0x41400000u; /* S12 */
*(--p_stk) = (CPU_STK)0x41300000u; /* S11 */
*(--p_stk) = (CPU_STK)0x41200000u; /* S10 */
*(--p_stk) = (CPU_STK)0x41100000u; /* S9 */
*(--p_stk) = (CPU_STK)0x41000000u; /* S8 */
*(--p_stk) = (CPU_STK)0x40E00000u; /* S7 */
*(--p_stk) = (CPU_STK)0x40C00000u; /* S6 */
*(--p_stk) = (CPU_STK)0x40A00000u; /* S5 */
*(--p_stk) = (CPU_STK)0x40800000u; /* S4 */
*(--p_stk) = (CPU_STK)0x40400000u; /* S3 */
*(--p_stk) = (CPU_STK)0x40000000u; /* S2 */
*(--p_stk) = (CPU_STK)0x3F800000u; /* S1 */
*(--p_stk) = (CPU_STK)0x00000000u; /* S0 */
#endif
*(--p_stk) = (CPU_STK)0x01000000u; /* xPSR */
*(--p_stk) = (CPU_STK)p_task; /* Entry Point */
*(--p_stk) = (CPU_STK)OS_TaskReturn; /* R14 (LR) */
*(--p_stk) = (CPU_STK)0x12121212u; /* R12 */
*(--p_stk) = (CPU_STK)0x03030303u; /* R3 */
*(--p_stk) = (CPU_STK)0x02020202u; /* R2 */
*(--p_stk) = (CPU_STK)p_stk_limit; /* R1 */
*(--p_stk) = (CPU_STK)p_arg; /* R0 : argument */
#if (OS_CPU_ARM_FP_EN > 0u)
*(--p_stk) = (CPU_STK)0xFFFFFFEDuL; /* R14: EXEC_RETURN; See Note 5 */
#else
*(--p_stk) = (CPU_STK)0xFFFFFFFDuL; /* R14: EXEC_RETURN; See Note 5 */
#endif
/* Remaining registers saved on process stack */
*(--p_stk) = (CPU_STK)0x11111111uL; /* R11 */
*(--p_stk) = (CPU_STK)0x10101010uL; /* R10 */
*(--p_stk) = (CPU_STK)0x09090909uL; /* R9 */
*(--p_stk) = (CPU_STK)0x08080808uL; /* R8 */
*(--p_stk) = (CPU_STK)0x07070707uL; /* R7 */
*(--p_stk) = (CPU_STK)0x06060606uL; /* R6 */
*(--p_stk) = (CPU_STK)0x05050505uL; /* R5 */
*(--p_stk) = (CPU_STK)0x04040404uL; /* R4 */
#if (OS_CPU_ARM_FP_EN > 0u)
/* Initialize S16-S31 floating point registers */
*(--p_stk) = (CPU_STK)0x41F80000u; /* S31 */
*(--p_stk) = (CPU_STK)0x41F00000u; /* S30 */
*(--p_stk) = (CPU_STK)0x41E80000u; /* S29 */
*(--p_stk) = (CPU_STK)0x41E00000u; /* S28 */
*(--p_stk) = (CPU_STK)0x41D80000u; /* S27 */
*(--p_stk) = (CPU_STK)0x41D00000u; /* S26 */
*(--p_stk) = (CPU_STK)0x41C80000u; /* S25 */
*(--p_stk) = (CPU_STK)0x41C00000u; /* S24 */
*(--p_stk) = (CPU_STK)0x41B80000u; /* S23 */
*(--p_stk) = (CPU_STK)0x41B00000u; /* S22 */
*(--p_stk) = (CPU_STK)0x41A80000u; /* S21 */
*(--p_stk) = (CPU_STK)0x41A00000u; /* S20 */
*(--p_stk) = (CPU_STK)0x41980000u; /* S19 */
*(--p_stk) = (CPU_STK)0x41900000u; /* S18 */
*(--p_stk) = (CPU_STK)0x41880000u; /* S17 */
*(--p_stk) = (CPU_STK)0x41800000u; /* S16 */
#endif
return (p_stk);
}
我在看《安富莱_STM32-V5开发板_μCOS-III教程》的FPU解决方案的代码如下:
[C] 纯文本查看 复制代码 CPU_STK *OSTaskStkInit (OS_TASK_PTR p_task,
void *p_arg,
CPU_STK *p_stk_base,
CPU_STK *p_stk_limit,
CPU_STK_SIZE stk_size,
OS_OPT opt)
{
CPU_STK *p_stk;
(void)opt; /* Prevent compiler warning */
p_stk = &p_stk_base[stk_size]; /* Load stack pointer */
/* Align the stack to 8-bytes. */
p_stk = (CPU_STK *)((CPU_STK)(p_stk) & 0xFFFFFFF8);
/* Registers stacked as if auto-saved on exception */
*--p_stk = (CPU_STK)0x01000000u; /* xPSR */
*--p_stk = (CPU_STK)p_task; /* Entry Point */
*--p_stk = (CPU_STK)OS_TaskReturn; /* R14 (LR) */
*--p_stk = (CPU_STK)0x12121212u; /* R12 */
*--p_stk = (CPU_STK)0x03030303u; /* R3 */
*--p_stk = (CPU_STK)0x02020202u; /* R2 */
*--p_stk = (CPU_STK)p_stk_limit; /* R1 */
*--p_stk = (CPU_STK)p_arg; /* R0 : argument */
/* Remaining registers saved on process stack */
*--p_stk = (CPU_STK)0x11111111u; /* R11 */
*--p_stk = (CPU_STK)0x10101010u; /* R10 */
*--p_stk = (CPU_STK)0x09090909u; /* R9 */
*--p_stk = (CPU_STK)0x08080808u; /* R8 */
*--p_stk = (CPU_STK)0x07070707u; /* R7 */
*--p_stk = (CPU_STK)0x06060606u; /* R6 */
*--p_stk = (CPU_STK)0x05050505u; /* R5 */
*--p_stk = (CPU_STK)0x04040404u; /* R4 */
*--p_stk = (CPU_STK)0xFFFFFFFDUL; (1)
return (p_stk);
}
为什么在《安富莱_STM32-V5开发板_μCOS-III教程》书中的处理方法和ucos3.08模板的处理方法不一样?
|