This commit is contained in:
2026-08-11 17:48:20 +02:00
committed by Marvin Friedrich
parent cf33867e68
commit 0e2d4ed8c6
55 changed files with 279 additions and 346 deletions
+7 -7
View File
@@ -1,11 +1,11 @@
#include <common/utils.h>
#include <kernel/alloc.h>
#include <kernel/assert.h>
#include <kernel/init.h>
#include <kernel/panic.h>
#include <kernel/print.h>
#include <kernel/vas.h>
#include <kernel/virt.h>
#include <assert.h>
#include <string.h>
extern uint8_t __ld_text_start[];
@@ -66,7 +66,7 @@ void mem_init(struct phys_mem* map, size_t map_len, uintptr_t kernel_virt, phys_
// since we're likely going to map it at a different base address.
mem_hhdm_base = tmp_hhdm;
ASSERT(pmap_new_kernel(&kernel_vas.pmap, 0) == 0, "Unable to allocate the kernel page table\n");
assert(pmap_new_kernel(&kernel_vas.pmap, 0) == 0, "Unable to allocate the kernel page table\n");
// text
kprintf("Mapping text segment at %p\n", __ld_text_start);
@@ -78,7 +78,7 @@ void mem_init(struct phys_mem* map, size_t map_len, uintptr_t kernel_virt, phys_
PTE_READ | PTE_EXEC,
CACHE_NONE
);
ASSERT(!status, "Failed to map %p with error %i\n", p, status);
assert(!status, "Failed to map %p with error %i\n", p, status);
}
// rodata
@@ -91,7 +91,7 @@ void mem_init(struct phys_mem* map, size_t map_len, uintptr_t kernel_virt, phys_
PTE_READ,
CACHE_NONE
);
ASSERT(!status, "Failed to map %p with error %i\n", p, status);
assert(!status, "Failed to map %p with error %i\n", p, status);
}
// data
@@ -104,7 +104,7 @@ void mem_init(struct phys_mem* map, size_t map_len, uintptr_t kernel_virt, phys_
PTE_READ | PTE_WRITE,
CACHE_NONE
);
ASSERT(!status, "Failed to map %p with error %i\n", p, status);
assert(!status, "Failed to map %p with error %i\n", p, status);
}
// The kernel address space is divided into 3 segments (plus kernel).
@@ -122,7 +122,7 @@ void mem_init(struct phys_mem* map, size_t map_len, uintptr_t kernel_virt, phys_
uintptr_t vaddr = (uintptr_t)(map[i].address + p + tmp_hhdm);
phys_t paddr = (phys_t)(map[i].address + p);
zn_status_t status = pmap_map(&kernel_vas.pmap, vaddr, paddr, PTE_READ | PTE_WRITE, CACHE_NONE);
ASSERT(!status, "Failed to map HHDM page %p to %p with error %i\n", (void*)vaddr, (void*)paddr, status);
assert(!status, "Failed to map HHDM page %p to %p with error %i\n", (void*)vaddr, (void*)paddr, status);
}
}
mem_hhdm_base = tmp_hhdm;
@@ -150,7 +150,7 @@ void mem_init(struct phys_mem* map, size_t map_len, uintptr_t kernel_virt, phys_
for (size_t page = 0; page < length; page += pgsz) {
phys_t paddr;
ASSERT(!mem_phys_alloc(1, 0, &paddr), "Failed to allocate memory for PFNDB!\n");
assert(!mem_phys_alloc(1, 0, &paddr), "Failed to allocate memory for PFNDB!\n");
pmap_map(&kernel_vas.pmap, vaddr + page, paddr, PTE_READ | PTE_WRITE, CACHE_NONE);
}
}
+1 -1
View File
@@ -6,6 +6,6 @@ kernel_sources += files(
'slab.c',
'usercopy.c',
'virt.c',
'vas.c',
'vma.c',
'vmo.c',
)
+2 -2
View File
@@ -1,12 +1,12 @@
#include <zinnia/status.h>
#include <common/utils.h>
#include <kernel/alloc.h>
#include <kernel/assert.h>
#include <kernel/vas.h>
#include <assert.h>
// Try to create a new, empty virtual address space.
zn_status_t vma_new(struct vas** out) {
DEBUG_ASSERT(out != nullptr, "Missing out");
debug_assert(out != nullptr, "Missing out");
zn_status_t res;
if (!out)
+2 -2
View File
@@ -105,7 +105,7 @@ static zn_status_t paged_get_page(struct vmo* vmo, uintptr_t offset_idx, struct
// Try to find the requested page in the cache.
struct page_list* iter;
SLIST_FOREACH(iter, &paged->cache, next) {
list_foreach(iter, &paged->cache, next) {
if (iter->offset != offset_idx)
continue;
@@ -128,7 +128,7 @@ static zn_status_t paged_get_page(struct vmo* vmo, uintptr_t offset_idx, struct
entry->value = new_page;
// Add page to the object cache.
SLIST_INSERT_HEAD(&paged->cache, entry, next);
list_insert_head(&paged->cache, entry, next);
*out = new_page;
return ZN_OK;