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 f53f82e1efde9a32ffd024c5479bcd43dfb7881d Author: hujun5 <[email protected]> AuthorDate: Mon Nov 17 16:50:28 2025 +0800 arm_a_r: merge arm_dataabort.c to arm_a_r merge arm_dataabort.c to arm_a_r Signed-off-by: hujun5 <[email protected]> --- arch/arm/Kconfig | 8 + arch/arm/include/arm/barriers.h | 2 + arch/arm/src/arm/CMakeLists.txt | 1 - arch/arm/src/arm/Make.defs | 2 +- arch/arm/src/arm/arm.h | 343 ---------------------- arch/arm/src/arm/arm_dataabort.c | 166 ----------- arch/arm/src/arm/arm_head.S | 1 + arch/arm/src/arm/arm_vectors.S | 2 - arch/arm/src/arm/pg_macros.h | 22 +- arch/arm/src/arm_a_r/CMakeLists.txt | 6 +- arch/arm/src/arm_a_r/Make.defs | 6 +- arch/arm/src/{armv7-a => arm_a_r}/arm_dataabort.c | 8 +- arch/arm/src/{armv7-a => arm_a_r}/arm_hwdebug.c | 2 +- arch/arm/src/{armv7-a => arm_a_r}/mmu.h | 95 +++++- arch/arm/src/armv7-a/CMakeLists.txt | 5 - arch/arm/src/armv7-a/Make.defs | 6 +- arch/arm/src/armv7-r/CMakeLists.txt | 1 - arch/arm/src/armv7-r/Make.defs | 2 +- arch/arm/src/armv7-r/arm_dataabort.c | 69 ----- arch/arm/src/armv8-r/CMakeLists.txt | 1 - arch/arm/src/armv8-r/Make.defs | 2 +- arch/arm/src/armv8-r/arm_dataabort.c | 69 ----- arch/arm/src/common/arm_internal.h | 7 +- arch/arm/src/dm320/dm320_boot.c | 9 +- arch/arm/src/imx1/imx_boot.c | 8 - arch/arm/src/lpc31xx/lpc31_boot.c | 10 +- 26 files changed, 136 insertions(+), 717 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 20f10fb66dd..f825f0dbd7d 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1056,6 +1056,7 @@ config ARCH_ARM7TDMI select ARCH_DCACHE select ARCH_ICACHE select LIBC_ATOMIC_IRQ + select ARCH_HAVE_DEBUG ---help--- The Arm7TDMI-S is an excellent workhorse processor capable of a wide array of applications. Traditionally used in mobile handsets, the @@ -1066,6 +1067,7 @@ config ARCH_ARM920T default n select ARCH_DCACHE select ARCH_ICACHE + select ARCH_HAVE_DEBUG select ARCH_HAVE_MMU select ARCH_USE_MMU ---help--- @@ -1083,6 +1085,7 @@ config ARCH_ARM926EJS default n select ARCH_DCACHE select ARCH_ICACHE + select ARCH_HAVE_DEBUG select ARCH_HAVE_MMU select ARCH_USE_MMU select LIBC_ATOMIC_IRQ @@ -1107,6 +1110,7 @@ config ARCH_ARM1136J default n select ARCH_DCACHE select ARCH_ICACHE + select ARCH_HAVE_DEBUG select ARCH_HAVE_MMU select ARCH_USE_MMU ---help--- @@ -1119,6 +1123,7 @@ config ARCH_ARM1156T2 default n select ARCH_DCACHE select ARCH_ICACHE + select ARCH_HAVE_DEBUG select ARCH_HAVE_MMU select ARCH_USE_MMU ---help--- @@ -1130,6 +1135,7 @@ config ARCH_ARM1176JZ default n select ARCH_DCACHE select ARCH_ICACHE + select ARCH_HAVE_DEBUG select ARCH_HAVE_MMU select ARCH_USE_MMU ---help--- @@ -1261,6 +1267,7 @@ config ARCH_ARMV7R bool default n select ARCH_HAVE_CPUINFO + select ARCH_HAVE_DEBUG select ARCH_HAVE_PERF_EVENTS select ARCH_HAVE_PERF_EVENTS_USER_ACCESS select ARM_HAVE_WFE_SEV @@ -1400,6 +1407,7 @@ config ARCH_ARMV8R select ONESHOT_COUNT select ALARM_ARCH select ARM_HAVE_WFE_SEV + select ARCH_HAVE_DEBUG config ARM_GIC_VERSION int "GIC version" diff --git a/arch/arm/include/arm/barriers.h b/arch/arm/include/arm/barriers.h index d8c5737d98f..2b77c81a3e8 100644 --- a/arch/arm/include/arm/barriers.h +++ b/arch/arm/include/arm/barriers.h @@ -32,11 +32,13 @@ /* ARM memory barriers */ #define arm_mb() __asm__ __volatile__ ("" : : : "memory") +#define arm_nop() __asm__ __volatile__ ("nop\n") #define UP_DSB() arm_mb() #define UP_ISB() arm_mb() #define UP_DMB() arm_mb() #define UP_RMB() arm_mb() #define UP_WMB() arm_mb() +#define UP_NOP() arm_nop() #endif /* __ARCH_ARM_INCLUDE_ARM_BARRIERS_H */ diff --git a/arch/arm/src/arm/CMakeLists.txt b/arch/arm/src/arm/CMakeLists.txt index 48d70f470d1..b6fb40ee9aa 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_dataabort.c arm_initialstate.c arm_prefetchabort.c arm_syscall.c diff --git a/arch/arm/src/arm/Make.defs b/arch/arm/src/arm/Make.defs index 2d3a98c67ce..996c80e752e 100644 --- a/arch/arm/src/arm/Make.defs +++ b/arch/arm/src/arm/Make.defs @@ -27,7 +27,7 @@ include arm_a_r/Make.defs HEAD_ASRC = arm_head.S -CMN_CSRCS += arm_dataabort.c arm_initialstate.c +CMN_CSRCS += arm_initialstate.c CMN_CSRCS += arm_prefetchabort.c CMN_CSRCS += arm_syscall.c CMN_CSRCS += arm_undefinedinsn.c diff --git a/arch/arm/src/arm/arm.h b/arch/arm/src/arm/arm.h index 2cd51c172f6..ff9b8d7f934 100644 --- a/arch/arm/src/arm/arm.h +++ b/arch/arm/src/arm/arm.h @@ -86,349 +86,6 @@ #define CR_XP 0x00800000 /* Extended page tables */ #define CR_VE 0x01000000 /* Vectored interrupts */ -/* The lowest 4-bits of the FSR register indicates the fault generated by - * the MMU. - */ - -#define FSR_MASK 15 /* Bits 0-3: Type of fault */ -#define FSR_VECTOR 0 /* Vector exception */ -#define FSR_ALIGN1 1 /* Alignment fault */ -#define FSR_TERMINAL 2 /* Terminal exception */ -#define FSR_ALIGN2 3 /* Alignment fault */ -#define FSR_LINESECT 4 /* External abort on linefetch for section translation */ -#define FSR_SECT 5 /* Section translation fault (unmapped virtual address) */ -#define FSR_LINEPAGE 6 /* External abort on linefetch for page translation */ -#define FSR_PAGE 7 /* Page translation fault (unmapped virtual address) */ -#define FSR_NLINESECT 8 /* External abort on non-linefetch for section translation */ -#define FSR_DOMSECT 9 /* Domain fault on section translation (i.e. accessing invalid domain) */ -#define FSR_NLINEPAGE 10 /* External abort on non-linefetch for page translation */ -#define FSR_DOMPAGE 11 /* Domain fault on page translation (i.e. accessing invalid domain) */ -#define FSR_EXTERN1 12 /* External abort on first level translation */ -#define FSR_PERMSECT 13 /* Permission fault on section (i.e. no permission to access virtual address) */ -#define FSR_EXTERN2 14 /* External abort on second level translation */ -#define FSR_PERMPAGE 15 /* Permission fault on page (i.e. no permission to access virtual address) */ - -#define FSR_DOM_SHIFT 4 /* Bits 4-7: Domain */ -#define FSR_DOM_MASK (15 << FSR_DOM_SHIFT) - -/* Hardware page table definitions. - * - * Level 1 Descriptor (PMD) - * - * Common definitions. - */ - -#define PMD_TYPE_MASK 0x00000003 /* Bits 1:0: Type of descriptor */ -#define PMD_TYPE_FAULT 0x00000000 -#define PMD_TYPE_COARSE 0x00000001 -#define PMD_TYPE_SECT 0x00000002 -#define PMD_TYPE_FINE 0x00000003 - /* Bits 3:2: Depends on descriptor */ -#define PMD_BIT4 0x00000010 /* Bit 4: Must be one */ -#define PMD_DOMAIN_MASK 0x000001e0 /* Bits 8:5: Domain control bits */ -#define PMD_DOMAIN(x) ((x) << 5) -#define PMD_PROTECTION 0x00000200 /* Bit 9: v5 only */ - /* Bits 31:10: Depend on descriptor */ - -/* Level 1 Section Descriptor. Section descriptors allow fast, single - * level mapping between 1Mb address regions. - */ - - /* Bits 1:0: Type of mapping */ -#define PMD_SECT_BUFFERABLE 0x00000004 /* Bit 2: 1=bufferable */ -#define PMD_SECT_CACHEABLE 0x00000008 /* Bit 3: 1=cacheable */ - /* Bit 4: Common, must be one */ - /* Bits 8:5: Common domain control */ - /* Bit 9: Common protection */ -#define PMD_SECT_AP_MASK 0x00000c00 /* Bits 11:10: Access permission */ -#define PMD_SECT_AP_WRITE 0x00000400 -#define PMD_SECT_AP_READ 0x00000800 - /* Bits 19:20: Should be zero */ -#define PMD_SECT_TEX_MASK 0xfff00000 /* Bits 31:20: v5, Physical page */ -#define PMD_SECT_APX 0x00008000 /* Bit 15: v6 only */ -#define PMD_SECT_S 0x00010000 /* Bit 16: v6 only */ -#define PMD_SECT_nG 0x00020000 /* Bit 17: v6 only */ - -#define PMD_SECT_UNCACHED (0) -#define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE) -#define PMD_SECT_WT (PMD_SECT_CACHEABLE) -#define PMD_SECT_WB (PMD_SECT_CACHEABLE|PMD_SECT_BUFFERABLE) -#define PMD_SECT_MINICACHE (PMD_SECT_TEX(1)|PMD_SECT_CACHEABLE) -#define PMD_SECT_WBWA (PMD_SECT_TEX(1)|PMD_SECT_CACHEABLE|PMD_SECT_BUFFERABLE) - -/* Level 1 Coarse Table Descriptor. Coarse Table Descriptors support - * two level mapping between 16Kb memory regions. - */ - - /* Bits 1:0: Type of mapping */ - - /* Bits 3:2: Should be zero */ - - /* Bit 4: Common, must be one */ - - /* Bits 8:5: Common domain control */ - - /* Bits 9: Should be zero */ - -#define PMD_COARSE_TEX_MASK 0xfffffc00 /* Bits 31:10: v5, Physical page */ - -/* Level 1 Fine Table Descriptor. Coarse Table Descriptors support - * two level mapping between 4Kb memory regions. - */ - - /* Bits 1:0: Type of mapping */ - - /* Bits 3:2: Should be zero */ - - /* Bit 4: Common, must be one */ - - /* Bits 8:5: Common domain control */ - - /* Bits 11:9: Should be zero */ - -#define PMD_FINE_TEX_MASK 0xfffff000 /* Bits 31:12: v5, Physical page */ - -/* Level 2 Table Descriptor (PTE). - * A section descriptor provides the base address of a 1MB block of memory. - * The page table descriptors provide the base address of a page table that - * contains second-level descriptors. - * There are two sizes of page table: - * - Coarse page tables have 256 entries, splitting the 1MB that the table - * describes into 4KB blocks - * - Fine/tiny page tables have 1024 entries, splitting the 1MB that the - * table describes into 1KB blocks. - * - * The following definitions apply to all L2 tables: - */ - -#define PTE_TYPE_MASK (3 << 0) /* Bits: 1:0: Type of mapping */ -#define PTE_TYPE_FAULT (0 << 0) /* None */ -#define PTE_TYPE_LARGE (1 << 0) /* 64Kb of memory */ -#define PTE_TYPE_SMALL (2 << 0) /* 4Kb of memory */ -#define PTE_TYPE_TINY (3 << 0) /* 1Kb of memory (v5)*/ -#define PTE_BUFFERABLE (1 << 2) /* Bit 2: 1=bufferable */ -#define PTE_CACHEABLE (1 << 3) /* Bit 3: 1=cacheable */ - /* Bits 31:4: Depend on type */ - -/* Large page -- 64Kb */ - - /* Bits: 1:0: Type of mapping */ - - /* Bits: 3:2: Bufferable/cacheable */ - -#define PTE_LARGE_AP_MASK (0xff << 4) /* Bits 11:4 Access permissions */ -#define PTE_LARGE_AP_UNO_SRO (0x00 << 4) -#define PTE_LARGE_AP_UNO_SRW (0x55 << 4) -#define PTE_LARGE_AP_URO_SRW (0xaa << 4) -#define PTE_LARGE_AP_URW_SRW (0xff << 4) - /* Bits 15:12: Should be zero */ -#define PTE_LARGE_TEX_MASK 0xffff0000 /* Bits 31:16: v5, Physical page */ - -/* Small page -- 4Kb */ - - /* Bits: 1:0: Type of mapping */ - - /* Bits: 3:2: Bufferable/cacheable */ - -#define PTE_SMALL_AP_MASK (0xff << 4) /* Bits: 11:4: Access permissions */ -#define PTE_SMALL_AP_UNO_SRO (0x00 << 4) -#define PTE_SMALL_AP_UNO_SRW (0x55 << 4) -#define PTE_SMALL_AP_URO_SRW (0xaa << 4) -#define PTE_SMALL_AP_URW_SRW (0xff << 4) -#define PTE_SMALL_TEX_MASK 0xfffff000 /* Bits: 31:12: Physical page */ - -#define PTE_SMALL_NPAGES 256 /* 256 Coarse PTE's per section */ - -/* Fine/Tiny page -- 1Kb */ - - /* Bits: 1:0: Type of mapping */ - - /* Bits: 3:2: Bufferable/cacheable */ - -#define PTE_EXT_AP_MASK (3 << 4) /* Bits: 5:4: Access persions */ -#define PTE_EXT_AP_UNO_SRO (0 << 4) -#define PTE_EXT_AP_UNO_SRW (1 << 4) -#define PTE_EXT_AP_URO_SRW (2 << 4) -#define PTE_EXT_AP_URW_SRW (3 << 4) - /* Bits: 9:6: Should be zero */ -#define PTE_TINY_TEX_MASK 0xfffffc00 /* Bits: 31:10: Physical page */ - -#define PTE_TINY_NPAGES 1024 /* 1024 Tiny PTE's per section */ - -/* Default MMU flags for RAM memory, IO, vector region */ - -#define MMU_ROMFLAGS \ - (PMD_TYPE_SECT|PMD_BIT4|PMD_SECT_AP_READ) - -#define MMU_MEMFLAGS \ - (PMD_TYPE_SECT|PMD_SECT_WB|PMD_BIT4|PMD_SECT_AP_WRITE|PMD_SECT_AP_READ) - -#define MMU_IOFLAGS \ - (PMD_TYPE_SECT|PMD_BIT4|PMD_SECT_AP_WRITE|PMD_SECT_AP_READ) - -#define MMU_L1_VECTORFLAGS (PMD_TYPE_COARSE|PMD_BIT4) -#define MMU_L2_VECTORFLAGS (PTE_TYPE_SMALL|PTE_SMALL_AP_UNO_SRW) - -/* Mapped section size */ - -#define SECTION_SIZE (1 << 20) /* 1Mb */ - -/* CP15 register c2 contains a pointer to the base address of a paged table - * in physical memory. - * Only bits 14-31 of the page table address is retained there; - * The full 30-bit address is formed by ORing in bits 2-13 or the virtual - * address (MVA). As a consequence, the page table must be aligned to a 16Kb - * address in physical memory and could require up to 16Kb of memory. - */ - -#define PGTABLE_SIZE 0x00004000 - -/**************************************************************************** - * Inline Functions - ****************************************************************************/ - -#ifndef __ASSEMBLY__ - -/* Get the current value of the CP15 C1 control register */ - -static inline unsigned int get_cp15c1(void) -{ - unsigned int retval; - __asm__ __volatile__ - ( - "\tmrc p15, 0, %0, c1, c0" - : "=r" (retval) - : - : "memory"); - return retval; -} - -/* Get the current value of the CP15 C2 page table pointer register */ - -static inline unsigned int get_cp15c2(void) -{ - unsigned int retval; - __asm__ __volatile__ - ( - "\tmrc p15, 0, %0, c2, c0" - : "=r" (retval) - : - : "memory"); - return retval; -} - -/* Get the current value of the CP15 C3 domain access register */ - -static inline unsigned int get_cp15c3(void) -{ - unsigned int retval; - __asm__ __volatile__ - ( - "\tmrc p15, 0, %0, c3, c0" - : "=r" (retval) - : - : "memory"); - return retval; -} - -/* ARMv4/ARMv5 operation: Invalidate TLB - * ARM926EJ-S operation: Invalidate set-associative - * Data: Should be zero - */ - -static inline void tlb_invalidate(void) -{ - unsigned int sbz = 0; - __asm__ __volatile__ - ( - "\tmcr p15, 0, %0, c8, c7, 0" - : - : "r" (sbz) - : "memory"); -} - -/* ARMv4/ARMv5 operation: Invalidate TLB single entry (MVA) - * ARM926EJ-S operation: Invalidate single entry - * Data: MVA - */ - -static inline void tlb_invalidate_single(unsigned int mva) -{ - mva &= 0xfffffc00; - __asm__ __volatile__ - ( - "mcr p15, 0, %0, c8, c7, 1" - : - : "r" (mva) - : "memory"); -} - -/* ARMv4/ARMv5 operation: Invalidate instruction TLB - * ARM926EJ-S operation: Invalidate set-associative TLB - * Data: Should be zero - */ - -static inline void tlb_instr_invalidate(void) -{ - unsigned int sbz = 0; - __asm__ __volatile__ - ( - "\tmcr p15, 0, %0, c8, c5, 0" - : - : "r" (sbz) - : "memory"); -} - -/* ARMv4/ARMv5 operation: Invalidate instruction TLB single entry (MVA) - * ARM926EJ-S operation: Invalidate single entry - * Data: MVA - */ - -static inline void tlb_inst_invalidate_single(unsigned int mva) -{ - mva &= 0xfffffc00; - __asm__ __volatile__ - ( - "mcr p15, 0, %0, c8, c5, 1" - : - : "r" (mva) - : "memory"); -} - -/* ARMv4/ARMv5 operation: Invalidate data TLB - * ARM926EJ-S operation: Invalidate set-associative TLB - * Data: Should be zero - */ - -static inline void tlb_data_invalidate(void) -{ - unsigned int sbz = 0; - __asm__ __volatile__ - ( - "\tmcr p15, 0, %0, c8, c6, 0" - : - : "r" (sbz) - : "memory"); -} - -/* ARMv4/ARMv5 operation: Invalidate data TLB single entry (MVA) - * ARM926EJ-S operation: Invalidate single entry - * Data: MVA - */ - -static inline void tlb_data_invalidate_single(unsigned int mva) -{ - mva &= 0xfffffc00; - __asm__ __volatile__ - ( - "mcr p15, 0, %0, c8, c6, 1" - : - : "r" (mva) - : "memory"); -} - -#endif /* __ASSEMBLY__ */ - /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/arch/arm/src/arm/arm_dataabort.c b/arch/arm/src/arm/arm_dataabort.c deleted file mode 100644 index 48e6f5fd159..00000000000 --- a/arch/arm/src/arm/arm_dataabort.c +++ /dev/null @@ -1,166 +0,0 @@ -/**************************************************************************** - * arch/arm/src/arm/arm_dataabort.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> - -#include "sched/sched.h" -#include "arm_internal.h" - -#ifdef CONFIG_LEGACY_PAGING -# include <nuttx/page.h> -# include "arm.h" -#endif - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: arm_dataabort - * - * Input Parameters: - * regs - The standard, ARM register save array. - * - * If CONFIG_LEGACY_PAGING is selected in the NuttX configuration file, then - * these additional input values are expected: - * - * far - Fault address register. On a data abort, the ARM MMU places the - * miss virtual address (MVA) into the FAR register. This is the address - * of the data which, when accessed, caused the fault. - * fsr - Fault status register. On a data a abort, the ARM MMU places an - * encoded four-bit value, the fault status, along with the four-bit - * encoded domain number, in the data FSR - * - * Description: - * This is the data abort exception handler. The ARM data abort exception - * occurs when a memory fault is detected during a data transfer. - * - ****************************************************************************/ - -#ifdef CONFIG_LEGACY_PAGING -void arm_dataabort(uint32_t *regs, uint32_t far, uint32_t fsr) -{ - 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 - /* In the NuttX on-demand paging implementation, only the read-only, .text - * section is paged. However, the ARM compiler generated PC-relative data - * fetches from within the .text sections. Also, it is customary to locate - * read-only data (.rodata) within the same section as .text so that it - * does not require copying to RAM. Misses in either of these case should - * cause a data abort. - * - * We are only interested in data aborts due to page translations faults. - * Sections should already be in place and permissions should already be - * be set correctly (to read-only) so any other data abort reason is a - * fatal error. - */ - - pginfo("FSR: %08" PRIx32 " FAR: %08" PRIx32 "\n", fsr, far); - if ((fsr & FSR_MASK) != FSR_PAGE) - { - goto segfault; - } - - /* Check the (virtual) address of data that caused the data abort. When - * the exception occurred, this address was provided in the FAR register. - * (It has not yet been saved in the register context save area). - */ - - pginfo("VBASE: %08x VEND: %08x\n", PG_PAGED_VBASE, PG_PAGED_VEND); - if (far < PG_PAGED_VBASE || far >= PG_PAGED_VEND) - { - goto segfault; - } - - /* Save the offending data address as the fault address in the TCB of - * the currently task. This fault address is also used by the prefetch - * abort handling; this 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 irq flag. */ - - up_set_interrupt_context(savestate); - tcb->xcp.regs = saveregs; - return; - -segfault: -#endif - _alert("Data abort. " - "PC: %08" PRIx32 " FAR: %08" PRIx32 " FSR: %08" PRIx32 "\n", - regs[REG_PC], far, fsr); - PANIC_WITH_REGS("panic", regs); -} - -#else /* CONFIG_LEGACY_PAGING */ - -void arm_dataabort(uint32_t *regs) -{ - struct tcb_s *tcb = this_task(); - - tcb->xcp.regs = regs; - up_set_interrupt_context(true); - - /* Crash -- possibly showing diagnost debug information. */ - - _alert("Data abort. PC: %08" PRIx32 "\n", regs[REG_PC]); - PANIC_WITH_REGS("panic", regs); -} - -#endif /* CONFIG_LEGACY_PAGING */ diff --git a/arch/arm/src/arm/arm_head.S b/arch/arm/src/arm/arm_head.S index 782f3f5bbdd..a9e2cb9408d 100644 --- a/arch/arm/src/arm/arm_head.S +++ b/arch/arm/src/arm/arm_head.S @@ -29,6 +29,7 @@ #include "arm.h" #include "chip.h" #include "arm_internal.h" +#include "mmu.h" #ifdef CONFIG_LEGACY_PAGING # include <nuttx/page.h> diff --git a/arch/arm/src/arm/arm_vectors.S b/arch/arm/src/arm/arm_vectors.S index add095fe3d0..40ff9b28a6c 100644 --- a/arch/arm/src/arm/arm_vectors.S +++ b/arch/arm/src/arm/arm_vectors.S @@ -397,10 +397,8 @@ arm_vectordata: mov fp, #0 /* Init frame pointer */ mov r0, sp /* Get r0=xcp */ -#ifdef CONFIG_LEGACY_PAGING mrc p15, 0, r1, c6, c0, 0 /* Get R1=FAR */ mrc p15, 0, r2, c5, c0, 0 /* Get r2=FSR */ -#endif bl arm_dataabort /* Call the handler */ #ifdef CONFIG_ARCH_FPU diff --git a/arch/arm/src/arm/pg_macros.h b/arch/arm/src/arm/pg_macros.h index cd195de5eb6..120de86b2fa 100644 --- a/arch/arm/src/arm/pg_macros.h +++ b/arch/arm/src/arm/pg_macros.h @@ -35,7 +35,7 @@ #include <nuttx/config.h> #include <nuttx/page.h> -#include "arm.h" +#include "mmu.h" /**************************************************************************** * Pre-processor Definitions @@ -99,16 +99,16 @@ /* MMU Flags for each memory region */ -# define MMU_L1_TEXTFLAGS (PMD_TYPE_FINE|PMD_BIT4) -# define MMU_L2_TEXTFLAGS (PTE_TYPE_TINY|PTE_EXT_AP_UNO_SRO|PTE_CACHEABLE) -# define MMU_L1_DATAFLAGS (PMD_TYPE_FINE|PMD_BIT4) -# define MMU_L2_DATAFLAGS (PTE_TYPE_TINY|PTE_EXT_AP_UNO_SRW|PTE_CACHEABLE|PTE_BUFFERABLE) +# define MMU_L1_TEXTFLAGS (PMD_TYPE_PXN|PMD_BIT4) +# define MMU_L2_TEXTFLAGS (PTE_TYPE_TINY|PTE_EXT_AP_UNO_SRO|PTE_C) +# define MMU_L1_DATAFLAGS (PMD_TYPE_PXN|PMD_BIT4) +# define MMU_L2_DATAFLAGS (PTE_TYPE_TINY|PTE_EXT_AP_UNO_SRW|PTE_C|PTE_B) # define MMU_L2_ALLOCFLAGS (PTE_TYPE_TINY|PTE_EXT_AP_UNO_SRW) -# define MMU_L1_PGTABFLAGS (PMD_TYPE_FINE|PMD_BIT4) +# define MMU_L1_PGTABFLAGS (PMD_TYPE_PXN|PMD_BIT4) # define MMU_L2_PGTABFLAGS (PTE_TYPE_TINY|PTE_EXT_AP_UNO_SRW) # define MMU_L2_VECTRWFLAGS (PTE_TYPE_TINY|PTE_EXT_AP_UNO_SRW) -# define MMU_L2_VECTROFLAGS (PTE_TYPE_TINY|PTE_EXT_AP_UNO_SRO|PTE_CACHEABLE) +# define MMU_L2_VECTROFLAGS (PTE_TYPE_TINY|PTE_EXT_AP_UNO_SRO|PTE_C) #elif CONFIG_PAGING_PAGESIZE == 4096 @@ -123,20 +123,20 @@ /* Mask to get the page table physical address from an L1 entry */ -# define PG_L1_PADDRMASK PMD_COARSE_TEX_MASK +# define PG_L1_PADDRMASK PMD_SECT_PADDR_MASK /* MMU Flags for each memory region. */ # define MMU_L1_TEXTFLAGS (PMD_TYPE_COARSE|PMD_BIT4) -# define MMU_L2_TEXTFLAGS (PTE_TYPE_SMALL|PTE_SMALL_AP_UNO_SRO|PTE_CACHEABLE) +# define MMU_L2_TEXTFLAGS (PTE_TYPE_SMALL|PTE_SMALL_AP_UNO_SRO|PTE_C) # define MMU_L1_DATAFLAGS (PMD_TYPE_COARSE|PMD_BIT4) -# define MMU_L2_DATAFLAGS (PTE_TYPE_SMALL|PTE_SMALL_AP_UNO_SRW|PTE_CACHEABLE|PTE_BUFFERABLE) +# define MMU_L2_DATAFLAGS (PTE_TYPE_SMALL|PTE_SMALL_AP_UNO_SRW|PTE_C|PTE_B) # define MMU_L2_ALLOCFLAGS (PTE_TYPE_SMALL|PTE_SMALL_AP_UNO_SRW) # define MMU_L1_PGTABFLAGS (PMD_TYPE_COARSE|PMD_BIT4) # define MMU_L2_PGTABFLAGS (PTE_TYPE_SMALL|PTE_SMALL_AP_UNO_SRW) # define MMU_L2_VECTRWFLAGS (PTE_TYPE_SMALL|PTE_SMALL_AP_UNO_SRW) -# define MMU_L2_VECTROFLAGS (PTE_TYPE_SMALL|PTE_SMALL_AP_UNO_SRO|PTE_CACHEABLE) +# define MMU_L2_VECTROFLAGS (PTE_TYPE_SMALL|PTE_SMALL_AP_UNO_SRO|PTE_C) #else # error "Need extended definitions for CONFIG_PAGING_PAGESIZE" diff --git a/arch/arm/src/arm_a_r/CMakeLists.txt b/arch/arm/src/arm_a_r/CMakeLists.txt index 4fd5862bb31..664d46bb6f9 100644 --- a/arch/arm/src/arm_a_r/CMakeLists.txt +++ b/arch/arm/src/arm_a_r/CMakeLists.txt @@ -24,6 +24,10 @@ if(CONFIG_ENABLE_ALL_SIGNALS) set(CSRCS arm_schedulesigaction.c arm_sigdeliver.c) endif() -list(APPEND CSRCS arm_tcbinfo.c arm_doirq.c) +if(CONFIG_ARCH_HAVE_DEBUG) + list(APPEND CSRCS arm_hwdebug.c) +endif() + +list(APPEND CSRCS arm_tcbinfo.c arm_doirq.c arm_dataabort.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 32c5687a3f0..b21218a969f 100644 --- a/arch/arm/src/arm_a_r/Make.defs +++ b/arch/arm/src/arm_a_r/Make.defs @@ -22,8 +22,12 @@ # Common ARM_A_R files -CMN_CSRCS += arm_tcbinfo.c arm_doirq.c +CMN_CSRCS += arm_tcbinfo.c arm_doirq.c arm_dataabort.c ifeq ($(CONFIG_ENABLE_ALL_SIGNALS),y) CMN_CSRCS += arm_schedulesigaction.c arm_sigdeliver.c endif + +ifeq ($(CONFIG_ARCH_HAVE_DEBUG),y) + CMN_CSRCS += arm_hwdebug.c +endif diff --git a/arch/arm/src/armv7-a/arm_dataabort.c b/arch/arm/src/arm_a_r/arm_dataabort.c similarity index 96% rename from arch/arm/src/armv7-a/arm_dataabort.c rename to arch/arm/src/arm_a_r/arm_dataabort.c index cd707aa4373..02cdadb8e54 100644 --- a/arch/arm/src/armv7-a/arm_dataabort.c +++ b/arch/arm/src/arm_a_r/arm_dataabort.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-a/arm_dataabort.c + * arch/arm/src/arm_a_r/arm_dataabort.c * * SPDX-License-Identifier: Apache-2.0 * @@ -93,12 +93,12 @@ uint32_t *arm_dataabort(uint32_t *regs, uint32_t dfar, uint32_t dfsr) * fatal error. */ - pginfo("DFSR: %08x DFAR: %08x\n", dfsr, dfar); + pginfo("DFSR: %08" PRIx32 " DFAR: %08" PRIx32 "\n", dfsr, dfar); if (FSR_FAULT(dfsr) == FSR_FAULT_DEBUG) { arm_dbgmonitor(0, (void *)dfar, regs); } - else if((dfsr & FSR_MASK) != FSR_PAGE) + else if((dfsr & FSR_MASK) != FSR_FAULT_TRANSLATION_L2) { goto segfault; } @@ -122,7 +122,7 @@ uint32_t *arm_dataabort(uint32_t *regs, uint32_t dfar, uint32_t dfsr) * prefetch and data aborts. */ - tcb->xcp.dfar = 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/arm_hwdebug.c b/arch/arm/src/arm_a_r/arm_hwdebug.c similarity index 99% rename from arch/arm/src/armv7-a/arm_hwdebug.c rename to arch/arm/src/arm_a_r/arm_hwdebug.c index 1fc43d830db..ec26c3f560d 100644 --- a/arch/arm/src/armv7-a/arm_hwdebug.c +++ b/arch/arm/src/arm_a_r/arm_hwdebug.c @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-a/arm_hwdebug.c + * arch/arm/src/arm_a_r/arm_hwdebug.c * * SPDX-License-Identifier: Apache-2.0 * diff --git a/arch/arm/src/armv7-a/mmu.h b/arch/arm/src/arm_a_r/mmu.h similarity index 94% rename from arch/arm/src/armv7-a/mmu.h rename to arch/arm/src/arm_a_r/mmu.h index 82819f306ef..44418b4fdf9 100644 --- a/arch/arm/src/armv7-a/mmu.h +++ b/arch/arm/src/arm_a_r/mmu.h @@ -1,5 +1,5 @@ /**************************************************************************** - * arch/arm/src/armv7-a/mmu.h + * arch/arm/src/arm_a_r/mmu.h * * SPDX-License-Identifier: Apache-2.0 * @@ -28,8 +28,8 @@ * All rights reserved. ARM DDI 0406C.b (ID072512) */ -#ifndef __ARCH_ARM_SRC_ARMV7_A_MMU_H -#define __ARCH_ARM_SRC_ARMV7_A_MMU_H +#ifndef __ARCH_ARM_SRC_ARM_A_R_MMU_H +#define __ARCH_ARM_SRC_ARM_A_R_MMU_H /**************************************************************************** * Included Files @@ -164,7 +164,12 @@ #define IFSR_EXT (1 << 12) /* Bit 12: External Abort Qualifier */ /* Bits 13-31: Reserved */ -#define FSR_FAULT(fsr) (((fsr) & 0x0f) | (((fsr) & 0x400) >> 6)) +/* The lowest 4-bits of the FSR register indicates the fault generated by + * the MMU. + */ + +#define FSR_MASK 0x0f /* Bits 0-3: Type of fault */ +#define FSR_FAULT(fsr) (((fsr) & FSR_MASK) | (((fsr) & 0x400) >> 6)) #define FSR_FAULT_ALIGNMENT 0x01 /* Alignment fault (DFSR only) */ #define FSR_FAULT_DEBUG 0x02 /* Debug event */ #define FSR_FAULT_TRANSLATION_L1 0x05 /* Translation fault, first level */ @@ -265,6 +270,7 @@ */ #define PMD_TYPE_SHIFT (0) /* Bits: 1:0: Type of mapping */ +#define PMD_BIT4 0x00000010 /* Bit 4: Must be one */ #define PMD_TYPE_MASK (3 << PMD_TYPE_SHIFT) #define PMD_TYPE_FAULT (0 << PMD_TYPE_SHIFT) /* None */ #define PMD_TYPE_PTE (1 << PMD_TYPE_SHIFT) /* Page table */ @@ -593,11 +599,86 @@ #define PMD_DEVICE (PMD_SECT_B) #define PMD_CACHEABLE (PMD_SECT_B | PMD_SECT_C) +/* Level 1 Fine Table Descriptor. Coarse Table Descriptors support + * two level mapping between 4Kb memory regions. + */ + + /* Bits 1:0: Type of mapping */ + + /* Bits 3:2: Should be zero */ + + /* Bit 4: Common, must be one */ + + /* Bits 8:5: Common domain control */ + + /* Bits 11:9: Should be zero */ + +#define PMD_FINE_TEX_MASK 0xfffff000 /* Bits 31:12: v5, Physical page */ + #define PTE_STRONGLY_ORDER (0) #define PTE_DEVICE (PTE_B) #define PTE_WRITE_THROUGH (PTE_C) #define PTE_WRITE_BACK (PTE_B | PTE_C) +/* Level 2 Table Descriptor (PTE). + * A section descriptor provides the base address of a 1MB block of memory. + * The page table descriptors provide the base address of a page table that + * contains second-level descriptors. + * There are two sizes of page table: + * - Coarse page tables have 256 entries, splitting the 1MB that the table + * describes into 4KB blocks + * - Fine/tiny page tables have 1024 entries, splitting the 1MB that the + * table describes into 1KB blocks. + * + * The following definitions apply to all L2 tables: + */ + +#define PTE_TYPE_TINY (3 << 0) /* 1Kb of memory (v5)*/ + +/* Large page -- 64Kb */ + + /* Bits: 1:0: Type of mapping */ + + /* Bits: 3:2: Bufferable/cacheable */ + +#define PTE_LARGE_AP_MASK (0xff << 4) /* Bits 11:4 Access permissions */ +#define PTE_LARGE_AP_UNO_SRO (0x00 << 4) +#define PTE_LARGE_AP_UNO_SRW (0x55 << 4) +#define PTE_LARGE_AP_URO_SRW (0xaa << 4) +#define PTE_LARGE_AP_URW_SRW (0xff << 4) + /* Bits 15:12: Should be zero */ + +/* Small page -- 4Kb */ + + /* Bits: 1:0: Type of mapping */ + + /* Bits: 3:2: Bufferable/cacheable */ + +#define PTE_SMALL_AP_MASK (0xff << 4) /* Bits: 11:4: Access permissions */ +#define PTE_SMALL_AP_UNO_SRO (0x00 << 4) +#define PTE_SMALL_AP_UNO_SRW (0x55 << 4) +#define PTE_SMALL_AP_URO_SRW (0xaa << 4) +#define PTE_SMALL_AP_URW_SRW (0xff << 4) +#define PTE_SMALL_TEX_MASK 0xfffff000 /* Bits: 31:12: Physical page */ + +#define PTE_SMALL_NPAGES 256 /* 256 Coarse PTE's per section */ + +/* Fine/Tiny page -- 1Kb */ + + /* Bits: 1:0: Type of mapping */ + + /* Bits: 3:2: Bufferable/cacheable */ + +#define PTE_EXT_AP_MASK (3 << 4) /* Bits: 5:4: Access persions */ +#define PTE_EXT_AP_UNO_SRO (0 << 4) +#define PTE_EXT_AP_UNO_SRW (1 << 4) +#define PTE_EXT_AP_URO_SRW (2 << 4) +#define PTE_EXT_AP_URW_SRW (3 << 4) + /* Bits: 9:6: Should be zero */ +#define PTE_TINY_TEX_MASK 0xfffffc00 /* Bits: 31:10: Physical page */ + +#define PTE_TINY_NPAGES 1024 /* 1024 Tiny PTE's per section */ + /* Default MMU flags for RAM memory, IO, vector sections (level 1) * * REVISIT: Here we expect all threads to be running at PL1 @@ -1375,7 +1456,7 @@ static inline void cp15_wrttb(uint32_t ttb) * ****************************************************************************/ -#ifndef CONFIG_ARCH_ROMPGTABLE +#if !defined(CONFIG_ARCH_ROMPGTABLE) && defined(PGTABLE_BASE_VADDR) static inline uintptr_t *mmu_l1_getpgtable(void) { #ifdef CONFIG_ARCH_ADDRENV @@ -1427,7 +1508,7 @@ static inline void mmu_l1_setpgtable(uintptr_t *ttb) * ****************************************************************************/ -#ifndef CONFIG_ARCH_ROMPGTABLE +#if !defined(CONFIG_ARCH_ROMPGTABLE) && defined(PGTABLE_BASE_VADDR) static inline uintptr_t mmu_l1table_getentry(uintptr_t *l1table, uintptr_t vaddr) { @@ -1692,4 +1773,4 @@ void mmu_invalidate_region(uintptr_t vstart, size_t size); #endif #endif /* __ASSEMBLY__ */ -#endif /* __ARCH_ARM_SRC_ARMV7_A_MMU_H */ +#endif /* __ARCH_ARM_SRC_ARM_A_R_MMU_H */ diff --git a/arch/arm/src/armv7-a/CMakeLists.txt b/arch/arm/src/armv7-a/CMakeLists.txt index 35f34034f00..e2231e1f45b 100644 --- a/arch/arm/src/armv7-a/CMakeLists.txt +++ b/arch/arm/src/armv7-a/CMakeLists.txt @@ -36,7 +36,6 @@ list( SRCS arm_cache.c arm_cpuinfo.c - arm_dataabort.c arm_gicv2.c arm_gicv2_dump.c arm_initialstate.c @@ -52,10 +51,6 @@ if(CONFIG_ARMV7A_GICv2M) list(APPEND SRCS arm_gicv2m.c) endif() -if(CONFIG_ARCH_HAVE_DEBUG) - list(APPEND SRCS arm_hwdebug.c) -endif() - if(CONFIG_ARMV7A_HAVE_PTM) list(APPEND SRCS arm_timer.c) endif() diff --git a/arch/arm/src/armv7-a/Make.defs b/arch/arm/src/armv7-a/Make.defs index 61cc1a6ceb9..31a6a770bbf 100644 --- a/arch/arm/src/armv7-a/Make.defs +++ b/arch/arm/src/armv7-a/Make.defs @@ -36,7 +36,7 @@ CMN_ASRCS += arm_cpuhead.S arm_vectors.S arm_saveusercontext.S # Common C source files -CMN_CSRCS += arm_cache.c arm_cpuinfo.c arm_dataabort.c +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_syscall.c arm_undefinedinsn.c @@ -46,10 +46,6 @@ ifeq ($(CONFIG_ARMV7A_GICv2M),y) CMN_CSRCS += arm_gicv2m.c endif -ifeq ($(CONFIG_ARCH_HAVE_DEBUG),y) - CMN_CSRCS += arm_hwdebug.c -endif - ifeq ($(CONFIG_ARMV7A_HAVE_PTM),y) CMN_CSRCS += arm_timer.c endif diff --git a/arch/arm/src/armv7-r/CMakeLists.txt b/arch/arm/src/armv7-r/CMakeLists.txt index c2b0f981ad9..53c1779e398 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_dataabort.c arm_initialstate.c arm_prefetchabort.c arm_syscall.c diff --git a/arch/arm/src/armv7-r/Make.defs b/arch/arm/src/armv7-r/Make.defs index 8e8120de7d4..5a000adeff7 100644 --- a/arch/arm/src/armv7-r/Make.defs +++ b/arch/arm/src/armv7-r/Make.defs @@ -32,7 +32,7 @@ HEAD_ASRC += arm_vectortab.S # Common assembly language files -CMN_CSRCS += arm_cache.c arm_cpuinfo.c arm_dataabort.c +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_syscall.c arm_undefinedinsn.c diff --git a/arch/arm/src/armv7-r/arm_dataabort.c b/arch/arm/src/armv7-r/arm_dataabort.c deleted file mode 100644 index 0a795aef5df..00000000000 --- a/arch/arm/src/armv7-r/arm_dataabort.c +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv7-r/arm_dataabort.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_dataabort - * - * Input Parameters: - * regs - The standard, ARM register save array. - * dfar - Fault address register. - * dfsr - Fault status register. - * - * Description: - * This is the data abort exception handler. The ARM data abort exception - * occurs when a memory fault is detected during a data transfer. - * - ****************************************************************************/ - -uint32_t *arm_dataabort(uint32_t *regs, uint32_t dfar, uint32_t dfsr) -{ - struct tcb_s *tcb = this_task(); - - tcb->xcp.regs = regs; - up_set_interrupt_context(true); - - /* Crash -- possibly showing diagnostic debug information. */ - - _alert("Data abort. PC: %08" PRIx32 " DFAR: %08" PRIx32 " DFSR: %08" - PRIx32 "\n", regs[REG_PC], dfar, dfsr); - 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 05f9991a117..f30a09268e5 100644 --- a/arch/arm/src/armv8-r/CMakeLists.txt +++ b/arch/arm/src/armv8-r/CMakeLists.txt @@ -32,7 +32,6 @@ list( arm_timer.c arm_cache.c arm_cpuinfo.c - arm_dataabort.c arm_gicv3.c arm_initialstate.c arm_prefetchabort.c diff --git a/arch/arm/src/armv8-r/Make.defs b/arch/arm/src/armv8-r/Make.defs index c90cab41cf5..642f23602e0 100644 --- a/arch/arm/src/armv8-r/Make.defs +++ b/arch/arm/src/armv8-r/Make.defs @@ -36,7 +36,7 @@ CMN_ASRCS += arm_head.S arm_vectors.S arm_saveusercontext.S # Common C source files -CMN_CSRCS += arm_timer.c arm_cache.c arm_cpuinfo.c arm_dataabort.c +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_syscall.c arm_undefinedinsn.c diff --git a/arch/arm/src/armv8-r/arm_dataabort.c b/arch/arm/src/armv8-r/arm_dataabort.c deleted file mode 100644 index cb96bc71a5d..00000000000 --- a/arch/arm/src/armv8-r/arm_dataabort.c +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** - * arch/arm/src/armv8-r/arm_dataabort.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_dataabort - * - * Input Parameters: - * regs - The standard, ARM register save array. - * dfar - Fault address register. - * dfsr - Fault status register. - * - * Description: - * This is the data abort exception handler. The ARM data abort exception - * occurs when a memory fault is detected during a data transfer. - * - ****************************************************************************/ - -uint32_t *arm_dataabort(uint32_t *regs, uint32_t dfar, uint32_t dfsr) -{ - struct tcb_s *tcb = this_task(); - - tcb->xcp.regs = regs; - up_set_interrupt_context(true); - - /* Crash -- possibly showing diagnostic debug information. */ - - _alert("Data abort. PC: %08" PRIx32 " DFAR: %08" PRIx32 " DFSR: %08" - PRIx32 "\n", regs[REG_PC], dfar, dfsr); - 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 cbe3c9f1157..5466a605532 100644 --- a/arch/arm/src/common/arm_internal.h +++ b/arch/arm/src/common/arm_internal.h @@ -376,12 +376,12 @@ uint32_t *arm_undefinedinsn(uint32_t *regs); #ifdef CONFIG_LEGACY_PAGING void arm_pginitialize(void); uint32_t *arm_va2pte(uintptr_t vaddr); -void arm_dataabort(uint32_t *regs, uint32_t far, uint32_t fsr); #else /* CONFIG_LEGACY_PAGING */ # define arm_pginitialize() -void arm_dataabort(uint32_t *regs); #endif /* CONFIG_LEGACY_PAGING */ +uint32_t * arm_dataabort(uint32_t *regs, uint32_t dfar, uint32_t dfsr); + /* Exception handlers */ void arm_prefetchabort(uint32_t *regs); @@ -538,6 +538,9 @@ void arm_stack_check_init(void) noinstrument_function; #ifdef CONFIG_ARCH_HAVE_DEBUG int arm_enable_dbgmonitor(void); int arm_dbgmonitor(int irq, void *context, void *arg); +#else +# define arm_enable_dbgmonitor() +# define arm_dbgmonitor(i, c, a) #endif #ifdef __cplusplus diff --git a/arch/arm/src/dm320/dm320_boot.c b/arch/arm/src/dm320/dm320_boot.c index fd4c1e65df5..48d857d5c73 100644 --- a/arch/arm/src/dm320/dm320_boot.c +++ b/arch/arm/src/dm320/dm320_boot.c @@ -30,6 +30,7 @@ #include "chip.h" #include "arm.h" #include "arm_internal.h" +#include "mmu.h" #include <nuttx/board.h> @@ -37,14 +38,6 @@ * Private Types ****************************************************************************/ -struct section_mapping_s -{ - uint32_t physbase; /* Physical address of the region to be mapped */ - uint32_t virtbase; /* Virtual address of the region to be mapped */ - uint32_t mmuflags; /* MMU settings for the region (e.g., cache-able) */ - uint32_t nsections; /* Number of mappings in the region */ -}; - /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/arch/arm/src/imx1/imx_boot.c b/arch/arm/src/imx1/imx_boot.c index 4e0e7620eeb..d28f036c676 100644 --- a/arch/arm/src/imx1/imx_boot.c +++ b/arch/arm/src/imx1/imx_boot.c @@ -40,14 +40,6 @@ * Private Types ****************************************************************************/ -struct section_mapping_s -{ - uint32_t physbase; /* Physical address of the region to be mapped */ - uint32_t virtbase; /* Virtual address of the region to be mapped */ - uint32_t mmuflags; /* MMU settings for the region (e.g., cache-able) */ - uint32_t nsections; /* Number of mappings in the region */ -}; - /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/arch/arm/src/lpc31xx/lpc31_boot.c b/arch/arm/src/lpc31xx/lpc31_boot.c index a99292831bc..d9345a0191e 100644 --- a/arch/arm/src/lpc31xx/lpc31_boot.c +++ b/arch/arm/src/lpc31xx/lpc31_boot.c @@ -45,14 +45,6 @@ * Private Types ****************************************************************************/ -struct section_mapping_s -{ - uint32_t physbase; /* Physical address of the region to be mapped */ - uint32_t virtbase; /* Virtual address of the region to be mapped */ - uint32_t mmuflags; /* MMU settings for the region (e.g., cache-able) */ - uint32_t nsections; /* Number of mappings in the region */ -}; - /**************************************************************************** * Public Data ****************************************************************************/ @@ -216,7 +208,7 @@ static void up_vectorpermissions(uint32_t mmuflags) /* Invalid the TLB for this address */ - tlb_invalidate_single(PG_L2_VECT_VADDR); + cp15_invalidate_tlb_bymva(PG_L2_VECT_VADDR); } #endif
