[mp] restructure the sequence of how cpus are brought up

- Move a bit of the shared logic of secondary bootstrapping into a new
  function, lk_secondary_cpu_entry_early() which sets the current cpu
  pointer before calling the first half of the secondary LK_INIT
  routines.
- Create the per cpu idle threads on the main cpu instead of the
  secondary as they come up.
- Tweak all of the SMP capable architectures to use this new path.
- Move the top level mp routines into a separate file top/mp.c
- A bit more correctly ifdef out more SMP code.
This commit is contained in:
Travis Geiselbrecht
2025-10-08 05:00:31 +00:00
parent e47183725d
commit e4d65228b5
15 changed files with 141 additions and 85 deletions

View File

@@ -14,6 +14,7 @@
#include <lk/err.h>
#include <lk/main.h>
#include <lk/trace.h>
#include <kernel/thread.h>
#include <stdio.h>
#include <sys/types.h>
#if WITH_KERNEL_VM
@@ -239,7 +240,7 @@ status_t fdtwalk_setup_cpus_arm(const void *fdt) {
/* boot the secondary cpus using the Power State Coordintion Interface */
for (size_t i = 1; i < cpu_count; i++) {
/* note: assumes cpuids are numbered like MPIDR 0:0:0:N */
dprintf(INFO, "ARM: starting cpu %#x\n", cpus[i].id);
dprintf(INFO, "ARM: starting cpu %u\n", cpus[i].id);
int ret = psci_cpu_on(cpus[i].id, phys_entry, i);
if (ret != 0) {
printf("ERROR: psci CPU_ON returns %d\n", ret);