Zephyr Project API
4.1.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
arm_mmu.h
Go to the documentation of this file.
1
/*
2
* ARMv7 MMU support
3
*
4
* Copyright (c) 2021 Weidmueller Interface GmbH & Co. KG
5
* SPDX-License-Identifier: Apache-2.0
6
*/
7
8
#ifndef ZEPHYR_INCLUDE_ARCH_AARCH32_ARM_MMU_H_
9
#define ZEPHYR_INCLUDE_ARCH_AARCH32_ARM_MMU_H_
10
11
#ifndef _ASMLANGUAGE
12
13
#include <
stdint.h
>
14
#include <
stdlib.h
>
15
16
/*
17
* Comp.:
18
* ARM Architecture Reference Manual, ARMv7-A and ARMv7-R edition,
19
* ARM document ID DDI0406C Rev. d, March 2018
20
* Memory type definitions:
21
* Table B3-10, chap. B3.8.2, p. B3-1363f.
22
* Outer / inner cache attributes for cacheable memory:
23
* Table B3-11, chap. B3.8.2, p. B3-1364
24
*/
25
26
/*
27
* The following definitions are used when specifying a memory
28
* range to be mapped at boot time using the MMU_REGION_ENTRY
29
* macro.
30
*/
31
#define MT_STRONGLY_ORDERED BIT(0)
32
#define MT_DEVICE BIT(1)
33
#define MT_NORMAL BIT(2)
34
#define MT_MASK 0x7
35
36
#define MPERM_R BIT(3)
37
#define MPERM_W BIT(4)
38
#define MPERM_X BIT(5)
39
#define MPERM_UNPRIVILEGED BIT(6)
40
41
#define MATTR_NON_SECURE BIT(7)
42
#define MATTR_NON_GLOBAL BIT(8)
43
#define MATTR_SHARED BIT(9)
44
#define MATTR_CACHE_OUTER_WB_WA BIT(10)
45
#define MATTR_CACHE_OUTER_WT_nWA BIT(11)
46
#define MATTR_CACHE_OUTER_WB_nWA BIT(12)
47
#define MATTR_CACHE_INNER_WB_WA BIT(13)
48
#define MATTR_CACHE_INNER_WT_nWA BIT(14)
49
#define MATTR_CACHE_INNER_WB_nWA BIT(15)
50
51
#define MATTR_MAY_MAP_L1_SECTION BIT(16)
52
53
/*
54
* The following macros are used for adding constant entries
55
* mmu_regions array of the mmu_config struct. Use MMU_REGION_ENTRY
56
* for the specification of mappings whose PA and VA differ,
57
* the use of MMU_REGION_FLAT_ENTRY always results in an identity
58
* mapping, which are used for the mappings of the Zephyr image's
59
* code and data.
60
*/
61
#define MMU_REGION_ENTRY(_name, _base_pa, _base_va, _size, _attrs) \
62
{\
63
.name = _name, \
64
.base_pa = _base_pa, \
65
.base_va = _base_va, \
66
.size = _size, \
67
.attrs = _attrs, \
68
}
69
70
#define MMU_REGION_FLAT_ENTRY(name, adr, sz, attrs) \
71
MMU_REGION_ENTRY(name, adr, adr, sz, attrs)
72
73
/*
74
* @brief Auto generate mmu region entry for node_id
75
*
76
* Example usage:
77
*
78
* @code{.c}
79
* DT_FOREACH_STATUS_OKAY_VARGS(nxp_imx_gpio,
80
* MMU_REGION_DT_FLAT_ENTRY,
81
* (MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_NS))
82
* @endcode
83
*
84
* @note Since devicetree_generated.h does not include
85
* node_id##_P_reg_FOREACH_PROP_ELEM* definitions,
86
* we can't automate dts node with multiple reg
87
* entries.
88
*/
89
#define MMU_REGION_DT_FLAT_ENTRY(node_id, attrs) \
90
MMU_REGION_FLAT_ENTRY(DT_NODE_FULL_NAME(node_id), \
91
DT_REG_ADDR(node_id), \
92
DT_REG_SIZE(node_id), \
93
attrs),
94
95
/*
96
* @brief Auto generate mmu region entry for status = "okay"
97
* nodes compatible to a driver
98
*
99
* Example usage:
100
*
101
* @code{.c}
102
* MMU_REGION_DT_COMPAT_FOREACH_FLAT_ENTRY(nxp_imx_gpio,
103
* (MT_DEVICE_nGnRnE | MT_P_RW_U_NA | MT_NS))
104
* @endcode
105
*
106
* @note This is a wrapper of @ref MMU_REGION_DT_FLAT_ENTRY
107
*/
108
#define MMU_REGION_DT_COMPAT_FOREACH_FLAT_ENTRY(compat, attr) \
109
DT_FOREACH_STATUS_OKAY_VARGS(compat, \
110
MMU_REGION_DT_FLAT_ENTRY, attr)
111
112
/* Region definition data structure */
113
struct
arm_mmu_region
{
114
/* Region Base Physical Address */
115
uintptr_t
base_pa
;
116
/* Region Base Virtual Address */
117
uintptr_t
base_va
;
118
/* Region size */
119
size_t
size
;
120
/* Region Name */
121
const
char
*
name
;
122
/* Region Attributes */
123
uint32_t
attrs
;
124
};
125
126
/* MMU configuration data structure */
127
struct
arm_mmu_config
{
128
/* Number of regions */
129
uint32_t
num_regions
;
130
/* Regions */
131
const
struct
arm_mmu_region
*
mmu_regions
;
132
};
133
134
/*
135
* Reference to the MMU configuration.
136
*
137
* This struct is defined and populated for each SoC (in the SoC definition),
138
* and holds the build-time configuration information for the fixed MMU
139
* regions enabled during kernel initialization.
140
*/
141
extern
const
struct
arm_mmu_config
mmu_config
;
142
143
int
z_arm_mmu_init(
void
);
144
145
#endif
/* _ASMLANGUAGE */
146
147
#endif
/* ZEPHYR_INCLUDE_ARCH_AARCH32_ARM_MMU_H_ */
mmu_config
const struct arm_mmu_config mmu_config
stdint.h
uint32_t
__UINT32_TYPE__ uint32_t
Definition
stdint.h:90
uintptr_t
__UINTPTR_TYPE__ uintptr_t
Definition
stdint.h:105
stdlib.h
arm_mmu_config
Definition
arm_mmu.h:127
arm_mmu_config::mmu_regions
const struct arm_mmu_region * mmu_regions
Definition
arm_mmu.h:131
arm_mmu_config::num_regions
uint32_t num_regions
Definition
arm_mmu.h:129
arm_mmu_region
Definition
arm_mmu.h:113
arm_mmu_region::base_va
uintptr_t base_va
Definition
arm_mmu.h:117
arm_mmu_region::size
size_t size
Definition
arm_mmu.h:119
arm_mmu_region::base_pa
uintptr_t base_pa
Definition
arm_mmu.h:115
arm_mmu_region::name
const char * name
Definition
arm_mmu.h:121
arm_mmu_region::attrs
uint32_t attrs
Definition
arm_mmu.h:123
include
zephyr
arch
arm
mmu
arm_mmu.h
Generated on Sun May 4 2025 13:59:45 for Zephyr Project API by
1.9.8