[][src]Struct sunrise_kernel::paging::mapping::Mapping

pub struct Mapping {
    address: VirtualAddress,
    length: usize,
    state: MemoryState,
    frames: MappingFrames,
    offset: usize,
    flags: MappingAccessRights,
}

A memory mapping. Stores the address, the length, and the type it maps. A mapping is guaranteed to have page aligned address, length and offset, and the length will never be zero.

If the mapping maps physical frames, we also guarantee that the mapping contains enough physical frames to cover the whole virtual mapping (taking into account length and offset).

Getting the last address of this mapping (length - 1 + address) is guaranteed to not overflow. However we do not make any assumption on address + length, which falls outside of the mapping.

Fields

address: VirtualAddress

The first address of this mapping.

length: usize

The length of this mapping.

state: MemoryState

The type of this mapping.

frames: MappingFrames

The frames this mapping is referencing.

offset: usize

Physical frame offset of this mapping,

flags: MappingAccessRights

The access rights of this mapping.

Implementations

impl Mapping[src]

pub fn new(
    address: VirtualAddress,
    frames: MappingFrames,
    offset: usize,
    length: usize,
    ty: MemoryType,
    flags: MappingAccessRights
) -> Result<Mapping, KernelError>
[src]

Tries to construct a mapping.

Errors

  • InvalidAddress:
    • address is not page aligned.
    • offset is not page aligned.
    • offset is bigger than the amount of pages in frames.
    • address plus length would overflow.
  • InvalidSize:
    • length is bigger than the amount of pages in frames, minus the offset.
    • length is zero.
    • length is not page-aligned.
  • WrongMappingFramesForTy:
    • frames didnt' contain the variant of MappingFrames expected by ty.

pub fn address(&self) -> VirtualAddress[src]

Returns the address of this mapping.

Because we make guarantees about a mapping being always valid, this field cannot be public.

pub fn length(&self) -> usize[src]

Returns the address of this mapping.

Because we make guarantees about a mapping being always valid, this field cannot be public.

pub fn frames(&self) -> &MappingFrames[src]

Returns the frames in this mapping.

pub fn frames_it(
    &self
) -> impl Iterator<Item = PhysicalAddress> + Clone + Debug + '_
[src]

Returns an iterator over the Physical Addresses mapped by this region. This takes into account the physical offset and the length of the mapping.

pub fn phys_offset(&self) -> usize[src]

Returns the offset in frames this mapping starts from.

This will be different from 0 when this mapping was created as a partial remapping of a different shared memory mapping (such as when creating an IPC buffer).

pub fn state(&self) -> MemoryState[src]

Returns the MemoryState of this mapping.

pub fn flags(&self) -> MappingAccessRights[src]

Returns the type of this mapping.

Because we make guarantees about a mapping being always valid, this field cannot be public.

Trait Implementations

impl Debug for Mapping[src]

Auto Trait Implementations

impl !RefUnwindSafe for Mapping

impl Send for Mapping

impl Sync for Mapping

impl Unpin for Mapping

impl !UnwindSafe for Mapping

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.