void __init early_init_devtree(void *params) { pr_debug(" -> early_init_devtree(%p)\n", params); /* Setup flat device-tree pointer */ initial_boot_params = params; /* Retrieve various informations from the /chosen node of the * device-tree, including the platform type, initrd location and * size, TCE reserve, and more ... */ of_scan_flat_dt(early_init_dt_scan_chosen, NULL); /* Scan memory nodes and rebuild MEMBLOCKs */ memblock_init(); of_scan_flat_dt(early_init_dt_scan_root, NULL); of_scan_flat_dt(early_init_dt_scan_memory, NULL); /* Save command line for /proc/cmdline and then parse parameters */ strlcpy(boot_command_line, cmd_line, COMMAND_LINE_SIZE); parse_early_param(); memblock_analyze(); pr_debug("Phys. mem: %lx\n", (unsigned long) memblock_phys_mem_size()); pr_debug(" <- early_init_devtree()\n"); }
void __init wii_memory_fixups(void) { struct memblock_property *p = memblock.memory.region; BUG_ON(memblock.memory.cnt != 2); BUG_ON(!page_aligned(p[0].base) || !page_aligned(p[1].base)); p[0].size = _ALIGN_DOWN(p[0].size, PAGE_SIZE); p[1].size = _ALIGN_DOWN(p[1].size, PAGE_SIZE); wii_hole_start = p[0].base + p[0].size; wii_hole_size = p[1].base - wii_hole_start; pr_info("MEM1: <%08llx %08llx>\n", p[0].base, p[0].size); pr_info("HOLE: <%08lx %08lx>\n", wii_hole_start, wii_hole_size); pr_info("MEM2: <%08llx %08llx>\n", p[1].base, p[1].size); p[0].size += wii_hole_size + p[1].size; memblock.memory.cnt = 1; memblock_analyze(); /* reserve the hole */ memblock_reserve(wii_hole_start, wii_hole_size); /* allow ioremapping the address space in the hole */ __allow_ioremap_reserved = 1; }
void __init early_init_devtree(void *params) { /* Setup flat device-tree pointer */ initial_boot_params = params; /* Retrieve various informations from the /chosen node of the * device-tree, including the platform type, initrd location and * size, and more ... */ of_scan_flat_dt(early_init_dt_scan_chosen, cmd_line); /* Scan memory nodes */ memblock_init(); of_scan_flat_dt(early_init_dt_scan_root, NULL); of_scan_flat_dt(early_init_dt_scan_memory_arch, NULL); memblock_analyze(); }
void __init bootmem_init(void) { struct memblock_region *reg; unsigned long bootmap_size; unsigned long free_pfn, end_pfn, start_pfn; init_mm.start_code = (unsigned long)_stext; init_mm.end_code = (unsigned long)_etext; init_mm.end_data = (unsigned long)_edata; init_mm.brk = (unsigned long)_end; memblock_init(); memblock_add(memory_start, memory_end); if(((unsigned long)__pa(_end) < memory_start) || ((unsigned long)__pa(_end) > memory_end)) printk("BUG: your kernel is not located in the ddr sdram"); start_pfn = PFN_UP(memory_start); free_pfn = PFN_UP(__pa((unsigned long)_end)); end_pfn = PFN_DOWN(memory_end); //memblock_reserve(PFN_PHYS(start_pfn), PFN_PHYS(free_pfn - start_pfn)); memblock_reserve(__pa(_stext), _end - _stext); #ifdef CONFIG_BLK_DEV_INITRD if (initrd_start && initrd_end && initrd_start < initrd_end) { memblock_reserve(initrd_start, initrd_end - initrd_start); } #endif bootmap_size = init_bootmem(free_pfn, end_pfn); memblock_reserve(PFN_PHYS(free_pfn), bootmap_size); free_bootmem(PFN_PHYS(free_pfn), PFN_PHYS(end_pfn - free_pfn)); for_each_memblock(reserved, reg) reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT); memory_start += PAGE_OFFSET; memory_end += PAGE_OFFSET; memblock_analyze(); memblock_dump_all(); }
void __init wii_memory_fixups(void) { struct memblock_region *p = memblock.memory.regions; /* * This is part of a workaround to allow the use of two * discontinuous RAM ranges on the Wii, even if this is * currently unsupported on 32-bit PowerPC Linux. * * We coalesce the two memory ranges of the Wii into a * single range, then create a reservation for the "hole" * between both ranges. */ BUG_ON(memblock.memory.cnt != 2); BUG_ON(!page_aligned(p[0].base) || !page_aligned(p[1].base)); p[0].size = _ALIGN_DOWN(p[0].size, PAGE_SIZE); p[1].size = _ALIGN_DOWN(p[1].size, PAGE_SIZE); wii_hole_start = p[0].base + p[0].size; wii_hole_size = p[1].base - wii_hole_start; pr_info("MEM1: <%08llx %08llx>\n", (unsigned long long) p[0].base, (unsigned long long) p[0].size); pr_info("HOLE: <%08lx %08lx>\n", wii_hole_start, wii_hole_size); pr_info("MEM2: <%08llx %08llx>\n", (unsigned long long) p[1].base, (unsigned long long) p[1].size); p[0].size += wii_hole_size + p[1].size; memblock.memory.cnt = 1; memblock_analyze(); /* reserve the hole */ memblock_reserve(wii_hole_start, wii_hole_size); /* allow ioremapping the address space in the hole */ __allow_ioremap_reserved = 1; }
/* * MMU_init sets up the basic memory mappings for the kernel, * including both RAM and possibly some I/O regions, * and sets up the page tables and the MMU hardware ready to go. */ void __init MMU_init(void) { if (ppc_md.progress) ppc_md.progress("MMU:enter", 0x111); /* parse args from command line */ MMU_setup(); if (memblock.memory.cnt > 1) { #ifndef CONFIG_WII memblock.memory.cnt = 1; memblock_analyze(); printk(KERN_WARNING "Only using first contiguous memory region"); #else wii_memory_fixups(); #endif } total_lowmem = total_memory = memblock_end_of_DRAM() - memstart_addr; lowmem_end_addr = memstart_addr + total_lowmem; #ifdef CONFIG_FSL_BOOKE /* Freescale Book-E parts expect lowmem to be mapped by fixed TLB * entries, so we need to adjust lowmem to match the amount we can map * in the fixed entries */ adjust_total_lowmem(); #endif /* CONFIG_FSL_BOOKE */ if (total_lowmem > __max_low_memory) { total_lowmem = __max_low_memory; lowmem_end_addr = memstart_addr + total_lowmem; #ifndef CONFIG_HIGHMEM total_memory = total_lowmem; memblock_enforce_memory_limit(total_lowmem); memblock_analyze(); #endif /* CONFIG_HIGHMEM */ } /* Initialize the MMU hardware */ if (ppc_md.progress) ppc_md.progress("MMU:hw init", 0x300); MMU_init_hw(); /* Map in all of RAM starting at KERNELBASE */ if (ppc_md.progress) ppc_md.progress("MMU:mapin", 0x301); mapin_ram(); /* Initialize early top-down ioremap allocator */ ioremap_bot = IOREMAP_TOP; /* Map in I/O resources */ if (ppc_md.progress) ppc_md.progress("MMU:setio", 0x302); if (ppc_md.progress) ppc_md.progress("MMU:exit", 0x211); /* From now on, btext is no longer BAT mapped if it was at all */ #ifdef CONFIG_BOOTX_TEXT btext_unmap(); #endif /* Shortly after that, the entire linear mapping will be available */ memblock_set_current_limit(lowmem_end_addr); }