fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / arch / i386 / kernel / mpparse.c
index 6eb88e8..4fd260f 100644 (file)
 #include <asm/io_apic.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 __initdata maxcpus = NR_CPUS;
+unsigned int __cpuinitdata maxcpus = NR_CPUS;
 
 /*
  * Various Linux-internal data structures created from the
@@ -68,7 +69,7 @@ unsigned int def_to_bigsmp = 0;
 /* Processor that is doing the boot up */
 unsigned int boot_cpu_physical_apicid = -1U;
 /* Internal processor count */
-static unsigned int __devinitdata num_processors;
+unsigned int __cpuinitdata num_processors;
 
 /* Bitmask of physically existing CPUs */
 physid_mask_t phys_cpu_present_map;
@@ -101,10 +102,11 @@ static int __init mpf_checksum(unsigned char *mp, int len)
  */
 
 static int mpc_record; 
-static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] __initdata;
+static struct mpc_config_translation *translation_table[MAX_MPC_ENTRY] __cpuinitdata;
 
-static void __devinit MP_processor_info (struct mpc_config_processor *m)
+static void __cpuinit MP_processor_info (struct mpc_config_processor *m)
 {
+#ifndef CONFIG_XEN
        int ver, apicid;
        physid_mask_t phys_cpu;
        
@@ -195,8 +197,9 @@ static void __devinit MP_processor_info (struct mpc_config_processor *m)
        }
 
        cpu_set(num_processors, cpu_possible_map);
+#endif /* CONFIG_XEN */
        num_processors++;
-
+#ifndef CONFIG_XEN
        /*
         * Would be preferable to switch to bigsmp when CONFIG_HOTPLUG_CPU=y
         * but we need to work other dependencies like SMP_SUSPEND etc
@@ -217,6 +220,7 @@ static void __devinit MP_processor_info (struct mpc_config_processor *m)
                }
        }
        bios_cpu_apicid[num_processors - 1] = m->mpc_apicid;
+#endif /* CONFIG_XEN */
 }
 
 static void __init MP_bus_info (struct mpc_config_bus *m)
@@ -228,12 +232,14 @@ static void __init MP_bus_info (struct mpc_config_bus *m)
 
        mpc_oem_bus_info(m, str, translation_table[mpc_record]);
 
+#if MAX_MP_BUSSES < 256
        if (m->mpc_busid >= MAX_MP_BUSSES) {
                printk(KERN_WARNING "MP table busid value (%d) for bustype %s "
                        " is too large, max. supported is %d\n",
                        m->mpc_busid, str, MAX_MP_BUSSES - 1);
                return;
        }
+#endif
 
        if (strncmp(str, BUSTYPE_ISA, sizeof(BUSTYPE_ISA)-1) == 0) {
                mp_bus_id_to_type[m->mpc_busid] = MP_BUS_ISA;
@@ -246,8 +252,6 @@ static void __init MP_bus_info (struct mpc_config_bus *m)
                mp_current_pci_id++;
        } else if (strncmp(str, BUSTYPE_MCA, sizeof(BUSTYPE_MCA)-1) == 0) {
                mp_bus_id_to_type[m->mpc_busid] = MP_BUS_MCA;
-       } else if (strncmp(str, BUSTYPE_NEC98, sizeof(BUSTYPE_NEC98)-1) == 0) {
-               mp_bus_id_to_type[m->mpc_busid] = MP_BUS_NEC98;
        } else {
                printk(KERN_WARNING "Unknown bustype %s - ignoring\n", str);
        }
@@ -293,19 +297,6 @@ static void __init MP_lintsrc_info (struct mpc_config_lintsrc *m)
                        m->mpc_irqtype, m->mpc_irqflag & 3,
                        (m->mpc_irqflag >> 2) &3, m->mpc_srcbusid,
                        m->mpc_srcbusirq, m->mpc_destapic, m->mpc_destapiclint);
-       /*
-        * Well it seems all SMP boards in existence
-        * use ExtINT/LVT1 == LINT0 and
-        * NMI/LVT2 == LINT1 - the following check
-        * will show us if this assumptions is false.
-        * Until then we do not have to add baggage.
-        */
-       if ((m->mpc_irqtype == mp_ExtINT) &&
-               (m->mpc_destapiclint != 0))
-                       BUG();
-       if ((m->mpc_irqtype == mp_NMI) &&
-               (m->mpc_destapiclint != 1))
-                       BUG();
 }
 
 #ifdef CONFIG_X86_NUMAQ
