aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Moffett <ian@osmora.org>2024-04-25 14:26:33 -0400
committerIan Moffett <ian@osmora.org>2024-04-25 14:28:51 -0400
commit5ada17916af15077da6ec443ee094e69dc6ed704 (patch)
tree0ff8526a611fad9ffc6334cac0a6c342f518a40c
parent35fbcb94cead0a487b6a6a4e9d86bc7eb7b9fba2 (diff)
kernel: vm_map: Refactor mmap()
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r--sys/vm/vm_map.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index f022e7a..4f7aadc 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -333,7 +333,6 @@ mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off)
{
const int PROT_MASK = PROT_WRITE | PROT_EXEC;
const size_t GRANULE = vm_get_page_size();
-
uintptr_t map_end, map_start;
struct proc *td = this_td();
@@ -355,9 +354,8 @@ mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off)
if (mapping == NULL)
return MAP_FAILED;
+ /* Setup prot and mapping start */
mapping->prot = prot | PROT_USER;
-
- /* Setup mapping start */
map_start = __ALIGN_DOWN(va, GRANULE);
/*
@@ -386,7 +384,9 @@ mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off)
mapping->vmobj = vmobj;
mapping->physmem_base = 0;
- } else if (physmem != 0) {
+ }
+
+ if (addr == NULL && physmem != 0) {
map_start = physmem + mapoff;
vm_map((void *)map_start, physmem, prot, len);
addr = (void *)physmem;