1 #include "syscall.h"
2 #include <stdio.h>
3 #include <errno.h>
syscall_invoke(uint64_t syscall_id,uint64_t arg0,uint64_t arg1,uint64_t arg2,uint64_t arg3,uint64_t arg4,uint64_t arg5,uint64_t arg6,uint64_t arg7)4 long syscall_invoke(uint64_t syscall_id, uint64_t arg0, uint64_t arg1, uint64_t arg2, uint64_t arg3, uint64_t arg4, uint64_t arg5, uint64_t arg6, uint64_t arg7)
5 {
6 uint64_t __err_code;
7 __asm__ __volatile__(
8 "movq %2, %%r8 \n\t"
9 "movq %3, %%r9 \n\t"
10 "movq %4, %%r10 \n\t"
11 "movq %5, %%r11 \n\t"
12 "movq %6, %%r12 \n\t"
13 "movq %7, %%r13 \n\t"
14 "movq %8, %%r14 \n\t"
15 "movq %9, %%r15 \n\t"
16 "int $0x80 \n\t"
17 "movq %%rax, %0 \n\t"
18 :"=a"(__err_code)
19 : "a"(syscall_id), "m"(arg0), "m"(arg1), "m"(arg2), "m"(arg3), "m"(arg4), "m"(arg5), "m"(arg6), "m"(arg7)
20 : "memory", "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", "rcx", "rdx");
21 // printf("errcode = %#018lx\n", __err_code);
22 errno = __err_code;
23
24 return __err_code;
25 }
26