Skip to content

Commit 70c403c

Browse files
ibirnbaumcarlescufi
authored andcommitted
arch: arm: core: aarch32: introduce basic ARMv7 MMU support
An initial implementation for memory management using the ARMv7 MMU. A single L1 translation table for the whole 4 GB address space is al- ways present, a configurable number of L2 page tables are linked to the L1 table based on the static memory area configuration at boot time, or whenever arch_mem_map/arch_mem_unmap are called at run-time. Currently, a CPU with the Multiprocessor Extensions and execution at PL1 are always assumed. Userspace-related features or thread stack guard pages are not yet supported. Neither are LPAE, PXN or TEX re- mapping. All mappings are currently assigned to the same domain. Re- garding the permissions model, access permissions are specified using the AP[2:1] model rather than the older AP[2:0] model, which, accor- ding to ARM's documentation, is deprecated and should no longer be used. The newer model adds some complexity when it comes to mapping pages as unaccessible (the AP[2:1] model doesn't support explicit specification of "no R, no W" permissions, it's always at least "RO"), this is accomplished by invalidating the ID bits of the respective page's PTE. Includes sources, Kconfig integration, adjusted CMakeLists and the modified linker command file (proper section alignment!). Signed-off-by: Immo Birnbaum <[email protected]>
1 parent eac90ee commit 70c403c

File tree

10 files changed

+1475
-2
lines changed

10 files changed

+1475
-2
lines changed

arch/arm/core/aarch32/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ add_subdirectory_ifdef(CONFIG_ARM_SECURE_FIRMWARE cortex_m/tz)
2727
add_subdirectory_ifdef(CONFIG_ARM_NONSECURE_FIRMWARE cortex_m/tz)
2828

2929
add_subdirectory_ifdef(CONFIG_ARM_MPU mpu)
30+
add_subdirectory_ifdef(CONFIG_ARM_AARCH32_MMU mmu)
3031

3132
add_subdirectory_ifdef(CONFIG_CPU_CORTEX_R cortex_a_r)
3233

arch/arm/core/aarch32/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,4 @@ rsource "cortex_m/Kconfig"
306306
rsource "cortex_a_r/Kconfig"
307307

308308
rsource "mpu/Kconfig"
309+
rsource "mmu/Kconfig"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
zephyr_library()
4+
5+
zephyr_library_sources(arm_mmu.c)

arch/arm/core/aarch32/mmu/Kconfig

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# ARMv7 Memory Management Unit (MMU) configuration options
3+
#
4+
# Copyright (c) 2021 Weidmueller Interface GmbH & Co. KG
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
if CPU_HAS_MMU
9+
10+
config ARM_AARCH32_MMU
11+
bool "ARMv7 Cortex-A MMU Support"
12+
default y if CPU_AARCH32_CORTEX_A
13+
select MMU
14+
select SRAM_REGION_PERMISSIONS
15+
select THREAD_STACK_INFO
16+
select ARCH_HAS_EXECUTABLE_PAGE_BIT
17+
help
18+
The current CPU has an ARMv7 Memory Management Unit.
19+
20+
config ARM_MMU_NUM_L2_TABLES
21+
depends on ARM_AARCH32_MMU
22+
int "Number of L2 translation tables available to the MMU"
23+
default 64
24+
help
25+
Number of level 2 translation tables. Each level 2 table
26+
covers 1 MB of address space.
27+
28+
config ARM_MMU_REGION_MIN_ALIGN_AND_SIZE
29+
int
30+
default 4096
31+
help
32+
Minimum size (and alignment) of an ARM MMU page.
33+
This value should not be modified.
34+
35+
endif # CPU_HAS_MMU

0 commit comments

Comments
 (0)