Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions libcpu/arm/cortex-a/cpuport.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ struct rt_hw_stack
#define E_Bit (1<<9)
#define J_Bit (1<<24)

/* VFP/NEON register count for FPU context */
#ifndef VFP_DATA_NR
#define VFP_DATA_NR 64 /* 32 double-precision registers = 64 words */
#endif

#ifdef RT_USING_SMP
typedef union {
unsigned long slock;
Expand Down
8 changes: 7 additions & 1 deletion libcpu/arm/cortex-a/stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,13 @@ rt_uint8_t *rt_hw_stack_init(void *tentry, void *parameter,
*(--stk) = 0; /* user sp*/
#endif
#ifdef RT_USING_FPU
*(--stk) = 0; /* not use fpu*/
/* FPU context initialization matches context_gcc.S restore order:
* Stack layout (high to low): FPEXC -> FPSCR -> D16-D31 -> D0-D15
*/
stk -= VFP_DATA_NR;
rt_memset(stk, 0, VFP_DATA_NR * sizeof(rt_uint32_t)); /* Initialize D0-D31 (64 words for 32 double regs) */
*(--stk) = 0; /* FPSCR: Floating-Point Status and Control Register */
*(--stk) = 0x40000000; /* FPEXC: Enable FPU (bit 30 = EN) */
#endif

/* return task's current stack address */
Expand Down