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> | 2023-01-24 11:46:52 +0100 |
commit | f2ff32e50431da838e0a4a7347ee92a06579233e (patch) | |
tree | 5576ffbcbbaed9b90253c94908ab6b95da493d71 | |
parent | 777b446bd383fc6fbaa194417034c8ba8b374c73 (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 7869b1a97e..3bc35e1f64 100644 --- a/bsps/sparc/leon3/clock/ckinit.c +++ b/bsps/sparc/leon3/clock/ckinit.c @@ -40,9 +40,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 a7054030e2..ef0f6245f9 100644 --- a/bsps/sparc/leon3/include/bsp/irq.h +++ b/bsps/sparc/leon3/include/bsp/irq.h @@ -37,7 +37,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 0623eaa4ff..82e93ddb41 100644 --- a/bsps/sparc/leon3/include/leon.h +++ b/bsps/sparc/leon3/include/leon.h @@ -154,24 +154,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 0be5af1bd0..1f47aa5439 100644 --- a/bsps/sparc/leon3/start/eirq.c +++ b/bsps/sparc/leon3/start/eirq.c @@ -36,7 +36,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"); @@ -47,11 +47,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 cf2800cd85..22d168cdb6 100644 --- a/bsps/sparc/shared/irq/bsp_isr_handler.c +++ b/bsps/sparc/shared/irq/bsp_isr_handler.c @@ -30,6 +30,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 0a79b2ffa3..01f544df0e 100644 --- a/bsps/sparc/shared/irq/irq-shared.c +++ b/bsps/sparc/shared/irq/irq-shared.c @@ -30,6 +30,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) |