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§
Source§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>
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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.
Sourcepub 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§
Source§impl AsHandleRef for Vmar
impl AsHandleRef for Vmar
Source§fn as_handle_ref(&self) -> Unowned<'_, Handle>
fn as_handle_ref(&self) -> Unowned<'_, Handle>
object_wait_many
.Source§fn raw_handle(&self) -> u32
fn raw_handle(&self) -> u32
Source§fn signal_handle(
&self,
clear_mask: Signals,
set_mask: Signals,
) -> Result<(), Status>
fn signal_handle( &self, clear_mask: Signals, set_mask: Signals, ) -> Result<(), Status>
Source§fn wait_handle(
&self,
signals: Signals,
deadline: Instant<MonotonicTimeline>,
) -> WaitResult
fn wait_handle( &self, signals: Signals, deadline: Instant<MonotonicTimeline>, ) -> WaitResult
Source§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>
Source§fn get_name(&self) -> Result<Name, Status>
fn get_name(&self) -> Result<Name, Status>
Source§fn set_name(&self, name: &Name) -> Result<(), Status>
fn set_name(&self, name: &Name) -> Result<(), Status>
Source§fn basic_info(&self) -> Result<HandleBasicInfo, Status>
fn basic_info(&self) -> Result<HandleBasicInfo, Status>
Source§fn count_info(&self) -> Result<HandleCountInfo, Status>
fn count_info(&self) -> Result<HandleCountInfo, Status>
§impl FromWire<WireHandle> for Vmar
impl FromWire<WireHandle> for Vmar
§fn from_wire(wire: WireHandle) -> Vmar
fn from_wire(wire: WireHandle) -> Vmar
wire
to this type.§const COPY_OPTIMIZATION: CopyOptimization<W, Self> = _
const COPY_OPTIMIZATION: CopyOptimization<W, Self> = _
§impl FromWireOption<WireOptionalHandle> for Vmar
impl FromWireOption<WireOptionalHandle> for Vmar
§fn from_wire_option(wire: WireOptionalHandle) -> Option<Vmar>
fn from_wire_option(wire: WireOptionalHandle) -> Option<Vmar>
wire
to an option of this type.Source§impl HandleBased for Vmar
impl HandleBased for Vmar
Source§fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
fn duplicate_handle(&self, rights: Rights) -> Result<Self, Status>
Source§fn replace_handle(self, rights: Rights) -> Result<Self, Status>
fn replace_handle(self, rights: Rights) -> Result<Self, Status>
Source§fn into_handle(self) -> Handle
fn into_handle(self) -> Handle
Source§fn from_handle(handle: Handle) -> Self
fn from_handle(handle: Handle) -> Self
Source§fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
fn into_handle_based<H>(self) -> Hwhere
H: HandleBased,
Source§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
Source§impl Ord for Vmar
impl Ord for Vmar
Source§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
Source§impl<T> EncodableAsHandle for Twhere
T: HandleBased,
impl<T> EncodableAsHandle for Twhere
T: HandleBased,
Source§type Dialect = DefaultFuchsiaResourceDialect
type Dialect = DefaultFuchsiaResourceDialect
Source§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
§impl<T, W> FromWireOption<WireBox<'_, W>> for Twhere
T: FromWire<W>,
impl<T, W> FromWireOption<WireBox<'_, W>> for Twhere
T: FromWire<W>,
§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.