x86: introduce initmem_init for 32 bit
authorYinghai Lu <yhlu.kernel@gmail.com>
Sun, 22 Jun 2008 09:45:39 +0000 (02:45 -0700)
committerIngo Molnar <mingo@elte.hu>
Tue, 8 Jul 2008 10:50:15 +0000 (12:50 +0200)
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/setup_32.c
arch/x86/mm/discontig_32.c
arch/x86/mm/init_32.c
include/asm-x86/page_32.h

index d24ac268523f20f1878200fd20b4a5486abf998b..190546bd3bd3718a640025368dc1c20d8afcf742 100644 (file)
@@ -300,71 +300,11 @@ unsigned long __init find_max_low_pfn(void)
        return max_low_pfn;
 }
 
-#ifndef CONFIG_NEED_MULTIPLE_NODES
-static void __init setup_bootmem_allocator(void);
-static unsigned long __init setup_memory(void)
-{
-       /*
-        * partially used pages are not usable - thus
-        * we are rounding upwards:
-        */
-       min_low_pfn = PFN_UP(init_pg_tables_end);
-
-       max_low_pfn = find_max_low_pfn();
-
-#ifdef CONFIG_HIGHMEM
-       highstart_pfn = highend_pfn = max_pfn;
-       if (max_pfn > max_low_pfn) {
-               highstart_pfn = max_low_pfn;
-       }
-       memory_present(0, 0, highend_pfn);
-       printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
-               pages_to_mb(highend_pfn - highstart_pfn));
-       num_physpages = highend_pfn;
-       high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
-#else
-       memory_present(0, 0, max_low_pfn);
-       num_physpages = max_low_pfn;
-       high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
-#endif
-#ifdef CONFIG_FLATMEM
-       max_mapnr = num_physpages;
-#endif
-       printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
-                       pages_to_mb(max_low_pfn));
-
-       setup_bootmem_allocator();
-
-       return max_low_pfn;
-}
-
-static void __init zone_sizes_init(void)
-{
-       unsigned long max_zone_pfns[MAX_NR_ZONES];
-       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
-       max_zone_pfns[ZONE_DMA] =
-               virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
-       max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
-       remove_all_active_ranges();
-#ifdef CONFIG_HIGHMEM
-       max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
-       e820_register_active_regions(0, 0, highend_pfn);
-#else
-       e820_register_active_regions(0, 0, max_low_pfn);
-#endif
-
-       free_area_init_nodes(max_zone_pfns);
-}
-#else
-extern unsigned long __init setup_memory(void);
-extern void zone_sizes_init(void);
-#endif /* !CONFIG_NEED_MULTIPLE_NODES */
-
 #ifdef CONFIG_BLK_DEV_INITRD
 
 static bool do_relocate_initrd = false;
 
