diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-07-19 16:29:59 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2021-12-08 17:25:15 +0100 |
commit | dc94bcdfd7f1d041a6fde70fd540ba4f60d187ce (patch) | |
tree | 50eb6dcf1399b71cf68210c40ae7f851cc022d43 | |
parent | 284cf66bec095ea481f9aa4d04cfebec6a41d68e (diff) |
bsp/leon3: Move and simplify bsp_irq_fixup()
-rw-r--r-- | bsps/sparc/leon3/clock/ckinit.c | 4 | ||||
-rw-r--r-- | bsps/sparc/leon3/include/bsp/irq.h | 1 | ||||
-rw-r--r-- | bsps/sparc/leon3/include/bsp/leon3.h | 31 | ||||
-rw-r--r-- | bsps/sparc/leon3/include/leon.h | 18 | ||||
-rw-r--r-- | bsps/sparc/leon3/start/eirq.c | 8 | ||||
-rw-r--r-- | bsps/sparc/shared/irq/bsp_isr_handler.c | 4 | ||||
-rw-r--r-- | bsps/sparc/shared/irq/irq-shared.c | 4 |
7 files changed, 43 insertions, 27 deletions
diff --git a/bsps/sparc/leon3/clock/ckinit.c b/bsps/sparc/leon3/clock/ckinit.c index 69afb25f3c..1146c77bd5 100644 --- a/bsps/sparc/leon3/clock/ckinit.c +++ b/bsps/sparc/leon3/clock/ckinit.c @@ -21,9 +21,9 @@ */ #include <bsp.h> -#include <bsp/irq.h> -#include <bspopts.h> #include <bsp/fatal.h> +#include <bsp/irq.h> +#include <leon.h> #include <rtems/rtems/intr.h> #include <grlib/ambapp.h> #include <rtems/score/profiling.h> diff --git a/bsps/sparc/leon3/include/bsp/irq.h b/bsps/sparc/leon3/include/bsp/irq.h index 967086f8eb..30b28e4b96 100644 --- a/bsps/sparc/leon3/include/bsp/irq.h +++ b/bsps/sparc/leon3/include/bsp/irq.h @@ -18,7 +18,6 @@ #ifndef LIBBSP_LEON3_IRQ_CONFIG_H #define LIBBSP_LEON3_IRQ_CONFIG_H -#include <leon.h> #include <rtems/score/processormask.h> #define BSP_INTERRUPT_VECTOR_MAX_STD 15 /* Standard IRQ controller */ diff --git a/bsps/sparc/leon3/include/bsp/leon3.h b/bsps/sparc/leon3/include/bsp/leon3.h index ff1ef261e6..32d18be14b 100644 --- a/bsps/sparc/leon3/include/bsp/leon3.h +++ b/bsps/sparc/leon3/include/bsp/leon3.h @@ -67,12 +67,43 @@ extern volatile struct irqmp_regs *LEON3_IrqCtrl_Regs; extern struct ambapp_dev *LEON3_IrqCtrl_Adev; /** + * @brief This object provides the interrupt number used to multiplex extended + * interrupts or is zero if no extended interrupts are available. + * + * This object should be read-only after initialization. + */ +extern uint32_t LEON3_IrqCtrl_EIrq; + +/** * @brief Initializes the interrupt controller for the boot processor. * * @param[in, out] regs is the IRQ(A)MP register block address. */ void leon3_ext_irq_init( volatile struct irqmp_regs *regs ); +/** + * @brief Acknowledges and maps extended interrupts if this feature is + * available and the interrupt for extended interrupts is present. + * + * @param irq is the standard interrupt number. + */ +static inline uint32_t bsp_irq_fixup( uint32_t irq ) +{ + uint32_t eirq; + + if ( irq != LEON3_IrqCtrl_EIrq ) { + return irq; + } + + eirq = LEON3_IrqCtrl_Regs->intid[ _LEON3_Get_current_processor() ] & 0x1f; + + if ( eirq < 16 ) { + return irq; + } + + return eirq; +} + /** @} */ #ifdef __cplusplus diff --git a/bsps/sparc/leon3/include/leon.h b/bsps/sparc/leon3/include/leon.h index 8cee0972d4..c42b377170 100644 --- a/bsps/sparc/leon3/include/leon.h +++ b/bsps/sparc/leon3/include/leon.h @@ -135,24 +135,6 @@ extern struct ambapp_dev *LEON3_Timer_Adev; /* LEON3 CPU Index of boot CPU */ extern uint32_t LEON3_Cpu_Index; -/* The external IRQ number, -1 if not external interrupts */ -extern int LEON3_IrqCtrl_EIrq; - -static __inline__ int bsp_irq_fixup(int irq) -{ - int eirq, cpu; - - if (LEON3_IrqCtrl_EIrq != 0 && irq == LEON3_IrqCtrl_EIrq) { - /* Get interrupt number from IRQ controller */ - cpu = _LEON3_Get_current_processor(); - eirq = LEON3_IrqCtrl_Regs->intid[cpu] & 0x1f; - if (eirq & 0x10) - irq = eirq; - } - - return irq; -} - /* Macros used for manipulating bits in LEON3 GP Timer Control Register */ #define LEON3_IRQMPSTATUS_CPUNR 28 diff --git a/bsps/sparc/leon3/start/eirq.c b/bsps/sparc/leon3/start/eirq.c index fdfa9a80dd..23acb5744d 100644 --- a/bsps/sparc/leon3/start/eirq.c +++ b/bsps/sparc/leon3/start/eirq.c @@ -17,7 +17,7 @@ #include <bsp/irq-generic.h> /* GRLIB extended IRQ controller IRQ number */ -int LEON3_IrqCtrl_EIrq = -1; +uint32_t LEON3_IrqCtrl_EIrq; rtems_interrupt_lock LEON3_IrqCtrl_Lock = RTEMS_INTERRUPT_LOCK_INITIALIZER("LEON3 IrqCtrl"); @@ -28,11 +28,7 @@ void leon3_ext_irq_init(volatile struct irqmp_regs *regs) regs->mask[LEON3_Cpu_Index] = 0; regs->force[LEON3_Cpu_Index] = 0; regs->iclear = 0xffffffff; - - if ( (regs->mpstat >> 16) & 0xf ) { - /* Extended IRQ controller available */ - LEON3_IrqCtrl_EIrq = (regs->mpstat >> 16) & 0xf; - } + LEON3_IrqCtrl_EIrq = (regs->mpstat >> 16) & 0xf; } bool bsp_interrupt_is_valid_vector(rtems_vector_number vector) diff --git a/bsps/sparc/shared/irq/bsp_isr_handler.c b/bsps/sparc/shared/irq/bsp_isr_handler.c index 2616b5caae..1541aa236f 100644 --- a/bsps/sparc/shared/irq/bsp_isr_handler.c +++ b/bsps/sparc/shared/irq/bsp_isr_handler.c @@ -11,6 +11,10 @@ #include <bsp.h> #include <bsp/irq-generic.h> +#ifdef LEON3 +#include <bsp/leon3.h> +#endif + /* * This function is called directly from _SPARC_Interrupt_trap() for * traps 0x10 to 0x1F which correspond to IRQ 0 to 15 respectively. diff --git a/bsps/sparc/shared/irq/irq-shared.c b/bsps/sparc/shared/irq/irq-shared.c index c815e00e40..a14b09598b 100644 --- a/bsps/sparc/shared/irq/irq-shared.c +++ b/bsps/sparc/shared/irq/irq-shared.c @@ -11,6 +11,10 @@ #include <bsp.h> #include <bsp/irq-generic.h> +#if defined(LEON3) +#include <leon.h> +#endif + static inline int bsp_irq_cpu(int irq) { #if defined(RTEMS_SMP) |