mm: rename vmm api to mm

This commit is contained in:
Matheus
2026-07-01 14:57:05 -03:00
parent c650036cfe
commit 239c267ed3
47 changed files with 402 additions and 413 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
#include <kernel/abi.h>
#include <time.h>
#include <kernel/timekeeper.h>
#include <kernel/vmm.h>
#include <kernel/mm.h>
syscallret_t syscall_clockget(context_t *, int clockid, timespec_t *tp) {
syscallret_t ret = {
+10 -10
View File
@@ -2,7 +2,7 @@
#include <kernel/alloc.h>
#include <string.h>
#include <errno.h>
#include <kernel/vmm.h>
#include <kernel/mm.h>
#include <arch/cpu.h>
#include <kernel/elf.h>
#include <kernel/scheduler.h>
@@ -67,8 +67,8 @@ static syscallret_t execve(context_t *context, char *upath, char *uargv[], char
size_t envsize = 0;
char **argv = NULL;
char **envp = NULL;
vmmcontext_t *vmmctx = NULL;
vmmcontext_t *oldctx = current_vmm_context();
mm_context_t *mmctx = NULL;
mm_context_t *oldctx = current_mm_context();
vnode_t *node = NULL;
vnode_t *refnode = NULL;
char *interp = NULL;
@@ -237,13 +237,13 @@ static syscallret_t execve(context_t *context, char *upath, char *uargv[], char
}
}
vmmctx = vmm_newcontext();
if (vmmctx == NULL) {
mmctx = mm_create_context();
if (mmctx == NULL) {
ret.errno = ENOMEM;
goto error;
}
vmm_switchcontext(vmmctx);
mm_switch_context(mmctx);
auxv64list_t auxv64;
void *entry;
@@ -321,7 +321,7 @@ static syscallret_t execve(context_t *context, char *upath, char *uargv[], char
proc->signals.actions[i].address = SIG_IGN;
}
vmm_destroycontext(oldctx);
mm_destroy_context(oldctx);
CTX_SP(context) = (uint64_t)stack;
CTX_IP(context) = (uint64_t)entry;
@@ -339,9 +339,9 @@ static syscallret_t execve(context_t *context, char *upath, char *uargv[], char
if (envp)
freevec(envp);
if (vmmctx && ret.errno) {
vmm_switchcontext(oldctx);
vmm_destroycontext(vmmctx);
if (mmctx && ret.errno) {
mm_switch_context(oldctx);
mm_destroy_context(mmctx);
}
if (refnode)
+2 -2
View File
@@ -27,9 +27,9 @@ syscallret_t syscall_fork(context_t *ctx) {
goto cleanup;
}
nthread->vmmctx = vmm_fork(current_thread()->vmmctx);
nthread->mmctx = mm_fork_context(current_thread()->mmctx);
if (nthread->vmmctx == NULL) {
if (nthread->mmctx == NULL) {
ret.errno = ENOMEM;
goto cleanup;
}
+2 -2
View File
@@ -1,6 +1,6 @@
#include <kernel/syscalls.h>
#include <kernel/slab.h>
#include <kernel/vmm.h>
#include <kernel/mm.h>
#include <time.h>
#include <hashtable.h>
#include <kernel/poll.h>
@@ -66,7 +66,7 @@ syscallret_t syscall_futex(context_t *, uint32_t *futexp, int op, uint32_t value
if (unlikely(ret.errno))
goto cleanup;
uint32_t *physical = vmm_getphysical(futexp, 0);
uint32_t *physical = mm_get_physical_address(futexp, 0);
futex_t *futex = getfutex(physical);
switch (op) {
+1 -1
View File
@@ -1,6 +1,6 @@
#include <kernel/syscalls.h>
#include <kernel/file.h>
#include <kernel/vmm.h>
#include <kernel/mm.h>
#include <errno.h>
#include <kernel/alloc.h>
+9 -9
View File
@@ -1,7 +1,7 @@
#include <kernel/syscalls.h>
#include <kernel/abi.h>
#include <errno.h>
#include <kernel/vmm.h>
#include <kernel/mm.h>
#include <logging.h>
#define PROT_READ 0x01
@@ -59,21 +59,21 @@ syscallret_t syscall_mmap(context_t *context, void *hint, size_t len, int prot,
mmuflags |= ARCH_MMU_FLAGS_NOEXEC;
bool isfile = (flags & MAP_ANONYMOUS) == 0;
int vmmflags = 0;
int mm_flags = 0;
if (flags & MAP_FIXED)
vmmflags |= VMM_FLAGS_REPLACE;
mm_flags |= MM_RANGE_FLAGS_REPLACE;
if (flags & MAP_FIXED_NOREPLACE)
vmmflags |= VMM_FLAGS_EXACT;
mm_flags |= MM_RANGE_FLAGS_EXACT;
if ((flags & MAP_ANONYMOUS) == 0)
vmmflags |= VMM_FLAGS_FILE;
mm_flags |= MM_RANGE_FLAGS_FILE;
if (flags & MAP_SHARED)
vmmflags |= VMM_FLAGS_SHARED;
mm_flags |= MM_RANGE_FLAGS_SHARED;
vmmfiledesc_t vfd;
mm_map_file_desc_t vfd;
file_t *file = NULL;
if (isfile) {
// make sure offset is page aligned
@@ -99,7 +99,7 @@ syscallret_t syscall_mmap(context_t *context, void *hint, size_t len, int prot,
}
// if the vnode is not cacheable, we need to make sure we can map it
// TODO move this check to vmm_map once the return value of mmap is fixed to return an errno
// TODO move this check to mm_map once the return value of mmap is fixed to return an errno
if (vfs_iscacheable(file->vnode) == false) {
ret.errno = VOP_MMAP(file->vnode, VOP_MMAP_ADDRESS_MMAP_SUPPORTED, 0, 0, NULL);
if (ret.errno)
@@ -113,7 +113,7 @@ syscallret_t syscall_mmap(context_t *context, void *hint, size_t len, int prot,
if (hint < USERSPACE_START)
hint = USERSPACE_MMAP_START;
ret.ret = (uint64_t)vmm_map(hint, len, vmmflags, mmuflags, &vfd);
ret.ret = (uint64_t)mm_map(hint, len, mm_flags, mmuflags, &vfd);
if (ret.ret == 0)
ret.errno = ENOMEM;
+1 -1
View File
@@ -1,5 +1,5 @@
#include <kernel/syscalls.h>
#include <kernel/vmm.h>
#include <kernel/mm.h>
#include <kernel/alloc.h>
#include <kernel/vfs.h>
#include <logging.h>
+2 -2
View File
@@ -1,7 +1,7 @@
#include <kernel/syscalls.h>
#include <kernel/abi.h>
#include <errno.h>
#include <kernel/vmm.h>
#include <kernel/mm.h>
#include <logging.h>
#define PROT_READ 0x01
@@ -37,7 +37,7 @@ syscallret_t syscall_mprotect(context_t *context, void *address, size_t len, int
if ((prot & PROT_EXEC) == 0)
mmuflags |= ARCH_MMU_FLAGS_NOEXEC;
ret.errno = vmm_changemmuflags(address, len, mmuflags, VMM_FLAGS_CREDCHECK);
ret.errno = mm_change_mmu_flags(address, len, mmuflags, MM_RANGE_FLAGS_CREDCHECK);
ret.ret = ret.errno ? -1 : 0;
return ret;
+2 -2
View File
@@ -1,5 +1,5 @@
#include <kernel/syscalls.h>
#include <kernel/vmm.h>
#include <kernel/mm.h>
#include <errno.h>
syscallret_t syscall_munmap(context_t *ctx, void *addr, size_t length) {
@@ -18,7 +18,7 @@ syscallret_t syscall_munmap(context_t *ctx, void *addr, size_t length) {
return ret;
}
vmm_unmap(addr, length, 0);
mm_unmap(addr, length, 0);
ret.ret = 0;
ret.errno = 0;
+1 -1
View File
@@ -26,7 +26,7 @@ syscallret_t syscall_newthread(context_t *, void *entry, void *stack) {
return ret;
}
thread->vmmctx = current_thread()->vmmctx;
thread->mmctx = current_thread()->mmctx;
bool intstatus = interrupt_set(false);
spinlock_acquire(&proc->threadlistlock);
+1 -1
View File
@@ -1,7 +1,7 @@
#include <kernel/syscalls.h>
#include <kernel/file.h>
#include <kernel/poll.h>
#include <kernel/vmm.h>
#include <kernel/mm.h>
#include <logging.h>
#include <kernel/alloc.h>
+1 -1
View File
@@ -1,6 +1,6 @@
#include <kernel/syscalls.h>
#include <time.h>
#include <kernel/vmm.h>
#include <kernel/mm.h>
#include <kernel/timer.h>
#include <arch/cpu.h>