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 d4893dc473071715e7aab9284c300601b95da998
Author: buxiasen <[email protected]>
AuthorDate: Fri Dec 19 21:27:06 2025 +0800

    arch/arm_m: merge v6/7/8-m arm_initialstate.c
    
    We should reduce the dup of code.
    Merge arm_initialize_stack more compatible for v6m
    
    Signed-off-by: buxiasen <[email protected]>
---
 arch/arm/Kconfig                                   |  17 ++
 arch/arm/src/arm_m/CMakeLists.txt                  |   1 +
 arch/arm/src/arm_m/Make.defs                       |   2 +-
 arch/arm/src/{armv8-m => arm_m}/arm_initialstate.c |  37 ++--
 arch/arm/src/armv6-m/CMakeLists.txt                |   2 +-
 arch/arm/src/armv6-m/Make.defs                     |   2 +-
 arch/arm/src/armv6-m/arm_initialstate.c            | 196 -------------------
 arch/arm/src/armv7-m/CMakeLists.txt                |   1 -
 arch/arm/src/armv7-m/Kconfig                       |   1 +
 arch/arm/src/armv7-m/Make.defs                     |   2 +-
 arch/arm/src/armv7-m/arm_initialstate.c            | 208 ---------------------
 arch/arm/src/armv8-m/CMakeLists.txt                |   1 -
 arch/arm/src/armv8-m/Kconfig                       |   1 +
 arch/arm/src/armv8-m/Make.defs                     |   2 +-
 14 files changed, 51 insertions(+), 422 deletions(-)

diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 8f1971bff05..38653c13372 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1869,6 +1869,23 @@ config UNWINDER_ARM
 
 endchoice # Choose ARM unwinder
 
+config ARM_STACKCHECK
+       bool
+       default n
+       ---help---
+               This check uses R10 to check for a stack overflow within each
+               function call. This has performances and code size impacts, but 
it
+               will be able to catch hard to find stack overflows.
+
+               Currently only available only for the STM32, SAM3/4 and SAMA5D
+               architectures.  The changes are not complex and patches for
+               other architectures will be accepted.
+
+               This option requires that you are using a GCC toolchain and that
+               you also include -finstrument-functions in your CFLAGS when you
+               compile.  This addition to your CFLAGS should probably be added
+               to the definition of the CFFLAGS in your board Make.defs file.
+
 endif
 
 if ARCH_ARM_M
diff --git a/arch/arm/src/arm_m/CMakeLists.txt 
b/arch/arm/src/arm_m/CMakeLists.txt
index b78671c8e7e..bf5647d07e3 100644
--- a/arch/arm/src/arm_m/CMakeLists.txt
+++ b/arch/arm/src/arm_m/CMakeLists.txt
@@ -28,6 +28,7 @@ list(
   arm_hardfault.c
   arm_systemreset.c
   arm_svcall.c
+  arm_initialstate.c
   arm_trigger_irq.c)
 
 if(NOT CONFIG_ARCH_ARMV6M)
diff --git a/arch/arm/src/arm_m/Make.defs b/arch/arm/src/arm_m/Make.defs
index e3f1355604b..43740c8cd2b 100644
--- a/arch/arm/src/arm_m/Make.defs
+++ b/arch/arm/src/arm_m/Make.defs
@@ -30,7 +30,7 @@ ifeq ($(CONFIG_LIB_SYSCALL),y)
   CMN_ASRCS += arm_dispatch_syscall.S
 endif
 
-CMN_CSRCS += arm_tcbinfo.c arm_busfault.c arm_hardfault.c
+CMN_CSRCS += arm_tcbinfo.c arm_busfault.c arm_hardfault.c arm_initialstate.c
 CMN_CSRCS += arm_systemreset.c arm_trigger_irq.c arm_svcall.c
 
 ifneq ($(CONFIG_ARCH_ARMV6M),y)
diff --git a/arch/arm/src/armv8-m/arm_initialstate.c 
b/arch/arm/src/arm_m/arm_initialstate.c
similarity index 91%
rename from arch/arm/src/armv8-m/arm_initialstate.c
rename to arch/arm/src/arm_m/arm_initialstate.c
index 76d0eb36183..725528d97c1 100644
--- a/arch/arm/src/armv8-m/arm_initialstate.c
+++ b/arch/arm/src/arm_m/arm_initialstate.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/arm/src/armv8-m/arm_initialstate.c
+ * arch/arm/src/arm_m/arm_initialstate.c
  *
  * SPDX-License-Identifier: Apache-2.0
  *
