[PATCH v2 09/12] bsps/irq: Use BSP_INTERRUPT_VECTOR_COUNT

Sebastian Huber sebastian.huber at embedded-brains.de
Sat Jun 19 14:04:45 UTC 2021


Use BSP_INTERRUPT_VECTOR_COUNT instead of BSP_INTERRUPT_VECTOR_MAX.

Update #3269.
---
 bsps/arm/atsam/start/bspstart.c         | 2 +-
 bsps/arm/beagle/irq/irq.c               | 2 +-
 bsps/arm/lpc176x/irq/irq.c              | 2 +-
 bsps/arm/lpc24xx/irq/irq.c              | 4 ++--
 bsps/arm/lpc32xx/include/bsp/irq.h      | 2 +-
 bsps/arm/shared/irq/irq-armv7m.c        | 2 +-
 bsps/arm/shared/start/start.S           | 2 +-
 bsps/arm/tms570/irq/irq.c               | 2 +-
 bsps/include/bsp/irq-generic.h          | 8 ++++----
 bsps/m68k/genmcf548x/irq/irq.c          | 4 ++--
 bsps/mips/shared/irq/irq.c              | 2 +-
 bsps/powerpc/qoriq/irq/irq.c            | 6 +++---
 bsps/shared/irq/irq-info.c              | 2 +-
 bsps/shared/irq/irq-server.c            | 2 +-
 testsuites/smptests/smpcapture02/init.c | 2 +-
 15 files changed, 22 insertions(+), 22 deletions(-)

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/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/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/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 d6f7e3144e..02fce3258a 100644
--- a/bsps/arm/lpc32xx/include/bsp/irq.h
+++ b/bsps/arm/lpc32xx/include/bsp/irq.h
@@ -142,7 +142,7 @@ extern "C" {
 #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/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/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/include/bsp/irq-generic.h b/bsps/include/bsp/irq-generic.h
index 749dc78988..ad64c457d6 100644
--- a/bsps/include/bsp/irq-generic.h
+++ b/bsps/include/bsp/irq-generic.h
@@ -132,8 +132,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
@@ -144,7 +144,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
@@ -179,7 +179,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/m68k/genmcf548x/irq/irq.c b/bsps/m68k/genmcf548x/irq/irq.c
index d010865152..547e851cdd 100644
--- a/bsps/m68k/genmcf548x/irq/irq.c
+++ b/bsps/m68k/genmcf548x/irq/irq.c
@@ -19,7 +19,7 @@
 static inline bool is_valid_vector(rtems_vector_number vector)
 {
   return 1 <= vector
-    && vector <= (rtems_vector_number) BSP_INTERRUPT_VECTOR_MAX;
+    && vector < (rtems_vector_number) BSP_INTERRUPT_VECTOR_COUNT;
 }
 
 void asm_default_interrupt(void);
@@ -32,7 +32,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/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/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/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/testsuites/smptests/smpcapture02/init.c b/testsuites/smptests/smpcapture02/init.c
index 329fd344e6..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