[PATCH 2/2] bsp/sparc: Flush only instruction cache

Daniel Cederman cederman at gaisler.com
Thu Jul 3 09:39:55 UTC 2014


The flush instruction on LEON flushes both the data and the instruction
cache. Flushing of just the instruction cache can be done by setting
the "flush instruction cache" bit in the cache control register.
---
 c/src/lib/libbsp/sparc/leon3/include/cache_.h |    4 +++-
 c/src/lib/libbsp/sparc/leon3/include/leon.h   |    1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/c/src/lib/libbsp/sparc/leon3/include/cache_.h b/c/src/lib/libbsp/sparc/leon3/include/cache_.h
index 70c1e2c..8339114 100644
--- a/c/src/lib/libbsp/sparc/leon3/include/cache_.h
+++ b/c/src/lib/libbsp/sparc/leon3/include/cache_.h
@@ -134,7 +134,9 @@ static inline void _CPU_cache_unfreeze_data(void)
 
 static inline void _CPU_cache_invalidate_entire_instruction(void)
 {
-  __asm__ volatile ("flush");
+  uint32_t cache_reg = leon3_get_cache_control_register();
+  cache_reg |= LEON3_REG_CACHE_CTRL_FI;
+  leon3_set_cache_control_register(cache_reg);
 }
 
 static inline void _CPU_cache_invalidate_instruction_range(
diff --git a/c/src/lib/libbsp/sparc/leon3/include/leon.h b/c/src/lib/libbsp/sparc/leon3/include/leon.h
index a62ad29..bc3cdde 100644
--- a/c/src/lib/libbsp/sparc/leon3/include/leon.h
+++ b/c/src/lib/libbsp/sparc/leon3/include/leon.h
@@ -90,6 +90,7 @@ extern "C" {
  *  The following defines the bits in the LEON Cache Control Register.
  */
 #define LEON3_REG_CACHE_CTRL_DS      0x00800000 /* Data cache snooping */
+#define LEON3_REG_CACHE_CTRL_FI      0x00200000 /* Flush instruction cache */
 
 /* LEON3 Interrupt Controller */
 extern volatile struct irqmp_regs *LEON3_IrqCtrl_Regs;
-- 
1.7.9.5




More information about the devel mailing list