diff --git a/kernel/src/memory.rs b/kernel/src/memory.rs index f5903f7f..265f2be1 100644 --- a/kernel/src/memory.rs +++ b/kernel/src/memory.rs @@ -20,6 +20,14 @@ impl MemoryManager { 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 /// This method assumes that `address` is in range of this allocator pub unsafe fn deallocate_pages(&mut self, address: *mut u8, order: usize) {