From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 2/6] ARM: add early mmu cache flush function and use it in setup_c
Date: Mon, 4 Mar 2013 21:03:05 +0100 [thread overview]
Message-ID: <1362427389-2144-3-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1362427389-2144-1-git-send-email-s.hauer@pengutronix.de>
Since recently with MMU_EARLY support it may happen that setup_c
runs with data caches enabled, so we have to make sure the caches
are flushed before we jump to the new binary.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/cpu/cache.c | 33 +++++++++++++++++++++++++++++++++
arch/arm/cpu/setupc.S | 3 +++
arch/arm/include/asm/cache.h | 8 ++++++++
3 files changed, 44 insertions(+)
diff --git a/arch/arm/cpu/cache.c b/arch/arm/cpu/cache.c
index 1254609..95c8338 100644
--- a/arch/arm/cpu/cache.c
+++ b/arch/arm/cpu/cache.c
@@ -101,3 +101,36 @@ int arm_set_cache_functions(void)
return 0;
}
+
+/*
+ * Early function to flush the caches. This is for use when the
+ * C environment is not yet fully initialized.
+ */
+void arm_early_mmu_cache_flush(void)
+{
+ switch (arm_early_get_cpu_architecture()) {
+#ifdef CONFIG_CPU_32v4T
+ case CPU_ARCH_ARMv4T:
+ v4_mmu_cache_flush();
+ return;
+#endif
+#ifdef CONFIG_CPU_32v5
+ case CPU_ARCH_ARMv5:
+ case CPU_ARCH_ARMv5T:
+ case CPU_ARCH_ARMv5TE:
+ case CPU_ARCH_ARMv5TEJ:
+ v5_mmu_cache_flush();
+ return;
+#endif
+#ifdef CONFIG_CPU_32v6
+ case CPU_ARCH_ARMv6:
+ v6_mmu_cache_flush();
+ return;
+#endif
+#ifdef CONFIG_CPU_32v7
+ case CPU_ARCH_ARMv7:
+ v7_mmu_cache_flush();
+ return;
+#endif
+ }
+}
diff --git a/arch/arm/cpu/setupc.S b/arch/arm/cpu/setupc.S
index 9a8d54c..d0de87d 100644
--- a/arch/arm/cpu/setupc.S
+++ b/arch/arm/cpu/setupc.S
@@ -26,6 +26,9 @@ ENTRY(setup_c)
ldr r2, =__bss_stop
sub r2, r2, r0
bl memset /* clear bss */
+#ifdef CONFIG_MMU
+ bl arm_early_mmu_cache_flush
+#endif
mov r0, #0
mcr p15, 0, r0, c7, c5, 0 /* flush icache */
add lr, r5, r4 /* adjust return address to new location */
diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
index d5877ff..e5621eb 100644
--- a/arch/arm/include/asm/cache.h
+++ b/arch/arm/include/asm/cache.h
@@ -8,4 +8,12 @@ static inline void flush_icache(void)
int arm_set_cache_functions(void);
+#ifdef CONFIG_MMU
+void arm_early_mmu_cache_flush(void);
+#else
+static inline void arm_early_mmu_cache_flush(void)
+{
+}
+#endif
+
#endif
--
1.8.2.rc2
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2013-03-04 20:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-04 20:03 [PATCH] ARM: Add relocatable binary support Sascha Hauer
2013-03-04 20:03 ` [PATCH 1/6] ARM: make cpu architecture detection available as static inline function Sascha Hauer
2013-03-04 20:46 ` Alexander Aring
2013-03-05 10:34 ` Sascha Hauer
2013-03-04 20:03 ` Sascha Hauer [this message]
2013-03-04 20:03 ` [PATCH 3/6] ARM: provide accessor functions for linker variables Sascha Hauer
2013-03-04 20:03 ` [PATCH 4/6] ARM boards: Use accessor functions to access " Sascha Hauer
2013-03-04 20:03 ` [PATCH 5/6] ARN: fixup vector addresses for relocatable binaries Sascha Hauer
2013-03-04 20:03 ` [PATCH 6/6] ARM: Add relocatable binary support Sascha Hauer
2013-03-04 20:10 ` Alexander Shiyan
2013-03-04 20:19 ` Sascha Hauer
2013-03-05 4:32 ` Re[2]: " Alexander Shiyan
2013-03-05 7:25 ` Sascha Hauer
2013-03-04 20:53 ` Alexander Aring
2013-03-05 10:46 ` 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=1362427389-2144-3-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