aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/mm/init_32.c
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2008-06-22 05:45:39 -0400
committerIngo Molnar <mingo@elte.hu>2008-07-08 06:50:15 -0400
commitb2ac82a0909aea0d2620ba4c189f37c567c21fe5 (patch)
tree97331aa19837b20542b387bd7d8f1f01c472ee37 /arch/x86/mm/init_32.c
parent1f75d7e32ed47b2ab8570771a2ce8c707a7225a2 (diff)
x86: introduce initmem_init for 32 bit
Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/mm/init_32.c')
-rw-r--r--arch/x86/mm/init_32.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
index a0484adbf59d..9bc8607d7980 100644
--- a/arch/x86/mm/init_32.c
+++ b/arch/x86/mm/init_32.c
@@ -540,6 +540,96 @@ static void __init set_nx(void)
540} 540}
541#endif 541#endif
542 542
543#ifndef CONFIG_NEED_MULTIPLE_NODES
544extern unsigned long find_max_low_pfn(void);
545unsigned long __init initmem_init(unsigned long start_pfn,
546 unsigned long end_pfn)
547{
548 /*
549 * partially used pages are not usable - thus
550 * we are rounding upwards:
551 */
552 min_low_pfn = PFN_UP(init_pg_tables_end);
553
554 max_low_pfn = find_max_low_pfn();
555
556#ifdef CONFIG_HIGHMEM
557 highstart_pfn = highend_pfn = max_pfn;
558 if (max_pfn > max_low_pfn)
559 highstart_pfn = max_low_pfn;
560 memory_present(0, 0, highend_pfn);
561 printk(KERN_NOTICE "%ldMB HIGHMEM available.\n",
562 pages_to_mb(highend_pfn - highstart_pfn));
563 num_physpages = highend_pfn;
564 high_memory = (void *) __va(highstart_pfn * PAGE_SIZE - 1) + 1;
565#else
566 memory_present(0, 0, max_low_pfn);
567 num_physpages = max_low_pfn;
568 high_memory = (void *) __va(max_low_pfn * PAGE_SIZE - 1) + 1;
569#endif
570#ifdef CONFIG_FLATMEM
571 max_mapnr = num_physpages;
572#endif
573 printk(KERN_NOTICE "%ldMB LOWMEM available.\n",
574 pages_to_mb(max_low_pfn));
575
576 setup_bootmem_allocator();
577
578 return max_low_pfn;
579}
580
581void __init zone_sizes_init(void)
582{
583 unsigned long max_zone_pfns[MAX_NR_ZONES];
584 memset(max_zone_pfns, 0, sizeof(max_zone_pfns));
585 max_zone_pfns[ZONE_DMA] =
586 virt_to_phys((char *)MAX_DMA_ADDRESS) >> PAGE_SHIFT;
587 max_zone_pfns[ZONE_NORMAL] = max_low_pfn;
588 remove_all_active_ranges();
589#ifdef CONFIG_HIGHMEM
590 max_zone_pfns[ZONE_HIGHMEM] = highend_pfn;
591 e820_register_active_regions(0, 0, highend_pfn);
592#else
593 e820_register_active_regions(0, 0, max_low_pfn);
594#endif
595
596 free_area_init_nodes(max_zone_pfns);
597}
598#endif /* !CONFIG_NEED_MULTIPLE_NODES */
599
600extern void reserve_initrd(void);
601
602void __init setup_bootmem_allocator(void)
603{
604 int i;
605 unsigned long bootmap_size, bootmap;
606 /*
607 * Initialize the boot-time allocator (with low memory only):
608 */
609 bootmap_size = bootmem_bootmap_pages(max_low_pfn)<<PAGE_SHIFT;
610 bootmap = find_e820_area(min_low_pfn<<PAGE_SHIFT,
611 max_pfn_mapped<<PAGE_SHIFT, bootmap_size,
612 PAGE_SIZE);
613 if (bootmap == -1L)
614 panic("Cannot find bootmem map of size %ld\n", bootmap_size);
615 reserve_early(bootmap, bootmap + bootmap_size, "BOOTMAP");
616#ifdef CONFIG_BLK_DEV_INITRD
617 reserve_initrd();
618#endif
619 bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, max_low_pfn);
620 printk(KERN_INFO " mapped low ram: 0 - %08lx\n",
621 max_pfn_mapped<<PAGE_SHIFT);
622 printk(KERN_INFO " low ram: %08lx - %08lx\n",
623 min_low_pfn<<PAGE_SHIFT, max_low_pfn<<PAGE_SHIFT);
624 printk(KERN_INFO " bootmap %08lx - %08lx\n",
625 bootmap, bootmap + bootmap_size);
626 for_each_online_node(i)
627 free_bootmem_with_active_regions(i, max_low_pfn);
628 early_res_to_bootmem(0, max_low_pfn<<PAGE_SHIFT);
629
630}
631
632
543/* 633/*
544 * paging_init() sets up the page tables - note that the first 8MB are 634 * paging_init() sets up the page tables - note that the first 8MB are
545 * already mapped by head.S. 635 * already mapped by head.S.