|
AquilaOS documentation
How it works, and its code
|
System calls: what the architecture calls when user mode makes one (syscall_dispatch()), the table of them, and the helpers that several kinds of calls share, for the user memory and descriptors they take. More...
#include "syscalls.h"Go to the source code of this file.
Macros | |
| #define | SYSCALL_ARGS uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5 |
| #define | SYSCALL0(name) |
| #define | SYSCALL1(name, t1) |
| #define | SYSCALL2(name, t1, t2) |
| #define | SYSCALL3(name, t1, t2, t3) |
| #define | SYSCALL4(name, t1, t2, t3, t4) |
| #define | SYSCALL5(name, t1, t2, t3, t4, t5) |
Functions | |
| struct file * | fd_file (int fd) |
| Finds the open file that a descriptor of the current process refers to, and holds it until the system call returns, so that a close() by another thread meanwhile doesn't free it. | |
| int | upath_get (const char *upath, char **path) |
| Copies a path from user memory into a new kernel buffer. | |
| void | syscall_dispatch (unsigned long nr, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5) |
| Runs a system call that the current thread made from user mode. | |
Variables | |
| static int | syscall_log_level = LOG_NONE |
| const syscall_t | syscall_table [] |
| const size_t | syscall_cnt = sizeof(syscall_table)/sizeof(syscall_table[0]) |
System calls: what the architecture calls when user mode makes one (syscall_dispatch()), the table of them, and the helpers that several kinds of calls share, for the user memory and descriptors they take.
The calls themselves are in sys_file.c, sys_proc.c, sys_signal.c, sys_net.c and sys_poll.c, and syscalls.h lists them all.
Definition in file syscall.c.
| #define SYSCALL0 | ( | name | ) |
| #define SYSCALL1 | ( | name, | |
| t1 ) |
| #define SYSCALL2 | ( | name, | |
| t1, | |||
| t2 ) |
| #define SYSCALL3 | ( | name, | |
| t1, | |||
| t2, | |||
| t3 ) |
| #define SYSCALL4 | ( | name, | |
| t1, | |||
| t2, | |||
| t3, | |||
| t4 ) |
| #define SYSCALL5 | ( | name, | |
| t1, | |||
| t2, | |||
| t3, | |||
| t4, | |||
| t5 ) |
| struct file * fd_file | ( | int | fd | ) |
Finds the open file that a descriptor of the current process refers to, and holds it until the system call returns, so that a close() by another thread meanwhile doesn't free it.
| fd | the descriptor |
Definition at line 22 of file syscall.c.
References curproc, fd_file(), file_hold(), NULL, and proc_fd_file().
Referenced by at_uio(), fd_file(), fd_vnode(), socket_name(), sys_accept(), sys_bind(), sys_connect(), sys_fchdir(), sys_fcntl(), sys_flock(), sys_fstat(), sys_ftruncate(), sys_getsockopt(), sys_ioctl(), sys_isatty(), sys_listen(), sys_lseek(), sys_mmap(), sys_read(), sys_readdir(), sys_recv(), sys_send(), sys_setsockopt(), sys_shutdown(), and sys_write().
| void syscall_dispatch | ( | unsigned long | nr, |
| uintptr_t | a1, | ||
| uintptr_t | a2, | ||
| uintptr_t | a3, | ||
| uintptr_t | a4, | ||
| uintptr_t | a5 ) |
Runs a system call that the current thread made from user mode.
The architecture's arch_syscall() calls it with the number and the arguments, as they came in registers.
The call's result is set as the thread's result to return to user mode (arch_syscall_return()), except for sigreturn's: its registers are the ones it restored from the signal frame. A call that doesn't return (exit, or an execve that worked) doesn't come back here.
| nr | the system call's number (SYS_*) |
| a1 | its first argument |
| a2 | its second argument |
| a3 | its third argument |
| a4 | its fourth argument |
| a5 | its fifth argument |
Definition at line 313 of file syscall.c.
References arch_syscall_return(), curproc, curthread, printk(), syscall_cnt, syscall_dispatch(), syscall_table, and thread_files_release().
Referenced by arch_syscall(), arch_syscall(), and syscall_dispatch().
| int upath_get | ( | const char * | upath, |
| char ** | path ) |
Copies a path from user memory into a new kernel buffer.
| upath | the path, in user memory |
| path | set to the kernel's copy, which the caller frees with kfree(); NULL on failure |
Definition at line 46 of file syscall.c.
References kfree(), kmalloc(), NULL, upath_get(), and UPATH_MAX.
Referenced by at_lookup(), at_path(), do_mknodat(), do_openat(), do_unlinkat(), sys_chdir(), sys_execve(), sys_mount(), sys_readlinkat(), sys_symlinkat(), and upath_get().
| const size_t syscall_cnt = sizeof(syscall_table)/sizeof(syscall_table[0]) |
Definition at line 293 of file syscall.c.
Referenced by syscall_dispatch().
| const syscall_t syscall_table[] |
Definition at line 197 of file syscall.c.
Referenced by syscall_dispatch().