Differentiate between logical CPU IDs and ACPI MADT IDs
All checks were successful
Build documentation / build-and-deploy (push) Successful in 34s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 34s
This commit is contained in:
@@ -20,14 +20,17 @@ static struct cpu cpus[CPUS_MAX];
|
||||
|
||||
static atomic_int last_cpu_index = 0;
|
||||
static atomic_int cpu_counter;
|
||||
static atomic_int cpu_id_counter = 0;
|
||||
|
||||
/// Allocate a CPU structure
|
||||
struct cpu* cpu_make (uint64_t lapic_id, uint64_t cpu_id) {
|
||||
struct cpu* cpu = &cpus[cpu_id];
|
||||
struct cpu* cpu_make (uint64_t lapic_id, uint64_t acpi_id) {
|
||||
int id = atomic_fetch_add (&cpu_id_counter, 1);
|
||||
struct cpu* cpu = &cpus[id];
|
||||
|
||||
memset (cpu, 0, sizeof (*cpu));
|
||||
cpu->lock = SPIN_LOCK_INIT;
|
||||
cpu->id = cpu_id;
|
||||
cpu->id = id;
|
||||
cpu->acpi_id = acpi_id;
|
||||
cpu->lapic_id = lapic_id;
|
||||
|
||||
amd64_wrmsr (MSR_GS_BASE, (uint64_t)cpu);
|
||||
@@ -102,11 +105,15 @@ void smp_init (void) {
|
||||
cpu_counter = mp->cpu_count - 1;
|
||||
|
||||
for (size_t i = 0; i < mp->cpu_count; i++) {
|
||||
if (mp->cpus[i]->lapic_id != thiscpu->lapic_id) {
|
||||
if (mp->cpus[i]->processor_id != thiscpu->acpi_id) {
|
||||
mp->cpus[i]->goto_address = &amd64_smp_bootstrap;
|
||||
}
|
||||
}
|
||||
|
||||
DEBUG ("Waiting for other CPUs:\n");
|
||||
|
||||
while (atomic_load (&cpu_counter) > 0)
|
||||
;
|
||||
debugprintf (".\n");
|
||||
|
||||
DEBUG ("All CPUs are up!\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user