1 /* SPDX-License-Identifier: Apache-2.0 2 * 3 * Copyright (c) 2021 Lexmark International, Inc. 4 */ 5 6 #include <zephyr/kernel.h> 7 #include <zephyr/arch/arm/mpu/arm_mpu.h> 8 9 #define MPUTYPE_READ_ONLY \ 10 { \ 11 .rasr = (P_RO_U_RO_Msk \ 12 | (7 << MPU_RASR_TEX_Pos) \ 13 | MPU_RASR_C_Msk \ 14 | MPU_RASR_B_Msk \ 15 | MPU_RASR_XN_Msk) \ 16 } 17 18 #define MPUTYPE_READ_ONLY_PRIV \ 19 { \ 20 .rasr = (P_RO_U_RO_Msk \ 21 | (5 << MPU_RASR_TEX_Pos) \ 22 | MPU_RASR_B_Msk) \ 23 } 24 25 #define MPUTYPE_PRIV_WBWACACHE_XN \ 26 { \ 27 .rasr = (P_RW_U_NA_Msk \ 28 | (5 << MPU_RASR_TEX_Pos) \ 29 | MPU_RASR_B_Msk \ 30 | MPU_RASR_XN_Msk) \ 31 } 32 33 #define MPUTYPE_PRIV_DEVICE \ 34 { \ 35 .rasr = (P_RW_U_NA_Msk \ 36 | (2 << MPU_RASR_TEX_Pos)) \ 37 } 38 39 extern uint32_t _image_rom_end_order; 40 static const struct arm_mpu_region mpu_regions[] = { 41 MPU_REGION_ENTRY("FLASH0", 42 0xc0000000, 43 REGION_32M, 44 MPUTYPE_READ_ONLY), 45 46 MPU_REGION_ENTRY("SRAM_PRIV", 47 0x00000000, 48 REGION_2G, 49 MPUTYPE_PRIV_WBWACACHE_XN), 50 51 MPU_REGION_ENTRY("SRAM", 52 0x00000000, 53 ((uint32_t)&_image_rom_end_order), 54 MPUTYPE_READ_ONLY_PRIV), 55 56 MPU_REGION_ENTRY("REGISTERS", 57 0xf8000000, 58 REGION_128M, 59 MPUTYPE_PRIV_DEVICE), 60 }; 61 62 const struct arm_mpu_config mpu_config = { 63 .num_regions = ARRAY_SIZE(mpu_regions), 64 .mpu_regions = mpu_regions, 65 }; 66