SimpleKernel 1.17.0
Loading...
Searching...
No Matches
syscall.cpp
Go to the documentation of this file.
1
5#include "syscall.hpp"
6
7#include "interrupt.h"
8#include "kernel_log.hpp"
9
10auto Syscall(uint64_t, cpu_io::TrapContext* context_ptr) -> void {
11 // 获取系统调用号和参数
12 uint64_t syscall_id = 0;
13 uint64_t args[6] = {0};
14
15 syscall_id = context_ptr->a7;
16 args[0] = context_ptr->a0;
17 args[1] = context_ptr->a1;
18 args[2] = context_ptr->a2;
19 args[3] = context_ptr->a3;
20 args[4] = context_ptr->a4;
21 args[5] = context_ptr->a5;
22
23 // 执行处理函数
24 auto ret = syscall_dispatcher(syscall_id, args);
25
26 // 设置返回值
27 context_ptr->a0 = static_cast<uint64_t>(ret);
28 // 跳过 ecall 指令
29 context_ptr->sepc += 4;
30}
auto Syscall(uint64_t, cpu_io::TrapContext *context_ptr) -> void
AArch64 系统调用处理
Definition syscall.cpp:16
auto syscall_dispatcher(int64_t syscall_id, uint64_t args[6]) -> int
Definition syscall.cpp:17