You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by an...@apache.org on 2019/07/02 11:53:55 UTC

[mynewt-core] branch master updated: kernel/os/arch: Reset all handlers to os_default_irq_asm

This is an automated email from the ASF dual-hosted git repository.

andk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 156943b  kernel/os/arch: Reset all handlers to os_default_irq_asm
156943b is described below

commit 156943b9e3e3c9ec8f20b906bd277a61eea9964e
Author: Andrzej Kaczmarek <an...@codecoup.pl>
AuthorDate: Mon May 13 23:13:25 2019 +0200

    kernel/os/arch: Reset all handlers to os_default_irq_asm
    
    Instead of leaving some (possibly) unused interrupt handlers set to
    default values set by startup code, let's just set all of them to
    our os_default_irq_asm.
    
    This allows to avoid magic numbers like "-13" for HardFault_IRQn which
    for some reason is not defined for some ST MCUs.
---
 kernel/os/src/arch/cortex_m0/os_arch_arm.c  | 22 +++++++++++-----------
 kernel/os/src/arch/cortex_m3/os_arch_arm.c  | 24 +++++++++++-------------
 kernel/os/src/arch/cortex_m33/os_arch_arm.c | 24 +++++++++++-------------
 kernel/os/src/arch/cortex_m4/os_arch_arm.c  | 24 +++++++++++-------------
 kernel/os/src/arch/cortex_m7/os_arch_arm.c  | 24 +++++++++++-------------
 5 files changed, 55 insertions(+), 63 deletions(-)

diff --git a/kernel/os/src/arch/cortex_m0/os_arch_arm.c b/kernel/os/src/arch/cortex_m0/os_arch_arm.c
index cd8515f..3fd9091 100644
--- a/kernel/os/src/arch/cortex_m0/os_arch_arm.c
+++ b/kernel/os/src/arch/cortex_m0/os_arch_arm.c
@@ -201,22 +201,22 @@ os_arch_os_init(void)
             NVIC->IP[i] = -1;
         }
 
-        NVIC_SetVector(SVC_IRQ_NUMBER, (uint32_t)SVC_Handler);
-        NVIC_SetVector(PendSV_IRQn, (uint32_t)PendSV_Handler);
-        NVIC_SetVector(SysTick_IRQn, (uint32_t)SysTick_Handler);
-
         /*
-         * Install default interrupt handler, which'll print out system
-         * state at the time of the interrupt, and few other regs which
-         * should help in trying to figure out what went wrong.
+         * Install default interrupt handler for all interrupts except Reset,
+         * which'll print out system state at the time of the interrupt, and
+         * few other regs which should help in trying to figure out what went
+         * wrong.
          */
-        NVIC_SetVector(NonMaskableInt_IRQn, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(HardFault_IRQn, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(-13, (uint32_t)os_default_irq_asm); /* Hardfault */
-        for (i = 0; i < NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET; i++) {
+        for (i = -NVIC_USER_IRQ_OFFSET + 2;
+             i < NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET; i++) {
             NVIC_SetVector(i, (uint32_t)os_default_irq_asm);
         }
 
+        /* Install our system interrupt handlers */
+        NVIC_SetVector(SVC_IRQ_NUMBER, (uint32_t)SVC_Handler);
+        NVIC_SetVector(PendSV_IRQn, (uint32_t)PendSV_Handler);
+        NVIC_SetVector(SysTick_IRQn, (uint32_t)SysTick_Handler);
+
         /* Set the PendSV interrupt exception priority to the lowest priority */
         NVIC_SetPriority(PendSV_IRQn, PEND_SV_PRIO);
 
diff --git a/kernel/os/src/arch/cortex_m3/os_arch_arm.c b/kernel/os/src/arch/cortex_m3/os_arch_arm.c
index c498d93..6219339 100644
--- a/kernel/os/src/arch/cortex_m3/os_arch_arm.c
+++ b/kernel/os/src/arch/cortex_m3/os_arch_arm.c
@@ -210,24 +210,22 @@ os_arch_os_init(void)
             NVIC->IP[i] = -1;
         }
 
-        NVIC_SetVector(SVC_IRQ_NUMBER, (uint32_t)SVC_Handler);
-        NVIC_SetVector(PendSV_IRQn, (uint32_t)PendSV_Handler);
-        NVIC_SetVector(SysTick_IRQn, (uint32_t)SysTick_Handler);
-
         /*
-         * Install default interrupt handler, which'll print out system
-         * state at the time of the interrupt, and few other regs which
-         * should help in trying to figure out what went wrong.
+         * Install default interrupt handler for all interrupts except Reset,
+         * which'll print out system state at the time of the interrupt, and
+         * few other regs which should help in trying to figure out what went
+         * wrong.
          */
-        NVIC_SetVector(NonMaskableInt_IRQn, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(-13, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(MemoryManagement_IRQn, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(BusFault_IRQn, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(UsageFault_IRQn, (uint32_t)os_default_irq_asm);
-        for (i = 0; i < NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET; i++) {
+        for (i = -NVIC_USER_IRQ_OFFSET + 2;
+             i < NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET; i++) {
             NVIC_SetVector(i, (uint32_t)os_default_irq_asm);
         }
 
+        /* Install our system interrupt handlers */
+        NVIC_SetVector(SVC_IRQ_NUMBER, (uint32_t)SVC_Handler);
+        NVIC_SetVector(PendSV_IRQn, (uint32_t)PendSV_Handler);
+        NVIC_SetVector(SysTick_IRQn, (uint32_t)SysTick_Handler);
+
         /* Set the PendSV interrupt exception priority to the lowest priority */
         NVIC_SetPriority(PendSV_IRQn, PEND_SV_PRIO);
 
diff --git a/kernel/os/src/arch/cortex_m33/os_arch_arm.c b/kernel/os/src/arch/cortex_m33/os_arch_arm.c
index 221b12f..4b79392 100644
--- a/kernel/os/src/arch/cortex_m33/os_arch_arm.c
+++ b/kernel/os/src/arch/cortex_m33/os_arch_arm.c
@@ -214,24 +214,22 @@ os_arch_os_init(void)
             NVIC->IPR[i] = -1;
         }
 
-        NVIC_SetVector(SVCall_IRQn, (uint32_t)SVC_Handler);
-        NVIC_SetVector(PendSV_IRQn, (uint32_t)PendSV_Handler);
-        NVIC_SetVector(SysTick_IRQn, (uint32_t)SysTick_Handler);
-
         /*
-         * Install default interrupt handler, which'll print out system
-         * state at the time of the interrupt, and few other regs which
-         * should help in trying to figure out what went wrong.
+         * Install default interrupt handler for all interrupts except Reset,
+         * which'll print out system state at the time of the interrupt, and
+         * few other regs which should help in trying to figure out what went
+         * wrong.
          */
-        NVIC_SetVector(NonMaskableInt_IRQn, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(-13, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(MemoryManagement_IRQn, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(BusFault_IRQn, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(UsageFault_IRQn, (uint32_t)os_default_irq_asm);
-        for (i = 0; i < NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET; i++) {
+        for (i = -NVIC_USER_IRQ_OFFSET + 2;
+             i < NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET; i++) {
             NVIC_SetVector(i, (uint32_t)os_default_irq_asm);
         }
 
+        /* Install our system interrupt handlers */
+        NVIC_SetVector(SVCall_IRQn, (uint32_t)SVC_Handler);
+        NVIC_SetVector(PendSV_IRQn, (uint32_t)PendSV_Handler);
+        NVIC_SetVector(SysTick_IRQn, (uint32_t)SysTick_Handler);
+
         /* Set the PendSV interrupt exception priority to the lowest priority */
         NVIC_SetPriority(PendSV_IRQn, PEND_SV_PRIO);
 
diff --git a/kernel/os/src/arch/cortex_m4/os_arch_arm.c b/kernel/os/src/arch/cortex_m4/os_arch_arm.c
index a208347..1826ed9 100644
--- a/kernel/os/src/arch/cortex_m4/os_arch_arm.c
+++ b/kernel/os/src/arch/cortex_m4/os_arch_arm.c
@@ -214,24 +214,22 @@ os_arch_os_init(void)
             NVIC->IP[i] = -1;
         }
 
-        NVIC_SetVector(SVCall_IRQn, (uint32_t)SVC_Handler);
-        NVIC_SetVector(PendSV_IRQn, (uint32_t)PendSV_Handler);
-        NVIC_SetVector(SysTick_IRQn, (uint32_t)SysTick_Handler);
-
         /*
-         * Install default interrupt handler, which'll print out system
-         * state at the time of the interrupt, and few other regs which
-         * should help in trying to figure out what went wrong.
+         * Install default interrupt handler for all interrupts except Reset,
+         * which'll print out system state at the time of the interrupt, and
+         * few other regs which should help in trying to figure out what went
+         * wrong.
          */
-        NVIC_SetVector(NonMaskableInt_IRQn, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(-13, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(MemoryManagement_IRQn, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(BusFault_IRQn, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(UsageFault_IRQn, (uint32_t)os_default_irq_asm);
-        for (i = 0; i < NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET; i++) {
+        for (i = -NVIC_USER_IRQ_OFFSET + 2;
+             i < NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET; i++) {
             NVIC_SetVector(i, (uint32_t)os_default_irq_asm);
         }
 
+        /* Install our system interrupt handlers */
+        NVIC_SetVector(SVCall_IRQn, (uint32_t)SVC_Handler);
+        NVIC_SetVector(PendSV_IRQn, (uint32_t)PendSV_Handler);
+        NVIC_SetVector(SysTick_IRQn, (uint32_t)SysTick_Handler);
+
         /* Set the PendSV interrupt exception priority to the lowest priority */
         NVIC_SetPriority(PendSV_IRQn, PEND_SV_PRIO);
 
diff --git a/kernel/os/src/arch/cortex_m7/os_arch_arm.c b/kernel/os/src/arch/cortex_m7/os_arch_arm.c
index a208347..1826ed9 100644
--- a/kernel/os/src/arch/cortex_m7/os_arch_arm.c
+++ b/kernel/os/src/arch/cortex_m7/os_arch_arm.c
@@ -214,24 +214,22 @@ os_arch_os_init(void)
             NVIC->IP[i] = -1;
         }
 
-        NVIC_SetVector(SVCall_IRQn, (uint32_t)SVC_Handler);
-        NVIC_SetVector(PendSV_IRQn, (uint32_t)PendSV_Handler);
-        NVIC_SetVector(SysTick_IRQn, (uint32_t)SysTick_Handler);
-
         /*
-         * Install default interrupt handler, which'll print out system
-         * state at the time of the interrupt, and few other regs which
-         * should help in trying to figure out what went wrong.
+         * Install default interrupt handler for all interrupts except Reset,
+         * which'll print out system state at the time of the interrupt, and
+         * few other regs which should help in trying to figure out what went
+         * wrong.
          */
-        NVIC_SetVector(NonMaskableInt_IRQn, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(-13, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(MemoryManagement_IRQn, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(BusFault_IRQn, (uint32_t)os_default_irq_asm);
-        NVIC_SetVector(UsageFault_IRQn, (uint32_t)os_default_irq_asm);
-        for (i = 0; i < NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET; i++) {
+        for (i = -NVIC_USER_IRQ_OFFSET + 2;
+             i < NVIC_NUM_VECTORS - NVIC_USER_IRQ_OFFSET; i++) {
             NVIC_SetVector(i, (uint32_t)os_default_irq_asm);
         }
 
+        /* Install our system interrupt handlers */
+        NVIC_SetVector(SVCall_IRQn, (uint32_t)SVC_Handler);
+        NVIC_SetVector(PendSV_IRQn, (uint32_t)PendSV_Handler);
+        NVIC_SetVector(SysTick_IRQn, (uint32_t)SysTick_Handler);
+
         /* Set the PendSV interrupt exception priority to the lowest priority */
         NVIC_SetPriority(PendSV_IRQn, PEND_SV_PRIO);