diff options
Diffstat (limited to 'arch/arm/mm/init.c')
-rw-r--r-- | arch/arm/mm/init.c | 209 |
1 files changed, 4 insertions, 205 deletions
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c index 83145d1d3389..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,87 +159,9 @@ static int __init check_initrd(struct meminfo *mi) | |||
173 | return initrd_node; | 159 | return initrd_node; |
174 | } | 160 | } |
175 | 161 | ||
176 | /* | ||
177 | * Reserve the various regions of node 0 | ||
178 | */ | ||
179 | static __init void reserve_node_zero(pg_data_t *pgdat) | ||
180 | { | ||
181 | unsigned long res_size = 0; | ||
182 | |||
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 | |||
200 | /* | ||
201 | * Hmm... This should go elsewhere, but we really really need to | ||
202 | * stop things allocating the low memory; ideally we need a better | ||
203 | * implementation of GFP_DMA which does not assume that DMA-able | ||
204 | * memory starts at zero. | ||
205 | */ | ||
206 | if (machine_is_integrator() || machine_is_cintegrator()) | ||
207 | res_size = __pa(swapper_pg_dir) - PHYS_OFFSET; | ||
208 | |||
209 | /* | ||
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 | ||
225 | if (res_size) | ||
226 | reserve_bootmem_node(pgdat, PHYS_OFFSET, res_size); | ||
227 | } | ||
228 | |||
229 | static inline void prepare_page_table(struct meminfo *mi) | ||
230 | { | ||
231 | unsigned long addr; | ||
232 | |||
233 | /* | ||
234 | * Clear out all the mappings below the kernel image. | ||
235 | */ | ||
236 | for (addr = 0; addr < MODULE_START; addr += PGDIR_SIZE) | ||
237 | pmd_clear(pmd_off_k(addr)); | ||
238 | |||
239 | #ifdef CONFIG_XIP_KERNEL | ||
240 | /* The XIP kernel is mapped in the module area -- skip over it */ | ||
241 | addr = ((unsigned long)&_etext + PGDIR_SIZE - 1) & PGDIR_MASK; | ||
242 | #endif | ||
243 | for ( ; addr < PAGE_OFFSET; addr += PGDIR_SIZE) | ||
244 | pmd_clear(pmd_off_k(addr)); | ||
245 | |||
246 | /* | ||
247 | * Clear out all the kernel space mappings, except for the first | ||
248 | * memory bank, up to the end of the vmalloc region. | ||
249 | */ | ||
250 | for (addr = __phys_to_virt(mi->bank[0].start + mi->bank[0].size); | ||
251 | addr < VMALLOC_END; addr += PGDIR_SIZE) | ||
252 | pmd_clear(pmd_off_k(addr)); | ||
253 | } | ||
254 | |||
255 | static inline void map_memory_bank(struct membank *bank) | 162 | static inline void map_memory_bank(struct membank *bank) |
256 | { | 163 | { |
164 | #ifdef CONFIG_MMU | ||
257 | struct map_desc map; | 165 | struct map_desc map; |
258 | 166 | ||
259 | map.pfn = __phys_to_pfn(bank->start); | 167 | map.pfn = __phys_to_pfn(bank->start); |
@@ -262,6 +170,7 @@ static inline void map_memory_bank(struct membank *bank) | |||
262 | map.type = MT_MEMORY; | 170 | map.type = MT_MEMORY; |
263 | 171 | ||
264 | create_mapping(&map); | 172 | create_mapping(&map); |
173 | #endif | ||
265 | } | 174 | } |
266 | 175 | ||
267 | static unsigned long __init | 176 | static unsigned long __init |
@@ -373,7 +282,7 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi) | |||
373 | return end_pfn; | 282 | return end_pfn; |
374 | } | 283 | } |
375 | 284 | ||
376 | static void __init bootmem_init(struct meminfo *mi) | 285 | void __init bootmem_init(struct meminfo *mi) |
377 | { | 286 | { |
378 | unsigned long memend_pfn = 0; | 287 | unsigned long memend_pfn = 0; |
379 | int node, initrd_node, i; | 288 | int node, initrd_node, i; |
@@ -387,8 +296,6 @@ static void __init bootmem_init(struct meminfo *mi) | |||
387 | 296 | ||
388 | memcpy(&meminfo, mi, sizeof(meminfo)); | 297 | memcpy(&meminfo, mi, sizeof(meminfo)); |
389 | 298 | ||
390 | prepare_page_table(mi); | ||
391 | |||
392 | /* | 299 | /* |
393 | * Locate which node contains the ramdisk image, if any. | 300 | * Locate which node contains the ramdisk image, if any. |
394 | */ | 301 | */ |
@@ -422,114 +329,6 @@ static void __init bootmem_init(struct meminfo *mi) | |||
422 | max_pfn = max_low_pfn = memend_pfn - PHYS_PFN_OFFSET; | 329 | max_pfn = max_low_pfn = memend_pfn - PHYS_PFN_OFFSET; |
423 | } | 330 | } |
424 | 331 | ||
425 | /* | ||
426 | * Set up device the mappings. Since we clear out the page tables for all | ||
427 | * mappings above VMALLOC_END, we will remove any debug device mappings. | ||
428 | * This means you have to be careful how you debug this function, or any | ||
429 | * called function. This means you can't use any function or debugging | ||
430 | * method which may touch any device, otherwise the kernel _will_ crash. | ||
431 | */ | ||
432 | static void __init devicemaps_init(struct machine_desc *mdesc) | ||
433 | { | ||
434 | struct map_desc map; | ||
435 | unsigned long addr; | ||
436 | void *vectors; | ||
437 | |||
438 | /* | ||
439 | * Allocate the vector page early. | ||
440 | */ | ||
441 | vectors = alloc_bootmem_low_pages(PAGE_SIZE); | ||
442 | BUG_ON(!vectors); | ||
443 | |||
444 | for (addr = VMALLOC_END; addr; addr += PGDIR_SIZE) | ||
445 | pmd_clear(pmd_off_k(addr)); | ||
446 | |||
447 | /* | ||
448 | * Map the kernel if it is XIP. | ||
449 | * It is always first in the modulearea. | ||
450 | */ | ||
451 | #ifdef CONFIG_XIP_KERNEL | ||
452 | map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK); | ||
453 | map.virtual = MODULE_START; | ||
454 | map.length = ((unsigned long)&_etext - map.virtual + ~SECTION_MASK) & SECTION_MASK; | ||
455 | map.type = MT_ROM; | ||
456 | create_mapping(&map); | ||
457 | #endif | ||
458 | |||
459 | /* | ||
460 | * Map the cache flushing regions. | ||
461 | */ | ||
462 | #ifdef FLUSH_BASE | ||
463 | map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS); | ||
464 | map.virtual = FLUSH_BASE; | ||
465 | map.length = SZ_1M; | ||
466 | map.type = MT_CACHECLEAN; | ||
467 | create_mapping(&map); | ||
468 | #endif | ||
469 | #ifdef FLUSH_BASE_MINICACHE | ||
470 | map.pfn = __phys_to_pfn(FLUSH_BASE_PHYS + SZ_1M); | ||
471 | map.virtual = FLUSH_BASE_MINICACHE; | ||
472 | map.length = SZ_1M; | ||
473 | map.type = MT_MINICLEAN; | ||
474 | create_mapping(&map); | ||
475 | #endif | ||
476 | |||
477 | /* | ||
478 | * Create a mapping for the machine vectors at the high-vectors | ||
479 | * location (0xffff0000). If we aren't using high-vectors, also | ||
480 | * create a mapping at the low-vectors virtual address. | ||
481 | */ | ||
482 | map.pfn = __phys_to_pfn(virt_to_phys(vectors)); | ||
483 | map.virtual = 0xffff0000; | ||
484 | map.length = PAGE_SIZE; | ||
485 | map.type = MT_HIGH_VECTORS; | ||
486 | create_mapping(&map); | ||
487 | |||
488 | if (!vectors_high()) { | ||
489 | map.virtual = 0; | ||
490 | map.type = MT_LOW_VECTORS; | ||
491 | create_mapping(&map); | ||
492 | } | ||
493 | |||
494 | /* | ||
495 | * Ask the machine support to map in the statically mapped devices. | ||
496 | */ | ||
497 | if (mdesc->map_io) | ||
498 | mdesc->map_io(); | ||
499 | |||
500 | /* | ||
501 | * Finally flush the caches and tlb to ensure that we're in a | ||
502 | * consistent state wrt the writebuffer. This also ensures that | ||
503 | * any write-allocated cache lines in the vector page are written | ||
504 | * back. After this point, we can start to touch devices again. | ||
505 | */ | ||
506 | local_flush_tlb_all(); | ||
507 | flush_cache_all(); | ||
508 | } | ||
509 | |||
510 | /* | ||
511 | * paging_init() sets up the page tables, initialises the zone memory | ||
512 | * maps, and sets up the zero page, bad page and bad page tables. | ||
513 | */ | ||
514 | void __init paging_init(struct meminfo *mi, struct machine_desc *mdesc) | ||
515 | { | ||
516 | void *zero_page; | ||
517 | |||
518 | build_mem_type_table(); | ||
519 | bootmem_init(mi); | ||
520 | devicemaps_init(mdesc); | ||
521 | |||
522 | top_pmd = pmd_off_k(0xffff0000); | ||
523 | |||
524 | /* | ||
525 | * allocate the zero page. Note that we count on this going ok. | ||
526 | */ | ||
527 | zero_page = alloc_bootmem_low_pages(PAGE_SIZE); | ||
528 | memzero(zero_page, PAGE_SIZE); | ||
529 | empty_zero_page = virt_to_page(zero_page); | ||
530 | flush_dcache_page(empty_zero_page); | ||
531 | } | ||
532 | |||
533 | 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) |
534 | { | 333 | { |
535 | unsigned int size = (end - addr) >> 10; | 334 | unsigned int size = (end - addr) >> 10; |