[PR 05] LEON3: CPU index intialization moved to bspstart.c

Gedare Bloom gedare at rtems.org
Thu Feb 2 15:56:17 UTC 2012


On Thu, Feb 2, 2012 at 10:50 AM, Daniel Hellstrom <daniel at gaisler.com> wrote:
> On 02/02/2012 04:45 PM, Gedare Bloom wrote:
>>
>> On Thu, Feb 2, 2012 at 9:46 AM, Daniel Hellstrom<daniel at gaisler.com>
>>  wrote:
>>>
>>> All LEON3/4 systems have a CPU-id, if on a single-CPU system the
>>> ID is always zero. On a multicore system it ranges from 0 to 15.
>>>
>>> The CPU index should always by updated even in a non-MP RTEMS OS
>>> since the CPU running RTEMS may not always be CPU0. For example
>>> when RTEMS runs on CPU1 and Linux on CPU0 in a mixed ASMP system.
>>>
>>> The old code executed within the IRQ controller initialization code
>>> makes no sense since the ASR register is a CPU register, it has
>>> nothing to do with AMBA initialization either.
>>>
>>> Signed-off-by: Daniel Hellstrom<daniel at gaisler.com>
>>> ---
>>>  c/src/lib/libbsp/sparc/leon3/amba/amba.c        |   18
>>> ------------------
>>>  c/src/lib/libbsp/sparc/leon3/startup/bspstart.c |   18
>>> ++++++++++++++++++
>>>  2 files changed, 18 insertions(+), 18 deletions(-)
>>>
>>> diff --git a/c/src/lib/libbsp/sparc/leon3/amba/amba.c
>>> b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
>>> index 1932cee..b0a43f9 100644
>>> --- a/c/src/lib/libbsp/sparc/leon3/amba/amba.c
>>> +++ b/c/src/lib/libbsp/sparc/leon3/amba/amba.c
>>> @@ -21,8 +21,6 @@ amba_confarea_type amba_conf;
>>>  /* Pointers to Interrupt Controller configuration registers */
>>>  volatile LEON3_IrqCtrl_Regs_Map *LEON3_IrqCtrl_Regs;
>>>
>>> -int LEON3_Cpu_Index = 0;
>>> -
>>>  /*
>>>  *  amba_initialize
>>>  *
>>> @@ -33,16 +31,6 @@ int LEON3_Cpu_Index = 0;
>>>  *  amba_ahb_masters, amba_ahb_slaves and amba.
>>>  */
>>>
>>> -unsigned int getasr17(void);
>>> -
>>> -__asm__ (" .text  \n"
>>> -    "getasr17:   \n"
>>> -    "retl \n"
>>> -    "mov %asr17, %o0\n"
>>> -);
>>> -
>>> -
>>> -extern rtems_configuration_table Configuration;
>>>  extern int scan_uarts(void);
>>>
>>>  void amba_initialize(void)
>>> @@ -58,12 +46,6 @@ void amba_initialize(void)
>>>   if ( i>  0 ){
>>>     /* Found APB IRQ_MP Interrupt Controller */
>>>     LEON3_IrqCtrl_Regs = (volatile LEON3_IrqCtrl_Regs_Map *) dev.start;
>>> -#if defined(RTEMS_MULTIPROCESSING)
>>> -      if (rtems_configuration_get_user_multiprocessing_table() != NULL)
>>> {
>>> -        unsigned int tmp = getasr17();
>>> -        LEON3_Cpu_Index = (tmp>>  28)&  3;
>>>
>>> -      }
>>> -#endif
>>>   }
>>>
>>>   /* find GP Timer */
>>> diff --git a/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
>>> b/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
>>> index a4b9ffa..82054e8 100644
>>> --- a/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
>>> +++ b/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c
>>> @@ -27,6 +27,9 @@
>>>  */
>>>  int CPU_SPARC_HAS_SNOOPING;
>>>
>>> +/* Index of CPU, in an AMP system CPU-index may be non-zero */
>>> +int LEON3_Cpu_Index = 0;
>>> +
>>>  extern void amba_initialize(void);
>>>
>>>  /*
>>> @@ -48,6 +51,14 @@ static inline int set_snooping(void)
>>>   return (tmp>>  27)&  1;
>>>
>>>  }
>>>
>>> +/* ASM-function used to get the CPU-Index on calling LEON3 CPUs */
>>> +static inline unsigned int get_asr17(void)
>>> +{
>>> +  unsigned int reg;
>>> +  __asm__ (" mov %%asr17, %0 " : "=r"(reg) :);
>>> +  return reg;
>>> +}
>>
>> Might get_asr17 make sense as a function defined by
>> cpukit/score/cpu/sparc/rtems/score/sparc.h? Or is it really only
>> useful for getting the cpu index as used below?
>>
>>> +
>>>  /*
>>>  *  bsp_start
>>>  *
>>> @@ -57,6 +68,13 @@ void bsp_start( void )
>>>  {
>>>   CPU_SPARC_HAS_SNOOPING = set_snooping();
>>>
>>> +  /* Get the LEON3 CPU index, normally 0, but for MP systems we do
>>> +   * _not_ assume that this is CPU0. One may run another OS on CPU0
>>> +   * and RTEMS on this CPU, and AMP system with mixed operating
>>> +   * systems
>>> +   */
>>> +  LEON3_Cpu_Index = (get_asr17()>>  28)&  3;
>>
>> Would it make sense to also define something like
>> sparc_get_cpu_index()? Or does it only ever need to be done during bsp
>> initialization?
>
> Yes, that makes sens, but perhaps in a separate "clean patch" for HEAD? This
> is the way the code was code first time:
>
OK.

>
> -      if (rtems_configuration_get_user_multiprocessing_table() != NULL) {
> -        unsigned int tmp = getasr17();
> -        LEON3_Cpu_Index = (tmp>>  28)&  3;
> -      }
>
>
>>> +
>>>   /* Find UARTs */
>>>   amba_initialize();
>>>  }
>>> --
>>> 1.7.0.4
>>>
>>> _______________________________________________
>>> rtems-devel mailing list
>>> rtems-devel at rtems.org
>>> http://www.rtems.org/mailman/listinfo/rtems-devel
>>
>>
>




More information about the devel mailing list