Struct kernel::upcall::Upcall

source ·
pub(crate) struct Upcall {
    pub(crate) process_id: ProcessId,
    pub(crate) upcall_id: UpcallId,
    pub(crate) appdata: usize,
    pub(crate) fn_ptr: Option<NonNull<()>>,
}
Expand description

Type for calling an upcall in a process.

This is essentially a wrapper around a function pointer with associated process data.

Fields§

§process_id: ProcessId

The ProcessId of the process this upcall is for.

§upcall_id: UpcallId

A unique identifier of this particular upcall, representing the driver_num and subdriver_num used to submit it.

§appdata: usize

The application data passed by the app when subscribe() was called.

§fn_ptr: Option<NonNull<()>>

A pointer to the first instruction of the function in the app that corresponds to this upcall.

If this value is None, this is a null upcall, which cannot actually be scheduled. An Upcall can be null when it is first created, or after an app unsubscribes from an upcall.

Implementations§

source§

impl Upcall

source

pub(crate) fn new( process_id: ProcessId, upcall_id: UpcallId, appdata: usize, fn_ptr: Option<NonNull<()>>, ) -> Upcall

source

pub(crate) fn schedule( &self, process: &dyn Process, r0: usize, r1: usize, r2: usize, ) -> Result<(), UpcallError>

Schedule the upcall.

This will queue the Upcall for the given process. It returns false if the queue for the process is full and the upcall could not be scheduled or this is a null upcall.

The arguments (r0-r2) are the values passed back to the process and are specific to the individual Driver interfaces.

This function also takes process as a parameter (even though we have process_id in our struct) to avoid a search through the processes array to schedule the upcall. Currently, it is convenient to pass this parameter so we take advantage of it. If in the future that is not the case we could have process be an Option and just do the search with the stored process_id.

source

pub(crate) fn into_subscribe_success(self) -> SyscallReturn

Create a successful syscall return type suitable for returning to userspace.

This function is intended to be called on the “old upcall” that is being returned to userspace after a successful subscribe call and upcall swap.

We provide this .into function because the return type needs to include the function pointer of the upcall.

source

pub(crate) fn into_subscribe_failure(self, err: ErrorCode) -> SyscallReturn

Create a failure case syscall return type suitable for returning to userspace.

This is intended to be used when a subscribe call cannot be handled and the function pointer passed from userspace must be returned back to userspace.

We provide this .into function because the return type needs to include the function pointer of the upcall.

Auto Trait Implementations§

§

impl Freeze for Upcall

§

impl !RefUnwindSafe for Upcall

§

impl !Send for Upcall

§

impl !Sync for Upcall

§

impl Unpin for Upcall

§

impl !UnwindSafe for Upcall

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.