pub struct LockedFrameAllocator(/* private fields */);Expand description
Global frame allocator with spinlock protection Wrapper around a static mutex to avoid stack overflow
Implementations§
Source§impl LockedFrameAllocator
impl LockedFrameAllocator
Sourcepub unsafe fn init(memory_map: &'static MemoryMapResponse) -> Self
pub unsafe fn init(memory_map: &'static MemoryMapResponse) -> Self
Initialize the global allocator from the memory map
§Safety
This function is unsafe because the caller must guarantee that:
- The passed memory map is valid
- All frames marked as
USABLEin it are really unused - This is called only once during initialization
Sourcepub fn deallocate_frame(&self, frame: PhysFrame)
pub fn deallocate_frame(&self, frame: PhysFrame)
Deallocate a frame
Sourcepub fn deallocate_contiguous(&self, frame: PhysFrame, count: usize)
pub fn deallocate_contiguous(&self, frame: PhysFrame, count: usize)
Deallocate a contiguous block of frames
Sourcepub fn stats(&self) -> FrameStats
pub fn stats(&self) -> FrameStats
Get memory statistics
Sourcepub fn is_allocated(&self, frame: PhysFrame) -> bool
pub fn is_allocated(&self, frame: PhysFrame) -> bool
Check if a frame is allocated
Sourcepub fn free_frames(&self) -> usize
pub fn free_frames(&self) -> usize
Get the number of free frames
Trait Implementations§
Source§impl FrameAllocator<Size4KiB> for LockedFrameAllocator
impl FrameAllocator<Size4KiB> for LockedFrameAllocator
Source§fn allocate_frame(&mut self) -> Option<PhysFrame>
fn allocate_frame(&mut self) -> Option<PhysFrame>
Allocate a frame of the appropriate size and return it if possible.
Auto Trait Implementations§
impl Freeze for LockedFrameAllocator
impl !RefUnwindSafe for LockedFrameAllocator
impl Send for LockedFrameAllocator
impl Sync for LockedFrameAllocator
impl Unpin for LockedFrameAllocator
impl !UnwindSafe for LockedFrameAllocator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more