From bc0215286a51da3b028873e4ea1b44d23a87ebdd Mon Sep 17 00:00:00 2001 From: Sepherosa Ziehau Date: Sat, 20 Jun 2009 18:29:27 +0800 Subject: [PATCH] Add APIC_ID to extract apic id from local apic id field --- sys/platform/pc32/apic/apicreg.h | 2 ++ sys/platform/pc32/i386/mp_machdep.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/sys/platform/pc32/apic/apicreg.h b/sys/platform/pc32/apic/apicreg.h index df5e57cab0..64270f91d0 100644 --- a/sys/platform/pc32/apic/apicreg.h +++ b/sys/platform/pc32/apic/apicreg.h @@ -450,6 +450,8 @@ typedef struct IOAPIC ioapic_t; #define APIC_MAX_INTRACLUSTER_ID 3 #define APIC_ID_CLUSTER_SHIFT 4 +#define APIC_ID(id) (((id) & APIC_ID_MASK) >> APIC_ID_SHIFT) + /* * lapic.ver (ro) */ diff --git a/sys/platform/pc32/i386/mp_machdep.c b/sys/platform/pc32/i386/mp_machdep.c index d68795de07..2ae47bd283 100644 --- a/sys/platform/pc32/i386/mp_machdep.c +++ b/sys/platform/pc32/i386/mp_machdep.c @@ -693,7 +693,7 @@ mp_enable(u_int boot_addr) lapic_init(lapic_addr); - bsp_apic_id = (lapic.id & 0xff000000) >> 24; + bsp_apic_id = APIC_ID(lapic.id); if (madt_pass2(madt_paddr, bsp_apic_id)) panic("mp_enable: madt_pass2 failed\n"); } @@ -2948,7 +2948,7 @@ mptable_lapic_enumerate(struct mptable_pos *mpt) if (fps->mpfb1 != 0) { int ap_cpu_id, boot_cpu_id; - boot_cpu_id = (lapic.id & APIC_ID_MASK) >> 24; + boot_cpu_id = APIC_ID(lapic.id); ap_cpu_id = (boot_cpu_id == 0) ? 1 : 0; /* BSP */ -- 2.41.0