diff options
| author | Alejandro Soto <alejandro@34project.org> | 2023-11-15 19:10:34 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2023-11-16 16:43:59 -0600 |
| commit | 87a42e555bf952047e287f4c7810cd538595d5af (patch) | |
| tree | d08db58fc3484bae6d63e5b2d69e66bf8c11cf95 /demo/main.c | |
| parent | ba803067cb54edece9ffa8b92f9bb97317d082e5 (diff) | |
rtl/smp: implement SMP dead/alive handling
Diffstat (limited to 'demo/main.c')
| -rw-r--r-- | demo/main.c | 22 |
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) { |
