armv[7/8]-r: add ARM_BUSY_WAIT

On a system with multiple CPU cores, when the system is powered on,
multiple cores may start running simultaneously. In this case, software
is required to handle the startup logic for multi-core synchronization.
One approach is to use global variables.
however, the global variable region may not have been initialized yet.
In such scenarios, we can use a busywait flag to
implement the synchronization strategy.

Signed-off-by: hujun5 <hujun5@xiaomi.com>
This commit is contained in:
hujun5
2025-04-16 10:30:27 +08:00
committed by Xiang Xiao
parent c0db55f453
commit f59510ec62
2 changed files with 36 additions and 0 deletions

View File

@@ -134,7 +134,17 @@ __start:
and r0, r0, #0x3
cmp r0, #0
beq __cpu0_start
#ifdef CONFIG_ARM_BUSY_WAIT
ldr r2, =CONFIG_ARM_BUSY_WAIT_FLAG_ADDR
1:
ldr r1, [r2, #0]
cmp r1, #0
beq 1b
#else
wfe
#endif
cmp r0, #1
beq __cpu1_start
# if CONFIG_SMP_NCPUS > 2
@@ -395,6 +405,15 @@ __cpu0_start:
b arm_boot
/* finish busy wait */
#if defined(CONFIG_ARM_BUSY_WAIT) && defined(CONFIG_SMP)
ldr r0, =CONFIG_ARM_BUSY_WAIT_FLAG_ADDR
mov r1, #1
str r1, [r0]
dsb sy
#endif
/* .text Data */
.Lstackpointer:

View File

@@ -142,7 +142,17 @@ __start:
cmp r0, #0
#if defined(CONFIG_SMP) && CONFIG_SMP_NCPUS > 1
beq __cpu0_start
#ifdef CONFIG_ARM_BUSY_WAIT
ldr r2, =CONFIG_ARM_BUSY_WAIT_FLAG_ADDR
1:
ldr r1, [r2, #0]
cmp r1, #0
beq 1b
#else
wfe
#endif
cmp r0, #1
beq __cpu1_start
# if CONFIG_SMP_NCPUS > 2
@@ -247,6 +257,13 @@ __cpu0_start:
mov lr, #0 /* LR = return address (none) */
b nx_start /* Branch to nx_start */
#if defined(CONFIG_ARM_BUSY_WAIT) && defined(CONFIG_SMP)
ldr r0, =CONFIG_ARM_BUSY_WAIT_FLAG_ADDR
mov r1, #1
str r1, [r0]
dsb sy
#endif
/* .text Data */
.Lstackpointer: