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 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_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) -> HandleRef<'_>
fn as_handle_ref(&self) -> HandleRef<'_>
object_wait_many
.source§fn raw_handle(&self) -> zx_handle_t
fn raw_handle(&self) -> zx_handle_t
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: MonotonicInstant,
) -> Result<Signals, Status>
fn wait_handle( &self, signals: Signals, deadline: MonotonicInstant, ) -> Result<Signals, Status>
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>
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 into_raw(self) -> zx_handle_t
fn into_raw(self) -> zx_handle_t
source§fn from_handle(handle: Handle) -> Self
fn from_handle(handle: Handle) -> Self
source§fn into_handle_based<H: HandleBased>(self) -> H
fn into_handle_based<H: HandleBased>(self) -> H
source§fn from_handle_based<H: HandleBased>(h: H) -> Self
fn from_handle_based<H: HandleBased>(h: H) -> Self
fn is_invalid_handle(&self) -> bool
source§impl Ord for Vmar
impl Ord for Vmar
source§impl PartialEq for Vmar
impl PartialEq for Vmar
source§impl PartialOrd for Vmar
impl PartialOrd for Vmar
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more