forked from AbleOS/ableos
Zeroed page allocation
This commit is contained in:
parent
11620e6499
commit
d9fb718b86
|
@ -20,6 +20,14 @@ impl MemoryManager {
|
||||||
self.get_free_pages(order).map(|addr| addr as *mut u8)
|
self.get_free_pages(order).map(|addr| addr as *mut u8)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn zallocate_pages(&mut self, order: usize) -> Option<*mut u8> {
|
||||||
|
let ptr = self.allocate_pages(order)?;
|
||||||
|
unsafe {
|
||||||
|
ptr.write_bytes(0, PAGE_SIZE << order);
|
||||||
|
}
|
||||||
|
Some(ptr)
|
||||||
|
}
|
||||||
|
|
||||||
/// # Safety
|
/// # Safety
|
||||||
/// This method assumes that `address` is in range of this allocator
|
/// This method assumes that `address` is in range of this allocator
|
||||||
pub unsafe fn deallocate_pages(&mut self, address: *mut u8, order: usize) {
|
pub unsafe fn deallocate_pages(&mut self, address: *mut u8, order: usize) {
|
||||||
|
|
Loading…
Reference in a new issue