From: Ahmad Fatoum <a.fat...@pengutronix.de>

In preparation for moving the remapping of memory banks into the common
code, rename vectors_init to setup_trap_pages and export it for both
32-bit and 64-bit ARM, so it can be called from the common code as well.

This needs to happen after the remapping, because otherwise the trap
pages would be switched cached by the SDRAM remapping loop.

Signed-off-by: Ahmad Fatoum <a.fat...@pengutronix.de>
Signed-off-by: Ahmad Fatoum <a.fat...@barebox.org>
---
 arch/arm/cpu/mmu-common.c |  2 ++
 arch/arm/cpu/mmu-common.h |  1 +
 arch/arm/cpu/mmu_32.c     |  4 +---
 arch/arm/cpu/mmu_64.c     | 12 ++++++++----
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/arch/arm/cpu/mmu-common.c b/arch/arm/cpu/mmu-common.c
index f3416ae7f7ca..a55dce72a22d 100644
--- a/arch/arm/cpu/mmu-common.c
+++ b/arch/arm/cpu/mmu-common.c
@@ -95,6 +95,8 @@ static int mmu_init(void)
 
        __mmu_init(get_cr() & CR_M);
 
+       setup_trap_pages();
+
        return 0;
 }
 mmu_initcall(mmu_init);
diff --git a/arch/arm/cpu/mmu-common.h b/arch/arm/cpu/mmu-common.h
index 0f11a4b73d11..8d90da8c86fe 100644
--- a/arch/arm/cpu/mmu-common.h
+++ b/arch/arm/cpu/mmu-common.h
@@ -16,6 +16,7 @@ struct device;
 void dma_inv_range(void *ptr, size_t size);
 void dma_flush_range(void *ptr, size_t size);
 void *dma_alloc_map(struct device *dev, size_t size, dma_addr_t *dma_handle, 
unsigned flags);
+void setup_trap_pages(void);
 void __mmu_init(bool mmu_on);
 
 static inline void arm_mmu_not_initialized_error(void)
diff --git a/arch/arm/cpu/mmu_32.c b/arch/arm/cpu/mmu_32.c
index 80e302596890..3572fa70d13a 100644
--- a/arch/arm/cpu/mmu_32.c
+++ b/arch/arm/cpu/mmu_32.c
@@ -518,7 +518,7 @@ static void create_guard_page(void)
 /*
  * Map vectors and zero page
  */
-static void vectors_init(void)
+void setup_trap_pages(void)
 {
        create_guard_page();
 
@@ -595,8 +595,6 @@ void __mmu_init(bool mmu_on)
 
                remap_range((void *)pos, bank->start + bank->size - pos, 
MAP_CACHED);
        }
-
-       vectors_init();
 }
 
 /*
diff --git a/arch/arm/cpu/mmu_64.c b/arch/arm/cpu/mmu_64.c
index db312daafdd2..ba82528990fe 100644
--- a/arch/arm/cpu/mmu_64.c
+++ b/arch/arm/cpu/mmu_64.c
@@ -345,6 +345,14 @@ static void create_guard_page(void)
        pr_debug("Created guard page\n");
 }
 
+void setup_trap_pages(void)
+{
+       /* Vectors are already registered by aarch64_init_vectors */
+       /* Make zero page faulting to catch NULL pointer derefs */
+       zero_page_faulting();
+       create_guard_page();
+}
+
 /*
  * Prepare MMU for usage enable it.
  */
@@ -380,10 +388,6 @@ void __mmu_init(bool mmu_on)
 
                remap_range((void *)pos, bank->start + bank->size - pos, 
MAP_CACHED);
        }
-
-       /* Make zero page faulting to catch NULL pointer derefs */
-       zero_page_faulting();
-       create_guard_page();
 }
 
 void mmu_disable(void)
-- 
2.39.5


Reply via email to