source: rtems/c/src/lib/libbsp/sparc/leon3/startup/bspsmp.c @ c34f94f7

4.115
Last change on this file since c34f94f7 was c34f94f7, checked in by Sebastian Huber <sebastian.huber@…>, on 02/16/15 at 10:55:03

score: Add _CPU_SMP_Prepare_start_multitasking()

Update #2268.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/**
2 * @file
3 * @ingroup sparc_leon3
4 * @brief LEON3 SMP BSP Support
5 */
6
7/*
8 *  COPYRIGHT (c) 1989-2011.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.org/license/LICENSE.
14 */
15
16#include <bsp.h>
17#include <bsp/bootcard.h>
18#include <bsp/fatal.h>
19#include <cache_.h>
20#include <leon.h>
21#include <rtems/bspIo.h>
22#include <rtems/score/smpimpl.h>
23#include <stdlib.h>
24
25#if !defined(__leon__) || defined(RTEMS_PARAVIRT)
26uint32_t _CPU_SMP_Get_current_processor( void )
27{
28  return _LEON3_Get_current_processor();
29}
30#endif
31
32static rtems_isr bsp_inter_processor_interrupt(
33  rtems_vector_number vector
34)
35{
36  _SMP_Inter_processor_interrupt_handler();
37}
38
39void bsp_start_on_secondary_processor()
40{
41  uint32_t cpu_index_self = _CPU_SMP_Get_current_processor();
42
43  /*
44   * If data cache snooping is not enabled we terminate using BSP_fatal_exit()
45   * instead of bsp_fatal().  This is done since the latter function tries to
46   * acquire a ticket lock, an operation which requires data cache snooping to
47   * be enabled.
48   */
49  if ( !leon3_data_cache_snooping_enabled() )
50    BSP_fatal_exit( LEON3_FATAL_INVALID_CACHE_CONFIG_SECONDARY_PROCESSOR );
51
52  /* Unmask IPI interrupts at Interrupt controller for this CPU */
53  LEON3_IrqCtrl_Regs->mask[cpu_index_self] |= 1U << LEON3_mp_irq;
54
55  _SMP_Start_multitasking_on_secondary_processor();
56}
57
58uint32_t _CPU_SMP_Initialize( void )
59{
60  if ( !leon3_data_cache_snooping_enabled() )
61    bsp_fatal( LEON3_FATAL_INVALID_CACHE_CONFIG_MAIN_PROCESSOR );
62
63  if ( rtems_configuration_get_maximum_processors() > 1 ) {
64    LEON_Unmask_interrupt(LEON3_mp_irq);
65    set_vector(bsp_inter_processor_interrupt, LEON_TRAP_TYPE(LEON3_mp_irq), 1);
66  }
67
68  return leon3_get_cpu_count(LEON3_IrqCtrl_Regs);
69}
70
71bool _CPU_SMP_Start_processor( uint32_t cpu_index )
72{
73  #if defined(RTEMS_DEBUG)
74    printk( "Waking CPU %d\n", cpu_index );
75  #endif
76
77  LEON3_IrqCtrl_Regs->mpstat = 1U << cpu_index;
78
79  return true;
80}
81
82void _CPU_SMP_Finalize_initialization( uint32_t cpu_count )
83{
84  (void) cpu_count;
85
86  /* Nothing to do */
87}
88
89void _CPU_SMP_Prepare_start_multitasking( void )
90{
91  _CPU_cache_invalidate_entire_instruction();
92}
93
94void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
95{
96  /* send interrupt to destination CPU */
97  LEON3_IrqCtrl_Regs->force[target_processor_index] = 1 << LEON3_mp_irq;
98}
Note: See TracBrowser for help on using the repository browser.