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

4.115
Last change on this file since 93b000e was 93b000e, checked in by Daniel Cederman <cederman@…>, on Oct 1, 2014 at 11:53:03 AM

bsp/leon3: Replace the define LEON3_MP_IRQ with a weakly linked variable

The LEON3_MP_IRQ define is used to pick the IRQ to be used by the
shared memory driver and for inter-processor interrupts. On some LEON3
systems, for example the GR712RC, the default value of 14 is not suitable.
To make this value configurable from the application, it is replaced with
a weakly linked variable that can be overridden from the application.

  • Property mode set to 100644
File size: 2.2 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 <cache_.h>
19#include <leon.h>
20#include <rtems/bspIo.h>
21#include <rtems/score/smpimpl.h>
22#include <stdlib.h>
23
24/* Irq used by shared memory driver and for inter-processor interrupts.
25 * Can be overridden by being defined in the application.
26 */
27unsigned char LEON3_mp_irq __attribute__((weak)) = 14;
28
29#if !defined(__leon__) || defined(RTEMS_PARAVIRT)
30uint32_t _CPU_SMP_Get_current_processor( void )
31{
32  return _LEON3_Get_current_processor();
33}
34#endif
35
36static rtems_isr bsp_inter_processor_interrupt(
37  rtems_vector_number vector
38)
39{
40  _SMP_Inter_processor_interrupt_handler();
41}
42
43void bsp_start_on_secondary_processor()
44{
45  uint32_t cpu_index_self = _CPU_SMP_Get_current_processor();
46
47  leon3_set_cache_control_register(0x80000F);
48  /* Unmask IPI interrupts at Interrupt controller for this CPU */
49  LEON3_IrqCtrl_Regs->mask[cpu_index_self] |= 1U << LEON3_mp_irq;
50
51  _SMP_Start_multitasking_on_secondary_processor();
52}
53
54uint32_t _CPU_SMP_Initialize( void )
55{
56  leon3_set_cache_control_register(0x80000F);
57
58  if ( rtems_configuration_get_maximum_processors() > 1 ) {
59    LEON_Unmask_interrupt(LEON3_mp_irq);
60    set_vector(bsp_inter_processor_interrupt, LEON_TRAP_TYPE(LEON3_mp_irq), 1);
61  }
62
63  return leon3_get_cpu_count(LEON3_IrqCtrl_Regs);
64}
65
66bool _CPU_SMP_Start_processor( uint32_t cpu_index )
67{
68  #if defined(RTEMS_DEBUG)
69    printk( "Waking CPU %d\n", cpu_index );
70  #endif
71
72  LEON3_IrqCtrl_Regs->mpstat = 1U << cpu_index;
73
74  return true;
75}
76
77void _CPU_SMP_Finalize_initialization( uint32_t cpu_count )
78{
79  (void) cpu_count;
80
81  /* Nothing to do */
82}
83
84void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
85{
86  /* send interrupt to destination CPU */
87  LEON3_IrqCtrl_Regs->force[target_processor_index] = 1 << LEON3_mp_irq;
88}
89
90void _LEON3_Start_multitasking(
91  Context_Control *heir
92)
93{
94  _CPU_cache_invalidate_entire_instruction();
95  _CPU_Context_Restart_self( heir );
96}
Note: See TracBrowser for help on using the repository browser.