Skip to content

[ARCH/RISC-V] Next RISC-V #10320

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
420 changes: 352 additions & 68 deletions bsp/qemu-virt64-riscv/.config

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions bsp/qemu-virt64-riscv/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
mnt.c
romfs_data.c
opensbi
*.qcow2
47 changes: 8 additions & 39 deletions bsp/qemu-virt64-riscv/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,52 +6,21 @@ RTT_DIR := ../../

PKGS_DIR := packages

SOC_DM_PIC_DIR := $(RTT_DIR)/libcpu/risc-v/common/pic
SOC_DM_SERIAL_DIR := $(RTT_DIR)/libcpu/risc-v/common/serial

source "$(RTT_DIR)/Kconfig"
osource "$PKGS_DIR/Kconfig"
rsource "driver/Kconfig"

config BOARD_QEMU_VIRT_RV64
config SOC_VIRT64_RISCV64
bool
select ARCH_RISCV64
select ARCH_RISCV
select ARCH_CPU_64BIT
select ARCH_USING_RISCV_COMMON64
select RT_USING_COMPONENTS_INIT
select RT_USING_USER_MAIN
select RT_USING_CACHE
select ARCH_MM_MMU
select ARCH_REMAP_KERNEL
default y

config ENABLE_FPU
bool "Enable FPU"
select ARCH_RISCV_FPU
select ARCH_REMAP_KERNEL if RT_USING_SMART
select RT_USING_STDC_ATOMIC
default y

config ENABLE_VECTOR
bool "Using RISC-V Vector Extension"
select ARCH_RISCV_VECTOR
default n

if ENABLE_VECTOR
choice
prompt "Vector Registers Length in Bits"
default ARCH_VECTOR_VLEN_128

config ARCH_VECTOR_VLEN_128
bool "128"

config ARCH_VECTOR_VLEN_256
bool "256"
endchoice
endif

config RT_USING_USERSPACE_32BIT_LIMIT
bool "Enable userspace 32bit limit"
default n

config RT_USING_VIRTIO_MMIO_ALIGN
bool "Open packed attribution, this may caused an error on virtio"
default n

config __STACKSIZE__
int "stack size for interrupt"
default 4096
13 changes: 0 additions & 13 deletions bsp/qemu-virt64-riscv/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,9 @@ env['ASCOM'] = env['ASPPCOM']

Export('RTT_ROOT')
Export('rtconfig')
rtconfig.CPU='virt64'
rtconfig.ARCH='risc-v'

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

stack_size = 4096

if GetDepend('RT_USING_SMART'):
# use smart link.lds
env['LINKFLAGS'] = env['LINKFLAGS'].replace('link.lds', 'link_smart.lds')

stack_lds = open('link_stacksize.lds', 'w')
if GetDepend('__STACKSIZE__'): stack_size = GetDepend('__STACKSIZE__')
stack_lds.write('__STACKSIZE__ = %d;\n' % stack_size)
stack_lds.close()

# make a building
DoBuilding(TARGET, objs)
42 changes: 0 additions & 42 deletions bsp/qemu-virt64-riscv/applications/mnt.c

This file was deleted.

43 changes: 0 additions & 43 deletions bsp/qemu-virt64-riscv/driver/Kconfig

This file was deleted.

10 changes: 0 additions & 10 deletions bsp/qemu-virt64-riscv/driver/asm/sbiasm.h

This file was deleted.

27 changes: 0 additions & 27 deletions bsp/qemu-virt64-riscv/driver/asm/sbidef.h

This file was deleted.

98 changes: 3 additions & 95 deletions bsp/qemu-virt64-riscv/driver/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,104 +6,12 @@
* Change Logs:
* Date Author Notes
* 2021-01-30 lizhirui first version
* 2025-04-26 GuEe-GUI init common
*/

#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>

#include "board.h"
#include "mm_aspace.h"
#include "tick.h"

#include "drv_uart.h"
#include "encoding.h"
#include "stack.h"
#include "sbi.h"
#include "riscv.h"
#include "plic.h"
#include "stack.h"

