<div dir="ltr">Looks ok.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 10, 2023 at 3:57 AM Sebastian Huber <<a href="mailto:sebastian.huber@embedded-brains.de">sebastian.huber@embedded-brains.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The LEON3_Boot_Cpu global object is only used by start.S. Move the definition<br>
of this object to start.S and use a local symbol .Lbootcpuindex for it.<br>
<br>
Use a compare-and-swap instruction to assign the boot CPU. This allows a<br>
concurrent initialization.<br>
<br>
Close #4845.<br>
---<br>
bsps/sparc/leon3/start/bspstart.c | 5 -----<br>
bsps/sparc/shared/start/start.S | 35 +++++++++++++++++++++----------<br>
2 files changed, 24 insertions(+), 16 deletions(-)<br>
<br>
diff --git a/bsps/sparc/leon3/start/bspstart.c b/bsps/sparc/leon3/start/bspstart.c<br>
index d93d73aca8..61f888247f 100644<br>
--- a/bsps/sparc/leon3/start/bspstart.c<br>
+++ b/bsps/sparc/leon3/start/bspstart.c<br>
@@ -59,11 +59,6 @@ int CPU_SPARC_HAS_SNOOPING;<br>
/* Index of CPU, in an AMP system CPU-index may be non-zero */<br>
uint32_t LEON3_Cpu_Index = 0;<br>
<br>
-#if defined(RTEMS_SMP)<br>
-/* Index of the boot CPU. Set by the first CPU at boot to its CPU ID. */<br>
-int LEON3_Boot_Cpu = -1;<br>
-#endif<br>
-<br>
/*<br>
* set_snooping<br>
*<br>
diff --git a/bsps/sparc/shared/start/start.S b/bsps/sparc/shared/start/start.S<br>
index a67c6bc163..01f1353758 100644<br>
--- a/bsps/sparc/shared/start/start.S<br>
+++ b/bsps/sparc/shared/start/start.S<br>
@@ -493,17 +493,13 @@ SYM(hard_reset):<br>
mov %sp, %fp ! set frame pointer<br>
<br>
#if defined(START_LEON3_ENABLE_SMP)<br>
- /* If LEON3_Boot_Cpu < 0 then assign us as boot CPU and continue. */<br>
- set SYM(LEON3_Boot_Cpu), %l0<br>
- ld [%l0], %l1<br>
- tst %l1<br>
- bneg .Lbootcpu<br>
- nop<br>
-<br>
- call SYM(bsp_start_on_secondary_processor) ! does not return<br>
- mov %g6, %o0<br>
-.Lbootcpu:<br>
- st %l7, [%l0]<br>
+ /* If .Lbootcpuindex < 0 then assign us as boot CPU and continue. */<br>
+ set SYM(.Lbootcpuindex), %l0<br>
+ mov -1, %l1<br>
+ casa [ %l0 ] (10), %l1, %l7<br>
+ cmp %l1, %l7<br>
+ bne .Lbootsecondarycpu<br>
+ nop<br>
#endif<br>
<br>
/* clear the bss */<br>
@@ -527,4 +523,21 @@ SYM(hard_reset):<br>
call SYM(boot_card) ! does not return<br>
mov %g0, %o0 ! command line<br>
<br>
+#if defined(START_LEON3_ENABLE_SMP)<br>
+.Lbootsecondarycpu:<br>
+ call SYM(bsp_start_on_secondary_processor) ! does not return<br>
+ mov %g6, %o0<br>
+<br>
+ /*<br>
+ * This is the index of the boot CPU. Set by the first CPU at boot to<br>
+ * its CPU index.<br>
+ */<br>
+ .section .data, "aw"<br>
+ .align 4<br>
+ .type .Lbootcpuindex, #object<br>
+ .size .Lbootcpuindex, 4<br>
+.Lbootcpuindex:<br>
+ .long -1<br>
+#endif<br>
+<br>
/* end of file */<br>
-- <br>
2.35.3<br>
<br>
_______________________________________________<br>
devel mailing list<br>
<a href="mailto:devel@rtems.org" target="_blank">devel@rtems.org</a><br>
<a href="http://lists.rtems.org/mailman/listinfo/devel" rel="noreferrer" target="_blank">http://lists.rtems.org/mailman/listinfo/devel</a><br>
</blockquote></div>