vserver 1.9.3
[linux-2.6.git] / arch / x86_64 / kernel / setup.c
index 14a2572..108cf17 100644 (file)
@@ -55,6 +55,7 @@
 #include <asm/bootsetup.h>
 #include <asm/smp.h>
 #include <asm/proto.h>
+#include <asm/setup.h>
 
 /*
  * Machine setup..
@@ -70,7 +71,7 @@ EXPORT_SYMBOL(acpi_disabled);
 #ifdef CONFIG_ACPI_BOOT
 extern int __initdata acpi_ht;
 extern acpi_interrupt_flags    acpi_sci_flags;
-/* int __initdata acpi_force = 0; */
+int __initdata acpi_force = 0;
 #endif
 
 /* For PCI or other memory-mapped resources */
@@ -78,8 +79,10 @@ unsigned long pci_mem_start = 0x10000000;
 
 unsigned long saved_video_mode;
 
+#ifdef CONFIG_SWIOTLB
 int swiotlb;
 EXPORT_SYMBOL(swiotlb);
+#endif
 
 /*
  * Setup options
@@ -100,12 +103,12 @@ extern int root_mountflags;
 extern char _text, _etext, _edata, _end;
 
 char command_line[COMMAND_LINE_SIZE];
-char saved_command_line[COMMAND_LINE_SIZE];
 
 struct resource standard_io_resources[] = {
        { "dma1", 0x00, 0x1f, IORESOURCE_BUSY | IORESOURCE_IO },
        { "pic1", 0x20, 0x21, IORESOURCE_BUSY | IORESOURCE_IO },
-       { "timer", 0x40, 0x5f, IORESOURCE_BUSY | IORESOURCE_IO },
+       { "timer0", 0x40, 0x43, IORESOURCE_BUSY | IORESOURCE_IO },
+       { "timer1", 0x50, 0x53, IORESOURCE_BUSY | IORESOURCE_IO },
        { "keyboard", 0x60, 0x6f, IORESOURCE_BUSY | IORESOURCE_IO },
        { "dma page reg", 0x80, 0x8f, IORESOURCE_BUSY | IORESOURCE_IO },
        { "pic2", 0xa0, 0xa1, IORESOURCE_BUSY | IORESOURCE_IO },
@@ -116,9 +119,10 @@ struct resource standard_io_resources[] = {
 #define STANDARD_IO_RESOURCES \
        (sizeof standard_io_resources / sizeof standard_io_resources[0])
 
-struct resource code_resource = { "Kernel code", 0x100000, 0, IORESOURCE_MEM };
-struct resource data_resource = { "Kernel data", 0, 0, IORESOURCE_MEM };
-struct resource vram_resource = { "Video RAM area", 0xa0000, 0xbffff, IORESOURCE_BUSY | IORESOURCE_MEM };
+#define IORESOURCE_RAM (IORESOURCE_BUSY | IORESOURCE_MEM)
+
+struct resource data_resource = { "Kernel data", 0, 0, IORESOURCE_RAM };
+struct resource code_resource = { "Kernel code", 0, 0, IORESOURCE_RAM };
 
 #define IORESOURCE_ROM (IORESOURCE_BUSY | IORESOURCE_READONLY | IORESOURCE_MEM)
 
@@ -138,10 +142,11 @@ static struct resource adapter_rom_resources[] = {
        (sizeof adapter_rom_resources / sizeof adapter_rom_resources[0])
 
 static struct resource video_rom_resource = { "Video ROM", 0xc0000, 0xc7fff, IORESOURCE_ROM };
+static struct resource video_ram_resource = { "Video RAM area", 0xa0000, 0xbffff, IORESOURCE_RAM };
 
 #define romsignature(x) (*(unsigned short *)(x) == 0xaa55)
 
-static int __init checksum(unsigned char *rom, unsigned long length)
+static int __init romchecksum(unsigned char *rom, unsigned long length)
 {
        unsigned char *p, sum = 0;
 
@@ -169,7 +174,7 @@ static void __init probe_roms(void)
                length = rom[2] * 512;
 
                /* if checksum okay, trust length byte */
-               if (length && checksum(rom, length))
+               if (length && romchecksum(rom, length))
                        video_rom_resource.end = start + length - 1;
 
                request_resource(&iomem_resource, &video_rom_resource);