#ifdef RT_USING_SMART
#include "riscv_mmu.h"
#include "mmu.h"
#include "page.h"
#include "lwp_arch.h"

rt_region_t init_page_region = {(rt_size_t)RT_HW_PAGE_START, (rt_size_t)RT_HW_PAGE_END};

extern size_t MMUTable[];

struct mem_desc platform_mem_desc[] = {
{KERNEL_VADDR_START, (rt_size_t)RT_HW_PAGE_END - 1, (rt_size_t)ARCH_MAP_FAILED, NORMAL_MEM},
};

#define NUM_MEM_DESC (sizeof(platform_mem_desc) / sizeof(platform_mem_desc[0]))

#endif

void primary_cpu_entry(void)
{
/* disable global interrupt */
rt_hw_interrupt_disable();

entry();
}

#define IOREMAP_SIZE (1ul << 30)

#ifndef ARCH_REMAP_KERNEL
#define IOREMAP_VEND USER_VADDR_START
#else
#define IOREMAP_VEND 0ul
#endif /* ARCH_REMAP_KERNEL */
#include <setup.h>

void rt_hw_board_init(void)
{
#ifdef RT_USING_SMART
/* init data structure */
rt_hw_mmu_map_init(&rt_kernel_space, (void *)(IOREMAP_VEND - IOREMAP_SIZE), IOREMAP_SIZE, (rt_size_t *)MMUTable, PV_OFFSET);

/* init page allocator */
rt_page_init(init_page_region);

/* setup region, and enable MMU */
rt_hw_mmu_setup(&rt_kernel_space, platform_mem_desc, NUM_MEM_DESC);
#endif

#ifdef RT_USING_HEAP
/* initialize memory system */
rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
#endif

plic_init();

rt_hw_interrupt_init();

rt_hw_uart_init();

#ifdef RT_USING_CONSOLE
/* set console device */
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
#endif /* RT_USING_CONSOLE */

rt_hw_tick_init();

#ifdef RT_USING_COMPONENTS_INIT
rt_components_board_init();
#endif

#ifdef RT_USING_HEAP
rt_kprintf("heap: [0x%08x - 0x%08x]\n", (rt_ubase_t)RT_HW_HEAP_BEGIN, (rt_ubase_t)RT_HW_HEAP_END);
#endif /* RT_USING_HEAP */
rt_hw_common_setup();
}

void rt_hw_cpu_reset(void)
{
sbi_shutdown();

while (1)
;
}
MSH_CMD_EXPORT_ALIAS(rt_hw_cpu_reset, reboot, reset machine);

18 changes: 1 addition & 17 deletions bsp/qemu-virt64-riscv/driver/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,6 @@

#include <rtconfig.h>

extern unsigned int __bss_start;
extern unsigned int __bss_end;

#ifndef RT_USING_SMART
#define KERNEL_VADDR_START 0x0
#endif

#define VIRT64_SBI_MEMSZ (0x200000)

#define RT_HW_HEAP_BEGIN ((void *)&__bss_end)
#define RT_HW_HEAP_END ((void *)(RT_HW_HEAP_BEGIN + 64 * 1024 * 1024))
#define RT_HW_PAGE_START RT_HW_HEAP_END
#define RT_HW_PAGE_END ((void *)(KERNEL_VADDR_START + (256 * 1024 * 1024 - VIRT64_SBI_MEMSZ)))

void rt_hw_board_init(void);
void rt_init_user_mem(struct rt_thread *thread, const char *name,
unsigned long *entry);

#endif
#endif /* BOARD_H__ */
20 changes: 20 additions & 0 deletions bsp/qemu-virt64-riscv/driver/drv_romfb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-02-25 GuEe-GUI the first version
*/

#include <rtthread.h>
#include <rtdevice.h>

void platform_get_ramfb_params(rt_uint32_t *width, rt_uint32_t *height)
{
*width = 800;
*height = 600;
}

#include "../../../examples/test/hmi_test.c"
Loading
Loading