mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-16 01:05:15 +08:00
* [libcpu][risc-v] Refactor the RISC-V architecture port Introduce an opt-in unified RISC-V common layer for RV32 and RV64 while keeping existing BSPs on the legacy implementation during migration. - use ARCH_RISCV and ARCH_CPU_64BIT for architecture and XLEN selection - unify context, trap, MMU, cache, timer, SBI, SMP and ISA handling - add PLIC, CLIC, ACLINT, APLIC and IMSIC support - map physical hart IDs to contiguous logical CPU IDs - add T-Head vendor overrides while preserving legacy ports - migrate qemu-virt64-riscv with RV32 and RV64 support - update clock_time, MM, LWP, OFW, PCI and Rust integration Existing BSPs continue using legacy_common or common64 unless they select RT_USING_RISCV_NEW_COMMON. Signed-off-by: GuEe-GUI <2991707448@qq.com> * [libcpu][risc-v] skip disabled CPU nodes in early FDT walk Rbb666 noted that rt_hw_fdt_install_early() walked every /cpus child without checking status, so disabled cores still joined hart registration and MMU capability probing. Skip nodes that are not okay/ok via rt_fdt_device_is_available() before reading reg or mmu-type. Signed-off-by: seteiro <chenmoushun@163.com> * [libcpu][risc-v] Fix per-CPU page table mapping - reuse existing non-leaf page table entries when mapping per-CPU areas - reject leaf entry conflicts instead of overwriting mappings Signed-off-by: GuEe-GUI <2991707448@qq.com> --------- Signed-off-by: GuEe-GUI <2991707448@qq.com> Signed-off-by: seteiro <chenmoushun@163.com> Co-authored-by: seteiro <chenmoushun@163.com>
62 lines
1.5 KiB
C
62 lines
1.5 KiB
C
/*
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*
|
|
* Change Logs:
|
|
* Date Author Notes
|
|
* 2021-02-03 lizhirui first version
|
|
* 2022-11-10 WangXiaoyao Add readable syscall tracing
|
|
*/
|
|
|
|
#include <rthw.h>
|
|
#include <rtthread.h>
|
|
|
|
#define DBG_TAG "syscall"
|
|
#define DBG_LVL DBG_WARNING
|
|
#include <rtdbg.h>
|
|
|
|
#include <mmu.h>
|
|
#include <page.h>
|
|
#include <stack.h>
|
|
#include <lwp_user_mm.h>
|
|
|
|
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)
|
|
{
|
|
const char *syscall_name;
|
|
int syscallid = regs->a7;
|
|
|
|
if (syscallid == 0)
|
|
{
|
|
LOG_E("syscall id = 0!\n");
|
|
|
|
while (RT_TRUE)
|
|
{
|
|
rt_hw_cpu_relax();
|
|
}
|
|
}
|
|
|
|
syscallfunc_t syscallfunc = (syscallfunc_t)lwp_get_sys_api(syscallid);
|
|
|
|
if (syscallfunc == RT_NULL)
|
|
{
|
|
LOG_E("unsupported syscall!\n");
|
|
sys_exit_group(-1);
|
|
}
|
|
|
|
#if DBG_LVL >= DBG_INFO
|
|
syscall_name = lwp_get_syscall_name(syscallid);
|
|
#else
|
|
RT_UNUSED(syscall_name);
|
|
#endif
|
|
|
|
LOG_I("[0x%lx] %s(0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%lx)", rt_thread_self(), syscall_name,
|
|
regs->a0, regs->a1, regs->a2, regs->a3, regs->a4, regs->a5, regs->a6);
|
|
regs->a0 = syscallfunc(regs->a0, regs->a1, regs->a2, regs->a3, regs->a4, regs->a5, regs->a6);
|
|
regs->a7 = 0;
|
|
regs->epc += 4; // skip ecall instruction
|
|
LOG_I("[0x%lx] %s ret: 0x%lx", rt_thread_self(), syscall_name, regs->a0);
|
|
}
|