]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - arch/x86/kernel/mpparse_32.c
x86: move mp_ioapic_routing to boot.c
[karo-tx-linux.git] / arch / x86 / kernel / mpparse_32.c
index 838e4974e1ce9c936ee83fad62a3295831081443..b6f1e4e235e314cb8ebc3854ed5795a5f1dcb4a4 100644 (file)
 #include <asm/mtrr.h>
 #include <asm/mpspec.h>
 #include <asm/io_apic.h>
+#include <asm/bios_ebda.h>
 
 #include <mach_apic.h>
 #include <mach_apicdef.h>
 #include <mach_mpparse.h>
-#include <bios_ebda.h>
 
 /* Have we found an MP table */
 int smp_found_config;
-unsigned int __cpuinitdata maxcpus = NR_CPUS;
 
 /*
  * Various Linux-internal data structures created from the
  * MP-table.
  */
-int apic_version [MAX_APICS];
 #if defined (CONFIG_MCA) || defined (CONFIG_EISA)
 int mp_bus_id_to_type [MAX_MP_BUSSES];
 #endif
@@ -49,34 +47,21 @@ DECLARE_BITMAP(mp_bus_not_pci, MAX_MP_BUSSES);
 int mp_bus_id_to_pci_bus [MAX_MP_BUSSES] = { [0 ... MAX_MP_BUSSES-1] = -1 };
 static int mp_current_pci_id;
 
-/* I/O APIC entries */
-struct mpc_config_ioapic mp_ioapics[MAX_IO_APICS];
-
 /* # of MP IRQ source entries */
 struct mpc_config_intsrc mp_irqs[MAX_IRQ_SOURCES];
 
 /* MP IRQ source entries */
 int mp_irq_entries;
 
-int nr_ioapics;
-
 int pic_mode;
-unsigned long mp_lapic_addr;
-
-unsigned int def_to_bigsmp = 0;
 
-/* Processor that is doing the boot up */
-unsigned int boot_cpu_physical_apicid = -1U;
-/* Internal processor count */
+/* Make it easy to share the UP and SMP code: */
+#ifndef CONFIG_X86_SMP
 unsigned int num_processors;
-
 unsigned disabled_cpus __cpuinitdata;
