Skip to content

Commit

Permalink
kernel: process: add get_short_id() to ProcessId
Browse files Browse the repository at this point in the history
This allows capsules to access the short ID to determine which app a
process is and to act accordingly.
  • Loading branch information
bradjc committed Jan 14, 2024
1 parent 99edd4f commit 8543a54
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions kernel/src/process.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,21 @@ impl ProcessId {
self.identifier
}

/// Get the `ShortID` for this application this process is an execution of.
///
/// The `ShortID` is an identifier for the _application_, not the particular
/// execution (i.e. the currently running process). This makes `ShortID`
/// distinct from `ProcessId`.
///
/// This function is a helper function as capsules typically use `ProcessId`
/// as a handle to the running process and corresponding app.
pub fn short_app_id(&self) -> ShortID {
self.kernel
.process_map_or(ShortID::LocallyUnique, *self, |process| {
process.short_app_id()
})
}

/// 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,
Expand Down

0 comments on commit 8543a54

Please sign in to comment.