-static void __init reserve_initrd(void)
+void __init reserve_initrd(void)
 {
        u64 ramdisk_image = boot_params.hdr.ramdisk_image;
        u64 ramdisk_size  = boot_params.hdr.ramdisk_size;
@@ -480,36 +420,6 @@ static void __init relocate_initrd(void)
 
 #endif /* CONFIG_BLK_DEV_INITRD */
 
-void __init setup_bootmem_allocator(void)
-{
-       int i;
-       unsigned long bootmap_size, bootmap;
-       /*
-        * Initialize the boot-time allocator (with low memory only):
-        */
-       bootmap_size = bootmem_bootmap_pages(max_low_pfn)<<PAGE_SHIFT;
-       bootmap = find_e820_area(min_low_pfn<<PAGE_SHIFT,
-                                max_pfn_mapped<<PAGE_SHIFT, bootmap_size,
-                                PAGE_SIZE);
-       if (bootmap == -1L)
-               panic("Cannot find bootmem map of size %ld\n", bootmap_size);
-       reserve_early(bootmap, bootmap + bootmap_size, "BOOTMAP");
-#ifdef CONFIG_BLK_DEV_INITRD
-       reserve_initrd();
-#endif
-       bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, max_low_pfn);
-       printk(KERN_INFO "  mapped low ram: 0 - %08lx\n",
-                max_pfn_mapped<<PAGE_SHIFT);
-       printk(KERN_INFO "  low ram: %08lx - %08lx\n",
-                min_low_pfn<<PAGE_SHIFT, max_low_pfn<<PAGE_SHIFT);
-       printk(KERN_INFO "  bootmap %08lx - %08lx\n",
-                bootmap, bootmap + bootmap_size);
-       for_each_online_node(i)
-               free_bootmem_with_active_regions(i, max_low_pfn);
-       early_res_to_bootmem(0, max_low_pfn<<PAGE_SHIFT);
-
-}
-
 /*
  * The node 0 pgdat is initialized before all of these because
  * it's needed for bootmem.  node>0 pgdats have their virtual
@@ -666,7 +576,7 @@ void __init setup_arch(char **cmdline_p)
         acpi_numa_init();
 #endif
 
-       max_low_pfn = setup_memory();
+       max_low_pfn = initmem_init(0, max_pfn);
 
 #ifdef CONFIG_ACPI_SLEEP
        /*
index a2f73ba42b8bcbe6bf1eddc18e2052644d2b0882..3e75be46c4f21b7b9d8e1195c7e5982be9b128be 100644 (file)
@@ -309,8 +309,8 @@ static void init_remap_allocator(int nid)
                (ulong) node_remap_end_vaddr[nid]);
 }
 
-extern void setup_bootmem_allocator(void);
-unsigned long __init setup_memory(void)
+unsigned long __init initmem_init(unsigned long start_pfn,
+                                 unsigned long end_pfn)
 {
        int nid;
        unsigned long system_start_pfn, system_max_low_pfn;
index a0484adbf59db23104dc8a1a91b9a54103a53338..9bc8607d79800b9fbce500d0ab019eb7dce674c2 100644 (file)
@@ -540,6 +540,96 @@ static void __init set_nx(void)
 }
 #endif
 
+#ifndef CONFIG_NEED_MULTIPLE_NODES
+extern unsigned long find_max_low_pfn(void);
+unsigned long __init initmem_init(unsigned long start_pfn,
+                                 unsigned long end_pfn)
+{
+       /*
+        * partially used pages are not usable - thus
+        * we are rounding upwards:
+        */
+       min_low_pfn = PFN_UP(init_pg_tables_end);
+
+       max_low_pfn = find_max_low_pfn();
+
+#ifdef CONFIG_HIGHMEM
+       highstart_pfn = highend_pfn = max_pfn;
+       if (max_pfn > max_low_pfn)
+               highstart_pfn = max_low_pfn;
+       memory_present(0, 0, highend_pfn);
+       printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
+               pages_to_mb(highend_pfn - highstart_pfn));
+       num_physpages = highend_pfn;
+       high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
+#else
+       memory_present(0, 0, max_low_pfn);
+       num_physpages = max_low_pfn;
+       high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
+#endif
+#ifdef CONFIG_FLATMEM
+       max_mapnr = num_physpages;
+#endif
+       printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
+                       pages_to_mb(max_low_pfn));
+
+       setup_bootmem_allocator();
+
+       return max_low_pfn;
+}
+
+void __init zone_sizes_init(void)
+{
+       unsigned long max_zone_pfns[MAX_NR_ZONES];
+       memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
+       max_zone_pfns[ZONE_DMA] =
+               virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
+       max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
+       remove_all_active_ranges();
+#ifdef CONFIG_HIGHMEM
+       max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
+       e820_register_active_regions(0, 0, highend_pfn);
+#else
+       e820_register_active_regions(0, 0, max_low_pfn);
+#endif
+
+       free_area_init_nodes(max_zone_pfns);
+}
+#endif /* !CONFIG_NEED_MULTIPLE_NODES */
+
+extern void reserve_initrd(void);
+
+void __init setup_bootmem_allocator(void)
+{
+       int i;
+       unsigned long bootmap_size, bootmap;
+       /*
+        * Initialize the boot-time allocator (with low memory only):
+        */
+       bootmap_size = bootmem_bootmap_pages(max_low_pfn)<<PAGE_SHIFT;
+       bootmap = find_e820_area(min_low_pfn<<PAGE_SHIFT,
+                                max_pfn_mapped<<PAGE_SHIFT, bootmap_size,
+                                PAGE_SIZE);
+       if (bootmap == -1L)
+               panic("Cannot find bootmem map of size %ld\n", bootmap_size);
+       reserve_early(bootmap, bootmap + bootmap_size, "BOOTMAP");
+#ifdef CONFIG_BLK_DEV_INITRD
+       reserve_initrd();
+#endif
+       bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, max_low_pfn);
+       printk(KERN_INFO "  mapped low ram: 0 - %08lx\n",
+                max_pfn_mapped<<PAGE_SHIFT);
+       printk(KERN_INFO "  low ram: %08lx - %08lx\n",
+                min_low_pfn<<PAGE_SHIFT, max_low_pfn<<PAGE_SHIFT);
+       printk(KERN_INFO "  bootmap %08lx - %08lx\n",
+                bootmap, bootmap + bootmap_size);
+       for_each_online_node(i)
+               free_bootmem_with_active_regions(i, max_low_pfn);
+       early_res_to_bootmem(0, max_low_pfn<<PAGE_SHIFT);
+
+}
+
+
 /*
  * paging_init() sets up the page tables - note that the first 8MB are
  * already mapped by head.S.
index 73ed2e4ebf95189b3d89afe2137bb879b34eab39..a0713d175f45b6c7b09e23d971c380c69d006f8f 100644 (file)
@@ -92,6 +92,11 @@ extern int sysctl_legacy_va_layout;
 #define VMALLOC_RESERVE                ((unsigned long)__VMALLOC_RESERVE)
 #define MAXMEM                 (-__PAGE_OFFSET - __VMALLOC_RESERVE)
 
+extern unsigned long initmem_init(unsigned long, unsigned long);
+extern void zone_sizes_init(void);
+extern void setup_bootmem_allocator(void);
+
+
 #ifdef CONFIG_X86_USE_3DNOW
 #include <asm/mmx.h>