0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015 #include <linux/module.h>
0016 #include <linux/sched.h>
0017 #include <linux/kernel.h>
0018 #include <linux/errno.h>
0019 #include <linux/string.h>
0020 #include <linux/types.h>
0021 #include <linux/mm.h>
0022 #include <linux/stddef.h>
0023 #include <linux/init.h>
0024 #include <linux/highmem.h>
0025 #include <linux/initrd.h>
0026 #include <linux/pagemap.h>
0027 #include <linux/memblock.h>
0028 #include <linux/gfp.h>
0029 #include <linux/slab.h>
0030 #include <linux/hugetlb.h>
0031
0032 #include <asm/io.h>
0033 #include <asm/mmu.h>
0034 #include <asm/smp.h>
0035 #include <asm/machdep.h>
0036 #include <asm/btext.h>
0037 #include <asm/tlb.h>
0038 #include <asm/sections.h>
0039 #include <asm/hugetlb.h>
0040 #include <asm/kup.h>
0041 #include <asm/kasan.h>
0042
0043 #include <mm/mmu_decl.h>
0044
0045 #if defined(CONFIG_KERNEL_START_BOOL) || defined(CONFIG_LOWMEM_SIZE_BOOL)
0046
0047 #if (CONFIG_LOWMEM_SIZE > (0xF0000000 - PAGE_OFFSET))
0048 #error "You must adjust CONFIG_LOWMEM_SIZE or CONFIG_KERNEL_START"
0049 #endif
0050 #endif
0051 #define MAX_LOW_MEM CONFIG_LOWMEM_SIZE
0052
0053 phys_addr_t total_memory;
0054 phys_addr_t total_lowmem;
0055
0056 #ifdef CONFIG_RELOCATABLE
0057
0058 long long virt_phys_offset;
0059 EXPORT_SYMBOL(virt_phys_offset);
0060 #endif
0061
0062 phys_addr_t lowmem_end_addr;
0063
0064 int boot_mapsize;
0065 #ifdef CONFIG_PPC_PMAC
0066 unsigned long agp_special_page;
0067 EXPORT_SYMBOL(agp_special_page);
0068 #endif
0069
0070 void MMU_init(void);
0071
0072
0073 unsigned long __max_low_memory = MAX_LOW_MEM;
0074
0075
0076
0077
0078
0079
0080 void __init MMU_init(void)
0081 {
0082 if (ppc_md.progress)
0083 ppc_md.progress("MMU:enter", 0x111);
0084
0085
0086
0087
0088
0089 if (memblock.memory.cnt > 1) {
0090 #ifndef CONFIG_WII
0091 memblock_enforce_memory_limit(memblock.memory.regions[0].size);
0092 pr_warn("Only using first contiguous memory region\n");
0093 #else
0094 wii_memory_fixups();
0095 #endif
0096 }
0097
0098 total_lowmem = total_memory = memblock_end_of_DRAM() - memstart_addr;
0099 lowmem_end_addr = memstart_addr + total_lowmem;
0100
0101 #ifdef CONFIG_FSL_BOOKE
0102
0103
0104
0105 adjust_total_lowmem();
0106 #endif
0107
0108 if (total_lowmem > __max_low_memory) {
0109 total_lowmem = __max_low_memory;
0110 lowmem_end_addr = memstart_addr + total_lowmem;
0111 #ifndef CONFIG_HIGHMEM
0112 total_memory = total_lowmem;
0113 memblock_enforce_memory_limit(total_lowmem);
0114 #endif
0115 }
0116
0117
0118 if (ppc_md.progress)
0119 ppc_md.progress("MMU:hw init", 0x300);
0120 MMU_init_hw();
0121
0122
0123 if (ppc_md.progress)
0124 ppc_md.progress("MMU:mapin", 0x301);
0125 mapin_ram();
0126
0127
0128 ioremap_bot = IOREMAP_TOP;
0129
0130 if (ppc_md.progress)
0131 ppc_md.progress("MMU:exit", 0x211);
0132
0133
0134 #ifdef CONFIG_BOOTX_TEXT
0135 btext_unmap();
0136 #endif
0137
0138 kasan_mmu_init();
0139
0140 setup_kup();
0141
0142
0143 memblock_set_current_limit(lowmem_end_addr);
0144 }