Skip to content

Commit 85501c5

Browse files
yangbolu1991nashif
authored andcommitted
include: arm: arm_mpu_v8: support memory attribute for device for Cortex-M
Supported memory attribute for device for Cortex-M. Not sure why such code was conditional compile for only Cortex-R, but Cortex-M also suited. Signed-off-by: Yangbo Lu <[email protected]>
1 parent ded9e11 commit 85501c5

File tree

1 file changed

+8
-15
lines changed

1 file changed

+8
-15
lines changed

include/zephyr/arch/arm/mpu/arm_mpu_v8.h

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
(((base & MPU_RBAR_BASE_Msk) + size - 1) & MPU_RLAR_LIMIT_Msk)
8383

8484
/* Attribute flags for cache-ability */
85-
#if defined(CONFIG_AARCH32_ARMV8_R)
85+
8686
/* Memory Attributes for Device Memory
8787
* 1.Gathering (G/nG)
8888
* Determines whether multiple accesses can be merged into a single
@@ -105,7 +105,6 @@
105105
#define DEVICE_nGnRE 0x4U
106106
#define DEVICE_nGRE 0x8U
107107
#define DEVICE_GRE 0xCU
108-
#endif
109108

110109
/* Read/Write Allocation Configurations for Cacheable Memory */
111110
#define R_NON_W_NON 0x0 /* Do not allocate Read/Write */
@@ -152,8 +151,6 @@
152151
#define MPU_MAIR_INDEX_SRAM 1
153152
#define MPU_MAIR_ATTR_SRAM_NOCACHE MPU_CACHE_ATTRIBUTES_SRAM_NOCACHE
154153
#define MPU_MAIR_INDEX_SRAM_NOCACHE 2
155-
156-
#if defined(CONFIG_AARCH32_ARMV8_R)
157154
#define MPU_MAIR_ATTR_DEVICE DEVICE_nGnRnE
158155
#define MPU_MAIR_INDEX_DEVICE 3
159156
/* Flash region(s): Attribute-0
@@ -166,17 +163,6 @@
166163
(MPU_MAIR_ATTR_SRAM << (MPU_MAIR_INDEX_SRAM * 8)) | \
167164
(MPU_MAIR_ATTR_SRAM_NOCACHE << (MPU_MAIR_INDEX_SRAM_NOCACHE * 8)) | \
168165
(MPU_MAIR_ATTR_DEVICE << (MPU_MAIR_INDEX_DEVICE * 8)))
169-
#else
170-
/* Flash region(s): Attribute-0
171-
* SRAM region(s): Attribute-1
172-
* SRAM no cache-able regions(s): Attribute-2
173-
*/
174-
#define MPU_MAIR_ATTRS \
175-
(((MPU_MAIR_ATTR_FLASH << MPU_MAIR0_Attr0_Pos) & MPU_MAIR0_Attr0_Msk) | \
176-
((MPU_MAIR_ATTR_SRAM << MPU_MAIR0_Attr1_Pos) & MPU_MAIR0_Attr1_Msk) | \
177-
((MPU_MAIR_ATTR_SRAM_NOCACHE << MPU_MAIR0_Attr2_Pos) & \
178-
MPU_MAIR0_Attr2_Msk))
179-
#endif
180166

181167
/* Some helper defines for common regions.
182168
*
@@ -309,6 +295,13 @@
309295
}
310296
#endif /* CONFIG_MPU_ALLOW_FLASH_WRITE */
311297

298+
#define REGION_DEVICE_ATTR(base, size) \
299+
{ \
300+
/* AP, XN, SH */ \
301+
.rbar = NOT_EXEC | P_RW_U_NA_Msk | NON_SHAREABLE_Msk, /* Cache-ability */ \
302+
.mair_idx = MPU_MAIR_INDEX_DEVICE, \
303+
.r_limit = REGION_LIMIT_ADDR(base, size), /* Region Limit */ \
304+
}
312305
#endif
313306

314307
struct arm_mpu_region_attr {

0 commit comments

Comments
 (0)