[kernel] Add vm_space::allocate

Refactored out vm_space::handle_fault's allocation code into a separate
vm_space::allocate function, and reimplemented handle_fault in terms of
the new function.
This commit is contained in:
Justin C. Miller
2021-01-28 01:08:06 -08:00
parent e3ebaeb2c8
commit 35d8d2ab2d
2 changed files with 33 additions and 17 deletions

View File

@@ -79,6 +79,13 @@ public:
fetch = 0x10
};
/// Allocate pages into virtual memory. May allocate less than requested.
/// \arg virt The virtual address at which to allocate
/// \arg count The number of pages to allocate
/// \arg phys [out] The physical address of the pages allocated
/// \returns The number of pages actually allocated
size_t allocate(uintptr_t virt, size_t count, uintptr_t *phys);
/// Handle a page fault.
/// \arg addr Address which caused the fault
/// \arg ft Flags from the interrupt about the kind of fault