From 31c1536e68399a199a09fa55571fa5bdd92cbef7 Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 24 Aug 2021 16:56:17 +0200 Subject: move syscalls.h to shared/syscalls.h --- src/init/main.c | 2 +- src/init/syscalls.c | 2 +- src/kernel/syscalls.c | 2 +- src/kernel/syscalls.h | 43 ------------------------------------------- src/shared/syscalls.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 45 insertions(+), 46 deletions(-) delete mode 100644 src/kernel/syscalls.h create mode 100644 src/shared/syscalls.h (limited to 'src') diff --git a/src/init/main.c b/src/init/main.c index 7c1c882..06ac3a2 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -1,5 +1,5 @@ -#include #include +#include #include // takes a cstring and copies it right before a page boundary diff --git a/src/init/syscalls.c b/src/init/syscalls.c index 9422e79..8d87beb 100644 --- a/src/init/syscalls.c +++ b/src/init/syscalls.c @@ -1,5 +1,5 @@ // this file could probably just get generated by a script -#include +#include int _syscall(int, int, int, int); diff --git a/src/kernel/syscalls.c b/src/kernel/syscalls.c index 9e64b01..7544174 100644 --- a/src/kernel/syscalls.c +++ b/src/kernel/syscalls.c @@ -2,8 +2,8 @@ #include #include #include -#include #include +#include #include _Noreturn static void await_finish(struct process *dead, struct process *listener) { diff --git a/src/kernel/syscalls.h b/src/kernel/syscalls.h deleted file mode 100644 index c390c73..0000000 --- a/src/kernel/syscalls.h +++ /dev/null @@ -1,43 +0,0 @@ -// note: this file gets included in both kernel and userland -#pragma once -#include - -typedef int fd_t; -typedef int fs_handle_t; - -enum { - // idc about stable syscall numbers just yet - _SYSCALL_EXIT, - _SYSCALL_AWAIT, - _SYSCALL_FORK, - - _SYSCALL_FS_OPEN, - _SYSCALL_MOUNT, - - _SYSCALL_FD_READ, - _SYSCALL_FD_WRITE, - _SYSCALL_FD_CLOSE, -}; - -/** Kills the current process. - * TODO: what happens to the children? - */ -_Noreturn void _syscall_exit(const char *msg, size_t len); - -/** Waits for a child to exit, putting its exit message into *buf. - * @return the length of the message - */ -int _syscall_await(char *buf, int len); - -/** Creates a copy of the current process, and executes it. - * All user memory pages get copied too. - * @return 0 in the child, a meaningless positive value in the parent. - */ -int _syscall_fork(); - -fd_t _syscall_fs_open(const char *path, int len); -int _syscall_mount(const char *path, int len, fd_t fd); - -int _syscall_fd_read(fd_t fd, char *buf, int len); -int _syscall_fd_write(fd_t fd, char *buf, int len); -int _syscall_fd_close(fd_t fd); diff --git a/src/shared/syscalls.h b/src/shared/syscalls.h new file mode 100644 index 0000000..89907ae --- /dev/null +++ b/src/shared/syscalls.h @@ -0,0 +1,42 @@ +#pragma once +#include + +typedef int fd_t; +typedef int fs_handle_t; + +enum { + // idc about stable syscall numbers just yet + _SYSCALL_EXIT, + _SYSCALL_AWAIT, + _SYSCALL_FORK, + + _SYSCALL_FS_OPEN, + _SYSCALL_MOUNT, + + _SYSCALL_FD_READ, + _SYSCALL_FD_WRITE, + _SYSCALL_FD_CLOSE, +}; + +/** Kills the current process. + * TODO: what happens to the children? + */ +_Noreturn void _syscall_exit(const char *msg, size_t len); + +/** Waits for a child to exit, putting its exit message into *buf. + * @return the length of the message + */ +int _syscall_await(char *buf, int len); + +/** Creates a copy of the current process, and executes it. + * All user memory pages get copied too. + * @return 0 in the child, a meaningless positive value in the parent. + */ +int _syscall_fork(); + +fd_t _syscall_fs_open(const char *path, int len); +int _syscall_mount(const char *path, int len, fd_t fd); + +int _syscall_fd_read(fd_t fd, char *buf, int len); +int _syscall_fd_write(fd_t fd, char *buf, int len); +int _syscall_fd_close(fd_t fd); -- cgit v1.2.3