Setup kernel stack; but process is failing

This commit is contained in:
2026-02-17 23:01:32 +01:00
parent 458ba375f3
commit ac7216d84a
15 changed files with 136 additions and 21 deletions

View File

@@ -142,6 +142,6 @@ void kfree(void* ptr)
// Should return a pointer to top of the stack (as stack grows DOWNWARDS)
void* kalloc_stack()
{
uint8_t* ptr = kmalloc(PROCESS_STACK_SIZE);
uint8_t* ptr = kmalloc(PROCESS_STACK_SIZE); // As it's out of kmalloc, stack is already mapped into kernel space
return ptr ? ptr+PROCESS_STACK_SIZE : NULL;
}

View File

@@ -24,7 +24,7 @@ If we use 1GB huge pages: PML4 -> PDPT -> 1gb pages
4KB (regular size): PML4 -> PDPT -> PD -> PT -> 4kb pages
*/
static inline void load_cr3(uint64_t value) {
void load_cr3(uint64_t value) {
asm volatile ("mov %0, %%cr3" :: "r"(value) : "memory");
}

View File

@@ -16,6 +16,9 @@
void paging_init();
void paging_map_page(uint64_t* root_table, uint64_t virt, uint64_t phys, uint64_t flags);
// To swap root page tables
void load_cr3(uint64_t value);
extern uint64_t hhdm_off;
#define PHYS_TO_VIRT(x) ((void*)((uintptr_t)(x) + hhdm_off))