7#ifndef ZEPHYR_INCLUDE_ARCH_ARM64_ARM_MMU_H_
8#define ZEPHYR_INCLUDE_ARCH_ARM64_ARM_MMU_H_
20#define MT_TYPE_MASK 0x7U
21#define MT_TYPE(attr) (attr & MT_TYPE_MASK)
22#define MT_DEVICE_nGnRnE 0U
23#define MT_DEVICE_nGnRE 1U
24#define MT_DEVICE_GRE 2U
25#define MT_NORMAL_NC 3U
27#define MT_NORMAL_WT 5U
29#define MEMORY_ATTRIBUTES ((0x00 << (MT_DEVICE_nGnRnE * 8)) | \
30 (0x04 << (MT_DEVICE_nGnRE * 8)) | \
31 (0x0c << (MT_DEVICE_GRE * 8)) | \
32 (0x44 << (MT_NORMAL_NC * 8)) | \
33 (0xffUL << (MT_NORMAL * 8)) | \
34 (0xbbUL << (MT_NORMAL_WT * 8)))
51#define MT_PERM_SHIFT 3U
52#define MT_SEC_SHIFT 4U
53#define MT_P_EXECUTE_SHIFT 5U
54#define MT_U_EXECUTE_SHIFT 6U
55#define MT_RW_AP_SHIFT 7U
56#define MT_NO_OVERWRITE_SHIFT 8U
57#define MT_NON_GLOBAL_SHIFT 9U
58#define MT_PAGED_OUT_SHIFT 10U
60#define MT_RO (0U << MT_PERM_SHIFT)
61#define MT_RW (1U << MT_PERM_SHIFT)
63#define MT_RW_AP_ELx (1U << MT_RW_AP_SHIFT)
64#define MT_RW_AP_EL_HIGHER (0U << MT_RW_AP_SHIFT)
66#define MT_SECURE (0U << MT_SEC_SHIFT)
67#define MT_NS (1U << MT_SEC_SHIFT)
69#define MT_P_EXECUTE (0U << MT_P_EXECUTE_SHIFT)
70#define MT_P_EXECUTE_NEVER (1U << MT_P_EXECUTE_SHIFT)
72#define MT_U_EXECUTE (0U << MT_U_EXECUTE_SHIFT)
73#define MT_U_EXECUTE_NEVER (1U << MT_U_EXECUTE_SHIFT)
75#define MT_NO_OVERWRITE (1U << MT_NO_OVERWRITE_SHIFT)
77#define MT_G (0U << MT_NON_GLOBAL_SHIFT)
78#define MT_NG (1U << MT_NON_GLOBAL_SHIFT)
80#define MT_PAGED_OUT (1U << MT_PAGED_OUT_SHIFT)
82#define MT_P_RW_U_RW (MT_RW | MT_RW_AP_ELx | MT_P_EXECUTE_NEVER | MT_U_EXECUTE_NEVER)
83#define MT_P_RW_U_NA (MT_RW | MT_RW_AP_EL_HIGHER | MT_P_EXECUTE_NEVER | MT_U_EXECUTE_NEVER)
84#define MT_P_RO_U_RO (MT_RO | MT_RW_AP_ELx | MT_P_EXECUTE_NEVER | MT_U_EXECUTE_NEVER)
85#define MT_P_RO_U_NA (MT_RO | MT_RW_AP_EL_HIGHER | MT_P_EXECUTE_NEVER | MT_U_EXECUTE_NEVER)
86#define MT_P_RO_U_RX (MT_RO | MT_RW_AP_ELx | MT_P_EXECUTE_NEVER | MT_U_EXECUTE)
87#define MT_P_RX_U_RX (MT_RO | MT_RW_AP_ELx | MT_P_EXECUTE | MT_U_EXECUTE)
88#define MT_P_RX_U_NA (MT_RO | MT_RW_AP_EL_HIGHER | MT_P_EXECUTE | MT_U_EXECUTE_NEVER)
90#ifdef CONFIG_ARMV8_A_NS
91#define MT_DEFAULT_SECURE_STATE MT_NS
93#define MT_DEFAULT_SECURE_STATE MT_SECURE
97#define ARCH_DATA_PAGE_LOADED BIT(0)
98#define ARCH_DATA_PAGE_ACCESSED BIT(1)
99#define ARCH_DATA_PAGE_DIRTY BIT(2)
100#define ARCH_DATA_PAGE_NOT_MAPPED BIT(3)
106#define ARCH_UNPAGED_ANON_ZERO 0x0000fffffffff000
107#define ARCH_UNPAGED_ANON_UNINIT 0x0000ffffffffe000
143#define MMU_REGION_ENTRY(_name, _base_pa, _base_va, _size, _attrs) \
146 .base_pa = _base_pa, \
147 .base_va = _base_va, \
152#define MMU_REGION_FLAT_ENTRY(name, adr, sz, attrs) \
153 MMU_REGION_ENTRY(name, adr, adr, sz, attrs)
171#define MMU_REGION_DT_FLAT_ENTRY(node_id, attrs) \
172 MMU_REGION_FLAT_ENTRY(DT_NODE_FULL_NAME(node_id), \
173 DT_REG_ADDR(node_id), \
174 DT_REG_SIZE(node_id), \
190#define MMU_REGION_DT_COMPAT_FOREACH_FLAT_ENTRY(compat, attr) \
191 DT_FOREACH_STATUS_OKAY_VARGS(compat, \
192 MMU_REGION_DT_FLAT_ENTRY, attr)
204#define K_MEM_PARTITION_P_RW_U_RW ((k_mem_partition_attr_t) \
206#define K_MEM_PARTITION_P_RW_U_NA ((k_mem_partition_attr_t) \
208#define K_MEM_PARTITION_P_RO_U_RO ((k_mem_partition_attr_t) \
210#define K_MEM_PARTITION_P_RO_U_NA ((k_mem_partition_attr_t) \
213#define K_MEM_PARTITION_P_RX_U_RX ((k_mem_partition_attr_t) \
uint32_t k_mem_partition_attr_t
Definition arch.h:346
const struct arm_mmu_config mmu_config
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
__UINT64_TYPE__ uint64_t
Definition stdint.h:91
__UINTPTR_TYPE__ uintptr_t
Definition stdint.h:105
const struct arm_mmu_region * mmu_regions
Definition arm_mmu.h:128
unsigned int num_regions
Definition arm_mmu.h:128
uint64_t ttbr0
Definition arm_mmu.h:135
uint64_t * base_xlat_table
Definition arm_mmu.h:134
uintptr_t base_va
Definition arm_mmu.h:114
size_t size
Definition arm_mmu.h:116
uintptr_t base_pa
Definition arm_mmu.h:112
const char * name
Definition arm_mmu.h:118
uint32_t attrs
Definition arm_mmu.h:120
uint32_t attrs
Definition arm_mmu.h:216