aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRussell King <rmk@dyn-67.arm.linux.org.uk>2006-09-27 05:00:54 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2006-09-27 05:10:58 -0400
commit456335e2072fb35bf290b45e61d51916c322c145 (patch)
tree985fddceeeff3e3a8cbbff33a8130fc31637ec8d
parentc06015148fa9a3cc452ec7121b8c3f59f4a7d6ac (diff)
[ARM] Separate page table manipulation code from bootmem initialisation
nommu does not require the page table manipulation code in the bootmem initialisation paths. Move this into separate inline functions. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mm/init.c73
-rw-r--r--include/asm-arm/setup.h12
2 files changed, 51 insertions, 34 deletions
diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
index 64262bda8e54..83145d1d3389 100644
--- a/arch/arm/mm/init.c
+++ b/arch/arm/mm/init.c
@@ -226,6 +226,44 @@ static __init void reserve_node_zero(pg_data_t *pgdat)
226 reserve_bootmem_node(pgdat, PHYS_OFFSET, res_size); 226 reserve_bootmem_node(pgdat, PHYS_OFFSET, res_size);
227} 227}
228 228
229static 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
255static inline void map_memory_bank(struct membank *bank)
256{
257 struct map_desc map;
258
259 map.pfn = __phys_to_pfn(bank->start);
260 map.virtual = __phys_to_virt(bank->start);
261 map.length = bank->size;
262 map.type = MT_MEMORY;
263
264 create_mapping(&map);
265}
266
229static unsigned long __init 267static unsigned long __init
230bootmem_init_node(int node, int initrd_node, struct meminfo *mi) 268bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
231{ 269{
@@ -242,23 +280,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. 280 * Calculate the pfn range, and map the memory banks for this node.
243 */ 281 */
244 for_each_nodebank(i, mi, node) { 282 for_each_nodebank(i, mi, node) {
283 struct membank *bank = &mi->bank[i];
245 unsigned long start, end; 284 unsigned long start, end;
246 struct map_desc map;
247 285
248 start = mi->bank[i].start >> PAGE_SHIFT; 286 start = bank->start >> PAGE_SHIFT;
249 end = (mi->bank[i].start + mi->bank[i].size) >> PAGE_SHIFT; 287 end = (bank->start + bank->size) >> PAGE_SHIFT;
250 288
251 if (start_pfn > start) 289 if (start_pfn > start)
252 start_pfn = start; 290 start_pfn = start;
253 if (end_pfn < end) 291 if (end_pfn < end)
254 end_pfn = end; 292 end_pfn = end;
255 293
256 map.pfn = __phys_to_pfn(mi->bank[i].start); 294 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 } 295 }
263 296
264 /* 297 /*
@@ -342,7 +375,7 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
342 375
343static void __init bootmem_init(struct meminfo *mi) 376static void __init bootmem_init(struct meminfo *mi)
344{ 377{
345 unsigned long addr, memend_pfn = 0; 378 unsigned long memend_pfn = 0;
346 int node, initrd_node, i; 379 int node, initrd_node, i;
347 380
348 /* 381 /*
@@ -354,25 +387,7 @@ static void __init bootmem_init(struct meminfo *mi)
354 387
355 memcpy(&meminfo, mi, sizeof(meminfo)); 388 memcpy(&meminfo, mi, sizeof(meminfo));
356 389
357 /* 390 prepare_page_table(mi);
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 391
377 /* 392 /*
378 * Locate which node contains the ramdisk image, if any. 393 * Locate which node contains the ramdisk image, if any.
diff --git a/include/asm-arm/setup.h b/include/asm-arm/setup.h
index ea3ed2465233..aa4b5782f0c9 100644
--- a/include/asm-arm/setup.h
+++ b/include/asm-arm/setup.h
@@ -194,13 +194,15 @@ static struct tagtable __tagtable_##fn __tag = { tag, fn }
194# define NR_BANKS 8 194# define NR_BANKS 8
195#endif 195#endif
196 196
197struct membank {
198 unsigned long start;
199 unsigned long size;
200 int node;
201};
202
197struct meminfo { 203struct meminfo {
198 int nr_banks; 204 int nr_banks;
199 struct { 205 struct membank bank[NR_BANKS];
200 unsigned long start;
201 unsigned long size;
202 int node;
203 } bank[NR_BANKS];
204}; 206};
205 207
206/* 208/*