1 /* 2 * Copyright (c) 2017 Synopsys 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 */ 6 7 #include <zephyr/devicetree.h> 8 #include <zephyr/arch/arc/v2/mpu/arc_mpu.h> 9 #include <zephyr/arch/arc/arch.h> 10 #include <zephyr/linker/linker-defs.h> 11 12 /* 13 * for secure firmware, MPU entries are only set up for secure world. 14 * All regions not listed here are shared by secure world and normal world. 15 */ 16 static struct arc_mpu_region mpu_regions[] = { 17 18 #if defined(CONFIG_COVERAGE_GCOV) && defined(CONFIG_USERSPACE) 19 /* Region Coverage */ 20 MPU_REGION_ENTRY("COVERAGE", 21 (uint32_t)&(__gcov_bss_start), 22 (uint32_t)&__gcov_bss_size, 23 REGION_IO_ATTR), 24 #endif /* CONFIG_COVERAGE_GCOV && CONFIG_USERSPACE */ 25 26 #ifdef CONFIG_HARVARD 27 #if DT_REG_SIZE(DT_INST(0, arc_iccm)) > 0 28 /* Region ICCM */ 29 MPU_REGION_ENTRY("ICCM", 30 DT_REG_ADDR(DT_INST(0, arc_iccm)), 31 DT_REG_SIZE(DT_INST(0, arc_iccm)), 32 REGION_ROM_ATTR), 33 #endif 34 #if DT_REG_SIZE(DT_INST(0, arc_dccm)) > 0 35 /* Region DCCM */ 36 MPU_REGION_ENTRY("DCCM", 37 DT_REG_ADDR(DT_INST(0, arc_dccm)), 38 DT_REG_SIZE(DT_INST(0, arc_dccm)), 39 REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), 40 #endif 41 #if DT_REG_SIZE(DT_INST(0, arc_xccm)) > 0 42 /* Region XCCM */ 43 MPU_REGION_ENTRY("XCCM", 44 DT_REG_ADDR(DT_INST(0, arc_xccm)), 45 DT_REG_SIZE(DT_INST(0, arc_xccm)), 46 REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), 47 #endif 48 #if DT_REG_SIZE(DT_INST(0, arc_yccm)) > 0 49 /* Region YCCM */ 50 MPU_REGION_ENTRY("YCCM", 51 DT_REG_ADDR(DT_INST(0, arc_yccm)), 52 DT_REG_SIZE(DT_INST(0, arc_yccm)), 53 REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), 54 #endif 55 56 #else /* !CONFIG_HARVARD */ 57 58 #if DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) > 0 59 #if CONFIG_XIP 60 /* Region RAM */ 61 MPU_REGION_ENTRY("RAM", 62 DT_REG_ADDR(DT_CHOSEN(zephyr_sram)), 63 DT_REG_SIZE(DT_CHOSEN(zephyr_sram)), 64 REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), 65 #else /* !CONFIG_XIP */ 66 MPU_REGION_ENTRY("RAM_RX", 67 (uintptr_t)__rom_region_start, 68 (uintptr_t)__rom_region_size, 69 REGION_ROM_ATTR), 70 71 MPU_REGION_ENTRY("RAM_RW", 72 (uintptr_t)_image_ram_start, 73 (uintptr_t)__arc_rw_sram_size, 74 REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC), 75 #endif /* CONFIG_XIP */ 76 #endif /* zephyr_sram > 0 */ 77 78 #if DT_REG_SIZE(DT_CHOSEN(zephyr_flash)) > 0 79 /* Region FLASH */ 80 MPU_REGION_ENTRY("FLASH", 81 DT_REG_ADDR(DT_CHOSEN(zephyr_flash)), 82 DT_REG_SIZE(DT_CHOSEN(zephyr_flash)), 83 REGION_ROM_ATTR), 84 #endif 85 86 #endif /* CONFIG_HARVARD */ 87 88 /* 89 * Region peripheral is shared by secure world and normal world by default, 90 * no need a static mpu entry. If some peripherals belong to secure world, 91 * add it here. 92 */ 93 #ifndef CONFIG_ARC_SECURE_FIRMWARE 94 /* Region Peripheral */ 95 MPU_REGION_ENTRY("PERIPHERAL", 96 0xF0000000, 97 64 * 1024, 98 REGION_KERNEL_RAM_ATTR), 99 #endif 100 }; 101 102 struct arc_mpu_config mpu_config = { 103 .num_regions = ARRAY_SIZE(mpu_regions), 104 .mpu_regions = mpu_regions, 105 }; 106