pub struct LayoutBuilder<'a> { /* private fields */ }Expand description
A builder for computing a deterministic VM address-space layout.
Implementations§
Source§impl<'a> LayoutBuilder<'a>
impl<'a> LayoutBuilder<'a>
Sourcepub fn reserve(&mut self, tag: impl Into<Arc<str>>, range: MemoryRange)
pub fn reserve(&mut self, tag: impl Into<Arc<str>>, range: MemoryRange)
Reserves a range so no allocation can use it.
Reserved ranges are removed from the free list and may appear in the
returned PlacedRange list, but they do not affect post-MMIO
placement. Trailing reserved ranges are omitted from the returned list.
Sourcepub fn fixed(&mut self, tag: impl Into<Arc<str>>, range: MemoryRange)
pub fn fixed(&mut self, tag: impl Into<Arc<str>>, range: MemoryRange)
Adds a fixed range request to the builder.
Sourcepub fn request(
&mut self,
tag: impl Into<Arc<str>>,
target: &'a mut MemoryRange,
size: u64,
alignment: u64,
placement: Placement,
)
pub fn request( &mut self, tag: impl Into<Arc<str>>, target: &'a mut MemoryRange, size: u64, alignment: u64, placement: Placement, )
Adds a dynamic single-range request to the builder.
The target is filled in when Self::allocate succeeds.
Sourcepub fn ram(
&mut self,
tag: impl Into<Arc<str>>,
target: &'a mut Vec<MemoryRange>,
size: u64,
alignment: u64,
)
pub fn ram( &mut self, tag: impl Into<Arc<str>>, target: &'a mut Vec<MemoryRange>, size: u64, alignment: u64, )
Adds an ordinary RAM request to the builder.
RAM requests are placed in caller order. The first request is placed
bottom up from GPA 0; each subsequent request starts at or above the
highest address used by previous RAM requests, so later requests never
backfill fragments skipped by earlier ones. A single request may still
split around fixed and Mmio32 ranges encountered inside its own span;
each extent starts at alignment, and split extents that do not
satisfy the rest of the request are rounded down to alignment so
large aligned requests are not fragmented into smaller chunks. The
target vector is replaced with the placed RAM extents when
Self::allocate succeeds.
Sourcepub fn allocate(self) -> Result<Vec<PlacedRange>, AllocateError>
pub fn allocate(self) -> Result<Vec<PlacedRange>, AllocateError>
Allocates all requests, fills in each target, and returns every placed range sorted by address.