summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Cederman <cederman@gaisler.com>2014-09-10 13:39:53 +0200
committerDaniel Hellstrom <daniel@gaisler.com>2014-09-10 13:48:27 +0200
commit58c122cd863f185fd0137a8607df91d6e27574d3 (patch)
treee483785e82071f374a0ff83df9eab539b2edc159
parent30ea723c26e417d8a6dc6fef9f684e35e7156da9 (diff)
bsp/sparc: Ensure that data cache snooping is enabledsmp-toolchain-5
Check that data cache snooping exists and is enabled on all cores.
-rw-r--r--c/src/lib/libbsp/shared/include/fatal.h2
-rw-r--r--c/src/lib/libbsp/sparc/leon3/include/leon.h12
-rw-r--r--c/src/lib/libbsp/sparc/leon3/startup/bspsmp.c15
3 files changed, 27 insertions, 2 deletions
diff --git a/c/src/lib/libbsp/shared/include/fatal.h b/c/src/lib/libbsp/shared/include/fatal.h
index c650a91b8b..640651cb27 100644
--- a/c/src/lib/libbsp/shared/include/fatal.h
+++ b/c/src/lib/libbsp/shared/include/fatal.h
@@ -50,6 +50,8 @@ typedef enum {
LEON3_FATAL_NO_IRQMP_CONTROLLER = BSP_FATAL_CODE_BLOCK(2),
LEON3_FATAL_CONSOLE_REGISTER_DEV,
LEON3_FATAL_CLOCK_INITIALIZATION,
+ LEON3_FATAL_INVALID_CACHE_CONFIG_MAIN_PROCESSOR,
+ LEON3_FATAL_INVALID_CACHE_CONFIG_SECONDARY_PROCESSOR,
/* LPC24XX fatal codes */
LPC24XX_FATAL_PL111_SET_UP = BSP_FATAL_CODE_BLOCK(3),
diff --git a/c/src/lib/libbsp/sparc/leon3/include/leon.h b/c/src/lib/libbsp/sparc/leon3/include/leon.h
index e2a05f4819..61afbc9567 100644
--- a/c/src/lib/libbsp/sparc/leon3/include/leon.h
+++ b/c/src/lib/libbsp/sparc/leon3/include/leon.h
@@ -119,6 +119,13 @@ extern "C" {
#define LEON_REG_UART_CTRL_FL 0x00000040 /* Flow control enable */
#define LEON_REG_UART_CTRL_LB 0x00000080 /* Loop Back enable */
+/*
+ * The following defines the bits in the LEON Cache Control Register.
+ */
+
+#define LEON3_REG_CACHE_CTRL_FI 0x00200000 /* Flush instruction cache */
+#define LEON3_REG_CACHE_CTRL_DS 0x00800000 /* Data cache snooping */
+
/* LEON3 Interrupt Controller */
extern volatile struct irqmp_regs *LEON3_IrqCtrl_Regs;
/* LEON3 GP Timer */
@@ -408,6 +415,11 @@ static inline uint32_t leon3_get_cache_control_register(void)
return leon3_get_system_register(0x0);
}
+static inline bool leon3_data_cache_snooping_enabled(void)
+{
+ return leon3_get_cache_control_register() & LEON3_REG_CACHE_CTRL_DS;
+}
+
static inline uint32_t leon3_get_inst_cache_config_register(void)
{
return leon3_get_system_register(0x8);
diff --git a/c/src/lib/libbsp/sparc/leon3/startup/bspsmp.c b/c/src/lib/libbsp/sparc/leon3/startup/bspsmp.c
index b90fb2f094..b924479f3d 100644
--- a/c/src/lib/libbsp/sparc/leon3/startup/bspsmp.c
+++ b/c/src/lib/libbsp/sparc/leon3/startup/bspsmp.c
@@ -15,6 +15,8 @@
#include <bsp.h>
#include <bsp/bootcard.h>
+#include <bsp/fatal.h>
+#include <cache_.h>
#include <leon.h>
#include <rtems/bspIo.h>
#include <rtems/score/smpimpl.h>
@@ -38,7 +40,15 @@ void bsp_start_on_secondary_processor()
{
uint32_t cpu_index_self = _CPU_SMP_Get_current_processor();
- leon3_set_cache_control_register(0x80000F);
+ /*
+ * If data cache snooping is not enabled we terminate using
+ * BSP_fatal_exit instead of bsp_fatal. This is done since
+ * the latter function tries to acquire a ticket lock, an
+ * operation which requires data cache snooping to be enabled.
+ */
+ if ( ! leon3_data_cache_snooping_enabled() )
+ BSP_fatal_exit( LEON3_FATAL_INVALID_CACHE_CONFIG_SECONDARY_PROCESSOR );
+
/* Unmask IPI interrupts at Interrupt controller for this CPU */
LEON3_IrqCtrl_Regs->mask[cpu_index_self] |= 1U << LEON3_MP_IRQ;
@@ -47,7 +57,8 @@ void bsp_start_on_secondary_processor()
uint32_t _CPU_SMP_Initialize( void )
{
- leon3_set_cache_control_register(0x80000F);
+ if ( ! leon3_data_cache_snooping_enabled() )
+ bsp_fatal( LEON3_FATAL_INVALID_CACHE_CONFIG_MAIN_PROCESSOR );
if ( rtems_configuration_get_maximum_processors() > 1 ) {
LEON_Unmask_interrupt(LEON3_MP_IRQ);