Skip to content

Commit 06eae47

Browse files
CopilotBernardXiong
andcommitted
[libcpu][cortex-a] Replace FPU init loop with rt_memset
Co-authored-by: BernardXiong <[email protected]>
1 parent 4dc072c commit 06eae47

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

libcpu/arm/cortex-a/stack.c

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
3131
rt_uint8_t *stack_addr, void *texit)
3232
{
3333
rt_uint32_t *stk;
34-
#ifdef RT_USING_FPU
35-
rt_uint32_t i;
36-
#endif
3734

3835
stack_addr += sizeof(rt_uint32_t);
3936
stack_addr = (rt_uint8_t *)RT_ALIGN_DOWN((rt_uint32_t)stack_addr, 8);
@@ -67,10 +64,8 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
6764
/* FPU context initialization matches context_gcc.S restore order:
6865
* Stack layout (high to low): FPEXC -> FPSCR -> D16-D31 -> D0-D15
6966
*/
70-
for (i = 0; i < VFP_DATA_NR; i++)
71-
{
72-
*(--stk) = 0; /* Initialize D0-D31 (64 words for 32 double regs) */
73-
}
67+
stk -= VFP_DATA_NR;
68+
rt_memset(stk, 0, VFP_DATA_NR * sizeof(rt_uint32_t)); /* Initialize D0-D31 (64 words for 32 double regs) */
7469
*(--stk) = 0; /* FPSCR: Floating-Point Status and Control Register */
7570
*(--stk) = 0x40000000; /* FPEXC: Enable FPU (bit 30 = EN) */
7671
#endif

0 commit comments

Comments
 (0)