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>
impl<I, D> LegacyFrameAllocator<I, D>
Sourcepub fn new(memory_map: I) -> Self
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).
Sourcepub fn new_starting_at(frame: PhysFrame, memory_map: I) -> Self
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).
Sourcepub fn len(&self) -> usize
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
.
Sourcepub fn max_phys_addr(&self) -> PhysAddr
pub fn max_phys_addr(&self) -> PhysAddr
Returns the largest detected physical memory address.
Useful for creating a mapping for all physical memory.
Sourcepub fn memory_map_max_region_count(&self) -> usize
pub fn memory_map_max_region_count(&self) -> usize
Calculate the maximum number of regions produced by Self::construct_memory_map
Sourcepub 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]
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.