KernelVM: clean up a bit
This commit is contained in:
parent
8c04788793
commit
b9b7d1e201
@ -21,6 +21,7 @@ namespace KernelVM
|
|||||||
void init()
|
void init()
|
||||||
{
|
{
|
||||||
g_kernelvm_bitmap.initialize(bitmap_memory, sizeof(bitmap_memory));
|
g_kernelvm_bitmap.initialize(bitmap_memory, sizeof(bitmap_memory));
|
||||||
|
g_kernelvm_bitmap.clear(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<u64> alloc_one_page()
|
Result<u64> alloc_one_page()
|
||||||
@ -36,7 +37,7 @@ namespace KernelVM
|
|||||||
return err(ENOMEM);
|
return err(ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
Result<u64> alloc_several_pages(usize count)
|
bool find_several_pages_impl(usize count, u64& start_index)
|
||||||
{
|
{
|
||||||
u64 first_free_index = 0;
|
u64 first_free_index = 0;
|
||||||
u64 free_contiguous_pages = 0;
|
u64 free_contiguous_pages = 0;
|
||||||
@ -56,12 +57,24 @@ namespace KernelVM
|
|||||||
// Found enough contiguous free pages!!
|
// Found enough contiguous free pages!!
|
||||||
if (free_contiguous_pages == count)
|
if (free_contiguous_pages == count)
|
||||||
{
|
{
|
||||||
g_used_vm += ARCH_PAGE_SIZE * count;
|
start_index = first_free_index;
|
||||||
g_kernelvm_bitmap.clear_region(first_free_index, count, true);
|
return true;
|
||||||
return KERNEL_VM_RANGE_START + (first_free_index * ARCH_PAGE_SIZE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Result<u64> alloc_several_pages(const usize count)
|
||||||
|
{
|
||||||
|
u64 start_index;
|
||||||
|
if (find_several_pages_impl(count, start_index))
|
||||||
|
{
|
||||||
|
g_kernelvm_bitmap.clear_region(start_index, count, true);
|
||||||
|
g_used_vm += ARCH_PAGE_SIZE * count;
|
||||||
|
return KERNEL_VM_RANGE_START + (start_index * ARCH_PAGE_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
return err(ENOMEM);
|
return err(ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user