Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What does align_log2 in alloc_contiguous means? #6

Open
stevefan1999-personal opened this issue Sep 5, 2023 · 0 comments
Open

What does align_log2 in alloc_contiguous means? #6

stevefan1999-personal opened this issue Sep 5, 2023 · 0 comments

Comments

@stevefan1999-personal
Copy link

stevefan1999-personal commented Sep 5, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant