pub struct Grant<T: Default, Upcalls: UpcallSize, AllowROs: AllowRoSize, AllowRWs: AllowRwSize> { /* private fields */ }
Expand description
Type for storing an object of type T in process memory that is only accessible by the kernel.
A single Grant
can allocate space for one object of type T for each
process on the board. Each allocated object will reside in the grant region
belonging to the process that the object is allocated for. The Grant
type is used to get access to ProcessGrant
s, which are tied to a
specific process and provide access to the memory object allocated for that
process.
Implementations§
Source§impl<T: Default, Upcalls: UpcallSize, AllowROs: AllowRoSize, AllowRWs: AllowRwSize> Grant<T, Upcalls, AllowROs, AllowRWs>
impl<T: Default, Upcalls: UpcallSize, AllowROs: AllowRoSize, AllowRWs: AllowRwSize> Grant<T, Upcalls, AllowROs, AllowRWs>
Sourcepub fn enter<F, R>(&self, processid: ProcessId, fun: F) -> Result<R, Error>
pub fn enter<F, R>(&self, processid: ProcessId, fun: F) -> Result<R, Error>
Enter the grant for a specific process.
This creates a ProcessGrant
which is a handle for a grant allocated
for a specific process. Then, that ProcessGrant
is entered and the
provided closure is run with access to the memory in the grant region.
Sourcepub fn enter_with_allocator<F, R>(
&self,
processid: ProcessId,
fun: F,
) -> Result<R, Error>
pub fn enter_with_allocator<F, R>( &self, processid: ProcessId, fun: F, ) -> Result<R, Error>
Enter the grant for a specific process with access to an allocator.
This creates an ProcessGrant
which is a handle for a grant allocated
for a specific process. Then, that ProcessGrant
is entered and the
provided closure is run with access to the memory in the grant region.
The allocator allows the caller to dynamically allocate additional memory in the process’s grant region.
Sourcepub fn each<F>(&self, fun: F)
pub fn each<F>(&self, fun: F)
Run a function on the grant for each active process if the grant has been allocated for that process.
This will silently skip any process where the grant has not previously been allocated. This will also silently skip any invalid processes.
Calling this function when an ProcessGrant
for a process is
currently entered will result in a panic.
Sourcepub fn iter(&self) -> Iter<'_, T, Upcalls, AllowROs, AllowRWs> ⓘ
pub fn iter(&self) -> Iter<'_, T, Upcalls, AllowROs, AllowRWs> ⓘ
Get an iterator over all processes and their active grant regions for this particular grant.
Calling this function when an ProcessGrant
for a process is
currently entered will result in a panic.