source: rtems/c/src/lib/libbsp/arm/shared/arm-a9mpcore-smp.c @ db42c079

4.11
Last change on this file since db42c079 was db42c079, checked in by Sebastian Huber <sebastian.huber@…>, on May 31, 2013 at 11:59:47 AM

bsps/arm: Add SMP support

  • Property mode set to 100644
File size: 1.5 KB
Line 
1/*
2 * Copyright (c) 2013 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.com/license/LICENSE.
13 */
14
15#include <assert.h>
16
17#include <rtems/bspsmp.h>
18
19#include <libcpu/arm-cp15.h>
20
21#include <bsp/irq.h>
22
23int bsp_smp_processor_id(void)
24{
25  return (int) arm_cortex_a9_get_multiprocessor_cpu_id();
26}
27
28static void ipi_handler(void *arg)
29{
30  rtems_smp_process_interrupt();
31}
32
33uint32_t bsp_smp_initialize(uint32_t configured_cpu_count)
34{
35  rtems_status_code sc;
36  uint32_t max_cpu_count = arm_gic_irq_processor_count();
37  uint32_t used_cpu_count = configured_cpu_count < max_cpu_count ?
38    configured_cpu_count : max_cpu_count;
39
40  sc = rtems_interrupt_handler_install(
41    ARM_GIC_IRQ_SGI_0,
42    "IPI",
43    RTEMS_INTERRUPT_UNIQUE,
44    ipi_handler,
45    NULL
46  );
47  assert(sc == RTEMS_SUCCESSFUL);
48
49  return used_cpu_count;
50}
51
52void bsp_smp_broadcast_interrupt(void)
53{
54  /*
55   * FIXME: This broadcasts the interrupt also to processors not used by RTEMS.
56   */
57  rtems_status_code sc = arm_gic_irq_generate_software_irq(
58    ARM_GIC_IRQ_SGI_0,
59    ARM_GIC_IRQ_SOFTWARE_IRQ_TO_ALL_EXCEPT_SELF,
60    0xff
61  );
62}
63
64void bsp_smp_interrupt_cpu(int cpu)
65{
66  rtems_status_code sc = arm_gic_irq_generate_software_irq(
67    ARM_GIC_IRQ_SGI_0,
68    ARM_GIC_IRQ_SOFTWARE_IRQ_TO_ALL_IN_LIST,
69    (uint8_t) (1U << cpu)
70  );
71}
Note: See TracBrowser for help on using the repository browser.