From 9623c48284a184ff5ef9de6d614a1525ffa79e77 Mon Sep 17 00:00:00 2001 From: Travis Geiselbrecht Date: Sat, 12 Jun 2010 01:01:54 +0000 Subject: [PATCH] SMP: remove the tracking of apic id -> cpu id. Don't pass between bootloader and kernel. Kernel doesn't use it, and it could be regenerated in the kernel if it did need it. This also unlocks the apic range the bios can use. Previously the apic ids would have to fit within 0..MAX_CPUS or it'd reject the cpu. Some boxes (mine in particular) seem to sparsely populate the apic id so that the range is pretty large. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37108 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../kernel/arch/x86/arch_kernel_args.h | 1 - src/system/boot/platform/bios_ia32/smp.cpp | 25 ++++++------------- src/system/kernel/arch/x86/arch_smp.cpp | 2 -- 3 files changed, 7 insertions(+), 21 deletions(-) diff --git a/headers/private/kernel/arch/x86/arch_kernel_args.h b/headers/private/kernel/arch/x86/arch_kernel_args.h index 8fb6268c82..0949d48726 100644 --- a/headers/private/kernel/arch/x86/arch_kernel_args.h +++ b/headers/private/kernel/arch/x86/arch_kernel_args.h @@ -38,7 +38,6 @@ typedef struct { uint32 ioapic_phys; uint32 *ioapic; uint32 cpu_apic_id[MAX_BOOT_CPUS]; - uint32 cpu_os_id[MAX_BOOT_CPUS]; uint32 cpu_apic_version[MAX_BOOT_CPUS]; // hpet stuff uint32 hpet_phys; diff --git a/src/system/boot/platform/bios_ia32/smp.cpp b/src/system/boot/platform/bios_ia32/smp.cpp index 2714d5b3d6..5a6006fd44 100644 --- a/src/system/boot/platform/bios_ia32/smp.cpp +++ b/src/system/boot/platform/bios_ia32/smp.cpp @@ -78,8 +78,13 @@ smp_get_current_cpu(void) if (gKernelArgs.arch_args.apic == NULL) return 0; - return gKernelArgs.arch_args.cpu_os_id[ - (apic_read(APIC_ID) & 0xffffffff) >> 24]; + uint8_t apic_id = (apic_read(APIC_ID) & 0xffffffff) >> 24; + for (int i = 0; i < gKernelArgs.num_cpus; i++) { + if (gKernelArgs.arch_args.cpu_apic_id[i] == apic_id) + return i; + } + + return 0; } @@ -165,16 +170,8 @@ smp_do_mp_config(mp_floating_struct *floatingStruct) continue; } - // skip if the apic id is too large - if (processor->apic_id >= MAX_BOOT_CPUS) { - TRACE(("smp: apic id too large (%d)\n", processor->apic_id)); - continue; - } - gKernelArgs.arch_args.cpu_apic_id[gKernelArgs.num_cpus] = processor->apic_id; - gKernelArgs.arch_args.cpu_os_id[processor->apic_id] - = gKernelArgs.num_cpus; gKernelArgs.arch_args.cpu_apic_version[gKernelArgs.num_cpus] = processor->apic_version; @@ -280,16 +277,8 @@ smp_do_acpi_config(void) break; } - // skip if the apic id is too large - if (localApic->apic_id >= MAX_BOOT_CPUS) { - TRACE(("smp: apic id too large (%d)\n", localApic->apic_id)); - break; - } - gKernelArgs.arch_args.cpu_apic_id[gKernelArgs.num_cpus] = localApic->apic_id; - gKernelArgs.arch_args.cpu_os_id[localApic->apic_id] - = gKernelArgs.num_cpus; // TODO: how to find out? putting 0x10 in to indicate a local apic gKernelArgs.arch_args.cpu_apic_version[gKernelArgs.num_cpus] = 0x10; diff --git a/src/system/kernel/arch/x86/arch_smp.cpp b/src/system/kernel/arch/x86/arch_smp.cpp index 0ad8232a84..1b585eada6 100644 --- a/src/system/kernel/arch/x86/arch_smp.cpp +++ b/src/system/kernel/arch/x86/arch_smp.cpp @@ -34,7 +34,6 @@ #endif static uint32 sCPUAPICIds[B_MAX_CPU_COUNT]; -static uint32 sCPUOSIds[B_MAX_CPU_COUNT]; static uint32 sAPICVersions[B_MAX_CPU_COUNT]; extern "C" void init_sse(void); @@ -84,7 +83,6 @@ arch_smp_init(kernel_args *args) // setup some globals memcpy(sCPUAPICIds, args->arch_args.cpu_apic_id, sizeof(args->arch_args.cpu_apic_id)); - memcpy(sCPUOSIds, args->arch_args.cpu_os_id, sizeof(args->arch_args.cpu_os_id)); memcpy(sAPICVersions, args->arch_args.cpu_apic_version, sizeof(args->arch_args.cpu_apic_version)); // set up the local apic on the boot cpu