Linux 2.6.26
[pandora-kernel.git] / arch / x86 / kernel / setup_32.c
index d1d8c34..5a2f8e0 100644 (file)
@@ -39,6 +39,7 @@
 #include <linux/efi.h>
 #include <linux/init.h>
 #include <linux/edd.h>
+#include <linux/iscsi_ibft.h>
 #include <linux/nodemask.h>
 #include <linux/kexec.h>
 #include <linux/crash_dump.h>
@@ -46,6 +47,7 @@
 #include <linux/pfn.h>
 #include <linux/pci.h>
 #include <linux/init_ohci1394_dma.h>
+#include <linux/kvm_para.h>
 
 #include <video/edid.h>
 
@@ -62,8 +64,9 @@
 #include <asm/io.h>
 #include <asm/vmi.h>
 #include <setup_arch.h>
-#include <bios_ebda.h>
+#include <asm/bios_ebda.h>
 #include <asm/cacheflush.h>
+#include <asm/processor.h>
 
 /* This value is set up by the early boot code to point to the value
    immediately after the boot time page tables.  It contains a *physical*
@@ -124,7 +127,12 @@ static struct resource standard_io_resources[] = { {
 }, {
        .name   = "keyboard",
        .start  = 0x0060,
-       .end    = 0x006f,
+       .end    = 0x0060,
+       .flags  = IORESOURCE_BUSY | IORESOURCE_IO
+}, {
+       .name   = "keyboard",
+       .start  = 0x0064,
+       .end    = 0x0064,
        .flags  = IORESOURCE_BUSY | IORESOURCE_IO
 }, {
        .name   = "dma page reg",
@@ -154,13 +162,18 @@ struct cpuinfo_x86 new_cpu_data __cpuinitdata = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
 struct cpuinfo_x86 boot_cpu_data __read_mostly = { 0, 0, 0, 0, -1, 1, 0, 0, -1 };
 EXPORT_SYMBOL(boot_cpu_data);
 
+unsigned int def_to_bigsmp;
+
+#ifndef CONFIG_X86_PAE
 unsigned long mmu_cr4_features;
+#else
+unsigned long mmu_cr4_features = X86_CR4_PAE;
+#endif
 
 /* for MCA, but anyone else can use it if they want */
 unsigned int machine_id;
 unsigned int machine_submodel_id;
 unsigned int BIOS_revision;
-unsigned int mca_pentium_flag;
 
 /* Boot loader ID as an integer, for the benefit of proc_dointvec */
 int bootloader_type;
@@ -186,7 +199,7 @@ EXPORT_SYMBOL(ist_info);
 extern void early_cpu_init(void);
 extern int root_mountflags;
 
-unsigned long saved_videomode;
+unsigned long saved_video_mode;
 
 #define RAMDISK_IMAGE_START_MASK       0x07FF
 #define RAMDISK_PROMPT_FLAG            0x8000
@@ -224,7 +237,7 @@ static inline void copy_edd(void)
 }
 #endif
 
-int __initdata user_defined_memmap = 0;
+int __initdata user_defined_memmap;
 
 /*
  * "mem=nopentium" disables the 4MB page tables.
@@ -382,19 +395,58 @@ unsigned long __init find_max_low_pfn(void)
        return max_low_pfn;
 }
 
+#define BIOS_LOWMEM_KILOBYTES 0x413
+
 /*
- * workaround for Dell systems that neglect to reserve EBDA
+ * The BIOS places the EBDA/XBDA at the top of conventional
+ * memory, and usually decreases the reported amount of
+ * conventional memory (int 0x12) too. This also contains a
+ * workaround for Dell systems that neglect to reserve EBDA.
+ * The same workaround also avoids a problem with the AMD768MPX
+ * chipset: reserve a page before VGA to prevent PCI prefetch
+ * into it (errata #56). Usually the page is reserved anyways,
+ * unless you have no PS/2 mouse plugged in.
  */
 static void __init reserve_ebda_region(void)
 {
-       unsigned int addr;
-       addr = get_bios_ebda();
-       if (addr)
-               reserve_bootmem(addr, PAGE_SIZE, BOOTMEM_DEFAULT);
+       unsigned int lowmem, ebda_addr;
+
+       /* To determine the position of the EBDA and the */
+       /* end of conventional memory, we need to look at */
+       /* the BIOS data area. In a paravirtual environment */
+       /* that area is absent. We'll just have to assume */
+       /* that the paravirt case can handle memory setup */
+       /* correctly, without our help. */
+       if (paravirt_enabled())
+               return;
+
+       /* end of low (conventional) memory */
+       lowmem = *(unsigned short *)__va(BIOS_LOWMEM_KILOBYTES);
+       lowmem <<= 10;
+
+       /* start of EBDA area */
+       ebda_addr = get_bios_ebda();
+
+       /* Fixup: bios puts an EBDA in the top 64K segment */
+       /* of conventional memory, but does not adjust lowmem. */
+       if ((lowmem - ebda_addr) <= 0x10000)
+               lowmem = ebda_addr;
+
+       /* Fixup: bios does not report an EBDA at all. */
+       /* Some old Dells seem to need 4k anyhow (bugzilla 2990) */
+       if ((ebda_addr == 0) && (lowmem >= 0x9f000))
+               lowmem = 0x9f000;
+
+       /* Paranoia: should never happen, but... */
+       if ((lowmem == 0) || (lowmem >= 0x100000))
+               lowmem = 0x9f000;
+
+       /* reserve all memory between lowmem and the 1MB mark */
+       reserve_bootmem(lowmem, 0x100000 - lowmem, BOOTMEM_DEFAULT);
 }
 
 #ifndef CONFIG_NEED_MULTIPLE_NODES
