Skip to content

Commit

Permalink
Devices: Ensure IRQn_Type enum size matches maximum value
Browse files Browse the repository at this point in the history
This change fixes a bug where a compiler choses a signed byte
to store the IRQn_Type enum type as all listed enum values
fit a signed byte. This causes undefined behavior when calling
functions such as NVIC_EnableIRQ with interrupt channels greater
than 127 as these do not fit a signed byte. As a result,
interrupt channels higher than 127 cannot be enabled, disabled,
or triggered.

Fix this by listing the highest possible interrupt channel in
each enum declaration which ensures that a storage type is chosen
that can accommodate all valid interrupt channels.

Tested on a MEC1527 devices by triggering interrupt channel
171 (watchdog) and observing that the ISR is executed.
  • Loading branch information
axel-simon committed May 3, 2023
1 parent 7b8c3f3 commit e94a962
Show file tree
Hide file tree
Showing 22 changed files with 111 additions and 88 deletions.
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM0/Include/ARMCM0.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM0.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM0 Device
* @version V5.3.1
* @date 09. July 2018
* @version V5.3.2
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -56,8 +56,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 31 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 30 are left out */
Interrupt31_IRQn = 31
} IRQn_Type;


Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM0plus/Include/ARMCM0plus.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM0plus.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM0plus Device
* @version V5.3.1
* @date 09. July 2018
* @version V5.3.2
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -56,8 +56,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 31 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 30 are left out */
Interrupt31_IRQn = 31
} IRQn_Type;


Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM0plus/Include/ARMCM0plus_MPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM0plus_MPU.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM0plus Device (configured for CM0+ with MPU)
* @version V5.3.1
* @date 09. July 2018
* @version V5.3.2
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -56,8 +56,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 31 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 30 are left out */
Interrupt31_IRQn = 31
} IRQn_Type;


Expand Down
10 changes: 6 additions & 4 deletions Device/ARM/ARMCM1/Include/ARMCM1.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM1.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM1 Device
* @version V5.3.1
* @date 20. July 2018
* @version V5.3.2
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -56,11 +56,13 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 31 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 30 are left out */
Interrupt31_IRQn = 31
} IRQn_Type;



/* ================================================================================ */
/* ================ Processor and Core Peripheral Section ================ */
/* ================================================================================ */
Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM23/Include/ARMCM23.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM23.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM23 Device
* @version V5.3.1
* @date 09. July 2018
* @version V5.3.2
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -56,8 +56,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 224 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 223 are left out */
Interrupt224_IRQn = 224
} IRQn_Type;


Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM23/Include/ARMCM23_TZ.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM23_TZ.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM23 Device (configured for TrustZone)
* @version V5.3.1
* @date 09. July 2018
* @version V5.3.2
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -56,8 +56,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 224 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 223 are left out */
Interrupt224_IRQn = 224
} IRQn_Type;


Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM3/Include/ARMCM3.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM3.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM3 Device
* @version V5.3.1
* @date 09. July 2018
* @version V5.3.2
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -56,8 +56,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 224 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 223 are left out */
Interrupt224_IRQn = 224
} IRQn_Type;


Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM33/Include/ARMCM33.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM33.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM33 Device (configured for ARMCM33 without FPU, without DSP extension, without TrustZone)
* @version V5.3.1
* @date 09. July 2018
* @version V5.3.2
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -57,8 +57,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 480 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 479 are left out */
Interrupt480_IRQn = 480
} IRQn_Type;


Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM33/Include/ARMCM33_DSP_FP.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM33_DSP_FP.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM33 Device (configured for ARMCM33 with FPU, with DSP extension)
* @version V5.3.1
* @date 09. July 2018
* @version V5.3.2
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -57,8 +57,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 480 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 479 are left out */
Interrupt480_IRQn = 480
} IRQn_Type;


Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM33/Include/ARMCM33_DSP_FP_TZ.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM33_DSP_FP_TZ.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM33 Device (configured for ARMCM33 with FPU, with DSP extension, with TrustZone)
* @version V5.3.1
* @date 09. July 2018
* @version V5.3.2
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -57,8 +57,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 480 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 479 are left out */
Interrupt480_IRQn = 480
} IRQn_Type;


Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM33/Include/ARMCM33_TZ.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM33_TZ.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM33 Device (configured for ARMCM33 without FPU, without DSP extension, with TrustZone)
* @version V5.3.1
* @date 09. July 2018
* @version V5.3.2
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -57,8 +57,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 480 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 479 are left out */
Interrupt480_IRQn = 480
} IRQn_Type;


Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM35P/Include/ARMCM35P.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM35P.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM35P Device (configured for ARMCM35P without FPU, without DSP extension, without TrustZone)
* @version V1.0.0
* @date 03. September 2018
* @version V1.0.1
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -57,8 +57,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 480 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 479 are left out */
Interrupt480_IRQn = 480
} IRQn_Type;


Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM35P/Include/ARMCM35P_DSP_FP.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM35P_DSP_FP.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM35P Device (configured for ARMCM35P with FPU, with DSP extension)
* @version V1.0.0
* @date 03. September 2018
* @version V1.0.1
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -57,8 +57,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 480 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 479 are left out */
Interrupt480_IRQn = 480
} IRQn_Type;


Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM35P/Include/ARMCM35P_DSP_FP_TZ.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM35P_DSP_FP_TZ.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM35P Device (configured for ARMCM35P with FPU, with DSP extension, with TrustZone)
* @version V1.0.0
* @date 03. September 2018
* @version V1.0.1
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -57,8 +57,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 480 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 479 are left out */
Interrupt480_IRQn = 480
} IRQn_Type;


Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM35P/Include/ARMCM35P_TZ.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM35P_TZ.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM35P Device (configured for ARMCM35P without FPU, without DSP extension, with TrustZone)
* @version V1.0.0
* @date 03. September 2018
* @version V1.0.1
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -57,8 +57,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 480 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 479 are left out */
Interrupt480_IRQn = 480
} IRQn_Type;


Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM4/Include/ARMCM4.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM4.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM4 Device (configured for CM4 without FPU)
* @version V5.3.1
* @date 09. July 2018
* @version V5.3.2
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -56,8 +56,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 224 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 223 are left out */
Interrupt224_IRQn = 224
} IRQn_Type;


Expand Down
9 changes: 5 additions & 4 deletions Device/ARM/ARMCM4/Include/ARMCM4_FP.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
* @file ARMCM4_FP.h
* @brief CMSIS Core Peripheral Access Layer Header File for
* ARMCM4 Device (configured for CM4 with FPU)
* @version V5.3.1
* @date 09. July 2018
* @version V5.3.2
* @date 01. May 2023
******************************************************************************/
/*
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
Expand Down Expand Up @@ -56,8 +56,9 @@ typedef enum IRQn
Interrupt6_IRQn = 6,
Interrupt7_IRQn = 7,
Interrupt8_IRQn = 8,
Interrupt9_IRQn = 9
/* Interrupts 10 .. 224 are left out */
Interrupt9_IRQn = 9,
/* Interrupts 10 .. 223 are left out */
Interrupt224_IRQn = 224
} IRQn_Type;


Expand Down

0 comments on commit e94a962

Please sign in to comment.