2018-07-07 23:21:17 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2017 Synopsys
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2022-05-06 16:56:39 +08:00
|
|
|
#include <zephyr/devicetree.h>
|
|
|
|
#include <zephyr/arch/arc/v2/mpu/arc_mpu.h>
|
2022-10-31 22:28:26 +08:00
|
|
|
#include <zephyr/arch/arc/arch.h>
|
2022-05-06 16:56:39 +08:00
|
|
|
#include <zephyr/linker/linker-defs.h>
|
2018-07-07 23:21:17 +08:00
|
|
|
|
2019-08-01 14:25:50 +08:00
|
|
|
/*
|
|
|
|
* for secure firmware, MPU entries are only set up for secure world.
|
|
|
|
* All regions not listed here are shared by secure world and normal world.
|
|
|
|
*/
|
2018-07-07 23:21:17 +08:00
|
|
|
static struct arc_mpu_region mpu_regions[] = {
|
2020-07-16 15:55:18 +08:00
|
|
|
|
|
|
|
#if defined(CONFIG_COVERAGE_GCOV) && defined(CONFIG_USERSPACE)
|
|
|
|
/* Region Coverage */
|
|
|
|
MPU_REGION_ENTRY("COVERAGE",
|
|
|
|
(uint32_t)&(__gcov_bss_start),
|
|
|
|
(uint32_t)&__gcov_bss_size,
|
|
|
|
REGION_IO_ATTR),
|
|
|
|
#endif /* CONFIG_COVERAGE_GCOV && CONFIG_USERSPACE */
|
|
|
|
|
2022-10-31 22:28:26 +08:00
|
|
|
#ifdef CONFIG_HARVARD
|
2020-04-30 22:34:04 +08:00
|
|
|
#if DT_REG_SIZE(DT_INST(0, arc_iccm)) > 0
|
2018-07-07 23:21:17 +08:00
|
|
|
/* Region ICCM */
|
|
|
|
MPU_REGION_ENTRY("ICCM",
|
2020-04-30 22:34:04 +08:00
|
|
|
DT_REG_ADDR(DT_INST(0, arc_iccm)),
|
|
|
|
DT_REG_SIZE(DT_INST(0, arc_iccm)),
|
2019-03-05 10:29:16 +08:00
|
|
|
REGION_ROM_ATTR),
|
2018-07-07 23:21:17 +08:00
|
|
|
#endif
|
2020-04-30 22:34:04 +08:00
|
|
|
#if DT_REG_SIZE(DT_INST(0, arc_dccm)) > 0
|
2018-07-07 23:21:17 +08:00
|
|
|
/* Region DCCM */
|
|
|
|
MPU_REGION_ENTRY("DCCM",
|
2020-04-30 22:34:04 +08:00
|
|
|
DT_REG_ADDR(DT_INST(0, arc_dccm)),
|
|
|
|
DT_REG_SIZE(DT_INST(0, arc_dccm)),
|
2019-03-05 10:29:16 +08:00
|
|
|
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
|
2018-07-07 23:21:17 +08:00
|
|
|
#endif
|
2022-10-31 15:14:21 +08:00
|
|
|
#if DT_REG_SIZE(DT_INST(0, arc_xccm)) > 0
|
|
|
|
/* Region XCCM */
|
|
|
|
MPU_REGION_ENTRY("XCCM",
|
|
|
|
DT_REG_ADDR(DT_INST(0, arc_xccm)),
|
|
|
|
DT_REG_SIZE(DT_INST(0, arc_xccm)),
|
|
|
|
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
|
|
|
|
#endif
|
|
|
|
#if DT_REG_SIZE(DT_INST(0, arc_yccm)) > 0
|
|
|
|
/* Region YCCM */
|
|
|
|
MPU_REGION_ENTRY("YCCM",
|
|
|
|
DT_REG_ADDR(DT_INST(0, arc_yccm)),
|
|
|
|
DT_REG_SIZE(DT_INST(0, arc_yccm)),
|
|
|
|
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
|
|
|
|
#endif
|
2019-08-01 14:25:50 +08:00
|
|
|
|
2022-10-31 22:28:26 +08:00
|
|
|
#else /* !CONFIG_HARVARD */
|
|
|
|
|
|
|
|
#if DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) > 0
|
|
|
|
#if CONFIG_XIP
|
|
|
|
/* Region RAM */
|
|
|
|
MPU_REGION_ENTRY("RAM",
|
|
|
|
DT_REG_ADDR(DT_CHOSEN(zephyr_sram)),
|
|
|
|
DT_REG_SIZE(DT_CHOSEN(zephyr_sram)),
|
|
|
|
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
|
|
|
|
#else /* !CONFIG_XIP */
|
|
|
|
MPU_REGION_ENTRY("RAM_RX",
|
|
|
|
(uintptr_t)__rom_region_start,
|
|
|
|
(uintptr_t)__rom_region_size,
|
|
|
|
REGION_ROM_ATTR),
|
|
|
|
|
|
|
|
MPU_REGION_ENTRY("RAM_RW",
|
|
|
|
(uintptr_t)_image_ram_start,
|
|
|
|
(uintptr_t)__arc_rw_sram_size,
|
|
|
|
REGION_KERNEL_RAM_ATTR | REGION_DYNAMIC),
|
|
|
|
#endif /* CONFIG_XIP */
|
|
|
|
#endif /* zephyr_sram > 0 */
|
|
|
|
|
|
|
|
#if DT_REG_SIZE(DT_CHOSEN(zephyr_flash)) > 0
|
|
|
|
/* Region FLASH */
|
|
|
|
MPU_REGION_ENTRY("FLASH",
|
|
|
|
DT_REG_ADDR(DT_CHOSEN(zephyr_flash)),
|
|
|
|
DT_REG_SIZE(DT_CHOSEN(zephyr_flash)),
|
|
|
|
REGION_ROM_ATTR),
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* CONFIG_HARVARD */
|
2022-10-31 15:14:21 +08:00
|
|
|
|
2019-08-01 14:25:50 +08:00
|
|
|
/*
|
|
|
|
* Region peripheral is shared by secure world and normal world by default,
|
|
|
|
* no need a static mpu entry. If some peripherals belong to secure world,
|
|
|
|
* add it here.
|
|
|
|
*/
|
|
|
|
#ifndef CONFIG_ARC_SECURE_FIRMWARE
|
2018-07-07 23:21:17 +08:00
|
|
|
/* Region Peripheral */
|
|
|
|
MPU_REGION_ENTRY("PERIPHERAL",
|
|
|
|
0xF0000000,
|
|
|
|
64 * 1024,
|
2019-03-05 10:29:16 +08:00
|
|
|
REGION_KERNEL_RAM_ATTR),
|
2019-08-01 14:25:50 +08:00
|
|
|
#endif
|
2018-07-07 23:21:17 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct arc_mpu_config mpu_config = {
|
|
|
|
.num_regions = ARRAY_SIZE(mpu_regions),
|
|
|
|
.mpu_regions = mpu_regions,
|
|
|
|
};
|