6#ifndef ZEPHYR_INCLUDE_ARCH_ARM_MPU_NXP_MPU_H_
7#define ZEPHYR_INCLUDE_ARCH_ARM_MPU_NXP_MPU_H_
11#define NXP_MPU_REGION_NUMBER 12
20#define BM2_UM_SHIFT 12
21#define BM3_UM_SHIFT 18
27#define SM_SAME_AS_UM 3
31#define BM2_SM_SHIFT 15
32#define BM3_SM_SHIFT 21
34#define BM4_WE_SHIFT 24
35#define BM4_RE_SHIFT 25
37#if CONFIG_USB_KINETIS || CONFIG_UDC_KINETIS
38#define BM4_PERMISSIONS ((1 << BM4_RE_SHIFT) | (1 << BM4_WE_SHIFT))
40#define BM4_PERMISSIONS 0
44#define MPU_REGION_READ ((UM_READ << BM0_UM_SHIFT) | \
45 (UM_READ << BM1_UM_SHIFT) | \
46 (UM_READ << BM2_UM_SHIFT) | \
47 (UM_READ << BM3_UM_SHIFT))
50#define MPU_REGION_WRITE ((UM_WRITE << BM0_UM_SHIFT) | \
51 (UM_WRITE << BM1_UM_SHIFT) | \
52 (UM_WRITE << BM2_UM_SHIFT) | \
53 (UM_WRITE << BM3_UM_SHIFT))
56#define MPU_REGION_EXEC ((UM_EXEC << BM0_UM_SHIFT) | \
57 (UM_EXEC << BM1_UM_SHIFT) | \
58 (UM_EXEC << BM2_UM_SHIFT) | \
59 (UM_EXEC << BM3_UM_SHIFT))
62#define MPU_REGION_SU ((SM_SAME_AS_UM << BM0_SM_SHIFT) | \
63 (SM_SAME_AS_UM << BM1_SM_SHIFT) | \
64 (SM_SAME_AS_UM << BM2_SM_SHIFT) | \
65 (SM_SAME_AS_UM << BM3_SM_SHIFT))
67#define MPU_REGION_SU_RX ((SM_RX_ALLOW << BM0_SM_SHIFT) | \
68 (SM_RX_ALLOW << BM1_SM_SHIFT) | \
69 (SM_RX_ALLOW << BM2_SM_SHIFT) | \
70 (SM_RX_ALLOW << BM3_SM_SHIFT))
72#define MPU_REGION_SU_RW ((SM_RW_ALLOW << BM0_SM_SHIFT) | \
73 (SM_RW_ALLOW << BM1_SM_SHIFT) | \
74 (SM_RW_ALLOW << BM2_SM_SHIFT) | \
75 (SM_RW_ALLOW << BM3_SM_SHIFT))
77#define MPU_REGION_SU_RWX ((SM_RWX_ALLOW << BM0_SM_SHIFT) | \
78 (SM_RWX_ALLOW << BM1_SM_SHIFT) | \
79 (SM_RWX_ALLOW << BM2_SM_SHIFT) | \
80 (SM_RWX_ALLOW << BM3_SM_SHIFT))
83#define ENDADDR_ROUND(x) (x - 0x1F)
85#define REGION_USER_MODE_ATTR {(MPU_REGION_READ | \
90#if defined(CONFIG_MPU_ALLOW_FLASH_WRITE)
91#define REGION_RAM_ATTR {((MPU_REGION_SU_RWX) | \
92 ((UM_READ | UM_WRITE | UM_EXEC) << BM3_UM_SHIFT) | \
95#define REGION_FLASH_ATTR {(MPU_REGION_SU_RWX)}
98#define REGION_RAM_ATTR {((MPU_REGION_SU_RW) | \
99 ((UM_READ | UM_WRITE) << BM3_UM_SHIFT) | \
102#define REGION_FLASH_ATTR {(MPU_REGION_READ | \
107#define REGION_IO_ATTR {(MPU_REGION_READ | \
112#define REGION_RO_ATTR {(MPU_REGION_READ | MPU_REGION_SU)}
114#define REGION_USER_RO_ATTR {(MPU_REGION_READ | \
120#define REGION_DEBUGGER_AND_DEVICE_ATTR {((MPU_REGION_SU) | \
121 ((UM_READ | UM_WRITE) << BM3_UM_SHIFT) | \
124#define REGION_DEBUG_ATTR {MPU_REGION_SU}
126#define REGION_BACKGROUND_ATTR {MPU_REGION_SU_RW}
148#define K_MEM_PARTITION_P_NA_U_NA ((k_mem_partition_attr_t) \
150#define K_MEM_PARTITION_P_RW_U_RW ((k_mem_partition_attr_t) \
151 {(MPU_REGION_READ | MPU_REGION_WRITE | MPU_REGION_SU)})
152#define K_MEM_PARTITION_P_RW_U_RO ((k_mem_partition_attr_t) \
153 {(MPU_REGION_READ | MPU_REGION_SU_RW)})
154#define K_MEM_PARTITION_P_RW_U_NA ((k_mem_partition_attr_t) \
155 {(MPU_REGION_SU_RW)})
156#define K_MEM_PARTITION_P_RO_U_RO ((k_mem_partition_attr_t) \
157 {(MPU_REGION_READ | MPU_REGION_SU)})
158#define K_MEM_PARTITION_P_RO_U_NA ((k_mem_partition_attr_t) \
159 {(MPU_REGION_SU_RX)})
162#define K_MEM_PARTITION_P_RWX_U_RWX ((k_mem_partition_attr_t) \
163 {(MPU_REGION_READ | MPU_REGION_WRITE | \
164 MPU_REGION_EXEC | MPU_REGION_SU)})
165#define K_MEM_PARTITION_P_RWX_U_RX ((k_mem_partition_attr_t) \
166 {(MPU_REGION_READ | MPU_REGION_EXEC | MPU_REGION_SU_RWX)})
167#define K_MEM_PARTITION_P_RX_U_RX ((k_mem_partition_attr_t) \
168 {(MPU_REGION_READ | MPU_REGION_EXEC | MPU_REGION_SU)})
178#define K_MEM_PARTITION_IS_WRITABLE(attr) \
180 int __is_writable__; \
181 switch (attr.ap_attr) { \
182 case MPU_REGION_WRITE: \
183 case MPU_REGION_SU_RW: \
184 __is_writable__ = 1; \
187 __is_writable__ = 0; \
201#define K_MEM_PARTITION_IS_EXECUTABLE(attr) \
203 int __is_executable__; \
204 switch (attr.ap_attr) { \
205 case MPU_REGION_SU_RX: \
206 case MPU_REGION_EXEC: \
207 __is_executable__ = 1; \
210 __is_executable__ = 0; \
228#define MPU_REGION_ENTRY(_name, _base, _end, _attr) \
258#define _ARCH_MEM_PARTITION_ALIGN_CHECK(start, size) \
259 BUILD_ASSERT((size) % \
260 CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE == 0 && \
261 (size) >= CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE && \
262 (uint32_t)(start) % CONFIG_ARM_MPU_REGION_MIN_ALIGN_AND_SIZE == 0, \
263 "the size of the partition must align with minimum MPU \
265 " and greater than or equal to minimum MPU region size." \
266 "start address of the partition must align with minimum MPU \
uint32_t k_mem_partition_attr_t
Definition arch.h:346
const struct nxp_mpu_config mpu_config
__UINT32_TYPE__ uint32_t
Definition stdint.h:90
uint32_t ap_attr
Definition nxp_mpu.h:137
uint32_t sram_region
Definition nxp_mpu.h:243
const struct nxp_mpu_region * mpu_regions
Definition nxp_mpu.h:241
uint32_t num_regions
Definition nxp_mpu.h:239
uint32_t attr
Definition nxp_mpu.h:130
uint32_t base
Definition nxp_mpu.h:219
const char * name
Definition nxp_mpu.h:223
uint32_t end
Definition nxp_mpu.h:221
nxp_mpu_region_attr_t attr
Definition nxp_mpu.h:225