RTEMS
irq-shared.c
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. */
17 const unsigned char LEON3_irq_to_cpu[32] __attribute__((weak));
18 
19 /* On SMP use map table above relative to SMP Boot CPU (normally CPU0) */
20 static 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 */
30 static 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 */
41 void 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) && (defined(RTEMS_SMP) || defined(RTEMS_MULTIPROCESSING))
49  /* Don't install IRQ handler on IPI interrupt */
50  if (i == LEON3_mp_irq)
51  continue;
52 #endif
53  vector = SPARC_ASYNCHRONOUS_TRAP(i) + 0x10;
54  rtems_interrupt_catch(bsp_isr_handler, vector, &previous_isr);
55  }
56 
57  /* Initalize interrupt support */
59 }
60 
61 /* Callback from bsp_interrupt_initialize() */
63 {
64  return RTEMS_SUCCESSFUL;
65 }
66 
68 {
69  int irq = (int)vector;
70  bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector));
71  BSP_Cpu_Unmask_interrupt(irq, bsp_irq_cpu(irq));
72 }
73 
75 {
76  int irq = (int)vector;
77  bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector));
78  BSP_Cpu_Mask_interrupt(irq, bsp_irq_cpu(irq));
79 }
80 
81 void BSP_shared_interrupt_mask(int irq)
82 {
83  BSP_Cpu_Mask_interrupt(irq, bsp_irq_cpu(irq));
84 }
85 
86 void BSP_shared_interrupt_unmask(int irq)
87 {
88  BSP_Cpu_Unmask_interrupt(irq, bsp_irq_cpu(irq));
89 }
90 
91 void BSP_shared_interrupt_clear(int irq)
92 {
93  /* We don't have to interrupt lock here, because the register is only
94  * written and self clearing
95  */
96  BSP_Clear_interrupt(irq);
97 }
Generic BSP interrupt support API.
void bsp_interrupt_vector_disable(rtems_vector_number vector)
Disables the interrupt vector with number vector.
Definition: irq-shared.c:74
#define SPARC_ASYNCHRONOUS_TRAP(_trap)
Definition: cpu.h:703
This status code indicates successful completion.
Definition: status.h:86
rtems_status_code
This enumeration provides status codes for directives of the Classic API.
Definition: status.h:82
rtems_status_code rtems_interrupt_catch(rtems_isr_entry new_isr_handler, rtems_vector_number vector, rtems_isr_entry *old_isr_handler)
%
This header file defines the RTEMS Classic API.
static bool bsp_interrupt_is_valid_vector(rtems_vector_number vector)
Returns true if the interrupt vector with number vector is valid.
Definition: irq-generic.h:167
void bsp_interrupt_initialize(void)
Initialize BSP interrupt support.
Definition: irq-generic.c:161
void(* rtems_isr_entry)(void *)
Interrupt service routines installed by rtems_interrupt_catch() shall have this function pointer type...
Definition: intr.h:103
ISR_Vector_number rtems_vector_number
%
Definition: intr.h:90
rtems_status_code bsp_interrupt_facility_initialize(void)
BSP specific initialization.
Definition: irq-shared.c:62
#define rtems_configuration_get_maximum_processors()
Returns the maximum number of processors which are configured for this application.
Definition: config.h:194
void bsp_interrupt_vector_enable(rtems_vector_number vector)
Enables the interrupt vector with number vector.
Definition: irq-shared.c:67