diff options
| author | Richard Qin <richard.qin.x@gmail.com> | 2026-05-13 16:25:58 +0800 |
|---|---|---|
| committer | Richard Qin <richard.qin.x@gmail.com> | 2026-05-13 16:25:58 +0800 |
| commit | b321b8b0180daa74cdd3c1285267702932af7b41 (patch) | |
| tree | 02814f4fc35df18f1be8d4d113994ccbe58ded4d | |
| parent | 6dd868b2919c594760d6cb671c859c1d35f12f2b (diff) | |
| download | lume-b321b8b0180daa74cdd3c1285267702932af7b41.tar.gz lume-b321b8b0180daa74cdd3c1285267702932af7b41.tar.xz | |
feat: add syscall dispatch implementation for RISC-V architecture
| -rw-r--r-- | na/arch/riscv/syscall/syscall_md.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/na/arch/riscv/syscall/syscall_md.cc b/na/arch/riscv/syscall/syscall_md.cc new file mode 100644 index 0000000..a52eb0e --- /dev/null +++ b/na/arch/riscv/syscall/syscall_md.cc @@ -0,0 +1,28 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Copyright (C) 2026 Richard Qin */ + +/* + * Syscall MD Layer — RISC-V Register Extraction + * + * Extracts syscall number (a7) and arguments (a0-a5) from the TrapFrame, + * calls the MI dispatcher, and writes the return value back to a0. + * + * Reference: docs/specs/syscall.md §5 + */ + +#include <lume/syscall.h> +#include <arch/trapframe.h> + +void syscall_dispatch_md(arch::TrapFrame* tf) +{ + uint64 nr = tf->a[7]; /* RISC-V ABI: syscall number in a7 */ + + uint64 args[6] = { + tf->a[0], tf->a[1], tf->a[2], + tf->a[3], tf->a[4], tf->a[5], + }; + + int64 ret = syscall_dispatch(nr, args); + + tf->a[0] = static_cast<uint64>(ret); /* Return value in a0 */ +} |
