-
Notifications
You must be signed in to change notification settings - Fork 12
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
doc: add information about types used in the kernel #53
Open
bradjc
wants to merge
1
commit into
master
Choose a base branch
from
doc-types
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Types | ||
|
||
Certain types within the Tock kernel are chosen very deliberately. This aids | ||
with clarity on how the kernel works and helps with porting to new platforms. | ||
|
||
## Integer Types | ||
|
||
Many kernel interfaces use integer types (e.g., `usize` or `u32`). These types | ||
are often used because the contained value must fit in a hardware register, | ||
represents a memory address, or is a fixed width in an interface specification. | ||
The kernel should use these types very deliberately depending on the meaning of | ||
the underlying value. | ||
|
||
- Fixed-width integers (e.g., `u32`, `u8`, etc.): These types should be used | ||
when the value is meant to be precisely the specified number of bits and the | ||
width restriction has a particular semantic meaning. For example, this could | ||
be a timer value used within a system call interface, or a field in a TBF | ||
header. | ||
- Machine-sized types (e.g., `usize`): These types should be used for a value | ||
that should fit exactly into a register, like a abstract argument to the | ||
`command` syscall. | ||
- Constant pointer (e.g., `*const u8`): These types should be used for a value | ||
that refers to an address but userspace does not have access to. For example, | ||
this could be the intended new boundary of the heap after calling `brk`. | ||
- Authenticated pointer (e.g., `AuthenticatedPtr`): This type should be used for | ||
a pointer that is provided to userspace. These pointers, on some systems, | ||
include additional information which allows userspace to dereference the | ||
pointer. On other systems this behaves as a traditional pointer. With any | ||
underlying implementation, this type expresses that the value is a pointer | ||
that userspace uses. |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this example really what we want to have? Way back when we talked about this for the 2.0 system call interface, we converged on having the current system call interface and driver traits use
u32
s consistently, and implement an additional, 64-bit specific trait for such platforms when we have them. I know that at least for command args, we're currently not living this reality, though we arguably ought to be.I still think this is a good idea, because this way we don't have to reason about edge-cases on different platforms for the system call interface. Driver (interfaces) behave identically across these platforms.
I'll have to check whether the CHERI PR (tock/tock#4174) changes this.