Skip to content
Snippets Groups Projects
Commit 53380cff authored by Videau Luc's avatar Videau Luc
Browse files

do_allocate allocation

parent b7c32b14
No related branches found
Tags tp2-act-4-6
No related merge requests found
......@@ -378,9 +378,22 @@ int load_from_file(char* file,
int do_allocate(pagetable_t pagetable, struct proc* p, uint64 addr){
pte_t* ad = walk(pagetable, addr, 0);
struct vma* mem_area = get_memory_area(p, addr);
if(!mem_area){
return ENOVMA;
}
if (!ad || (PTE_FLAGS(*ad) & PTE_V) == 0)
{
return ENOMEM;
uint64 pa = (uint64) kalloc();
if (!pa)
{
return ENOMEM;
}
if (mappages(pagetable, addr, PGSIZE, pa, PTE_W | PTE_X | PTE_R | PTE_U) != 0)
{
kfree((void*)pa);
return EMAPFAILED;
}
}
if ((PTE_FLAGS(*ad) & PTE_U) == 0)
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment