diff options
Diffstat (limited to 'arch/arm/mm/init.c')
-rw-r--r-- | arch/arm/mm/init.c | 216 |
1 files changed, 15 insertions, 201 deletions
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 64262bda8e54..22217fe2650b 100644 --- a/arch/arm/mm/init.c +++ b/arch/arm/mm/init.c | |||
@@ -27,10 +27,7 @@ | |||
27 | 27 | ||
28 | #include "mm.h" | 28 | #include "mm.h" |
29 | 29 | ||
30 | DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); | 30 | extern void _text, _etext, __data_start, _end, __init_begin, __init_end; |
31 | |||
32 | extern pgd_t swapper_pg_dir[PTRS_PER_PGD]; | ||
33 | extern void _stext, _text, _etext, __data_start, _end, __init_begin, __init_end; | ||
34 | extern unsigned long phys_initrd_start; | 31 | extern unsigned long phys_initrd_start; |
35 | extern unsigned long phys_initrd_size; | 32 | extern unsigned long phys_initrd_size; |
36 | 33 | ||
@@ -40,17 +37,6 @@ extern unsigned long phys_initrd_size; | |||
40 | */ | 37 | */ |
41 | static struct meminfo meminfo __initdata = { 0, }; | 38 | static struct meminfo meminfo __initdata = { 0, }; |
42 | 39 | ||
43 | /* | ||
44 | * empty_zero_page is a special page that is used for | ||
45 | * zero-initialized data and COW. | ||
46 | */ | ||
47 | struct page *empty_zero_page; | ||
48 | |||
49 | /* | ||
50 | * The pmd table for the upper-most set of pages. | ||
51 | */ | ||
52 | pmd_t *top_pmd; | ||
53 | |||
54 | void show_mem(void) | 40 | void show_mem(void) |
55 | { | 41 | { |
56 | int free = 0, total = 0, reserved = 0; | 42 | int free = 0, total = 0, reserved = 0; |
@@ -173,57 +159,18 @@ static int __init check_initrd(struct meminfo *mi) | |||
173 | return initrd_node; | 159 | return initrd_node; |
174 | } | 160 | } |
175 | 161 | ||
176 | /* | 162 | static inline void map_memory_bank(struct membank *bank) |
177 | * Reserve the various regions of node 0 | ||
178 | */ | ||
179 | static __init void reserve_node_zero(pg_data_t *pgdat) | ||
180 | { | 163 | { |
181 | unsigned long res_size = 0; | 164 | #ifdef CONFIG_MMU |
182 | 165 | struct map_desc map; | |
183 | /* | ||
184 | * Register the kernel text and data with bootmem. | ||
185 | * Note that this can only be in node 0. | ||
186 | */ | ||
187 | #ifdef CONFIG_XIP_KERNEL | ||
188 | reserve_bootmem_node(pgdat, __pa(&__data_start), &_end - &__data_start); | ||
189 | #else | ||
190 | reserve_bootmem_node(pgdat, __pa(&_stext), &_end - &_stext); | ||
191 | #endif | ||
192 | |||
193 | /* | ||
194 | * Reserve the page tables. These are already in use, | ||
195 | * and can only be in node 0. | ||
196 | */ | ||
197 | reserve_bootmem_node(pgdat, __pa(swapper_pg_dir), | ||
198 | PTRS_PER_PGD * sizeof(pgd_t)); | ||
199 | 166 | ||
200 | /* | 167 | map.pfn = __phys_to_pfn(bank->start); |
201 | * Hmm... This should go elsewhere, but we really really need to | 168 | map.virtual = __phys_to_virt(bank->start); |
202 | * stop things allocating the low memory; ideally we need a better | 169 | map.length = bank->size; |
203 | * implementation of GFP_DMA which does not assume that DMA-able | 170 | map.type = MT_MEMORY; |
204 | * memory starts at zero. | ||
205 | */ | ||
206 | if (machine_is_integrator() || machine_is_cintegrator()) | ||
207 | res_size = __pa(swapper_pg_dir) - PHYS_OFFSET; | ||
208 | 171 | ||
209 | /* | 172 | create_mapping(&map); |
210 | * These should likewise go elsewhere. They pre-reserve the | ||
211 | * screen memory region at the start of main system memory. | ||
212 | */ | ||
213 | if (machine_is_edb7211()) | ||
214 | res_size = 0x00020000; | ||
215 | if (machine_is_p720t()) | ||
216 | res_size = 0x00014000; | ||
217 | |||
218 | #ifdef CONFIG_SA1111 | ||
219 | /* | ||
220 | * Because of the SA1111 DMA bug, we want to preserve our | ||
221 | * precious DMA-able memory... | ||
222 | */ | ||
223 | res_size = __pa(swapper_pg_dir) - PHYS_OFFSET; | ||
224 | #endif | 173 | #endif |
225 | if (res_size) | ||
226 | reserve_bootmem_node(pgdat, PHYS_OFFSET, res_size); | ||
227 | } | 174 | } |
228 | 175 | ||
229 | static unsigned long __init | 176 | static unsigned long __init |
@@ -242,23 +189,18 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi) | |||
242 | * Calculate the pfn range, and map the memory banks for this node. | 189 | * Calculate the pfn range, and map the memory banks for this node. |
243 | */ | 190 | */ |
244 | for_each_nodebank(i, mi, node) { | 191 | for_each_nodebank(i, mi, node) { |
192 | struct membank *bank = &mi->bank[i]; | ||
245 | unsigned long start, end; | 193 | unsigned long start, end; |
246 | struct map_desc map; | ||
247 | 194 | ||
248 | start = mi->bank[i].start >> PAGE_SHIFT; | 195 | start = bank->start >> PAGE_SHIFT; |
249 | end = (mi->bank[i].start + mi->bank[i].size) >> PAGE_SHIFT; | 196 | end = (bank->start + bank->size) >> PAGE_SHIFT; |
250 | 197 | ||
251 | if (start_pfn > start) | 198 | if (start_pfn > start) |
252 | start_pfn = start; | 199 | start_pfn = start; |
253 | if (end_pfn < end) | 200 | if (end_pfn < end) |
254 | end_pfn = end; | 201 | end_pfn = end; |
255 | 202 | ||
256 | map.pfn = __phys_to_pfn(mi->bank[i].start); | 203 | map_memory_bank(bank); |
257 | map.virtual = __phys_to_virt(mi->bank[i].start); | ||
258 | map.length = mi->bank[i].size; | ||
259 | map.type = MT_MEMORY; | ||
260 | |||
261 | create_mapping(&map); | ||
262 | } | 204 | } |
263 | 205 | ||
264 | /* | 206 | /* |
@@ -340,9 +282,9 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi) | |||
340 | return end_pfn; | 282 | return end_pfn; |
341 | } | 283 | } |
342 | 284 | ||
343 | static void __init bootmem_init(struct meminfo *mi) | 285 | void __init bootmem_init(struct meminfo *mi) |
344 | { | 286 | { |
345 | unsigned long addr, memend_pfn = 0; | 287 | unsigned long memend_pfn = 0; |
346 | int node, initrd_node, i; | 288 | int node, initrd_node, i; |
347 | 289 | ||
348 | /* | 290 | /* |
@@ -355,26 +297,6 @@ static void __init bootmem_init(struct meminfo *mi) | |||
355 | memcpy(&meminfo, mi, sizeof(meminfo)); | 297 | memcpy(&meminfo, mi, sizeof(meminfo)); |
356 | 298 | ||
357 | /* | 299 | /* |
358 | * Clear out all the mappings below the kernel image. | ||
359 | */ | ||
360 | for (addr = 0; addr < MODULE_START; addr += PGDIR_SIZE) | ||
361 | pmd_clear(pmd_off_k(addr)); | ||
362 | #ifdef CONFIG_XIP_KERNEL | ||
363 | /* The XIP kernel is mapped in the module area -- skip over it */ | ||
364 | addr = ((unsigned long)&_etext + PGDIR_SIZE - 1) & PGDIR_MASK; | ||
365 | #endif | ||
366 | for ( ; addr < PAGE_OFFSET; addr += PGDIR_SIZE) | ||
367 | pmd_clear(pmd_off_k(addr)); | ||
368 | |||
369 | /* | ||
370 | * Clear out all the kernel space mappings, except for the first | ||
371 | * memory bank, up to the end of the vmalloc region. | ||
372 | */ | ||
373 | for (addr = __phys_to_virt(mi->bank[0].start + mi->bank[0].size); | ||
374 | addr < VMALLOC_END; addr += PGDIR_SIZE) | ||
375 | pmd_clear(pmd_off_k(addr)); | ||
376 | |||
377 | /* | ||
378 | * Locate which node contains the ramdisk image, if any. | 300 | * Locate which node contains the ramdisk image, if any. |
379 | */ | 301 | */ |
380 | initrd_node = check_initrd(mi); | 302 | initrd_node = check_initrd(mi); |
@@ -407,114 +329,6 @@ static void __init bootmem_init(struct meminfo *mi) | |||
407 | max_pfn = max_low_pfn = memend_pfn - PHYS_PFN_OFFSET; | 329 | max_pfn = max_low_pfn = memend_pfn - PHYS_PFN_OFFSET; |
408 | } | 330 | } |
409 | 331 | ||
410 | /* | ||
411 | * Set up device the mappings. Since we clear out the page tables for all | ||
412 | * mappings above VMALLOC_END, we will remove any debug device mappings. | ||
413 | * This means you have to be careful how you debug this function, or any | ||
414 | * called function. This means you can't use any function or debugging | ||
415 | * method which may touch any device, otherwise the kernel _will_ crash. | ||
416 | */ | ||
417 | static void __init devicemaps_init(struct machine_desc *mdesc) | ||
418 | { | ||
419 | struct map_desc map; | ||
420 | unsigned long addr; | ||
421 | void *vectors; | ||
422 | |||
423 | /* | ||
424 | * Allocate the vector page early. | ||
425 | */ | ||
426 | vectors = alloc_bootmem_low_pages(PAGE_SIZE); | ||
427 | BUG_ON(!vectors); | ||
428 | |||
429 | for (addr = VMALLOC_END; addr; addr += PGDIR_SIZE) | ||
430 | pmd_clear(pmd_off_k(addr)); | ||
431 | |||
432 | /* | ||
433 | * Map the kernel if it is XIP. | ||
434 | * It is always first in the modulearea. | ||
435 | */ | ||
436 | #ifdef CONFIG_XIP_KERNEL | ||
437 | map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK); | ||
438 | map.virtual = MODULE_START; | ||
439 | map.length = ((unsigned long)&_etext - map.virtual + ~SECTION_MASK) & SECTION_MASK; | ||
440 | map.type = MT_ROM; | ||
441 | create_mapping(&map); | ||
442 | #endif | ||
443 | |||
444 | /* | ||
445 | * Map the cache flushing regions. | ||
446 | */ | ||
447 | #ifdef FLUSH_BASE | ||
448 | map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS); | ||
449 | map.virtual = FLUSH_BASE; | ||
450 | map.length = SZ_1M; | ||
451 | map.type = MT_CACHECLEAN; | ||
452 | create_mapping(&map); | ||
453 | #endif | ||
454 | #ifdef FLUSH_BASE_MINICACHE | ||
455 | map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + SZ_1M); | ||
456 | map.virtual = FLUSH_BASE_MINICACHE; | ||
457 | map.length = SZ_1M; | ||
458 | map.type = MT_MINICLEAN; | ||
459 | create_mapping(&map); | ||
460 | #endif | ||
461 | |||
462 | /* | ||
463 | * Create a mapping for the machine vectors at the high-vectors | ||
464 | * location (0xffff0000). If we aren't using high-vectors, also | ||
465 | * create a mapping at the low-vectors virtual address. | ||
466 | */ | ||
467 | map.pfn = __phys_to_pfn(virt_to_phys(vectors)); | ||
468 | map.virtual = 0xffff0000; | ||
469 | map.length = PAGE_SIZE; | ||
470 | map.type = MT_HIGH_VECTORS; | ||
471 | create_mapping(&map); | ||
472 | |||
473 | if (!vectors_high()) { | ||
474 | map.virtual = 0; | ||
475 | map.type = MT_LOW_VECTORS; | ||
476 | create_mapping(&map); | ||
477 | } | ||
478 | |||
479 | /* | ||
480 | * Ask the machine support to map in the statically mapped devices. | ||
481 | */ | ||
482 | if (mdesc->map_io) | ||
483 | mdesc->map_io(); | ||
484 | |||
485 | /* | ||
486 | * Finally flush the caches and tlb to ensure that we're in a | ||
487 | * consistent state wrt the writebuffer. This also ensures that | ||
488 | * any write-allocated cache lines in the vector page are written | ||
489 | * back. After this point, we can start to touch devices again. | ||
490 | */ | ||
491 | local_flush_tlb_all(); | ||
492 | flush_cache_all(); | ||
493 | } | ||
494 | |||
495 | /* | ||
496 | * paging_init() sets up the page tables, initialises the zone memory | ||
497 | * maps, and sets up the zero page, bad page and bad page tables. | ||
498 | */ | ||
499 | void __init paging_init(struct meminfo *mi, struct machine_desc *mdesc) | ||
500 | { | ||
501 | void *zero_page; | ||
502 | |||
503 | build_mem_type_table(); | ||
504 | bootmem_init(mi); | ||
505 | devicemaps_init(mdesc); | ||
506 | |||
507 | top_pmd = pmd_off_k(0xffff0000); | ||
508 | |||
509 | /* | ||
510 | * allocate the zero page. Note that we count on this going ok. | ||
511 | */ | ||
512 | zero_page = alloc_bootmem_low_pages(PAGE_SIZE); | ||
513 | memzero(zero_page, PAGE_SIZE); | ||
514 | empty_zero_page = virt_to_page(zero_page); | ||
515 | flush_dcache_page(empty_zero_page); | ||
516 | } | ||
517 | |||
518 | static inline void free_area(unsigned long addr, unsigned long end, char *s) | 332 | static inline void free_area(unsigned long addr, unsigned long end, char *s) |
519 | { | 333 | { |
520 | unsigned int size = (end - addr) >> 10; | 334 | unsigned int size = (end - addr) >> 10; |