mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-27 20:58:22 +00:00
kernel: munmap syscall
This commit is contained in:
@@ -14,6 +14,7 @@ extern syscall_fork
|
||||
extern syscall_execve
|
||||
extern syscall_exit
|
||||
extern syscall_waitpid
|
||||
extern syscall_munmap
|
||||
syscalltab:
|
||||
dq syscall_print
|
||||
dq syscall_mmap
|
||||
@@ -30,7 +31,8 @@ dq syscall_fork
|
||||
dq syscall_execve
|
||||
dq syscall_exit
|
||||
dq syscall_waitpid
|
||||
syscallcount equ 15
|
||||
dq syscall_munmap
|
||||
syscallcount equ 16
|
||||
section .text
|
||||
global arch_syscall_entry
|
||||
; on entry:
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
#include <kernel/syscalls.h>
|
||||
#include <kernel/vmm.h>
|
||||
#include <errno.h>
|
||||
|
||||
syscallret_t syscall_munmap(context_t *ctx, void *addr, size_t length) {
|
||||
syscallret_t ret = {
|
||||
.ret = -1,
|
||||
.errno = 0
|
||||
};
|
||||
|
||||
if (addr > USERSPACE_END) {
|
||||
ret.errno = EFAULT;
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (length == 0 || length % PAGE_SIZE > 0) {
|
||||
ret.errno = EINVAL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
vmm_unmap(addr, length / PAGE_SIZE, 0);
|
||||
|
||||
ret.ret = 0;
|
||||
ret.errno = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -133,7 +133,7 @@ index 0000000..e5b087a
|
||||
+
|
||||
diff --git mlibc-workdir/sysdeps/astral/generic/generic.cpp mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||
new file mode 100644
|
||||
index 0000000..afd1ebc
|
||||
index 0000000..601407e
|
||||
--- /dev/null
|
||||
+++ mlibc-workdir/sysdeps/astral/generic/generic.cpp
|
||||
@@ -0,0 +1,193 @@
|
||||
@@ -314,8 +314,8 @@ index 0000000..afd1ebc
|
||||
+ }
|
||||
+
|
||||
+ int sys_vm_unmap(void *pointer, size_t size) {
|
||||
+ // TODO UNSTUB
|
||||
+ return ENOSYS;
|
||||
+ long ret;
|
||||
+ return syscall(SYSCALL_MUNMAP, &ret, (uintptr_t)pointer, size);
|
||||
+ }
|
||||
+
|
||||
+ int sys_isatty(int fd) {
|
||||
@@ -349,10 +349,10 @@ index 0000000..990eca0
|
||||
+#endif
|
||||
diff --git mlibc-workdir/sysdeps/astral/include/astral/syscall.h mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||
new file mode 100644
|
||||
index 0000000..43c4367
|
||||
index 0000000..1562c23
|
||||
--- /dev/null
|
||||
+++ mlibc-workdir/sysdeps/astral/include/astral/syscall.h
|
||||
@@ -0,0 +1,38 @@
|
||||
@@ -0,0 +1,39 @@
|
||||
+#ifndef _SYSCALL_H_INCLUDE
|
||||
+#define _SYSCALL_H_INCLUDE
|
||||
+
|
||||
@@ -371,6 +371,7 @@ index 0000000..43c4367
|
||||
+#define SYSCALL_EXECVE 12
|
||||
+#define SYSCALL_EXIT 13
|
||||
+#define SYSCALL_WAITPID 14
|
||||
+#define SYSCALL_MUNMAP 15
|
||||
+
|
||||
+#include <stddef.h>
|
||||
+#include <stdint.h>
|
||||
|
||||
Reference in New Issue
Block a user