RTEMS
bspsmp.c
Go to the documentation of this file.
1 
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)
25 uint32_t _CPU_SMP_Get_current_processor( void )
26 {
27  return _LEON3_Get_current_processor();
28 }
29 #endif
30 
31 static rtems_isr bsp_inter_processor_interrupt(
32  rtems_vector_number vector
33 )
34 {
36 }
37 
39 {
40  uint32_t cpu_index_self;
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  cpu_index_self = _Per_CPU_Get_index(cpu_self);
53  LEON3_IrqCtrl_Regs->mask[cpu_index_self] |= 1U << LEON3_mp_irq;
54 
56 }
57 
58 uint32_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  LEON_Unmask_interrupt(LEON3_mp_irq);
64  set_vector(bsp_inter_processor_interrupt, LEON_TRAP_TYPE(LEON3_mp_irq), 1);
65 
66  return leon3_get_cpu_count(LEON3_IrqCtrl_Regs);
67 }
68 
69 bool _CPU_SMP_Start_processor( uint32_t cpu_index )
70 {
71  #if defined(RTEMS_DEBUG)
72  printk( "Waking CPU %d\n", cpu_index );
73  #endif
74 
75  LEON3_IrqCtrl_Regs->mpstat = 1U << cpu_index;
76 
77  return true;
78 }
79 
80 void _CPU_SMP_Finalize_initialization( uint32_t cpu_count )
81 {
82  (void) cpu_count;
83 
84  /* Nothing to do */
85 }
86 
87 void _CPU_SMP_Prepare_start_multitasking( void )
88 {
90 }
91 
92 void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
93 {
94  /* send interrupt to destination CPU */
95  LEON3_IrqCtrl_Regs->force[target_processor_index] = 1 << LEON3_mp_irq;
96 }
void _SMP_Start_multitasking_on_secondary_processor(Per_CPU_Control *cpu_self) RTEMS_NO_RETURN
Performs high-level initialization of a secondary processor and runs the application threads...
Definition: smp.c:184
LEON3 BSP data types and macros.
Per CPU Core Structure.
Definition: percpu.h:347
void bsp_start_on_secondary_processor(Per_CPU_Control *cpu_self)
Standard start routine for secondary processors.
Definition: bspsmp.c:38
Interface to Kernel Print Methods.
void rtems_cache_invalidate_entire_instruction(void)
%
Definition: cacheimpl.h:365
ISR_Handler rtems_isr
%
Definition: intr.h:202
ISR_Vector_number rtems_vector_number
%
Definition: intr.h:90
static long unsigned _SMP_Inter_processor_interrupt_handler(Per_CPU_Control *cpu_self)
Interrupts handler for inter-processor interrupts.
Definition: smpimpl.h:138
SuperCore SMP Implementation.
int printk(const char *fmt,...) RTEMS_PRINTFLIKE(1
Kernel Print.