[PATCH v2 2/3] bsps: Remove uses of BSP-specific interrupt API

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Jun 16 05:34:57 UTC 2023


Update #3269.
---
 bsps/riscv/griscv/include/bsp.h             |  6 -----
 bsps/shared/grlib/drvmgr/ambapp_bus_grlib.c | 17 +++++++++---
 bsps/sparc/erc32/include/bsp.h              | 15 ++++++++---
 bsps/sparc/leon2/include/bsp.h              | 15 ++++++++---
 bsps/sparc/leon3/include/bsp.h              | 15 ++++++++---
 bsps/sparc/shared/drvmgr/leon2_amba_bus.c   | 16 ++++++++----
 bsps/sparc/shared/irq/irq-shared.c          | 29 ---------------------
 spec/build/bsps/sparc/leon3/obj.yml         |  1 -
 8 files changed, 60 insertions(+), 54 deletions(-)

diff --git a/bsps/riscv/griscv/include/bsp.h b/bsps/riscv/griscv/include/bsp.h
index 9d6fb2a16f..a0aec4f130 100644
--- a/bsps/riscv/griscv/include/bsp.h
+++ b/bsps/riscv/griscv/include/bsp.h
@@ -69,12 +69,6 @@ extern "C" {
 /* Maximum supported APBUARTs by BSP */
 #define BSP_NUMBER_OF_TERMIOS_PORTS 8
 
-/* GRLIB driver functions */
-
-extern void BSP_shared_interrupt_mask(int irq);
-extern void BSP_shared_interrupt_clear(int irq);
-extern void BSP_shared_interrupt_unmask(int irq);
-
 /*
  * Network driver configuration for greth
  */
diff --git a/bsps/shared/grlib/drvmgr/ambapp_bus_grlib.c b/bsps/shared/grlib/drvmgr/ambapp_bus_grlib.c
index 96b77907a6..35d23c1858 100644
--- a/bsps/shared/grlib/drvmgr/ambapp_bus_grlib.c
+++ b/bsps/shared/grlib/drvmgr/ambapp_bus_grlib.c
@@ -41,7 +41,7 @@
 #include <grlib/genirq.h>
 
 #include <bsp.h>
-#include <bsp/irq.h>
+#include <bsp/irq-generic.h>
 
 #include <grlib/grlib_impl.h>
 
@@ -227,7 +227,10 @@ static int ambapp_grlib_int_clear
 	struct drvmgr_dev *dev,
 	int irq)
 {
-	BSP_shared_interrupt_clear(irq);
+	if (rtems_interrupt_clear(irq) != RTEMS_SUCCESSFUL) {
+		return DRVMGR_FAIL;
+	}
+
 	return DRVMGR_OK;
 }
 
@@ -237,7 +240,10 @@ static int ambapp_grlib_int_mask
 	int irq
 	)
 {
-	BSP_shared_interrupt_mask(irq);
+	if (rtems_interrupt_vector_disable(irq) != RTEMS_SUCCESSFUL) {
+		return DRVMGR_FAIL;
+	}
+
 	return DRVMGR_OK;
 }
 
@@ -247,7 +253,10 @@ static int ambapp_grlib_int_unmask
 	int irq
 	)
 {
-	BSP_shared_interrupt_unmask(irq);
+	if (rtems_interrupt_vector_enable(irq) != RTEMS_SUCCESSFUL) {
+		return DRVMGR_FAIL;
+	}
+
 	return DRVMGR_OK;
 }
 
diff --git a/bsps/sparc/erc32/include/bsp.h b/bsps/sparc/erc32/include/bsp.h
index fd453fb6c2..cb62661aa1 100644
--- a/bsps/sparc/erc32/include/bsp.h
+++ b/bsps/sparc/erc32/include/bsp.h
@@ -142,7 +142,10 @@ static __inline__ int BSP_shared_interrupt_unregister
  * Arguments
  *  irq       System IRQ number
  */
-extern void BSP_shared_interrupt_clear(int irq);
+static inline void BSP_shared_interrupt_clear( int irq )
+{
+  (void) rtems_interrupt_clear( (rtems_vector_number) irq );
+}
 
 /* Enable Interrupt. This function will unmask the IRQ at the interrupt
  * controller. This is normally done by _register(). Note that this will
@@ -151,7 +154,10 @@ extern void BSP_shared_interrupt_clear(int irq);
  * Arguments
  *  irq       System IRQ number
  */
