miniOS
x86_64 hobby kernel with SMP, VFS, and POSIX process model
Loading...
Searching...
No Matches
syscall.h
Go to the documentation of this file.
1#ifndef _MINIOS_SYSCALL_H_
2#define _MINIOS_SYSCALL_H_
3
20
21#include <miniOS/types.h>
22
23/* Syscall numbers */
24#define SYS_read 0
25#define SYS_write 1
26#define SYS_open 2
27#define SYS_close 3
28#define SYS_stat 4
29#define SYS_fstat 5
30#define SYS_lstat 6
31#define SYS_waitpid 7 /* wait4 is a superset; this is for waitpid() */
32#define SYS_lseek 8
33#define SYS_mmap 9
34#define SYS_mprotect 10
35#define SYS_munmap 11
36#define SYS_signal 13
37#define SYS_sigreturn 15 /* return from signal handler; SA_RESTART decision here */
38#define SYS_ioctl 16
39#define SYS_pread64 17
40#define SYS_pwrite64 18
41#define SYS_access 21
42#define SYS_pipe 22
43#define SYS_poll 23
44#define SYS_select 24
45#define SYS_dup 32
46#define SYS_dup2 33
47#define SYS_nanosleep 35
48#define SYS_getpid 39
49#define SYS_fork 57
50#define SYS_execve 59
51#define SYS_exit 60
52#define SYS_wait4 61 /* waitpid is implemented via this */
53#define SYS_kill 62
54#define SYS_gettimeofday 96
55#define SYS_sysinfo 99
56#define SYS_chmod 90
57#define SYS_statfs 137
58#define SYS_fstatfs 138
59#define SYS_mknod 133
60#define SYS_fcntl 72
61#define SYS_ftruncate 77
62#define SYS_getdents 78
63#define SYS_brk 79
64#define SYS_getcwd 80
65#define SYS_chdir 81
66#define SYS_rename 82
67#define SYS_mkdir 83
68#define SYS_rmdir 84
69#define SYS_unlink 87
70#define SYS_symlink 88
71#define SYS_readlink 89
72#define SYS_ptrace 101
73#define SYS_setpgid 109
74#define SYS_getppid 110
75#define SYS_setsid 112
76#define SYS_mount 165
77#define SYS_umount 166
78#define SYS_sigaction 174
79#define SYS_sched_getcpu 318
80#define SYS_clock_gettime 228
81
82/* ── Socket syscalls (Linux x86-64 ABI, nr 41-55) ─────────────────────── */
83#define SYS_socket 41
84#define SYS_connect 42
85#define SYS_accept 43
86#define SYS_sendto 44
87#define SYS_recvfrom 45
88#define SYS_shutdown 48
89#define SYS_bind 49
90#define SYS_listen 50
91#define SYS_socketpair 53
92#define SYS_setsockopt 54
93#define SYS_getsockopt 55
94#define SYS_clone 56
95#define SYS_arch_prctl 158
96#define SYS_gettid 186
97#define SYS_futex 202
98#define SYS_set_tid_address 218
99
100/* ── miniOS-specific syscall numbers (beyond Linux x86-64 ABI range) ───── */
101#define SYS_setitimer_miniOS 452 /* miniOS setitimer(): set ITIMER_REAL precisely */
102#define SYS_alarm_miniOS 453 /* miniOS alarm(): set ITIMER_REAL in seconds */
103#define SYS_register_sigtrampoline 454 /* register userspace signal trampoline VA */
104
114 uint64_t a4, uint64_t a5, uint64_t a6);
115
125void syscall_init(void);
126
138void syscall_get_saved_user_rdi_rsi_rdx(uint64_t *out_rdi, uint64_t *out_rsi, uint64_t *out_rdx);
139
141
142#endif // _MINIOS_SYSCALL_H_
void syscall_init(void)
Writes IA32_LSTAR MSR to the address of syscall_entry (the NASM entry stub in syscall....
Definition syscall.c:145
void syscall_save_restart_state(uint64_t nr, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5, uint64_t a6)
Definition syscall.c:130
void syscall_get_saved_user_rdi_rsi_rdx(uint64_t *out_rdi, uint64_t *out_rsi, uint64_t *out_rdx)
The SYSCALL instruction clobbers RCX and R11; arguments in RDI/RSI/RDX are preserved by the syscall....
Definition syscall.c:117
unsigned long int uint64_t
Definition types.h:37