[rtems commit] bsp/leon3: Move SMP data to start.S

Sebastian Huber sebh at rtems.org
Fri Feb 10 15:01:11 UTC 2023


Module:    rtems
Branch:    master
Commit:    b993111594a2e49273a056bafd14a28dc04f5e19
Changeset: http://git.rtems.org/rtems/commit/?id=b993111594a2e49273a056bafd14a28dc04f5e19

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Fri Feb 10 10:52:02 2023 +0100

bsp/leon3: Move SMP data to start.S

The LEON3_Boot_Cpu global object is only used by start.S.  Move the definition
of this object to start.S and use a local symbol .Lbootcpuindex for it.

Use a compare-and-swap instruction to assign the boot CPU.  This allows a
concurrent initialization.

Close #4845.

---

 bsps/sparc/leon3/start/bspstart.c |  5 -----
 bsps/sparc/shared/start/start.S   | 35 ++++++++++++++++++++++++-----------
 2 files changed, 24 insertions(+), 16 deletions(-)

diff --git a/bsps/sparc/leon3/start/bspstart.c b/bsps/sparc/leon3/start/bspstart.c
index d93d73aca8..61f888247f 100644
--- a/bsps/sparc/leon3/start/bspstart.c
+++ b/bsps/sparc/leon3/start/bspstart.c
@@ -59,11 +59,6 @@ int CPU_SPARC_HAS_SNOOPING;
 /* Index of CPU, in an AMP system CPU-index may be non-zero */
 uint32_t LEON3_Cpu_Index = 0;
 
-#if defined(RTEMS_SMP)
-/* Index of the boot CPU. Set by the first CPU at boot to its CPU ID. */
-int LEON3_Boot_Cpu = -1;
-#endif
-
 /*
  * set_snooping
  *
diff --git a/bsps/sparc/shared/start/start.S b/bsps/sparc/shared/start/start.S
index a67c6bc163..8a22f8ff74 100644
--- a/bsps/sparc/shared/start/start.S
+++ b/bsps/sparc/shared/start/start.S
@@ -493,17 +493,13 @@ SYM(hard_reset):
         mov     %sp, %fp ! set frame pointer
 
 #if defined(START_LEON3_ENABLE_SMP)
-	/* If LEON3_Boot_Cpu < 0 then assign us as boot CPU and continue. */
-        set     SYM(LEON3_Boot_Cpu), %l0
-        ld      [%l0], %l1
-        tst     %l1
-	bneg	.Lbootcpu
-	 nop
-
-	call	SYM(bsp_start_on_secondary_processor) ! does not return
-	 mov	%g6, %o0
-.Lbootcpu:
-	st	%l7, [%l0]
+        /* If .Lbootcpuindex < 0 then assign us as boot CPU and continue. */
+        set     SYM(.Lbootcpuindex), %l0
+        mov     -1, %l1
+        casa    [%l0] (10), %l1, %l7
+        cmp     %l1, %l7
+        bne     .Lbootsecondarycpu
+         nop
 #endif
 
         /* clear the bss */
@@ -527,4 +523,21 @@ SYM(hard_reset):
         call    SYM(boot_card)          ! does not return
          mov    %g0, %o0                ! command line
 
+#if defined(START_LEON3_ENABLE_SMP)
+.Lbootsecondarycpu:
+        call    SYM(bsp_start_on_secondary_processor) ! does not return
+         mov    %g6, %o0
+
+        /*
+         * This is the index of the boot CPU.  Set by the first CPU at boot to
+         * its CPU index.
+         */
+        .section .data, "aw"
+        .align  4
+        .type   .Lbootcpuindex, #object
+        .size   .Lbootcpuindex, 4
+.Lbootcpuindex:
+        .long   -1
+#endif
+
 /* end of file */



More information about the vc mailing list