Add a system call return test that tries all syscall types - #583
Open
bradjc wants to merge 5 commits into
Open
Conversation
Verify we can get all return types in userspace correctly
brghena
reviewed
Aug 25, 2026
brghena
left a comment
Contributor
There was a problem hiding this comment.
One question for you right now
Comment on lines
+197
to
+216
| // Convert a `syscall_return_t` failure with one u32 to a `returncode_t`. | ||
| // | ||
| // This expects a failure with one u32 value (i.e. `TOCK_SYSCALL_FAILURE_U32`). | ||
| // Fills `val` with the failure u32 on failure. Do not use with other expected | ||
| // SyscallReturn variants. | ||
| returncode_t tock_command_return_failure_u32_to_returncode(syscall_return_t, uint32_t*); | ||
|
|
||
| // Convert a `syscall_return_t` failure with two u32 values to a `returncode_t`. | ||
| // | ||
| // This expects a failure with two u32 values (i.e. `TOCK_SYSCALL_FAILURE_U32_U32`). | ||
| // Fills `val1` and `val2` with the failure u32s on failure. Do not use with | ||
| // other expected SyscallReturn variants. | ||
| returncode_t tock_command_return_failure_u32_u32_to_returncode(syscall_return_t, uint32_t*, uint32_t*); | ||
|
|
||
| // Convert a `syscall_return_t` failure with a u64 value to a `returncode_t`. | ||
| // | ||
| // This expects a failure with one u64 value (i.e. `TOCK_SYSCALL_FAILURE_U64`). | ||
| // Fills `val` with the failure u64 on failure. Do not use with other expected | ||
| // SyscallReturn variants. | ||
| returncode_t tock_command_return_failure_u64_to_returncode(syscall_return_t, uint64_t*); |
Contributor
There was a problem hiding this comment.
I'm trying to decide if these failure variants are generally useful or only applicable to your test application.
Let's say I was building a capsule which either returns success with U32 and U64 or failure with U64. Is this how you'd propose it be implemented? Any problems with this?
syscall_return_t cval = command(...);
returncode_t ret = tock_command_return_u32_u64_to_returncode(cval, u32_ptr, u64_ptr);
if (ret != RETURNCODE_SUCCESS) {
return tock_command_return_failure_u64_to_returncode(cval, u64_ptr);
}For IPC, I made a tock_command_return_u32_u64_or_u64_to_returncode() function, but I'll admit that it did feel quite unwieldy. I could replace it with the above snippet.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Matches tock/tock#5083
To accomplish this, this PR also: