source: rtems/c/src/lib/libbsp/arm/altera-cyclone-v/startup/bspsmp.c @ 2a1d86c

4.115
Last change on this file since 2a1d86c was 2a1d86c, checked in by Sebastian Huber <sebastian.huber@…>, on 06/05/14 at 08:03:06

bsp/altera-cyclone-v: Move SMP support

  • Property mode set to 100644
File size: 1.9 KB
Line 
1/*
2 * Copyright (c) 2013-2014 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <info@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#include <assert.h>
16
17#include <rtems/score/smpimpl.h>
18
19#include <libcpu/arm-cp15.h>
20
21#include <bsp/irq.h>
22#include <bsp/linker-symbols.h>
23#include <bsp/start.h>
24
25#include <socal/alt_rstmgr.h>
26#include <socal/alt_sysmgr.h>
27#include <socal/hps.h>
28#include <socal/socal.h>
29
30static void bsp_inter_processor_interrupt(void *arg)
31{
32  _SMP_Inter_processor_interrupt_handler();
33}
34
35uint32_t _CPU_SMP_Initialize(void)
36{
37  uint32_t hardware_count = arm_gic_irq_processor_count();
38  uint32_t linker_count = (uint32_t) bsp_processor_count;
39
40  return hardware_count <= linker_count ? hardware_count : linker_count;
41}
42
43bool _CPU_SMP_Start_processor(uint32_t cpu_index)
44{
45  bool started;
46
47  if (cpu_index == 1) {
48    alt_write_word(
49      ALT_SYSMGR_ROMCODE_ADDR + ALT_SYSMGR_ROMCODE_CPU1STARTADDR_OFST,
50      ALT_SYSMGR_ROMCODE_CPU1STARTADDR_VALUE_SET((uint32_t) _start)
51    );
52
53    alt_clrbits_word(
54      ALT_RSTMGR_MPUMODRST_ADDR,
55      ALT_RSTMGR_MPUMODRST_CPU1_SET_MSK
56    );
57
58    started = true;
59  } else {
60    started = false;
61  }
62
63  return started;
64}
65
66void _CPU_SMP_Finalize_initialization(uint32_t cpu_count)
67{
68  if (cpu_count > 0) {
69    rtems_status_code sc;
70
71    sc = rtems_interrupt_handler_install(
72      ARM_GIC_IRQ_SGI_0,
73      "IPI",
74      RTEMS_INTERRUPT_UNIQUE,
75      bsp_inter_processor_interrupt,
76      NULL
77    );
78    assert(sc == RTEMS_SUCCESSFUL);
79  }
80}
81
82void _CPU_SMP_Send_interrupt(uint32_t target_processor_index)
83{
84  arm_gic_irq_generate_software_irq(
85    ARM_GIC_IRQ_SGI_0,
86    ARM_GIC_IRQ_SOFTWARE_IRQ_TO_ALL_IN_LIST,
87    (uint8_t) (1U << target_processor_index)
88  );
89}
Note: See TracBrowser for help on using the repository browser.