lapic: Record the max LAPIC APIC ID
authorSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 9 Mar 2011 13:07:28 +0000 (21:07 +0800)
committerSepherosa Ziehau <sephe@dragonflybsd.org>
Wed, 9 Mar 2011 13:15:31 +0000 (21:15 +0800)
sys/platform/pc32/apic/mpapic.c
sys/platform/pc32/i386/mp_machdep.c
sys/platform/pc32/include/smp.h
sys/platform/pc64/apic/mpapic.c
sys/platform/pc64/include/smp.h
sys/platform/pc64/x86_64/mp_machdep.c

index 136556d..57fce94 100644 (file)
@@ -90,6 +90,7 @@ static const uint32_t lapic_timer_divisors[] = {
 };
 #define APIC_TIMER_NDIVISORS (int)(NELEM(lapic_timer_divisors))
 
+int                    lapic_id_max;
 
 /*
  * Enable LAPIC, configure interrupts.
index ae87735..be83a34 100644 (file)
@@ -1542,6 +1542,9 @@ mp_set_cpuids(int cpu_id, int apic_id)
 {
        CPU_TO_ID(cpu_id) = apic_id;
        ID_TO_CPU(apic_id) = cpu_id;
+
+       if (apic_id > lapic_id_max)
+               lapic_id_max = apic_id;
 }
 
 static int
index acf5ee7..41deb99 100644 (file)
@@ -140,6 +140,7 @@ struct ioapic_enumerator {
 /* global data in mpapic.c */
 extern volatile lapic_t                lapic;
 extern volatile ioapic_t       **ioapic;
+extern int                     lapic_id_max;
 
 /* functions in mpapic.c */
 void   apic_dump               (char*);
index f11fd1d..a32b987 100644 (file)
@@ -91,6 +91,7 @@ static const uint32_t lapic_timer_divisors[] = {
 };
 #define APIC_TIMER_NDIVISORS (int)(NELEM(lapic_timer_divisors))
 
+int                    lapic_id_max;
 
 void
 lapic_eoi(void)
index de432e7..ad2d2e5 100644 (file)
@@ -150,6 +150,7 @@ struct ioapic_enumerator {
 /* global data in mpapic.c */
 extern volatile lapic_t                *lapic;
 extern volatile ioapic_t       **ioapic;
+extern int                     lapic_id_max;
 
 /* functions in mpapic.c */
 void   apic_dump               (char*);
index 161995b..e0fa588 100644 (file)
@@ -1567,6 +1567,9 @@ mp_set_cpuids(int cpu_id, int apic_id)
 {
        CPU_TO_ID(cpu_id) = apic_id;
        ID_TO_CPU(apic_id) = cpu_id;
+
+       if (apic_id > lapic_id_max)
+               lapic_id_max = apic_id;
 }
 
 static int