Skip to content

What does align_log2 in alloc_contiguous means? #6

@stevefan1999-personal

Description

@stevefan1999-personal

I'm trying to allocate a 2MiB huge frame like this:

unsafe impl<T: PageSize> FrameAllocator<T> for GlobalFrameAllocator {
    fn allocate_frame(&mut self) -> Option<PhysFrame<T>> {
        unsafe {
            if let Some(addr) = BITMAP.alloc_contiguous(T::SIZE as usize / Size4KiB::SIZE as usize, 1) {
                let addr = PhysAddr::new(addr as u64 * Size4KiB::SIZE);
                PhysFrame::from_start_address(addr).ok()
            } else {
                None
            }
        }
    }
}

impl<T: PageSize> FrameDeallocator<T> for GlobalFrameAllocator {
    unsafe fn deallocate_frame(&mut self, frame: PhysFrame<T>) {
        let addr = frame.start_address().as_u64() as usize;
        BITMAP.dealloc(addr);
    }
}

I'm very confused on what alloc_contiguous does

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions