Commit 456335e2 authored by Russell King's avatar Russell King Committed by Russell King

[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: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
parent c0601514
...@@ -226,6 +226,44 @@ static __init void reserve_node_zero(pg_data_t *pgdat) ...@@ -226,6 +226,44 @@ static __init void reserve_node_zero(pg_data_t *pgdat)
reserve_bootmem_node(pgdat, PHYS_OFFSET, res_size); reserve_bootmem_node(pgdat, PHYS_OFFSET, res_size);
} }
static inline void prepare_page_table(struct meminfo *mi)
{
unsigned long addr;
/*
* Clear out all the mappings below the kernel image.
*/
for (addr = 0; addr < MODULE_START; addr += PGDIR_SIZE)
pmd_clear(pmd_off_k(addr));
#ifdef CONFIG_XIP_KERNEL
/* The XIP kernel is mapped in the module area -- skip over it */
addr = ((unsigned long)&_etext + PGDIR_SIZE - 1) & PGDIR_MASK;
#endif
for ( ; addr < PAGE_OFFSET; addr += PGDIR_SIZE)
pmd_clear(pmd_off_k(addr));
/*
* Clear out all the kernel space mappings, except for the first
* memory bank, up to the end of the vmalloc region.
*/
for (addr = __phys_to_virt(mi->bank[0].start + mi->bank[0].size);
addr < VMALLOC_END; addr += PGDIR_SIZE)
pmd_clear(pmd_off_k(addr));
}
static inline void map_memory_bank(struct membank *bank)
{
struct map_desc map;
map.pfn = __phys_to_pfn(bank->start);
map.virtual = __phys_to_virt(bank->start);
map.length = bank->size;
map.type = MT_MEMORY;
create_mapping(&map);
}
static unsigned long __init static unsigned long __init
bootmem_init_node(int node, int initrd_node, struct meminfo *mi) bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
{ {
...@@ -242,23 +280,18 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi) ...@@ -242,23 +280,18 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
* Calculate the pfn range, and map the memory banks for this node. * Calculate the pfn range, and map the memory banks for this node.
*/ */
for_each_nodebank(i, mi, node) { for_each_nodebank(i, mi, node) {
struct membank *bank = &mi->bank[i];
unsigned long start, end; unsigned long start, end;
struct map_desc map;
start = mi->bank[i].start >> PAGE_SHIFT; start = bank->start >> PAGE_SHIFT;
end = (mi->bank[i].start + mi->bank[i].size) >> PAGE_SHIFT; end = (bank->start + bank->size) >> PAGE_SHIFT;
if (start_pfn > start) if (start_pfn > start)
start_pfn = start; start_pfn = start;
if (end_pfn < end) if (end_pfn < end)
end_pfn = end; end_pfn = end;
map.pfn = __phys_to_pfn(mi->bank[i].start); map_memory_bank(bank);
map.virtual = __phys_to_virt(mi->bank[i].start);
map.length = mi->bank[i].size;
map.type = MT_MEMORY;
create_mapping(&map);
} }
/* /*
...@@ -342,7 +375,7 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi) ...@@ -342,7 +375,7 @@ bootmem_init_node(int node, int initrd_node, struct meminfo *mi)
static void __init bootmem_init(struct meminfo *mi) static void __init bootmem_init(struct meminfo *mi)
{ {
unsigned long addr, memend_pfn = 0; unsigned long memend_pfn = 0;
int node, initrd_node, i; int node, initrd_node, i;
/* /*
...@@ -354,25 +387,7 @@ static void __init bootmem_init(struct meminfo *mi) ...@@ -354,25 +387,7 @@ static void __init bootmem_init(struct meminfo *mi)
memcpy(&meminfo, mi, sizeof(meminfo)); memcpy(&meminfo, mi, sizeof(meminfo));
/* prepare_page_table(mi);
* Clear out all the mappings below the kernel image.
*/
for (addr = 0; addr < MODULE_START; addr += PGDIR_SIZE)
pmd_clear(pmd_off_k(addr));
#ifdef CONFIG_XIP_KERNEL
/* The XIP kernel is mapped in the module area -- skip over it */
addr = ((unsigned long)&_etext + PGDIR_SIZE - 1) & PGDIR_MASK;
#endif
for ( ; addr < PAGE_OFFSET; addr += PGDIR_SIZE)
pmd_clear(pmd_off_k(addr));
/*
* Clear out all the kernel space mappings, except for the first
* memory bank, up to the end of the vmalloc region.
*/
for (addr = __phys_to_virt(mi->bank[0].start + mi->bank[0].size);
addr < VMALLOC_END; addr += PGDIR_SIZE)
pmd_clear(pmd_off_k(addr));
/* /*
* Locate which node contains the ramdisk image, if any. * Locate which node contains the ramdisk image, if any.
......
...@@ -194,13 +194,15 @@ static struct tagtable __tagtable_##fn __tag = { tag, fn } ...@@ -194,13 +194,15 @@ static struct tagtable __tagtable_##fn __tag = { tag, fn }
# define NR_BANKS 8 # define NR_BANKS 8
#endif #endif
struct meminfo { struct membank {
int nr_banks;
struct {
unsigned long start; unsigned long start;
unsigned long size; unsigned long size;
int node; int node;
} bank[NR_BANKS]; };
struct meminfo {
int nr_banks;
struct membank bank[NR_BANKS];
}; };
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment