diff --git a/kernel-src/arch/x86-64/syscall.asm b/kernel-src/arch/x86-64/syscall.asm index 6c093dd8..43096a9b 100644 --- a/kernel-src/arch/x86-64/syscall.asm +++ b/kernel-src/arch/x86-64/syscall.asm @@ -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: diff --git a/kernel-src/sys/syscalls/munmap.c b/kernel-src/sys/syscalls/munmap.c new file mode 100644 index 00000000..5be65d95 --- /dev/null +++ b/kernel-src/sys/syscalls/munmap.c @@ -0,0 +1,27 @@ +#include +#include +#include + +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; +} diff --git a/patches/mlibc/jinx-working-patch.patch b/patches/mlibc/jinx-working-patch.patch index 587013a0..80013876 100644 --- a/patches/mlibc/jinx-working-patch.patch +++ b/patches/mlibc/jinx-working-patch.patch @@ -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 +#include