From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 1/3] ARM: create a second level page table entry for the exception vectors
Date: Tue, 8 Mar 2011 12:24:50 +0100 [thread overview]
Message-ID: <1299583492-29504-2-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1299583492-29504-1-git-send-email-s.hauer@pengutronix.de>
Often enough the exception vectors are not on TEXT_BASE (for example
on i.MX SoCs in internal boot mode), so the board specific code did
not map the exception vectors to 0x0 but whatever happens to be on
TEXT_BASE. Also, the current section-only mapping requires the
exception vectors to be on a 1MB boundary.
Instead, create the possibility to create second level tables and
use this to map a copy of the exception vectors in a board
independent way.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/boards/chumby_falconwing/falconwing.c | 5 --
arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c | 5 --
arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c | 5 --
arch/arm/boards/freescale-mx51-pdk/board.c | 6 ---
arch/arm/boards/guf-cupid/board.c | 6 ---
arch/arm/boards/guf-neso/board.c | 5 --
arch/arm/boards/karo-tx28/tx28.c | 5 --
arch/arm/boards/pcm037/pcm037.c | 5 --
arch/arm/boards/pcm038/pcm038.c | 5 --
arch/arm/boards/pcm043/pcm043.c | 6 ---
arch/arm/boards/phycard-i.MX27/pca100.c | 5 --
arch/arm/cpu/mmu.c | 48 +++++++++++++++++++++
12 files changed, 48 insertions(+), 58 deletions(-)
diff --git a/arch/arm/boards/chumby_falconwing/falconwing.c b/arch/arm/boards/chumby_falconwing/falconwing.c
index d46431c..6de8e28 100644
--- a/arch/arm/boards/chumby_falconwing/falconwing.c
+++ b/arch/arm/boards/chumby_falconwing/falconwing.c
@@ -292,11 +292,6 @@ static int falconwing_mmu_init(void)
setup_dma_coherent(0x10000000);
-#if TEXT_BASE & (0x100000 - 1)
-#warning cannot create vector section. Adjust TEXT_BASE to a 1M boundary
-#else
- arm_create_section(0x0, TEXT_BASE, 1, PMD_SECT_DEF_UNCACHED);
-#endif
mmu_enable();
return 0;
diff --git a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
index 4567cba..a7e9951 100644
--- a/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
+++ b/arch/arm/boards/eukrea_cpuimx27/eukrea_cpuimx27.c
@@ -153,11 +153,6 @@ static void eukrea_cpuimx27_mmu_init(void)
setup_dma_coherent(0x10000000);
-#if TEXT_BASE & (0x100000 - 1)
-#warning cannot create vector section. Adjust TEXT_BASE to a 1M boundary
-#else
- arm_create_section(0x0, TEXT_BASE, 1, PMD_SECT_DEF_UNCACHED);
-#endif
mmu_enable();
}
#else
diff --git a/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c b/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
index f377793..73bb2e1 100644
--- a/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
+++ b/arch/arm/boards/eukrea_cpuimx35/eukrea_cpuimx35.c
@@ -161,11 +161,6 @@ static int eukrea_cpuimx35_mmu_init(void)
setup_dma_coherent(0x10000000);
-#if TEXT_BASE & (0x100000 - 1)
-#warning cannot create vector section. Adjust TEXT_BASE to a 1M boundary
-#else
- arm_create_section(0x0, TEXT_BASE, 1, PMD_SECT_DEF_UNCACHED);
-#endif
mmu_enable();
#ifdef CONFIG_CACHE_L2X0
diff --git a/arch/arm/boards/freescale-mx51-pdk/board.c b/arch/arm/boards/freescale-mx51-pdk/board.c
index ff779ca..35d6153 100644
--- a/arch/arm/boards/freescale-mx51-pdk/board.c
+++ b/arch/arm/boards/freescale-mx51-pdk/board.c
@@ -96,12 +96,6 @@ static void babbage_mmu_init(void)
setup_dma_coherent(0x20000000);
-#if TEXT_BASE & (0x100000 - 1)
-#warning cannot create vector section. Adjust TEXT_BASE to a 1M boundary
-#else
- arm_create_section(0x0, TEXT_BASE, 1, PMD_SECT_DEF_UNCACHED);
-#endif
-
mmu_enable();
}
#else
diff --git a/arch/arm/boards/guf-cupid/board.c b/arch/arm/boards/guf-cupid/board.c
index e30f8e5..d04af78 100644
--- a/arch/arm/boards/guf-cupid/board.c
+++ b/arch/arm/boards/guf-cupid/board.c
@@ -145,12 +145,6 @@ static int cupid_mmu_init(void)
setup_dma_coherent(0x10000000);
-#if TEXT_BASE & (0x100000 - 1)
-#warning cannot create vector section. Adjust TEXT_BASE to a 1M boundary
-#else
- arm_create_section(0x0, TEXT_BASE, 1, PMD_SECT_DEF_UNCACHED);
-#endif
-
mmu_enable();
#ifdef CONFIG_CACHE_L2X0
diff --git a/arch/arm/boards/guf-neso/board.c b/arch/arm/boards/guf-neso/board.c
index d371dd6..c4b2fa1 100644
--- a/arch/arm/boards/guf-neso/board.c
+++ b/arch/arm/boards/guf-neso/board.c
@@ -167,11 +167,6 @@ static void neso_mmu_init(void)
setup_dma_coherent(0x10000000);
-#if TEXT_BASE & (0x100000 - 1)
-#warning cannot create vector section. Adjust TEXT_BASE to a 1M boundary
-#else
- arm_create_section(0x0, TEXT_BASE, 1, PMD_SECT_DEF_UNCACHED);
-#endif
mmu_enable();
}
#else
diff --git a/arch/arm/boards/karo-tx28/tx28.c b/arch/arm/boards/karo-tx28/tx28.c
index 5692171..1f47a8d 100644
--- a/arch/arm/boards/karo-tx28/tx28.c
+++ b/arch/arm/boards/karo-tx28/tx28.c
@@ -93,11 +93,6 @@ static int tx28_mmu_init(void)
setup_dma_coherent(0x10000000);
-#if TEXT_BASE & (0x100000 - 1)
-#warning cannot create vector section. Adjust TEXT_BASE to a 1M boundary
-#else
- arm_create_section(0x0, TEXT_BASE, 1, PMD_SECT_DEF_UNCACHED);
-#endif
mmu_enable();
return 0;
diff --git a/arch/arm/boards/pcm037/pcm037.c b/arch/arm/boards/pcm037/pcm037.c
index ffecec2..cb4ffe6 100644
--- a/arch/arm/boards/pcm037/pcm037.c
+++ b/arch/arm/boards/pcm037/pcm037.c
@@ -239,11 +239,6 @@ static void pcm037_mmu_init(void)
setup_dma_coherent(0x10000000);
-#if TEXT_BASE & (0x100000 - 1)
-#warning cannot create vector section. Adjust TEXT_BASE to a 1M boundary
-#else
- arm_create_section(0x0, TEXT_BASE, 1, PMD_SECT_DEF_UNCACHED);
-#endif
mmu_enable();
#ifdef CONFIG_CACHE_L2X0
diff --git a/arch/arm/boards/pcm038/pcm038.c b/arch/arm/boards/pcm038/pcm038.c
index 1dbc6b6..3ca6650 100644
--- a/arch/arm/boards/pcm038/pcm038.c
+++ b/arch/arm/boards/pcm038/pcm038.c
@@ -179,11 +179,6 @@ static void pcm038_mmu_init(void)
setup_dma_coherent(0x10000000);
-#if TEXT_BASE & (0x100000 - 1)
-#warning cannot create vector section. Adjust TEXT_BASE to a 1M boundary
-#else
- arm_create_section(0x0, TEXT_BASE, 1, PMD_SECT_DEF_UNCACHED);
-#endif
mmu_enable();
}
#else
diff --git a/arch/arm/boards/pcm043/pcm043.c b/arch/arm/boards/pcm043/pcm043.c
index 36bde45..7db3c83 100644
--- a/arch/arm/boards/pcm043/pcm043.c
+++ b/arch/arm/boards/pcm043/pcm043.c
@@ -133,12 +133,6 @@ static int pcm043_mmu_init(void)
setup_dma_coherent(0x10000000);
-#if TEXT_BASE & (0x100000 - 1)
-#warning cannot create vector section. Adjust TEXT_BASE to a 1M boundary
-#else
- arm_create_section(0x0, TEXT_BASE, 1, PMD_SECT_DEF_UNCACHED);
-#endif
-
mmu_enable();
#ifdef CONFIG_CACHE_L2X0
diff --git a/arch/arm/boards/phycard-i.MX27/pca100.c b/arch/arm/boards/phycard-i.MX27/pca100.c
index c539ea1..89c0a14 100644
--- a/arch/arm/boards/phycard-i.MX27/pca100.c
+++ b/arch/arm/boards/phycard-i.MX27/pca100.c
@@ -106,11 +106,6 @@ static void pca100_mmu_init(void)
setup_dma_coherent(0x10000000);
-#if TEXT_BASE & (0x100000 - 1)
-#warning cannot create vector section. Adjust TEXT_BASE to a 1M boundary
-#else
- arm_create_section(0x0, TEXT_BASE, 1, PMD_SECT_DEF_UNCACHED);
-#endif
mmu_enable();
}
#else
diff --git a/arch/arm/cpu/mmu.c b/arch/arm/cpu/mmu.c
index df664f6..593e39c 100644
--- a/arch/arm/cpu/mmu.c
+++ b/arch/arm/cpu/mmu.c
@@ -24,6 +24,52 @@ void arm_create_section(unsigned long virt, unsigned long phys, int size_m,
}
/*
+ * Create a second level translation table for the given virtual address.
+ * We initially create a flat uncached mapping on it.
+ * Not yet exported, but may be later if someone finds use for it.
+ */
+static u32 *arm_create_pte(unsigned long virt)
+{
+ u32 *table;
+ int i;
+
+ table = memalign(0x400, 0x400);
+
+ ttb[virt] = (unsigned long)table | PMD_TYPE_TABLE;
+
+ for (i = 0; i < 256; i++)
+ table[i] = virt | PTE_TYPE_SMALL | PTE_SMALL_AP_UNO_SRW;
+
+ return table;
+}
+
+/*
+ * We have 8 exception vectors and the table consists of absolute
+ * jumps, so we need 8 * 4 bytes for the instructions and another
+ * 8 * 4 bytes for the addresses.
+ */
+#define ARM_VECTORS_SIZE (sizeof(u32) * 8 * 2)
+
+/*
+ * Allocate a page, map it to the zero page and copy our exception
+ * vectors there.
+ */
+static void vectors_init(void)
+{
+ u32 *exc;
+ void *vectors;
+ extern unsigned long exception_vectors;
+
+ exc = arm_create_pte(0x0);
+
+ vectors = xmemalign(PAGE_SIZE, PAGE_SIZE);
+ memset(vectors, 0, PAGE_SIZE);
+ memcpy(vectors, &exception_vectors, ARM_VECTORS_SIZE);
+
+ exc[0] = (u32)vectors | PTE_TYPE_SMALL | PTE_SMALL_AP_UNO_SRW;
+}
+
+/*
* Prepare MMU for usage and create a flat mapping. Board
* code is responsible to remap the SDRAM cached
*/
@@ -43,6 +89,8 @@ void mmu_init(void)
/* create a flat mapping */
arm_create_section(0, 0, 4096, PMD_SECT_AP_WRITE | PMD_SECT_AP_READ | PMD_TYPE_SECT);
+
+ vectors_init();
}
/*
--
1.7.2.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2011-03-08 11:25 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-08 11:24 [PATCH] ARM stack unwinding support Sascha Hauer
2011-03-08 11:24 ` Sascha Hauer [this message]
2011-03-08 11:24 ` [PATCH 2/3] ARM: Add " Sascha Hauer
2011-03-08 11:37 ` Baruch Siach
2011-03-08 11:40 ` Sascha Hauer
2011-03-08 15:14 ` Sascha Hauer
2011-03-08 11:24 ` [PATCH 3/3] kallsyms/printk: enable symbol printing support (%pS) 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=1299583492-29504-2-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