-
-
Notifications
You must be signed in to change notification settings - Fork 770
Process trait improvements #3716
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
00eb525
60e5e97
32e109d
9404d48
4d9cfac
f450658
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ | |
|
||
use core::fmt; | ||
use core::fmt::Write; | ||
use core::num::NonZeroU32; | ||
use core::ptr::NonNull; | ||
use core::str; | ||
|
||
|
@@ -272,6 +273,17 @@ pub enum StoppedExecutingReason { | |
KernelPreemption, | ||
} | ||
|
||
/// The version of a binary. | ||
#[derive(PartialEq, Eq, PartialOrd, Ord, Debug)] | ||
pub struct BinaryVersion(NonZeroU32); | ||
alevy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
impl BinaryVersion { | ||
/// Creates a new binary version. | ||
pub fn new(value: NonZeroU32) -> Self { | ||
Self(value) | ||
} | ||
} | ||
|
||
/// This trait represents a generic process that the Tock scheduler can | ||
/// schedule. | ||
pub trait Process { | ||
|
@@ -283,9 +295,8 @@ pub trait Process { | |
fn short_app_id(&self) -> ShortID; | ||
|
||
/// Returns the version number of the binary in this process, as specified | ||
/// in a TBF Program Header; if the Userspace Binary only has a TBF Main | ||
/// Header, returns 0. | ||
fn binary_version(&self) -> u32; | ||
/// in a TBF Program Header; if the binary has no version assigned, return [None] | ||
fn binary_version(&self) -> Option<BinaryVersion>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously, 0 marked the absence of the binary version. This approach works, but Using a In the end, NonZeroU32 has been chosen as the underlying type of the new |
||
|
||
/// Queue a `Task` for the process. This will be added to a per-process | ||
/// buffer and executed by the scheduler. `Task`s are some function the app | ||
|
@@ -601,7 +612,7 @@ pub trait Process { | |
/// app_brk, as MPU alignment and size constraints may result in the MPU | ||
/// enforced region differing from the app_brk. | ||
/// | ||
/// This will return `false` and fail if: | ||
/// This will return `Err(())` and fail if: | ||
/// - The process is inactive, or | ||
/// - There is not enough available memory to do the allocation, or | ||
/// - The grant_num is invalid, or | ||
|
@@ -612,7 +623,7 @@ pub trait Process { | |
driver_num: usize, | ||
size: usize, | ||
align: usize, | ||
) -> bool; | ||
) -> Result<(), ()>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
/// Check if a given grant for this process has been allocated. | ||
/// | ||
|
@@ -625,14 +636,14 @@ pub trait Process { | |
/// are not recorded in the grant pointer array, but are useful for capsules | ||
/// which need additional process-specific dynamically allocated memory. | ||
/// | ||
/// If successful, return a Some() with an identifier that can be used with | ||
/// If successful, return a Ok() with an identifier that can be used with | ||
/// `enter_custom_grant()` to get access to the memory and the pointer to | ||
/// the memory which must be used to initialize the memory. | ||
fn allocate_custom_grant( | ||
&self, | ||
size: usize, | ||
align: usize, | ||
) -> Option<(ProcessCustomGrantIdentifier, NonNull<u8>)>; | ||
) -> Result<(ProcessCustomGrantIdentifier, NonNull<u8>), ()>; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This follows the pattern of returning a |
||
|
||
/// Enter the grant based on `grant_num` for this process. | ||
/// | ||
|
Uh oh!
There was an error while loading. Please reload this page.