@@ -100,7 +100,7 @@ void up_initial_state(struct tcb_s *tcb)
   xcp->regs[REG_SP]      = (uint32_t)tcb->stack_base_ptr +
                                      tcb->adj_stack_size;
 
-#ifdef CONFIG_ARMV8M_STACKCHECK
+#ifdef CONFIG_ARM_STACKCHECK
   /* Set the stack limit value */
 
   xcp->regs[REG_R10]     = (uint32_t)tcb->stack_alloc_ptr + 64;
@@ -174,11 +174,19 @@ void up_initial_state(struct tcb_s *tcb)
 
 #ifdef CONFIG_SUPPRESS_INTERRUPTS
 
+#  ifdef CONFIG_ARCH_ARMV6M
+  xcp->regs[REG_PRIMASK] = 1;
+#  else
   xcp->regs[REG_BASEPRI] = NVIC_SYSH_DISABLE_PRIORITY;
+#  endif
 
 #else /* CONFIG_SUPPRESS_INTERRUPTS */
 
+#  ifdef CONFIG_ARCH_ARMV6M
+  xcp->regs[REG_PRIMASK] = 0;
+#  else
   xcp->regs[REG_BASEPRI] = 0;
+#  endif
 
 #endif /* CONFIG_SUPPRESS_INTERRUPTS */
 }
@@ -196,31 +204,36 @@ noinline_function void arm_initialize_stack(void)
 {
   uint32_t stacklim = up_get_intstackbase(this_cpu());
   uint32_t stack = stacklim + INTSTACK_SIZE;
-  uint32_t temp = 0;
+  uint32_t tempa = 0;
+  uint32_t tempb = 2;
 
   __asm__ __volatile__
     (
+#ifndef CONFIG_ARCH_ARMV6M
       "mrs %1, CONTROL\n"
       "tst %1, #2\n"
       "bne 1f\n"
+#endif
 
       /* Initialize PSP */
 
       "mrs %1, msp\n"
       "msr psp, %1\n"
-#ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE
+#ifdef CONFIG_ARCH_ARMV8M
+#  ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE
       "mrs %1, msplim\n"
       "msr psplim, %1\n"
-#else
+#  else
       "mov %1, #0\n"
       "msr psplim, %1\n"
+#  endif
 #endif
       "isb sy\n"
 
       /* Select PSP */
 
       "mrs %1, CONTROL\n"
-      "orr %1, #2\n"
+      "orr %1, %2\n"
       "msr CONTROL, %1\n"
       "isb sy\n"
 
@@ -228,18 +241,20 @@ noinline_function void arm_initialize_stack(void)
 
       "1:\n"
       "msr msp, %0\n"
-#ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE
-      "msr msplim, %2\n"
-#else
+#ifdef CONFIG_ARCH_ARMV8M
+#  ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE
+      "msr msplim, %3\n"
+#  else
       "mov %1, #0\n"
       "msr msplim, %1\n"
+#  endif
 #endif
       "isb sy\n"
       :
 #ifdef CONFIG_ARMV8M_STACKCHECK_HARDWARE
-      : "r" (stack), "r" (temp), "r" (stacklim)
+      : "r" (stack), "r" (tempa), "r" (tempb), "r" (stacklim)
 #else
-      : "r" (stack), "r" (temp)
+      : "r" (stack), "r" (tempa), "r" (tempb)
 #endif
       : "memory");
 }
diff --git a/arch/arm/src/armv6-m/CMakeLists.txt 
b/arch/arm/src/armv6-m/CMakeLists.txt
index e7c68a3128f..899a3eb999d 100644
--- a/arch/arm/src/armv6-m/CMakeLists.txt
+++ b/arch/arm/src/armv6-m/CMakeLists.txt
@@ -20,6 +20,6 @@
 #
 # 
##############################################################################
 
