Changeset 3d77001 in rtems


Ignore:
Timestamp:
Feb 5, 2014, 2:15:51 PM (5 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
4.11, master
Children:
36a52ab
Parents:
3ef2d17
git-author:
Sebastian Huber <sebastian.huber@…> (02/05/14 14:15:51)
git-committer:
Sebastian Huber <sebastian.huber@…> (02/05/14 14:46:29)
Message:

bsp/leon3: Fix SMP initialization

Avoid usage of the same stack area by multiple secondary processors at
the same time.

Avoid magic delay loops.

Location:
c/src/lib/libbsp/sparc
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/leon3/include/leon.h

    r3ef2d17 r3d77001  
    311311int apbuart_inbyte_nonblocking(struct apbuart_regs *regs);
    312312
     313/**
     314 * @brief Initializes a secondary processor.
     315 *
     316 * @param[in] cpu The processor executing this function.
     317 */
     318void leon3_secondary_cpu_initialize(uint32_t cpu);
     319
    313320#endif /* !ASM */
    314321
  • c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c

    r3ef2d17 r3d77001  
    1414 */
    1515
    16 #include <rtems.h>
    1716#include <bsp.h>
     17#include <leon.h>
    1818#include <rtems/bspIo.h>
    1919#include <rtems/bspsmp.h>
     
    4141}
    4242
    43 static void leon3_secondary_cpu_initialize(void)
     43void leon3_secondary_cpu_initialize(uint32_t cpu)
    4444{
    45   uint32_t cpu = rtems_smp_get_current_processor();
    46 
    4745  sparc_leon3_set_cctrl( 0x80000F );
    4846  LEON_Unmask_interrupt(LEON3_MP_IRQ);
     
    5149  rtems_smp_secondary_cpu_initialize();
    5250}
    53 
    54 /*
    55  *  Used to pass information to start.S when bringing secondary CPUs
    56  *  out of reset.
    57  */
    58 void *bsp_ap_stack;
    59 void *bsp_ap_entry;
    6051
    6152static void bsp_smp_delay( int );
     
    8879  }
    8980
    90   for ( cpu=1 ; cpu < found_cpus ; cpu++ ) {
    91     const Per_CPU_Control *per_cpu = _Per_CPU_Get_by_index( cpu );
    92 
     81  for ( cpu = 1 ; cpu < found_cpus ; ++cpu ) {
    9382    #if defined(RTEMS_DEBUG)
    9483      printk( "Waking CPU %d\n", cpu );
    9584    #endif
    9685
    97     bsp_ap_stack = per_cpu->interrupt_stack_high -
    98                       CPU_MINIMUM_STACK_FRAME_SIZE;
    99     bsp_ap_entry = leon3_secondary_cpu_initialize;
     86    LEON3_IrqCtrl_Regs->mpstat = 1 << cpu;
     87  }
    10088
    101     LEON3_IrqCtrl_Regs->mpstat = 1 << cpu;
    102     bsp_smp_delay( 1000000 );
    103     #if defined(RTEMS_DEBUG)
    104       printk(
    105         "CPU %d is %s\n",
    106         cpu,
    107         per_cpu->state == PER_CPU_STATE_READY_TO_BEGIN_MULTITASKING ?
    108           "online" : "offline"
    109       );
    110     #endif
    111   }
    11289  return found_cpus;
    11390}
  • c/src/lib/libbsp/sparc/shared/start/start.S

    r3ef2d17 r3d77001  
    1717
    1818#include <rtems/asm.h>
    19 #include <rtems/system.h>
     19#include <rtems/score/percpu.h>
    2020#include <bspopts.h>
    2121
    2222#if defined(RTEMS_SMP) && defined(BSP_LEON3_SMP)
    23   #define ENABLE_SMP
     23  #define START_LEON3_ENABLE_SMP
    2424#endif
    2525
     
    3232  nop; \
    3333  nop;
    34 
    35 #if defined(ENABLE_SMP)
    36 /*
    37  * Variables to contain information used with bring a secondary core
    38  * out of reset.
    39  */
    40         .global bsp_ap_stack
    41         .global bsp_ap_entry
    42 #endif
    4334
    4435/*
     
    232223        nop
    233224
    234 #if defined(ENABLE_SMP)
    235         rd      %asr17, %g1
    236         srl     %g1, 28, %g1
    237         and     %g1, 0xff, %g1                  ! extract cpu id
    238         cmp     %g1, 0
     225#if defined(START_LEON3_ENABLE_SMP)
     226        rd      %asr17, %o0             ! get CPU identifier
     227        srl     %o0, 28, %o0            ! CPU index is upper 4 bits so shift
     228
     229        cmp     %o0, 0
    239230        beq     cpu0
    240         nop
    241         set     SYM(bsp_ap_stack), %g1          ! set the stack pointer
    242         ld      [%g1], %sp
    243         mov     %sp, %fp
    244         set     SYM(bsp_ap_entry), %g1          ! where to start
    245         ld      [%g1], %g1
    246         call    %g1
    247         nop
     231         nop
     232
     233        sethi   %hi(_Per_CPU_Information), %o1 ! get per-CPU control
     234        add     %o1, %lo(_Per_CPU_Information), %o1
     235        sll     %o0, PER_CPU_CONTROL_SIZE_LOG2, %o2
     236        add     %o1, %o2, %o1
     237
     238        ld      [%o1 + PER_CPU_INTERRUPT_STACK_HIGH], %sp ! set stack pointer
     239        sub     %sp, 4, %sp             ! stack starts at end of area - 4
     240        andn    %sp, 0x0f, %sp          ! align stack on 16-byte boundary
     241        mov     %sp, %fp                ! set frame pointer
     242
     243        call    SYM(leon3_secondary_cpu_initialize) ! does not return
     244         sub    %sp, CPU_MINIMUM_STACK_FRAME_SIZE, %sp
     245        ba      SYM(bsp_reset)          ! just in case
     246         nop
    248247cpu0:
    249248#endif
Note: See TracChangeset for help on using the changeset viewer.