From bd8aa7e222aa89ca27a5fe2e660f02ff942abb48 Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Sat, 13 Jun 2009 11:16:53 +0800 Subject: [PATCH] Get rid of global variable 'boot_cpu_id' --- sys/platform/pc32/i386/mp_machdep.c | 12 ++++-------- sys/platform/pc32/include/smp.h | 1 - 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/sys/platform/pc32/i386/mp_machdep.c b/sys/platform/pc32/i386/mp_machdep.c index 75aebedea9..8741347d9c 100644 --- a/sys/platform/pc32/i386/mp_machdep.c +++ b/sys/platform/pc32/i386/mp_machdep.c @@ -232,7 +232,6 @@ int mp_nbusses; /* # of busses */ #ifdef APIC_IO int mp_napics; /* # of IO APICs */ #endif -int boot_cpu_id; /* designated BSP */ vm_offset_t cpu_apic_address; #ifdef APIC_IO vm_offset_t io_apic_address[NAPICID]; /* NAPICID is more than enough */ @@ -830,7 +829,6 @@ mptable_pass1(struct mptable_pos *mpt) * 2nd pass on motherboard's Intel MP specification table. * * sets: - * boot_cpu_id * logical_cpus_mask * ID_TO_IO(N), phy APIC ID to log CPU/IO table * CPU_TO_ID(N), logical CPU to APIC ID table @@ -900,9 +898,6 @@ mptable_pass2(struct mptable_pos *mpt) } #endif - /* setup the cpu/apic mapping arrays */ - boot_cpu_id = -1; - /* record whether PIC or virtual-wire mode */ machintr_setvar_simple(MACHINTR_VAR_IMCR_PRESENT, fps->mpfb2 & 0x80); @@ -970,7 +965,7 @@ mptable_pass2(struct mptable_pos *mpt) position = (uint8_t *)position + basetable_entry_types[type].length; } - if (boot_cpu_id == -1) + if (CPU_TO_ID(0) < 0) panic("NO BSP found!"); /* report fact that its NOT a default configuration */ @@ -1469,6 +1464,8 @@ setup_apic_irq_mapping(void) static int processor_entry(proc_entry_ptr entry, int cpu) { + KKASSERT(cpu > 0); + /* check for usability */ if (!(entry->cpu_flags & PROCENTRY_FLAG_EN)) return 0; @@ -1477,7 +1474,6 @@ processor_entry(proc_entry_ptr entry, int cpu) panic("CPU APIC ID out of range (0..%d)", NAPICID - 1); /* check for BSP flag */ if (entry->cpu_flags & PROCENTRY_FLAG_BP) { - boot_cpu_id = entry->apic_id; CPU_TO_ID(0) = entry->apic_id; ID_TO_CPU(entry->apic_id) = 0; return 0; /* its already been counted */ @@ -1933,7 +1929,7 @@ apic_polarity(int apic, int pin) static void default_mp_table(int type) { - int ap_cpu_id; + int ap_cpu_id, boot_cpu_id; #if defined(APIC_IO) int io_apic_id; int pin; diff --git a/sys/platform/pc32/include/smp.h b/sys/platform/pc32/include/smp.h index 9cb6149d6a..161448c4e0 100644 --- a/sys/platform/pc32/include/smp.h +++ b/sys/platform/pc32/include/smp.h @@ -61,7 +61,6 @@ extern int bsp_apic_ready; extern int mp_naps; extern int mp_nbusses; extern int mp_napics; -extern int boot_cpu_id; extern vm_offset_t cpu_apic_address; extern vm_offset_t io_apic_address[]; extern u_int32_t cpu_apic_versions[]; -- 2.41.0