blob: 93fc6137f0faf8a355bc2749331ef9b899e6383a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
#include "arch/context_switching/syscall/main.hpp"
namespace teachos::arch::context_switching::syscall
{
auto syscall(type syscall_number, arguments args) -> error
{
asm volatile("mov %[input], %%rax"
: /* no output from call */
: [input] "m"(syscall_number)
: "memory");
asm volatile("mov %[input], %%rdi " : /* no output from call */ : [input] "m"(args.arg_0) : "memory");
asm volatile("mov %[input], %%rsi" : /* no output from call */ : [input] "m"(args.arg_1) : "memory");
asm volatile("mov %[input], %%rdx" : /* no output from call */ : [input] "m"(args.arg_2) : "memory");
asm volatile("mov %[input], %%r10" : /* no output from call */ : [input] "m"(args.arg_3) : "memory");
asm volatile("mov %[input], %%r8" : /* no output from call */ : [input] "m"(args.arg_4) : "memory");
asm volatile("mov %[input], %%r9" : /* no output from call */ : [input] "m"(args.arg_5) : "memory");
asm volatile("syscall");
error error{};
asm volatile("mov %%rax, %[output]" : [output] "=m"(error));
return error;
}
} // namespace teachos::arch::context_switching::syscall
|