xv6, line by line
kernel/syscall.h

kernel/syscall.h

C header · 23 lines · annotated 100% · kernel · upstream

Included by 4 fileskernel/syscall.c, user/grind.c, user/usertests.c, user/usys.S
About this file

The list of system call numbers: the agreement between user programs and the kernel about which number means which system call.

The header is included on both sides of that agreement. In the kernel, kernel/syscall.c uses the numbers as indices into its dispatch table syscalls. On the user side, the stub generator user/usys.pl writes #include "kernel/syscall.h" at the top of user/usys.S, and each stub loads its number into register a7 before ecall, for example li a7, SYS_fork. Since the header is shared, the two sides cannot disagree.

Read next: kernel/syscall.c.

1// System call numbers
2#define SYS_fork 1
3#define SYS_exit 2
4#define SYS_wait 3
5#define SYS_pipe 4
6#define SYS_read 5
7#define SYS_kill 6
8#define SYS_exec 7
9#define SYS_fstat 8
10#define SYS_chdir 9
11#define SYS_dup 10
12#define SYS_getpid 11
13#define SYS_sbrk 12
14#define SYS_pause 13
15#define SYS_uptime 14
16#define SYS_open 15
17#define SYS_write 16
18#define SYS_mknod 17
19#define SYS_unlink 18
20#define SYS_link 19
21#define SYS_mkdir 20
22#define SYS_close 21
23#define SYS_sync 22