[PATCH 1/2] bsp/sparc: Ensure that data cache snooping is enabled

Joel Sherrill joel.sherrill at oarcorp.com
Thu Jul 3 15:58:04 UTC 2014


OK besides style comments.
On 7/3/2014 4:39 AM, Daniel Cederman wrote:
> Check that data cache snooping exists and is enabled on all cores.
> ---
>  c/src/lib/libbsp/shared/include/fatal.h       |    1 +
>  c/src/lib/libbsp/sparc/leon3/include/leon.h   |   10 ++++++++++
>  c/src/lib/libbsp/sparc/leon3/startup/bspsmp.c |    8 ++++++--
>  3 files changed, 17 insertions(+), 2 deletions(-)
>
> diff --git a/c/src/lib/libbsp/shared/include/fatal.h b/c/src/lib/libbsp/shared/include/fatal.h
> index e928bba..1cf3c60 100644
> --- a/c/src/lib/libbsp/shared/include/fatal.h
> +++ b/c/src/lib/libbsp/shared/include/fatal.h
> @@ -49,6 +49,7 @@ typedef enum {
>    /* LEON3 fatal codes */
>    LEON3_FATAL_NO_IRQMP_CONTROLLER = BSP_FATAL_CODE_BLOCK(2),
>    LEON3_FATAL_CONSOLE_REGISTER_DEV,
> +  LEON3_FATAL_INVALID_CACHE_CONFIG,
>  
>    /* 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 d7048f3..a62ad29 100644
> --- a/c/src/lib/libbsp/sparc/leon3/include/leon.h
> +++ b/c/src/lib/libbsp/sparc/leon3/include/leon.h
> @@ -86,6 +86,11 @@ extern "C" {
>  #define LEON_REG_TIMER_CONTROL_LD    0x00000004  /* 1 = load counter */
>                                                /* 0 = no function */
>  
> +/*
> + *  The following defines the bits in the LEON Cache Control Register.
> + */
> +#define LEON3_REG_CACHE_CTRL_DS      0x00800000 /* Data cache snooping */
> +
>  /* LEON3 Interrupt Controller */
>  extern volatile struct irqmp_regs *LEON3_IrqCtrl_Regs;
>  /* LEON3 GP Timer */
> @@ -347,6 +352,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 9166ad5..7382bd1 100644
> --- a/c/src/lib/libbsp/sparc/leon3/startup/bspsmp.c
> +++ b/c/src/lib/libbsp/sparc/leon3/startup/bspsmp.c
> @@ -15,6 +15,7 @@
>  
>  #include <bsp.h>
>  #include <bsp/bootcard.h>
> +#include <bsp/fatal.h>
>  #include <cache_.h>
>  #include <leon.h>
>  #include <rtems/bspIo.h>
> @@ -39,7 +40,9 @@ void bsp_start_on_secondary_processor()
>  {
>    uint32_t cpu_index_self = _CPU_SMP_Get_current_processor();
>  
> -  leon3_set_cache_control_register(0x80000F);
> +  if( ! leon3_data_cache_snooping_enabled() )
> +    BSP_fatal_exit( LEON3_FATAL_INVALID_CACHE_CONFIG );
> +
if ( not if(
>    /* Unmask IPI interrupts at Interrupt controller for this CPU */
>    LEON3_IrqCtrl_Regs->mask[cpu_index_self] |= 1U << LEON3_MP_IRQ;
>  
> @@ -48,7 +51,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 );
if ( not if(
>  
>    if ( rtems_configuration_get_maximum_processors() > 1 ) {
>      LEON_Unmask_interrupt(LEON3_MP_IRQ);

-- 
Joel Sherrill, Ph.D.             Director of Research & Development
joel.sherrill at OARcorp.com        On-Line Applications Research
Ask me about RTEMS: a free RTOS  Huntsville AL 35805
Support Available                (256) 722-9985




More information about the devel mailing list