x86 module: merge the rest functions with macros
[safe/jmp/linux-2.6] / arch / x86 / kernel / efi.c
index d5c7fcd..1736acc 100644 (file)
@@ -64,6 +64,17 @@ static int __init setup_noefi(char *arg)
 }
 early_param("noefi", setup_noefi);
 
+int add_efi_memmap;
+EXPORT_SYMBOL(add_efi_memmap);
+
+static int __init setup_add_efi_memmap(char *arg)
+{
+       add_efi_memmap = 1;
+       return 0;
+}
+early_param("add_efi_memmap", setup_add_efi_memmap);
+
+
 static efi_status_t virt_efi_get_time(efi_time_t *tm, efi_time_cap_t *tc)
 {
        return efi_call_virt2(get_time, tm, tc);
@@ -219,7 +230,7 @@ unsigned long efi_get_time(void)
  * (zeropage) memory map.
  */
 
-static void __init add_efi_memmap(void)
+static void __init do_add_efi_memmap(void)
 {
        void *p;
 
@@ -233,7 +244,7 @@ static void __init add_efi_memmap(void)
                        e820_type = E820_RAM;
                else
                        e820_type = E820_RESERVED;
-               add_memory_region(start, size, e820_type);
+               e820_add_region(start, size, e820_type);
        }
        sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
 }
@@ -242,9 +253,11 @@ void __init efi_reserve_early(void)
 {
        unsigned long pmap;
 
+#ifdef CONFIG_X86_32
        pmap = boot_params.efi_info.efi_memmap;
-#ifdef CONFIG_X86_64
-       pmap += (__u64)boot_params.efi_info.efi_memmap_hi << 32;
+#else
+       pmap = (boot_params.efi_info.efi_memmap |
+               ((__u64)boot_params.efi_info.efi_memmap_hi<<32));
 #endif
        memmap.phys_map = (void *)pmap;
        memmap.nr_map = boot_params.efi_info.efi_memmap_size /
@@ -284,10 +297,12 @@ void __init efi_init(void)
        int i = 0;
        void *tmp;
 
+#ifdef CONFIG_X86_32
        efi_phys.systab = (efi_system_table_t *)boot_params.efi_info.efi_systab;
-#ifdef CONFIG_X86_64
-       efi_phys.systab = (void *)efi_phys.systab +
-               ((__u64)boot_params.efi_info.efi_systab_hi<<32);
+#else
+       efi_phys.systab = (efi_system_table_t *)
+               (boot_params.efi_info.efi_systab |
+                ((__u64)boot_params.efi_info.efi_systab_hi<<32));
 #endif
 
        efi.systab = early_ioremap((unsigned long)efi_phys.systab,
@@ -351,6 +366,12 @@ void __init efi_init(void)
                                        SMBIOS_TABLE_GUID)) {
                        efi.smbios = config_tables[i].table;
                        printk(" SMBIOS=0x%lx ", config_tables[i].table);
+#ifdef CONFIG_X86_UV
+               } else if (!efi_guidcmp(config_tables[i].guid,
+                                       UV_SYSTEM_TABLE_GUID)) {
+                       efi.uv_systab = config_tables[i].table;
+                       printk(" UVsystab=0x%lx ", config_tables[i].table);
+#endif
                } else if (!efi_guidcmp(config_tables[i].guid,
                                        HCDP_TABLE_GUID)) {
                        efi.hcdp = config_tables[i].table;
@@ -399,10 +420,13 @@ void __init efi_init(void)
        if (memmap.map == NULL)
                printk(KERN_ERR "Could not map the EFI memory map!\n");
        memmap.map_end = memmap.map + (memmap.nr_map * memmap.desc_size);
+
        if (memmap.desc_size != sizeof(efi_memory_desc_t))
-               printk(KERN_WARNING "Kernel-defined memdesc"
-                      "doesn't match the one from EFI!\n");
-       add_efi_memmap();
+               printk(KERN_WARNING
+                 "Kernel-defined memdesc doesn't match the one from EFI!\n");
+
+       if (add_efi_memmap)
+               do_add_efi_memmap();
 
        /* Setup for EFI runtime service */
        reboot_type = BOOT_EFI;
@@ -445,7 +469,7 @@ void __init efi_enter_virtual_mode(void)
        efi_memory_desc_t *md;
        efi_status_t status;
        unsigned long size;
-       u64 end, systab, addr, npages;
+       u64 end, systab, addr, npages, end_pfn;
        void *p, *va;
 
        efi.systab = NULL;
@@ -457,7 +481,10 @@ void __init efi_enter_virtual_mode(void)
                size = md->num_pages << EFI_PAGE_SHIFT;
                end = md->phys_addr + size;
 
-               if (PFN_UP(end) <= max_pfn_mapped)
+               end_pfn = PFN_UP(end);
+               if (end_pfn <= max_low_pfn_mapped
+                   || (end_pfn > (1UL << (32 - PAGE_SHIFT))
+                       && end_pfn <= max_pfn_mapped))
                        va = __va(md->phys_addr);
                else
                        va = efi_ioremap(md->phys_addr, size);