mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-29 05:38:21 +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;
|
||||
}
|
||||
Reference in New Issue
Block a user