diff --git a/arch/arm/src/armv6-m/arm_doirq.c b/arch/arm/src/armv6-m/arm_doirq.c index b9683a57081b2..fea1620bd207a 100644 --- a/arch/arm/src/armv6-m/arm_doirq.c +++ b/arch/arm/src/armv6-m/arm_doirq.c @@ -67,25 +67,27 @@ uint32_t *arm_doirq(int irq, uint32_t *regs) arm_ack_irq(irq); + /* Set current regs for crash dump */ + + up_set_current_regs(regs); + if (irq == NVIC_IRQ_PENDSV) { +#ifdef CONFIG_ARCH_HIPRI_INTERRUPT + /* Dispatch the PendSV interrupt */ + + irq_dispatch(irq, regs); +#endif + up_irq_save(); g_running_tasks[this_cpu()]->xcp.regs = regs; } else { - /* Set current regs for crash dump */ - - up_set_current_regs(regs); - /* Dispatch irq */ tcb->xcp.regs = regs; irq_dispatch(irq, regs); - - /* Clear current regs */ - - up_set_current_regs(NULL); } /* If a context switch occurred while processing the interrupt then @@ -110,6 +112,11 @@ uint32_t *arm_doirq(int irq, uint32_t *regs) regs = tcb->xcp.regs; #endif + /* Clear current regs */ + + up_set_current_regs(NULL); + board_autoled_off(LED_INIRQ); + return regs; } diff --git a/arch/arm/src/armv7-m/arm_doirq.c b/arch/arm/src/armv7-m/arm_doirq.c index 2f532969a53f0..a14b24e6a4222 100644 --- a/arch/arm/src/armv7-m/arm_doirq.c +++ b/arch/arm/src/armv7-m/arm_doirq.c @@ -67,25 +67,27 @@ uint32_t *arm_doirq(int irq, uint32_t *regs) arm_ack_irq(irq); + /* Set current regs for crash dump */ + + up_set_current_regs(regs); + if (irq == NVIC_IRQ_PENDSV) { +#ifdef CONFIG_ARCH_HIPRI_INTERRUPT + /* Dispatch the PendSV interrupt */ + + irq_dispatch(irq, regs); +#endif + up_irq_save(); g_running_tasks[this_cpu()]->xcp.regs = regs; } else { - /* Set current regs for crash dump */ - - up_set_current_regs(regs); - /* Dispatch irq */ tcb->xcp.regs = regs; irq_dispatch(irq, regs); - - /* Clear current regs */ - - up_set_current_regs(NULL); } /* If a context switch occurred while processing the interrupt then @@ -110,6 +112,11 @@ uint32_t *arm_doirq(int irq, uint32_t *regs) regs = tcb->xcp.regs; #endif + /* Clear current regs */ + + up_set_current_regs(NULL); + board_autoled_off(LED_INIRQ); + return regs; } diff --git a/arch/arm/src/armv8-m/arm_doirq.c b/arch/arm/src/armv8-m/arm_doirq.c index d024d1ebad45f..0f3fad50bbe12 100644 --- a/arch/arm/src/armv8-m/arm_doirq.c +++ b/arch/arm/src/armv8-m/arm_doirq.c @@ -67,25 +67,27 @@ uint32_t *arm_doirq(int irq, uint32_t *regs) arm_ack_irq(irq); + /* Set current regs for crash dump */ + + up_set_current_regs(regs); + if (irq == NVIC_IRQ_PENDSV) { +#ifdef CONFIG_ARCH_HIPRI_INTERRUPT + /* Dispatch the PendSV interrupt */ + + irq_dispatch(irq, regs); +#endif + up_irq_save(); g_running_tasks[this_cpu()]->xcp.regs = regs; } else { - /* Set current regs for crash dump */ - - up_set_current_regs(regs); - /* Dispatch irq */ tcb->xcp.regs = regs; irq_dispatch(irq, regs); - - /* Clear current regs */ - - up_set_current_regs(NULL); } /* If a context switch occurred while processing the interrupt then @@ -110,6 +112,10 @@ uint32_t *arm_doirq(int irq, uint32_t *regs) regs = tcb->xcp.regs; #endif + /* Clear current regs */ + + up_set_current_regs(NULL); + board_autoled_off(LED_INIRQ); #ifdef CONFIG_ARMV8M_TRUSTZONE_HYBRID diff --git a/arch/arm/src/lpc17xx_40xx/lpc17_40_irq.c b/arch/arm/src/lpc17xx_40xx/lpc17_40_irq.c index d0f131656890a..7c971c81fb518 100644 --- a/arch/arm/src/lpc17xx_40xx/lpc17_40_irq.c +++ b/arch/arm/src/lpc17xx_40xx/lpc17_40_irq.c @@ -137,9 +137,11 @@ static int lpc17_40_nmi(int irq, void *context, void *arg) static int lpc17_40_pendsv(int irq, void *context, void *arg) { +#ifndef CONFIG_ARCH_HIPRI_INTERRUPT up_irq_save(); _err("PANIC!!! PendSV received\n"); PANIC(); +#endif return 0; } diff --git a/arch/arm/src/mps/mps_irq.c b/arch/arm/src/mps/mps_irq.c index c6091959ee37e..1e882bbafa109 100644 --- a/arch/arm/src/mps/mps_irq.c +++ b/arch/arm/src/mps/mps_irq.c @@ -61,9 +61,11 @@ static int mps_nmi(int irq, void *context, void *arg) static int mps_pendsv(int irq, void *context, void *arg) { +#ifndef CONFIG_ARCH_HIPRI_INTERRUPT up_irq_save(); _err("PANIC!!! PendSV received\n"); PANIC(); +#endif return 0; } diff --git a/arch/arm/src/nrf52/nrf52_irq.c b/arch/arm/src/nrf52/nrf52_irq.c index 7c400bbf9ca95..2e916afc72a39 100644 --- a/arch/arm/src/nrf52/nrf52_irq.c +++ b/arch/arm/src/nrf52/nrf52_irq.c @@ -143,9 +143,11 @@ static int nrf52_nmi(int irq, void *context, void *arg) static int nrf52_pendsv(int irq, void *context, void *arg) { +#ifndef CONFIG_ARCH_HIPRI_INTERRUPT up_irq_save(); _err("PANIC!!! PendSV received\n"); PANIC(); +#endif return 0; } diff --git a/arch/arm/src/stm32/stm32_irq.c b/arch/arm/src/stm32/stm32_irq.c index 99374e5db7964..7a63323a37d53 100644 --- a/arch/arm/src/stm32/stm32_irq.c +++ b/arch/arm/src/stm32/stm32_irq.c @@ -148,9 +148,11 @@ static int stm32_nmi(int irq, void *context, void *arg) static int stm32_pendsv(int irq, void *context, void *arg) { +#ifndef CONFIG_ARCH_HIPRI_INTERRUPT up_irq_save(); _err("PANIC!!! PendSV received\n"); PANIC(); +#endif return 0; } diff --git a/arch/arm/src/stm32l4/stm32l4_irq.c b/arch/arm/src/stm32l4/stm32l4_irq.c index e8c0031550c9e..8499204741b25 100644 --- a/arch/arm/src/stm32l4/stm32l4_irq.c +++ b/arch/arm/src/stm32l4/stm32l4_irq.c @@ -145,9 +145,11 @@ static int stm32l4_nmi(int irq, void *context, void *arg) static int stm32l4_pendsv(int irq, void *context, void *arg) { +#ifndef CONFIG_ARCH_HIPRI_INTERRUPT up_irq_save(); _err("PANIC!!! PendSV received\n"); PANIC(); +#endif return 0; }