pub struct Usercopy { /* private fields */ }
Implementations§
source§impl Usercopy
impl Usercopy
sourcepub fn new(restricted_address_range: Range<usize>) -> Result<Self, Status>
pub fn new(restricted_address_range: Range<usize>) -> Result<Self, Status>
Returns a new instance of Usercopy
if unified address spaces is
supported on the target architecture.
sourcepub unsafe fn raw_hermetic_copy(
&self,
dest: *mut u8,
source: *const u8,
count: usize,
ret_dest: bool,
) -> usize
pub unsafe fn raw_hermetic_copy( &self, dest: *mut u8, source: *const u8, count: usize, ret_dest: bool, ) -> usize
Copies bytes from the source address to the destination address.
§Safety
Only one of source
/dest
may be an address to a buffer owned by user/restricted-mode
(ret_dest
indicates whether the user-owned buffer is dest
when true
).
The other must be a valid Starnix/normal-mode buffer that will never cause a fault
when the first count
bytes are read/written.
sourcepub fn zero(&self, dest_addr: usize, count: usize) -> usize
pub fn zero(&self, dest_addr: usize, count: usize) -> usize
Zeros count
bytes to starting at dest_addr
.
Returns the number of bytes zeroed.
sourcepub fn copyout(&self, source: &[u8], dest_addr: usize) -> usize
pub fn copyout(&self, source: &[u8], dest_addr: usize) -> usize
Copies data from source
to the restricted address dest_addr
.
Returns the number of bytes copied.
sourcepub fn copyin<'a>(
&self,
source_addr: usize,
dest: &'a mut [MaybeUninit<u8>],
) -> (&'a mut [u8], &'a mut [MaybeUninit<u8>])
pub fn copyin<'a>( &self, source_addr: usize, dest: &'a mut [MaybeUninit<u8>], ) -> (&'a mut [u8], &'a mut [MaybeUninit<u8>])
Copies data from the restricted address source_addr
to dest
.
Returns the read and unread bytes.
The returned slices will always reference dest
. Because of this, it is
guaranteed that that dest
and the returned initialized slice will have
the same address.
sourcepub fn copyin_until_null_byte<'a>(
&self,
source_addr: usize,
dest: &'a mut [MaybeUninit<u8>],
) -> (&'a mut [u8], &'a mut [MaybeUninit<u8>])
pub fn copyin_until_null_byte<'a>( &self, source_addr: usize, dest: &'a mut [MaybeUninit<u8>], ) -> (&'a mut [u8], &'a mut [MaybeUninit<u8>])
Copies data from the restricted address source_addr
to dest
until the
first null byte.
Returns the read and unread bytes. The read bytes includes the null byte if present.
The returned slices will always reference dest
. Because of this, it is
guaranteed that that dest
and the returned initialized slice will have
the same address.
sourcepub fn atomic_load_u32_relaxed(&self, addr: usize) -> Result<u32, ()>
pub fn atomic_load_u32_relaxed(&self, addr: usize) -> Result<u32, ()>
Performs an atomic load of a 32 bit value at addr
.
addr
must be aligned to 4 bytes.
sourcepub fn atomic_load_u32_acquire(&self, addr: usize) -> Result<u32, ()>
pub fn atomic_load_u32_acquire(&self, addr: usize) -> Result<u32, ()>
Performs an atomic load of a 32 bit value at addr
.
addr
must be aligned to 4 bytes.
sourcepub fn atomic_store_u32_relaxed(
&self,
addr: usize,
value: u32,
) -> Result<(), ()>
pub fn atomic_store_u32_relaxed( &self, addr: usize, value: u32, ) -> Result<(), ()>
Performs an atomic store of a 32 bit value to addr
.
addr
must be aligned to 4 bytes.
sourcepub fn atomic_store_u32_release(
&self,
addr: usize,
value: u32,
) -> Result<(), ()>
pub fn atomic_store_u32_release( &self, addr: usize, value: u32, ) -> Result<(), ()>
Performs an atomic store of a 32 bit value to addr
.
addr
must be aligned to 4 bytes.