summaryrefslogtreecommitdiff
path: root/src/init/syscalls.c
blob: 4c645c201048925e3bb90cb9a2a47ebde69492be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// this file could probably just get generated by a script
#include <init/types.h>
#include <shared/syscalls.h>

int _syscall(int, int, int, int);

_Noreturn void _syscall_exit(const user_ptr msg, size_t len) {
	_syscall(_SYSCALL_EXIT, (int)msg, len, 0);
	__builtin_unreachable();
}

int _syscall_fork(void) {
	return _syscall(_SYSCALL_FORK, 0, 0, 0);
}

int _syscall_await(user_ptr buf, int len) {
	return _syscall(_SYSCALL_AWAIT, (int)buf, (int)len, 0);
}

handle_t _syscall_open(const user_ptr path, int len) {
	return _syscall(_SYSCALL_OPEN, (int)path, len, 0);
}

int _syscall_mount(handle_t handle, const user_ptr path, int len) {
	return _syscall(_SYSCALL_MOUNT, handle, (int)path, len);
}

int _syscall_read(handle_t handle, user_ptr buf, int len) {
	return _syscall(_SYSCALL_READ, handle, (int)buf, len);
}

int _syscall_write(handle_t handle, user_ptr buf, int len) {
	return _syscall(_SYSCALL_WRITE, handle, (int)buf, len);
}

int _syscall_close(handle_t handle) {
	return _syscall(_SYSCALL_CLOSE, handle, 0, 0);
}

handle_t _syscall_fs_create(user_ptr back) {
	return _syscall(_SYSCALL_FS_CREATE, (int)back, 0, 0);
}