diff options
| author | Shell <[email protected]> | 2024-09-02 18:03:21 +0800 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2024-09-11 18:06:51 -0400 |
| commit | c78a19ed264adf9a5f90180148d3d7cf441f95b1 (patch) | |
| tree | c33f4c65318daa3fb5b7b6585e84cb7f3adc13f8 /libcpu | |
| parent | e244c196c4f1f5a867891df303476947a7769876 (diff) | |
feat: libcpu/risc-v: unify low-level bringups
This patch consolidates the separated architecture-specific code for
rv64 (virt64 and c906) under a more unified approach. The changes
aim to enhance maintainability and code reuse, reducing duplication
between these two architectures while adding small improvements in
porting compatibility.
Changes:
- Modified build scripts (SConscript) for both virt64 and c906 to
remove ASID and vector dependencies when not required.
- Updated c906's sbi.c and sbi.h to use standard integer types
(uint32_t) and include the missing <stdint.h> header.
- Unified inline function declaration for `sbi_call` across both
c906 and virt64 using `rt_inline`.
- Disabled FPU and vector in c906's startup assembly file, aligning it
with the virt64 handling.
- Corrected syscall handler type definitions in c906 for consistency.
Signed-off-by: Shell <[email protected]>
Diffstat (limited to 'libcpu')
| -rw-r--r-- | libcpu/risc-v/t-head/c906/SConscript | 4 | ||||
| -rw-r--r-- | libcpu/risc-v/t-head/c906/sbi.c | 4 | ||||
| -rw-r--r-- | libcpu/risc-v/t-head/c906/sbi.h | 3 | ||||
| -rw-r--r-- | libcpu/risc-v/t-head/c906/startup_gcc.S | 2 | ||||
| -rw-r--r-- | libcpu/risc-v/t-head/c906/syscall_c.c | 2 | ||||
| -rw-r--r-- | libcpu/risc-v/virt64/SConscript | 10 | ||||
| -rw-r--r-- | libcpu/risc-v/virt64/sbi.h | 2 | ||||
| -rw-r--r-- | libcpu/risc-v/virt64/startup_gcc.S | 3 |
8 files changed, 19 insertions, 11 deletions
diff --git a/libcpu/risc-v/t-head/c906/SConscript b/libcpu/risc-v/t-head/c906/SConscript index 194b3268c5..5f750ad65f 100644 --- a/libcpu/risc-v/t-head/c906/SConscript +++ b/libcpu/risc-v/t-head/c906/SConscript @@ -1,11 +1,13 @@ # RT-Thread building script for component from building import * - cwd = GetCurrentDir() src = Glob('*.c') + Glob('*.cpp') + Glob('*_gcc.S') CPPPATH = [cwd] +if not GetDepend('ARCH_USING_ASID'): + SrcRemove(src, ['asid.c']) + group = DefineGroup('libcpu', src, depend = [''], CPPPATH = CPPPATH) Return('group') diff --git a/libcpu/risc-v/t-head/c906/sbi.c b/libcpu/risc-v/t-head/c906/sbi.c index ff5669bb30..b2b1e8e788 100644 --- a/libcpu/risc-v/t-head/c906/sbi.c +++ b/libcpu/risc-v/t-head/c906/sbi.c @@ -68,8 +68,8 @@ static struct sbi_ret sbi_get_impl_version(void) void sbi_print_version(void) { - unsigned int major; - unsigned int minor; + uint32_t major; + uint32_t minor; /* For legacy SBI implementations. */ if (sbi_spec_version == 0) diff --git a/libcpu/risc-v/t-head/c906/sbi.h b/libcpu/risc-v/t-head/c906/sbi.h index ed29ecfd20..45853871a8 100644 --- a/libcpu/risc-v/t-head/c906/sbi.h +++ b/libcpu/risc-v/t-head/c906/sbi.h @@ -48,6 +48,7 @@ #ifndef _MACHINE_SBI_H_ #define _MACHINE_SBI_H_ +#include <stdint.h> #include <rtdef.h> /* SBI Specification Version */ @@ -140,7 +141,7 @@ struct sbi_ret long value; }; -static inline struct sbi_ret +rt_inline struct sbi_ret sbi_call(uint64_t arg7, uint64_t arg6, uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4) { diff --git a/libcpu/risc-v/t-head/c906/startup_gcc.S b/libcpu/risc-v/t-head/c906/startup_gcc.S index 7f25564fb4..184b48a1ae 100644 --- a/libcpu/risc-v/t-head/c906/startup_gcc.S +++ b/libcpu/risc-v/t-head/c906/startup_gcc.S @@ -75,6 +75,8 @@ _start: li x31,0 /* set to disable FPU */ + li t0, SSTATUS_FS + SSTATUS_VS + csrc sstatus, t0 li t0, SSTATUS_SUM csrs sstatus, t0 diff --git a/libcpu/risc-v/t-head/c906/syscall_c.c b/libcpu/risc-v/t-head/c906/syscall_c.c index 2abe1d065b..ceffd94dbc 100644 --- a/libcpu/risc-v/t-head/c906/syscall_c.c +++ b/libcpu/risc-v/t-head/c906/syscall_c.c @@ -26,7 +26,7 @@ #include "riscv_mmu.h" #include "stack.h" -typedef rt_size_t (*syscallfunc_t)(rt_size_t, rt_size_t, rt_size_t, rt_size_t, rt_size_t, rt_size_t, rt_size_t); +typedef rt_ubase_t (*syscallfunc_t)(rt_ubase_t, rt_ubase_t, rt_ubase_t, rt_ubase_t, rt_ubase_t, rt_ubase_t, rt_ubase_t); void syscall_handler(struct rt_hw_stack_frame *regs) { diff --git a/libcpu/risc-v/virt64/SConscript b/libcpu/risc-v/virt64/SConscript index a0d110a43d..5de136c789 100644 --- a/libcpu/risc-v/virt64/SConscript +++ b/libcpu/risc-v/virt64/SConscript @@ -1,14 +1,16 @@ # RT-Thread building script for component from building import * - -Import('rtconfig') - cwd = GetCurrentDir() src = Glob('*.c') + Glob('*.cpp') + Glob('*_gcc.S') -src = src + ['../common/atomic_riscv.c'] CPPPATH = [cwd] +if not GetDepend('ARCH_USING_ASID'): + SrcRemove(src, ['asid.c']) + +if not GetDepend('ARCH_RISCV_VECTOR'): + SrcRemove(src, ['vector_gcc.S']) + group = DefineGroup('libcpu', src, depend = [''], CPPPATH = CPPPATH) Return('group') diff --git a/libcpu/risc-v/virt64/sbi.h b/libcpu/risc-v/virt64/sbi.h index be54dede72..45853871a8 100644 --- a/libcpu/risc-v/virt64/sbi.h +++ b/libcpu/risc-v/virt64/sbi.h @@ -141,7 +141,7 @@ struct sbi_ret long value; }; -static __inline struct sbi_ret +rt_inline struct sbi_ret sbi_call(uint64_t arg7, uint64_t arg6, uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4) { diff --git a/libcpu/risc-v/virt64/startup_gcc.S b/libcpu/risc-v/virt64/startup_gcc.S index cfa39f8535..184b48a1ae 100644 --- a/libcpu/risc-v/virt64/startup_gcc.S +++ b/libcpu/risc-v/virt64/startup_gcc.S @@ -8,6 +8,7 @@ * 2018/10/01 Bernard The first version * 2018/12/27 Jesven Add SMP support * 2020/6/12 Xim Port to QEMU and remove SMP support + * 2024-06-30 Shell Support of kernel remapping */ #include <encoding.h> @@ -15,7 +16,7 @@ .data .global boot_hartid /* global varible rt_boot_hartid in .data section */ -boot_hartid: +boot_hartid: .word 0xdeadbeef .global _start |
