blob: 59861b344bf83731b091b79b9c20ebfd5ad074d8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/**
* @file
* @ingroup sparc_leon3
* @brief LEON3 SMP BSP Support
*/
/*
* COPYRIGHT (c) 1989-2011.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rtems.com/license/LICENSE.
*/
#include <bsp.h>
#include <leon.h>
#include <rtems/bspIo.h>
#include <rtems/score/smpimpl.h>
#include <stdlib.h>
static inline void sparc_leon3_set_cctrl( unsigned int val )
{
__asm__ volatile( "sta %0, [%%g0] 2" : : "r" (val) );
}
static inline unsigned int sparc_leon3_get_cctrl( void )
{
unsigned int v = 0;
__asm__ volatile( "lda [%%g0] 2, %0" : "=r" (v) : "0" (v) );
return v;
}
static rtems_isr bsp_inter_processor_interrupt(
rtems_vector_number vector
)
{
_SMP_Inter_processor_interrupt_handler();
}
void leon3_secondary_cpu_initialize(uint32_t cpu)
{
sparc_leon3_set_cctrl( 0x80000F );
LEON_Unmask_interrupt(LEON3_MP_IRQ);
LEON3_IrqCtrl_Regs->mask[cpu] |= 1 << LEON3_MP_IRQ;
_SMP_Start_multitasking_on_secondary_processor();
}
uint32_t _CPU_SMP_Initialize( uint32_t configured_cpu_count )
{
uint32_t max_cpu_count;
uint32_t used_cpu_count;
uint32_t cpu;
sparc_leon3_set_cctrl( 0x80000F );
max_cpu_count =
((LEON3_IrqCtrl_Regs->mpstat >> LEON3_IRQMPSTATUS_CPUNR) & 0xf) + 1;
used_cpu_count = configured_cpu_count < max_cpu_count ?
configured_cpu_count : max_cpu_count;
#if defined(RTEMS_DEBUG)
printk( "Found %d CPUs\n", max_cpu_count );
if ( max_cpu_count > configured_cpu_count ) {
printk(
"%d CPUs IS MORE THAN CONFIGURED -- ONLY USING %d\n",
max_cpu_count,
configured_cpu_count
);
}
#endif
if ( used_cpu_count > 1 ) {
LEON_Unmask_interrupt(LEON3_MP_IRQ);
set_vector(bsp_inter_processor_interrupt, LEON_TRAP_TYPE(LEON3_MP_IRQ), 1);
}
for ( cpu = 1 ; cpu < used_cpu_count ; ++cpu ) {
#if defined(RTEMS_DEBUG)
printk( "Waking CPU %d\n", cpu );
#endif
LEON3_IrqCtrl_Regs->mpstat = 1 << cpu;
}
return used_cpu_count;
}
void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
{
/* send interrupt to destination CPU */
LEON3_IrqCtrl_Regs->force[target_processor_index] = 1 << LEON3_MP_IRQ;
}
|