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

Chris Johns chrisj at rtems.org
Fri Jun 16 01:49:12 UTC 2023


On 15/6/2023 10:46 pm, Sebastian Huber wrote:
> Update #3269.
> ---
>  bsps/riscv/griscv/include/bsp.h             |  4 ---
>  bsps/shared/grlib/drvmgr/ambapp_bus_grlib.c |  8 +++---
>  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   |  5 ++--
>  bsps/sparc/shared/irq/irq-shared.c          | 29 ---------------------
>  spec/build/bsps/sparc/leon3/obj.yml         |  1 -
>  8 files changed, 43 insertions(+), 49 deletions(-)
> 
> diff --git a/bsps/riscv/griscv/include/bsp.h b/bsps/riscv/griscv/include/bsp.h
> index 9d6fb2a16f..c7d24839ca 100644
> --- a/bsps/riscv/griscv/include/bsp.h
> +++ b/bsps/riscv/griscv/include/bsp.h
> @@ -71,10 +71,6 @@ extern "C" {
>  
>  /* 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..bc211e37b6 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,7 @@ static int ambapp_grlib_int_clear
>  	struct drvmgr_dev *dev,
>  	int irq)
>  {
> -	BSP_shared_interrupt_clear(irq);
> +	(void) rtems_interrupt_clear(irq);
>  	return DRVMGR_OK;

Why ignore the return code of the clear and assume the result is OK?

This pattern is repeated in other places.

Chris
>  }
>  
> @@ -237,7 +237,7 @@ static int ambapp_grlib_int_mask
>  	int irq
>  	)
>  {
> -	BSP_shared_interrupt_mask(irq);
> +	bsp_interrupt_vector_disable(irq);
>  	return DRVMGR_OK;
>  }
>  
> @@ -247,7 +247,7 @@ static int ambapp_grlib_int_unmask
>  	int irq
>  	)
>  {
> -	BSP_shared_interrupt_unmask(irq);
> +	bsp_interrupt_vector_enable(irq);
>  	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..af4ff69863 100644
> --- a/bsps/sparc/shared/drvmgr/leon2_amba_bus.c
> +++ b/bsps/sparc/shared/drvmgr/leon2_amba_bus.c
> @@ -43,6 +43,7 @@
>  #include <drvmgr/leon2_amba_bus.h>
>  
>  #include <bsp.h>
> +#include <bsp/irq-generic.h>
>  #include <rtems/bspIo.h>
>  
>  #define DBG(args...)
> @@ -424,7 +425,7 @@ int leon2_amba_int_mask
>  	if ( irq < 0 )
>  		return -1;
>  
> -	BSP_shared_interrupt_mask(irq);
> +	bsp_interrupt_vector_disable(irq);
>  
>  	return DRVMGR_OK;
>  }
> @@ -441,7 +442,7 @@ int leon2_amba_int_unmask
>  	if ( irq < 0 )
>  		return -1;
>  
> -	BSP_shared_interrupt_unmask(irq);
> +	bsp_interrupt_vector_enable(irq);
>  
>  	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


More information about the devel mailing list