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 07f71690fcd2869b714a2cf553fd955586c35537 Author: hujun5 <[email protected]> AuthorDate: Mon Dec 29 12:35:33 2025 +0800 arm: merge arm_initialstate.c merge arm_initialstate.c Signed-off-by: hujun5 <[email protected]> --- arch/arm/src/arm/CMakeLists.txt | 1 - arch/arm/src/arm/Make.defs | 1 - arch/arm/src/arm/arm_initialstate.c | 155 -------------------- arch/arm/src/arm_a_r/CMakeLists.txt | 3 +- arch/arm/src/arm_a_r/Make.defs | 1 + .../src/{armv7-a => arm_a_r}/arm_initialstate.c | 8 +- arch/arm/src/armv7-a/CMakeLists.txt | 1 - arch/arm/src/armv7-a/Make.defs | 2 +- arch/arm/src/armv7-r/CMakeLists.txt | 1 - arch/arm/src/armv7-r/Make.defs | 1 - arch/arm/src/armv7-r/arm_initialstate.c | 156 --------------------- arch/arm/src/armv8-r/CMakeLists.txt | 1 - arch/arm/src/armv8-r/Make.defs | 1 - arch/arm/src/armv8-r/arm_initialstate.c | 156 --------------------- 14 files changed, 10 insertions(+), 478 deletions(-) diff --git a/arch/arm/src/arm/CMakeLists.txt b/arch/arm/src/arm/CMakeLists.txt index e28b87d5492..891ae04992b 100644 --- a/arch/arm/src/arm/CMakeLists.txt +++ b/arch/arm/src/arm/CMakeLists.txt @@ -25,7 +25,6 @@ target_sources(nuttx PRIVATE arm_head.S) list( APPEND SRCS - arm_initialstate.c arm_undefinedinsn.c arm_cache.S arm_vectors.S diff --git a/arch/arm/src/arm/Make.defs b/arch/arm/src/arm/Make.defs index ad99b44c396..e8d56002c13 100644 --- a/arch/arm/src/arm/Make.defs +++ b/arch/arm/src/arm/Make.defs @@ -27,7 +27,6 @@ include arm_a_r/Make.defs HEAD_ASRC = arm_head.S -CMN_CSRCS += arm_initialstate.c CMN_CSRCS += arm_undefinedinsn.c CMN_ASRCS += arm_cache.S arm_vectors.S arm_vectortab.S diff --git a/arch/arm/src/arm/arm_initialstate.c b/arch/arm/src/arm/arm_initialstate.c deleted file mode 100644 index fa1e990a60f..00000000000 --- a/arch/arm/src/arm/arm_initialstate.c +++ /dev/null @@ -1,155 +0,0 @@ -/**************************************************************************** - * arch/arm/src/arm/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 <stdint.h> -#include <string.h> - -#include <nuttx/arch.h> - -#include "arm.h" -#include "arm_internal.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; - uint32_t cpsr; - - /* 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 */ - - xcp->regs[REG_PC] = (uint32_t)tcb->start; - - /* 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; - } -#endif - - /* Set supervisor- or user-mode, depending on how NuttX is configured and - * what kind of thread is being started. Disable FIQs in any event - */ - -#ifdef CONFIG_BUILD_KERNEL - if ((tcb->flags & TCB_FLAG_TTYPE_MASK) == TCB_FLAG_TTYPE_KERNEL) - { - /* It is a kernel thread.. set supervisor mode */ - - cpsr = PSR_MODE_SYS | PSR_F_BIT; - } - else - { - /* It is a normal task or a pthread. Set user mode */ - - cpsr = PSR_MODE_USR | PSR_F_BIT; - } -#else - /* If the kernel build is not selected, then all threads run in - * supervisor-mode. - */ - - cpsr = PSR_MODE_SYS | PSR_F_BIT; -#endif - - /* Enable or disable interrupts, based on user configuration */ - -#ifdef CONFIG_SUPPRESS_INTERRUPTS - cpsr |= PSR_I_BIT; -#endif - -#ifdef CONFIG_ARM_THUMB - cpsr |= PSR_T_BIT; -#endif - - xcp->regs[REG_CPSR] = cpsr; -} diff --git a/arch/arm/src/arm_a_r/CMakeLists.txt b/arch/arm/src/arm_a_r/CMakeLists.txt index 3d2b3763bc1..43b741a7f30 100644 --- a/arch/arm/src/arm_a_r/CMakeLists.txt +++ b/arch/arm/src/arm_a_r/CMakeLists.txt @@ -41,6 +41,7 @@ list( arm_syscall.c arm_prefetchabort.c arm_cpuidlestack.c - arm_userfault.c) + arm_userfault.c + arm_initialstate.c) target_sources(arch PRIVATE ${CSRCS}) diff --git a/arch/arm/src/arm_a_r/Make.defs b/arch/arm/src/arm_a_r/Make.defs index c112b6dc6fd..6e93052ae01 100644 --- a/arch/arm/src/arm_a_r/Make.defs +++ b/arch/arm/src/arm_a_r/Make.defs @@ -24,6 +24,7 @@ CMN_CSRCS += arm_tcbinfo.c arm_doirq.c arm_dataabort.c arm_syscall.c CMN_CSRCS += arm_prefetchabort.c arm_userfault.c arm_cpuidlestack.c +CMN_CSRCS += arm_initialstate.c ifeq ($(CONFIG_ENABLE_ALL_SIGNALS),y) CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c diff --git a/arch/arm/src/armv7-a/arm_initialstate.c b/arch/arm/src/arm_a_r/arm_initialstate.c similarity index 96% rename from arch/arm/src/armv7-a/arm_initialstate.c rename to arch/arm/src/arm_a_r/arm_initialstate.c index bb074e94914..fb0f5e40cbc 100644 --- a/arch/arm/src/armv7-a/arm_initialstate.c +++ b/arch/arm/src/arm_a_r/arm_initialstate.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-a/arm_initialstate.c + * arch/arm/src/arm_a_r/arm_initialstate.c * * SPDX-License-Identifier: Apache-2.0 * @@ -172,7 +172,7 @@ void up_initial_state(struct tcb_s *tcb) */ cpsr |= PSR_I_BIT; -#elif !defined(CONFIG_ARCH_HIPRI_INTERRUPT) +#elif !defined(CONFIG_ARCH_HIPRI_INTERRUPT) && !defined(CONFIG_ARM_DECODEFIQ) /* Leave IRQs enabled (Also FIQs if CONFIG_ARCH_TRUSTZONE_SECURE or * CONFIG_ARCH_HIPRI_INTERRUPT is selected) */ @@ -184,5 +184,9 @@ void up_initial_state(struct tcb_s *tcb) cpsr |= PSR_T_BIT; #endif +#ifdef CONFIG_ENDIAN_BIG + cpsr |= PSR_E_BIT; +#endif /* CONFIG_ENDIAN_BIG */ + xcp->regs[REG_CPSR] = cpsr; } diff --git a/arch/arm/src/armv7-a/CMakeLists.txt b/arch/arm/src/armv7-a/CMakeLists.txt index fbdda9e76f2..b3d974a398c 100644 --- a/arch/arm/src/armv7-a/CMakeLists.txt +++ b/arch/arm/src/armv7-a/CMakeLists.txt @@ -38,7 +38,6 @@ list( arm_cpuinfo.c arm_gicv2.c arm_gicv2_dump.c - arm_initialstate.c arm_mmu.c arm_undefinedinsn.c arm_perf.c diff --git a/arch/arm/src/armv7-a/Make.defs b/arch/arm/src/armv7-a/Make.defs index 09d3b26bf2e..5a53d5c2e70 100644 --- a/arch/arm/src/armv7-a/Make.defs +++ b/arch/arm/src/armv7-a/Make.defs @@ -38,7 +38,7 @@ CMN_ASRCS += arm_cpuhead.S arm_vectors.S arm_saveusercontext.S CMN_CSRCS += arm_cache.c arm_cpuinfo.c CMN_CSRCS += arm_gicv2.c arm_gicv2_dump.c -CMN_CSRCS += arm_initialstate.c arm_mmu.c +CMN_CSRCS += arm_mmu.c CMN_CSRCS += arm_undefinedinsn.c CMN_CSRCS += arm_perf.c cp15_cacheops.c diff --git a/arch/arm/src/armv7-r/CMakeLists.txt b/arch/arm/src/armv7-r/CMakeLists.txt index b75b4a4833f..4dda7431fde 100644 --- a/arch/arm/src/armv7-r/CMakeLists.txt +++ b/arch/arm/src/armv7-r/CMakeLists.txt @@ -35,7 +35,6 @@ list( SRCS arm_cache.c arm_cpuinfo.c - arm_initialstate.c arm_undefinedinsn.c arm_perf.c cp15_cacheops.c) diff --git a/arch/arm/src/armv7-r/Make.defs b/arch/arm/src/armv7-r/Make.defs index 6ef399b388a..7153db23548 100644 --- a/arch/arm/src/armv7-r/Make.defs +++ b/arch/arm/src/armv7-r/Make.defs @@ -34,7 +34,6 @@ HEAD_ASRC += arm_vectortab.S CMN_CSRCS += arm_cache.c arm_cpuinfo.c CMN_CSRCS += arm_gicv2.c arm_gicv2_dump.c -CMN_CSRCS += arm_initialstate.c CMN_CSRCS += arm_undefinedinsn.c CMN_CSRCS += arm_perf.c cp15_cacheops.c diff --git a/arch/arm/src/armv7-r/arm_initialstate.c b/arch/arm/src/armv7-r/arm_initialstate.c deleted file mode 100644 index 17b01c2327b..00000000000 --- a/arch/arm/src/armv7-r/arm_initialstate.c +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-r/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 <stdint.h> -#include <string.h> - -#include <nuttx/arch.h> - -#include "arm.h" -#include "arm_internal.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; - uint32_t cpsr; - - /* 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 */ - - xcp->regs[REG_PC] = (uint32_t)tcb->start; - - /* 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; - } -#endif - - /* Set supervisor-mode and disable FIQs, regardless of how NuttX is - * configured and of what kind of thread is being started. That is - * because all threads, even user-mode threads will start in kernel - * trampoline at nxtask_start() or pthread_start(). The thread's - * privileges will be dropped before transitioning to user code. - */ - - cpsr = PSR_MODE_SYS; - - /* Enable or disable interrupts, based on user configuration */ - -#ifdef CONFIG_SUPPRESS_INTERRUPTS - /* Disable interrupts (both IRQs and FIQs) */ - - cpsr |= (PSR_I_BIT | PSR_F_BIT); - -#else /* CONFIG_SUPPRESS_INTERRUPTS */ - /* Leave IRQs enabled (Also FIQs if CONFIG_ARMV7R_DECODEFIQ is selected) */ - -#ifndef CONFIG_ARMV7R_DECODEFIQ - - cpsr |= PSR_F_BIT; - -#endif /* !CONFIG_ARMV7R_DECODEFIQ */ - -#ifdef CONFIG_ARM_THUMB - cpsr |= PSR_T_BIT; -#endif - -#ifdef CONFIG_ENDIAN_BIG - - cpsr |= PSR_E_BIT; - -#endif /* CONFIG_ENDIAN_BIG */ -#endif /* CONFIG_SUPPRESS_INTERRUPTS */ - - xcp->regs[REG_CPSR] = cpsr; -} diff --git a/arch/arm/src/armv8-r/CMakeLists.txt b/arch/arm/src/armv8-r/CMakeLists.txt index 723666a05cb..e2bb601f57c 100644 --- a/arch/arm/src/armv8-r/CMakeLists.txt +++ b/arch/arm/src/armv8-r/CMakeLists.txt @@ -33,7 +33,6 @@ list( arm_cache.c arm_cpuinfo.c arm_gicv3.c - arm_initialstate.c arm_undefinedinsn.c arm_perf.c cp15_cacheops.c) diff --git a/arch/arm/src/armv8-r/Make.defs b/arch/arm/src/armv8-r/Make.defs index 0f11b069940..6c6580b8850 100644 --- a/arch/arm/src/armv8-r/Make.defs +++ b/arch/arm/src/armv8-r/Make.defs @@ -38,7 +38,6 @@ CMN_ASRCS += arm_head.S arm_vectors.S arm_saveusercontext.S CMN_CSRCS += arm_timer.c arm_cache.c arm_cpuinfo.c CMN_CSRCS += arm_gicv3.c -CMN_CSRCS += arm_initialstate.c CMN_CSRCS += arm_undefinedinsn.c CMN_CSRCS += arm_perf.c cp15_cacheops.c diff --git a/arch/arm/src/armv8-r/arm_initialstate.c b/arch/arm/src/armv8-r/arm_initialstate.c deleted file mode 100644 index 89d39d501e9..00000000000 --- a/arch/arm/src/armv8-r/arm_initialstate.c +++ /dev/null @@ -1,156 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv8-r/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 <stdint.h> -#include <string.h> - -#include <nuttx/arch.h> - -#include "arm.h" -#include "arm_internal.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; - uint32_t cpsr; - - /* 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 */ - - xcp->regs[REG_PC] = (uint32_t)tcb->start; - - /* 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; - } -#endif - - /* Set supervisor-mode and disable FIQs, regardless of how NuttX is - * configured and of what kind of thread is being started. That is - * because all threads, even user-mode threads will start in kernel - * trampoline at nxtask_start() or pthread_start(). The thread's - * privileges will be dropped before transitioning to user code. - */ - - cpsr = PSR_MODE_SYS; - - /* Enable or disable interrupts, based on user configuration */ - -#ifdef CONFIG_SUPPRESS_INTERRUPTS - /* Disable interrupts (both IRQs and FIQs) */ - - cpsr |= (PSR_I_BIT | PSR_F_BIT); - -#else /* CONFIG_SUPPRESS_INTERRUPTS */ - /* Leave IRQs enabled (Also FIQs if CONFIG_ARCH_HIPRI_INTERRUPT is selected) */ - -#ifndef CONFIG_ARCH_HIPRI_INTERRUPT - - cpsr |= PSR_F_BIT; - -#endif /* !CONFIG_ARCH_HIPRI_INTERRUPT */ - -#ifdef CONFIG_ARM_THUMB - cpsr |= PSR_T_BIT; -#endif - -#ifdef CONFIG_ENDIAN_BIG - - cpsr |= PSR_E_BIT; - -#endif /* CONFIG_ENDIAN_BIG */ -#endif /* CONFIG_SUPPRESS_INTERRUPTS */ - - xcp->regs[REG_CPSR] = cpsr; -}
