1 /*
2  * Copyright (c) 2021 Arm Limited (or its affiliates). All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #include <sys/slist.h>
7 #include <linker/linker-defs.h>
8 #include <arch/arm64/cortex_r/mpu/arm_mpu.h>
9 
10 
11 #define DEVICE_REGION_START 0x80000000UL
12 #define DEVICE_REGION_END   0xFFFFFFFFUL
13 
14 static const struct arm_mpu_region mpu_regions[] = {
15 	/* Region 0 */
16 	MPU_REGION_ENTRY("FLASH_0",
17 			 CONFIG_FLASH_BASE_ADDRESS,
18 			 CONFIG_FLASH_BASE_ADDRESS +
19 			 KB(CONFIG_FLASH_SIZE),
20 			 REGION_FLASH_ATTR),
21 
22 	/* Region 1 zephyr text */
23 	MPU_REGION_ENTRY("SRAM_0",
24 			 (uintptr_t)__text_region_start,
25 			 (uintptr_t)__text_region_end,
26 			 REGION_RAM_TEXT_ATTR),
27 
28 	/* Region 2 zephyr rodata */
29 	MPU_REGION_ENTRY("SRAM_1",
30 			 (uintptr_t)__rodata_region_start,
31 			 (uintptr_t)__rodata_region_end,
32 			 REGION_RAM_RO_ATTR),
33 
34 	/* Region 3 zephyr data */
35 	MPU_REGION_ENTRY("SRAM_2",
36 			 (uintptr_t)__kernel_ram_start,
37 			 (uintptr_t)__kernel_ram_end,
38 			 REGION_RAM_ATTR),
39 
40 	/* Region 4 device region */
41 	MPU_REGION_ENTRY("DEVICE",
42 			 DEVICE_REGION_START,
43 			 DEVICE_REGION_END,
44 			 REGION_DEVICE_ATTR)
45 };
46 
47 const struct arm_mpu_config mpu_config = {
48 	.num_regions = ARRAY_SIZE(mpu_regions),
49 	.mpu_regions = mpu_regions,
50 };
51