-set(SRCS arm_doirq.c arm_initialstate.c arm_cpuinfo.c)
+set(SRCS arm_doirq.c arm_cpuinfo.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 05b0e845c31..7b537799d31 100644
--- a/arch/arm/src/armv6-m/Make.defs
+++ b/arch/arm/src/armv6-m/Make.defs
@@ -25,6 +25,6 @@
 include common/Make.defs
 include arm_m/Make.defs
 
-CMN_CSRCS += arm_cpuinfo.c arm_doirq.c arm_initialstate.c
+CMN_CSRCS += arm_cpuinfo.c arm_doirq.c
 
 VPATH += arm_m
diff --git a/arch/arm/src/armv6-m/arm_initialstate.c 
b/arch/arm/src/armv6-m/arm_initialstate.c
deleted file mode 100644
index df6cc8b93f1..00000000000
--- a/arch/arm/src/armv6-m/arm_initialstate.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/****************************************************************************
- * arch/arm/src/armv6-m/arm_initialstate.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 <sys/types.h>
-#include <stdint.h>
-#include <string.h>
-
-#include <nuttx/arch.h>
-
-#include "arm_internal.h"
-#include "psr.h"
-#include "exc_return.h"
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: up_initial_state
- *
- * Description:
- *   A new thread is being started and a new TCB
- *   has been created. This function is called to initialize
- *   the processor specific portions of the new TCB.
- *
- *   This function must setup the initial architecture registers
- *   and/or  stack so that execution will begin at tcb->start
- *   on the next context switch.
- *
- ****************************************************************************/
-
-void up_initial_state(struct tcb_s *tcb)
-{
-  struct xcptcontext *xcp = &tcb->xcp;
-
-  /* Initialize the initial exception register context structure */
-
-  memset(xcp, 0, sizeof(struct xcptcontext));
-
-  /* Initialize the idle thread stack */
-
-  if (tcb->pid == IDLE_PROCESS_ID)
-    {
-      tcb->stack_alloc_ptr = (void *)(g_idle_topstack -
-                                      CONFIG_IDLETHREAD_STACKSIZE);
-      tcb->stack_base_ptr  = tcb->stack_alloc_ptr;
-      tcb->adj_stack_size  = CONFIG_IDLETHREAD_STACKSIZE;
-
-#ifdef CONFIG_STACK_COLORATION
-      /* If stack debug is enabled, then fill the stack with a
-       * recognizable value that we can use later to test for high
-       * water marks.
-       */
-
-      arm_stack_color(tcb->stack_alloc_ptr, 0);
-#endif /* CONFIG_STACK_COLORATION */
-
-      return;
-    }
-
-  /* Initialize the context registers to stack top */
-
-  xcp->regs = (void *)((uint32_t)tcb->stack_base_ptr +
-                                 tcb->adj_stack_size -
-                                 XCPTCONTEXT_SIZE);
-
-  /* Initialize the xcp registers */
-
-  memset(xcp->regs, 0, XCPTCONTEXT_SIZE);
-
-  /* Save the initial stack pointer */
-
-  xcp->regs[REG_SP]      = (uint32_t)tcb->stack_base_ptr +
-                                     tcb->adj_stack_size;
-
-  /* Save the task entry point (stripping off the thumb bit) */
-
-  xcp->regs[REG_PC]      = (uint32_t)tcb->start & ~1;
-
-  /* Specify thumb mode */
-
-  xcp->regs[REG_XPSR]    = ARM_XPSR_T;
-
-  /* All tasks need set to pic address to special register */
-
-#ifdef CONFIG_BUILD_PIC
-  __asm__ ("mov %0, r9" : "=r"(xcp->regs[REG_R9]));
-#endif
-
-  /* If this task is running PIC, then set the PIC base register to the
-   * address of the allocated D-Space region.
-   */
-
-#ifdef CONFIG_PIC
-  if (tcb->dspace != NULL)
-    {
-      /* Set the PIC base register (R9) to the address of the allocated
-       * D-Space region.
-       */
-
-      xcp->regs[REG_PIC] = (uint32_t)tcb->dspace->region;
-    }
-
-#ifdef CONFIG_NXFLAT
-  /* Make certain that bit 0 is set in the main entry address.  This is
-   * only an issue when NXFLAT is enabled.  NXFLAT doesn't know anything
-   * about thumb; the addresses that NXFLAT sets are based on file header
-   * info and won't have bit 0 set.
-   */
-
-  tcb->entry.main = (main_t)((uint32_t)tcb->entry.main | 1);
-#endif
-#endif /* CONFIG_PIC */
-
-  /* All tasks start via a stub function in kernel space.  So all
-   * tasks must start in privileged thread mode.  If CONFIG_BUILD_PROTECTED
-   * is defined, then that stub function will switch to unprivileged
-   * mode before transferring control to the user task.
-   */
-
-  xcp->regs[REG_EXC_RETURN] = EXC_RETURN_THREAD;
-
-  xcp->regs[REG_CONTROL] = getcontrol() & ~CONTROL_NPRIV;
-
-  /* Enable or disable interrupts, based on user configuration */
-
-#ifdef CONFIG_SUPPRESS_INTERRUPTS
-  xcp->regs[REG_PRIMASK] = 1;
-#endif /* CONFIG_SUPPRESS_INTERRUPTS */
-}
-
-#if CONFIG_ARCH_INTERRUPTSTACK > 3
-/****************************************************************************
- * Name: arm_initialize_stack
- *
- * Description:
- *   If interrupt stack is defined, the PSP and MSP need to be reinitialized.
- *
- ****************************************************************************/
-
-noinline_function void arm_initialize_stack(void)
-{
-  uint32_t stack = up_get_intstackbase(this_cpu()) + INTSTACK_SIZE;
-  uint32_t tempa = 0;
-  uint32_t tempb = 2;
-
-  __asm__ __volatile__
-    (
-
-      /* Initialize PSP */
-
-      "mov %1, sp\n"
-      "msr psp, %1\n"
-      "isb sy\n"
-
-      /* Select PSP */
-
-      "mrs %1, CONTROL\n"
-      "orr %1, %2\n"
-      "msr CONTROL, %1\n"
-      "isb sy\n"
-
-      /* Initialize MSP */
-
-      "msr msp, %0\n"
-      "isb sy\n"
-      :
-      : "r" (stack), "r" (tempa), "r" (tempb)
-      : "memory");
-}
-#endif
diff --git a/arch/arm/src/armv7-m/CMakeLists.txt 
b/arch/arm/src/armv7-m/CMakeLists.txt
index 951f991398c..730e670b105 100644
--- a/arch/arm/src/armv7-m/CMakeLists.txt
+++ b/arch/arm/src/armv7-m/CMakeLists.txt
@@ -27,7 +27,6 @@ set(SRCS
     arm_cache.c
     arm_cpuinfo.c
     arm_doirq.c
-    arm_initialstate.c
     arm_itm.c
     arm_perf.c)
 
diff --git a/arch/arm/src/armv7-m/Kconfig b/arch/arm/src/armv7-m/Kconfig
index 79a4ce64773..c6047c829f0 100644
--- a/arch/arm/src/armv7-m/Kconfig
+++ b/arch/arm/src/armv7-m/Kconfig
@@ -102,6 +102,7 @@ config ARMV7M_STACKCHECK
        bool "Check for stack overflow on each function call"
        default n
        depends on ARMV7M_HAVE_STACKCHECK
+       select ARM_STACKCHECK
        ---help---
                This check uses R10 to check for a stack overflow within each
                function call. This has performances and code size impacts, but 
it
diff --git a/arch/arm/src/armv7-m/Make.defs b/arch/arm/src/armv7-m/Make.defs
index a05521d409a..51d717eda51 100644
--- a/arch/arm/src/armv7-m/Make.defs
+++ b/arch/arm/src/armv7-m/Make.defs
@@ -25,7 +25,7 @@
 include common/Make.defs
 include arm_m/Make.defs
 
-CMN_CSRCS += arm_cache.c arm_cpuinfo.c arm_doirq.c arm_initialstate.c
+CMN_CSRCS += arm_cache.c arm_cpuinfo.c arm_doirq.c
 CMN_CSRCS += arm_itm.c arm_perf.c arm_dbgmonitor.c
 
 ifeq ($(CONFIG_ARMV7M_ITMSYSLOG),y)
diff --git a/arch/arm/src/armv7-m/arm_initialstate.c 
b/arch/arm/src/armv7-m/arm_initialstate.c
deleted file mode 100644
index f981cc2fae7..00000000000
--- a/arch/arm/src/armv7-m/arm_initialstate.c
+++ /dev/null
@@ -1,208 +0,0 @@
-/****************************************************************************
- * arch/arm/src/armv7-m/arm_initialstate.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 <sys/types.h>
-#include <stdint.h>
-#include <string.h>
-
-#include <nuttx/arch.h>
-#include <arch/arm_m/nvicpri.h>
-
-#include "arm_internal.h"
-#include "psr.h"
-#include "exc_return.h"
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: up_initial_state
- *
- * Description:
- *   A new thread is being started and a new TCB
- *   has been created. This function is called to initialize
- *   the processor specific portions of the new TCB.
- *
- *   This function must setup the initial architecture registers
- *   and/or  stack so that execution will begin at tcb->start
- *   on the next context switch.
- *
- ****************************************************************************/
-
-void up_initial_state(struct tcb_s *tcb)
-{
-  struct xcptcontext *xcp = &tcb->xcp;
-
-  /* Initialize the initial exception register context structure */
-
-  memset(xcp, 0, sizeof(struct xcptcontext));
-
-  /* Initialize the idle thread stack */
-
-  if (tcb->pid == IDLE_PROCESS_ID)
-    {
-      tcb->stack_alloc_ptr = (void *)(g_idle_topstack -
-                                      CONFIG_IDLETHREAD_STACKSIZE);
-      tcb->stack_base_ptr  = tcb->stack_alloc_ptr;
-      tcb->adj_stack_size  = CONFIG_IDLETHREAD_STACKSIZE;
-
-#ifdef CONFIG_STACK_COLORATION
-      /* If stack debug is enabled, then fill the stack with a
-       * recognizable value that we can use later to test for high
-       * water marks.
-       */
-
-      arm_stack_color(tcb->stack_alloc_ptr, 0);
-#endif /* CONFIG_STACK_COLORATION */
-
-      return;
-    }
-
-  /* Initialize the context registers to stack top */
-
-  xcp->regs = (void *)((uint32_t)tcb->stack_base_ptr +
-                                 tcb->adj_stack_size -
-                                 XCPTCONTEXT_SIZE);
-
-  /* Initialize the xcp registers */
-
-  memset(xcp->regs, 0, XCPTCONTEXT_SIZE);
-
-  /* Save the initial stack pointer */
-
-  xcp->regs[REG_SP]      = (uint32_t)tcb->stack_base_ptr +
-                                     tcb->adj_stack_size;
-
-#ifdef CONFIG_ARMV7M_STACKCHECK
-  /* Set the stack limit value */
-
-  xcp->regs[REG_R10]     = (uint32_t)tcb->stack_alloc_ptr + 64;
-#endif
-
-  /* Save the task entry point (stripping off the thumb bit) */
-
-  xcp->regs[REG_PC]      = (uint32_t)tcb->start & ~1;
-
-  /* Specify thumb mode */
-
-  xcp->regs[REG_XPSR]    = ARM_XPSR_T;
-
-  /* All tasks need set to pic address to special register */
-
-#ifdef CONFIG_BUILD_PIC
-  __asm__ ("mov %0, r9" : "=r"(xcp->regs[REG_R9]));
-#endif
-
-  /* If this task is running PIC, then set the PIC base register to the
-   * address of the allocated D-Space region.
-   */
-
-#ifdef CONFIG_PIC
-  if (tcb->dspace != NULL)
-    {
-      /* Set the PIC base register (R9) to the address of the allocated
-       * D-Space region.
-       */
-
-      xcp->regs[REG_PIC] = (uint32_t)tcb->dspace->region;
-    }
-
-#ifdef CONFIG_NXFLAT
-  /* Make certain that bit 0 is set in the main entry address.  This
-   * is only an issue when NXFLAT is enabled.  NXFLAT doesn't know
-   * anything about thumb; the addresses that NXFLAT sets are based
-   * on file header info and won't have bit 0 set.
-   */
-
-  tcb->entry.main = (main_t)((uint32_t)tcb->entry.main | 1);
-#endif
-#endif /* CONFIG_PIC */
-
-  /* All tasks start via a stub function in kernel space.  So all
-   * tasks must start in privileged thread mode.  If CONFIG_BUILD_PROTECTED
-   * is defined, then that stub function will switch to unprivileged
-   * mode before transferring control to the user task.
-   */
-
-  xcp->regs[REG_EXC_RETURN] = EXC_RETURN_THREAD;
-
-  xcp->regs[REG_CONTROL] = getcontrol() & ~CONTROL_NPRIV;
-
-#ifdef CONFIG_ARCH_FPU
-  xcp->regs[REG_FPSCR]   = 0; /* REVISIT: Initial FPSCR should be configurable 
*/
-#endif /* CONFIG_ARCH_FPU */
-
-  /* Enable or disable interrupts, based on user configuration */
-
-#ifdef CONFIG_SUPPRESS_INTERRUPTS
-  xcp->regs[REG_BASEPRI] = NVIC_SYSH_DISABLE_PRIORITY;
-#else /* CONFIG_SUPPRESS_INTERRUPTS */
-  xcp->regs[REG_BASEPRI] = 0;
-#endif /* CONFIG_SUPPRESS_INTERRUPTS */
-}
-
-#if CONFIG_ARCH_INTERRUPTSTACK > 7
-/****************************************************************************
- * Name: arm_initialize_stack
- *
- * Description:
- *   If interrupt stack is defined, the PSP and MSP need to be reinitialized.
- *
- ****************************************************************************/
-
-noinline_function void arm_initialize_stack(void)
-{
-  uint32_t stack = up_get_intstackbase(this_cpu()) + INTSTACK_SIZE;
-  uint32_t temp = 0;
-
-  __asm__ __volatile__
-    (
-
-      /* Initialize PSP */
-
-      "mov %1, sp\n"
-      "msr psp, %1\n"
-      "isb sy\n"
-
-      /* Select PSP */
-
-      "mrs %1, CONTROL\n"
-      "orr %1, #2\n"
-      "msr CONTROL, %1\n"
-      "isb sy\n"
-
-      /* Initialize MSP */
-
-      "msr msp, %0\n"
-      "isb sy\n"
-      :
-      : "r" (stack), "r" (temp)
-      : "memory");
-}
-#endif
diff --git a/arch/arm/src/armv8-m/CMakeLists.txt 
b/arch/arm/src/armv8-m/CMakeLists.txt
index 1f2843369b2..ad5e1e3635f 100644
--- a/arch/arm/src/armv8-m/CMakeLists.txt
+++ b/arch/arm/src/armv8-m/CMakeLists.txt
@@ -25,7 +25,6 @@ set(SRCS
     arm_cache.c
     arm_cpuinfo.c
     arm_doirq.c
-    arm_initialstate.c
     arm_itm.c
     arm_perf.c
     arm_sau.c
diff --git a/arch/arm/src/armv8-m/Kconfig b/arch/arm/src/armv8-m/Kconfig
index c4036ccd2d1..b272aad01d0 100644
--- a/arch/arm/src/armv8-m/Kconfig
+++ b/arch/arm/src/armv8-m/Kconfig
@@ -86,6 +86,7 @@ config ARMV8M_STACKCHECK_NONE
 
 config ARMV8M_STACKCHECK
        bool "Check for stack overflow on each function call"
+       select ARM_STACKCHECK
        ---help---
                This check uses R10 to check for a stack overflow within each
                function call. This has performances and code size impacts, but 
it
diff --git a/arch/arm/src/armv8-m/Make.defs b/arch/arm/src/armv8-m/Make.defs
index d01f70fcc9a..49c806ad91d 100644
--- a/arch/arm/src/armv8-m/Make.defs
+++ b/arch/arm/src/armv8-m/Make.defs
@@ -25,7 +25,7 @@
 include common/Make.defs
 include arm_m/Make.defs
 
-CMN_CSRCS += arm_cache.c arm_cpuinfo.c arm_doirq.c arm_initialstate.c
+CMN_CSRCS += arm_cache.c arm_cpuinfo.c arm_doirq.c
 CMN_CSRCS += arm_itm.c arm_perf.c arm_sau.c arm_secure_irq.c
 CMN_CSRCS += arm_dbgmonitor.c
 

Reply via email to