source: rtems/c/src/lib/libbsp/sparc/leon3/smp/smp_leon3.c @ e644155a

4.115
Last change on this file since e644155a was e644155a, checked in by Sebastian Huber <sebastian.huber@…>, on 02/14/14 at 08:20:08

bsp/leon3: Do not define RTEMS_DEBUG

Move vital code out of debug section. Harmonize variable names with
other implementations.

  • Property mode set to 100644
File size: 2.5 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.com/license/LICENSE.
14 */
15
16#include <bsp.h>
17#include <leon.h>
18#include <rtems/bspIo.h>
19#include <rtems/bspsmp.h>
20#include <stdlib.h>
21
22static inline void sparc_leon3_set_cctrl( unsigned int val )
23{
24  __asm__ volatile( "sta %0, [%%g0] 2" : : "r" (val) );
25}
26
27static inline unsigned int sparc_leon3_get_cctrl( void )
28{
29  unsigned int v = 0;
30  __asm__ volatile( "lda [%%g0] 2, %0" : "=r" (v) : "0" (v) );
31  return v;
32}
33
34static rtems_isr bsp_ap_ipi_isr(
35  rtems_vector_number vector
36)
37{
38  rtems_smp_process_interrupt();
39}
40
41void leon3_secondary_cpu_initialize(uint32_t cpu)
42{
43  sparc_leon3_set_cctrl( 0x80000F );
44  LEON_Unmask_interrupt(LEON3_MP_IRQ);
45  LEON3_IrqCtrl_Regs->mask[cpu] |= 1 << LEON3_MP_IRQ;
46
47  rtems_smp_secondary_cpu_initialize();
48}
49
50uint32_t bsp_smp_initialize( uint32_t configured_cpu_count )
51{
52  uint32_t max_cpu_count;
53  uint32_t used_cpu_count;
54  uint32_t cpu;
55
56  sparc_leon3_set_cctrl( 0x80000F );
57
58  max_cpu_count =
59    ((LEON3_IrqCtrl_Regs->mpstat >> LEON3_IRQMPSTATUS_CPUNR) & 0xf)  + 1;
60  used_cpu_count = configured_cpu_count < max_cpu_count ?
61    configured_cpu_count : max_cpu_count;
62
63  #if defined(RTEMS_DEBUG)
64    printk( "Found %d CPUs\n", max_cpu_count );
65
66    if ( max_cpu_count > configured_cpu_count ) {
67      printk(
68        "%d CPUs IS MORE THAN CONFIGURED -- ONLY USING %d\n",
69        max_cpu_count,
70        configured_cpu_count
71      );
72    }
73  #endif
74
75  if ( used_cpu_count > 1 ) {
76    LEON_Unmask_interrupt(LEON3_MP_IRQ);
77    set_vector(bsp_ap_ipi_isr, LEON_TRAP_TYPE(LEON3_MP_IRQ), 1);
78  }
79
80  for ( cpu = 1 ; cpu < used_cpu_count ; ++cpu ) {
81    #if defined(RTEMS_DEBUG)
82      printk( "Waking CPU %d\n", cpu );
83    #endif
84
85    LEON3_IrqCtrl_Regs->mpstat = 1 << cpu;
86  }
87
88  return used_cpu_count;
89}
90
91void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
92{
93  /* send interrupt to destination CPU */
94  LEON3_IrqCtrl_Regs->force[target_processor_index] = 1 << LEON3_MP_IRQ;
95}
96
97void bsp_smp_broadcast_interrupt(void)
98{
99  uint32_t dest_cpu;
100  uint32_t cpu;
101  uint32_t max_cpus;
102
103  cpu = rtems_smp_get_current_processor();
104  max_cpus = rtems_smp_get_processor_count();
105
106  for ( dest_cpu=0 ; dest_cpu < max_cpus ; dest_cpu++ ) {
107    if ( cpu != dest_cpu ) {
108      _CPU_SMP_Send_interrupt( dest_cpu );
109    }
110  }
111}
Note: See TracBrowser for help on using the repository browser.