Free a memory chunk, releasing the pages back to the frame allocator
(
level_4_physaddr: u64,
address: VirtAddr
)
| 528 | |
| 529 | /// Free a memory chunk, releasing the pages back to the frame allocator |
| 530 | pub fn free_page_chunk( |
| 531 | level_4_physaddr: u64, |
| 532 | address: VirtAddr |
| 533 | ) -> Result<(), usize> { |
| 534 | let memory_info = unsafe {MEMORY_INFO.as_mut().unwrap()}; |
| 535 | |
| 536 | // Remove from page table, get address of l3 entry |
| 537 | let (physaddr, level) = get_page_chunk(level_4_physaddr, address, true)?; |
| 538 | |
| 539 | // Free page tables and pages recursively |
| 540 | free_pages_rec(memory_info.physical_memory_offset, |
| 541 | &mut memory_info.frame_allocator, |
| 542 | physaddr, |
| 543 | level); // Page table level |
| 544 | Ok(()) |
| 545 | } |
| 546 | |
| 547 | /// Remove a page chunk from a page table |
| 548 | /// Doesn't free any of the pages |
no test coverage detected