source: rtems/bsps/riscv/griscv/start/bspsmp.c @ d556af36

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

bsps: Always install IPI in SMP configs

The inter-processor interrupt (IPI) may be used to process per-CPU jobs.
See for example the blocked handler in T_interrupt_test().

Update #3199.

  • Property mode set to 100644
File size: 2.8 KB
Line 
1/*
2 * Copyright (c) 2018 embedded brains GmbH
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 *    notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 *    notice, this list of conditions and the following disclaimer in the
11 *    documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23 * SUCH DAMAGE.
24 */
25
26#include <bsp/bootcard.h>
27#include <bsp/irq.h>
28#include <amba.h>
29
30#include <rtems/score/riscv-utility.h>
31#include <rtems/score/smpimpl.h>
32
33static rtems_isr bsp_inter_processor_interrupt( void *v )
34{
35  _SMP_Inter_processor_interrupt_handler(_Per_CPU_Get());
36}
37
38void bsp_start_on_secondary_processor(Per_CPU_Control *cpu_self)
39{
40  uint32_t cpu_index_self;
41
42  cpu_index_self = _Per_CPU_Get_index(cpu_self);
43  GRLIB_IrqCtrl_Regs->mask[cpu_index_self] |= 1U << GRLIB_mp_irq;
44
45  if (
46    cpu_index_self < rtems_configuration_get_maximum_processors()
47      && _SMP_Should_start_processor(cpu_index_self)
48  ) {
49    set_csr(mie, MIP_MEIP);
50    _SMP_Start_multitasking_on_secondary_processor(cpu_self);
51  } else {
52    _CPU_Thread_Idle_body(0);
53  }
54}
55
56uint32_t _CPU_SMP_Initialize(void)
57{
58  GRLIB_Cpu_Unmask_interrupt(GRLIB_mp_irq, _CPU_SMP_Get_current_processor());
59
60  rtems_interrupt_handler_install(
61    GRLIB_mp_irq,
62    "IPI",
63    RTEMS_INTERRUPT_SHARED,
64    bsp_inter_processor_interrupt,
65    NULL
66  );
67
68  return grlib_get_cpu_count(GRLIB_IrqCtrl_Regs);
69}
70
71bool _CPU_SMP_Start_processor(uint32_t cpu_index)
72{
73  GRLIB_IrqCtrl_Regs->mpstat = 1U << cpu_index;
74
75  return true;
76}
77
78void _CPU_SMP_Finalize_initialization(uint32_t cpu_count)
79{
80  (void) cpu_count;
81//  set_csr(mie, MIP_MSIP);
82}
83
84void _CPU_SMP_Prepare_start_multitasking(void)
85{
86  /* Do nothing */
87}
88
89void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
90{
91 
92  GRLIB_IrqCtrl_Regs->force[target_processor_index] = 1 << GRLIB_mp_irq;
93
94}
Note: See TracBrowser for help on using the repository browser.