-
-/* Bitmask of physically existing CPUs */
-physid_mask_t phys_cpu_present_map;
-
-#ifndef CONFIG_SMP
-DEFINE_PER_CPU(u16, x86_bios_cpu_apicid) = BAD_APICID;
+#ifndef CONFIG_X86_LOCAL_APIC
+unsigned int boot_cpu_physical_apicid = -1U;
+#endif
 #endif
 
 /*
@@ -98,6 +83,7 @@ static int __init mpf_checksum(unsigned char *mp, int len)
        return sum & 0xFF;
 }
 
+#ifdef CONFIG_X86_NUMAQ
 /*
  * Have to match translation table entries to main table entries by counter
  * hence the mpc_record variable .... can't see a less disgusting way of
@@ -106,19 +92,29 @@ static int __init mpf_checksum(unsigned char *mp, int len)
 
 static int mpc_record; 
 static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] __cpuinitdata;
+#endif
 
-static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
+static void __cpuinit MP_processor_info(struct mpc_config_processor *m)
 {
-       int ver, apicid, cpu;
-       cpumask_t tmp_map;
-       physid_mask_t phys_cpu;
-       
+       int apicid;
+
        if (!(m->mpc_cpuflag & CPU_ENABLED)) {
+#ifdef CONFIG_X86_SMP
                disabled_cpus++;
+#endif
                return;
        }
 
+#ifdef CONFIG_X86_NUMAQ
        apicid = mpc_apic_id(m, translation_table[mpc_record]);
+#else
+       Dprintk("Processor #%d %u:%u APIC version %d\n",
+               m->mpc_apicid,
+               (m->mpc_cpufeature & CPU_FAMILY_MASK) >> 8,
+               (m->mpc_cpufeature & CPU_MODEL_MASK) >> 4,
+               m->mpc_apicver);
+       apicid = m->mpc_apicid;
+#endif
 
        if (m->mpc_featureflag&(1<<0))
                Dprintk("    Floating point unit present.\n");
@@ -173,80 +169,7 @@ static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
                boot_cpu_physical_apicid = m->mpc_apicid;
        }
 
-       ver = m->mpc_apicver;
-
-       /*
-        * Validate version
-        */
-       if (ver == 0x0) {
-               printk(KERN_WARNING "BIOS bug, APIC version is 0 for CPU#%d! "
-                               "fixing up to 0x10. (tell your hw vendor)\n",
-                               m->mpc_apicid);
-               ver = 0x10;
-       }
-       apic_version[m->mpc_apicid] = ver;
-
-       phys_cpu = apicid_to_cpu_present(apicid);
-       physids_or(phys_cpu_present_map, phys_cpu_present_map, phys_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;
-       }
-
-       cpu_set(num_processors, cpu_possible_map);
-       num_processors++;
-       cpus_complement(tmp_map, cpu_present_map);
-       cpu = first_cpu(tmp_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;
-
-       /*
-        * Would be preferable to switch to bigsmp when CONFIG_HOTPLUG_CPU=y
-        * but we need to work other dependencies like SMP_SUSPEND etc
-        * before this can be done without some confusion.
-        * if (CPU_HOTPLUG_ENABLED || num_processors > 8)
-        *       - Ashok Raj <ashok.raj@intel.com>
-        */
-       if (num_processors > 8) {
-               switch (boot_cpu_data.x86_vendor) {
-               case X86_VENDOR_INTEL:
-                       if (!APIC_XAPIC(ver)) {
-                               def_to_bigsmp = 0;
-                               break;
-                       }
-                       /* If P4 and above fall through */
-               case X86_VENDOR_AMD:
-                       def_to_bigsmp = 1;
-               }
-       }
-#ifdef CONFIG_SMP
-       /* 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[num_processors - 1] = m->mpc_apicid;
-       } else {
-               per_cpu(x86_cpu_to_apicid, cpu) = m->mpc_apicid;
-               per_cpu(x86_bios_cpu_apicid, cpu) = m->mpc_apicid;
-       }
-#endif
-       cpu_set(cpu, cpu_present_map);
+       generic_processor_info(apicid, m->mpc_apicver);
 }
 
 static void __init MP_bus_info (struct mpc_config_bus *m)
@@ -256,7 +179,11 @@ static void __init MP_bus_info (struct mpc_config_bus *m)
        memcpy(str, m->mpc_bustype, 6);
        str[6] = 0;
 
+#ifdef CONFIG_X86_NUMAQ
        mpc_oem_bus_info(m, str, translation_table[mpc_record]);
+#else
+       Dprintk("Bus #%d is %s\n", m->mpc_busid, str);
+#endif
 
 #if MAX_MP_BUSSES < 256
        if (m->mpc_busid >= MAX_MP_BUSSES) {
@@ -269,7 +196,9 @@ static void __init MP_bus_info (struct mpc_config_bus *m)
 
        set_bit(m->mpc_busid, mp_bus_not_pci);
        if (strncmp(str, BUSTYPE_PCI, sizeof(BUSTYPE_PCI)-1) == 0) {
+#ifdef CONFIG_X86_NUMAQ
                mpc_oem_pci_bus(m, translation_table[mpc_record]);
+#endif
                clear_bit(m->mpc_busid, mp_bus_not_pci);
                mp_bus_id_to_pci_bus[m->mpc_busid] = mp_current_pci_id;
                mp_current_pci_id++;
@@ -287,6 +216,8 @@ static void __init MP_bus_info (struct mpc_config_bus *m)
        }
 }
 
+#ifdef CONFIG_X86_IO_APIC
+
 static int bad_ioapic(unsigned long address)
 {
        if (nr_ioapics >= MAX_IO_APICS) {
@@ -329,6 +260,8 @@ static void __init MP_intsrc_info (struct mpc_config_intsrc *m)
                panic("Max # of irq sources exceeded!!\n");
 }
 
+#endif
+
 static void __init MP_lintsrc_info (struct mpc_config_lintsrc *m)
 {
        Dprintk("Lint: type %d, pol %d, trig %d, bus %d,"
@@ -460,7 +393,9 @@ static int __init smp_read_mpc(struct mp_config_table *mpc)
        /*
         *      Now process the configuration blocks.
         */
+#ifdef CONFIG_X86_NUMAQ
        mpc_record = 0;
+#endif
        while (count < mpc->mpc_length) {
                switch(*mpt) {
                        case MP_PROCESSOR:
@@ -485,21 +420,25 @@ static int __init smp_read_mpc(struct mp_config_table *mpc)
                        }
                        case MP_IOAPIC:
                        {
+#ifdef CONFIG_X86_IO_APIC
                                struct mpc_config_ioapic *m=
                                        (struct mpc_config_ioapic *)mpt;
                                MP_ioapic_info(m);
-                               mpt+=sizeof(*m);
-                               count+=sizeof(*m);
+#endif
+                               mpt+=sizeof(struct mpc_config_ioapic);
+                               count+=sizeof(struct mpc_config_ioapic);
                                break;
                        }
                        case MP_INTSRC:
                        {
+#ifdef CONFIG_X86_IO_APIC
                                struct mpc_config_intsrc *m=
                                        (struct mpc_config_intsrc *)mpt;
 
                                MP_intsrc_info(m);
-                               mpt+=sizeof(*m);
-                               count+=sizeof(*m);
+#endif
+                               mpt+=sizeof(struct mpc_config_intsrc);
+                               count+=sizeof(struct mpc_config_intsrc);
                                break;
                        }
                        case MP_LINTSRC:
@@ -517,7 +456,9 @@ static int __init smp_read_mpc(struct mp_config_table *mpc)
                                break;
                        }
                }
