Load limine module + alloc user stack
This commit is contained in:
@@ -13,6 +13,7 @@ in a specified virtual space
|
||||
compared to the PMM which allocs/frees 4kb frames ("physical pages").
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include <mem/vmm.h>
|
||||
#include <mem/paging.h>
|
||||
#include <stddef.h>
|
||||
@@ -225,6 +226,30 @@ void* vmm_alloc_region(uint64_t* pml4, size_t pages, uint64_t flags)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* vmm_map_user_stack - Map a user stack
|
||||
* @pml4: the user process's PML4
|
||||
*
|
||||
* This function maps and allocates a userspace
|
||||
* stack in the user @pml4 provided, according
|
||||
* to constants USER_STACK_TOP and USER_STACK_PAGES.
|
||||
*
|
||||
* Return:
|
||||
* <addr> - User stack top address
|
||||
*/
|
||||
|
||||
uintptr_t vmm_alloc_user_stack(uint64_t* pml4)
|
||||
{
|
||||
uintptr_t stack_top = USER_STACK_TOP;
|
||||
size_t stack_size = USER_STACK_PAGES*PAGE_SIZE;
|
||||
|
||||
for (size_t i=stack_top; i>stack_top-stack_size; i-=PAGE_SIZE) {
|
||||
vmm_map(pml4, i, PTE_PRESENT | PTE_WRITABLE | PTE_USER);
|
||||
}
|
||||
|
||||
return stack_top;
|
||||
}
|
||||
|
||||
void vmm_init()
|
||||
{
|
||||
// NO U
|
||||
|
||||
Reference in New Issue
Block a user