mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 10/12] ARM mmu: find second level descriptors by walking the page table
Date: Fri, 23 Sep 2011 11:24:18 +0200	[thread overview]
Message-ID: <1316769860-24549-11-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1316769860-24549-1-git-send-email-s.hauer@pengutronix.de>

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>
---
 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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  parent reply	other threads:[~2011-09-23  9:24 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-23  9:24 patches for next Sascha Hauer
2011-09-23  9:24 ` [PATCH 01/12] introduce io.h Sascha Hauer
2011-09-23  9:24 ` [PATCH 02/12] introduce asm-generic/io.h Sascha Hauer
2011-09-23  9:24 ` [PATCH 03/12] arm: use asm-generic/io.h Sascha Hauer
2011-09-23  9:24 ` [PATCH 04/12] Jean-christophe, more careful please Sascha Hauer
2011-09-23 12:43   ` Jean-Christophe PLAGNIOL-VILLARD
2011-09-23 14:29     ` Sascha Hauer
2011-09-23 14:33       ` Sascha Hauer
2011-09-23  9:24 ` [PATCH 05/12] add cpu native ordered io accessors Sascha Hauer
2011-09-23  9:24 ` [PATCH 06/12] cfi flash: use cpu native accessors Sascha Hauer
2011-09-23  9:24 ` [PATCH 07/12] ppc pcm030: remove puts in early init Sascha Hauer
2011-09-23  9:24 ` [PATCH 08/12] cfi flash: fix flash_make_cmd for big endian access Sascha Hauer
2011-09-23  9:26   ` Sascha Hauer
2011-09-23 14:05     ` Teresa Gamez
2011-09-23 14:27       ` Sascha Hauer
2011-09-23  9:24 ` [PATCH 09/12] rename include/mem_malloc.h to include/memory.h Sascha Hauer
2011-09-23  9:24 ` Sascha Hauer [this message]
2011-09-23  9:24 ` [PATCH 11/12] introduce generic memory bank handling Sascha Hauer
2011-09-23  9:24 ` [PATCH 12/12] ARM: switch to generic memory banks Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1316769860-24549-11-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox