[PATCH 3/3] bsps/irq: Remove BSP_INTERRUPT_VECTOR_MAX

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Jun 18 07:20:35 UTC 2021


Replace it with BSP_INTERRUPT_VECTOR_COUNT.  This allows a default
implementation which supports no interrupt vector at all.

Using COUNT instead of MAX may avoid some interpretation issues, for example is
the maximum value a valid vector number or not.  The change shows that
BSP_INTERRUPT_VECTOR_MAX was a bit misleading since there was an off by one
error in some  BSPs.

Update #3269.
---
 bsps/aarch64/a53/include/bsp/irq.h              |  2 +-
 bsps/aarch64/a72/include/bsp/irq.h              |  2 +-
 bsps/aarch64/xilinx-zynqmp/include/bsp/irq.h    |  2 +-
 bsps/arm/altera-cyclone-v/include/bsp/irq.h     |  3 ++-
 bsps/arm/atsam/include/bsp/irq.h                |  2 +-
 bsps/arm/atsam/start/bspstart.c                 |  2 +-
 bsps/arm/beagle/include/bsp/irq.h               |  2 +-
 bsps/arm/beagle/irq/irq.c                       |  2 +-
 bsps/arm/csb336/include/bsp/irq.h               |  2 +-
 bsps/arm/csb337/include/bsp/irq.h               |  2 +-
 bsps/arm/edb7312/include/bsp/irq.h              |  2 +-
 bsps/arm/fvp/include/bsp/irq.h                  |  2 +-
 bsps/arm/gumstix/include/bsp/irq.h              |  2 +-
 bsps/arm/imx/include/bsp/irq.h                  |  2 +-
 bsps/arm/imxrt/include/bsp/irq.h                |  2 +-
 bsps/arm/lm3s69xx/include/bsp/irq.h             |  2 +-
 bsps/arm/lpc176x/include/bsp/irq.h              |  2 +-
 bsps/arm/lpc176x/irq/irq.c                      |  2 +-
 bsps/arm/lpc24xx/include/bsp/irq.h              |  4 ++--
 bsps/arm/lpc24xx/irq/irq.c                      |  4 ++--
 bsps/arm/lpc32xx/include/bsp/irq.h              |  4 ++--
 bsps/arm/raspberrypi/include/bsp/irq.h          |  4 ++--
 bsps/arm/realview-pbx-a9/include/bsp/irq.h      |  2 +-
 bsps/arm/rtl22xx/include/bsp/irq.h              |  2 +-
 bsps/arm/shared/irq/irq-armv7m.c                |  2 +-
 bsps/arm/shared/start/start.S                   |  2 +-
 bsps/arm/smdk2410/include/bsp/irq.h             |  2 +-
 bsps/arm/stm32f4/include/bsp/irq.h              |  2 +-
 bsps/arm/stm32h7/include/bsp/irq.h              |  2 +-
 bsps/arm/tms570/include/bsp/irq.h               |  2 +-
 bsps/arm/tms570/irq/irq.c                       |  2 +-
 bsps/arm/xen/include/bsp/irq.h                  |  2 +-
 bsps/arm/xilinx-zynq/include/bsp/irq.h          |  2 +-
 bsps/arm/xilinx-zynqmp/include/bsp/irq.h        |  2 +-
 bsps/i386/include/bsp/irq.h                     |  2 +-
 bsps/include/bsp/irq-default.h                  |  2 +-
 bsps/include/bsp/irq-generic.h                  | 16 +++++++---------
 bsps/lm32/include/bsp/irq.h                     |  2 +-
 bsps/m68k/genmcf548x/include/bsp/irq.h          |  2 +-
 bsps/m68k/genmcf548x/irq/irq.c                  |  2 +-
 bsps/mips/csb350/include/bsp/irq.h              |  2 +-
 bsps/mips/hurricane/include/bsp/irq.h           |  2 +-
 bsps/mips/jmr3904/include/bsp/irq.h             |  2 +-
 bsps/mips/malta/include/bsp/irq.h               |  2 +-
 bsps/mips/rbtx4925/include/bsp/irq.h            |  2 +-
 bsps/mips/rbtx4938/include/bsp/irq.h            |  2 +-
 bsps/mips/shared/irq/irq.c                      |  2 +-
 bsps/or1k/generic_or1k/include/bsp/irq.h        |  2 +-
 bsps/powerpc/gen5200/include/bsp/irq.h          |  2 +-
 bsps/powerpc/gen83xx/include/bsp/irq.h          |  2 +-
 bsps/powerpc/motorola_powerpc/include/bsp/irq.h |  2 +-
 bsps/powerpc/mpc55xxevb/include/bsp/irq.h       |  2 +-
 bsps/powerpc/mpc8260ads/include/bsp/irq.h       |  2 +-
 bsps/powerpc/psim/include/bsp/irq.h             |  2 +-
 bsps/powerpc/qemuppc/include/bsp/irq.h          |  2 +-
 bsps/powerpc/qoriq/include/bsp/irq.h            |  4 ++--
 bsps/powerpc/qoriq/irq/irq.c                    |  6 +++---
 bsps/powerpc/t32mppc/include/bsp/irq.h          |  2 +-
 bsps/powerpc/tqm8xx/include/bsp/irq.h           |  2 +-
 bsps/powerpc/virtex/include/bsp/irq.h           |  2 +-
 bsps/riscv/griscv/include/bsp/irq.h             |  2 +-
 bsps/riscv/riscv/include/bsp/irq.h              |  2 +-
 bsps/shared/irq/irq-generic.c                   |  2 +-
 bsps/shared/irq/irq-info.c                      |  2 +-
 bsps/shared/irq/irq-server.c                    |  2 +-
 bsps/sparc/erc32/include/bsp/irq.h              |  3 +--
 bsps/sparc/leon2/include/bsp/irq.h              |  3 +--
 bsps/sparc/leon3/include/bsp/irq.h              |  9 +++------
 bsps/sparc/shared/irq/irq-shared.c              |  2 +-
 bsps/x86_64/include/bsp/irq.h                   |  2 +-
 testsuites/smptests/smpcapture02/init.c         |  2 +-
 71 files changed, 87 insertions(+), 93 deletions(-)

