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

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 1e2c7f1d51736bb52fbdafdf3d29752ddbe705c4
Author: hujun5 <[email protected]>
AuthorDate: Wed Dec 3 14:01:06 2025 +0800

    arm_a_r: merge arm_prefetchabort.c to arm_a_r
    
    merge arm_prefetchabort.c to arm_a_r
    
    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_prefetchabort.c               | 130 ---------------------
 arch/arm/src/arm/arm_vectors.S                     |   3 +
 arch/arm/src/arm_a_r/CMakeLists.txt                |   9 +-
 arch/arm/src/arm_a_r/Make.defs                     |   1 +
 .../src/{armv7-a => arm_a_r}/arm_prefetchabort.c   |  10 +-
 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                     |   2 +-
 arch/arm/src/armv7-r/arm_prefetchabort.c           |  65 -----------
 arch/arm/src/armv8-r/CMakeLists.txt                |   1 -
 arch/arm/src/armv8-r/Make.defs                     |   2 +-
 arch/arm/src/armv8-r/arm_prefetchabort.c           |  65 -----------
 arch/arm/src/common/arm_internal.h                 |   2 +-
 16 files changed, 20 insertions(+), 276 deletions(-)

diff --git a/arch/arm/src/arm/CMakeLists.txt b/arch/arm/src/arm/CMakeLists.txt
index ea8c3c275ea..e28b87d5492 100644
--- a/arch/arm/src/arm/CMakeLists.txt
+++ b/arch/arm/src/arm/CMakeLists.txt
@@ -26,7 +26,6 @@ list(
   APPEND
   SRCS
   arm_initialstate.c
-  arm_prefetchabort.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 c7bf88d6f39..ad99b44c396 100644
--- a/arch/arm/src/arm/Make.defs
+++ b/arch/arm/src/arm/Make.defs
@@ -28,7 +28,6 @@ include arm_a_r/Make.defs
 HEAD_ASRC  = arm_head.S
 
 CMN_CSRCS += arm_initialstate.c
-CMN_CSRCS += arm_prefetchabort.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_prefetchabort.c 
b/arch/arm/src/arm/arm_prefetchabort.c
deleted file mode 100644
index d5494e7733a..00000000000
--- a/arch/arm/src/arm/arm_prefetchabort.c
+++ /dev/null
@@ -1,130 +0,0 @@
-/****************************************************************************
- * arch/arm/src/arm/arm_prefetchabort.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 <assert.h>
-
-#include <nuttx/debug.h>
-#include <nuttx/irq.h>
-#ifdef CONFIG_LEGACY_PAGING
-#  include <nuttx/page.h>
-#endif
-
-#include "sched/sched.h"
-#include "arm_internal.h"
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: arm_prefetchabort
- *
- * Description:
- *   This is the prefetch abort exception handler. The ARM prefetch abort
- *   exception occurs when a memory fault is detected during an an
- *   instruction fetch.
- *
- ****************************************************************************/
-
-void arm_prefetchabort(uint32_t *regs)
-{
-  struct tcb_s *tcb = this_task();
-
-#ifdef CONFIG_LEGACY_PAGING
-  uint32_t *saveregs;
-  bool savestate;
-
-  savestate = up_interrupt_context();
-  saveregs = tcb->xcp.regs;
-#endif
-  tcb->xcp.regs = regs;
-  up_set_interrupt_context(true);
-
-#ifdef CONFIG_LEGACY_PAGING
-  /* Get the (virtual) address of instruction that caused the prefetch
-   * abort.  When the exception occurred, this address was provided in the
-   * lr register and this value was saved in the context save area as the PC
-   * at the REG_R15 index.
-   *
-   * Check to see if this miss address is within the configured range of
-   * virtual addresses.
-   */
-
-  pginfo("VADDR: %08" PRIx32 " VBASE: %08x VEND: %08x\n",
-         regs[REG_PC], PG_PAGED_VBASE, PG_PAGED_VEND);
-
-  if (regs[REG_R15] >= PG_PAGED_VBASE && regs[REG_R15] < PG_PAGED_VEND)
-    {
-      /* Save the offending PC as the fault address in the TCB of the
-       * currently executing task.  This value is, of course, already known
-       * in regs[REG_R15], but saving it in this location will allow common
-       * paging logic for both prefetch and data aborts.
-       */
-
-      tcb->xcp.far  = regs[REG_R15];
-
-      /* Call pg_miss() to schedule the page fill.  A consequences of this
-       * call are:
-       *
-       * (1) The currently executing task will be blocked and saved on
-       *     on the g_waitingforfill task list.
-       * (2) An interrupt-level context switch will occur so that when
-       *     this function returns, it will return to a different task,
-       *     most likely the page fill worker thread.
-       * (3) The page fill worker task has been signalled and should
-       *     execute immediately when we return from this exception.
-       */
-
-      pg_miss();
-
-      /* Restore the previous value of saveregs. */
-
-      up_set_interrupt_context(savestate);
-      tcb->xcp.regs = saveregs;
-    }
-  else
-#endif
-    {
-      _alert("Prefetch abort. PC: %08" PRIx32 "\n", regs[REG_PC]);
-      PANIC_WITH_REGS("panic", regs);
-    }
-}
diff --git a/arch/arm/src/arm/arm_vectors.S b/arch/arm/src/arm/arm_vectors.S
index 40ff9b28a6c..d219a7b6227 100644
--- a/arch/arm/src/arm/arm_vectors.S
+++ b/arch/arm/src/arm/arm_vectors.S
@@ -489,6 +489,9 @@ arm_vectorprefetch:
        savefpu r0, r1
 #endif
 
+       mrc     CP15_IFAR(r1)   /* Get R1=IFAR */
+       mrc     CP15_IFSR(r2)   /* Get r2=IFSR */
+
        /* Then call the prefetch abort handler with interrupts disabled.
         * void arm_prefetchabort(struct xcptcontext *xcp)
         */
diff --git a/arch/arm/src/arm_a_r/CMakeLists.txt 
b/arch/arm/src/arm_a_r/CMakeLists.txt
index 9163ccb9005..ae9b8fa9bc9 100644
--- a/arch/arm/src/arm_a_r/CMakeLists.txt
+++ b/arch/arm/src/arm_a_r/CMakeLists.txt
@@ -32,6 +32,13 @@ if(CONFIG_LIB_SYSCALL)
   list(APPEND CSRCS arm_dispatch_syscall.S)
 endif()
 
-list(APPEND CSRCS arm_tcbinfo.c arm_doirq.c arm_dataabort.c arm_syscall.c)
+list(
+  APPEND
+  CSRCS
+  arm_tcbinfo.c
+  arm_doirq.c
+  arm_dataabort.c
+  arm_syscall.c
+  arm_prefetchabort.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 e58a9f762db..1a5509899d8 100644
--- a/arch/arm/src/arm_a_r/Make.defs
+++ b/arch/arm/src/arm_a_r/Make.defs
@@ -23,6 +23,7 @@
 # Common ARM_A_R files
 
 CMN_CSRCS += arm_tcbinfo.c arm_doirq.c arm_dataabort.c arm_syscall.c
+CMN_CSRCS += arm_prefetchabort.c
 
 ifeq ($(CONFIG_ENABLE_ALL_SIGNALS),y)
   CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c
diff --git a/arch/arm/src/armv7-a/arm_prefetchabort.c 
b/arch/arm/src/arm_a_r/arm_prefetchabort.c
similarity index 95%
rename from arch/arm/src/armv7-a/arm_prefetchabort.c
rename to arch/arm/src/arm_a_r/arm_prefetchabort.c
index e02a1fa1f4f..6d4c3aebfde 100644
--- a/arch/arm/src/armv7-a/arm_prefetchabort.c
+++ b/arch/arm/src/arm_a_r/arm_prefetchabort.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/arm/src/armv7-a/arm_prefetchabort.c
+ * arch/arm/src/arm_a_r/arm_prefetchabort.c
  *
  * SPDX-License-Identifier: Apache-2.0
  *
@@ -77,8 +77,8 @@ uint32_t *arm_prefetchabort(uint32_t *regs, uint32_t ifar, 
uint32_t ifsr)
    * virtual addresses.
    */
 
-  pginfo("VADDR: %08x VBASE: %08x VEND: %08x\n",
-         regs[REG_PC], PG_PAGED_VBASE, PG_PAGED_VEND);
+  pginfo("VADDR: %08" PRIx32 " VBASE: %08" PRIx32 " VEND: %08" PRIx32 "n",
+         regs[REG_PC], (uint32_t)PG_PAGED_VBASE, (uint32_t)PG_PAGED_VEND);
 
   if (FSR_FAULT(ifsr) == FSR_FAULT_DEBUG)
     {
@@ -92,9 +92,7 @@ uint32_t *arm_prefetchabort(uint32_t *regs, uint32_t ifar, 
uint32_t ifsr)
        * paging logic for both prefetch and data aborts.
        */
 
-      struct tcb_s *tcb = this_task();
-
-      tcb->xcp.far  = regs[REG_R15];
+      tcb->xcp.far = regs[REG_R15];
 
       /* Call pg_miss() to schedule the page fill.  A consequences of this
        * call are:
diff --git a/arch/arm/src/armv7-a/CMakeLists.txt 
b/arch/arm/src/armv7-a/CMakeLists.txt
index b5896082099..7f85ce45741 100644
--- a/arch/arm/src/armv7-a/CMakeLists.txt
+++ b/arch/arm/src/armv7-a/CMakeLists.txt
@@ -40,7 +40,6 @@ list(
   arm_gicv2_dump.c
   arm_initialstate.c
   arm_mmu.c
-  arm_prefetchabort.c
   arm_undefinedinsn.c
   arm_userfault.c
   arm_perf.c
diff --git a/arch/arm/src/armv7-a/Make.defs b/arch/arm/src/armv7-a/Make.defs
index ff2697a959f..92b6258ee37 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 arm_prefetchabort.c
+CMN_CSRCS += arm_initialstate.c arm_mmu.c
 CMN_CSRCS += arm_undefinedinsn.c
 CMN_CSRCS += arm_perf.c arm_userfault.c cp15_cacheops.c
 
diff --git a/arch/arm/src/armv7-r/CMakeLists.txt 
b/arch/arm/src/armv7-r/CMakeLists.txt
index a918bde1411..acf419401e9 100644
--- a/arch/arm/src/armv7-r/CMakeLists.txt
+++ b/arch/arm/src/armv7-r/CMakeLists.txt
@@ -36,7 +36,6 @@ list(
   arm_cache.c
   arm_cpuinfo.c
   arm_initialstate.c
-  arm_prefetchabort.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 209b7fa16a9..5237ce35a4c 100644
--- a/arch/arm/src/armv7-r/Make.defs
+++ b/arch/arm/src/armv7-r/Make.defs
@@ -34,7 +34,7 @@ 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 arm_prefetchabort.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_prefetchabort.c 
b/arch/arm/src/armv7-r/arm_prefetchabort.c
deleted file mode 100644
index 046de98127c..00000000000
--- a/arch/arm/src/armv7-r/arm_prefetchabort.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
- * arch/arm/src/armv7-r/arm_prefetchabort.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/debug.h>
-#include <nuttx/irq.h>
-
-#include "sched/sched.h"
-#include "arm_internal.h"
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: arm_prefetchabort
- *
- * Description:
- *   This is the prefetch abort exception handler. The ARM prefetch abort
- *   exception occurs when a memory fault is detected during an an
- *   instruction fetch.
- *
- ****************************************************************************/
-
-uint32_t *arm_prefetchabort(uint32_t *regs, uint32_t ifar, uint32_t ifsr)
-{
-  struct tcb_s *tcb = this_task();
-
-  tcb->xcp.regs = regs;
-  up_set_interrupt_context(true);
-
-  /* Crash -- possibly showing diagnostic debug information. */
-
-  _alert("Prefetch abort. PC: %08" PRIx32 " IFAR: %08" PRIx32 " IFSR: %08"
-         PRIx32 "\n", regs[REG_PC], ifar, ifsr);
-  PANIC_WITH_REGS("panic", regs);
-  return regs; /* To keep the compiler happy */
-}
diff --git a/arch/arm/src/armv8-r/CMakeLists.txt 
b/arch/arm/src/armv8-r/CMakeLists.txt
index 8237480a085..a5258f2f728 100644
--- a/arch/arm/src/armv8-r/CMakeLists.txt
+++ b/arch/arm/src/armv8-r/CMakeLists.txt
@@ -34,7 +34,6 @@ list(
   arm_cpuinfo.c
   arm_gicv3.c
   arm_initialstate.c
-  arm_prefetchabort.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 5ba94157ad0..de2b995d698 100644
--- a/arch/arm/src/armv8-r/Make.defs
+++ b/arch/arm/src/armv8-r/Make.defs
@@ -38,7 +38,7 @@ 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 arm_prefetchabort.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_prefetchabort.c 
b/arch/arm/src/armv8-r/arm_prefetchabort.c
deleted file mode 100644
index 31d939ad082..00000000000
--- a/arch/arm/src/armv8-r/arm_prefetchabort.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/****************************************************************************
- * arch/arm/src/armv8-r/arm_prefetchabort.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/debug.h>
-#include <nuttx/irq.h>
-
-#include "sched/sched.h"
-#include "arm_internal.h"
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: arm_prefetchabort
- *
- * Description:
- *   This is the prefetch abort exception handler. The ARM prefetch abort
- *   exception occurs when a memory fault is detected during an an
- *   instruction fetch.
- *
- ****************************************************************************/
-
-uint32_t *arm_prefetchabort(uint32_t *regs, uint32_t ifar, uint32_t ifsr)
-{
-  struct tcb_s *tcb = this_task();
-
-  tcb->xcp.regs = regs;
-  up_set_interrupt_context(true);
-
-  /* Crash -- possibly showing diagnostic debug information. */
-
-  _alert("Prefetch abort. PC: %08" PRIx32 " IFAR: %08" PRIx32 " IFSR: %08"
-         PRIx32 "\n", regs[REG_PC], ifar, ifsr);
-  PANIC_WITH_REGS("panic", regs);
-  return regs; /* To keep the compiler happy */
-}
diff --git a/arch/arm/src/common/arm_internal.h 
b/arch/arm/src/common/arm_internal.h
index 4a37188df80..f87ad185d58 100644
--- a/arch/arm/src/common/arm_internal.h
+++ b/arch/arm/src/common/arm_internal.h
@@ -386,7 +386,7 @@ uint32_t * arm_dataabort(uint32_t *regs, uint32_t dfar, 
uint32_t dfsr);
 
 /* Exception handlers */
 
-void arm_prefetchabort(uint32_t *regs);
+uint32_t *arm_prefetchabort(uint32_t *regs, uint32_t ifar, uint32_t ifsr);
 uint32_t *arm_syscall(uint32_t *regs);
 void arm_undefinedinsn(uint32_t *regs);
 

Reply via email to