Add RV64 support.

Signed-off-by: Wang Chen <wangchen20@iscas.ac.cn>
This commit is contained in:
Wang Chen
2024-03-27 17:40:52 +08:00
committed by Chen Wang
parent f343f9a41f
commit 504838dc04
6 changed files with 37 additions and 0 deletions

View File

@@ -1,6 +1,12 @@
#ifdef CONFIG_RV64
#define LOAD ld
#define STORE sd
#define SIZE_REG 8
#else
#define LOAD lw
#define STORE sw
#define SIZE_REG 4
#endif
# Save all General-Purpose(GP) registers to context.
# struct context *base = &ctx_task;

View File

@@ -1,4 +1,8 @@
#ifdef CONFIG_RV64
#define SIZE_PTR .dword
#else
#define SIZE_PTR .word
#endif
.section .rodata
.global HEAP_START

View File

@@ -93,8 +93,13 @@ static inline void w_mie(reg_t x)
}
/* Machine-mode Cause Masks */
#ifdef CONFIG_RV64
#define MCAUSE_MASK_INTERRUPT (reg_t)0x8000000000000000
#define MCAUSE_MASK_ECODE (reg_t)0x7FFFFFFFFFFFFFFF
#else
#define MCAUSE_MASK_INTERRUPT (reg_t)0x80000000
#define MCAUSE_MASK_ECODE (reg_t)0x7FFFFFFF
#endif
static inline reg_t r_mcause()
{

View File

@@ -9,7 +9,12 @@ typedef unsigned long long uint64_t;
/*
* Register Width
*/
#ifdef CONFIG_RV64
typedef uint64_t reg_t;
typedef uint64_t ptr_t;
#else
typedef uint32_t reg_t;
typedef uint32_t ptr_t;
#endif
#endif /* __TYPES_H__ */

View File

@@ -2,15 +2,25 @@
# This file will be included by the Makefile of each project.
# Custom Macro Definition (Common part)
ARCH = RV64
include ../defines.mk
DEFS +=
CROSS_COMPILE = riscv64-unknown-elf-
CFLAGS += -nostdlib -fno-builtin -g -Wall
ifeq (${ARCH}, RV64)
CFLAGS += -march=rv64g -mabi=lp64 -mcmodel=medany
else
CFLAGS += -march=rv32g -mabi=ilp32
endif
ifeq (${ARCH}, RV64)
QEMU = qemu-system-riscv64
else
QEMU = qemu-system-riscv32
endif
QFLAGS = -nographic -smp 1 -machine virt -bios none
GDB = gdb-multiarch

View File

@@ -2,6 +2,13 @@
# Support customization in the Makefile files for each project separately.
# And also support customization in common.mk
ifeq (${ARCH}, RV64)
DEFS += -DCONFIG_RV64
else
# RV32 or default is 32bit
DEFS += -DCONFIG_RV32
endif
ifeq (${SYSCALL}, y)
DEFS += -DCONFIG_SYSCALL
endif