@@ -673,11 +664,6 @@ void __init get_smp_config (void)
        else if (acpi_lapic)
                printk(KERN_INFO "Using ACPI for processor (LAPIC) configuration information\n");
 
-       else if (enable_local_apic < 0) {
-               smp_found_config = 0;
-               return;
-       }
-
        printk(KERN_INFO "Intel MultiProcessor Specification v1.%d\n", mpf->mpf_specification);
        if (mpf->mpf_feature2 & (1<<7)) {
                printk(KERN_INFO "    IMCR and PIC compatibility mode.\n");
@@ -701,7 +687,11 @@ void __init get_smp_config (void)
                 * Read the physical hardware table.  Anything here will
                 * override the defaults.
                 */
+#ifdef CONFIG_XEN
+               if (!smp_read_mpc(isa_bus_to_virt(mpf->mpf_physptr))) {
+#else
                if (!smp_read_mpc(phys_to_virt(mpf->mpf_physptr))) {
+#endif
                        smp_found_config = 0;
                        printk(KERN_ERR "BIOS bug, MP table errors detected!...\n");
                        printk(KERN_ERR "... disabling SMP support. (tell your hw vendor)\n");
@@ -736,7 +726,11 @@ void __init get_smp_config (void)
 
 static int __init smp_scan_config (unsigned long base, unsigned long length)
 {
+#ifdef CONFIG_XEN
+       unsigned long *bp = isa_bus_to_virt(base);
+#else
        unsigned long *bp = phys_to_virt(base);
+#endif
        struct intel_mp_floating *mpf;
 
        Dprintk("Scan SMP from %p for %ld bytes.\n", bp,length);
@@ -752,6 +746,7 @@ static int __init smp_scan_config (unsigned long base, unsigned long length)
                                || (mpf->mpf_specification == 4)) ) {
 
                        smp_found_config = 1;
+#ifndef CONFIG_XEN
                        printk(KERN_INFO "found SMP MP-table at %08lx\n",
                                                virt_to_phys(mpf));
                        reserve_bootmem(virt_to_phys(mpf), PAGE_SIZE);
@@ -771,6 +766,10 @@ static int __init smp_scan_config (unsigned long base, unsigned long length)
                                        size = end - mpf->mpf_physptr;
                                reserve_bootmem(mpf->mpf_physptr, size);
                        }
+#else
+                       printk(KERN_INFO "found SMP MP-table at %08lx\n",
+                               ((unsigned long)bp - (unsigned long)isa_bus_to_virt(base)) + base);
+#endif
 
                        mpf_found = mpf;
                        return 1;
@@ -783,7 +782,9 @@ static int __init smp_scan_config (unsigned long base, unsigned long length)
 
 void __init find_smp_config (void)
 {
+#ifndef CONFIG_XEN
        unsigned int address;
+#endif
 
        /*
         * FIXME: Linux assumes you have 640K of base ram..
@@ -814,9 +815,11 @@ void __init find_smp_config (void)
         * MP1.4 SPEC states to only scan first 1K of 4K EBDA.
         */
 
+#ifndef CONFIG_XEN
        address = get_bios_ebda();
        if (address)
                smp_scan_config(address, 0x400);
+#endif
 }
 
 int es7000_plat;
@@ -827,9 +830,9 @@ int es7000_plat;
 
 #ifdef CONFIG_ACPI
 
-void __init mp_register_lapic_address (
-       u64                     address)
+void __init mp_register_lapic_address(u64 address)
 {
+#ifndef CONFIG_XEN
        mp_lapic_addr = (unsigned long) address;
 
        set_fixmap_nocache(FIX_APIC_BASE, mp_lapic_addr);
@@ -838,15 +841,13 @@ void __init mp_register_lapic_address (
                boot_cpu_physical_apicid = GET_APIC_ID(apic_read(APIC_ID));
 
        Dprintk("Boot CPU = %d\n", boot_cpu_physical_apicid);
+#endif
 }
 
-
-void __devinit mp_register_lapic (
-       u8                      id, 
-       u8                      enabled)
+void __cpuinit mp_register_lapic (u8 id, u8 enabled)
 {
        struct mpc_config_processor processor;
-       int                     boot_cpu = 0;
+       int boot_cpu = 0;
        
        if (MAX_APICS - id <= 0) {
                printk(KERN_WARNING "Processor #%d invalid (max %d)\n",
@@ -857,6 +858,7 @@ void __devinit mp_register_lapic (
        if (id == boot_cpu_physical_apicid)
                boot_cpu = 1;
 
+#ifndef CONFIG_XEN
        processor.mpc_type = MP_PROCESSOR;
        processor.mpc_apicid = id;
        processor.mpc_apicver = GET_APIC_VERSION(apic_read(APIC_LVR));
@@ -867,6 +869,7 @@ void __devinit mp_register_lapic (
        processor.mpc_featureflag = boot_cpu_data.x86_capability[0];
        processor.mpc_reserved[0] = 0;
        processor.mpc_reserved[1] = 0;
+#endif
 
        MP_processor_info(&processor);
 }
@@ -883,11 +886,9 @@ static struct mp_ioapic_routing {
        u32                     pin_programmed[4];
 } mp_ioapic_routing[MAX_IO_APICS];
 
-
-static int mp_find_ioapic (
-       int                     gsi)
+static int mp_find_ioapic (int gsi)
 {
-       int                     i = 0;
+       int i = 0;
 
        /* Find the IOAPIC that manages this GSI. */
        for (i = 0; i < nr_ioapics; i++) {
@@ -900,15 +901,11 @@ static int mp_find_ioapic (
 
        return -1;
 }
-       
 
-void __init mp_register_ioapic (
-       u8                      id, 
-       u32                     address,
-       u32                     gsi_base)
+void __init mp_register_ioapic(u8 id, u32 address, u32 gsi_base)
 {
-       int                     idx = 0;
-       int                     tmpid;
+       int idx = 0;
+       int tmpid;
 
        if (nr_ioapics >= MAX_IO_APICS) {
                printk(KERN_ERR "ERROR: Max # of I/O APICs (%d) exceeded "
@@ -927,7 +924,9 @@ void __init mp_register_ioapic (
        mp_ioapics[idx].mpc_flags = MPC_APIC_USABLE;
        mp_ioapics[idx].mpc_apicaddr = address;
 
+#ifndef CONFIG_XEN
        set_fixmap_nocache(FIX_IO_APIC_BASE_0 + idx, address);
+#endif
        if ((boot_cpu_data.x86_vendor == X86_VENDOR_INTEL)
                && !APIC_XAPIC(apic_version[boot_cpu_physical_apicid]))
                tmpid = io_apic_get_unique_id(idx, id);
@@ -954,16 +953,10 @@ void __init mp_register_ioapic (
                mp_ioapics[idx].mpc_apicver, mp_ioapics[idx].mpc_apicaddr,
                mp_ioapic_routing[idx].gsi_base,
                mp_ioapic_routing[idx].gsi_end);
-
-       return;
 }
 
-
-void __init mp_override_legacy_irq (
-       u8                      bus_irq,
-       u8                      polarity, 
-       u8                      trigger, 
-       u32                     gsi)
+void __init
+mp_override_legacy_irq(u8 bus_irq, u8 polarity, u8 trigger, u32 gsi)
 {
        struct mpc_config_intsrc intsrc;
        int                     ioapic = -1;
@@ -1001,15 +994,13 @@ void __init mp_override_legacy_irq (
        mp_irqs[mp_irq_entries] = intsrc;
        if (++mp_irq_entries == MAX_IRQ_SOURCES)
                panic("Max # of irq sources exceeded!\n");
-
-       return;
 }
 
 void __init mp_config_acpi_legacy_irqs (void)
 {
        struct mpc_config_intsrc intsrc;
-       int                     i = 0;
-       int                     ioapic = -1;
+       int i = 0;
+       int ioapic = -1;
 
        /* 
         * Fabricate the legacy ISA bus (bus #31).
@@ -1078,12 +1069,12 @@ void __init mp_config_acpi_legacy_irqs (void)
 
 #define MAX_GSI_NUM    4096
 
-int mp_register_gsi (u32 gsi, int triggering, int polarity)
+int mp_register_gsi(u32 gsi, int triggering, int polarity)
 {
-       int                     ioapic = -1;
-       int                     ioapic_pin = 0;
-       int                     idx, bit = 0;
-       static int              pci_irq = 16;
+       int ioapic = -1;
+       int ioapic_pin = 0;
+       int idx, bit = 0;
+       static int pci_irq = 16;
        /*
         * Mapping between Global System Interrups, which
         * represent all possible interrupts, and IRQs