Line data Source code
1 0 : /* 2 : * Copyright (c) 2017 Synopsys. 3 : * 4 : * SPDX-License-Identifier: Apache-2.0 5 : */ 6 : #ifndef ZEPHYR_INCLUDE_ARCH_ARC_V2_MPU_ARC_MPU_H_ 7 : #define ZEPHYR_INCLUDE_ARCH_ARC_V2_MPU_ARC_MPU_H_ 8 : 9 : 10 : 11 0 : #define AUX_MPU_ATTR_UE 0x008 /* allow user execution */ 12 0 : #define AUX_MPU_ATTR_UW 0x010 /* allow user write */ 13 0 : #define AUX_MPU_ATTR_UR 0x020 /* allow user read */ 14 0 : #define AUX_MPU_ATTR_KE 0x040 /* only allow kernel execution */ 15 0 : #define AUX_MPU_ATTR_KW 0x080 /* only allow kernel write */ 16 0 : #define AUX_MPU_ATTR_KR 0x100 /* only allow kernel read */ 17 0 : #define AUX_MPU_ATTR_S 0x8000 /* secure */ 18 0 : #define AUX_MPU_ATTR_N 0x0000 /* normal */ 19 : 20 : 21 : /* 22 : * a region is dynamic means it can be split into sub regions. 23 : * This attribute is meaningful for ARC MPUv3 which does not support mpu 24 : * entry overlap. For ARC MPUv2, this attribute will be ignored as it 25 : * supports mpu overlap in hardware. 26 : */ 27 0 : #define REGION_DYNAMIC 0x800 /* dynamic flag */ 28 : 29 : 30 : /* Some helper defines for common regions */ 31 : 32 0 : #define REGION_KERNEL_RAM_ATTR \ 33 : (AUX_MPU_ATTR_KW | AUX_MPU_ATTR_KR) 34 : 35 0 : #define REGION_KERNEL_ROM_ATTR \ 36 : (AUX_MPU_ATTR_KE | AUX_MPU_ATTR_KR) 37 : 38 0 : #define REGION_RAM_ATTR \ 39 : (AUX_MPU_ATTR_UW | AUX_MPU_ATTR_UR | \ 40 : AUX_MPU_ATTR_KW | AUX_MPU_ATTR_KR) 41 : 42 0 : #define REGION_ROM_ATTR \ 43 : (AUX_MPU_ATTR_UE | AUX_MPU_ATTR_UR | \ 44 : AUX_MPU_ATTR_KE | AUX_MPU_ATTR_KR) 45 : 46 0 : #define REGION_IO_ATTR \ 47 : (AUX_MPU_ATTR_UW | AUX_MPU_ATTR_UR | \ 48 : AUX_MPU_ATTR_KW | AUX_MPU_ATTR_KR) 49 : 50 0 : #define REGION_ALL_ATTR \ 51 : (AUX_MPU_ATTR_UW | AUX_MPU_ATTR_UR | \ 52 : AUX_MPU_ATTR_KW | AUX_MPU_ATTR_KR | \ 53 : AUX_MPU_ATTR_KE | AUX_MPU_ATTR_UE) 54 : 55 : 56 0 : #define REGION_32B 0x200 57 0 : #define REGION_64B 0x201 58 0 : #define REGION_128B 0x202 59 0 : #define REGION_256B 0x203 60 0 : #define REGION_512B 0x400 61 0 : #define REGION_1K 0x401 62 0 : #define REGION_2K 0x402 63 0 : #define REGION_4K 0x403 64 0 : #define REGION_8K 0x600 65 0 : #define REGION_16K 0x601 66 0 : #define REGION_32K 0x602 67 0 : #define REGION_64K 0x603 68 0 : #define REGION_128K 0x800 69 0 : #define REGION_256K 0x801 70 0 : #define REGION_512K 0x802 71 0 : #define REGION_1M 0x803 72 0 : #define REGION_2M 0xA00 73 0 : #define REGION_4M 0xA01 74 0 : #define REGION_8M 0xA02 75 0 : #define REGION_16M 0xA03 76 0 : #define REGION_32M 0xC00 77 0 : #define REGION_64M 0xC01 78 0 : #define REGION_128M 0xC02 79 0 : #define REGION_256M 0xC03 80 0 : #define REGION_512M 0xE00 81 0 : #define REGION_1G 0xE01 82 0 : #define REGION_2G 0xE02 83 0 : #define REGION_4G 0xE03 84 : 85 : /* Region definition data structure */ 86 0 : struct arc_mpu_region { 87 : /* Region Name */ 88 0 : const char *name; 89 : /* Region Base Address */ 90 0 : uint32_t base; 91 0 : uint32_t size; 92 : /* Region Attributes */ 93 0 : uint32_t attr; 94 : }; 95 : 96 0 : #define MPU_REGION_ENTRY(_name, _base, _size, _attr) \ 97 : {\ 98 : .name = _name, \ 99 : .base = _base, \ 100 : .size = _size, \ 101 : .attr = _attr, \ 102 : } 103 : 104 : /* MPU configuration data structure */ 105 0 : struct arc_mpu_config { 106 : /* Number of regions */ 107 0 : uint32_t num_regions; 108 : /* Regions */ 109 0 : struct arc_mpu_region *mpu_regions; 110 : }; 111 : 112 : /* Reference to the MPU configuration */ 113 0 : extern struct arc_mpu_config mpu_config; 114 : 115 : #endif /* _ARC_CORE_MPU_H_ */