Skip to content

Commit 29764d3

Browse files
committed
[BSP/QEMU-VIRT-RISCV64] Port to the next RISC-V
1. VirtIO DM (NET, BLK, CONSOLE, RNG, RPMSG, SCSI, GPU, INPUT, CRYPTO). 2. Serial 8250 OFW. 3. MTD-CFI. 4. RTC-Goldfish. 5. ECAM generic PCI. 6. Syscon Reboot and Poweroff. 7. QEMU FW-CFG. 8. RISC-V AIA (APLIC, IMSIC), PLIC, INTC, ACLINT/CLINT. 9. PCI device (WDT, NVME, ATA, SDHCI)... Signed-off-by: GuEe-GUI <2991707448@qq.com>
1 parent 6e70c16 commit 29764d3

29 files changed

+833
-1201
lines changed

bsp/qemu-virt64-riscv/.config

Lines changed: 352 additions & 68 deletions
Large diffs are not rendered by default.

bsp/qemu-virt64-riscv/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
mnt.c
22
romfs_data.c
33
opensbi
4+
*.qcow2

bsp/qemu-virt64-riscv/Kconfig

Lines changed: 8 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -6,52 +6,21 @@ RTT_DIR := ../../
66

77
PKGS_DIR := packages
88

9+
SOC_DM_PIC_DIR := $(RTT_DIR)/libcpu/risc-v/common/pic
10+
SOC_DM_SERIAL_DIR := $(RTT_DIR)/libcpu/risc-v/common/serial
11+
912
source "$(RTT_DIR)/Kconfig"
1013
osource "$PKGS_DIR/Kconfig"
11-
rsource "driver/Kconfig"
1214

13-
config BOARD_QEMU_VIRT_RV64
15+
config SOC_VIRT64_RISCV64
1416
bool
15-
select ARCH_RISCV64
17+
select ARCH_RISCV
18+
select ARCH_CPU_64BIT
1619
select ARCH_USING_RISCV_COMMON64
1720
select RT_USING_COMPONENTS_INIT
1821
select RT_USING_USER_MAIN
1922
select RT_USING_CACHE
2023
select ARCH_MM_MMU
21-
select ARCH_REMAP_KERNEL
22-
default y
23-
24-
config ENABLE_FPU
25-
bool "Enable FPU"
26-
select ARCH_RISCV_FPU
24+
select ARCH_REMAP_KERNEL if RT_USING_SMART
25+
select RT_USING_STDC_ATOMIC
2726
default y
28-
29-
config ENABLE_VECTOR
30-
bool "Using RISC-V Vector Extension"
31-
select ARCH_RISCV_VECTOR
32-
default n
33-
34-
if ENABLE_VECTOR
35-
choice
36-
prompt "Vector Registers Length in Bits"
37-
default ARCH_VECTOR_VLEN_128
38-
39-
config ARCH_VECTOR_VLEN_128
40-
bool "128"
41-
42-
config ARCH_VECTOR_VLEN_256
43-
bool "256"
44-
endchoice
45-
endif
46-
47-
config RT_USING_USERSPACE_32BIT_LIMIT
48-
bool "Enable userspace 32bit limit"
49-
default n
50-
51-
config RT_USING_VIRTIO_MMIO_ALIGN
52-
bool "Open packed attribution, this may caused an error on virtio"
53-
default n
54-
55-
config __STACKSIZE__
56-
int "stack size for interrupt"
57-
default 4096

bsp/qemu-virt64-riscv/SConstruct

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,9 @@ env['ASCOM'] = env['ASPPCOM']
2121

2222
Export('RTT_ROOT')
2323
Export('rtconfig')
24-
rtconfig.CPU='virt64'
25-
rtconfig.ARCH='risc-v'
2624

2725
# prepare building environment
2826
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu = False)
2927

30-
stack_size = 4096
31-
32-
if GetDepend('RT_USING_SMART'):
33-
# use smart link.lds
34-
env['LINKFLAGS'] = env['LINKFLAGS'].replace('link.lds', 'link_smart.lds')
35-
36-
stack_lds = open('link_stacksize.lds', 'w')
37-
if GetDepend('__STACKSIZE__'): stack_size = GetDepend('__STACKSIZE__')
38-
stack_lds.write('__STACKSIZE__ = %d;\n' % stack_size)
39-
stack_lds.close()
40-
4128
# make a building
4229
DoBuilding(TARGET, objs)

bsp/qemu-virt64-riscv/applications/mnt.c

Lines changed: 0 additions & 42 deletions
This file was deleted.

bsp/qemu-virt64-riscv/driver/Kconfig

Lines changed: 0 additions & 43 deletions
This file was deleted.

bsp/qemu-virt64-riscv/driver/asm/sbiasm.h

Lines changed: 0 additions & 10 deletions
This file was deleted.

bsp/qemu-virt64-riscv/driver/asm/sbidef.h

Lines changed: 0 additions & 27 deletions
This file was deleted.

bsp/qemu-virt64-riscv/driver/board.c

