summaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2011-09-23 10:26:28 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2011-09-23 16:32:48 +0200
commitb4e4684958002255b311e27cb6b0b7fec7bf471e (patch)
tree50b207b214d8a9687dca264628d73e0b9a2fd355 /arch
parent0fc7fb6b4f5c992893d7cb33b0aa40c0ea7acc23 (diff)
downloadbarebox-b4e4684958002255b311e27cb6b0b7fec7bf471e.tar.gz
barebox-b4e4684958002255b311e27cb6b0b7fec7bf471e.tar.xz
ARM mmu: find second level descriptors by walking the page table
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@pengutronix.de>
Diffstat (limited to 'arch')
-rw-r--r--arch/arm/cpu/mmu.c39
-rw-r--r--arch/arm/include/asm/memory.h1
2 files changed, 20 insertions, 20 deletions
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index b6693495b6..6fa600ff84 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 93c2fe6007..0729886b82 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;
};