[][src]Struct kernel::AppId

pub struct AppId { /* fields omitted */ }

Userspace app identifier.

This should be treated as an opaque type that can be used to represent an application on the board without requiring an actual reference to a ProcessType object. Having this AppId reference type is useful for managing ownership and type issues in Rust, but more importantly AppId serves as a tool for capsules to hold pointers to applications.

Since AppId implements Copy, having an AppId does not ensure that the process the AppId refers to is still valid. The process may have been removed, terminated, or restarted as a new process. Therefore, all uses of AppId in the kernel must check that the AppId is still valid. This check happens automatically when .index() is called, as noted by the return type: Option<usize>. .index() will return the index of the process in the processes array, but if the process no longer exists then None is returned.

Outside of the kernel crate, holders of an AppId may want to use .id() to retrieve a simple identifier for the process that can be communicated over a UART bus or syscall interface. This call is guaranteed to return a suitable identifier for the AppId, but does not check that the corresponding application still exists.

This type also provides capsules an interface for interacting with processes since they otherwise would have no reference to a ProcessType. Very limited operations are available through this interface since capsules should not need to know the details of any given process. However, certain information makes certain capsules possible to implement. For example, capsules can use the get_editable_flash_range() function so they can safely allow an app to modify its own flash.

Implementations

impl AppId[src]

pub fn id(&self) -> usize[src]

Get a usize unique identifier for the app this AppId refers to.

This function should not generally be used, instead code should just use the AppId object itself to refer to various apps on the system. However, getting just a usize identifier is particularly useful when referring to a specific app with things outside of the kernel, say for userspace (e.g. IPC) or tockloader (e.g. for debugging) where a concrete number is required.

Note, this will always return the saved unique identifier for the app originally referred to, even if that app no longer exists. For example, the app may have restarted, or may have been ended or removed by the kernel. Therefore, calling id() is not a valid way to check that an application still exists.

pub fn get_editable_flash_range(&self) -> (usize, usize)[src]

Returns the full address of the start and end of the flash region that the app owns and can write to. This includes the app's code and data and any padding at the end of the app. It does not include the TBF header, or any space that the kernel is using for any potential bookkeeping.

Trait Implementations

impl Clone for AppId[src]

impl Copy for AppId[src]

impl Debug for AppId[src]

impl Eq for AppId[src]

impl PartialEq<AppId> for AppId[src]

Auto Trait Implementations

impl !Send for AppId

impl !Sync for AppId

impl Unpin for AppId

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.