source: rtems/c/src/lib/libbsp/sparc/shared/irq/irq-shared.c @ c6810c8

5
Last change on this file since c6810c8 was c6810c8, checked in by Sebastian Huber <sebastian.huber@…>, on 06/19/17 at 12:09:28

bsps: Improve interrupt vector enable/disable API

Change bsp_interrupt_vector_enable() and bsp_interrupt_vector_disable()
to not return a status code. Add bsp_interrupt_assert() and use it to
validate the vector number in the vector enable/disable implementations.

  • Property mode set to 100644
File size: 2.5 KB
Line 
1/*
2*  COPYRIGHT (c) 2012-2015
3*  Cobham Gaisler
4*
5*  The license and distribution terms for this file may be
6*  found in the file LICENSE in this distribution or at
7*  http://www.rtems.org/license/LICENSE.
8*
9*/
10
11#include <rtems.h>
12#include <bsp.h>
13#include <bsp/irq-generic.h>
14
15#if defined(RTEMS_SMP) && defined(LEON3)
16/* Interrupt to CPU map. Default to CPU0 since in BSS. */
17const unsigned char LEON3_irq_to_cpu[32] __attribute__((weak));
18
19/* On SMP use map table above relative to SMP Boot CPU (normally CPU0) */
20static inline int bsp_irq_cpu(int irq)
21{
22  /* protect from bad user configuration, default to boot cpu */
23  if (rtems_configuration_get_maximum_processors() <= LEON3_irq_to_cpu[irq])
24    return LEON3_Cpu_Index;
25  else
26    return LEON3_Cpu_Index + LEON3_irq_to_cpu[irq];
27}
28#else
29/* when not SMP the local CPU is returned */
30static inline int bsp_irq_cpu(int irq)
31{
32#ifdef LEON3
33  return _LEON3_Get_current_processor();
34#else
35  return 0;
36#endif
37}
38#endif
39
40/* Initialize interrupts */
41void BSP_shared_interrupt_init(void)
42{
43  rtems_vector_number vector;
44  rtems_isr_entry previous_isr;
45  int i;
46
47  for (i=0; i <= BSP_INTERRUPT_VECTOR_MAX_STD; i++) {
48#if defined(LEON3) && \
49    (defined(RTEMS_SMP) || defined(RTEMS_MULTIPROCESSING))
50    /* Don't install IRQ handler on IPI interrupt. An SMP kernel with max one
51     * CPU does not use IPIs
52     */
53#ifdef RTEMS_SMP
54    if (rtems_configuration_get_maximum_processors() > 1)
55#endif
56      if (i == LEON3_mp_irq)
57        continue;
58#endif
59    vector = SPARC_ASYNCHRONOUS_TRAP(i) + 0x10;
60    rtems_interrupt_catch(bsp_isr_handler, vector, &previous_isr);
61  }
62
63  /* Initalize interrupt support */
64  bsp_interrupt_initialize();
65}
66
67/* Callback from bsp_interrupt_initialize() */
68rtems_status_code bsp_interrupt_facility_initialize(void)
69{
70  return RTEMS_SUCCESSFUL;
71}
72
73void bsp_interrupt_vector_enable(rtems_vector_number vector)
74{
75  int irq = (int)vector;
76  bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector));
77  BSP_Cpu_Unmask_interrupt(irq, bsp_irq_cpu(irq));
78}
79
80void bsp_interrupt_vector_disable(rtems_vector_number vector)
81{
82  int irq = (int)vector;
83  bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector));
84  BSP_Cpu_Mask_interrupt(irq, bsp_irq_cpu(irq));
85}
86
87void BSP_shared_interrupt_mask(int irq)
88{
89  BSP_Cpu_Mask_interrupt(irq, bsp_irq_cpu(irq));
90}
91
92void BSP_shared_interrupt_unmask(int irq)
93{
94  BSP_Cpu_Unmask_interrupt(irq, bsp_irq_cpu(irq));
95}
96
97void BSP_shared_interrupt_clear(int irq)
98{
99  /* We don't have to interrupt lock here, because the register is only
100   * written and self clearing
101   */
102  BSP_Clear_interrupt(irq);
103}
Note: See TracBrowser for help on using the repository browser.