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
.