bootloader_x86_64_common::level_4_entries

Struct UsedLevel4Entries

Source
pub struct UsedLevel4Entries { /* private fields */ }
Expand description

Keeps track of used entries in a level 4 page table.

Useful for determining a free virtual memory block, e.g. for mapping additional data.

Implementations§

Source§

impl UsedLevel4Entries

Source

pub fn new( max_phys_addr: PhysAddr, regions_len: usize, framebuffer: Option<&RawFrameBufferInfo>, config: &BootloaderConfig, ) -> Self

Initializes a new instance.

Marks the statically configured virtual address ranges from the config as used.

Source

pub fn mark_segments<'a>( &mut self, segments: impl Iterator<Item = ProgramHeader<'a>>, virtual_address_offset: VirtualAddressOffset, )

Marks the virtual address range of all segments as used.

Source

pub fn get_free_entries(&mut self, num: u64) -> PageTableIndex

Returns the first index of a num contiguous unused level 4 entries and marks them as used. If CONFIG.aslr is enabled, this will return random contiguous available entries.

Since this method marks each returned index as used, it can be used multiple times to determine multiple unused virtual memory regions.

Source

pub fn get_free_address(&mut self, size: u64, alignment: u64) -> VirtAddr

Returns a virtual address in one or more unused level 4 entries and marks them as used.

This function calls [get_free_entries] internally, so all of its docs applies here too.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.