-void __init setup_bootmem_allocator(void);
+static void __init setup_bootmem_allocator(void);
 static unsigned long __init setup_memory(void)
 {
        /*
@@ -403,8 +455,6 @@ static unsigned long __init setup_memory(void)
         */
        min_low_pfn = PFN_UP(init_pg_tables_end);
 
-       find_max_pfn();
-
        max_low_pfn = find_max_low_pfn();
 
 #ifdef CONFIG_HIGHMEM
@@ -431,7 +481,7 @@ static unsigned long __init setup_memory(void)
        return max_low_pfn;
 }
 
-void __init zone_sizes_init(void)
+static void __init zone_sizes_init(void)
 {
        unsigned long max_zone_pfns[MAX_NR_ZONES];
        memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
@@ -482,10 +532,16 @@ static void __init reserve_crashkernel(void)
                                        (unsigned long)(crash_size >> 20),
                                        (unsigned long)(crash_base >> 20),
                                        (unsigned long)(total_mem >> 20));
+
+                       if (reserve_bootmem(crash_base, crash_size,
+                                       BOOTMEM_EXCLUSIVE) < 0) {
+                               printk(KERN_INFO "crashkernel reservation "
+                                       "failed - memory is in use\n");
+                               return;
+                       }
+
                        crashk_res.start = crash_base;
                        crashk_res.end   = crash_base + crash_size - 1;
-                       reserve_bootmem(crash_base, crash_size,
-                                       BOOTMEM_DEFAULT);
                } else
                        printk(KERN_INFO "crashkernel reservation failed - "
                                        "you have to specify a base address\n");
@@ -616,16 +672,9 @@ void __init setup_bootmem_allocator(void)
         */
        reserve_bootmem(0, PAGE_SIZE, BOOTMEM_DEFAULT);
 
-       /* reserve EBDA region, it's a 4K region */
+       /* reserve EBDA region */
        reserve_ebda_region();
 
-    /* could be an AMD 768MPX chipset. Reserve a page  before VGA to prevent
-       PCI prefetch into it (errata #56). Usually the page is reserved anyways,
-       unless you have no PS/2 mouse plugged in. */
-       if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD &&
-           boot_cpu_data.x86 == 6)
-            reserve_bootmem(0xa0000 - 4096, 4096, BOOTMEM_DEFAULT);
-
 #ifdef CONFIG_SMP
        /*
         * But first pinch a few for the stack/trampoline stuff
@@ -651,6 +700,8 @@ void __init setup_bootmem_allocator(void)
 #endif
        numa_kva_reserve();
        reserve_crashkernel();
+
+       reserve_ibft_region();
 }
 
 /*
@@ -686,6 +737,18 @@ char * __init __attribute__((weak)) memory_setup(void)
        return machine_specific_memory_setup();
 }
 
+#ifdef CONFIG_NUMA
+/*
+ * In the golden day, when everything among i386 and x86_64 will be
+ * integrated, this will not live here
+ */
+void *x86_cpu_to_node_map_early_ptr;
+int x86_cpu_to_node_map_init[NR_CPUS] = {
+       [0 ... NR_CPUS-1] = NUMA_NO_NODE
+};
+DEFINE_PER_CPU(int, x86_cpu_to_node_map) = NUMA_NO_NODE;
+#endif
+
 /*
  * Determine if we were loaded by an EFI loader.  If so, then we have also been
  * passed the efi memmap, systab, etc., so we should use these data structures
@@ -713,7 +776,7 @@ void __init setup_arch(char **cmdline_p)
        edid_info = boot_params.edid_info;
        apm_info.bios = boot_params.apm_bios_info;
        ist_info = boot_params.ist_info;
-       saved_videomode = boot_params.hdr.vid_mode;
+       saved_video_mode = boot_params.hdr.vid_mode;
        if( boot_params.sys_desc_table.length != 0 ) {
                set_mca_bus(boot_params.sys_desc_table.table[3] & 0x2);
                machine_id = boot_params.sys_desc_table.table[0];
@@ -761,12 +824,17 @@ void __init setup_arch(char **cmdline_p)
        if (efi_enabled)
                efi_init();
 
-       max_low_pfn = setup_memory();
-
        /* update e820 for memory not covered by WB MTRRs */
+       propagate_e820_map();
        mtrr_bp_init();
        if (mtrr_trim_uncached_memory(max_pfn))
-               max_low_pfn = setup_memory();
+               propagate_e820_map();
+
+       max_low_pfn = setup_memory();
+
+#ifdef CONFIG_KVM_CLOCK
+       kvmclock_init();
+#endif
 
 #ifdef CONFIG_VMI
        /*
@@ -775,6 +843,7 @@ void __init setup_arch(char **cmdline_p)
         */
        vmi_init();
 #endif
+       kvm_guest_init();
 
        /*
         * NOTE: before this point _nobody_ is allowed to allocate
@@ -818,6 +887,18 @@ void __init setup_arch(char **cmdline_p)
 
        io_delay_init();
 
+#ifdef CONFIG_X86_SMP
+       /*
+        * setup to use the early static init tables during kernel startup
+        * X86_SMP will exclude sub-arches that don't deal well with it.
+        */
+       x86_cpu_to_apicid_early_ptr = (void *)x86_cpu_to_apicid_init;
+       x86_bios_cpu_apicid_early_ptr = (void *)x86_bios_cpu_apicid_init;
+#ifdef CONFIG_NUMA
+       x86_cpu_to_node_map_early_ptr = (void *)x86_cpu_to_node_map_init;
+#endif
+#endif
+
 #ifdef CONFIG_X86_GENERICARCH
        generic_apic_probe();
 #endif