x86: mpparse: 64-bit fix
[safe/jmp/linux-2.6] / arch / x86 / kernel / mpparse_64.c
index fb74135..5e789bd 100644 (file)
@@ -35,7 +35,6 @@
 
 /* Have we found an MP table */
 int smp_found_config;
-unsigned int __cpuinitdata maxcpus = NR_CPUS;
 
 /*
  * Various Linux-internal data structures created from the
@@ -55,26 +54,29 @@ struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
 int mp_irq_entries;
 
 int nr_ioapics;
-unsigned long mp_lapic_addr = 0;
-
-/* Processor that is doing the boot up */
-unsigned int boot_cpu_physical_apicid = -1U;
-EXPORT_SYMBOL(boot_cpu_physical_apicid);
-
-/* Internal processor count */
-unsigned int num_processors;
-
-unsigned disabled_cpus __cpuinitdata;
-
-/* Bitmask of physically existing CPUs */
-physid_mask_t phys_cpu_present_map = PHYSID_MASK_NONE;
 
+#ifdef CONFIG_SMP
 u16 x86_bios_cpu_apicid_init[NR_CPUS] __initdata
     = {[0 ... NR_CPUS - 1] = BAD_APICID };
 void *x86_bios_cpu_apicid_early_ptr;
+#endif
 DEFINE_PER_CPU(u16, x86_bios_cpu_apicid) = BAD_APICID;
 EXPORT_PER_CPU_SYMBOL(x86_bios_cpu_apicid);
 
+/* Make it easy to share the UP and SMP code: */
+#ifndef CONFIG_X86_SMP
+unsigned int num_processors;
+unsigned disabled_cpus __cpuinitdata;
+#ifndef CONFIG_X86_LOCAL_APIC
+unsigned int boot_cpu_physical_apicid = -1U;
+#endif
+#endif
+
+/* Make it easy to share the UP and SMP code: */
+#ifndef CONFIG_X86_SMP
+physid_mask_t phys_cpu_present_map;
+#endif
+
 /*
  * Intel MP BIOS table parsing routines:
  */
@@ -95,8 +97,6 @@ static int __init mpf_checksum(unsigned char *mp, int len)
 
 static void __cpuinit MP_processor_info(struct mpc_config_processor *m)
 {
-       int cpu;
-       cpumask_t tmp_map;
        char *bootup_cpu = "";
 
        if (!(m->mpc_cpuflag & CPU_ENABLED)) {
@@ -109,46 +109,7 @@ static void __cpuinit MP_processor_info(struct mpc_config_processor *m)
        }
 
        printk(KERN_INFO "Processor #%d%s\n", m->mpc_apicid, bootup_cpu);
-
-       if (num_processors >= NR_CPUS) {
-               printk(KERN_WARNING "WARNING: NR_CPUS limit of %i reached."
-                      " Processor ignored.\n", NR_CPUS);
-               return;
-       }
-
-       if (num_processors >= maxcpus) {
-               printk(KERN_WARNING "WARNING: maxcpus limit of %i reached."
-                      " Processor ignored.\n", maxcpus);
-               return;
-       }
-
-       num_processors++;
-       cpus_complement(tmp_map, cpu_present_map);
-       cpu = first_cpu(tmp_map);
-
-       physid_set(m->mpc_apicid, phys_cpu_present_map);
-       if (m->mpc_cpuflag & CPU_BOOTPROCESSOR) {
-               /*
-                * x86_bios_cpu_apicid is required to have processors listed
-                * in same order as logical cpu numbers. Hence the first
-                * entry is BSP, and so on.
-                */
-               cpu = 0;
-       }
-       /* are we being called early in kernel startup? */
-       if (x86_cpu_to_apicid_early_ptr) {
-               u16 *cpu_to_apicid = x86_cpu_to_apicid_early_ptr;
-               u16 *bios_cpu_apicid = x86_bios_cpu_apicid_early_ptr;
-
-               cpu_to_apicid[cpu] = m->mpc_apicid;
-               bios_cpu_apicid[cpu] = m->mpc_apicid;
-       } else {
-               per_cpu(x86_cpu_to_apicid, cpu) = m->mpc_apicid;
-               per_cpu(x86_bios_cpu_apicid, cpu) = m->mpc_apicid;
-       }
-
-       cpu_set(cpu, cpu_possible_map);
-       cpu_set(cpu, cpu_present_map);
+       generic_processor_info(m->mpc_apicid, 0);
 }
 
 static void __init MP_bus_info(struct mpc_config_bus *m)
