mirror of
https://github.com/apache/nuttx.git
synced 2025-12-07 10:03:38 +08:00
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:
@@ -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:
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user