From 1bf901c803bff3393d0cc9dfe76fc9f025cecb1c Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sun, 12 Sep 2021 14:59:47 +0200 Subject: barebones `memflag()` implementation - letting the user allocate pages --- src/init/main.c | 6 ++++++ src/init/syscalls.c | 4 ++++ 2 files changed, 10 insertions(+) (limited to 'src/init') diff --git a/src/init/main.c b/src/init/main.c index 06e59a2..dc5a975 100644 --- a/src/init/main.c +++ b/src/init/main.c @@ -1,4 +1,5 @@ #include +#include #include #include @@ -8,6 +9,8 @@ __attribute__((section("text"))) int tty_fd; +int test; + void fs_test(void); int main(void) { @@ -16,6 +19,9 @@ int main(void) { _syscall_exit(argify("couldn't open tty")); log(" opened /tty "); + _syscall_memflag(&test, sizeof(int), MEMFLAG_PRESENT); + test = 0; // would cause a pagefault without the memflag call + fs_test(); _syscall_exit(argify("my job here is done.")); } diff --git a/src/init/syscalls.c b/src/init/syscalls.c index e63f911..8d5ecf2 100644 --- a/src/init/syscalls.c +++ b/src/init/syscalls.c @@ -44,3 +44,7 @@ handle_t _syscall_fs_create(handle_t __user *back) { int _syscall_fs_wait(handle_t back, char __user *buf, int __user *len) { return _syscall(_SYSCALL_FS_WAIT, back, (int)buf, (int)len); } + +int _syscall_memflag(void __user *addr, size_t len, int flags) { + return _syscall(_SYSCALL_MEMFLAG, (int)addr, len, flags); +} -- cgit v1.2.3