[−][src]Struct sunrise_kernel::paging::mapping::Mapping
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]
address: VirtualAddress,
frames: MappingFrames,
offset: usize,
length: usize,
ty: MemoryType,
flags: MappingAccessRights
) -> Result<Mapping, KernelError>
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 inframes
.address
pluslength
would overflow.
InvalidSize
:length
is bigger than the amount of pages inframes
, minus the offset.length
is zero.length
is not page-aligned.
WrongMappingFramesForTy
:frames
didnt' contain the variant of MappingFrames expected byty
.
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]
&self
) -> impl Iterator<Item = PhysicalAddress> + Clone + Debug + '_
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
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
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>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,