@@ -640,11 +601,13 @@ static void __init __find_smp_config(unsigned reserve)
         * trustworthy, simply because the SMP table may have been
         * stomped on during early boot. These loaders are buggy and
         * should be fixed.
+        *
+        * MP1.4 SPEC states to only scan first 1K of 4K EBDA.
         */
 
        address = get_bios_ebda();
        if (address)
-               smp_scan_config(address, 0x1000, reserve);
+               smp_scan_config(address, 0x400, reserve);
 }
 
 void __init early_find_smp_config(void)
@@ -670,34 +633,23 @@ void __init mp_register_lapic_address(u64 address)
        if (boot_cpu_physical_apicid == -1U)
                boot_cpu_physical_apicid  = GET_APIC_ID(apic_read(APIC_ID));
 }
-
 void __cpuinit mp_register_lapic(u8 id, u8 enabled)
 {
-       struct mpc_config_processor processor;
-       int boot_cpu = 0;
-
-       if (id == boot_cpu_physical_apicid)
-               boot_cpu = 1;
-
-       processor.mpc_type = MP_PROCESSOR;
-       processor.mpc_apicid = id;
-       processor.mpc_apicver = 0;
-       processor.mpc_cpuflag = (enabled ? CPU_ENABLED : 0);
-       processor.mpc_cpuflag |= (boot_cpu ? CPU_BOOTPROCESSOR : 0);
-       processor.mpc_cpufeature = 0;
-       processor.mpc_featureflag = 0;
-       processor.mpc_reserved[0] = 0;
-       processor.mpc_reserved[1] = 0;
+       if (!enabled) {
+               ++disabled_cpus;
+               return;
+       }
 
-       MP_processor_info(&processor);
+       generic_processor_info(id, 0);
 }
 
+
 #define MP_ISA_BUS             0
 #define MP_MAX_IOAPIC_PIN      127
 
 static struct mp_ioapic_routing {
        int apic_id;
-       int gsi_start;
+       int gsi_base;
        int gsi_end;
        u32 pin_programmed[4];
 } mp_ioapic_routing[MAX_IO_APICS];
@@ -708,7 +660,7 @@ static int mp_find_ioapic(int gsi)
 
        /* Find the IOAPIC that manages this GSI. */
        for (i = 0; i < nr_ioapics; i++) {
-               if ((gsi >= mp_ioapic_routing[i].gsi_start)
+               if ((gsi >= mp_ioapic_routing[i].gsi_base)
                    && (gsi <= mp_ioapic_routing[i].gsi_end))
                        return i;
        }
@@ -753,14 +705,14 @@ void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
         * and to prevent reprogramming of IOAPIC pins (PCI IRQs).
         */
        mp_ioapic_routing[idx].apic_id = mp_ioapics[idx].mpc_apicid;
-       mp_ioapic_routing[idx].gsi_start = gsi_base;
+       mp_ioapic_routing[idx].gsi_base = gsi_base;
        mp_ioapic_routing[idx].gsi_end = gsi_base +
            io_apic_get_redir_entries(idx);
 
        printk(KERN_INFO "IOAPIC[%d]: apic_id %d, address 0x%x, "
               "GSI %d-%d\n", idx, mp_ioapics[idx].mpc_apicid,
               mp_ioapics[idx].mpc_apicaddr,
-              mp_ioapic_routing[idx].gsi_start,
+              mp_ioapic_routing[idx].gsi_base,
               mp_ioapic_routing[idx].gsi_end);
 
        nr_ioapics++;
@@ -778,7 +730,7 @@ void __init mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
        ioapic = mp_find_ioapic(gsi);
        if (ioapic < 0)
                return;
-       pin = gsi - mp_ioapic_routing[ioapic].gsi_start;
+       pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
 
        /*
         * TBD: This check is for faulty timer entries, where the override
@@ -890,7 +842,7 @@ int mp_register_gsi(u32 gsi, int triggering, int polarity)
                return gsi;
        }
 
-       ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_start;
+       ioapic_pin = gsi - mp_ioapic_routing[ioapic].gsi_base;
 
        /* 
         * Avoid pin reprogramming.  PRTs typically include entries