diff options
Diffstat (limited to 'arch/microblaze/mm/init.c')
-rw-r--r-- | arch/microblaze/mm/init.c | 67 |
1 files changed, 43 insertions, 24 deletions
diff --git a/arch/microblaze/mm/init.c b/arch/microblaze/mm/init.c index a72f42498c25..2253e122aa85 100644 --- a/arch/microblaze/mm/init.c +++ b/arch/microblaze/mm/init.c | |||
@@ -44,9 +44,9 @@ char *klimit = _end; | |||
44 | */ | 44 | */ |
45 | unsigned long memory_start; | 45 | unsigned long memory_start; |
46 | EXPORT_SYMBOL(memory_start); | 46 | EXPORT_SYMBOL(memory_start); |
47 | unsigned long memory_end; /* due to mm/nommu.c */ | ||
48 | unsigned long memory_size; | 47 | unsigned long memory_size; |
49 | EXPORT_SYMBOL(memory_size); | 48 | EXPORT_SYMBOL(memory_size); |
49 | unsigned long lowmem_size; | ||
50 | 50 | ||
51 | /* | 51 | /* |
52 | * paging_init() sets up the page tables - in fact we've already done this. | 52 | * paging_init() sets up the page tables - in fact we've already done this. |
@@ -58,7 +58,7 @@ static void __init paging_init(void) | |||
58 | /* Clean every zones */ | 58 | /* Clean every zones */ |
59 | memset(zones_size, 0, sizeof(zones_size)); | 59 | memset(zones_size, 0, sizeof(zones_size)); |
60 | 60 | ||
61 | zones_size[ZONE_DMA] = max_mapnr; | 61 | zones_size[ZONE_DMA] = max_pfn; |
62 | 62 | ||
63 | free_area_init(zones_size); | 63 | free_area_init(zones_size); |
64 | } | 64 | } |
@@ -74,32 +74,31 @@ void __init setup_memory(void) | |||
74 | /* Find main memory where is the kernel */ | 74 | /* Find main memory where is the kernel */ |
75 | for_each_memblock(memory, reg) { | 75 | for_each_memblock(memory, reg) { |
76 | memory_start = (u32)reg->base; | 76 | memory_start = (u32)reg->base; |
77 | memory_end = (u32) reg->base + reg->size; | 77 | lowmem_size = reg->size; |
78 | if ((memory_start <= (u32)_text) && | 78 | if ((memory_start <= (u32)_text) && |
79 | ((u32)_text <= memory_end)) { | 79 | ((u32)_text <= (memory_start + lowmem_size - 1))) { |
80 | memory_size = memory_end - memory_start; | 80 | memory_size = lowmem_size; |
81 | PAGE_OFFSET = memory_start; | 81 | PAGE_OFFSET = memory_start; |
82 | printk(KERN_INFO "%s: Main mem: 0x%x-0x%x, " | 82 | printk(KERN_INFO "%s: Main mem: 0x%x, " |
83 | "size 0x%08x\n", __func__, (u32) memory_start, | 83 | "size 0x%08x\n", __func__, (u32) memory_start, |
84 | (u32) memory_end, (u32) memory_size); | 84 | (u32) memory_size); |
85 | break; | 85 | break; |
86 | } | 86 | } |
87 | } | 87 | } |
88 | 88 | ||
89 | if (!memory_start || !memory_end) { | 89 | if (!memory_start || !memory_size) { |
90 | panic("%s: Missing memory setting 0x%08x-0x%08x\n", | 90 | panic("%s: Missing memory setting 0x%08x, size=0x%08x\n", |
91 | __func__, (u32) memory_start, (u32) memory_end); | 91 | __func__, (u32) memory_start, (u32) memory_size); |
92 | } | 92 | } |
93 | 93 | ||
94 | /* reservation of region where is the kernel */ | 94 | /* reservation of region where is the kernel */ |
95 | kernel_align_start = PAGE_DOWN((u32)_text); | 95 | kernel_align_start = PAGE_DOWN((u32)_text); |
96 | /* ALIGN can be remove because _end in vmlinux.lds.S is align */ | 96 | /* ALIGN can be remove because _end in vmlinux.lds.S is align */ |
97 | kernel_align_size = PAGE_UP((u32)klimit) - kernel_align_start; | 97 | kernel_align_size = PAGE_UP((u32)klimit) - kernel_align_start; |
98 | memblock_reserve(kernel_align_start, kernel_align_size); | 98 | printk(KERN_INFO "%s: kernel addr:0x%08x-0x%08x size=0x%08x\n", |
99 | printk(KERN_INFO "%s: kernel addr=0x%08x-0x%08x size=0x%08x\n", | ||
100 | __func__, kernel_align_start, kernel_align_start | 99 | __func__, kernel_align_start, kernel_align_start |
101 | + kernel_align_size, kernel_align_size); | 100 | + kernel_align_size, kernel_align_size); |
102 | 101 | memblock_reserve(kernel_align_start, kernel_align_size); | |
103 | #endif | 102 | #endif |
104 | /* | 103 | /* |
105 | * Kernel: | 104 | * Kernel: |
@@ -116,11 +115,13 @@ void __init setup_memory(void) | |||
116 | min_low_pfn = memory_start >> PAGE_SHIFT; /* minimum for allocation */ | 115 | min_low_pfn = memory_start >> PAGE_SHIFT; /* minimum for allocation */ |
117 | /* RAM is assumed contiguous */ | 116 | /* RAM is assumed contiguous */ |
118 | num_physpages = max_mapnr = memory_size >> PAGE_SHIFT; | 117 | num_physpages = max_mapnr = memory_size >> PAGE_SHIFT; |
119 | max_pfn = max_low_pfn = memory_end >> PAGE_SHIFT; | 118 | max_low_pfn = ((u64)memory_start + (u64)lowmem_size) >> PAGE_SHIFT; |
119 | max_pfn = ((u64)memory_start + (u64)memory_size) >> PAGE_SHIFT; | ||
120 | 120 | ||
121 | printk(KERN_INFO "%s: max_mapnr: %#lx\n", __func__, max_mapnr); | 121 | printk(KERN_INFO "%s: max_mapnr: %#lx\n", __func__, max_mapnr); |
122 | printk(KERN_INFO "%s: min_low_pfn: %#lx\n", __func__, min_low_pfn); | 122 | printk(KERN_INFO "%s: min_low_pfn: %#lx\n", __func__, min_low_pfn); |
123 | printk(KERN_INFO "%s: max_low_pfn: %#lx\n", __func__, max_low_pfn); | 123 | printk(KERN_INFO "%s: max_low_pfn: %#lx\n", __func__, max_low_pfn); |
124 | printk(KERN_INFO "%s: max_pfn: %#lx\n", __func__, max_pfn); | ||
124 | 125 | ||
125 | /* | 126 | /* |
126 | * Find an area to use for the bootmem bitmap. | 127 | * Find an area to use for the bootmem bitmap. |
@@ -134,14 +135,25 @@ void __init setup_memory(void) | |||
134 | memblock_reserve(PFN_UP(TOPHYS((u32)klimit)) << PAGE_SHIFT, map_size); | 135 | memblock_reserve(PFN_UP(TOPHYS((u32)klimit)) << PAGE_SHIFT, map_size); |
135 | 136 | ||
136 | /* free bootmem is whole main memory */ | 137 | /* free bootmem is whole main memory */ |
137 | free_bootmem(memory_start, memory_size); | 138 | free_bootmem(memory_start, lowmem_size); |
138 | 139 | ||
139 | /* reserve allocate blocks */ | 140 | /* reserve allocate blocks */ |
140 | for_each_memblock(reserved, reg) { | 141 | for_each_memblock(reserved, reg) { |
141 | pr_debug("reserved - 0x%08x-0x%08x\n", | 142 | unsigned long top = reg->base + reg->size - 1; |
142 | (u32) reg->base, (u32) reg->size); | 143 | |
143 | reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT); | 144 | pr_debug("reserved - 0x%08x-0x%08x, %lx, %lx\n", |
145 | (u32) reg->base, (u32) reg->size, top, | ||
146 | memory_start + lowmem_size - 1); | ||
147 | |||
148 | if (top <= (memory_start + lowmem_size - 1)) { | ||
149 | reserve_bootmem(reg->base, reg->size, BOOTMEM_DEFAULT); | ||
150 | } else if (reg->base < (memory_start + lowmem_size - 1)) { | ||
151 | unsigned long trunc_size = memory_start + lowmem_size - | ||
152 | reg->base; | ||
153 | reserve_bootmem(reg->base, trunc_size, BOOTMEM_DEFAULT); | ||
154 | } | ||
144 | } | 155 | } |
156 | |||
145 | #ifdef CONFIG_MMU | 157 | #ifdef CONFIG_MMU |
146 | init_bootmem_done = 1; | 158 | init_bootmem_done = 1; |
147 | #endif | 159 | #endif |
@@ -186,7 +198,8 @@ void free_initmem(void) | |||
186 | 198 | ||
187 | void __init mem_init(void) | 199 | void __init mem_init(void) |
188 | { | 200 | { |
189 | high_memory = (void *)__va(memory_end); | 201 | high_memory = (void *)__va(memory_start + lowmem_size - 1); |
202 | |||
190 | /* this will put all memory onto the freelists */ | 203 | /* this will put all memory onto the freelists */ |
191 | totalram_pages += free_all_bootmem(); | 204 | totalram_pages += free_all_bootmem(); |
192 | 205 | ||
@@ -222,7 +235,6 @@ static void mm_cmdline_setup(void) | |||
222 | maxmem = memparse(p, &p); | 235 | maxmem = memparse(p, &p); |
223 | if (maxmem && memory_size > maxmem) { | 236 | if (maxmem && memory_size > maxmem) { |
224 | memory_size = maxmem; | 237 | memory_size = maxmem; |
225 | memory_end = memory_start + memory_size; | ||
226 | memblock.memory.regions[0].size = memory_size; | 238 | memblock.memory.regions[0].size = memory_size; |
227 | } | 239 | } |
228 | } | 240 | } |
@@ -272,9 +284,12 @@ asmlinkage void __init mmu_init(void) | |||
272 | } | 284 | } |
273 | /* Find main memory where the kernel is */ | 285 | /* Find main memory where the kernel is */ |
274 | memory_start = (u32) memblock.memory.regions[0].base; | 286 | memory_start = (u32) memblock.memory.regions[0].base; |
275 | memory_end = (u32) memblock.memory.regions[0].base + | 287 | lowmem_size = memory_size = (u32) memblock.memory.regions[0].size; |
276 | (u32) memblock.memory.regions[0].size; | 288 | |
277 | memory_size = memory_end - memory_start; | 289 | if (lowmem_size > CONFIG_LOWMEM_SIZE) { |
290 | lowmem_size = CONFIG_LOWMEM_SIZE; | ||
291 | memory_size = lowmem_size; | ||
292 | } | ||
278 | 293 | ||
279 | mm_cmdline_setup(); /* FIXME parse args from command line - not used */ | 294 | mm_cmdline_setup(); /* FIXME parse args from command line - not used */ |
280 | 295 | ||
@@ -307,9 +322,13 @@ asmlinkage void __init mmu_init(void) | |||
307 | ioremap_base = 0xfe000000UL; /* for now, could be 0xfffff000 */ | 322 | ioremap_base = 0xfe000000UL; /* for now, could be 0xfffff000 */ |
308 | #endif /* CONFIG_HIGHMEM_START_BOOL */ | 323 | #endif /* CONFIG_HIGHMEM_START_BOOL */ |
309 | ioremap_bot = ioremap_base; | 324 | ioremap_bot = ioremap_base; |
310 | |||
311 | /* Initialize the context management stuff */ | 325 | /* Initialize the context management stuff */ |
312 | mmu_context_init(); | 326 | mmu_context_init(); |
327 | |||
328 | /* Shortly after that, the entire linear mapping will be available */ | ||
329 | /* This will also cause that unflatten device tree will be allocated | ||
330 | * inside 768MB limit */ | ||
331 | memblock_set_current_limit(memory_start + lowmem_size - 1); | ||
313 | } | 332 | } |
314 | 333 | ||
315 | /* This is only called until mem_init is done. */ | 334 | /* This is only called until mem_init is done. */ |