pub(crate) unsafe fn from(tree_location: VirtAddr) -> &'static mut Self {
        // Is power of 2? We don't care about the case of x == 0 here.
        fn is_pow2(x: usize) -> bool {
            x & (x - 1) == 0
        }

        // Limit scope of unsafety, this procedure is safe.
        fn fill_nodes(entries: &mut MaybeUninitEntries) {
            let mut size = (MAX_LEVEL + 1) as u8;
            for (i, entry) in entries.iter_mut().enumerate() {
                if is_pow2(i + 1) {
                    size -= 1;
                }

                *entry = MaybeUninit::new(size);
            }
        }

        // Safety:
        // Assumptions caller must guarantee are in the method docs.
        let array = &mut *(tree_location.as_mut::<MaybeUninitEntries>());
        // This is safe.
        fill_nodes(array);
        // Safety:
        // `MaybeUninit<u8>` and `u8` have the same ABI, size & alignment.
        // Thus, `Entries` and `MaybeUninitEntries` may be transmuted to each other.
        // `Tree` and `Entries` have the same ABI, size & alignment due to the repr(transparent).
        &mut *(array as *mut _ as *mut Tree)
    }
/// Initializes the tree.
/// This is unsafe as we can't verify that the `tree_location` is valid
/// and will live long enough.
Initializes the tree.
This is unsafe as we can't verify that the `tree_location` is valid
and will live long enough.
Initializes the tree . This is unsafe as we can ' t verify that the ` tree_location ` is valid and will live long enough .
pub(crate) unsafe fn from(tree_location: VirtAddr) -> &'static mut Self {
        // Is power of 2? We don't care about the case of x == 0 here.
        fn is_pow2(x: usize) -> bool {
            x & (x - 1) == 0
        }
        // Limit scope of unsafety, this procedure is safe.
        fn fill_nodes(entries: &mut MaybeUninitEntries) {
            let mut size = (MAX_LEVEL + 1) as u8;
            for (i, entry) in entries.iter_mut().enumerate() {
                if is_pow2(i + 1) {
                    size -= 1;
                }
                *entry = MaybeUninit::new(size);
            }
        }
        // Safety:
        // Assumptions caller must guarantee are in the method docs.
        let array = &mut *(tree_location.as_mut::<MaybeUninitEntries>());
        // This is safe.
        fill_nodes(array);
        // Safety:
        // `MaybeUninit<u8>` and `u8` have the same ABI, size & alignment.
        // Thus, `Entries` and `MaybeUninitEntries` may be transmuted to each other.
        // `Tree` and `Entries` have the same ABI, size & alignment due to the repr(transparent).
        &mut *(array as *mut _ as *mut Tree)
    }
pub ( crate ) unsafe fn from ( tree_location : VirtAddr ) -> & ' static mut Self { // Is power of 2? We don't care about the case of x == 0 here. fn is_pow2 ( x : usize ) -> bool { x & ( x - 1 ) == 0 } // Limit scope of unsafety, this procedure is safe. fn fill_nodes ( entries : & mut MaybeUninitEntries ) { let mut size = ( MAX_LEVEL + 1 ) as u8 ; for ( i , entry ) in entries . iter_mut ( ) . enumerate ( ) { if is_pow2 ( i + 1 ) { size -= 1 ; } * entry = MaybeUninit :: new ( size ) ; } } // Safety: // Assumptions caller must guarantee are in the method docs. let array = & mut * ( tree_location . as_mut :: < MaybeUninitEntries > ( ) ) ; // This is safe. fill_nodes ( array ) ; // Safety: // `MaybeUninit<u8>` and `u8` have the same ABI, size & alignment. // Thus, `Entries` and `MaybeUninitEntries` may be transmuted to each other. // `Tree` and `Entries` have the same ABI, size & alignment due to the repr(transparent). & mut * ( array as * mut _ as * mut Tree ) }
Initializes the tree.
Initializes the tree .
tree_location
VirtAddr
tree_location
VirtAddr