summaryrefslogtreecommitdiff
path: root/src/init
diff options
context:
space:
mode:
authordzwdz2021-09-12 14:59:47 +0200
committerdzwdz2021-09-12 14:59:47 +0200
commit1bf901c803bff3393d0cc9dfe76fc9f025cecb1c (patch)
tree10f0c1c5d64496c3b300a4d691d640a7da73c772 /src/init
parentd7a91165004baf67b645b5604934ec89402d034b (diff)
barebones `memflag()` implementation - letting the user allocate pages
Diffstat (limited to 'src/init')
-rw-r--r--src/init/main.c6
-rw-r--r--src/init/syscalls.c4
2 files changed, 10 insertions, 0 deletions
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 <init/types.h>
+#include <shared/flags.h>
#include <shared/syscalls.h>
#include <stdint.h>
@@ -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);
+}