+#ifdef CONFIG_X86_NUMAQ
                ++mpc_record;
+#endif
        }
        setup_apic_routing();
        if (!num_processors)
@@ -525,6 +466,8 @@ static int __init smp_read_mpc(struct mp_config_table *mpc)
        return num_processors;
 }
 
+#ifdef CONFIG_X86_IO_APIC
+
 static int __init ELCR_trigger(unsigned int irq)
 {
        unsigned int port;
@@ -599,11 +542,15 @@ static void __init construct_default_ioirq_mptable(int mpc_default_type)
        MP_intsrc_info(&intsrc);
 }
 
+#endif
+
 static inline void __init construct_default_ISA_mptable(int mpc_default_type)
 {
        struct mpc_config_processor processor;
        struct mpc_config_bus bus;
+#ifdef CONFIG_X86_IO_APIC
        struct mpc_config_ioapic ioapic;
+#endif
        struct mpc_config_lintsrc lintsrc;
        int linttypes[2] = { mp_ExtINT, mp_NMI };
        int i;
@@ -659,6 +606,7 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type)
                MP_bus_info(&bus);
        }
 
+#ifdef CONFIG_X86_IO_APIC
        ioapic.mpc_type = MP_IOAPIC;
        ioapic.mpc_apicid = 2;
        ioapic.mpc_apicver = mpc_default_type > 4 ? 0x10 : 0x01;
@@ -670,7 +618,7 @@ static inline void __init construct_default_ISA_mptable(int mpc_default_type)
         * We set up most of the low 16 IO-APIC pins according to MPS rules.
         */
        construct_default_ioirq_mptable(mpc_default_type);
-
+#endif
        lintsrc.mpc_type = MP_LINTSRC;
        lintsrc.mpc_irqflag = 0;                /* conforming */
        lintsrc.mpc_srcbusid = 0;
@@ -732,6 +680,8 @@ void __init get_smp_config (void)
                        printk(KERN_ERR "... disabling SMP support. (tell your hw vendor)\n");
                        return;
                }
+
+#ifdef CONFIG_X86_IO_APIC
                /*
                 * If there are no explicit MP IRQ entries, then we are
                 * broken.  We set up most of the low 16 IO-APIC pins to
@@ -749,7 +699,7 @@ void __init get_smp_config (void)
 
                        construct_default_ioirq_mptable(0);
                }
-
+#endif
        } else
                BUG();
 
@@ -846,8 +796,6 @@ void __init find_smp_config (void)
                smp_scan_config(address, 0x400);
 }
 
-int es7000_plat;
-
 /* --------------------------------------------------------------------------
                             ACPI-based MP Configuration
    -------------------------------------------------------------------------- */
