arm: set DebugMonitor IRQ unconditionally during initialization

If the DebugMonitor extension is implemented by the core,
the interrupt may be pended and become active, even if it
is not enabled. Set the priority level of DebugMonitor upon
system initialization to the intended value unconditionally
so we do not end up in undefined behavior, if the exception
is accidentally pended. Since the priority level is set at
init, we can remove resetting the priority in DWT driver
initialization.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
Ioannis Glaropoulos 2021-06-16 15:55:36 +02:00 committed by Christopher Friedt
commit 70984a1587
2 changed files with 7 additions and 2 deletions

View file

@ -163,8 +163,10 @@ static inline void z_arm_dwt_enable_debug_monitor(void)
"DebugMonitor targets Non-Secure\n");
#endif
/* Set the DebugMonitor handler priority to the higyhest value. */
NVIC_SetPriority(DebugMonitor_IRQn, _EXC_FAULT_PRIO);
/* The DebugMonitor handler priority is set already
* to the highest value (_EXC_FAULT_PRIO) during
* system initialization.
*/
/* Enable debug monitor exception triggered on debug events */
CoreDebug->DEMCR |= CoreDebug_DEMCR_MON_EN_Msk;

View file

@ -114,6 +114,9 @@ static ALWAYS_INLINE void z_arm_exc_setup(void)
NVIC_SetPriority(MemoryManagement_IRQn, _EXC_FAULT_PRIO);
NVIC_SetPriority(BusFault_IRQn, _EXC_FAULT_PRIO);
NVIC_SetPriority(UsageFault_IRQn, _EXC_FAULT_PRIO);
#if defined(CONFIG_CPU_CORTEX_M_HAS_DWT)
NVIC_SetPriority(DebugMonitor_IRQn, _EXC_FAULT_PRIO);
#endif
#if defined(CONFIG_ARM_SECURE_FIRMWARE)
NVIC_SetPriority(SecureFault_IRQn, _EXC_FAULT_PRIO);
#endif /* CONFIG_ARM_SECURE_FIRMWARE */