1 /*
2  * Copyright (c) 2022 IoT.bzh
3  * SPDX-License-Identifier: Apache-2.0
4  */
5 
6 #include <zephyr/sys/slist.h>
7 #include <zephyr/linker/linker-defs.h>
8 #include <zephyr/arch/arm/mpu/arm_mpu.h>
9 
10 #define DEVICE_REGION_START 0x80000000UL
11 #define DEVICE_REGION_END   0xFFFFFFFFUL
12 
13 static const struct arm_mpu_region mpu_regions[] = {
14 	/* Region 0 zephyr vector */
15 	MPU_REGION_ENTRY("vector",
16 			 (uintptr_t)_vector_start,
17 			 REGION_RAM_TEXT_ATTR((uintptr_t)_vector_end)),
18 
19 	/* Region 1 zephyr text */
20 	MPU_REGION_ENTRY("SRAM_0",
21 			 (uintptr_t)__text_region_start,
22 			 REGION_RAM_TEXT_ATTR((uintptr_t)__rodata_region_start)),
23 
24 	/* Region 2 zephyr rodata */
25 	MPU_REGION_ENTRY("SRAM_1",
26 			 (uintptr_t)__rodata_region_start,
27 			 REGION_RAM_RO_ATTR((uintptr_t)__rodata_region_end)),
28 
29 	/* Region 3 zephyr data */
30 	MPU_REGION_ENTRY("SRAM_2",
31 			 (uintptr_t)__rom_region_end,
32 			 REGION_RAM_ATTR((uintptr_t)__kernel_ram_end)),
33 
34 	/* Region 4 device region */
35 	MPU_REGION_ENTRY("DEVICE",
36 			 DEVICE_REGION_START,
37 			 REGION_DEVICE_ATTR(DEVICE_REGION_END)),
38 };
39 
40 const struct arm_mpu_config mpu_config = {
41 	.num_regions = ARRAY_SIZE(mpu_regions),
42 	.mpu_regions = mpu_regions,
43 };
44