Commit 6dc48538 authored by Nifou's avatar Nifou

Implement FrameDeallocator for the frame allocator. It can now deallocate frames!

parent 0b8ad72e
......@@ -17,7 +17,7 @@
//! Physical memory's frames allocator
use alloc::prelude::v1::Vec;
use x86_64::{
structures::paging::{FrameAllocator, PhysFrame, Size4KiB},
structures::paging::{FrameAllocator, FrameDeallocator, PhysFrame, Size4KiB},
PhysAddr,
};
use multiboot2::{MemoryAreaIter, MemoryArea, MemoryAreaType};
......@@ -118,6 +118,12 @@ unsafe impl FrameAllocator<Size4KiB> for NextFrameAllocator {
}
}
impl FrameDeallocator<Size4KiB> for NextFrameAllocator {
unsafe fn deallocate_frame(&mut self, frame: PhysFrame) {
self.free.push(frame);
}
}
/// Translate an address to a frame
pub fn addr_to_frame(addr: u64) -> PhysFrame {
PhysFrame::from_start_address(PhysAddr::new(addr)).expect("Not start address")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment