bootloader_x86_64_common::legacy_memory_region

Struct LegacyFrameAllocator

Source
pub struct LegacyFrameAllocator<I, D> { /* private fields */ }
Expand description

A physical frame allocator based on a BIOS or UEFI provided memory map.

Implementations§

Source§

impl<I, D> LegacyFrameAllocator<I, D>
where I: ExactSizeIterator<Item = D> + Clone, I::Item: LegacyMemoryRegion,

Source

pub fn new(memory_map: I) -> Self

Creates a new frame allocator based on the given legacy memory regions.

Skips the frame at physical address zero to avoid potential problems. For example identity-mapping the frame at address zero is not valid in Rust, because Rust’s core library assumes that references can never point to virtual address 0.
Also skips the lower 1MB of frames, there are use cases that require lower conventional memory access (Such as SMP SIPI).

Source

pub fn new_starting_at(frame: PhysFrame, memory_map: I) -> Self

Creates a new frame allocator based on the given legacy memory regions. Skips any frames before the given frame or 0x10000(1MB) whichever is higher, there are use cases that require lower conventional memory access (Such as SMP SIPI).

Source

pub fn len(&self) -> usize

Returns the number of memory regions in the underlying memory map.

The function always returns the same value, i.e. the length doesn’t change after calls to allocate_frame.

Source

pub fn is_empty(&self) -> bool

Returns whether this memory map is empty.

Source

pub fn max_phys_addr(&self) -> PhysAddr

Returns the largest detected physical memory address.

Useful for creating a mapping for all physical memory.

Source

pub fn memory_map_max_region_count(&self) -> usize

Calculate the maximum number of regions produced by Self::construct_memory_map

Source

pub fn construct_memory_map( self, regions: &mut [MaybeUninit<MemoryRegion>], kernel_slice_start: PhysAddr, kernel_slice_len: u64, ramdisk_slice_start: Option<PhysAddr>, ramdisk_slice_len: u64, ) -> &mut [MemoryRegion]

Converts this type to a boot info memory map.

The memory map is placed in the given regions slice. The length of the given slice must be at least the value returned by [len] plus 1.

The return slice is a subslice of regions, shortened to the actual number of regions.

Trait Implementations§

Source§

impl<I, D> FrameAllocator<Size4KiB> for LegacyFrameAllocator<I, D>
where I: ExactSizeIterator<Item = D> + Clone, I::Item: LegacyMemoryRegion,

Source§

fn allocate_frame(&mut self) -> Option<PhysFrame<Size4KiB>>

Allocate a frame of the appropriate size and return it if possible.

Auto Trait Implementations§

§

impl<I, D> Freeze for LegacyFrameAllocator<I, D>
where I: Freeze, D: Freeze,

§

impl<I, D> RefUnwindSafe for LegacyFrameAllocator<I, D>

§

impl<I, D> Send for LegacyFrameAllocator<I, D>
where I: Send, D: Send,

§

impl<I, D> Sync for LegacyFrameAllocator<I, D>
where I: Sync, D: Sync,

§

impl<I, D> Unpin for LegacyFrameAllocator<I, D>
where I: Unpin, D: Unpin,

§

impl<I, D> UnwindSafe for LegacyFrameAllocator<I, D>
where I: UnwindSafe, D: UnwindSafe,

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.