The manual
ginnOS
The reference: libc, the libraries and the kernel
Loading...
Searching...
No Matches
syscall.h
Go to the documentation of this file.
1#pragma once
2
3/**
4 * @file syscall.h
5 * @brief This file contains the declarations of system call numbers and the raw syscall interface.
6 */
7
8/* ginnOS syscall numbers */
9#define SYS_EXIT 0 // exit the current process
10#define SYS_WRITE 1 // write to a file descriptor
11#define SYS_READ 2 // read from a file descriptor
12#define SYS_OPEN 3 // open a file
13#define SYS_CLOSE 4 // close a file descriptor
14#define SYS_STAT 5 // get file status
15#define SYS_CREATE 6 // retired: create() is open(O_CREAT | O_WRONLY | O_TRUNC)
16#define SYS_MKDIR 7 // create a new directory
17#define SYS_EXEC 8 // execute a program
18#define SYS_GETPID 9 // get the current process ID
19#define SYS_WAITPID 10 // wait for a child process to change state
20#define SYS_SBRK 11 // increase program data space
21#define SYS_GETCWD 12 // get current working directory
22#define SYS_CHDIR 13 // change current working directory
23#define SYS_READDIR 14 // retired: use SYS_GETDENTS
24#define SYS_UNLINK 15 // remove a file or directory
25#define SYS_RMDIR 16 // remove a directory
26#define SYS_TTYCTL 17 // retired: ttyctl() is a libc wrapper over termios
27#define SYS_PIPE 18 // create a pipe
28#define SYS_DUP2 19
29#define SYS_FTRUNCATE 20
30#define SYS_LSEEK 21 // duplicate a file descriptor
31#define SYS_POLLKEY 22 // non-blocking: return a pending char key, or 0
32#define SYS_IOCTL 23 // device-control request on a file descriptor
33#define SYS_MMAP 24 // map memory (anonymous or device-backed)
34#define SYS_MUNMAP 25 // unmap a range of memory
35#define SYS_MPROTECT 26 // change the protection of a range of memory
36#define SYS_FORK 27 // create a copy of the calling process
37#define SYS_EXECVE 28 // replace the calling process's program
38#define SYS_GETPPID 29 // get the parent's process ID
39#define SYS_SCHED_YIELD 30 // let other processes run first
40#define SYS_FCNTL 31 // control an open file descriptor
41#define SYS_FSTAT 32 // metadata of an open file
42#define SYS_RENAME 33 // rename a file
43#define SYS_ACCESS 34 // check that a file can be accessed
44#define SYS_PREAD 35 // read at an offset
45#define SYS_PWRITE 36 // write at an offset
46#define SYS_FSYNC 37 // write a file's data to disk
47#define SYS_GETDENTS 38 // read directory records
48#define SYS_POLL 39 // wait for file descriptors to become ready
49#define SYS_KILL 40 // send a signal
50#define SYS_SIGACTION 41 // read and change a signal's action
51#define SYS_SIGPROCMASK 42 // read and change the blocked signals
52#define SYS_SIGRETURN 43 // return from a signal handler
53#define SYS_SIGPENDING 44 // blocked signals that are pending
54#define SYS_SIGSUSPEND 45 // wait for a signal
55#define SYS_ALARM 46 // SIGALRM after a number of seconds
56#define SYS_SETPGID 47 // move a process into a process group
57#define SYS_GETPGID 48 // the process group of a process
58#define SYS_SETSID 49 // start a new session
59#define SYS_GETSID 50 // the session of a process
60#define SYS_CLOCK_GETTIME 51 // read a clock
61#define SYS_NANOSLEEP 52 // sleep for a time span
62#define SYS_TIMES 53 // process CPU times
63#define SYS_GETUID 54 // real user id
64#define SYS_GETEUID 55 // effective user id
65#define SYS_GETGID 56 // real group id
66#define SYS_GETEGID 57 // effective group id
67#define SYS_SETUID 58 // set the user ids
68#define SYS_SETGID 59 // set the group ids
69#define SYS_SETEUID 60 // set the effective user id
70#define SYS_SETEGID 61 // set the effective group id
71#define SYS_CHMOD 62 // change a file's mode
72#define SYS_FCHMOD 63 // change an open file's mode
73#define SYS_CHOWN 64 // change a file's owner
74#define SYS_UMASK 65 // set the file creation mask
75#define SYS_REBOOT 66 // restart the machine (root only)
76#define SYS_SHM_CREATE 67 // make a shared memory object, return its fd
77#define SYS_SOCKET 68 // make a Unix domain socket
78#define SYS_BIND 69 // give a socket a name
79#define SYS_LISTEN 70 // let a bound socket take connections
80#define SYS_ACCEPT 71 // take a connection (accept4 flags)
81#define SYS_CONNECT 72 // connect to a named socket
82#define SYS_SOCKETPAIR 73 // make two connected sockets
83#define SYS_SENDMSG 74 // send data and files
84#define SYS_RECVMSG 75 // receive data and files
85#define SYS_UNAME 76 // the name, release and machine of the system
86#define SYS_OPENAT 77 // the *at calls: a path relative to a directory fd
87#define SYS_MKDIRAT 78
88#define SYS_UNLINKAT 79
89#define SYS_RENAMEAT 80
90#define SYS_FSTATAT 81
91#define SYS_FACCESSAT 82
92#define SYS_FCHMODAT 83
93#define SYS_FCHOWNAT 84
94#define SYS_FCHOWN 85
95#define SYS_SYMLINKAT 86 // links: a symbolic link, its target, a hard link
96#define SYS_READLINKAT 87
97#define SYS_LINKAT 88
98#define SYS_UTIMENSAT 89 // set a file's times
99#define SYS_CLOCK_SETTIME 90 // set the realtime clock (root)
100#define SYS_SETHOSTNAME 91 // set the host name (root)
101#define SYS_GETPRIORITY 92 // the nice value of processes
102#define SYS_SETPRIORITY 93
103#define SYS_FLOCK 94 // an advisory lock on a whole file
104#define SYS_MKNODAT 95 // a named pipe or a device node
105#define SYS_CHROOT 96 // change the root directory (root)
106#define SYS_CLONE 97 // make a thread (the Linux flags for one)
107#define SYS_EXIT_GROUP 98 // end every thread of the process
108#define SYS_GETTID 99 // the calling thread's id
109#define SYS_TGKILL 100 // send a signal to one thread
110#define SYS_SET_TLS 101 // set the thread pointer (thread-local storage)
111#define SYS_FUTEX 102 // wait on or wake a word in user memory
112#define SYS_GETSOCKNAME 103 // the address of a socket, and of its peer
113#define SYS_GETPEERNAME 104
114#define SYS_SETSOCKOPT 105 // socket options
115#define SYS_GETSOCKOPT 106
116#define SYS_SHUTDOWN 107 // stop reading or writing on a socket
117#define SYS_GETRANDOM 108 // random bytes
118
119/**
120 * the raw syscall (src/libc/arch/<arch>/syscall.asm). the arguments and
121 * the result are pointer-wide, so a pointer passes through unchanged. a
122 * result from -4095 to -1 is a negative errno.
123 */
124long _syscall(long num, long arg1, long arg2, long arg3, long arg4, long arg5);
long _syscall(long num, long arg1, long arg2, long arg3, long arg4, long arg5)
the raw syscall (src/libc/arch/<arch>/syscall.asm).