arc: qemu: enable MPU
Enable MPU for arc qemu. Signed-off-by: Watson Zeng <zhiwei@synopsys.com>
This commit is contained in:
parent
85a9e04aa2
commit
6a7982ff10
8 changed files with 83 additions and 0 deletions
3
boards/arc/qemu_arc/CMakeLists.txt
Normal file
3
boards/arc/qemu_arc/CMakeLists.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_sources_ifdef(CONFIG_ARC_MPU_ENABLE arc_mpu_regions.c)
|
59
boards/arc/qemu_arc/arc_mpu_regions.c
Normal file
59
boards/arc/qemu_arc/arc_mpu_regions.c
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Copyright (c) 2021 Synopsys
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <devicetree.h>
|
||||
#include <soc.h>
|
||||
#include <arch/arc/v2/mpu/arc_mpu.h>
|
||||
#include <linker/linker-defs.h>
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
static struct arc_mpu_region mpu_regions[] = {
|
||||
|
||||
#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 */
|
||||
|
||||
#if DT_REG_SIZE(DT_CHOSEN(zephyr_sram)) > 0
|
||||
/* 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),
|
||||
#endif
|
||||
|
||||
#if DT_REG_SIZE(DT_CHOSEN(zephyr_flash)) > 0
|
||||
/* Region DCCM */
|
||||
MPU_REGION_ENTRY("FLASH",
|
||||
DT_REG_ADDR(DT_CHOSEN(zephyr_flash)),
|
||||
DT_REG_SIZE(DT_CHOSEN(zephyr_flash)),
|
||||
REGION_ROM_ATTR),
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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
|
||||
/* Region Peripheral */
|
||||
MPU_REGION_ENTRY("PERIPHERAL",
|
||||
0xF0000000,
|
||||
64 * 1024,
|
||||
REGION_KERNEL_RAM_ATTR),
|
||||
#endif
|
||||
};
|
||||
|
||||
struct arc_mpu_config mpu_config = {
|
||||
.num_regions = ARRAY_SIZE(mpu_regions),
|
||||
.mpu_regions = mpu_regions,
|
||||
};
|
|
@ -23,6 +23,8 @@ list(APPEND QEMU_FLAGS_${ARCH}
|
|||
-global cpu.freq_hz=1000000
|
||||
-global cpu.timer0=true
|
||||
-global cpu.timer1=true
|
||||
-global cpu.has-mpu=true
|
||||
-global cpu.mpu-numreg=16
|
||||
)
|
||||
|
||||
set(BOARD_DEBUG_RUNNER qemu)
|
||||
|
|
|
@ -11,3 +11,4 @@ CONFIG_UART_CONSOLE=y
|
|||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_NS16550=y
|
||||
CONFIG_QEMU_ICOUNT_SHIFT=6
|
||||
CONFIG_ARC_MPU_ENABLE=y
|
||||
|
|
|
@ -11,3 +11,4 @@ CONFIG_UART_CONSOLE=y
|
|||
CONFIG_SERIAL=y
|
||||
CONFIG_UART_NS16550=y
|
||||
CONFIG_QEMU_ICOUNT_SHIFT=6
|
||||
CONFIG_ARC_MPU_ENABLE=y
|
||||
|
|
|
@ -27,6 +27,13 @@ config NUM_IRQ_PRIO_LEVELS
|
|||
config NUM_IRQS
|
||||
default 25
|
||||
|
||||
# Technically ARC HS supports MPUv3, but not v2. But given MPUv3
|
||||
# is the same as v2 but with minimal region size of 32 bytes, we
|
||||
# may assume MPUv3 is just a subset of MPUv2.
|
||||
|
||||
config ARC_MPU_VER
|
||||
default 2
|
||||
|
||||
source "soc/arc/snps_qemu/Kconfig.defconfig.em"
|
||||
source "soc/arc/snps_qemu/Kconfig.defconfig.hs"
|
||||
|
||||
|
|
|
@ -4,3 +4,4 @@
|
|||
config SOC_QEMU_ARC
|
||||
bool "QEMU emulation of ARC cores"
|
||||
select ARC
|
||||
select CPU_HAS_MPU
|
||||
|
|
|
@ -16,4 +16,13 @@
|
|||
#define SRAM_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_sram))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* flash base address and size
|
||||
*/
|
||||
#if DT_NODE_HAS_PROP(DT_CHOSEN(zephyr_flash), reg) && \
|
||||
(DT_REG_SIZE(DT_CHOSEN(zephyr_flash)) > 0)
|
||||
#define FLASH_START DT_REG_ADDR(DT_CHOSEN(zephyr_flash))
|
||||
#define FLASH_SIZE DT_REG_SIZE(DT_CHOSEN(zephyr_flash))
|
||||
#endif
|
||||
|
||||
#include <arch/arc/v2/linker.ld>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue