summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-02-27 08:32:52 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-02-28 09:06:19 +0100
commit80186ca8f418f5c461a7f9fd689bb7bcdc2e8d5e (patch)
tree3f8a8a4121c06aeee7d16d46388306fc20a0b483
parentrtems: Add cache size functions (diff)
downloadrtems-80186ca8f418f5c461a7f9fd689bb7bcdc2e8d5e.tar.bz2
bsp/leon3: Add and use cache register functions
-rw-r--r--c/src/lib/libbsp/sparc/leon3/include/leon.h42
-rw-r--r--c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c16
-rw-r--r--c/src/lib/libbsp/sparc/leon3/startup/bspstart.c9
3 files changed, 46 insertions, 21 deletions
diff --git a/c/src/lib/libbsp/sparc/leon3/include/leon.h b/c/src/lib/libbsp/sparc/leon3/include/leon.h
index a2c9bc6bc3..476ed5c848 100644
--- a/c/src/lib/libbsp/sparc/leon3/include/leon.h
+++ b/c/src/lib/libbsp/sparc/leon3/include/leon.h
@@ -357,6 +357,48 @@ static inline uint32_t leon3_get_cpu_count(
return ((mpstat >> LEON3_IRQMPSTATUS_CPUNR) & 0xf) + 1;
}
+static inline void leon3_set_system_register(uint32_t addr, uint32_t val)
+{
+ __asm__ volatile(
+ "sta %1, [%0] 2"
+ :
+ : "r" (addr), "r" (val)
+ );
+}
+
+static inline uint32_t leon3_get_system_register(uint32_t addr)
+{
+ uint32_t val;
+
+ __asm__ volatile(
+ "lda [%1] 2, %0"
+ : "=r" (val)
+ : "r" (addr)
+ );
+
+ return val;
+}
+
+static inline void leon3_set_cache_control_register(uint32_t val)
+{
+ leon3_set_system_register(0x0, val);
+}
+
+static inline uint32_t leon3_get_cache_control_register(void)
+{
+ return leon3_get_system_register(0x0);
+}
+
+static inline uint32_t leon3_get_inst_cache_config_register(void)
+{
+ return leon3_get_system_register(0x8);
+}
+
+static inline uint32_t leon3_get_data_cache_config_register(void)
+{
+ return leon3_get_system_register(0xc);
+}
+
#endif /* !ASM */
#ifdef __cplusplus
diff --git a/c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c b/c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c
index e8f6b6331c..1fb4957bb5 100644
--- a/c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c
+++ b/c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c
@@ -19,18 +19,6 @@
#include <rtems/score/smpimpl.h>
#include <stdlib.h>
-static inline void sparc_leon3_set_cctrl( unsigned int val )
-{
- __asm__ volatile( "sta %0, [%%g0] 2" : : "r" (val) );
-}
-
-static inline unsigned int sparc_leon3_get_cctrl( void )
-{
- unsigned int v = 0;
- __asm__ volatile( "lda [%%g0] 2, %0" : "=r" (v) : "0" (v) );
- return v;
-}
-
static rtems_isr bsp_inter_processor_interrupt(
rtems_vector_number vector
)
@@ -40,7 +28,7 @@ static rtems_isr bsp_inter_processor_interrupt(
void leon3_secondary_cpu_initialize(uint32_t cpu)
{
- sparc_leon3_set_cctrl( 0x80000F );
+ leon3_set_cache_control_register(0x80000F);
LEON_Unmask_interrupt(LEON3_MP_IRQ);
LEON3_IrqCtrl_Regs->mask[cpu] |= 1 << LEON3_MP_IRQ;
@@ -53,7 +41,7 @@ uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count )
uint32_t used_cpu_count;
uint32_t cpu;
- sparc_leon3_set_cctrl( 0x80000F );
+ leon3_set_cache_control_register(0x80000F);
max_cpu_count = leon3_get_cpu_count(LEON3_IrqCtrl_Regs);
used_cpu_count = configured_cpu_count < max_cpu_count ?
diff --git a/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c b/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
index 64ab4d81c9..5ecea6c881 100644
--- a/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
+++ b/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
@@ -32,7 +32,7 @@ uint32_t LEON3_Cpu_Index = 0;
/*
* set_snooping
*
- * Read the data cache configuration register to determine if
+ * Read the cache control register to determine if
* bus snooping is available and enabled. This is needed for some
* drivers so that they can select the most efficient copy routines.
*
@@ -40,12 +40,7 @@ uint32_t LEON3_Cpu_Index = 0;
static inline int set_snooping(void)
{
- int tmp;
- __asm__ (" lda [%%g0] 2, %0 "
- : "=r"(tmp)
- :
- );
- return (tmp >> 23) & 1;
+ return (leon3_get_cache_control_register() >> 23) & 1;
}
/*