6#ifndef ZEPHYR_INCLUDE_ARCH_ARM_AARCH32_MPU_NXP_MPU_H_
7#define ZEPHYR_INCLUDE_ARCH_ARM_AARCH32_MPU_NXP_MPU_H_
11#include <fsl_common.h>
13#define NXP_MPU_BASE SYSMPU_BASE
15#define NXP_MPU_REGION_NUMBER 12
24#define BM2_UM_SHIFT 12
25#define BM3_UM_SHIFT 18
31#define SM_SAME_AS_UM 3
35#define BM2_SM_SHIFT 15
36#define BM3_SM_SHIFT 21
38#define BM4_WE_SHIFT 24
39#define BM4_RE_SHIFT 25
41#ifdef CONFIG_USB_KINETIS
42#define BM4_PERMISSIONS ((1 << BM4_RE_SHIFT) | (1 << BM4_WE_SHIFT))
44#define BM4_PERMISSIONS 0
48#define MPU_REGION_READ ((UM_READ << BM0_UM_SHIFT) | \
49 (UM_READ << BM1_UM_SHIFT) | \
50 (UM_READ << BM2_UM_SHIFT) | \
51 (UM_READ << BM3_UM_SHIFT))
54#define MPU_REGION_WRITE ((UM_WRITE << BM0_UM_SHIFT) | \
55 (UM_WRITE << BM1_UM_SHIFT) | \
56 (UM_WRITE << BM2_UM_SHIFT) | \
57 (UM_WRITE << BM3_UM_SHIFT))
60#define MPU_REGION_EXEC ((UM_EXEC << BM0_UM_SHIFT) | \
61 (UM_EXEC << BM1_UM_SHIFT) | \
62 (UM_EXEC << BM2_UM_SHIFT) | \
63 (UM_EXEC << BM3_UM_SHIFT))
66#define MPU_REGION_SU ((SM_SAME_AS_UM << BM0_SM_SHIFT) | \
67 (SM_SAME_AS_UM << BM1_SM_SHIFT) | \
68 (SM_SAME_AS_UM << BM2_SM_SHIFT) | \
69 (SM_SAME_AS_UM << BM3_SM_SHIFT))
71#define MPU_REGION_SU_RX ((SM_RX_ALLOW << BM0_SM_SHIFT) | \
72 (SM_RX_ALLOW << BM1_SM_SHIFT) | \
73 (SM_RX_ALLOW << BM2_SM_SHIFT) | \
74 (SM_RX_ALLOW << BM3_SM_SHIFT))
76#define MPU_REGION_SU_RW ((SM_RW_ALLOW << BM0_SM_SHIFT) | \
77 (SM_RW_ALLOW << BM1_SM_SHIFT) | \
78 (SM_RW_ALLOW << BM2_SM_SHIFT) | \
79 (SM_RW_ALLOW << BM3_SM_SHIFT))
81#define MPU_REGION_SU_RWX ((SM_RWX_ALLOW << BM0_SM_SHIFT) | \
82 (SM_RWX_ALLOW << BM1_SM_SHIFT) | \
83 (SM_RWX_ALLOW << BM2_SM_SHIFT) | \
84 (SM_RWX_ALLOW << BM3_SM_SHIFT))
87#define ENDADDR_ROUND(x) (x - 0x1F)
89#define REGION_USER_MODE_ATTR {(MPU_REGION_READ | \
94#if defined(CONFIG_MPU_ALLOW_FLASH_WRITE)
95#define REGION_RAM_ATTR {((MPU_REGION_SU_RWX) | \
96 ((UM_READ | UM_WRITE | UM_EXEC) << BM3_UM_SHIFT) | \
99#define REGION_FLASH_ATTR {(MPU_REGION_SU_RWX)}
102#define REGION_RAM_ATTR {((MPU_REGION_SU_RW) | \
103 ((UM_READ | UM_WRITE) << BM3_UM_SHIFT) | \
106#define REGION_FLASH_ATTR {(MPU_REGION_READ | \
111#define REGION_IO_ATTR {(MPU_REGION_READ | \
116#define REGION_RO_ATTR {(MPU_REGION_READ | MPU_REGION_SU)}
118#define REGION_USER_RO_ATTR {(MPU_REGION_READ | \
124#define REGION_DEBUGGER_AND_DEVICE_ATTR {((MPU_REGION_SU) | \
125 ((UM_READ | UM_WRITE) << BM3_UM_SHIFT) | \
128#define REGION_DEBUG_ATTR {MPU_REGION_SU}
130#define REGION_BACKGROUND_ATTR {MPU_REGION_SU_RW}
152#define K_MEM_PARTITION_P_NA_U_NA ((k_mem_partition_attr_t) \
154#define K_MEM_PARTITION_P_RW_U_RW ((k_mem_partition_attr_t) \
155 {(MPU_REGION_READ | MPU_REGION_WRITE | MPU_REGION_SU)})
156#define K_MEM_PARTITION_P_RW_U_RO ((k_mem_partition_attr_t) \
157 {(MPU_REGION_READ | MPU_REGION_SU_RW)})
158#define K_MEM_PARTITION_P_RW_U_NA ((k_mem_partition_attr_t) \
159 {(MPU_REGION_SU_RW)})
160#define K_MEM_PARTITION_P_RO_U_RO ((k_mem_partition_attr_t) \
161 {(MPU_REGION_READ | MPU_REGION_SU)})
162#define K_MEM_PARTITION_P_RO_U_NA ((k_mem_partition_attr_t) \
163 {(MPU_REGION_SU_RX)})
166#define K_MEM_PARTITION_P_RWX_U_RWX ((k_mem_partition_attr_t) \
167 {(MPU_REGION_READ | MPU_REGION_WRITE | \
168 MPU_REGION_EXEC | MPU_REGION_SU)})
169#define K_MEM_PARTITION_P_RWX_U_RX ((k_mem_partition_attr_t) \
170 {(MPU_REGION_READ | MPU_REGION_EXEC | MPU_REGION_SU_RWX)})
171#define K_MEM_PARTITION_P_RX_U_RX ((k_mem_partition_attr_t) \
172 {(MPU_REGION_READ | MPU_REGION_EXEC | MPU_REGION_SU)})
182#define K_MEM_PARTITION_IS_WRITABLE(attr) \
184 int __is_writable__; \
185 switch (attr.ap_attr) { \
186 case MPU_REGION_WRITE: \
187 case MPU_REGION_SU_RW: \
188 __is_writable__ = 1; \
191 __is_writable__ = 0; \
205#define K_MEM_PARTITION_IS_EXECUTABLE(attr) \
207 int __is_executable__; \
208 switch (attr.ap_attr) { \
209 case MPU_REGION_SU_RX: \
210 case MPU_REGION_EXEC: \
211 __is_executable__ = 1; \
214 __is_executable__ = 0; \
232#define MPU_REGION_ENTRY(_name, _base, _end, _attr) \
262#define _ARCH_MEM_PARTITION_ALIGN_CHECK(start, size) \
263 BUILD_ASSERT((size) % \
264 CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE == 0 && \
265 (size) >= CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE && \
266 (uint32_t)(start) % CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE == 0, \
267 "the size of the partition must align with minimum MPU \
269 " and greater than or equal to minimum MPU region size." \
270 "start address of the partition must align with minimum MPU \
uint32_t k_mem_partition_attr_t
Definition: arch.h:267
const struct nxp_mpu_config mpu_config
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
uint32_t ap_attr
Definition: nxp_mpu.h:141
Definition: nxp_mpu.h:241
uint32_t sram_region
Definition: nxp_mpu.h:247
const struct nxp_mpu_region * mpu_regions
Definition: nxp_mpu.h:245
uint32_t num_regions
Definition: nxp_mpu.h:243
Definition: nxp_mpu.h:132
uint32_t attr
Definition: nxp_mpu.h:134
Definition: nxp_mpu.h:221
uint32_t base
Definition: nxp_mpu.h:223
const char * name
Definition: nxp_mpu.h:227
uint32_t end
Definition: nxp_mpu.h:225
nxp_mpu_region_attr_t attr
Definition: nxp_mpu.h:229