RTEMS
eirq.c
1 /*
2  * GRLIB/LEON3 extended interrupt controller
3  *
4  * COPYRIGHT (c) 2011
5  * Aeroflex Gaisler
6  *
7  * The license and distribution terms for this file may be
8  * found in the file LICENSE in this distribution or at
9  * http://www.rtems.org/license/LICENSE.
10  *
11  */
12 
13 #include <leon.h>
14 #include <bsp/irq.h>
15 
16 /* GRLIB extended IRQ controller IRQ number */
17 int LEON3_IrqCtrl_EIrq = -1;
18 
19 /* Initialize Extended Interrupt controller */
20 void leon3_ext_irq_init(void)
21 {
22  if ( (LEON3_IrqCtrl_Regs->mpstat >> 16) & 0xf ) {
23  /* Extended IRQ controller available */
24  LEON3_IrqCtrl_EIrq = (LEON3_IrqCtrl_Regs->mpstat >> 16) & 0xf;
25  }
26 }
27 
28 void bsp_interrupt_set_affinity(
29  rtems_vector_number vector,
30  const Processor_mask *affinity
31 )
32 {
33  uint32_t unmasked = 0;
34  uint32_t cpu_count = rtems_scheduler_get_processor_maximum();
35  uint32_t cpu_index;
36 
37  for (cpu_index = 0; cpu_index < cpu_count; ++cpu_index) {
38  if (_Processor_mask_Is_set(affinity, cpu_index)) {
39  BSP_Cpu_Unmask_interrupt(vector, cpu_index);
40  ++unmasked;
41  }
42  }
43 
44  if (unmasked > 1) {
45  LEON_Enable_interrupt_broadcast(vector);
46  } else {
47  LEON_Disable_interrupt_broadcast(vector);
48  }
49 }
50 
51 void bsp_interrupt_get_affinity(
52  rtems_vector_number vector,
53  Processor_mask *affinity
54 )
55 {
56  uint32_t cpu_count = rtems_scheduler_get_processor_maximum();
57  uint32_t cpu_index;
58 
59  _Processor_mask_Zero(affinity);
60 
61  for (cpu_index = 0; cpu_index < cpu_count; ++cpu_index) {
62  if (!BSP_Cpu_Is_interrupt_masked(vector, cpu_index)) {
63  _Processor_mask_Set(affinity, cpu_index);
64  }
65  }
66 }
RTEMS_INLINE_ROUTINE bool _Processor_mask_Is_set(const Processor_mask *mask, uint32_t index)
Checks if the specified index bit of the mask is set.
RTEMS_INLINE_ROUTINE void _Processor_mask_Zero(Processor_mask *mask)
Sets the bits of the mask to zero, also considers CPU_MAXIMUM_PROCESSORS.
Definition: processormask.h:61
LEON3 BSP data types and macros.
#define rtems_scheduler_get_processor_maximum()
Returns the processor maximum supported by the system.
Definition: tasks.h:350
LEON3 generic shared IRQ setup.
ISR_Vector_number rtems_vector_number
%
Definition: intr.h:90
RTEMS_INLINE_ROUTINE void _Processor_mask_Set(Processor_mask *mask, uint32_t index)
Sets the specified index bit of the mask.