soc: renode: Add cortex_r8_virtual

Add virtual Cortex R8 SoC. This target does not represent a real SoC,
but can be easily run in Renode.

This will allow to easily test basic architecture support.

Signed-off-by: Krzysztof Sychla <ksychla@antmicro.com>
Signed-off-by: Marek Slowinski <mslowinski@antmicro.com>
Signed-off-by: Piotr Zierhoffer <pzierhoffer@antmicro.com>
Signed-off-by: Mateusz Hołenko <mholenko@antmicro.com>
This commit is contained in:
Krzysztof Sychla 2024-03-27 14:54:24 +01:00 committed by Alberto Escolar
commit dc433dd6bd
9 changed files with 222 additions and 0 deletions

View file

@ -0,0 +1,13 @@
# Copyright (c) 2024 Antmicro <www.antmicro.com>
# SPDX-License-Identifier: Apache-2.0
zephyr_sources(soc.c)
zephyr_sources_ifdef(
CONFIG_ARM_MPU
arm_mpu_regions.c
)
zephyr_include_directories(.)
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld CACHE INTERNAL "")

View file

@ -0,0 +1,9 @@
# Copyright (c) 2024 Antmicro <www.antmicro.com>
# SPDX-License-Identifier: Apache-2.0
config SOC_CORTEX_R8_VIRTUAL
select ARM
select CPU_CORTEX_R8
select PLATFORM_SPECIFIC_INIT
select CPU_HAS_ARM_MPU
select VFP_DP_D16

View file

@ -0,0 +1,20 @@
# Copyright (c) 2024 Antmicro <www.antmicro.com>
# SPDX-License-Identifier: Apache-2.0
if SOC_CORTEX_R8_VIRTUAL
config NUM_IRQS
default 220
config SYS_CLOCK_HW_CYCLES_PER_SEC
default 5000000
DT_CHOSEN_Z_FLASH := zephyr,flash
config FLASH_SIZE
default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_FLASH),0,K)
config FLASH_BASE_ADDRESS
default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_FLASH))
endif # SOC_CORTEX_R8_VIRTUAL

View file

@ -0,0 +1,10 @@
# Copyright (c) 2024 Antmicro <www.antmicro.com>
# SPDX-License-Identifier: Apache-2.0
config SOC_CORTEX_R8_VIRTUAL
bool
help
Cortex R8 Virtual system implementation
config SOC
default "cortex_r8_virtual" if SOC_CORTEX_R8_VIRTUAL

View file

@ -0,0 +1,66 @@
/* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2021 Lexmark International, Inc.
* Copyright (c) 2024 Antmicro <www.antmicro.com>
*/
#include <zephyr/kernel.h>
#include <zephyr/arch/arm/mpu/arm_mpu.h>
#define MPUTYPE_READ_ONLY \
{ \
.rasr = (P_RO_U_RO_Msk \
| (7 << MPU_RASR_TEX_Pos) \
| MPU_RASR_C_Msk \
| MPU_RASR_B_Msk \
| MPU_RASR_XN_Msk) \
}
#define MPUTYPE_READ_ONLY_PRIV \
{ \
.rasr = (P_RO_U_RO_Msk \
| (5 << MPU_RASR_TEX_Pos) \
| MPU_RASR_B_Msk) \
}
#define MPUTYPE_PRIV_WBWACACHE_XN \
{ \
.rasr = (P_RW_U_NA_Msk \
| (5 << MPU_RASR_TEX_Pos) \
| MPU_RASR_B_Msk \
| MPU_RASR_XN_Msk) \
}
#define MPUTYPE_PRIV_DEVICE \
{ \
.rasr = (P_RW_U_NA_Msk \
| (2 << MPU_RASR_TEX_Pos)) \
}
extern uint32_t _image_rom_end_order;
static const struct arm_mpu_region mpu_regions[] = {
MPU_REGION_ENTRY("FLASH0",
0xc0000000,
REGION_32M,
MPUTYPE_READ_ONLY),
MPU_REGION_ENTRY("SRAM_PRIV",
0x00000000,
REGION_2G,
MPUTYPE_PRIV_WBWACACHE_XN),
MPU_REGION_ENTRY("SRAM",
0x00000000,
((uint32_t)&_image_rom_end_order),
MPUTYPE_READ_ONLY_PRIV),
MPU_REGION_ENTRY("REGISTERS",
0xf8000000,
REGION_128M,
MPUTYPE_PRIV_DEVICE),
};
const struct arm_mpu_config mpu_config = {
.num_regions = ARRAY_SIZE(mpu_regions),
.mpu_regions = mpu_regions,
};

View file

@ -0,0 +1,23 @@
/*
* Copyright (c) 2019 Lexmark International, Inc.
* Copyright (c) 2024 Antmicro <www.antmicro.com>
*
* SPDX-License-Identifier: Apache-2.0
*
*/
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <cmsis_core.h>
void z_arm_platform_init(void)
{
/*
* Use normal exception vectors address range (0x0-0x1C).
*/
unsigned int sctlr = __get_SCTLR();
sctlr &= ~SCTLR_V_Msk;
__set_SCTLR(sctlr);
}

View file

@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 Antmicro <www.antmicro.com>
*
* SPDX-License-Identifier: Apache-2.0
*
*/
#ifndef ZEPHYR_SOC_CORTEX_R8_VIRTUAL_SOC_H_
#define ZEPHYR_SOC_CORTEX_R8_VIRTUAL_SOC_H_
#define __CR_REV 1U
#define __GIC_PRESENT 0U
#define __TIM_PRESENT 0U
#endif /* ZEPHYR_SOC_CORTEX_R8_VIRTUAL_SOC_H_ */

View file

@ -0,0 +1,2 @@
socs:
- name: cortex_r8_virtual