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

5
Last change on this file since 5f0a6376 was 5f0a6376, checked in by Sebastian Huber <sebastian.huber@…>, on 02/01/18 at 08:39:14

bsp/leon3: Do not use internal cache API

Update #3285.

  • 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 <leon.h>
20#include <rtems/bspIo.h>
21#include <rtems/score/smpimpl.h>
22#include <stdlib.h>
23
24#if !defined(__leon__) || defined(RTEMS_PARAVIRT)
25uint32_t _CPU_SMP_Get_current_processor( void )
26{
27  return _LEON3_Get_current_processor();
28}
29#endif
30
31static rtems_isr bsp_inter_processor_interrupt(
32  rtems_vector_number vector
33)
34{
35  _SMP_Inter_processor_interrupt_handler();
36}
37
38void bsp_start_on_secondary_processor()
39{
40  uint32_t cpu_index_self = _CPU_SMP_Get_current_processor();
41
42  /*
43   * If data cache snooping is not enabled we terminate using BSP_fatal_exit()
44   * instead of bsp_fatal().  This is done since the latter function tries to
45   * acquire a ticket lock, an operation which requires data cache snooping to
46   * be enabled.
47   */
48  if ( !leon3_data_cache_snooping_enabled() )
49    BSP_fatal_exit( LEON3_FATAL_INVALID_CACHE_CONFIG_SECONDARY_PROCESSOR );
50
51  /* Unmask IPI interrupts at Interrupt controller for this CPU */
52  LEON3_IrqCtrl_Regs->mask[cpu_index_self] |= 1U << LEON3_mp_irq;
53
54  _SMP_Start_multitasking_on_secondary_processor();
55}
56
57uint32_t _CPU_SMP_Initialize( void )
58{
59  if ( !leon3_data_cache_snooping_enabled() )
60    bsp_fatal( LEON3_FATAL_INVALID_CACHE_CONFIG_MAIN_PROCESSOR );
61
62  if ( rtems_configuration_get_maximum_processors() > 1 ) {
63    LEON_Unmask_interrupt(LEON3_mp_irq);
64    set_vector(bsp_inter_processor_interrupt, LEON_TRAP_TYPE(LEON3_mp_irq), 1);
65  }
66
67  return leon3_get_cpu_count(LEON3_IrqCtrl_Regs);
68}
69
70bool _CPU_SMP_Start_processor( uint32_t cpu_index )
71{
72  #if defined(RTEMS_DEBUG)
73    printk( "Waking CPU %d\n", cpu_index );
74  #endif
75
76  LEON3_IrqCtrl_Regs->mpstat = 1U << cpu_index;
77
78  return true;
79}
80
81void _CPU_SMP_Finalize_initialization( uint32_t cpu_count )
82{
83  (void) cpu_count;
84
85  /* Nothing to do */
86}
87
88void _CPU_SMP_Prepare_start_multitasking( void )
89{
90  rtems_cache_invalidate_entire_instruction();
91}
92
93void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
94{
95  /* send interrupt to destination CPU */
96  LEON3_IrqCtrl_Regs->force[target_processor_index] = 1 << LEON3_mp_irq;
97}
Note: See TracBrowser for help on using the repository browser.