Lines changed: 3 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -6,104 +6,12 @@
66
* Change Logs:
77
* Date Author Notes
88
* 2021-01-30 lizhirui first version
9+
* 2025-04-26 GuEe-GUI init common
910
*/
1011

11-
#include <rthw.h>
12-
#include <rtthread.h>
13-
#include <rtdevice.h>
14-
15-
#include "board.h"
16-
#include "mm_aspace.h"
17-
#include "tick.h"
18-
19-
#include "drv_uart.h"
20-
#include "encoding.h"
21-
#include "stack.h"
22-
#include "sbi.h"
23-
#include "riscv.h"
24-
#include "plic.h"
25-
#include "stack.h"
26-
27-
#ifdef RT_USING_SMART
28-
#include "riscv_mmu.h"
29-
#include "mmu.h"
30-
#include "page.h"
31-
#include "lwp_arch.h"
32-
33-
rt_region_t init_page_region = {(rt_size_t)RT_HW_PAGE_START, (rt_size_t)RT_HW_PAGE_END};
34-
35-
extern size_t MMUTable[];
36-
37-
struct mem_desc platform_mem_desc[] = {
38-
{KERNEL_VADDR_START, (rt_size_t)RT_HW_PAGE_END - 1, (rt_size_t)ARCH_MAP_FAILED, NORMAL_MEM},
39-
};
40-
41-
#define NUM_MEM_DESC (sizeof(platform_mem_desc) / sizeof(platform_mem_desc[0]))
42-
43-
#endif
44-
45-
void primary_cpu_entry(void)
46-
{
47-
/* disable global interrupt */
48-
rt_hw_interrupt_disable();
49-
50-
entry();
51-
}
52-
53-
#define IOREMAP_SIZE (1ul << 30)
54-
55-
#ifndef ARCH_REMAP_KERNEL
56-
#define IOREMAP_VEND USER_VADDR_START
57-
#else
58-
#define IOREMAP_VEND 0ul
59-
#endif /* ARCH_REMAP_KERNEL */
12+
#include <setup.h>
6013

6114
void rt_hw_board_init(void)
6215
{
63-
#ifdef RT_USING_SMART
64-
/* init data structure */
65-
rt_hw_mmu_map_init(&rt_kernel_space, (void *)(IOREMAP_VEND - IOREMAP_SIZE), IOREMAP_SIZE, (rt_size_t *)MMUTable, PV_OFFSET);
66-
67-
/* init page allocator */
68-
rt_page_init(init_page_region);
69-
70-
/* setup region, and enable MMU */
71-
rt_hw_mmu_setup(&rt_kernel_space, platform_mem_desc, NUM_MEM_DESC);
72-
#endif
73-
74-
#ifdef RT_USING_HEAP
75-
/* initialize memory system */
76-
rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
77-
#endif
78-
79-
plic_init();
80-
81-
rt_hw_interrupt_init();
82-
83-
rt_hw_uart_init();
84-
85-
#ifdef RT_USING_CONSOLE
86-
/* set console device */
87-
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
88-
#endif /* RT_USING_CONSOLE */
89-
90-
rt_hw_tick_init();
91-
92-
#ifdef RT_USING_COMPONENTS_INIT
93-
rt_components_board_init();
94-
#endif
95-
96-
#ifdef RT_USING_HEAP
97-
rt_kprintf("heap: [0x%08x - 0x%08x]\n", (rt_ubase_t)RT_HW_HEAP_BEGIN, (rt_ubase_t)RT_HW_HEAP_END);
98-
#endif /* RT_USING_HEAP */
16+
rt_hw_common_setup();
9917
}
100-
101-
void rt_hw_cpu_reset(void)
102-
{
103-
sbi_shutdown();
104-
105-
while (1)
106-
;
107-
}
108-
MSH_CMD_EXPORT_ALIAS(rt_hw_cpu_reset, reboot, reset machine);
109-

bsp/qemu-virt64-riscv/driver/board.h

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,6 @@
1313

1414
#include <rtconfig.h>
1515

16-
extern unsigned int __bss_start;
17-
extern unsigned int __bss_end;
18-
19-
#ifndef RT_USING_SMART
20-
#define KERNEL_VADDR_START 0x0
21-
#endif
22-
23-
#define VIRT64_SBI_MEMSZ (0x200000)
24-
25-
#define RT_HW_HEAP_BEGIN ((void *)&__bss_end)
26-
#define RT_HW_HEAP_END ((void *)(RT_HW_HEAP_BEGIN + 64 * 1024 * 1024))
27-
#define RT_HW_PAGE_START RT_HW_HEAP_END
28-
#define RT_HW_PAGE_END ((void *)(KERNEL_VADDR_START + (256 * 1024 * 1024 - VIRT64_SBI_MEMSZ)))
29-
3016
void rt_hw_board_init(void);
31-
void rt_init_user_mem(struct rt_thread *thread, const char *name,
32-
unsigned long *entry);
3317

34-
#endif
18+
#endif /* BOARD_H__ */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy