summaryrefslogtreecommitdiff
path: root/demo/main.c
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2023-11-15 19:10:34 -0600
committerAlejandro Soto <alejandro@34project.org>2023-11-16 16:43:59 -0600
commit87a42e555bf952047e287f4c7810cd538595d5af (patch)
treed08db58fc3484bae6d63e5b2d69e66bf8c11cf95 /demo/main.c
parentba803067cb54edece9ffa8b92f9bb97317d082e5 (diff)
rtl/smp: implement SMP dead/alive handling
Diffstat (limited to 'demo/main.c')
-rw-r--r--demo/main.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/demo/main.c b/demo/main.c
index c5b7353..d8f38d4 100644
--- a/demo/main.c
+++ b/demo/main.c
@@ -123,13 +123,27 @@ static void cmd_remote(char **tokens)
unknown_command(cmd);
}
+static void kick_cpus(void)
+{
+ for (unsigned i = this_cpu->num + 1; i < NUM_CPUS; ++i) {
+ if (cpu_is_alive(i)) {
+ run_cpu(i);
+ return;
+ }
+
+ print("cpu%u is dead", i);
+ }
+
+ boot_done = 1;
+}
+
static void bsp_main(void)
{
for (struct cpu *cpu = all_cpus; cpu < all_cpus + NUM_CPUS; ++cpu)
cpu->mailbox = 0;
boot_done = 0;
- run_cpu(1);
+ kick_cpus();
while (!boot_done);
print("booted %u cpus", NUM_CPUS);
@@ -165,11 +179,7 @@ static void bsp_main(void)
static void ap_main(void)
{
- if (this_cpu->num < NUM_CPUS - 1)
- run_cpu(this_cpu->num + 1);
- else
- boot_done = 1;
-
+ kick_cpus();
halt_cpu(this_cpu->num);
while (1) {