@@ -188,7 +193,7 @@ static void __init probe_roms(void)
        rom = isa_bus_to_virt(extension_rom_resource.start);
        if (romsignature(rom)) {
                length = extension_rom_resource.end - extension_rom_resource.start + 1;
-               if (checksum(rom, length)) {
+               if (romchecksum(rom, length)) {
                        request_resource(&iomem_resource, &extension_rom_resource);
                        upper = extension_rom_resource.start;
                }
@@ -204,7 +209,7 @@ static void __init probe_roms(void)
                length = rom[2] * 512;
 
                /* but accept any length that fits if checksum okay */
-               if (!length || start + length > upper || !checksum(rom, length))
+               if (!length || start + length > upper || !romchecksum(rom, length))
                        continue;
 
                adapter_rom_resources[i].start = start;
@@ -246,14 +251,14 @@ static __init void parse_cmdline_early (char ** cmdline_p)
 
                if (!memcmp(from, "acpi=force", 10)) { 
                        /* add later when we do DMI horrors: */
-                       /* acpi_force = 1; */   
+                       acpi_force = 1;
                        acpi_disabled = 0;
                }
 
                /* acpi=ht just means: do ACPI MADT parsing 
                   at bootup, but don't enable the full ACPI interpreter */
                if (!memcmp(from, "acpi=ht", 7)) { 
-                       /* if (!acpi_force) */
+                       if (!acpi_force)
                                disable_acpi();
                        acpi_ht = 1; 
                }
@@ -399,29 +404,42 @@ static int __init noreplacement_setup(char *s)
 __setup("noreplacement", noreplacement_setup); 
 
 #if defined(CONFIG_EDD) || defined(CONFIG_EDD_MODULE)
-unsigned char eddnr;
-struct edd_info edd[EDDMAXNR];
-unsigned int edd_disk80_sig;
+struct edd edd;
 #ifdef CONFIG_EDD_MODULE
-EXPORT_SYMBOL(eddnr);
 EXPORT_SYMBOL(edd);
-EXPORT_SYMBOL(edd_disk80_sig);
 #endif
 /**
  * copy_edd() - Copy the BIOS EDD information
- *              from empty_zero_page into a safe place.
+ *              from boot_params into a safe place.
  *
  */
 static inline void copy_edd(void)
 {
-     eddnr = EDD_NR;
-     memcpy(edd, EDD_BUF, sizeof(edd));
-     edd_disk80_sig = DISK80_SIGNATURE;
+     memcpy(edd.mbr_signature, EDD_MBR_SIGNATURE, sizeof(edd.mbr_signature));
+     memcpy(edd.edd_info, EDD_BUF, sizeof(edd.edd_info));
+     edd.mbr_signature_nr = EDD_MBR_SIG_NR;
+     edd.edd_info_nr = EDD_NR;
 }
 #else
-#define copy_edd() do {} while (0)
+static inline void copy_edd(void)
+{
+}
 #endif
 
+#define EBDA_ADDR_POINTER 0x40E
+static void __init reserve_ebda_region(void)
+{
+       unsigned int addr;
+       /** 
+        * there is a real-mode segmented pointer pointing to the 
+        * 4K EBDA area at 0x40E
+        */
+       addr = *(unsigned short *)phys_to_virt(EBDA_ADDR_POINTER);
+       addr <<= 4;
+       if (addr)
+               reserve_bootmem_generic(addr, PAGE_SIZE);
+}
+
 void __init setup_arch(char **cmdline_p)
 {
        unsigned long low_mem_size;
@@ -486,6 +504,9 @@ void __init setup_arch(char **cmdline_p)
         */
        reserve_bootmem_generic(0, PAGE_SIZE);
 
+       /* reserve ebda region */
+       reserve_ebda_region();
+
 #ifdef CONFIG_SMP
        /*
         * But first pinch a few for the stack/trampoline stuff
@@ -555,13 +576,13 @@ void __init setup_arch(char **cmdline_p)
        probe_roms();
        e820_reserve_resources(); 
 
-       request_resource(&iomem_resource, &vram_resource);
+       request_resource(&iomem_resource, &video_ram_resource);
 
        {
        unsigned i;
        /* request I/O space for devices used on all i[345]86 PCs */
        for (i = 0; i < STANDARD_IO_RESOURCES; i++)
-               request_resource(&ioport_resource, standard_io_resources+i);
+               request_resource(&ioport_resource, &standard_io_resources[i]);
        }
 
        /* Will likely break when you have unassigned resources with more
@@ -661,6 +682,26 @@ static int __init init_amd(struct cpuinfo_x86 *c)
                } 
        } 
        display_cacheinfo(c);
+
+       if (c->cpuid_level >= 0x80000008) {
+               c->x86_num_cores = (cpuid_ecx(0x80000008) & 0xff) + 1;
+               if (c->x86_num_cores & (c->x86_num_cores - 1))
+                       c->x86_num_cores = 1;
+
+#ifdef CONFIG_NUMA
+               /* On a dual core setup the lower bits of apic id
+                  distingush the cores. Fix up the CPU<->node mappings
+                  here based on that.
+                  Assumes number of cores is a power of two. */
+               if (c->x86_num_cores > 1) {
+                       int cpu = c->x86_apicid;
+                       cpu_to_node[cpu] = cpu >> hweight32(c->x86_num_cores - 1);
+                       printk(KERN_INFO "CPU %d -> Node %d\n",
+                              cpu, cpu_to_node[cpu]);
+               }
+#endif
+       }
+
        return r;
 }
 