diff --git a/bsps/aarch64/a53/include/bsp/irq.h b/bsps/aarch64/a53/include/bsp/irq.h
index e1aebf5a22..b797408ca5 100644
--- a/bsps/aarch64/a53/include/bsp/irq.h
+++ b/bsps/aarch64/a53/include/bsp/irq.h
@@ -48,7 +48,7 @@
 extern "C" {
 #endif /* __cplusplus */
 
-#define BSP_INTERRUPT_VECTOR_MAX 1023
+#define BSP_INTERRUPT_VECTOR_COUNT 1024
 
 /* Interrupts vectors */
 #define BSP_TIMER_VIRT_PPI 27
diff --git a/bsps/aarch64/a72/include/bsp/irq.h b/bsps/aarch64/a72/include/bsp/irq.h
index 71076ed82a..c2e86ec0a9 100644
--- a/bsps/aarch64/a72/include/bsp/irq.h
+++ b/bsps/aarch64/a72/include/bsp/irq.h
@@ -48,7 +48,7 @@
 extern "C" {
 #endif /* __cplusplus */
 
-#define BSP_INTERRUPT_VECTOR_MAX 1023
+#define BSP_INTERRUPT_VECTOR_COUNT 1024
 
 /* Interrupts vectors */
 #define BSP_TIMER_VIRT_PPI 27
diff --git a/bsps/aarch64/xilinx-zynqmp/include/bsp/irq.h b/bsps/aarch64/xilinx-zynqmp/include/bsp/irq.h
index f12a4536b5..b67d7d0f8e 100644
--- a/bsps/aarch64/xilinx-zynqmp/include/bsp/irq.h
+++ b/bsps/aarch64/xilinx-zynqmp/include/bsp/irq.h
@@ -48,7 +48,7 @@
 extern "C" {
 #endif /* __cplusplus */
 
-#define BSP_INTERRUPT_VECTOR_MAX 1023
+#define BSP_INTERRUPT_VECTOR_COUNT 1024
 
 /* Interrupts vectors */
 #define BSP_TIMER_VIRT_PPI 27
diff --git a/bsps/arm/altera-cyclone-v/include/bsp/irq.h b/bsps/arm/altera-cyclone-v/include/bsp/irq.h
index d5470f9b4e..496645c23f 100644
--- a/bsps/arm/altera-cyclone-v/include/bsp/irq.h
+++ b/bsps/arm/altera-cyclone-v/include/bsp/irq.h
@@ -47,7 +47,8 @@ extern "C" {
  */
 
 /* Use interrupt IDs as defined in alt_interrupt_common.h */
-#define BSP_INTERRUPT_VECTOR_MAX ALT_INT_INTERRUPT_RAM_ECC_UNCORRECTED_IRQ
+#define BSP_INTERRUPT_VECTOR_COUNT \
+  (ALT_INT_INTERRUPT_RAM_ECC_UNCORRECTED_IRQ + 1)
 
 /** @} */
 
diff --git a/bsps/arm/atsam/include/bsp/irq.h b/bsps/arm/atsam/include/bsp/irq.h
index b6eac75042..e788570469 100644
--- a/bsps/arm/atsam/include/bsp/irq.h
+++ b/bsps/arm/atsam/include/bsp/irq.h
@@ -23,6 +23,6 @@
   #include <rtems/irq-extension.h>
 #endif
 
-#define BSP_INTERRUPT_VECTOR_MAX 64
+#define BSP_INTERRUPT_VECTOR_COUNT 64
 
 #endif /* LIBBSP_ARM_ATSAM_ESV_70_IRQ_H */
diff --git a/bsps/arm/atsam/start/bspstart.c b/bsps/arm/atsam/start/bspstart.c
index b463bab696..3f49779797 100644
--- a/bsps/arm/atsam/start/bspstart.c
+++ b/bsps/arm/atsam/start/bspstart.c
@@ -21,7 +21,7 @@
 #include <chip.h>
 
 RTEMS_STATIC_ASSERT(
-  PERIPH_COUNT_IRQn <= BSP_INTERRUPT_VECTOR_MAX,
+  PERIPH_COUNT_IRQn <= BSP_INTERRUPT_VECTOR_COUNT,
   PERIPH_COUNT_IRQn
 );
 
diff --git a/bsps/arm/beagle/include/bsp/irq.h b/bsps/arm/beagle/include/bsp/irq.h
index 9ecd6bc31e..a4e0addd4c 100644
--- a/bsps/arm/beagle/include/bsp/irq.h
+++ b/bsps/arm/beagle/include/bsp/irq.h
@@ -15,7 +15,7 @@
 #include <rtems/irq.h>
 #include <rtems/irq-extension.h>
 
-#define BSP_INTERRUPT_VECTOR_MAX 127
+#define BSP_INTERRUPT_VECTOR_COUNT 128
 
 #endif /* ASM */
 
diff --git a/bsps/arm/beagle/irq/irq.c b/bsps/arm/beagle/irq/irq.c
index 721703b87b..8e9294cae9 100644
--- a/bsps/arm/beagle/irq/irq.c
+++ b/bsps/arm/beagle/irq/irq.c
@@ -133,7 +133,7 @@ rtems_status_code bsp_interrupt_facility_initialize(void)
   }
 
   /* Mask all interrupts */
-  for(i = 0; i <= BSP_INTERRUPT_VECTOR_MAX; i++)
+  for(i = 0; i < BSP_INTERRUPT_VECTOR_COUNT; i++)
     bsp_interrupt_vector_disable(i);
 
   /* Install generic interrupt handler */
diff --git a/bsps/arm/csb336/include/bsp/irq.h b/bsps/arm/csb336/include/bsp/irq.h
index b9978242eb..4402a7d6a5 100644
--- a/bsps/arm/csb336/include/bsp/irq.h
+++ b/bsps/arm/csb336/include/bsp/irq.h
@@ -88,6 +88,6 @@
 #define BSP_INT_WDT              63
 #define BSP_MAX_INT              64
 
-#define BSP_INTERRUPT_VECTOR_MAX (BSP_MAX_INT - 1)
+#define BSP_INTERRUPT_VECTOR_COUNT BSP_MAX_INT
 
 #endif /* __IRQ_H__ */
diff --git a/bsps/arm/csb337/include/bsp/irq.h b/bsps/arm/csb337/include/bsp/irq.h
index 7d967b0ae0..6a60caad33 100644
--- a/bsps/arm/csb337/include/bsp/irq.h
+++ b/bsps/arm/csb337/include/bsp/irq.h
@@ -72,6 +72,6 @@
 #define AT91RM9200_INT_IRQ6      31
 #define AT91RM9200_MAX_INT       32
 
-#define BSP_INTERRUPT_VECTOR_MAX (AT91RM9200_MAX_INT - 1)
+#define BSP_INTERRUPT_VECTOR_COUNT AT91RM9200_MAX_INT
 
 #endif /* __IRQ_H__ */
diff --git a/bsps/arm/edb7312/include/bsp/irq.h b/bsps/arm/edb7312/include/bsp/irq.h
index ba167083d3..66a17b8dda 100644
--- a/bsps/arm/edb7312/include/bsp/irq.h
+++ b/bsps/arm/edb7312/include/bsp/irq.h
@@ -83,7 +83,7 @@
 
 /** @} */
 
-#define BSP_INTERRUPT_VECTOR_MAX (BSP_MAX_INT - 1)
+#define BSP_INTERRUPT_VECTOR_COUNT BSP_MAX_INT
 
 /** @} */
 
diff --git a/bsps/arm/fvp/include/bsp/irq.h b/bsps/arm/fvp/include/bsp/irq.h
index d28f7a6db3..724ecdc9ab 100644
--- a/bsps/arm/fvp/include/bsp/irq.h
+++ b/bsps/arm/fvp/include/bsp/irq.h
@@ -40,6 +40,6 @@
 
 #include <bspopts.h>
 
-#define BSP_INTERRUPT_VECTOR_MAX (32 + BSP_ARM_SHARED_PERIPHERAL_INTERRUPT_COUNT)
+#define BSP_INTERRUPT_VECTOR_COUNT (32 + BSP_ARM_SHARED_PERIPHERAL_INTERRUPT_COUNT)
 
 #endif /* LIBBSP_ARM_FVP_IRQ_H */
diff --git a/bsps/arm/gumstix/include/bsp/irq.h b/bsps/arm/gumstix/include/bsp/irq.h
index f7d0ca72d5..af7832e92c 100644
--- a/bsps/arm/gumstix/include/bsp/irq.h
+++ b/bsps/arm/gumstix/include/bsp/irq.h
@@ -20,7 +20,7 @@
 
 #include <pxa255.h>
 
-#define BSP_INTERRUPT_VECTOR_MAX (PRIMARY_IRQS - 1)
+#define BSP_INTERRUPT_VECTOR_COUNT PRIMARY_IRQS
 
 #endif /* __asm__ */
 
diff --git a/bsps/arm/imx/include/bsp/irq.h b/bsps/arm/imx/include/bsp/irq.h
index 249b416387..000623aa43 100644
--- a/bsps/arm/imx/include/bsp/irq.h
+++ b/bsps/arm/imx/include/bsp/irq.h
@@ -26,7 +26,7 @@
 extern "C" {
 #endif /* __cplusplus */
 
-#define BSP_INTERRUPT_VECTOR_MAX 159
+#define BSP_INTERRUPT_VECTOR_COUNT 160
 #define BSP_INTERRUPT_VECTOR_INVALID (UINT32_MAX)
 
 #ifdef __cplusplus
diff --git a/bsps/arm/imxrt/include/bsp/irq.h b/bsps/arm/imxrt/include/bsp/irq.h
index 5e7fba0d33..6fcd055f03 100644
--- a/bsps/arm/imxrt/include/bsp/irq.h
+++ b/bsps/arm/imxrt/include/bsp/irq.h
@@ -43,7 +43,7 @@
 extern "C" {
 #endif /* __cplusplus */
 
-#define BSP_INTERRUPT_VECTOR_MAX 159
+#define BSP_INTERRUPT_VECTOR_COUNT 160
 #define BSP_INTERRUPT_VECTOR_INVALID (UINT32_MAX)
 
 #ifdef __cplusplus
diff --git a/bsps/arm/lm3s69xx/include/bsp/irq.h b/bsps/arm/lm3s69xx/include/bsp/irq.h
index 25df016b16..f342c1a361 100644
--- a/bsps/arm/lm3s69xx/include/bsp/irq.h
+++ b/bsps/arm/lm3s69xx/include/bsp/irq.h
@@ -101,6 +101,6 @@
 #define LM3S69XX_IRQ_PRIORITY_LOWEST LM3S69XX_IRQ_PRIORITY_VALUE_MAX
 
 /* NOTE: for lm3s6965 - 43 */
-#define BSP_INTERRUPT_VECTOR_MAX 47
+#define BSP_INTERRUPT_VECTOR_COUNT 48
 
 #endif /* LIBBSP_ARM_LM3S69XX_IRQ_H */
diff --git a/bsps/arm/lpc176x/include/bsp/irq.h b/bsps/arm/lpc176x/include/bsp/irq.h
index 4757e19a62..7b9cbcbb72 100644
--- a/bsps/arm/lpc176x/include/bsp/irq.h
+++ b/bsps/arm/lpc176x/include/bsp/irq.h
@@ -68,7 +68,7 @@
 #define LPC176X_IRQ_PWM 39U
 #define LPC176X_IRQ_EEPROM 40U
 
-#define BSP_INTERRUPT_VECTOR_MAX 40
+#define BSP_INTERRUPT_VECTOR_COUNT 41
 
 #define LPC176X_IRQ_PRIORITY_VALUE_MIN 0U
 
diff --git a/bsps/arm/lpc176x/irq/irq.c b/bsps/arm/lpc176x/irq/irq.c
index e05fd59e6c..a060401d0b 100644
--- a/bsps/arm/lpc176x/irq/irq.c
+++ b/bsps/arm/lpc176x/irq/irq.c
@@ -38,7 +38,7 @@
  */
 static inline bool lpc176x_irq_is_valid( const rtems_vector_number vector )
 {
-  return vector <= BSP_INTERRUPT_VECTOR_MAX;
+  return vector < BSP_INTERRUPT_VECTOR_COUNT;
 }
 
 void lpc176x_irq_set_priority(
diff --git a/bsps/arm/lpc24xx/include/bsp/irq.h b/bsps/arm/lpc24xx/include/bsp/irq.h
index 7bbbf44f49..9794a01546 100644
--- a/bsps/arm/lpc24xx/include/bsp/irq.h
+++ b/bsps/arm/lpc24xx/include/bsp/irq.h
@@ -69,7 +69,7 @@
   #define LPC24XX_IRQ_I2C_2 30
   #define LPC24XX_IRQ_I2S 31
 
-  #define BSP_INTERRUPT_VECTOR_MAX 31
+  #define BSP_INTERRUPT_VECTOR_COUNT 32
 #else
   #define LPC24XX_IRQ_WDT 0
   #define LPC24XX_IRQ_TIMER_0 1
@@ -112,7 +112,7 @@
   #define LPC24XX_IRQ_PWM 39
   #define LPC24XX_IRQ_EEPROM 40
 
-  #define BSP_INTERRUPT_VECTOR_MAX 40
+  #define BSP_INTERRUPT_VECTOR_COUNT 41
 #endif
 
 #define LPC24XX_IRQ_PRIORITY_VALUE_MIN 0
diff --git a/bsps/arm/lpc24xx/irq/irq.c b/bsps/arm/lpc24xx/irq/irq.c
index 2fed80efda..ed07805a9a 100644
--- a/bsps/arm/lpc24xx/irq/irq.c
+++ b/bsps/arm/lpc24xx/irq/irq.c
@@ -31,7 +31,7 @@
 
 static inline bool lpc24xx_irq_is_valid(rtems_vector_number vector)
 {
-  return vector <= BSP_INTERRUPT_VECTOR_MAX;
+  return vector < BSP_INTERRUPT_VECTOR_COUNT;
 }
 
 void lpc24xx_irq_set_priority(rtems_vector_number vector, unsigned priority)
@@ -91,7 +91,7 @@ rtems_status_code bsp_interrupt_facility_initialize(void)
   /* Use IRQ category */
   VICIntSelect = 0;
 
-  for (i = 0; i <= BSP_INTERRUPT_VECTOR_MAX; ++i) {
+  for (i = 0; i < BSP_INTERRUPT_VECTOR_COUNT; ++i) {
     /* Use the vector address register to store the vector number */
     addr [i] = i;
 
diff --git a/bsps/arm/lpc32xx/include/bsp/irq.h b/bsps/arm/lpc32xx/include/bsp/irq.h
index 1b1ff8db78..84b296431b 100644
--- a/bsps/arm/lpc32xx/include/bsp/irq.h
+++ b/bsps/arm/lpc32xx/include/bsp/irq.h
@@ -139,9 +139,9 @@ extern "C" {
 #define LPC32XX_IRQ_PRIORITY_HIGHEST LPC32XX_IRQ_PRIORITY_VALUE_MIN
 #define LPC32XX_IRQ_PRIORITY_LOWEST LPC32XX_IRQ_PRIORITY_VALUE_MAX
 
-#define BSP_INTERRUPT_VECTOR_MAX LPC32XX_IRQ_SYSCLK
+#define BSP_INTERRUPT_VECTOR_COUNT (LPC32XX_IRQ_SYSCLK + 1)
 
-#define LPC32XX_IRQ_COUNT (BSP_INTERRUPT_VECTOR_MAX + 1)
+#define LPC32XX_IRQ_COUNT BSP_INTERRUPT_VECTOR_COUNT
 
 void lpc32xx_irq_set_priority(rtems_vector_number vector, unsigned priority);
 
diff --git a/bsps/arm/raspberrypi/include/bsp/irq.h b/bsps/arm/raspberrypi/include/bsp/irq.h
index 87b6da2963..fae147124f 100644
--- a/bsps/arm/raspberrypi/include/bsp/irq.h
+++ b/bsps/arm/raspberrypi/include/bsp/irq.h
@@ -33,7 +33,7 @@
  * @brief Interrupt support.
  */
 
-#define BCM2835_INTC_TOTAL_IRQ       64 + 8
+#define BCM2835_INTC_TOTAL_IRQ       (64 + 8)
 
 #define BCM2835_IRQ_SET1_MIN         0
 #define BCM2835_IRQ_SET2_MIN         32
@@ -69,7 +69,7 @@
 #define BCM2835_IRQ_ID_ILL_ACCESS_1  70
 #define BCM2835_IRQ_ID_ILL_ACCESS_0  71
 
-#define BSP_INTERRUPT_VECTOR_MAX    (BCM2835_INTC_TOTAL_IRQ - 1)
+#define BSP_INTERRUPT_VECTOR_COUNT    BCM2835_INTC_TOTAL_IRQ
 #define BSP_INTERRUPT_VECTOR_INVALID (UINT32_MAX)
 
 #define BSP_IRQ_COUNT               (BCM2835_INTC_TOTAL_IRQ)
diff --git a/bsps/arm/realview-pbx-a9/include/bsp/irq.h b/bsps/arm/realview-pbx-a9/include/bsp/irq.h
index 1d7a6b68c8..6563d1ba1a 100644
--- a/bsps/arm/realview-pbx-a9/include/bsp/irq.h
+++ b/bsps/arm/realview-pbx-a9/include/bsp/irq.h
@@ -90,7 +90,7 @@ extern "C" {
 #define RVPBXA9_IRQ_P_NINT_6 88
 #define RVPBXA9_IRQ_P_NINT_7 89
 
-#define BSP_INTERRUPT_VECTOR_MAX 89
+#define BSP_INTERRUPT_VECTOR_COUNT 90
 
 #ifdef __cplusplus
 }
diff --git a/bsps/arm/rtl22xx/include/bsp/irq.h b/bsps/arm/rtl22xx/include/bsp/irq.h
index ee7f603cf9..7e94bf171a 100644
--- a/bsps/arm/rtl22xx/include/bsp/irq.h
+++ b/bsps/arm/rtl22xx/include/bsp/irq.h
@@ -53,7 +53,7 @@
 #define LPC22xx_INTERRUPT_CAN4RX 27	/* CAN2 Rx interrupt */
 #define BSP_MAX_INT              28
 
-#define BSP_INTERRUPT_VECTOR_MAX (BSP_MAX_INT - 1)
+#define BSP_INTERRUPT_VECTOR_COUNT BSP_MAX_INT
 
 #define UNDEFINED_INSTRUCTION_VECTOR_ADDR   (*(u_long *)0x00000004L)
 #define SOFTWARE_INTERRUPT_VECTOR_ADDR      (*(u_long *)0x00000008L)
diff --git a/bsps/arm/shared/irq/irq-armv7m.c b/bsps/arm/shared/irq/irq-armv7m.c
index 7c7c1ab114..2bf8c9df74 100644
--- a/bsps/arm/shared/irq/irq-armv7m.c
+++ b/bsps/arm/shared/irq/irq-armv7m.c
@@ -67,7 +67,7 @@ rtems_status_code bsp_interrupt_facility_initialize(void)
 
   _ARMV7M_SCB->icsr = ARMV7M_SCB_ICSR_PENDSVCLR | ARMV7M_SCB_ICSR_PENDSTCLR;
 
-  for (i = 0; i <= BSP_INTERRUPT_VECTOR_MAX; ++i) {
+  for (i = 0; i < BSP_INTERRUPT_VECTOR_COUNT; ++i) {
     _ARMV7M_NVIC_Clear_enable(i);
     _ARMV7M_NVIC_Clear_pending(i);
     _ARMV7M_NVIC_Set_priority(i, BSP_ARMV7M_IRQ_PRIORITY_DEFAULT);
diff --git a/bsps/arm/shared/start/start.S b/bsps/arm/shared/start/start.S
index bd623178ed..698495d32e 100644
--- a/bsps/arm/shared/start/start.S
+++ b/bsps/arm/shared/start/start.S
@@ -529,7 +529,7 @@ bsp_start_vector_table_begin:
 	.word	_ARMV7M_Exception_default /* Reserved */
 	.word	_ARMV7M_Pendable_service_call /* PendSV */
 	.word	_ARMV7M_Clock_handler /* SysTick */
-	.rept	BSP_INTERRUPT_VECTOR_MAX + 1
+	.rept	BSP_INTERRUPT_VECTOR_COUNT
 	.word	_ARMV7M_NVIC_Interrupt_dispatch /* IRQ */
 	.endr
 
diff --git a/bsps/arm/smdk2410/include/bsp/irq.h b/bsps/arm/smdk2410/include/bsp/irq.h
index ca846920ff..d848eb5568 100644
--- a/bsps/arm/smdk2410/include/bsp/irq.h
+++ b/bsps/arm/smdk2410/include/bsp/irq.h
@@ -90,7 +90,7 @@
 #error "Undefined Samsung CPU model"
 #endif
 
-#define BSP_INTERRUPT_VECTOR_MAX (BSP_MAX_INT - 1)
+#define BSP_INTERRUPT_VECTOR_COUNT BSP_MAX_INT
 
 #endif /* _IRQ_H_ */
 /* end of include file */
diff --git a/bsps/arm/stm32f4/include/bsp/irq.h b/bsps/arm/stm32f4/include/bsp/irq.h
index 3c047d3da7..586d68af82 100644
--- a/bsps/arm/stm32f4/include/bsp/irq.h
+++ b/bsps/arm/stm32f4/include/bsp/irq.h
@@ -133,7 +133,7 @@ extern "C" {
 #define STM32F4_IRQ_PRIORITY_HIGHEST STM32F4_IRQ_PRIORITY_VALUE_MIN
 #define STM32F4_IRQ_PRIORITY_LOWEST STM32F4_IRQ_PRIORITY_VALUE_MAX
 
-#define BSP_INTERRUPT_VECTOR_MAX 81
+#define BSP_INTERRUPT_VECTOR_COUNT 82
 
 /** @} */
 
diff --git a/bsps/arm/stm32h7/include/bsp/irq.h b/bsps/arm/stm32h7/include/bsp/irq.h
index 609c1a2ac2..15ebe5c48a 100644
--- a/bsps/arm/stm32h7/include/bsp/irq.h
+++ b/bsps/arm/stm32h7/include/bsp/irq.h
@@ -36,6 +36,6 @@
 
 #endif /* ASM */
 
-#define BSP_INTERRUPT_VECTOR_MAX 239
+#define BSP_INTERRUPT_VECTOR_COUNT 240
 
 #endif /* LIBBSP_ARM_STM32H7_IRQ_H */
diff --git a/bsps/arm/tms570/include/bsp/irq.h b/bsps/arm/tms570/include/bsp/irq.h
index 2f412604bb..bfb8ab4736 100644
--- a/bsps/arm/tms570/include/bsp/irq.h
+++ b/bsps/arm/tms570/include/bsp/irq.h
@@ -112,7 +112,7 @@
 #define TMS570_IRQ_DCC2_DONE_INTERRUPT 83
 #define TMS570_IRQ_HWAG1_INT_REQ_L 88
 #define TMS570_IRQ_HWAG2_INT_REQ_L 89
-#define BSP_INTERRUPT_VECTOR_MAX 94
+#define BSP_INTERRUPT_VECTOR_COUNT 94
 
 #define TMS570_IRQ_PRIORITY_VALUE_MIN 0U
 #define TMS570_IRQ_PRIORITY_VALUE_MAX 0U
diff --git a/bsps/arm/tms570/irq/irq.c b/bsps/arm/tms570/irq/irq.c
index 7129915c93..4abab8feb3 100644
--- a/bsps/arm/tms570/irq/irq.c
+++ b/bsps/arm/tms570/irq/irq.c
@@ -28,7 +28,7 @@
 #include <bsp/irq.h>
 #include <rtems/score/armv4.h>
 
-unsigned int priorityTable[BSP_INTERRUPT_VECTOR_MAX+1];
+unsigned int priorityTable[BSP_INTERRUPT_VECTOR_COUNT];
 
 /**
  * @brief Set priority of the interrupt vector.
diff --git a/bsps/arm/xen/include/bsp/irq.h b/bsps/arm/xen/include/bsp/irq.h
index a29917d31b..58ce78ffd2 100644
--- a/bsps/arm/xen/include/bsp/irq.h
+++ b/bsps/arm/xen/include/bsp/irq.h
@@ -40,7 +40,7 @@
 extern "C" {
 #endif /* __cplusplus */
 
-#define BSP_INTERRUPT_VECTOR_MAX 1023
+#define BSP_INTERRUPT_VECTOR_COUNT 1024
 
 /* Xen guest interrupts */
 #define GUEST_TIMER_VIRT_PPI 27
diff --git a/bsps/arm/xilinx-zynq/include/bsp/irq.h b/bsps/arm/xilinx-zynq/include/bsp/irq.h
index 099edcd034..f4579ae614 100644
--- a/bsps/arm/xilinx-zynq/include/bsp/irq.h
+++ b/bsps/arm/xilinx-zynq/include/bsp/irq.h
@@ -114,7 +114,7 @@ extern "C" {
 #define ZYNQ_IRQ_FPGA_15 91
 #define ZYNQ_IRQ_PARITY 92
 
-#define BSP_INTERRUPT_VECTOR_MAX 92
+#define BSP_INTERRUPT_VECTOR_COUNT 93
 
 /** @} */
 
diff --git a/bsps/arm/xilinx-zynqmp/include/bsp/irq.h b/bsps/arm/xilinx-zynqmp/include/bsp/irq.h
index 7ad1a01d90..9aae8168db 100644
--- a/bsps/arm/xilinx-zynqmp/include/bsp/irq.h
+++ b/bsps/arm/xilinx-zynqmp/include/bsp/irq.h
@@ -67,7 +67,7 @@ extern "C" {
 #define ZYNQMP_IRQ_UART_0 53
 #define ZYNQMP_IRQ_UART_1 54
 
-#define BSP_INTERRUPT_VECTOR_MAX 187
+#define BSP_INTERRUPT_VECTOR_COUNT 188
 
 /** @} */
 
diff --git a/bsps/i386/include/bsp/irq.h b/bsps/i386/include/bsp/irq.h
index 6e2f7cbb2c..c5ef954142 100644
--- a/bsps/i386/include/bsp/irq.h
+++ b/bsps/i386/include/bsp/irq.h
@@ -79,7 +79,7 @@ extern "C" {
 #define BSP_RT_TIMER3		10
 #define BSP_SMP_IPI   		16 /* not part of the ATPIC */
 
-#define BSP_INTERRUPT_VECTOR_MAX BSP_IRQ_VECTOR_MAX_OFFSET
+#define BSP_INTERRUPT_VECTOR_COUNT BSP_IRQ_VECTOR_NUMBER
 
 /** @brief
  * Type definition for RTEMS managed interrupts
diff --git a/bsps/include/bsp/irq-default.h b/bsps/include/bsp/irq-default.h
index c72782e993..fabc23c287 100644
--- a/bsps/include/bsp/irq-default.h
+++ b/bsps/include/bsp/irq-default.h
@@ -47,7 +47,7 @@ extern "C" {
 /**
  * @brief Default maximum interrupt vector.
  */
-#define BSP_INTERRUPT_VECTOR_MAX 0
+#define BSP_INTERRUPT_VECTOR_COUNT 0
 
 /** @} */
 
diff --git a/bsps/include/bsp/irq-generic.h b/bsps/include/bsp/irq-generic.h
index a423f19192..5b9ad3ed50 100644
--- a/bsps/include/bsp/irq-generic.h
+++ b/bsps/include/bsp/irq-generic.h
@@ -58,18 +58,16 @@
 extern "C" {
 #endif /* __cplusplus */
 
-#if !defined(BSP_INTERRUPT_VECTOR_MAX)
-  #error "BSP_INTERRUPT_VECTOR_MAX shall be defined"
+#if !defined(BSP_INTERRUPT_VECTOR_COUNT)
+  #error "BSP_INTERRUPT_VECTOR_COUNT shall be defined"
 #endif
 
 #if defined(BSP_INTERRUPT_USE_INDEX_TABLE) && !defined(BSP_INTERRUPT_HANDLER_TABLE_SIZE)
   #error "if you define BSP_INTERRUPT_USE_INDEX_TABLE, you have to define BSP_INTERRUPT_HANDLER_TABLE_SIZE etc. as well"
 #endif
 
-#define BSP_INTERRUPT_VECTOR_NUMBER (BSP_INTERRUPT_VECTOR_MAX + 1)
-
 #ifndef BSP_INTERRUPT_HANDLER_TABLE_SIZE
-  #define BSP_INTERRUPT_HANDLER_TABLE_SIZE BSP_INTERRUPT_VECTOR_NUMBER
+  #define BSP_INTERRUPT_HANDLER_TABLE_SIZE BSP_INTERRUPT_VECTOR_COUNT
 #endif
 
 /* Internal macros for SMP support, do not use externally */
@@ -126,8 +124,8 @@ static inline rtems_vector_number bsp_interrupt_handler_index(
  * @brief Generic BSP Interrupt Support
  *
  * The BSP interrupt support manages a sequence of interrupt vector numbers
- * ranging from zero to @ref BSP_INTERRUPT_VECTOR_MAX
- * including the end points.  It provides methods to
+ * greater than or equal to zero and less than @ref BSP_INTERRUPT_VECTOR_COUNT
+ * It provides methods to
  * @ref bsp_interrupt_handler_install() "install",
  * @ref bsp_interrupt_handler_remove() "remove" and
  * @ref bsp_interrupt_handler_dispatch() "dispatch" interrupt handlers for each
@@ -138,7 +136,7 @@ static inline rtems_vector_number bsp_interrupt_handler_index(
  *
  * You have to configure the BSP interrupt support in the <bsp/irq.h> file
  * for each BSP.  For a minimum configuration you have to provide
- * @ref BSP_INTERRUPT_VECTOR_MAX.
+ * @ref BSP_INTERRUPT_VECTOR_COUNT.
  *
  * For boards with small memory requirements you can define
  * @ref BSP_INTERRUPT_USE_INDEX_TABLE.  With an enabled index table the handler
@@ -173,7 +171,7 @@ static inline rtems_vector_number bsp_interrupt_handler_index(
    */
   static inline bool bsp_interrupt_is_valid_vector(rtems_vector_number vector)
   {
-    return vector <= (rtems_vector_number) BSP_INTERRUPT_VECTOR_MAX;
+    return vector < (rtems_vector_number) BSP_INTERRUPT_VECTOR_COUNT;
   }
 #endif
 
diff --git a/bsps/lm32/include/bsp/irq.h b/bsps/lm32/include/bsp/irq.h
index 19ba56e161..416af841a7 100644
--- a/bsps/lm32/include/bsp/irq.h
+++ b/bsps/lm32/include/bsp/irq.h
@@ -35,7 +35,7 @@
 /**
  * @brief Maximum vector number.
  */
-#define BSP_INTERRUPT_VECTOR_MAX 31
+#define BSP_INTERRUPT_VECTOR_COUNT 32
 
 /** @} */
 
diff --git a/bsps/m68k/genmcf548x/include/bsp/irq.h b/bsps/m68k/genmcf548x/include/bsp/irq.h
index b3a6285a21..63e623bfdd 100644
--- a/bsps/m68k/genmcf548x/include/bsp/irq.h
+++ b/bsps/m68k/genmcf548x/include/bsp/irq.h
@@ -89,6 +89,6 @@
 #define MCF548X_IRQ_GPT1 61
 #define MCF548X_IRQ_GPT0 62
 
-#define BSP_INTERRUPT_VECTOR_MAX 63
+#define BSP_INTERRUPT_VECTOR_COUNT 64
 
 #endif /* LIBBSP_M68K_MCF548X_IRQ_H */
diff --git a/bsps/m68k/genmcf548x/irq/irq.c b/bsps/m68k/genmcf548x/irq/irq.c
index f02231b67c..1e7cb25764 100644
--- a/bsps/m68k/genmcf548x/irq/irq.c
+++ b/bsps/m68k/genmcf548x/irq/irq.c
@@ -26,7 +26,7 @@ typedef struct {
   const char *info;
 } interrupt_control;
 
-static interrupt_control interrupt_controls[BSP_INTERRUPT_VECTOR_MAX + 1];
+static interrupt_control interrupt_controls[BSP_INTERRUPT_VECTOR_COUNT];
 
 static uint32_t vector_to_reg(rtems_vector_number vector)
 {
diff --git a/bsps/mips/csb350/include/bsp/irq.h b/bsps/mips/csb350/include/bsp/irq.h
index b1d3f86aa7..d02af135e7 100644
--- a/bsps/mips/csb350/include/bsp/irq.h
+++ b/bsps/mips/csb350/include/bsp/irq.h
@@ -115,7 +115,7 @@
 
 #define AU1X00_MAXIMUM_VECTORS        (MIPS_INTERRUPT_BASE + 72)
 
-#define BSP_INTERRUPT_VECTOR_MAX      AU1X00_MAXIMUM_VECTORS 
+#define BSP_INTERRUPT_VECTOR_COUNT    AU1X00_MAXIMUM_VECTORS
 
 /** @} */
 
diff --git a/bsps/mips/hurricane/include/bsp/irq.h b/bsps/mips/hurricane/include/bsp/irq.h
index 4264a0e84d..ccf827edfe 100644
--- a/bsps/mips/hurricane/include/bsp/irq.h
+++ b/bsps/mips/hurricane/include/bsp/irq.h
@@ -32,7 +32,7 @@
  */
 
 #define RM5231_MAXIMUM_VECTORS      (MIPS_INTERRUPT_BASE+8)
-#define BSP_INTERRUPT_VECTOR_MAX    RM5231_MAXIMUM_VECTORS
+#define BSP_INTERRUPT_VECTOR_COUNT  RM5231_MAXIMUM_VECTORS
 
 /** @} */
 
diff --git a/bsps/mips/jmr3904/include/bsp/irq.h b/bsps/mips/jmr3904/include/bsp/irq.h
index a40f26dc7a..ac7ffe03ea 100644
--- a/bsps/mips/jmr3904/include/bsp/irq.h
+++ b/bsps/mips/jmr3904/include/bsp/irq.h
@@ -59,7 +59,7 @@
   #define TX3904_IRQ_SOFTWARE_2  MIPS_INTERRUPT_BASE+18
   #define TX3904_MAXIMUM_VECTORS MIPS_INTERRUPT_BASE+19
 
-#define BSP_INTERRUPT_VECTOR_MAX TX3904_MAXIMUM_VECTORS
+#define BSP_INTERRUPT_VECTOR_COUNT TX3904_MAXIMUM_VECTORS
 
 /** @} */
 
diff --git a/bsps/mips/malta/include/bsp/irq.h b/bsps/mips/malta/include/bsp/irq.h
index 25cb186873..b5ef128760 100644
--- a/bsps/mips/malta/include/bsp/irq.h
+++ b/bsps/mips/malta/include/bsp/irq.h
@@ -79,7 +79,7 @@
 #define MALTA_PCI_ADP_LAST            MALTA_PCI_ADP31
 #
 
-#define BSP_INTERRUPT_VECTOR_MAX   MALTA_PCI_ADP_LAST
+#define BSP_INTERRUPT_VECTOR_COUNT   (MALTA_PCI_ADP_LAST + 1)
 
 /*
  * Redefine interrupts with more descriptive names.
diff --git a/bsps/mips/rbtx4925/include/bsp/irq.h b/bsps/mips/rbtx4925/include/bsp/irq.h
index db28e65989..5bd8bcd984 100644
--- a/bsps/mips/rbtx4925/include/bsp/irq.h
+++ b/bsps/mips/rbtx4925/include/bsp/irq.h
@@ -72,7 +72,7 @@
 #define TX4925_IRQ_SOFTWARE_2  MIPS_INTERRUPT_BASE+33
 #define TX4925_MAXIMUM_VECTORS MIPS_INTERRUPT_BASE+34
 
-#define BSP_INTERRUPT_VECTOR_MAX TX4925_MAXIMUM_VECTORS
+#define BSP_INTERRUPT_VECTOR_COUNT TX4925_MAXIMUM_VECTORS
 
 /** @} */
 
diff --git a/bsps/mips/rbtx4938/include/bsp/irq.h b/bsps/mips/rbtx4938/include/bsp/irq.h
index 03ecacda73..4e7849c20a 100644
--- a/bsps/mips/rbtx4938/include/bsp/irq.h
+++ b/bsps/mips/rbtx4938/include/bsp/irq.h
@@ -72,7 +72,7 @@
 #define TX4938_IRQ_SOFTWARE_2  MIPS_INTERRUPT_BASE+33
 #define TX4938_MAXIMUM_VECTORS MIPS_INTERRUPT_BASE+34
 
-#define BSP_INTERRUPT_VECTOR_MAX TX4938_MAXIMUM_VECTORS
+#define BSP_INTERRUPT_VECTOR_COUNT TX4938_MAXIMUM_VECTORS
 
 /** @} */
 
diff --git a/bsps/mips/shared/irq/irq.c b/bsps/mips/shared/irq/irq.c
index 1c2d3b8c5b..9fed3db489 100644
--- a/bsps/mips/shared/irq/irq.c
+++ b/bsps/mips/shared/irq/irq.c
@@ -64,7 +64,7 @@ static const char *const cause_strings[32] = {
 
 static inline bool bsp_irq_is_valid(rtems_vector_number vector)
 {
-  return vector <= BSP_INTERRUPT_VECTOR_MAX;
+  return vector < BSP_INTERRUPT_VECTOR_COUNT;
 }
 
 void bsp_interrupt_vector_enable(rtems_vector_number vector)
diff --git a/bsps/or1k/generic_or1k/include/bsp/irq.h b/bsps/or1k/generic_or1k/include/bsp/irq.h
index 9d8e1edc0b..4b50be09bf 100644
--- a/bsps/or1k/generic_or1k/include/bsp/irq.h
+++ b/bsps/or1k/generic_or1k/include/bsp/irq.h
@@ -23,7 +23,7 @@
 #include <rtems/irq.h>
 #include <rtems/irq-extension.h>
 
-#define BSP_INTERRUPT_VECTOR_MAX  0x1F00
+#define BSP_INTERRUPT_VECTOR_COUNT  0x1F00
 
 /* Interrupt Identification Register */
 #define OR1K_BSP_UART_REG_INT_ID_MSI    (0x00)
diff --git a/bsps/powerpc/gen5200/include/bsp/irq.h b/bsps/powerpc/gen5200/include/bsp/irq.h
index 63d39cb3df..d54f98a2af 100644
--- a/bsps/powerpc/gen5200/include/bsp/irq.h
+++ b/bsps/powerpc/gen5200/include/bsp/irq.h
@@ -203,7 +203,7 @@ typedef enum {
 #define BSP_CRIT_IRQ_PRIO_LEVELS	  		  4
 #define BSP_PERIODIC_TIMER                    BSP_SIU_IRQ_TMR6
 
-#define BSP_INTERRUPT_VECTOR_MAX BSP_MAX_OFFSET
+#define BSP_INTERRUPT_VECTOR_COUNT (BSP_MAX_OFFSET + 1)
 
 #endif
 
diff --git a/bsps/powerpc/gen83xx/include/bsp/irq.h b/bsps/powerpc/gen83xx/include/bsp/irq.h
index 42bd2980fe..5d896d2609 100644
--- a/bsps/powerpc/gen83xx/include/bsp/irq.h
+++ b/bsps/powerpc/gen83xx/include/bsp/irq.h
@@ -162,7 +162,7 @@ extern "C" {
     BSP_IPIC_IRQ_LAST     = BSP_IPIC_IRQ_MAX_OFFSET,
   } rtems_irq_symbolic_name;
 
-#define BSP_INTERRUPT_VECTOR_MAX BSP_MAX_OFFSET
+#define BSP_INTERRUPT_VECTOR_COUNT (BSP_MAX_OFFSET + 1)
 
 rtems_status_code mpc83xx_ipic_set_mask( rtems_vector_number vector, rtems_vector_number mask_vector, bool mask);
 
diff --git a/bsps/powerpc/motorola_powerpc/include/bsp/irq.h b/bsps/powerpc/motorola_powerpc/include/bsp/irq.h
index 3fcdf916c2..fea2859c3e 100644
--- a/bsps/powerpc/motorola_powerpc/include/bsp/irq.h
+++ b/bsps/powerpc/motorola_powerpc/include/bsp/irq.h
@@ -115,7 +115,7 @@ extern "C" {
 #define BSP_IRQ_NUMBER			(BSP_MISC_IRQ_MAX_OFFSET + 1)
 #define BSP_LOWEST_OFFSET		(BSP_ISA_IRQ_LOWEST_OFFSET)
 #define BSP_MAX_OFFSET			(BSP_MISC_IRQ_MAX_OFFSET)
-#define BSP_INTERRUPT_VECTOR_MAX	(BSP_MAX_OFFSET)
+#define BSP_INTERRUPT_VECTOR_COUNT	(BSP_MAX_OFFSET + 1)
 /*
  * Some ISA IRQ symbolic name definition
  */
diff --git a/bsps/powerpc/mpc55xxevb/include/bsp/irq.h b/bsps/powerpc/mpc55xxevb/include/bsp/irq.h
index e0b3c3eaf8..f6688bff86 100644
--- a/bsps/powerpc/mpc55xxevb/include/bsp/irq.h
+++ b/bsps/powerpc/mpc55xxevb/include/bsp/irq.h
@@ -477,7 +477,7 @@ rtems_status_code mpc55xx_intc_clear_software_irq(rtems_vector_number vector);
  * @{
  */
 
-#define BSP_INTERRUPT_VECTOR_MAX MPC55XX_IRQ_MAX
+#define BSP_INTERRUPT_VECTOR_COUNT (MPC55XX_IRQ_MAX + 1)
 
 #ifdef BSP_INTERRUPT_HANDLER_TABLE_SIZE
   #define BSP_INTERRUPT_USE_INDEX_TABLE
diff --git a/bsps/powerpc/mpc8260ads/include/bsp/irq.h b/bsps/powerpc/mpc8260ads/include/bsp/irq.h
index 12890d998e..22b547e404 100644
--- a/bsps/powerpc/mpc8260ads/include/bsp/irq.h
+++ b/bsps/powerpc/mpc8260ads/include/bsp/irq.h
@@ -141,7 +141,7 @@ extern volatile unsigned int ppc_cached_irq_mask;
 #define BSP_DECREMENTER			(BSP_PROCESSOR_IRQ_LOWEST_OFFSET)
 #define BSP_PERIODIC_TIMER		(BSP_DECREMENTER)
 
-#define BSP_INTERRUPT_VECTOR_MAX BSP_MAX_OFFSET
+#define BSP_INTERRUPT_VECTOR_COUNT (BSP_MAX_OFFSET + 1)
 
 #define CPM_INTERRUPT
 
diff --git a/bsps/powerpc/psim/include/bsp/irq.h b/bsps/powerpc/psim/include/bsp/irq.h
index 248cfb5579..5cd17e7daa 100644
--- a/bsps/powerpc/psim/include/bsp/irq.h
+++ b/bsps/powerpc/psim/include/bsp/irq.h
@@ -57,7 +57,7 @@
 
 #include <bsp/irq_supp.h>
 
-#define BSP_INTERRUPT_VECTOR_MAX BSP_MAX_OFFSET
+#define BSP_INTERRUPT_VECTOR_COUNT BSP_IRQ_NUMBER
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/bsps/powerpc/qemuppc/include/bsp/irq.h b/bsps/powerpc/qemuppc/include/bsp/irq.h
index 1fd8b53a11..38ee77fc41 100644
--- a/bsps/powerpc/qemuppc/include/bsp/irq.h
+++ b/bsps/powerpc/qemuppc/include/bsp/irq.h
@@ -56,7 +56,7 @@
    */
 #define BSP_DECREMENTER			(BSP_PROCESSOR_IRQ_LOWEST_OFFSET)
 
-#define BSP_INTERRUPT_VECTOR_MAX BSP_MAX_OFFSET
+#define BSP_INTERRUPT_VECTOR_COUNT BSP_IRQ_NUMBER
 
 /* #include <bsp/irq_supp.h> */
 
diff --git a/bsps/powerpc/qoriq/include/bsp/irq.h b/bsps/powerpc/qoriq/include/bsp/irq.h
index 09a4279399..cf46832045 100644
--- a/bsps/powerpc/qoriq/include/bsp/irq.h
+++ b/bsps/powerpc/qoriq/include/bsp/irq.h
@@ -34,7 +34,7 @@ extern "C" {
 
 #ifdef QORIQ_IS_HYPERVISOR_GUEST
 
-#define BSP_INTERRUPT_VECTOR_MAX 1023
+#define BSP_INTERRUPT_VECTOR_COUNT 1024
 
 #else /* !QORIQ_IS_HYPERVISOR_GUEST */
 
@@ -350,7 +350,7 @@ extern "C" {
 #define QORIQ_IRQ_GT_B_2 (QORIQ_IRQ_GT_BASE + 6)
 #define QORIQ_IRQ_GT_B_3 (QORIQ_IRQ_GT_BASE + 7)
 
-#define BSP_INTERRUPT_VECTOR_MAX QORIQ_IRQ_GT_B_3
+#define BSP_INTERRUPT_VECTOR_COUNT (QORIQ_IRQ_GT_B_3 + 1)
 
 /** @} */
 
diff --git a/bsps/powerpc/qoriq/irq/irq.c b/bsps/powerpc/qoriq/irq/irq.c
index 7f9680ea1c..ffbff25dc6 100644
--- a/bsps/powerpc/qoriq/irq/irq.c
+++ b/bsps/powerpc/qoriq/irq/irq.c
@@ -128,7 +128,7 @@ rtems_status_code bsp_interrupt_facility_initialize(void)
 {
 	unsigned int i;
 
-	for (i = 0; i <= BSP_INTERRUPT_VECTOR_MAX; ++i) {
+	for (i = 0; i < BSP_INTERRUPT_VECTOR_COUNT; ++i) {
 		uint32_t config;
 		unsigned int priority;
 		uint32_t destination;
@@ -354,7 +354,7 @@ rtems_status_code bsp_interrupt_facility_initialize(void)
 
 		pic_reset();
 
-		for (i = 0; i <= BSP_INTERRUPT_VECTOR_MAX; ++i) {
+		for (i = 0; i < BSP_INTERRUPT_VECTOR_COUNT; ++i) {
 			volatile qoriq_pic_src_cfg *src_cfg = get_src_cfg(i);
 
 			src_cfg->vpr = VPR_MSK | VPR_P
@@ -375,7 +375,7 @@ rtems_status_code bsp_interrupt_facility_initialize(void)
 
 	qoriq.pic.ctpr = 0;
 
-	for (i = 0; i <= BSP_INTERRUPT_VECTOR_MAX; ++i) {
+	for (i = 0; i < BSP_INTERRUPT_VECTOR_COUNT; ++i) {
 		qoriq.pic.iack;
 		qoriq.pic.eoi = 0;
 		qoriq.pic.whoami;
diff --git a/bsps/powerpc/t32mppc/include/bsp/irq.h b/bsps/powerpc/t32mppc/include/bsp/irq.h
index 7ac3b1f676..998eadf3df 100644
--- a/bsps/powerpc/t32mppc/include/bsp/irq.h
+++ b/bsps/powerpc/t32mppc/include/bsp/irq.h
@@ -24,7 +24,7 @@
 extern "C" {
 #endif /* __cplusplus */
 
-#define BSP_INTERRUPT_VECTOR_MAX 0
+#define BSP_INTERRUPT_VECTOR_COUNT 1
 
 RTEMS_INLINE_ROUTINE void bsp_interrupt_set_affinity(
   rtems_vector_number   vector,
diff --git a/bsps/powerpc/tqm8xx/include/bsp/irq.h b/bsps/powerpc/tqm8xx/include/bsp/irq.h
index 3a5010d602..c3dfbed0d1 100644
--- a/bsps/powerpc/tqm8xx/include/bsp/irq.h
+++ b/bsps/powerpc/tqm8xx/include/bsp/irq.h
@@ -146,7 +146,7 @@ extern "C" {
 #define BSP_PERIODIC_TIMER	BSP_SIU_INT_IRQ_6
 #define BSP_FAST_ETHERNET_CTRL	BSP_SIU_INT_IRQ_3
 
-#define BSP_INTERRUPT_VECTOR_MAX BSP_MAX_OFFSET
+#define BSP_INTERRUPT_VECTOR_COUNT (BSP_MAX_OFFSET + 1)
 
 extern int BSP_irq_enabled_at_cpm(const rtems_irq_number irqLine);
 
diff --git a/bsps/powerpc/virtex/include/bsp/irq.h b/bsps/powerpc/virtex/include/bsp/irq.h
index 02fe972404..892f18be5e 100644
--- a/bsps/powerpc/virtex/include/bsp/irq.h
+++ b/bsps/powerpc/virtex/include/bsp/irq.h
@@ -61,7 +61,7 @@
           (BSP_IS_PROCESSOR_IRQ(irqnum)	\
            || BSP_IS_OPBINTC_IRQ(irqnum))
 
-#define BSP_INTERRUPT_VECTOR_MAX BSP_PROCESSOR_IRQ_MAX_OFFSET
+#define BSP_INTERRUPT_VECTOR_COUNT (BSP_PROCESSOR_IRQ_MAX_OFFSET + 1)
 
 #ifndef ASM
 #ifdef __cplusplus
diff --git a/bsps/riscv/griscv/include/bsp/irq.h b/bsps/riscv/griscv/include/bsp/irq.h
index 2100e6f7d3..f9e280d5a9 100644
--- a/bsps/riscv/griscv/include/bsp/irq.h
+++ b/bsps/riscv/griscv/include/bsp/irq.h
@@ -54,7 +54,7 @@
 
 #define RISCV_INTERRUPT_VECTOR_EXTERNAL_TO_INDEX(x) ((x) - 2)
 
-#define BSP_INTERRUPT_VECTOR_MAX RISCV_INTERRUPT_VECTOR_EXTERNAL(RISCV_MAXIMUM_EXTERNAL_INTERRUPTS - 1)
+#define BSP_INTERRUPT_VECTOR_COUNT RISCV_INTERRUPT_VECTOR_EXTERNAL(RISCV_MAXIMUM_EXTERNAL_INTERRUPTS)
 
 void bsp_interrupt_set_affinity(
   rtems_vector_number vector,
diff --git a/bsps/riscv/riscv/include/bsp/irq.h b/bsps/riscv/riscv/include/bsp/irq.h
index a902570155..306988d5e3 100644
--- a/bsps/riscv/riscv/include/bsp/irq.h
+++ b/bsps/riscv/riscv/include/bsp/irq.h
@@ -54,7 +54,7 @@
 
 #define RISCV_INTERRUPT_VECTOR_EXTERNAL_TO_INDEX(x) ((x) - 2)
 
-#define BSP_INTERRUPT_VECTOR_MAX RISCV_INTERRUPT_VECTOR_EXTERNAL(RISCV_MAXIMUM_EXTERNAL_INTERRUPTS - 1)
+#define BSP_INTERRUPT_VECTOR_COUNT RISCV_INTERRUPT_VECTOR_EXTERNAL(RISCV_MAXIMUM_EXTERNAL_INTERRUPTS)
 
 void bsp_interrupt_set_affinity(
   rtems_vector_number vector,
diff --git a/bsps/shared/irq/irq-generic.c b/bsps/shared/irq/irq-generic.c
index abe732a9d3..65971fb1b3 100644
--- a/bsps/shared/irq/irq-generic.c
+++ b/bsps/shared/irq/irq-generic.c
@@ -44,7 +44,7 @@
 
 #ifdef BSP_INTERRUPT_USE_INDEX_TABLE
   bsp_interrupt_handler_index_type bsp_interrupt_handler_index_table
-    [BSP_INTERRUPT_VECTOR_NUMBER];
+    [BSP_INTERRUPT_VECTOR_COUNT];
 #endif
 
 bsp_interrupt_handler_entry bsp_interrupt_handler_table
diff --git a/bsps/shared/irq/irq-info.c b/bsps/shared/irq/irq-info.c
index 697976e525..a52465ef09 100644
--- a/bsps/shared/irq/irq-info.c
+++ b/bsps/shared/irq/irq-info.c
@@ -87,7 +87,7 @@ void bsp_interrupt_report_with_plugin(
     "--------+----------------------------------+---------+------------+------------\n"
   );
 
-  for (v = 0; v <= BSP_INTERRUPT_VECTOR_MAX; ++v) {
+  for (v = 0; v < BSP_INTERRUPT_VECTOR_COUNT; ++v) {
     e.vector = v;
     rtems_interrupt_handler_iterate(
       v,
diff --git a/bsps/shared/irq/irq-server.c b/bsps/shared/irq/irq-server.c
index fa2153fcb0..8b9d82eb29 100644
--- a/bsps/shared/irq/irq-server.c
+++ b/bsps/shared/irq/irq-server.c
@@ -42,7 +42,7 @@
 
 #include <bsp/irq-generic.h>
 
-#define BSP_INTERRUPT_SERVER_MANAGEMENT_VECTOR (BSP_INTERRUPT_VECTOR_MAX + 1)
+#define BSP_INTERRUPT_SERVER_MANAGEMENT_VECTOR BSP_INTERRUPT_VECTOR_COUNT
 
 static rtems_interrupt_server_control bsp_interrupt_server_default;
 
diff --git a/bsps/sparc/erc32/include/bsp/irq.h b/bsps/sparc/erc32/include/bsp/irq.h
index ad3a65fcc1..7bf6cff2ff 100644
--- a/bsps/sparc/erc32/include/bsp/irq.h
+++ b/bsps/sparc/erc32/include/bsp/irq.h
@@ -20,8 +20,7 @@
 
 #include <rtems/score/processormask.h>
 
-#define BSP_INTERRUPT_VECTOR_MAX_STD 15 /* Standard IRQ controller */
-#define BSP_INTERRUPT_VECTOR_MAX BSP_INTERRUPT_VECTOR_MAX_STD
+#define BSP_INTERRUPT_VECTOR_COUNT 16 /* Standard IRQ controller */
 
 /* No extra check is needed */
 #undef BSP_INTERRUPT_CUSTOM_VALID_VECTOR
diff --git a/bsps/sparc/leon2/include/bsp/irq.h b/bsps/sparc/leon2/include/bsp/irq.h
index 287530e275..a85eefaf10 100644
--- a/bsps/sparc/leon2/include/bsp/irq.h
+++ b/bsps/sparc/leon2/include/bsp/irq.h
@@ -18,8 +18,7 @@
 #ifndef LIBBSP_LEON2_IRQ_CONFIG_H
 #define LIBBSP_LEON2_IRQ_CONFIG_H
 
-#define BSP_INTERRUPT_VECTOR_MAX_STD 15 /* Standard IRQ controller */
-#define BSP_INTERRUPT_VECTOR_MAX BSP_INTERRUPT_VECTOR_MAX_STD
+#define BSP_INTERRUPT_VECTOR_COUNT 16 /* Standard IRQ controller */
 
 /* No extra check is needed */
 #undef BSP_INTERRUPT_CUSTOM_VALID_VECTOR
diff --git a/bsps/sparc/leon3/include/bsp/irq.h b/bsps/sparc/leon3/include/bsp/irq.h
index 77f9fc2528..980f3f5bfb 100644
--- a/bsps/sparc/leon3/include/bsp/irq.h
+++ b/bsps/sparc/leon3/include/bsp/irq.h
@@ -21,10 +21,7 @@
 #include <leon.h>
 #include <rtems/score/processormask.h>
 
-#define BSP_INTERRUPT_VECTOR_MAX_STD 15 /* Standard IRQ controller */
-#define BSP_INTERRUPT_VECTOR_MAX_EXT 31 /* Extended IRQ controller */
-
-#define BSP_INTERRUPT_VECTOR_MAX BSP_INTERRUPT_VECTOR_MAX_EXT
+#define BSP_INTERRUPT_VECTOR_COUNT 32
 
 /* The check is different depending on IRQ controller, runtime detected */
 #define BSP_INTERRUPT_CUSTOM_VALID_VECTOR
@@ -35,9 +32,9 @@
 static inline bool bsp_interrupt_is_valid_vector(rtems_vector_number vector)
 {
   if (LEON3_IrqCtrl_EIrq != 0) {
-    return vector <= BSP_INTERRUPT_VECTOR_MAX_EXT;
+    return vector < BSP_INTERRUPT_VECTOR_COUNT;
   } else {
-    return vector <= BSP_INTERRUPT_VECTOR_MAX_STD;
+    return vector < 16; /* Standard IRQ controller */
   }
 }
 
diff --git a/bsps/sparc/shared/irq/irq-shared.c b/bsps/sparc/shared/irq/irq-shared.c
index e0ac7d7f06..f7dba795c7 100644
--- a/bsps/sparc/shared/irq/irq-shared.c
+++ b/bsps/sparc/shared/irq/irq-shared.c
@@ -44,7 +44,7 @@ void BSP_shared_interrupt_init(void)
   rtems_isr_entry previous_isr;
   int i;
 
-  for (i=0; i <= BSP_INTERRUPT_VECTOR_MAX_STD; i++) {
+  for (i=0; i < BSP_INTERRUPT_VECTOR_COUNT; i++) {
 #if defined(LEON3) && (defined(RTEMS_SMP) || defined(RTEMS_MULTIPROCESSING))
     /* Don't install IRQ handler on IPI interrupt */
     if (i == LEON3_mp_irq)
diff --git a/bsps/x86_64/include/bsp/irq.h b/bsps/x86_64/include/bsp/irq.h
index 312c831962..4a7c34489e 100644
--- a/bsps/x86_64/include/bsp/irq.h
+++ b/bsps/x86_64/include/bsp/irq.h
@@ -39,7 +39,7 @@
 #include <rtems/irq-extension.h>
 
 #define BSP_IRQ_VECTOR_NUMBER     34
-#define BSP_INTERRUPT_VECTOR_MAX  BSP_IRQ_VECTOR_NUMBER
+#define BSP_INTERRUPT_VECTOR_COUNT  BSP_IRQ_VECTOR_NUMBER
 
 #endif /* !ASM */
 #endif /* LIBBSP_GENERIC_RISCV_IRQ_H */
diff --git a/testsuites/smptests/smpcapture02/init.c b/testsuites/smptests/smpcapture02/init.c
index 9cf1f0b006..4b11e6bbd7 100644
--- a/testsuites/smptests/smpcapture02/init.c
+++ b/testsuites/smptests/smpcapture02/init.c
@@ -316,7 +316,7 @@ static void Init(rtems_task_argument arg)
   test(cpu_count);
 
   /* Try to find the clock interrupt handler */
-  for ( vec = 0; vec < BSP_INTERRUPT_VECTOR_MAX; vec++ ) {
+  for ( vec = 0; vec < BSP_INTERRUPT_VECTOR_COUNT; vec++ ) {
     rtems_interrupt_handler_iterate(vec, locate_clock_interrupt_handler, &cih);
     if ( cih.found )
       break;
-- 
2.26.2





More information about the devel mailing list