[PATCH 10/12] ARM mmu: find second level descriptors by walking the page table
Sascha Hauer
s.hauer at pengutronix.de
Fri Sep 23 05:24:18 EDT 2011
By doing this we can remove the ptes field in struct arm_memory
which won't be present in a generic memory bank structure anymore.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
arch/arm/cpu/mmu.c | 39 ++++++++++++++++++++-------------------
arch/arm/include/asm/memory.h | 1 -
2 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index b669349..6fa600f 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -76,28 +76,28 @@ static u32 *arm_create_pte(unsigned long virt)
return table;
}
+static u32 *find_pte(unsigned long adr)
+{
+ u32 *table;
+
+ if ((ttb[adr >> 20] & PMD_TYPE_MASK) != PMD_TYPE_TABLE)
+ BUG();
+
+ /* find the coarse page table base address */
+ table = (u32 *)(ttb[adr >> 20] & ~0x3ff);
+
+ /* find second level descriptor */
+ return &table[(adr >> PAGE_SHIFT) & 0xff];
+}
+
static void remap_range(void *_start, size_t size, uint32_t flags)
{
- u32 pteentry;
- struct arm_memory *mem;
unsigned long start = (unsigned long)_start;
u32 *p;
int numentries, i;
- for_each_sdram_bank(mem) {
- if (start >= mem->start && start < mem->start + mem->size)
- goto found;
- }
-
- BUG();
- return;
-
-found:
- pteentry = (start - mem->start) >> PAGE_SHIFT;
-
numentries = size >> PAGE_SHIFT;
-
- p = mem->ptes + pteentry;
+ p = find_pte(start);
for (i = 0; i < numentries; i++) {
p[i] &= ~PTE_MASK;
@@ -121,6 +121,7 @@ static int arm_mmu_remap_sdram(struct arm_memory *mem)
unsigned long ttb_end = (phys + mem->size) >> 20;
unsigned long num_ptes = mem->size >> 10;
int i, pte;
+ u32 *ptes;
debug("remapping SDRAM from 0x%08lx (size 0x%08lx)\n",
phys, mem->size);
@@ -132,20 +133,20 @@ static int arm_mmu_remap_sdram(struct arm_memory *mem)
if ((phys & (SZ_1M - 1)) || (mem->size & (SZ_1M - 1)))
return -EINVAL;
- mem->ptes = memalign(0x400, num_ptes * sizeof(u32));
+ ptes = memalign(0x400, num_ptes * sizeof(u32));
debug("ptes: 0x%p ttb_start: 0x%08lx ttb_end: 0x%08lx\n",
- mem->ptes, ttb_start, ttb_end);
+ ptes, ttb_start, ttb_end);
for (i = 0; i < num_ptes; i++) {
- mem->ptes[i] = (phys + i * 4096) | PTE_TYPE_SMALL |
+ ptes[i] = (phys + i * 4096) | PTE_TYPE_SMALL |
PTE_FLAGS_CACHED;
}
pte = 0;
for (i = ttb_start; i < ttb_end; i++) {
- ttb[i] = (unsigned long)(&mem->ptes[pte]) | PMD_TYPE_TABLE |
+ ttb[i] = (unsigned long)(&ptes[pte]) | PMD_TYPE_TABLE |
(0 << 4);
pte += 256;
}
diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h
index 93c2fe6..0729886 100644
--- a/arch/arm/include/asm/memory.h
+++ b/arch/arm/include/asm/memory.h
@@ -4,7 +4,6 @@
struct arm_memory {
struct list_head list;
struct device_d *dev;
- u32 *ptes;
unsigned long start;
unsigned long size;
};
--
1.7.6.3
More information about the barebox
mailing list