void __init setup_arch_memory()

in mm/init.c [88:169]


void __init setup_arch_memory(void)
{
	unsigned long max_zone_pfn[MAX_NR_ZONES] = { 0 };

	setup_initial_init_mm(_text, _etext, _edata, _end);

	/* first page of system - kernel .vector starts here */
	min_low_pfn = virt_to_pfn(CONFIG_LINUX_RAM_BASE);

	/* Last usable page of low mem */
	max_low_pfn = max_pfn = PFN_DOWN(low_mem_start + low_mem_sz);

	/*------------- bootmem allocator setup -----------------------*/

	/*
	 * seed the bootmem allocator after any DT memory node parsing or
	 * "mem=xxx" cmdline overrides have potentially updated @arc_mem_sz
	 *
	 * Only low mem is added, otherwise we have crashes when allocating
	 * mem_map[] itself. NO_BOOTMEM allocates mem_map[] at the end of
	 * avail memory, ending in highmem with a > 32-bit address. However
	 * it then tries to memset it with a truncaed 32-bit handle, causing
	 * the crash
	 */

	memblock_reserve(CONFIG_LINUX_LINK_BASE,
			 __pa(_end) - CONFIG_LINUX_LINK_BASE);

#ifdef CONFIG_BLK_DEV_INITRD
	if (phys_initrd_size) {
		memblock_reserve(phys_initrd_start, phys_initrd_size);
		initrd_start = (unsigned long)__va(phys_initrd_start);
		initrd_end = initrd_start + phys_initrd_size;
	}
#endif

	early_init_fdt_reserve_self();
	early_init_fdt_scan_reserved_mem();

	memblock_dump_all();

	/*----------------- node/zones setup --------------------------*/
	max_zone_pfn[ZONE_NORMAL] = max_low_pfn;

#ifdef CONFIG_HIGHMEM
	/*
	 * On ARC (w/o PAE) HIGHMEM addresses are actually smaller (0 based)
	 * than addresses in normal aka low memory (0x8000_0000 based).
	 * Even with PAE, the huge peripheral space hole would waste a lot of
	 * mem with single contiguous mem_map[].
	 * Thus when HIGHMEM on ARC is enabled the memory map corresponding
	 * to the hole is freed and ARC specific version of pfn_valid()
	 * handles the hole in the memory map.
	 */

	min_high_pfn = PFN_DOWN(high_mem_start);
	max_high_pfn = PFN_DOWN(high_mem_start + high_mem_sz);

	/*
	 * max_high_pfn should be ok here for both HIGHMEM and HIGHMEM+PAE.
	 * For HIGHMEM without PAE max_high_pfn should be less than
	 * min_low_pfn to guarantee that these two regions don't overlap.
	 * For PAE case highmem is greater than lowmem, so it is natural
	 * to use max_high_pfn.
	 *
	 * In both cases, holes should be handled by pfn_valid().
	 */
	max_zone_pfn[ZONE_HIGHMEM] = max_high_pfn;

	high_memory = (void *)(min_high_pfn << PAGE_SHIFT);

	arch_pfn_offset = min(min_low_pfn, min_high_pfn);
	kmap_init();

#else /* CONFIG_HIGHMEM */
	/* pfn_valid() uses this when FLATMEM=y and HIGHMEM=n */
	max_mapnr = max_low_pfn - min_low_pfn;

#endif /* CONFIG_HIGHMEM */

	free_area_init(max_zone_pfn);
}