@@ -704,7 +745,7 @@ static void __init detect_ht(struct cpuinfo_x86 *c)
                }
                if (index_lsb != index_msb )
                        index_msb++;
-               initial_apic_id = ebx >> 24 & 0xff;
+               initial_apic_id = hard_smp_processor_id();
                phys_proc_id[cpu] = initial_apic_id >> index_msb;
                
                printk(KERN_INFO  "CPU: Physical Processor ID: %d\n",
@@ -747,6 +788,7 @@ static struct _cache_table cache_table[] __initdata =
        { 0x43, LVL_2,      512 },
        { 0x44, LVL_2,      1024 },
        { 0x45, LVL_2,      2048 },
+       { 0x60, LVL_1_DATA, 16 },
        { 0x66, LVL_1_DATA, 8 },
        { 0x67, LVL_1_DATA, 16 },
        { 0x68, LVL_1_DATA, 32 },
@@ -884,6 +926,8 @@ void __init early_identify_cpu(struct cpuinfo_x86 *c)
        c->x86_model_id[0] = '\0';  /* Unset */
        c->x86_clflush_size = 64;
        c->x86_cache_alignment = c->x86_clflush_size;
+       c->x86_num_cores = 1;
+       c->x86_apicid = c == &boot_cpu_data ? 0 : c - cpu_data;
        memset(&c->x86_capability, 0, sizeof c->x86_capability);
 
        /* Get vendor name */
@@ -911,6 +955,7 @@ void __init early_identify_cpu(struct cpuinfo_x86 *c)
                } 
                if (c->x86_capability[0] & (1<<19)) 
                        c->x86_clflush_size = ((misc >> 8) & 0xff) * 8;
+               c->x86_apicid = misc >> 24;
        } else {
                /* Have CPUID level 0 only - unheard of */
                c->x86 = 4;
@@ -930,8 +975,10 @@ void __init identify_cpu(struct cpuinfo_x86 *c)
        /* AMD-defined flags: level 0x80000001 */
        xlvl = cpuid_eax(0x80000000);
        if ( (xlvl & 0xffff0000) == 0x80000000 ) {
-               if ( xlvl >= 0x80000001 )
+               if ( xlvl >= 0x80000001 ) {
                        c->x86_capability[1] = cpuid_edx(0x80000001);
+                       c->x86_capability[5] = cpuid_ecx(0x80000001);
+               }
                if ( xlvl >= 0x80000004 )
                        get_model_name(c); /* Default name */
        }
@@ -1041,8 +1088,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
 
                /* Intel-defined (#2) */
-               "pni", NULL, NULL, "monitor", "ds_cpl", NULL, NULL, "tm2",
-               "est", NULL, "cid", NULL, NULL, "cmpxchg16b", NULL, NULL,
+               "pni", NULL, NULL, "monitor", "ds_cpl", NULL, NULL, "est",
+               "tm2", NULL, "cid", NULL, NULL, "cx16", "xtpr", NULL,
                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
                NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
        };
@@ -1131,6 +1178,9 @@ static int show_cpuinfo(struct seq_file *m, void *v)
                        }
        }
 
+       if (c->x86_num_cores > 1)
+               seq_printf(m, "cpu cores\t: %d\n", c->x86_num_cores);
+
        seq_printf(m, "\n\n"); 
 
        return 0;