pub struct RawMapping<'phys_allocator, R: Mappable, A: AddressSpaceTy = Kernel> {
raw: R,
address_space: ManuallyDrop<A>,
contiguity: RawMappingContiguity,
virtual_valid_start: Page,
physical_len: NonZero<usize>,
allocator: &'phys_allocator dyn PhysicalAllocator,
protection: Protection,
}use_std only.Expand description
The raw type underlying all memory mappings.
This will allocate any required memory when created, and register any lazily mapped memory as such. It will also manage the page tables to correctly unmap the memory when dropped.
Fields§
§raw: R§address_space: ManuallyDrop<A>The address space mapped into
contiguity: RawMappingContiguityWhether the underlying physical memory is contiguous or not
virtual_valid_start: PageThe first page in the mapping that is mapped to physical memory.
The region of virtual memory from virtual_valid_start to virtual_valid_start + physical_length is mapped.
physical_len: NonZero<usize>The number of physical pages allocated to the mapping
allocator: &'phys_allocator dyn PhysicalAllocatorThe physical allocator used for memory allocation
protection: ProtectionThe protection used when mapping pages into this mapping
Implementations§
Source§impl<'phys_alloc, R: Mappable> RawMapping<'phys_alloc, R, Kernel>
impl<'phys_alloc, R: Mappable> RawMapping<'phys_alloc, R, Kernel>
1.1.0 · Sourcepub fn new(
config: Config<'phys_alloc, Kernel>,
reason: u16,
raw: R,
) -> Result<Self, AllocError>
pub fn new( config: Config<'phys_alloc, Kernel>, reason: u16, raw: R, ) -> Result<Self, AllocError>
Create a new memory mapping with the given configuration
All physical memory used for the initial allocation will be contiguous. This may change in future.
§Errors
If the required physical or virtual memory could not be allocation, AllocError is returned.
§Panics
If the page tables already contained a mapping for the newly allocated virtual memory.
Source§impl<'phys_alloc, R: Mappable> RawMapping<'phys_alloc, R, Userspace>
impl<'phys_alloc, R: Mappable> RawMapping<'phys_alloc, R, Userspace>
1.1.0 · Sourcepub fn new_in(
config: Config<'phys_alloc, Userspace>,
reason: u16,
raw: R,
) -> Result<Self, AllocError>
pub fn new_in( config: Config<'phys_alloc, Userspace>, reason: u16, raw: R, ) -> Result<Self, AllocError>
Create a new memory mapping with the given configuration
All physical memory used for the initial allocation will be contiguous. This may change in future.
§Errors
If the required physical or virtual memory could not be allocation, AllocError is returned.
§Panics
If the page tables already contained a mapping for the newly allocated virtual memory.
Source§impl<'phys_alloc, R: Mappable, A: AddressSpaceTy> RawMapping<'phys_alloc, R, A>
impl<'phys_alloc, R: Mappable, A: AddressSpaceTy> RawMapping<'phys_alloc, R, A>
fn new_at( config: Config<'phys_alloc, A>, reason: u16, virtual_mem: OwnedPages<A>, raw: R, ) -> Result<Self, AllocError>
Sourcepub fn into_contiguous_raw_parts(
self,
) -> Result<(OwnedFrames<'phys_alloc>, OwnedPages<A>, Protection, R), DiscontiguityError>
🔬This is a nightly-only experimental API. (kernel_mmap_to_parts #24)
pub fn into_contiguous_raw_parts( self, ) -> Result<(OwnedFrames<'phys_alloc>, OwnedPages<A>, Protection, R), DiscontiguityError>
kernel_mmap_to_parts #24)Destructure into the underlying OwnedFrames and OwnedPages that back the allocation
Depending on the implementation of Mappable used, these may be different length.
These can be turned back into a RawMapping by calling [from_raw_parts()].
§Errors
If the underlying physical memory is not contiguous, and so cannot be represented as a single instance
of OwnedFrames, DiscontiguityError is returned.
pub unsafe fn from_contiguous_raw_parts( frames: OwnedFrames<'phys_alloc>, pages: OwnedPages<A>, protection: Protection, raw: R, ) -> Self
kernel_mmap_to_parts #24)fn virtual_len(&self) -> NonZero<usize>
pub fn virtual_start(&self) -> Page
kernel_mmap_to_parts #24)fn virtual_valid_start(&self) -> Page
pub fn virtual_end(&self) -> Page
kernel_mmap_to_parts #24)pub fn physical_len(&self) -> NonZero<usize>
kernel_mmap_to_parts #24)pub fn physical_start(&self) -> Result<Frame, DiscontiguityError>
kernel_mmap_to_parts #24)pub fn physical_end(&self) -> Result<Frame, DiscontiguityError>
kernel_mmap_to_parts #24)pub fn protection(&self) -> Protection
kernel_mmap_to_parts #24)1.1.0 · Sourcepub fn resize_in_place(
&mut self,
new_len: NonZero<usize>,
) -> Result<Page, AllocError>
pub fn resize_in_place( &mut self, new_len: NonZero<usize>, ) -> Result<Page, AllocError>
Attempts to resize the allocation to new_len without moving the allocation
If the allocation could be resized, the Page corresponding to the previous end of the mapping.
If it could not be resized, it returns the AllocError from the underlying allocators.