mirror of
https://github.com/apache/nuttx.git
synced 2026-10-06 13:55:15 +00:00
arm: use global variables for CPU startup addresses
Replace direct labels for CPU startup routines with indirection through global variables. Export cpu1_start, cpu2_start, cpu3_start as global objects containing addresses to __cpu1_start, __cpu2_start, __cpu3_start respectively. Use load-then- branch-exchange (ldr r1, =cpu*_start; ldr r1, [r1]; bxeq r1) instead of direct beq jumps. Enables flexible control of CPU startup positions and supports future AMP/ dynamic loading scenarios. Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
parent
c1884b8a4f
commit
f4cbc1455f
4 changed files with 56 additions and 10 deletions
|
|
@ -101,6 +101,12 @@ __cpu1_start:
|
|||
|
||||
b .Lcpu_start
|
||||
|
||||
.globl cpu1_start
|
||||
.type cpu1_start, object
|
||||
|
||||
cpu1_start:
|
||||
.long __cpu1_start
|
||||
|
||||
.Lcpu1_stackpointer:
|
||||
.long .Lcpu1_stacktop
|
||||
.size __cpu1_start, .-__cpu1_start
|
||||
|
|
@ -124,6 +130,12 @@ __cpu2_start:
|
|||
|
||||
b .Lcpu_start
|
||||
|
||||
.globl cpu2_start
|
||||
.type cpu2_start, object
|
||||
|
||||
cpu2_start:
|
||||
.long __cpu2_start
|
||||
|
||||
.Lcpu2_stackpointer:
|
||||
.long .Lcpu2_stacktop
|
||||
.size __cpu2_start, .-__cpu2_start
|
||||
|
|
@ -147,6 +159,12 @@ __cpu3_start:
|
|||
|
||||
b .Lcpu_start
|
||||
|
||||
.globl cpu3_start
|
||||
.type cpu3_start, object
|
||||
|
||||
cpu3_start:
|
||||
.long __cpu3_start
|
||||
|
||||
.Lcpu3_stackpointer:
|
||||
.long .Lcpu3_stacktop
|
||||
.size __cpu3_start, .-__cpu3_start
|
||||
|
|
|
|||
|
|
@ -197,19 +197,24 @@ __start:
|
|||
wfe
|
||||
#endif
|
||||
|
||||
ldr r1, =cpu1_start
|
||||
ldr r1, [r1]
|
||||
cmp r0, #1
|
||||
beq __cpu1_start
|
||||
bxeq r1
|
||||
# if CONFIG_NCPUS > 2
|
||||
ldr r1, =cpu2_start
|
||||
ldr r1, [r1]
|
||||
cmp r0, #2
|
||||
beq __cpu2_start
|
||||
bxeq r1
|
||||
# endif
|
||||
# if CONFIG_NCPUS > 3
|
||||
ldr r1, =cpu3_start
|
||||
ldr r1, [r1]
|
||||
cmp r0, #3
|
||||
beq __cpu3_start
|
||||
bxeq r1
|
||||
# endif
|
||||
# if CONFIG_NCPUS > 4
|
||||
cmp r0, #4
|
||||
beq __cpu4_start
|
||||
# error This logic needs to extended for CONFIG_SMP_NCPUS > 4
|
||||
# endif
|
||||
|
||||
__cpu0_start:
|
||||
|
|
|
|||
|
|
@ -127,6 +127,12 @@ __cpu1_start:
|
|||
|
||||
b .Lcpu_start
|
||||
|
||||
.globl cpu1_start
|
||||
.type cpu1_start, object
|
||||
|
||||
cpu1_start:
|
||||
.long __cpu1_start
|
||||
|
||||
.Lcpu1_stackpointer:
|
||||
.long .Lcpu1_stacktop
|
||||
.size __cpu1_start, .-__cpu1_start
|
||||
|
|
@ -150,6 +156,12 @@ __cpu2_start:
|
|||
|
||||
b .Lcpu_start
|
||||
|
||||
.globl cpu2_start
|
||||
.type cpu2_start, object
|
||||
|
||||
cpu2_start:
|
||||
.long __cpu2_start
|
||||
|
||||
.Lcpu2_stackpointer:
|
||||
.long .Lcpu2_stacktop
|
||||
.size __cpu2_start, .-__cpu2_start
|
||||
|
|
@ -173,6 +185,12 @@ __cpu3_start:
|
|||
|
||||
b .Lcpu_start
|
||||
|
||||
.globl cpu3_start
|
||||
.type cpu3_start, object
|
||||
|
||||
cpu3_start:
|
||||
.long __cpu3_start
|
||||
|
||||
.Lcpu3_stackpointer:
|
||||
.long .Lcpu3_stacktop
|
||||
.size __cpu3_start, .-__cpu3_start
|
||||
|
|
|
|||
|
|
@ -145,19 +145,24 @@ __start:
|
|||
wfe
|
||||
#endif
|
||||
|
||||
ldr r1, =cpu1_start
|
||||
ldr r1, [r1]
|
||||
cmp r0, #1
|
||||
beq __cpu1_start
|
||||
bxeq r1
|
||||
# if CONFIG_NCPUS > 2
|
||||
ldr r1, =cpu2_start
|
||||
ldr r1, [r1]
|
||||
cmp r0, #2
|
||||
beq __cpu2_start
|
||||
bxeq r1
|
||||
# endif
|
||||
# if CONFIG_NCPUS > 3
|
||||
ldr r1, =cpu3_start
|
||||
ldr r1, [r1]
|
||||
cmp r0, #3
|
||||
beq __cpu3_start
|
||||
bxeq r1
|
||||
# endif
|
||||
# if CONFIG_NCPUS > 4
|
||||
cmp r0, #4
|
||||
beq __cpu4_start
|
||||
# error This logic needs to extended for CONFIG_SMP_NCPUS > 4
|
||||
# endif
|
||||
|
||||
__cpu0_start:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue