Skip to content

Commit dc433dd

Browse files
ksychlaaescolar
authored andcommitted
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 <[email protected]> Signed-off-by: Marek Slowinski <[email protected]> Signed-off-by: Piotr Zierhoffer <[email protected]> Signed-off-by: Mateusz Hołenko <[email protected]>
1 parent 5d76b56 commit dc433dd

File tree

9 files changed

+222
-0
lines changed

9 files changed

+222
-0
lines changed

dts/arm/cortex_r8_virt.dtsi

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* Copyright (c) 2024 Antmicro <www.antmicro.com>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/dt-bindings/interrupt-controller/arm-gic.h>
8+
9+
/ {
10+
#address-cells = <1>;
11+
#size-cells = <1>;
12+
13+
cpus {
14+
#address-cells = <1>;
15+
#size-cells = <0>;
16+
cpu@0 {
17+
device_type = "cpu";
18+
compatible = "arm,cortex-r8f";
19+
reg = <0>;
20+
};
21+
};
22+
soc {
23+
#address-cells = <1>;
24+
#size-cells = <1>;
25+
compatible = "simple-bus";
26+
ranges;
27+
interrupt-parent = < &gic >;
28+
flash0: flash@c0000000 {
29+
compatible = "soc-nv-flash";
30+
reg = < 0xc0000000 0x2000000 >;
31+
};
32+
sram0: memory@0 {
33+
compatible = "mmio-sram";
34+
reg = < 0x0 0x4000000 >;
35+
};
36+
uart0: uart@ff000000 {
37+
compatible = "xlnx,xuartps";
38+
reg = < 0xff000000 0x4c >;
39+
status = "disabled";
40+
interrupts = <GIC_SPI 21 IRQ_TYPE_LEVEL
41+
IRQ_DEFAULT_PRIORITY>;
42+
interrupt-names = "irq_0";
43+
};
44+
ttc0: timer@ff110000 {
45+
compatible = "xlnx,ttcps";
46+
status = "okay";
47+
interrupts = < 0x0 0x24 0x2 0xa0 >,
48+
< 0x0 0x25 0x2 0xa0 >,
49+
< 0x0 0x26 0x2 0xa0 >;
50+
interrupt-names = "irq_0", "irq_1", "irq_2";
51+
reg = < 0xff110000 0x1000 >;
52+
clock-frequency = < 5000000 >;
53+
};
54+
gic: interrupt-controller@f9000000 {
55+
compatible = "arm,gic-v1", "arm,gic";
56+
reg = < 0xf9000000 0x1000 >, < 0xf9001000 0x100 >;
57+
interrupt-controller;
58+
#interrupt-cells = < 0x4 >;
59+
status = "okay";
60+
phandle = < 0x1 >;
61+
};
62+
};
63+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Copyright (c) 2024 Antmicro <www.antmicro.com>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
zephyr_sources(soc.c)
5+
6+
zephyr_sources_ifdef(
7+
CONFIG_ARM_MPU
8+
arm_mpu_regions.c
9+
)
10+
11+
zephyr_include_directories(.)
12+
13+
set(SOC_LINKER_SCRIPT ${ZEPHYR_BASE}/include/zephyr/arch/arm/cortex_a_r/scripts/linker.ld CACHE INTERNAL "")

soc/renode/cortex_r8_virtual/Kconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2024 Antmicro <www.antmicro.com>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SOC_CORTEX_R8_VIRTUAL
5+
select ARM
6+
select CPU_CORTEX_R8
7+
select PLATFORM_SPECIFIC_INIT
8+
select CPU_HAS_ARM_MPU
9+
select VFP_DP_D16
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Copyright (c) 2024 Antmicro <www.antmicro.com>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
if SOC_CORTEX_R8_VIRTUAL
5+
6+
config NUM_IRQS
7+
default 220
8+
9+
config SYS_CLOCK_HW_CYCLES_PER_SEC
10+
default 5000000
11+
12+
DT_CHOSEN_Z_FLASH := zephyr,flash
13+
14+
config FLASH_SIZE
15+
default $(dt_chosen_reg_size_int,$(DT_CHOSEN_Z_FLASH),0,K)
16+
17+
config FLASH_BASE_ADDRESS
18+
default $(dt_chosen_reg_addr_hex,$(DT_CHOSEN_Z_FLASH))
19+
20+
endif # SOC_CORTEX_R8_VIRTUAL
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Copyright (c) 2024 Antmicro <www.antmicro.com>
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
config SOC_CORTEX_R8_VIRTUAL
5+
bool
6+
help
7+
Cortex R8 Virtual system implementation
8+
9+
config SOC
10+
default "cortex_r8_virtual" if SOC_CORTEX_R8_VIRTUAL
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
/* SPDX-License-Identifier: Apache-2.0
2+
*
3+
* Copyright (c) 2021 Lexmark International, Inc.
4+
* Copyright (c) 2024 Antmicro <www.antmicro.com>
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/arch/arm/mpu/arm_mpu.h>
9+
10+
#define MPUTYPE_READ_ONLY \
11+
{ \
12+
.rasr = (P_RO_U_RO_Msk \
13+
| (7 << MPU_RASR_TEX_Pos) \
14+
| MPU_RASR_C_Msk \
15+
| MPU_RASR_B_Msk \
16+
| MPU_RASR_XN_Msk) \
17+
}
18+
19+
#define MPUTYPE_READ_ONLY_PRIV \
20+
{ \
21+
.rasr = (P_RO_U_RO_Msk \
22+
| (5 << MPU_RASR_TEX_Pos) \
23+
| MPU_RASR_B_Msk) \
24+
}
25+
26+
#define MPUTYPE_PRIV_WBWACACHE_XN \
27+
{ \
28+
.rasr = (P_RW_U_NA_Msk \
29+
| (5 << MPU_RASR_TEX_Pos) \
30+
| MPU_RASR_B_Msk \
31+
| MPU_RASR_XN_Msk) \
32+
}
33+
34+
#define MPUTYPE_PRIV_DEVICE \
35+
{ \
36+
.rasr = (P_RW_U_NA_Msk \
37+
| (2 << MPU_RASR_TEX_Pos)) \
38+
}
39+
40+
extern uint32_t _image_rom_end_order;
41+
static const struct arm_mpu_region mpu_regions[] = {
42+
MPU_REGION_ENTRY("FLASH0",
43+
0xc0000000,
44+
REGION_32M,
45+
MPUTYPE_READ_ONLY),
46+
47+
MPU_REGION_ENTRY("SRAM_PRIV",
48+
0x00000000,
49+
REGION_2G,
50+
MPUTYPE_PRIV_WBWACACHE_XN),
51+
52+
MPU_REGION_ENTRY("SRAM",
53+
0x00000000,
54+
((uint32_t)&_image_rom_end_order),
55+
MPUTYPE_READ_ONLY_PRIV),
56+
57+
MPU_REGION_ENTRY("REGISTERS",
58+
0xf8000000,
59+
REGION_128M,
60+
MPUTYPE_PRIV_DEVICE),
61+
};
62+
63+
const struct arm_mpu_config mpu_config = {
64+
.num_regions = ARRAY_SIZE(mpu_regions),
65+
.mpu_regions = mpu_regions,
66+
};

soc/renode/cortex_r8_virtual/soc.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright (c) 2019 Lexmark International, Inc.
3+
* Copyright (c) 2024 Antmicro <www.antmicro.com>
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*
7+
*/
8+
9+
#include <zephyr/kernel.h>
10+
#include <zephyr/device.h>
11+
12+
#include <cmsis_core.h>
13+
14+
void z_arm_platform_init(void)
15+
{
16+
/*
17+
* Use normal exception vectors address range (0x0-0x1C).
18+
*/
19+
unsigned int sctlr = __get_SCTLR();
20+
21+
sctlr &= ~SCTLR_V_Msk;
22+
__set_SCTLR(sctlr);
23+
}

soc/renode/cortex_r8_virtual/soc.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2024 Antmicro <www.antmicro.com>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
*/
7+
8+
#ifndef ZEPHYR_SOC_CORTEX_R8_VIRTUAL_SOC_H_
9+
#define ZEPHYR_SOC_CORTEX_R8_VIRTUAL_SOC_H_
10+
11+
#define __CR_REV 1U
12+
13+
#define __GIC_PRESENT 0U
14+
#define __TIM_PRESENT 0U
15+
16+
#endif /* ZEPHYR_SOC_CORTEX_R8_VIRTUAL_SOC_H_ */

soc/renode/cortex_r8_virtual/soc.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
socs:
2+
- name: cortex_r8_virtual

0 commit comments

Comments
 (0)