[PATCH 10/34] bsp/leon3: Move and simplify bsp_irq_fixup()
Sebastian Huber
sebastian.huber at embedded-brains.de
Wed May 31 16:30:45 UTC 2023
---
bsps/sparc/leon3/clock/ckinit.c | 4 ++--
bsps/sparc/leon3/include/bsp/irq.h | 1 -
bsps/sparc/leon3/include/bsp/leon3.h | 31 +++++++++++++++++++++++++
bsps/sparc/leon3/include/leon.h | 18 --------------
bsps/sparc/leon3/start/eirq.c | 8 ++-----
bsps/sparc/shared/irq/bsp_isr_handler.c | 4 ++++
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 b66ac793fc..2ec701fe2a 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 c0105e02f0..05915a7dea 100644
--- a/bsps/sparc/leon3/include/bsp/leon3.h
+++ b/bsps/sparc/leon3/include/bsp/leon3.h
@@ -66,6 +66,14 @@ 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.
*
@@ -73,6 +81,29 @@ extern struct ambapp_dev *LEON3_IrqCtrl_Adev;
*/
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 0371cfe98f..d9c5402dd0 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)
--
2.35.3
More information about the devel
mailing list