Struct RawMapping

1.1.0 · Source
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,
}
Available on non-crate feature 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: RawMappingContiguity

Whether the underlying physical memory is contiguous or not

§virtual_valid_start: Page

The 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 PhysicalAllocator

The physical allocator used for memory allocation

§protection: Protection

The protection used when mapping pages into this mapping

Implementations§

Source§

impl<'phys_alloc, R: Mappable> RawMapping<'phys_alloc, R, Kernel>

1.1.0 · Source

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>

1.1.0 · Source

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>

Source

fn new_at( config: Config<'phys_alloc, A>, reason: u16, virtual_mem: OwnedPages<A>, raw: R, ) -> Result<Self, AllocError>

Source

pub 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)

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.

Source

pub unsafe fn from_contiguous_raw_parts( frames: OwnedFrames<'phys_alloc>, pages: OwnedPages<A>, protection: Protection, raw: R, ) -> Self

🔬This is a nightly-only experimental API. (kernel_mmap_to_parts #24)
Source

fn virtual_len(&self) -> NonZero<usize>

Source

pub fn virtual_start(&self) -> Page

🔬This is a nightly-only experimental API. (kernel_mmap_to_parts #24)
Source

fn virtual_valid_start(&self) -> Page

Source

pub fn virtual_end(&self) -> Page

🔬This is a nightly-only experimental API. (kernel_mmap_to_parts #24)
Source

pub fn physical_len(&self) -> NonZero<usize>

🔬This is a nightly-only experimental API. (kernel_mmap_to_parts #24)
Source

pub fn physical_start(&self) -> Result<Frame, DiscontiguityError>

🔬This is a nightly-only experimental API. (kernel_mmap_to_parts #24)
Source

pub fn physical_end(&self) -> Result<Frame, DiscontiguityError>

🔬This is a nightly-only experimental API. (kernel_mmap_to_parts #24)
Source

pub fn protection(&self) -> Protection

🔬This is a nightly-only experimental API. (kernel_mmap_to_parts #24)
1.1.0 · Source

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.

Trait Implementations§

1.1.0 · Source§

impl<R: Mappable, A: AddressSpaceTy> Debug for RawMapping<'_, R, A>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
1.1.0 · Source§

impl<R: Mappable, A: AddressSpaceTy> Drop for RawMapping<'_, R, A>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'phys_allocator, R, A> Freeze for RawMapping<'phys_allocator, R, A>
where R: Freeze, A: Freeze,

§

impl<'phys_allocator, R, A = Kernel> !RefUnwindSafe for RawMapping<'phys_allocator, R, A>

§

impl<'phys_allocator, R, A> Send for RawMapping<'phys_allocator, R, A>
where R: Send, A: Send,

§

impl<'phys_allocator, R, A> Sync for RawMapping<'phys_allocator, R, A>
where R: Sync, A: Sync,

§

impl<'phys_allocator, R, A> Unpin for RawMapping<'phys_allocator, R, A>
where R: Unpin, A: Unpin,

§

impl<'phys_allocator, R, A = Kernel> !UnwindSafe for RawMapping<'phys_allocator, R, A>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.