-extern void BSP_shared_interrupt_unmask(int irq);
+static inline void BSP_shared_interrupt_unmask( int irq )
+{
+  (void) rtems_interrupt_vector_enable( (rtems_vector_number) irq );
+}
 
 /* Disable Interrupt. This function will mask one IRQ at the interrupt
  * controller. This is normally done by _unregister().  Note that this will
@@ -160,7 +166,10 @@ extern void BSP_shared_interrupt_unmask(int irq);
  * Arguments
  *  irq         System IRQ number
  */
-extern void BSP_shared_interrupt_mask(int irq);
+static inline void BSP_shared_interrupt_mask( int irq )
+{
+  (void) rtems_interrupt_vector_disable( (rtems_vector_number) irq );
+}
 
 /*
  *  Delay for the specified number of microseconds.
diff --git a/bsps/sparc/leon2/include/bsp.h b/bsps/sparc/leon2/include/bsp.h
index 510262206b..4a2f5967ef 100644
--- a/bsps/sparc/leon2/include/bsp.h
+++ b/bsps/sparc/leon2/include/bsp.h
@@ -166,7 +166,10 @@ static __inline__ int BSP_shared_interrupt_unregister
  * Arguments
  *  irq       System IRQ number
  */
-extern void BSP_shared_interrupt_clear(int irq);
+static inline void BSP_shared_interrupt_clear( int irq )
+{
+  (void) rtems_interrupt_clear( (rtems_vector_number) irq );
+}
 
 /* Enable Interrupt. This function will unmask the IRQ at the interrupt
  * controller. This is normally done by _register(). Note that this will
@@ -175,7 +178,10 @@ extern void BSP_shared_interrupt_clear(int irq);
  * Arguments
  *  irq       System IRQ number
  */
-extern void BSP_shared_interrupt_unmask(int irq);
+static inline void BSP_shared_interrupt_unmask( int irq )
+{
+  (void) rtems_interrupt_vector_enable( (rtems_vector_number) irq );
+}
 
 /* Disable Interrupt. This function will mask one IRQ at the interrupt
  * controller. This is normally done by _unregister().  Note that this will
@@ -184,7 +190,10 @@ extern void BSP_shared_interrupt_unmask(int irq);
  * Arguments
  *  irq         System IRQ number
  */
-extern void BSP_shared_interrupt_mask(int irq);
+static inline void BSP_shared_interrupt_mask( int irq )
+{
+  (void) rtems_interrupt_vector_disable( (rtems_vector_number) irq );
+}
 
 /*
  * Delay method
diff --git a/bsps/sparc/leon3/include/bsp.h b/bsps/sparc/leon3/include/bsp.h
index d47f5d2cdf..1712602bfd 100644
--- a/bsps/sparc/leon3/include/bsp.h
+++ b/bsps/sparc/leon3/include/bsp.h
@@ -185,7 +185,10 @@ static __inline__ int BSP_shared_interrupt_unregister
  * Arguments
  *  irq       System IRQ number
  */
-extern void BSP_shared_interrupt_clear(int irq);
+static inline void BSP_shared_interrupt_clear( int irq )
+{
+  (void) rtems_interrupt_clear( (rtems_vector_number) irq );
+}
 
 /* Enable Interrupt. This function will unmask the IRQ at the interrupt
  * controller. This is normally done by _register(). Note that this will
@@ -194,7 +197,10 @@ extern void BSP_shared_interrupt_clear(int irq);
  * Arguments
  *  irq       System IRQ number
  */
-extern void BSP_shared_interrupt_unmask(int irq);
+static inline void BSP_shared_interrupt_unmask( int irq )
+{
+  (void) rtems_interrupt_vector_enable( (rtems_vector_number) irq );
+}
 
 /* Disable Interrupt. This function will mask one IRQ at the interrupt
  * controller. This is normally done by _unregister().  Note that this will
@@ -203,7 +209,10 @@ extern void BSP_shared_interrupt_unmask(int irq);
  * Arguments
  *  irq         System IRQ number
  */
