Kernel: You can specify first vaddr for getting free pages

This commit is contained in:
Bananymous 2023-06-04 01:15:48 +03:00
parent 413f05bfca
commit 8352392b38
2 changed files with 5 additions and 3 deletions

View File

@ -382,11 +382,13 @@ namespace Kernel
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
} }
vaddr_t PageTable::get_free_contiguous_pages(size_t page_count) const vaddr_t PageTable::get_free_contiguous_pages(size_t page_count, vaddr_t first_address) const
{ {
ASSERT(first_address % PAGE_SIZE == 0);
LockGuard _(m_lock); LockGuard _(m_lock);
for (vaddr_t vaddr = PAGE_SIZE; !(vaddr >> 48); vaddr += PAGE_SIZE) for (vaddr_t vaddr = first_address; is_canonical(vaddr); vaddr += PAGE_SIZE)
{ {
bool valid { true }; bool valid { true };
for (size_t page = 0; page < page_count; page++) for (size_t page = 0; page < page_count; page++)

View File

@ -43,7 +43,7 @@ namespace Kernel
bool is_range_free(vaddr_t, size_t bytes) const; bool is_range_free(vaddr_t, size_t bytes) const;
vaddr_t get_free_page() const; vaddr_t get_free_page() const;
vaddr_t get_free_contiguous_pages(size_t page_count) const; vaddr_t get_free_contiguous_pages(size_t page_count, vaddr_t first_address = PAGE_SIZE) const;
void invalidate(vaddr_t); void invalidate(vaddr_t);
void load(); void load();