Skip to content

Add a system call return test that tries all syscall types - #583

Open
bradjc wants to merge 5 commits into
masterfrom
dev/syscall-return-test
Open

Add a system call return test that tries all syscall types#583
bradjc wants to merge 5 commits into
masterfrom
dev/syscall-return-test

Conversation

@bradjc

@bradjc bradjc commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Matches tock/tock#5083

To accomplish this, this PR also:

  • Adds the helper functions for all of the remaining command return types.
  • Implements the converters for rv64 support.
  • Fixes the riscv command implementation which was using only u32 types.
  • Adds a test which calls each command/subscribe/allow and checks the return values.

@brghena brghena left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question for you right now

Comment thread libtock/tock.h
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*);

@brghena brghena Aug 25, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants