This is an automated email from the ASF dual-hosted git repository. GUIDINGLI pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit f19c27705d31d146011ab1631c6c08baf2a81d90 Author: buxiasen <[email protected]> AuthorDate: Wed Dec 17 16:39:02 2025 +0800 arch/arm_m: merge src/x_fault.c systemreset triggerirq into arm_m Remove dup to reducethe maintain cost Signed-off-by: buxiasen <[email protected]> --- arch/arm/src/arm_m/CMakeLists.txt | 23 +++- arch/arm/src/arm_m/Make.defs | 15 ++- arch/arm/src/{armv8-m => arm_m}/arm_busfault.c | 2 +- .../src/{armv8-m => arm_m}/arm_gen_nonsecfault.c | 2 +- arch/arm/src/{armv8-m => arm_m}/arm_hardfault.c | 46 ++++++- arch/arm/src/{armv8-m => arm_m}/arm_memfault.c | 3 +- arch/arm/src/{armv8-m => arm_m}/arm_securefault.c | 2 +- arch/arm/src/{armv8-m => arm_m}/arm_systemreset.c | 2 +- arch/arm/src/{armv7-m => arm_m}/arm_trigger_irq.c | 2 +- arch/arm/src/{armv8-m => arm_m}/arm_usagefault.c | 2 +- arch/arm/src/armv6-m/CMakeLists.txt | 9 +- arch/arm/src/armv6-m/Make.defs | 4 +- arch/arm/src/armv6-m/arm_hardfault.c | 127 ------------------- arch/arm/src/armv6-m/arm_systemreset.c | 68 ---------- arch/arm/src/armv6-m/arm_trigger_irq.c | 89 ------------- arch/arm/src/armv7-m/CMakeLists.txt | 14 +-- arch/arm/src/armv7-m/Make.defs | 8 +- arch/arm/src/armv7-m/arm_busfault.c | 110 ---------------- arch/arm/src/armv7-m/arm_hardfault.c | 132 ------------------- arch/arm/src/armv7-m/arm_memfault.c | 140 --------------------- arch/arm/src/armv7-m/arm_systemreset.c | 68 ---------- arch/arm/src/armv7-m/arm_usagefault.c | 118 ----------------- arch/arm/src/armv8-m/CMakeLists.txt | 13 +- arch/arm/src/armv8-m/Make.defs | 14 +-- arch/arm/src/armv8-m/arm_trigger_irq.c | 89 ------------- 25 files changed, 112 insertions(+), 990 deletions(-) diff --git a/arch/arm/src/arm_m/CMakeLists.txt b/arch/arm/src/arm_m/CMakeLists.txt index 32d22f0dd88..d3af7e57ee9 100644 --- a/arch/arm/src/arm_m/CMakeLists.txt +++ b/arch/arm/src/arm_m/CMakeLists.txt @@ -18,7 +18,24 @@ # # ############################################################################## -list(APPEND SRCS arm_exception.S arm_saveusercontext.S arm_tcbinfo.c) +list( + APPEND + SRCS + arm_exception.S + arm_saveusercontext.S + arm_tcbinfo.c + arm_busfault.c + arm_hardfault.c + arm_systemreset.c + arm_trigger_irq.c) + +if(NOT CONFIG_ARCH_ARMV6M) + list(APPEND SRCS arm_usagefault.c arm_memfault.c) +endif() + +if(CONFIG_ARCH_ARMV8M) + list(APPEND SRCS arm_securefault.c) +endif() if(CONFIG_ARM_SYSTICK) list(APPEND SRCS arm_systick.c) @@ -44,4 +61,8 @@ if(CONFIG_ARM_COREDUMP_REGION) list(APPEND SRCS arm_dumpnvic.c) endif() +if(CONFIG_ARCH_TRUSTZONE_SECURE) + list(APPEND SRCS arm_gen_nonsecfault.c) +endif() + target_sources(arch PRIVATE ${SRCS}) diff --git a/arch/arm/src/arm_m/Make.defs b/arch/arm/src/arm_m/Make.defs index d1f66101f56..7c3c4147792 100644 --- a/arch/arm/src/arm_m/Make.defs +++ b/arch/arm/src/arm_m/Make.defs @@ -30,7 +30,16 @@ ifeq ($(CONFIG_LIB_SYSCALL),y) CMN_ASRCS += arm_dispatch_syscall.S endif -CMN_CSRCS += arm_tcbinfo.c +CMN_CSRCS += arm_tcbinfo.c arm_busfault.c arm_hardfault.c +CMN_CSRCS += arm_systemreset.c arm_trigger_irq.c + +ifneq ($(CONFIG_ARCH_ARMV6M),y) + CMN_CSRCS += arm_usagefault.c arm_memfault.c +endif + +ifeq ($(CONFIG_ARCH_ARMV8M),y) + CMN_CSRCS += arm_securefault.c +endif ifeq ($(CONFIG_ENABLE_ALL_SIGNALS),y) CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c @@ -47,3 +56,7 @@ endif ifeq ($(CONFIG_ARM_COREDUMP_REGION),y) CMN_CSRCS += arm_dumpnvic.c endif + +ifeq ($(CONFIG_ARCH_TRUSTZONE_SECURE),y) + CMN_CSRCS += arm_gen_nonsecfault.c +endif diff --git a/arch/arm/src/armv8-m/arm_busfault.c b/arch/arm/src/arm_m/arm_busfault.c similarity index 98% rename from arch/arm/src/armv8-m/arm_busfault.c rename to arch/arm/src/arm_m/arm_busfault.c index 2ac8ec78434..c594c2c43d9 100644 --- a/arch/arm/src/armv8-m/arm_busfault.c +++ b/arch/arm/src/arm_m/arm_busfault.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv8-m/arm_busfault.c + * arch/arm/src/arm_m/arm_busfault.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/arch/arm/src/armv8-m/arm_gen_nonsecfault.c b/arch/arm/src/arm_m/arm_gen_nonsecfault.c similarity index 99% rename from arch/arm/src/armv8-m/arm_gen_nonsecfault.c rename to arch/arm/src/arm_m/arm_gen_nonsecfault.c index 3d9040289ab..8188b8cb1d8 100644 --- a/arch/arm/src/armv8-m/arm_gen_nonsecfault.c +++ b/arch/arm/src/arm_m/arm_gen_nonsecfault.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv8-m/arm_gen_nonsecfault.c + * arch/arm/src/arm_m/arm_gen_nonsecfault.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/arch/arm/src/armv8-m/arm_hardfault.c b/arch/arm/src/arm_m/arm_hardfault.c similarity index 78% rename from arch/arm/src/armv8-m/arm_hardfault.c rename to arch/arm/src/arm_m/arm_hardfault.c index 38d0a8013d2..43499861296 100644 --- a/arch/arm/src/armv8-m/arm_hardfault.c +++ b/arch/arm/src/arm_m/arm_hardfault.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv8-m/arm_hardfault.c + * arch/arm/src/arm_m/arm_hardfault.c * * SPDX-License-Identifier: Apache-2.0 * @@ -26,6 +26,7 @@ #include <nuttx/config.h> +#include <inttypes.h> #include <stdint.h> #include <string.h> #include <assert.h> @@ -80,10 +81,51 @@ int arm_hardfault(int irq, void *context, void *arg) UNUSED(cfsr); UNUSED(hfsr); +#ifdef CONFIG_ARCH_ARMV6M + uint32_t *regs = (uint32_t *)context; + uint16_t *pc = (uint16_t *)regs[REG_PC] - 1; + + /* Check if the pc lies in known FLASH memory. + * REVISIT: What if the PC lies in "unknown" external memory? + */ + +#ifdef CONFIG_BUILD_PROTECTED + /* In the kernel build, SVCalls are expected in either the base, kernel + * FLASH region or in the user FLASH region. + */ + + if (((uintptr_t)pc >= (uintptr_t)_stext && + (uintptr_t)pc < (uintptr_t)_etext) || + ((uintptr_t)pc >= (uintptr_t)USERSPACE->us_textstart && + (uintptr_t)pc < (uintptr_t)USERSPACE->us_textend)) +#else + /* SVCalls are expected only from the base, kernel FLASH region */ + + if ((uintptr_t)pc >= (uintptr_t)_stext && + (uintptr_t)pc < (uintptr_t)_etext) +#endif + { + /* Fetch the instruction that caused the Hard fault */ + + uint16_t insn = *pc; + + hfinfo(" PC: %p INSN: %04x\n", pc, insn); + + /* If this was the instruction 'svc 0', then forward processing + * to the SVCall handler + */ + + if (insn == INSN_SVC0) + { + hfinfo("Forward SVCall\n"); + return arm_svcall(irq, context, NULL); + } + } +#endif + if (hfsr & NVIC_HFAULTS_FORCED) { hfalert("Hard Fault escalation:\n"); - #ifdef CONFIG_DEBUG_MEMFAULT if (cfsr & NVIC_CFAULTS_MEMFAULTSR_MASK) { diff --git a/arch/arm/src/armv8-m/arm_memfault.c b/arch/arm/src/arm_m/arm_memfault.c similarity index 99% rename from arch/arm/src/armv8-m/arm_memfault.c rename to arch/arm/src/arm_m/arm_memfault.c index 7ef494019d3..c15e66dda11 100644 --- a/arch/arm/src/armv8-m/arm_memfault.c +++ b/arch/arm/src/arm_m/arm_memfault.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv8-m/arm_memfault.c + * arch/arm/src/arm_m/arm_memfault.c * * SPDX-License-Identifier: Apache-2.0 * @@ -109,6 +109,7 @@ int arm_memfault(int irq, void *context, void *arg) { uint32_t *regs = context; uint16_t insn; + mfalert("Skip the memory management fault and proceed\n"); /* regs[REG_PC] advance by 2/4 bytes depends on whether the encoded diff --git a/arch/arm/src/armv8-m/arm_securefault.c b/arch/arm/src/arm_m/arm_securefault.c similarity index 98% rename from arch/arm/src/armv8-m/arm_securefault.c rename to arch/arm/src/arm_m/arm_securefault.c index 08ca4873ff1..68bcaf654a3 100644 --- a/arch/arm/src/armv8-m/arm_securefault.c +++ b/arch/arm/src/arm_m/arm_securefault.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv8-m/arm_securefault.c + * arch/arm/src/arm_m/arm_securefault.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/arch/arm/src/armv8-m/arm_systemreset.c b/arch/arm/src/arm_m/arm_systemreset.c similarity index 98% rename from arch/arm/src/armv8-m/arm_systemreset.c rename to arch/arm/src/arm_m/arm_systemreset.c index dc0108b50a9..caf9ee4cd7c 100644 --- a/arch/arm/src/armv8-m/arm_systemreset.c +++ b/arch/arm/src/arm_m/arm_systemreset.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv8-m/arm_systemreset.c + * arch/arm/src/arm_m/arm_systemreset.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/arch/arm/src/armv7-m/arm_trigger_irq.c b/arch/arm/src/arm_m/arm_trigger_irq.c similarity index 98% rename from arch/arm/src/armv7-m/arm_trigger_irq.c rename to arch/arm/src/arm_m/arm_trigger_irq.c index f8ae700afb7..1686b8a20e7 100644 --- a/arch/arm/src/armv7-m/arm_trigger_irq.c +++ b/arch/arm/src/arm_m/arm_trigger_irq.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-m/arm_trigger_irq.c + * arch/arm/src/arm_m/arm_trigger_irq.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/arch/arm/src/armv8-m/arm_usagefault.c b/arch/arm/src/arm_m/arm_usagefault.c similarity index 98% rename from arch/arm/src/armv8-m/arm_usagefault.c rename to arch/arm/src/arm_m/arm_usagefault.c index d03fc081049..aca25cbc794 100644 --- a/arch/arm/src/armv8-m/arm_usagefault.c +++ b/arch/arm/src/arm_m/arm_usagefault.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv8-m/arm_usagefault.c + * arch/arm/src/arm_m/arm_usagefault.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/arch/arm/src/armv6-m/CMakeLists.txt b/arch/arm/src/armv6-m/CMakeLists.txt index 85d9654e7db..cff43f8e9ef 100644 --- a/arch/arm/src/armv6-m/CMakeLists.txt +++ b/arch/arm/src/armv6-m/CMakeLists.txt @@ -20,13 +20,6 @@ # # ############################################################################## -set(SRCS - arm_cpuinfo.c - arm_doirq.c - arm_hardfault.c - arm_initialstate.c - arm_svcall.c - arm_systemreset.c - arm_trigger_irq.c) +set(SRCS arm_cpuinfo.c arm_doirq.c arm_initialstate.c arm_svcall.c) target_sources(arch PRIVATE ${SRCS}) diff --git a/arch/arm/src/armv6-m/Make.defs b/arch/arm/src/armv6-m/Make.defs index 9ee2bf9c0d0..3575f41d7d7 100644 --- a/arch/arm/src/armv6-m/Make.defs +++ b/arch/arm/src/armv6-m/Make.defs @@ -25,7 +25,7 @@ include common/Make.defs include arm_m/Make.defs -CMN_CSRCS += arm_cpuinfo.c arm_doirq.c arm_hardfault.c arm_initialstate.c -CMN_CSRCS += arm_svcall.c arm_systemreset.c arm_trigger_irq.c +CMN_CSRCS += arm_cpuinfo.c arm_doirq.c arm_initialstate.c +CMN_CSRCS += arm_svcall.c VPATH += arm_m diff --git a/arch/arm/src/armv6-m/arm_hardfault.c b/arch/arm/src/armv6-m/arm_hardfault.c deleted file mode 100644 index 90963cc97e9..00000000000 --- a/arch/arm/src/armv6-m/arm_hardfault.c +++ /dev/null @@ -1,127 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv6-m/arm_hardfault.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdint.h> -#include <string.h> -#include <assert.h> -#include <nuttx/debug.h> - -#include <arch/irq.h> - -#include "nvic.h" -#include "arm_internal.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifdef CONFIG_DEBUG_HARDFAULT_ALERT -# define hfalert(format, ...) _alert(format, ##__VA_ARGS__) -#else -# define hfalert(x...) -#endif - -#ifdef CONFIG_DEBUG_HARDFAULT_INFO -# define hfinfo(format, ...) _info(format, ##__VA_ARGS__) -#else -# define hfinfo(x...) -#endif - -#define INSN_SVC0 0xdf00 /* insn: svc 0 */ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_hardfault - * - * Description: - * This is Hard Fault exception handler. It also catches SVC call - * exceptions that are performed in bad contexts. - * - ****************************************************************************/ - -int arm_hardfault(int irq, void *context, void *arg) -{ - uint32_t *regs = (uint32_t *)context; - - /* Get the value of the program counter where the fault occurred */ - - uint16_t *pc = (uint16_t *)regs[REG_PC] - 1; - - /* Check if the pc lies in known FLASH memory. - * REVISIT: What if the PC lies in "unknown" external memory? - */ - -#ifdef CONFIG_BUILD_PROTECTED - /* In the kernel build, SVCalls are expected in either the base, kernel - * FLASH region or in the user FLASH region. - */ - - if (((uintptr_t)pc >= (uintptr_t)_stext && - (uintptr_t)pc < (uintptr_t)_etext) || - ((uintptr_t)pc >= (uintptr_t)USERSPACE->us_textstart && - (uintptr_t)pc < (uintptr_t)USERSPACE->us_textend)) -#else - /* SVCalls are expected only from the base, kernel FLASH region */ - - if ((uintptr_t)pc >= (uintptr_t)_stext && - (uintptr_t)pc < (uintptr_t)_etext) -#endif - { - /* Fetch the instruction that caused the Hard fault */ - - uint16_t insn = *pc; - hfinfo(" PC: %p INSN: %04x\n", pc, insn); - - /* If this was the instruction 'svc 0', then forward processing - * to the SVCall handler - */ - - if (insn == INSN_SVC0) - { - hfinfo("Forward SVCall\n"); - return arm_svcall(irq, context, NULL); - } - } - -#if defined(CONFIG_DEBUG_HARDFAULT_ALERT) - /* Dump some hard fault info */ - - hfalert("\nHard Fault:\n"); - hfalert(" IRQ: %d regs: %p\n", irq, regs); - hfalert(" PRIMASK: %08x IPSR: %08x\n", - getprimask(), getipsr()); -#endif - - up_irq_save(); - hfalert("PANIC!!! Hard fault\n"); - PANIC_WITH_REGS("panic", context); - return OK; /* Won't get here */ -} diff --git a/arch/arm/src/armv6-m/arm_systemreset.c b/arch/arm/src/armv6-m/arm_systemreset.c deleted file mode 100644 index 2ace557256f..00000000000 --- a/arch/arm/src/armv6-m/arm_systemreset.c +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv6-m/arm_systemreset.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdint.h> - -#include <nuttx/arch.h> -#include <nuttx/board.h> - -#include "arm_internal.h" -#include "nvic.h" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_systemreset - * - * Description: - * Internal, Cortex-M0 reset logic. - * - ****************************************************************************/ - -void up_systemreset(void) -{ - uint32_t regval; - - /* Set up for the system reset, retaining the priority group from the - * the AIRCR register. - */ - - regval = ((0x5fa << SYSCON_AIRCR_VECTKEY_SHIFT) | - SYSCON_AIRCR_SYSRESETREQ); - putreg32(regval, ARMV6M_SYSCON_AIRCR); - - /* Ensure completion of memory accesses */ - - __asm volatile ("dsb"); - - /* Wait for the reset */ - - for (; ; ); -} diff --git a/arch/arm/src/armv6-m/arm_trigger_irq.c b/arch/arm/src/armv6-m/arm_trigger_irq.c deleted file mode 100644 index cc52600c07c..00000000000 --- a/arch/arm/src/armv6-m/arm_trigger_irq.c +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv6-m/arm_trigger_irq.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdint.h> -#include <assert.h> - -#include <nuttx/arch.h> -#include <arch/irq.h> - -#include "arm_internal.h" -#include "nvic.h" - -#ifdef CONFIG_ARCH_HAVE_IRQTRIGGER - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_trigger_irq - * - * Description: - * Trigger an IRQ by software. - * - ****************************************************************************/ - -void up_trigger_irq(int irq, cpu_set_t cpuset) -{ - uint32_t pend_bit = 0; - - DEBUGASSERT(irq >= NVIC_IRQ_NMI && irq < NR_IRQS); - - if (irq >= NVIC_IRQ_FIRST) - { - putreg32(irq - NVIC_IRQ_FIRST, ARMV6M_NVIC2_BASE); - } - else - { - switch (irq) - { - case NVIC_IRQ_PENDSV: - pend_bit = SYSCON_ICSR_PENDSVSET; - break; - - case NVIC_IRQ_NMI: - pend_bit = SYSCON_ICSR_NMIPENDSET; - break; - - case NVIC_IRQ_SYSTICK: - pend_bit = SYSCON_ICSR_PENDSTSET; - break; - - default: - break; - } - - if (pend_bit) - { - modifyreg32(ARMV6M_SYSCON_ICSR, 0, pend_bit); - } - } -} - -#endif /* CONFIG_ARCH_HAVE_IRQTRIGGER */ diff --git a/arch/arm/src/armv7-m/CMakeLists.txt b/arch/arm/src/armv7-m/CMakeLists.txt index 4a9e85bcb24..0dd3c810c96 100644 --- a/arch/arm/src/armv7-m/CMakeLists.txt +++ b/arch/arm/src/armv7-m/CMakeLists.txt @@ -23,20 +23,14 @@ # TODO: do not use config to detect this set(SRCS - arm_busfault.c + arm_dbgmonitor.c arm_cache.c arm_cpuinfo.c arm_doirq.c - arm_hardfault.c arm_initialstate.c arm_itm.c - arm_memfault.c arm_perf.c - arm_svcall.c - arm_systemreset.c - arm_trigger_irq.c - arm_usagefault.c - arm_dbgmonitor.c) + arm_svcall.c) if(CONFIG_ARMV7M_ITMSYSLOG) list(APPEND SRCS arm_itm_syslog.c) @@ -54,4 +48,8 @@ if(CONFIG_ARM_MPU OR CONFIG_ARM_MPU_EARLY_RESET) list(APPEND SRCS arm_mpu.c) endif() +if(CONFIG_ARCH_ADDRENV) + list(APPEND SRCS arm_addrenv.c) +endif() + target_sources(arch PRIVATE ${SRCS}) diff --git a/arch/arm/src/armv7-m/Make.defs b/arch/arm/src/armv7-m/Make.defs index c7082973225..2e8605d5ead 100644 --- a/arch/arm/src/armv7-m/Make.defs +++ b/arch/arm/src/armv7-m/Make.defs @@ -25,11 +25,9 @@ include common/Make.defs include arm_m/Make.defs -CMN_CSRCS += arm_busfault.c arm_cache.c arm_cpuinfo.c arm_doirq.c -CMN_CSRCS += arm_hardfault.c arm_initialstate.c arm_itm.c -CMN_CSRCS += arm_memfault.c arm_perf.c -CMN_CSRCS += arm_svcall.c arm_systemreset.c -CMN_CSRCS += arm_trigger_irq.c arm_usagefault.c arm_dbgmonitor.c +CMN_CSRCS += arm_cache.c arm_cpuinfo.c arm_doirq.c arm_initialstate.c +CMN_CSRCS += arm_itm.c arm_perf.c arm_svcall.c +CMN_CSRCS += arm_dbgmonitor.c ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y) CMN_CSRCS += arm_itm_syslog.c diff --git a/arch/arm/src/armv7-m/arm_busfault.c b/arch/arm/src/armv7-m/arm_busfault.c deleted file mode 100644 index d18b4a50e48..00000000000 --- a/arch/arm/src/armv7-m/arm_busfault.c +++ /dev/null @@ -1,110 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/arm_busfault.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdint.h> -#include <string.h> -#include <assert.h> -#include <nuttx/debug.h> - -#include <arch/irq.h> - -#include "nvic.h" -#include "arm_internal.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifdef CONFIG_DEBUG_BUSFAULT -# define bfalert(format, ...) _alert(format, ##__VA_ARGS__) -#else -# define bfalert(x...) -#endif - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_busfault - * - * Description: - * This is Bus Fault exception handler. It also catches SVC call - * exceptions that are performed in bad contexts. - * - ****************************************************************************/ - -int arm_busfault(int irq, void *context, void *arg) -{ - uint32_t cfsr = getreg32(NVIC_CFAULTS); - - bfalert("PANIC!!! Bus Fault:\n"); - bfalert("\tIRQ: %d regs: %p\n", irq, context); - bfalert("\tBASEPRI: %08x PRIMASK: %08x IPSR: %08" - PRIx32 " CONTROL: %08" PRIx32 "\n", - getbasepri(), getprimask(), getipsr(), getcontrol()); - bfalert("\tCFSR: %08" PRIx32 " HFSR: %08" PRIx32 " DFSR: %08" - PRIx32 " BFAR: %08" PRIx32 " AFSR: %08" PRIx32 "\n", - cfsr, getreg32(NVIC_HFAULTS), getreg32(NVIC_DFAULTS), - getreg32(NVIC_BFAULT_ADDR), getreg32(NVIC_AFAULTS)); - - bfalert("Bus Fault Reason:\n"); - if (cfsr & NVIC_CFAULTS_IBUSERR) - { - bfalert("\tInstruction bus error\n"); - } - - if (cfsr & NVIC_CFAULTS_PRECISERR) - { - bfalert("\tPrecise data bus error\n"); - } - - if (cfsr & NVIC_CFAULTS_IMPRECISERR) - { - bfalert("\tImprecise data bus error\n"); - } - - if (cfsr & NVIC_CFAULTS_UNSTKERR) - { - bfalert("\tBusFault on unstacking for a return from exception\n"); - } - - if (cfsr & NVIC_CFAULTS_STKERR) - { - bfalert("\tBusFault on stacking for exception entry\n"); - } - - if (cfsr & NVIC_CFAULTS_LSPERR) - { - bfalert("\tFloating-point lazy state preservation error\n"); - } - - up_irq_save(); - PANIC_WITH_REGS("panic", context); - return OK; -} diff --git a/arch/arm/src/armv7-m/arm_hardfault.c b/arch/arm/src/armv7-m/arm_hardfault.c deleted file mode 100644 index e499d041761..00000000000 --- a/arch/arm/src/armv7-m/arm_hardfault.c +++ /dev/null @@ -1,132 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/arm_hardfault.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <inttypes.h> -#include <stdint.h> -#include <string.h> -#include <assert.h> -#include <nuttx/debug.h> - -#include <nuttx/userspace.h> -#include <arch/irq.h> - -#include "nvic.h" -#include "arm_internal.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifdef CONFIG_DEBUG_HARDFAULT_ALERT -# define hfalert(format, ...) _alert(format, ##__VA_ARGS__) -#else -# define hfalert(x...) -#endif - -#ifdef CONFIG_DEBUG_HARDFAULT_INFO -# define hfinfo(format, ...) _info(format, ##__VA_ARGS__) -#else -# define hfinfo(x...) -#endif - -#define INSN_SVC0 0xdf00 /* insn: svc 0 */ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_hardfault - * - * Description: - * This is Hard Fault exception handler. It also catches SVC call - * exceptions that are performed in bad contexts. - * - ****************************************************************************/ - -int arm_hardfault(int irq, void *context, void *arg) -{ - uint32_t hfsr = getreg32(NVIC_HFAULTS); - uint32_t cfsr = getreg32(NVIC_CFAULTS); - - UNUSED(cfsr); - UNUSED(hfsr); - - if (hfsr & NVIC_HFAULTS_FORCED) - { - hfalert("Hard Fault escalation:\n"); - -#ifdef CONFIG_DEBUG_MEMFAULT - if (cfsr & NVIC_CFAULTS_MEMFAULTSR_MASK) - { - return arm_memfault(irq, context, arg); - } -#endif /* CONFIG_DEBUG_MEMFAULT */ - -#ifdef CONFIG_DEBUG_BUSFAULT - if (cfsr & NVIC_CFAULTS_BUSFAULTSR_MASK) - { - return arm_busfault(irq, context, arg); - } -#endif /* CONFIG_DEBUG_BUSFAULT */ - -#ifdef CONFIG_DEBUG_USAGEFAULT - if (cfsr & NVIC_CFAULTS_USGFAULTSR_MASK) - { - return arm_usagefault(irq, context, arg); - } -#endif /* CONFIG_DEBUG_USAGEFAULT */ - } - - /* Dump some hard fault info */ - - hfalert("PANIC!!! Hard Fault!:"); - hfalert("\tIRQ: %d regs: %p\n", irq, context); - hfalert("\tBASEPRI: %08x PRIMASK: %08x IPSR: %08" - PRIx32 " CONTROL: %08" PRIx32 "\n", - getbasepri(), getprimask(), getipsr(), getcontrol()); - hfalert("\tCFSR: %08" PRIx32 " HFSR: %08" PRIx32 " DFSR: %08" - PRIx32 " BFAR: %08" PRIx32 " AFSR: %08" PRIx32 "\n", - cfsr, hfsr, getreg32(NVIC_DFAULTS), - getreg32(NVIC_BFAULT_ADDR), getreg32(NVIC_AFAULTS)); - - hfalert("Hard Fault Reason:\n"); - - if (hfsr & NVIC_HFAULTS_VECTTBL) - { - hfalert("\tBusFault on a vector table read\n"); - } - else if (hfsr & NVIC_HFAULTS_DEBUGEVT) - { - hfalert("\tDebug event\n"); - } - - up_irq_save(); - PANIC_WITH_REGS("panic", context); - return OK; -} diff --git a/arch/arm/src/armv7-m/arm_memfault.c b/arch/arm/src/armv7-m/arm_memfault.c deleted file mode 100644 index 0662d2cb0de..00000000000 --- a/arch/arm/src/armv7-m/arm_memfault.c +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/arm_memfault.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <assert.h> -#include <nuttx/debug.h> -#include <inttypes.h> - -#include <arch/irq.h> - -#include "nvic.h" -#include "arm_internal.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifdef CONFIG_DEBUG_MEMFAULT -# define mfalert(format, ...) _alert(format, ##__VA_ARGS__) -#else -# define mfalert(x...) -#endif - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_memfault - * - * Description: - * This is Memory Management Fault exception handler. Normally we get - * here when the Cortex M3 MPU is enabled and an MPU fault is detected. - * However, I understand that there are other error conditions that can - * also generate memory management faults. - * - ****************************************************************************/ - -int arm_memfault(int irq, void *context, void *arg) -{ - uint32_t cfsr = getreg32(NVIC_CFAULTS); - - /* Dump some memory management fault info */ - - mfalert("PANIC!!! Memory Management Fault:\n"); - mfalert("\tIRQ: %d context: %p\n", irq, context); - mfalert("\tCFSR: %08x MMFAR: %08x\n", - getreg32(NVIC_CFAULTS), getreg32(NVIC_MEMMANAGE_ADDR)); - mfalert("\tBASEPRI: %08x PRIMASK: %08x IPSR: %08" - PRIx32 " CONTROL: %08" PRIx32 "\n", - getbasepri(), getprimask(), getipsr(), getcontrol()); - - mfalert("Memory Management Fault Reason:\n"); - if (cfsr & NVIC_CFAULTS_IACCVIOL) - { - mfalert("\tInstruction access violation\n"); - } - - if (cfsr & NVIC_CFAULTS_DACCVIOL) - { - mfalert("\tData access violation\n"); - } - - if (cfsr & NVIC_CFAULTS_MUNSTKERR) - { - mfalert("\tMemManage fault on unstacking\n"); - } - - if (cfsr & NVIC_CFAULTS_MSTKERR) - { - mfalert("\tMemManage fault on stacking\n"); - } - - if (cfsr & NVIC_CFAULTS_MLSPERR) - { - mfalert("\tFloating-point lazy state preservation error\n"); - } - - /* In some scenarios (e.g. testing, debugging, etc.) where we want to - * ignore the memory management fault and proceed, we can set the parameter - * arg to 0xffffffff to skip the Memory Management Fault exception - */ - - if (arg == (void *)0xffffffff) - { - uint32_t *regs = context; - uint16_t insn; - mfalert("Skip the memory management fault and proceed\n"); - - /* regs[REG_PC] advance by 2/4 bytes depends on whether the encoded - * faulty instructions are 16-bit/32-bit thumb instructions - */ - - insn = (*(volatile uint16_t *)(regs[REG_PC]) >> 11) & 0x1f; - - if (insn == 0x1d || insn == 0x1e || insn == 0x1f) - { - regs[REG_PC] += 4; - } - else - { - regs[REG_PC] += 2; - } - - /* Clear the MMFSR and MMFAR register */ - - putreg32(0xff, NVIC_CFAULTS); - putreg32(0, NVIC_MEMMANAGE_ADDR); - - return OK; - } - - up_irq_save(); - PANIC_WITH_REGS("panic", context); - return OK; /* Won't get here */ -} diff --git a/arch/arm/src/armv7-m/arm_systemreset.c b/arch/arm/src/armv7-m/arm_systemreset.c deleted file mode 100644 index fae073d2404..00000000000 --- a/arch/arm/src/armv7-m/arm_systemreset.c +++ /dev/null @@ -1,68 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/arm_systemreset.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdint.h> - -#include <nuttx/arch.h> -#include <nuttx/board.h> - -#include "arm_internal.h" -#include "nvic.h" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_systemreset - * - * Description: - * Internal, Cortex-M0 reset logic. - * - ****************************************************************************/ - -void up_systemreset(void) -{ - uint32_t regval; - - /* Set up for the system reset, retaining the priority group from the - * the AIRCR register. - */ - - regval = getreg32(NVIC_AIRCR) & NVIC_AIRCR_PRIGROUP_MASK; - regval |= (NVIC_AIRCR_VECTKEY | NVIC_AIRCR_SYSRESETREQ); - putreg32(regval, NVIC_AIRCR); - - /* Ensure completion of memory accesses */ - - __asm volatile ("dsb"); - - /* Wait for the reset */ - - for (; ; ); -} diff --git a/arch/arm/src/armv7-m/arm_usagefault.c b/arch/arm/src/armv7-m/arm_usagefault.c deleted file mode 100644 index 34e6bac0b6e..00000000000 --- a/arch/arm/src/armv7-m/arm_usagefault.c +++ /dev/null @@ -1,118 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-m/arm_usagefault.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdint.h> -#include <string.h> -#include <assert.h> -#include <nuttx/debug.h> - -#include <arch/irq.h> - -#include "nvic.h" -#include "arm_internal.h" - -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -#ifdef CONFIG_DEBUG_USAGEFAULT -# define ufalert(format, ...) _alert(format, ##__VA_ARGS__) -#else -# define ufalert(x...) -#endif - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_usagefault - * - * Description: - * This is Usage Fault exception handler. It also catches SVC call - * exceptions that are performed in bad contexts. - * - ****************************************************************************/ - -int arm_usagefault(int irq, void *context, void *arg) -{ - uint32_t cfsr = getreg32(NVIC_CFAULTS); - - /* Dump some usage fault info */ - - ufalert("PANIC!!! Usage Fault:\n"); - ufalert("\tIRQ: %d regs: %p\n", irq, context); - ufalert("\tBASEPRI: %08x PRIMASK: %08x IPSR: %08" - PRIx32 " CONTROL: %08" PRIx32 "\n", - getbasepri(), getprimask(), getipsr(), getcontrol()); - ufalert("\tCFSR: %08" PRIx32 " HFSR: %08" PRIx32 " DFSR: %08" - PRIx32 " BFAR: %08" PRIx32 " AFSR: %08" PRIx32 "\n", - cfsr, getreg32(NVIC_HFAULTS), getreg32(NVIC_DFAULTS), - getreg32(NVIC_BFAULT_ADDR), getreg32(NVIC_AFAULTS)); - - ufalert("Usage Fault Reason:\n"); - if (cfsr & NVIC_CFAULTS_UNDEFINSTR) - { - ufalert("\tUndefined instruction\n"); - } - - if (cfsr & NVIC_CFAULTS_INVSTATE) - { - ufalert("\tInvalid state\n"); - } - - if (cfsr & NVIC_CFAULTS_INVPC) - { - ufalert("\tInvalid PC load, " - "caused by an invalid PC load by EXC_RETURN\n"); - } - - if (cfsr & NVIC_CFAULTS_NOCP) - { - ufalert("\tNo Coprocessor\n"); - } - - if (cfsr & NVIC_CFAULTS_STKOF) - { - ufalert("\tStack Overflow\n"); - } - - if (cfsr & NVIC_CFAULTS_UNALIGNED) - { - ufalert("\tUnaligned access\n"); - } - - if (cfsr & NVIC_CFAULTS_DIVBYZERO) - { - ufalert("\tDivide by zero\n"); - } - - up_irq_save(); - PANIC_WITH_REGS("panic", context); - return OK; -} diff --git a/arch/arm/src/armv8-m/CMakeLists.txt b/arch/arm/src/armv8-m/CMakeLists.txt index 5ce85a8aff5..926cd7530da 100644 --- a/arch/arm/src/armv8-m/CMakeLists.txt +++ b/arch/arm/src/armv8-m/CMakeLists.txt @@ -21,23 +21,16 @@ # ############################################################################## set(SRCS - arm_busfault.c arm_dbgmonitor.c arm_cache.c arm_cpuinfo.c arm_doirq.c - arm_hardfault.c arm_initialstate.c arm_itm.c - arm_memfault.c arm_perf.c arm_sau.c - arm_securefault.c arm_secure_irq.c - arm_svcall.c - arm_systemreset.c - arm_trigger_irq.c - arm_usagefault.c) + arm_svcall.c) if(CONFIG_ARMV8M_ITMSYSLOG) list(APPEND SRCS arm_itm_syslog.c) @@ -63,4 +56,8 @@ if(CONFIG_ARCH_TRUSTZONE_SECURE) list(APPEND SRCS arm_gen_nonsecfault.c) endif() +if(CONFIG_ARCH_ADDRENV) + list(APPEND SRCS arm_addrenv.c) +endif() + target_sources(arch PRIVATE ${SRCS}) diff --git a/arch/arm/src/armv8-m/Make.defs b/arch/arm/src/armv8-m/Make.defs index 4754f14bda4..6230cd197e5 100644 --- a/arch/arm/src/armv8-m/Make.defs +++ b/arch/arm/src/armv8-m/Make.defs @@ -25,13 +25,9 @@ include common/Make.defs include arm_m/Make.defs -CMN_CSRCS += arm_busfault.c arm_cache.c arm_cpuinfo.c arm_doirq.c -CMN_CSRCS += arm_hardfault.c arm_initialstate.c arm_itm.c -CMN_CSRCS += arm_memfault.c arm_perf.c arm_sau.c -CMN_CSRCS += arm_securefault.c arm_secure_irq.c -CMN_CSRCS += arm_svcall.c -CMN_CSRCS += arm_systemreset.c -CMN_CSRCS += arm_trigger_irq.c arm_usagefault.c arm_dbgmonitor.c +CMN_CSRCS += arm_cache.c arm_cpuinfo.c arm_doirq.c arm_initialstate.c +CMN_CSRCS += arm_itm.c arm_perf.c arm_sau.c arm_secure_irq.c arm_svcall.c +CMN_CSRCS += arm_dbgmonitor.c ifeq ($(CONFIG_ARMV8M_ITMSYSLOG),y) CMN_CSRCS += arm_itm_syslog.c @@ -58,4 +54,8 @@ ifeq ($(CONFIG_ARCH_TRUSTZONE_SECURE),y) CMN_CSRCS += arm_gen_nonsecfault.c endif +ifeq ($(CONFIG_ARCH_ADDRENV),y) + CMN_CSRCS += arm_addrenv.c +endif + VPATH += arm_m diff --git a/arch/arm/src/armv8-m/arm_trigger_irq.c b/arch/arm/src/armv8-m/arm_trigger_irq.c deleted file mode 100644 index d22aec71196..00000000000 --- a/arch/arm/src/armv8-m/arm_trigger_irq.c +++ /dev/null @@ -1,89 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv8-m/arm_trigger_irq.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. The - * ASF licenses this file to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the - * License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <nuttx/config.h> - -#include <stdint.h> -#include <assert.h> - -#include <nuttx/arch.h> -#include <arch/irq.h> - -#include "arm_internal.h" -#include "nvic.h" - -#ifdef CONFIG_ARCH_HAVE_IRQTRIGGER - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_trigger_irq - * - * Description: - * Trigger an IRQ by software. - * - ****************************************************************************/ - -void up_trigger_irq(int irq, cpu_set_t cpuset) -{ - uint32_t pend_bit = 0; - - DEBUGASSERT(irq >= NVIC_IRQ_NMI && irq < NR_IRQS); - - if (irq >= NVIC_IRQ_FIRST) - { - putreg32(irq - NVIC_IRQ_FIRST, NVIC_STIR); - } - else - { - switch (irq) - { - case NVIC_IRQ_PENDSV: - pend_bit = NVIC_INTCTRL_PENDSVSET; - break; - - case NVIC_IRQ_NMI: - pend_bit = NVIC_INTCTRL_NMIPENDSET; - break; - - case NVIC_IRQ_SYSTICK: - pend_bit = NVIC_INTCTRL_PENDSTSET; - break; - - default: - break; - } - - if (pend_bit) - { - modifyreg32(NVIC_INTCTRL, 0, pend_bit); - } - } -} - -#endif /* CONFIG_ARCH_HAVE_IRQTRIGGER */
