Struct Vmar
pub struct Vmar(/* private fields */);
Expand description
An object representing a Zircon virtual memory address region.
As essentially a subtype of Handle
, it can be freely interconverted.
Implementations§
§impl Vmar
impl Vmar
pub fn allocate( &self, offset: usize, size: usize, flags: VmarFlags, ) -> Result<(Vmar, usize), Status>
pub fn map( &self, vmar_offset: usize, vmo: &Vmo, vmo_offset: u64, len: usize, flags: VmarFlags, ) -> Result<usize, Status>
pub unsafe fn map_unsafe(
&self,
vmar_offset: usize,
vmo: &Vmo,
vmo_offset: u64,
len: usize,
flags: VmarFlagsExtended,
) -> Result<usize, Status>
pub unsafe fn map_unsafe( &self, vmar_offset: usize, vmo: &Vmo, vmo_offset: u64, len: usize, flags: VmarFlagsExtended, ) -> Result<usize, Status>
Directly call zx_vmar_map
.
§Safety
This function is unsafe because certain flags to zx_vmar_map
may
replace an existing mapping which is referenced elsewhere.
pub unsafe fn unmap(&self, addr: usize, len: usize) -> Result<(), Status>
pub unsafe fn unmap(&self, addr: usize, len: usize) -> Result<(), Status>
Directly call zx_vmar_unmap
.
§Safety
This function is unsafe because unmapping memory regions can arbitrarily cause read, write, and execution errors. Among other things, the caller must ensure that:
- The region being unmapped will not be accessed after unmapping.
- All references to memory in the region must be dropped or forgotten prior to calling this method.
- If the region contained executable code, then code in the region must not be currently executing and may not be executed in the future.
This is not an exhaustive list, as there are many ways to cause memory unsafety with memory mappings.
pub fn op_range(
&self,
op: VmarOp,
addr: usize,
len: usize,
) -> Result<(), Status>
pub fn op_range( &self, op: VmarOp, addr: usize, len: usize, ) -> Result<(), Status>
Perform an operation on VMOs mapped into this VMAR.
Wraps the zx_vmar_op_range syscall.
pub unsafe fn protect(
&self,
addr: usize,
len: usize,
flags: VmarFlags,
) -> Result<(), Status>
pub unsafe fn protect( &self, addr: usize, len: usize, flags: VmarFlags, ) -> Result<(), Status>
Directly call zx_vmar_protect
.
§Safety
This function is unsafe because changing the access protections for memory regions can arbitrarily cause read, write, and execution errors. Among other things, the caller must ensure that if a read, write, or execute permission is removed from a memory region, it must not read, write, or execute it respetively.
This is not an exhaustive list, as there are many ways to cause memory unsafety with memory mappings.
pub unsafe fn destroy(&self) -> Result<(), Status>
pub unsafe fn destroy(&self) -> Result<(), Status>
Directly call zx_vmar_destroy
.
§Safety
This function is unsafe because destroying a region unmaps all of the
mappings within it. See Vmar::unmap
for more details on how
unmapping memory regions can cause memory unsafety.
pub fn info(&self) -> Result<VmarInfo, Status>
pub fn info(&self) -> Result<VmarInfo, Status>
Wraps the zx_object_get_info syscall for the ZX_INFO_VMAR topic.
pub fn info_maps<'a>(
&self,
buf: &'a mut [MaybeUninit<MapInfo>],
) -> Result<(&'a mut [MapInfo], &'a mut [MaybeUninit<MapInfo>], usize), Status>
pub fn info_maps<'a>( &self, buf: &'a mut [MaybeUninit<MapInfo>], ) -> Result<(&'a mut [MapInfo], &'a mut [MaybeUninit<MapInfo>], usize), Status>
Wraps the zx_object_get_info syscall for the ZX_INFO_VMAR_MAPS topic.
Returns an initialized slice of MapInfo
s, any uninitialized trailing entries, and the
total number of infos that the kernel had available.
pub fn info_maps_vec(&self) -> Result<Vec<MapInfo>, Status>
pub fn info_maps_vec(&self) -> Result<Vec<MapInfo>, Status>
Wraps the zx_object_get_info syscall for the ZX_INFO_VMAR_MAPS topic.
Trait Implementations§
§impl AsHandleRef for Vmar
impl AsHandleRef for Vmar
§fn as_handle_ref(&self) -> Unowned<'_, Handle>
fn as_handle_ref(&self) -> Unowned<'_, Handle>
object_wait_many
.§fn raw_handle(&self) -> u32
fn raw_handle(&self) -> u32
§fn signal_handle(
&self,
clear_mask: Signals,
set_mask: Signals,
) -> Result<(), Status>
fn signal_handle( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>
§fn wait_handle(
&self,
signals: Signals,
deadline: Instant<MonotonicTimeline>,
) -> WaitResult
fn wait_handle( &self, signals: Signals, deadline: Instant<MonotonicTimeline>, ) -> WaitResult
§fn wait_async_handle(
&self,
port: &Port,
key: u64,
signals: Signals,
options: WaitAsyncOpts,
) -> Result<(), Status>
fn wait_async_handle( &self, port: &Port, key: u64, signals: Signals, options: WaitAsyncOpts, ) -> Result<(), Status>
§fn get_name(&self) -> Result<Name, Status>
fn get_name(&self) -> Result<Name, Status>
§fn set_name(&self, name: &Name) -> Result<(), Status>
fn set_name(&self, name: &Name) -> Result<(), Status>
§fn basic_info(&self) -> Result<HandleBasicInfo, Status>
fn basic_info(&self) -> Result<HandleBasicInfo, Status>
§fn count_info(&self) -> Result<HandleCountInfo, Status>
fn count_info(&self) -> Result<HandleCountInfo, Status>
Source§impl CompatFrom<Vmar> for Vmar
impl CompatFrom<Vmar> for Vmar
Source§fn compat_from(value: Vmar) -> Vmar
fn compat_from(value: Vmar) -> Vmar
value
into a value of this type.Source§impl Encodable for Vmar
impl Encodable for Vmar
Source§const COPY_OPTIMIZATION: CopyOptimization<Self, Self::Encoded> = _
const COPY_OPTIMIZATION: CopyOptimization<Self, Self::Encoded> = _
Self
to Self::Encoded
is equivalent to copying the raw bytes
of Self
. Read moreSource§impl EncodableOption for Vmar
impl EncodableOption for Vmar
Source§type EncodedOption = WireOptionalVmar
type EncodedOption = WireOptionalVmar
Source§impl<E> EncodeOption<E> for Vmarwhere
E: HandleEncoder + ?Sized,
impl<E> EncodeOption<E> for Vmarwhere
E: HandleEncoder + ?Sized,
Source§fn encode_option(
this: Option<Vmar>,
encoder: &mut E,
out: &mut MaybeUninit<<Vmar as EncodableOption>::EncodedOption>,
) -> Result<(), EncodeError>
fn encode_option( this: Option<Vmar>, encoder: &mut E, out: &mut MaybeUninit<<Vmar as EncodableOption>::EncodedOption>, ) -> Result<(), EncodeError>
Source§impl FromWire<WireVmar> for Vmar
impl FromWire<WireVmar> for Vmar
Source§const COPY_OPTIMIZATION: CopyOptimization<W, Self> = _
const COPY_OPTIMIZATION: CopyOptimization<W, Self> = _
Source§impl FromWireOption<WireOptionalVmar> for Vmar
impl FromWireOption<WireOptionalVmar> for Vmar
Source§fn from_wire_option(wire: WireOptionalVmar) -> Option<Vmar>
fn from_wire_option(wire: WireOptionalVmar) -> Option<Vmar>
wire
to an option of this type.§impl HandleBased for Vmar
impl HandleBased for Vmar
§fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
§fn replace_handle(self, rights: Rights) -> Result<Self, Status>
fn replace_handle(self, rights: Rights) -> Result<Self, Status>
§fn into_handle(self) -> Handle
fn into_handle(self) -> Handle
§fn from_handle(handle: Handle) -> Self
fn from_handle(handle: Handle) -> Self
§fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
§fn from_handle_based<H>(h: H) -> Selfwhere
H: HandleBased,
fn from_handle_based<H>(h: H) -> Selfwhere
H: HandleBased,
fn is_invalid_handle(&self) -> bool
§impl Ord for Vmar
impl Ord for Vmar
§impl PartialOrd for Vmar
impl PartialOrd for Vmar
impl Eq for Vmar
impl StructuralPartialEq for Vmar
Auto Trait Implementations§
impl Freeze for Vmar
impl RefUnwindSafe for Vmar
impl Send for Vmar
impl Sync for Vmar
impl Unpin for Vmar
impl UnwindSafe for Vmar
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> EncodableAsHandle for Twhere
T: HandleBased,
impl<T> EncodableAsHandle for Twhere
T: HandleBased,
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<T, W> FromWireOption<WireBox<'_, W>> for Twhere
T: FromWire<W>,
impl<T, W> FromWireOption<WireBox<'_, W>> for Twhere
T: FromWire<W>,
Source§fn from_wire_option(wire: WireBox<'_, W>) -> Option<T>
fn from_wire_option(wire: WireBox<'_, W>) -> Option<T>
wire
to an option of this type.