2 #include <lunaix/syscall.h>
3 #include "sys/interrupt64.S.inc"
7 注意,这里的顺序非常重要。每个系统调用在这个地址表里的索引等于其调用号。
12 .8byte __lxsys_fork /* 1 */
16 .8byte __lxsys_getpid /* 5 */
17 .8byte __lxsys_getppid
21 .8byte __lxsys_waitpid /* 10 */
22 .8byte __lxsys_sigreturn
23 .8byte __lxsys_sigprocmask
24 .8byte __lxsys_sys_sigaction
26 .8byte __lxsys_kill /* 15 */
28 .8byte __lxsys_sigpending
29 .8byte __lxsys_sigsuspend
31 .8byte __lxsys_close /* 20 */
34 .8byte __lxsys_sys_readdir
36 .8byte __lxsys_lseek /* 25 */
37 .8byte __lxsys_geterrno
38 .8byte __lxsys_readlink
39 .8byte __lxsys_readlinkat
41 .8byte __lxsys_unlink /* 30 */
42 .8byte __lxsys_unlinkat
46 .8byte __lxsys_dup2 /* 35 */
47 .8byte __lxsys_realpathat
48 .8byte __lxsys_symlink
51 .8byte __lxsys_getcwd /* 40 */
54 .8byte __lxsys_unmount
55 .8byte __lxsys_getxattr
56 .8byte __lxsys_setxattr /* 45 */
57 .8byte __lxsys_fgetxattr
58 .8byte __lxsys_fsetxattr
60 .8byte __lxsys_getpgid
61 .8byte __lxsys_setpgid /* 50 */
63 .8byte __lxsys_sys_mmap
66 .8byte __lxsys_fstat /* 55 */
67 .8byte __lxsys_pollctl
68 .8byte __lxsys_th_create
69 .8byte __lxsys_th_self
70 .8byte __lxsys_th_exit
71 .8byte __lxsys_th_join /* 60 */
72 .8byte __lxsys_th_kill
73 .8byte __lxsys_th_detach
74 .8byte __lxsys_th_sigmask
76 .rept __SYSCALL_MAX - (2b - 1b) / 8
82 .type syscall_hndlr, @function
89 movq %rdi, %rbx // struct hart_state*
91 movq irax(%rbx), %rax /* rax: call code as well as the return value from syscall */
92 cmpq $__SYSCALL_MAX, %rax
95 shlq $3, %rax // %rax * 8
96 movabsq $syscall_table, %r8
110 movq irbx(%rbx), %rdi /* rbx -> rdi #1 arg */
111 movq ircx(%rbx), %rsi /* rcx -> rsi #2 arg */
112 movq irdx(%rbx), %rdx /* rdx -> rdx #3 arg */
113 movq irdi(%rbx), %rcx /* rdi -> rcx #4 arg */
114 movq irsi(%rbx), %r8 /* rsi -> r8 #5 arg */
118 movq %rax, irax(%rbx) /* save the return value */