summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2021-07-19 16:29:59 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2023-07-14 12:21:33 +0200
commit32ff60293b835888557603973730b5cf2a8ec77c (patch)
treee0207c26cf1b9fe38935ca7c827632974717c90d
parenta5f95cbb5785a2331894029eae0332ba509d6a4c (diff)
bsp/leon3: Move and simplify bsp_irq_fixup()
-rw-r--r--bsps/sparc/erc32/include/bsp/irqimpl.h63
-rw-r--r--bsps/sparc/erc32/include/erc32.h5
-rw-r--r--bsps/sparc/leon2/include/bsp/irqimpl.h63
-rw-r--r--bsps/sparc/leon2/include/leon.h5
-rw-r--r--bsps/sparc/leon3/clock/ckinit.c4
-rw-r--r--bsps/sparc/leon3/include/bsp/irq.h1
-rw-r--r--bsps/sparc/leon3/include/bsp/irqimpl.h31
-rw-r--r--bsps/sparc/leon3/include/leon.h18
-rw-r--r--bsps/sparc/leon3/start/eirq.c8
-rw-r--r--bsps/sparc/shared/irq/bsp_isr_handler.c1
-rw-r--r--spec/build/bsps/sparc/erc32/bsperc32.yml1
-rw-r--r--spec/build/bsps/sparc/leon2/obj.yml1
12 files changed, 164 insertions, 37 deletions
diff --git a/bsps/sparc/erc32/include/bsp/irqimpl.h b/bsps/sparc/erc32/include/bsp/irqimpl.h
new file mode 100644
index 0000000000..6a8b17f188
--- /dev/null
+++ b/bsps/sparc/erc32/include/bsp/irqimpl.h
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSBSPsSPARCERC32
+ *
+ * @brief This header file provides interfaces used by the interrupt support
+ * implementation.
+ */
+
+/*
+ * Copyright (C) 2023 embedded brains GmbH & Co. KG
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBBSP_SPARC_ERC32_BSP_IRQIMPL_H
+#define LIBBSP_SPARC_ERC32_BSP_IRQIMPL_H
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup RTEMSBSPsSPARCERC32
+ *
+ * @{
+ */
+
+static inline uint32_t bsp_irq_fixup( uint32_t irq )
+{
+ return irq;
+}
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LIBBSP_SPARC_ERC32_BSP_IRQIMPL_H */
diff --git a/bsps/sparc/erc32/include/erc32.h b/bsps/sparc/erc32/include/erc32.h
index f9cdbc960a..3967f4c918 100644
--- a/bsps/sparc/erc32/include/erc32.h
+++ b/bsps/sparc/erc32/include/erc32.h
@@ -326,11 +326,6 @@ typedef struct {
extern ERC32_Register_Map ERC32_MEC;
-static __inline__ int bsp_irq_fixup(int irq)
-{
- return irq;
-}
-
/*
* Macros to manipulate the Interrupt Clear, Interrupt Force, Interrupt Mask,
* and the Interrupt Pending Registers.
diff --git a/bsps/sparc/leon2/include/bsp/irqimpl.h b/bsps/sparc/leon2/include/bsp/irqimpl.h
new file mode 100644
index 0000000000..868822f3aa
--- /dev/null
+++ b/bsps/sparc/leon2/include/bsp/irqimpl.h
@@ -0,0 +1,63 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup RTEMSBSPsSPARCLEON2
+ *
+ * @brief This header file provides interfaces used by the interrupt support
+ * implementation.
+ */
+
+/*
+ * Copyright (C) 2023 embedded brains GmbH & Co. KG
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LIBBSP_SPARC_LEON3_BSP_IRQIMPL_H
+#define LIBBSP_SPARC_LEON3_BSP_IRQIMPL_H
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup RTEMSBSPsSPARCLEON2
+ *
+ * @{
+ */
+
+static inline uint32_t bsp_irq_fixup( uint32_t irq )
+{
+ return irq;
+}
+
+/** @} */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LIBBSP_SPARC_LEON3_BSP_IRQIMPL_H */
diff --git a/bsps/sparc/leon2/include/leon.h b/bsps/sparc/leon2/include/leon.h
index 762260ba48..8f2d807eb4 100644
--- a/bsps/sparc/leon2/include/leon.h
+++ b/bsps/sparc/leon2/include/leon.h
@@ -292,11 +292,6 @@ typedef struct {
extern LEON_Register_Map LEON_REG;
-static __inline__ int bsp_irq_fixup(int irq)
-{
- return irq;
-}
-
/*
* Macros to manipulate the Interrupt Clear, Interrupt Force, Interrupt Mask,
* and the Interrupt Pending Registers.
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/irqimpl.h b/bsps/sparc/leon3/include/bsp/irqimpl.h
index 77619c99b9..60b198bd02 100644
--- a/bsps/sparc/leon3/include/bsp/irqimpl.h
+++ b/bsps/sparc/leon3/include/bsp/irqimpl.h
@@ -68,12 +68,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 0382e1b7e3..8a64285b3f 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..54e82b15a4 100644
--- a/bsps/sparc/shared/irq/bsp_isr_handler.c
+++ b/bsps/sparc/shared/irq/bsp_isr_handler.c
@@ -29,6 +29,7 @@
#include <bsp.h>
#include <bsp/irq-generic.h>
+#include <bsp/irqimpl.h>
/*
* This function is called directly from _SPARC_Interrupt_trap() for
diff --git a/spec/build/bsps/sparc/erc32/bsperc32.yml b/spec/build/bsps/sparc/erc32/bsperc32.yml
index d082feb5f7..4ca351cd61 100644
--- a/spec/build/bsps/sparc/erc32/bsperc32.yml
+++ b/spec/build/bsps/sparc/erc32/bsperc32.yml
@@ -17,6 +17,7 @@ install:
- destination: ${BSP_INCLUDEDIR}/bsp
source:
- bsps/sparc/erc32/include/bsp/irq.h
+ - bsps/sparc/erc32/include/bsp/irqimpl.h
- destination: ${BSP_LIBDIR}
source:
- bsps/sparc/erc32/start/linkcmds
diff --git a/spec/build/bsps/sparc/leon2/obj.yml b/spec/build/bsps/sparc/leon2/obj.yml
index 50ee715af2..87e5cd90c9 100644
--- a/spec/build/bsps/sparc/leon2/obj.yml
+++ b/spec/build/bsps/sparc/leon2/obj.yml
@@ -16,6 +16,7 @@ install:
source:
- bsps/sparc/leon2/include/bsp/at697_pci.h
- bsps/sparc/leon2/include/bsp/irq.h
+ - bsps/sparc/leon2/include/bsp/irqimpl.h
- destination: ${BSP_LIBDIR}
source:
- bsps/sparc/leon2/start/linkcmds.at697f