pub type UserspaceReadableProcessBuffer = ReadWriteProcessBuffer;
Expand description
A shareable region of userspace memory.
This trait can be used to gain read-write access to memory regions wrapped in a ProcessBuffer type.
Aliased Type§
struct UserspaceReadableProcessBuffer { /* private fields */ }
Implementations
Source§impl ReadWriteProcessBuffer
impl ReadWriteProcessBuffer
Sourcepub unsafe fn new_external(
ptr: *mut u8,
len: usize,
process_id: ProcessId,
_cap: &dyn ExternalProcessCapability,
) -> Self
pub unsafe fn new_external( ptr: *mut u8, len: usize, process_id: ProcessId, _cap: &dyn ExternalProcessCapability, ) -> Self
Construct a new ReadWriteProcessBuffer
over a given
pointer and length.
Publicly accessible constructor, which requires the
capabilities::ExternalProcessCapability
capability. This
is provided to allow implementations of the
Process
trait outside of the
kernel
crate.
§Safety requirements
If the length is 0
, an arbitrary pointer may be passed into
ptr
. It does not necessarily have to point to allocated
memory, nor does it have to meet Rust’s pointer validity
requirements.
ReadWriteProcessBuffer
must ensure that all Rust slices
with a length of 0
must be constructed over a valid (but not
necessarily allocated) base pointer.
If the length is not 0
, the memory region of [ptr; ptr + len)
must be valid memory of the process of the given
ProcessId
. It must be allocated and and accessible over
the entire lifetime of the ReadWriteProcessBuffer
. It must
not point to memory outside of the process’ accessible memory
range, or point (in part) to other processes or kernel
memory. The ptr
must meet Rust’s requirements for pointer
validity,
in particular it must have a minimum alignment of
core::mem::align_of::<u8>()
on the respective platform. It
must point to memory mapped as readable and optionally
writable and executable.
Sourcepub const fn const_default() -> Self
pub const fn const_default() -> Self
This is a const
version of Default::default
with the same
semantics.
Having a const initializer allows initializing a fixed-size
array with default values without the struct being marked
Copy
as such:
use kernel::processbuffer::ReadWriteProcessBuffer;
const DEFAULT_RWPROCBUF_VAL: ReadWriteProcessBuffer
= ReadWriteProcessBuffer::const_default();
let my_array = [DEFAULT_RWPROCBUF_VAL; 12];
Trait Implementations
Source§impl Default for ReadWriteProcessBuffer
impl Default for ReadWriteProcessBuffer
Source§impl WriteableProcessBuffer for ReadWriteProcessBuffer
impl WriteableProcessBuffer for ReadWriteProcessBuffer
Source§fn mut_enter<F, R>(&self, fun: F) -> Result<R, Error>where
F: FnOnce(&WriteableProcessSlice) -> R,
fn mut_enter<F, R>(&self, fun: F) -> Result<R, Error>where
F: FnOnce(&WriteableProcessSlice) -> R,
ReadWriteProcessBuffer
. Read more