@@ -861,37 +809,27 @@ void __init mp_register_lapic_address(u64 address)
        set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
 
        if (boot_cpu_physical_apicid == -1U)
-               boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID));
+               boot_cpu_physical_apicid = GET_APIC_ID(read_apic_id());
 
        Dprintk("Boot CPU = %d\n", boot_cpu_physical_apicid);
 }
 
-void __cpuinit mp_register_lapic (u8 id, u8 enabled)
+void __cpuinit mp_register_lapic (int id, u8 enabled)
 {
-       struct mpc_config_processor processor;
-       int boot_cpu = 0;
-       
        if (MAX_APICS - id <= 0) {
                printk(KERN_WARNING "Processor #%d invalid (max %d)\n",
                        id, MAX_APICS);
                return;
        }
 
-       if (id == boot_cpu_physical_apicid)
-               boot_cpu = 1;
-
-       processor.mpc_type = MP_PROCESSOR;
-       processor.mpc_apicid = id;
-       processor.mpc_apicver = GET_APIC_VERSION(apic_read(APIC_LVR));
-       processor.mpc_cpuflag = (enabled ? CPU_ENABLED : 0);
-       processor.mpc_cpuflag |= (boot_cpu ? CPU_BOOTPROCESSOR : 0);
-       processor.mpc_cpufeature = (boot_cpu_data.x86 << 8) | 
-               (boot_cpu_data.x86_model << 4) | boot_cpu_data.x86_mask;
-       processor.mpc_featureflag = boot_cpu_data.x86_capability[0];
-       processor.mpc_reserved[0] = 0;
-       processor.mpc_reserved[1] = 0;
+       if (!enabled) {
+#ifdef CONFIG_X86_SMP
+               ++disabled_cpus;
+#endif
+               return;
+       }
 
-       MP_processor_info(&processor);
+       generic_processor_info(id, GET_APIC_VERSION(apic_read(APIC_LVR)));
 }
 
 #ifdef CONFIG_X86_IO_APIC
@@ -899,12 +837,7 @@ void __cpuinit mp_register_lapic (u8 id, u8 enabled)
 #define MP_ISA_BUS             0
 #define MP_MAX_IOAPIC_PIN      127
 
-static struct mp_ioapic_routing {
-       int                     apic_id;
-       int                     gsi_base;
-       int                     gsi_end;
-       u32                     pin_programmed[4];
-} mp_ioapic_routing[MAX_IO_APICS];
+extern struct mp_ioapic_routing mp_ioapic_routing[MAX_IO_APICS];
 
 static int mp_find_ioapic (int gsi)
 {
@@ -931,7 +864,7 @@ static u8 uniq_ioapic_id(u8 id)
                return id;
 }
 
-void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
+void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)
 {
        int idx = 0;
 
@@ -1008,6 +941,8 @@ mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
                panic("Max # of irq sources exceeded!\n");
 }
 
+int es7000_plat;
+
 void __init mp_config_acpi_legacy_irqs (void)
 {
        struct mpc_config_intsrc intsrc;
@@ -1039,8 +974,9 @@ void __init mp_config_acpi_legacy_irqs (void)
        intsrc.mpc_type = MP_INTSRC;
        intsrc.mpc_irqflag = 0;                                 /* Conforming */
        intsrc.mpc_srcbus = MP_ISA_BUS;
+#ifdef CONFIG_X86_IO_APIC
        intsrc.mpc_dstapic = mp_ioapics[ioapic].mpc_apicid;
-
+#endif
        /* 
         * Use the default configuration for the IRQs 0-15.  Unless
         * overridden by (MADT) interrupt source override entries.
@@ -1155,8 +1091,7 @@ int mp_register_gsi(u32 gsi, int triggering, int polarity)
                         * So test for this condition, and if necessary, avoid
                         * the pin collision.
                         */
-                       if (gsi > 15 || (gsi == 0 && !timer_uses_ioapic_pin_0))
-                               gsi = pci_irq++;
+                       gsi = pci_irq++;
                        /*
                         * Don't assign IRQ used by ACPI SCI
                         */