-extern void BSP_shared_interrupt_mask(int irq);
+static inline void BSP_shared_interrupt_mask( int irq )
+{
+  (void) rtems_interrupt_vector_disable( (rtems_vector_number) irq );
+}
 
 #if defined(RTEMS_SMP) || defined(RTEMS_MULTIPROCESSING)
 /* Irq used by the shared memory driver and for inter-processor interrupts.
diff --git a/bsps/sparc/shared/drvmgr/leon2_amba_bus.c b/bsps/sparc/shared/drvmgr/leon2_amba_bus.c
index e4f6449520..9b8de54adc 100644
--- a/bsps/sparc/shared/drvmgr/leon2_amba_bus.c
+++ b/bsps/sparc/shared/drvmgr/leon2_amba_bus.c
@@ -373,7 +373,7 @@ int leon2_amba_int_register
 
 	DBG("Registering IRQ %d to func 0x%x arg 0x%x\n", irq, (unsigned int)isr, (unsigned int)arg);
 
-	return BSP_shared_interrupt_register(irq, info, isr, arg);
+	return rtems_interrupt_handler_install(irq, info, RTEMS_INTERRUPT_SHARED, isr, arg);
 }
 
 int leon2_amba_int_unregister
@@ -392,7 +392,7 @@ int leon2_amba_int_unregister
 
 	DBG("Unregistering IRQ %d to func 0x%x arg 0x%x\n", irq, (unsigned int)handler, (unsigned int)arg);
 
-	return BSP_shared_interrupt_unregister(irq, isr, arg);
+	return rtems_interrupt_handler_remove(irq, isr, arg);
 }
 
 int leon2_amba_int_clear
@@ -407,7 +407,9 @@ int leon2_amba_int_clear
 	if ( irq < 0 )
 		return -1;
 
-	BSP_shared_interrupt_clear(irq);
+	if (rtems_interrupt_clear(irq) != RTEMS_SUCCESSFUL) {
+		return DRVMGR_FAIL;
+	}
 
 	return DRVMGR_OK;
 }
@@ -424,7 +426,9 @@ int leon2_amba_int_mask
 	if ( irq < 0 )
 		return -1;
 
-	BSP_shared_interrupt_mask(irq);
+	if (rtems_interrupt_vector_disable(irq) != RTEMS_SUCCESSFUL) {
+		return DRVMGR_FAIL;
+	}
 
 	return DRVMGR_OK;
 }
@@ -441,7 +445,9 @@ int leon2_amba_int_unmask
 	if ( irq < 0 )
 		return -1;
 
-	BSP_shared_interrupt_unmask(irq);
+	if (rtems_interrupt_vector_enable(irq) != RTEMS_SUCCESSFUL) {
+		return DRVMGR_FAIL;
+	}
 
 	return DRVMGR_OK;
 }
diff --git a/bsps/sparc/shared/irq/irq-shared.c b/bsps/sparc/shared/irq/irq-shared.c
index 0a79b2ffa3..efa1d86020 100644
--- a/bsps/sparc/shared/irq/irq-shared.c
+++ b/bsps/sparc/shared/irq/irq-shared.c
@@ -32,19 +32,9 @@
 
 static inline int bsp_irq_cpu(int irq)
 {
-#if defined(RTEMS_SMP)
-  Processor_mask affinity;
-
-  (void) bsp_interrupt_get_affinity((rtems_vector_number) irq, &affinity);
-  return (int) _Processor_mask_Find_last_set(&affinity);
-#elif defined(LEON3)
-  return _LEON3_Get_current_processor();
-#else
   return 0;
-#endif
 }
 
-#if !defined(LEON3)
 bool bsp_interrupt_is_valid_vector(rtems_vector_number vector)
 {
   if (vector == 0) {
@@ -150,22 +140,3 @@ rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector)
   BSP_Cpu_Mask_interrupt(vector, 0);
   return RTEMS_SUCCESSFUL;
 }
-#endif
-
-void BSP_shared_interrupt_mask(int irq)
-{
-  BSP_Cpu_Mask_interrupt(irq, bsp_irq_cpu(irq));
-}
-
-void BSP_shared_interrupt_unmask(int irq)
-{
-  BSP_Cpu_Unmask_interrupt(irq, bsp_irq_cpu(irq));
-}
-
-void BSP_shared_interrupt_clear(int irq)
-{
-  /* We don't have to interrupt lock here, because the register is only
-   * written and self clearing
-   */
-  BSP_Clear_interrupt(irq);
-}
diff --git a/spec/build/bsps/sparc/leon3/obj.yml b/spec/build/bsps/sparc/leon3/obj.yml
index 752ab9e149..4d8394e111 100644
--- a/spec/build/bsps/sparc/leon3/obj.yml
+++ b/spec/build/bsps/sparc/leon3/obj.yml
@@ -52,7 +52,6 @@ source:
 - bsps/sparc/leon3/start/setvec.c
 - bsps/sparc/shared/gnatcommon.c
 - bsps/sparc/shared/irq/bsp_isr_handler.c
-- bsps/sparc/shared/irq/irq-shared.c
 - bsps/sparc/shared/pci/gr_cpci_gr740.c
 - bsps/sparc/shared/pci/gr_leon4_n2x.c
 - bsps/sparc/shared/pci/pci_memreg_sparc_be.c
-- 
2.35.3



More information about the devel mailing list