Skip to content

Commit

Permalink
xous: add api support for Scalar5
Browse files Browse the repository at this point in the history
Add syscall and return definitions for Scalar5, as well as
ReturnScalar5. This will enable us to pass up to five scalars as a
return from a blockingscalar call.

Signed-off-by: Sean Cross <sean@xobs.io>
  • Loading branch information
xobs committed Nov 5, 2022
1 parent f861af7 commit c8bb039
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
5 changes: 5 additions & 0 deletions xous-rs/src/definitions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ pub enum Result {
/// the caller.
NewProcess(ProcessStartup),

/// 20: A scalar with five values
Scalar5(usize, usize, usize, usize, usize),

UnknownResult(usize, usize, usize, usize, usize, usize, usize),
}

Expand Down Expand Up @@ -523,6 +526,7 @@ impl Result {
0,
],
Result::NewProcess(p) => Self::add_opcode(19, p.into()),
Result::Scalar5(a, b, c, d, e) => [15, *a, *b, *c, *d, *e, 0, 0],
Result::UnknownResult(arg1, arg2, arg3, arg4, arg5, arg6, arg7) => {
[usize::MAX, *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7]
}
Expand Down Expand Up @@ -600,6 +604,7 @@ impl Result {
17 => Result::None,
18 => Result::MemoryReturned(MemorySize::new(src[1]), MemorySize::new(src[2])),
19 => Result::NewProcess(src.into()),
20 => Result::Scalar5(src[1], src[2], src[3], src[4], src[5]),
_ => Result::UnknownResult(src[0], src[1], src[2], src[3], src[4], src[5], src[6]),
}
}
Expand Down
43 changes: 26 additions & 17 deletions xous-rs/src/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,10 +467,11 @@ pub enum SysCall {
///
/// ## Errors
/// * **BadAddress**: The mapping does not exist
#[cfg(feature="v2p")]
VirtToPhys(
usize, /* virtual address */
),
#[cfg(feature = "v2p")]
VirtToPhys(usize /* virtual address */),

/// Return five scalars to the sender
ReturnScalar5(MessageSender, usize, usize, usize, usize, usize),

/// This syscall does not exist. It captures all possible
/// arguments so detailed analysis can be performed.
Expand Down Expand Up @@ -516,8 +517,9 @@ pub enum SysCallNumber {
JoinThread = 36,
SetExceptionHandler = 37,
AdjustProcessLimit = 38,
#[cfg(feature="v2p")]
#[cfg(feature = "v2p")]
VirtToPhys = 39,
ReturnScalar5 = 40,
Invalid,
}

Expand Down Expand Up @@ -562,8 +564,9 @@ impl SysCallNumber {
36 => JoinThread,
37 => SetExceptionHandler,
38 => AdjustProcessLimit,
#[cfg(feature="v2p")]
#[cfg(feature = "v2p")]
39 => VirtToPhys,
40 => ReturnScalar5,
_ => Invalid,
}
}
Expand Down Expand Up @@ -928,15 +931,18 @@ impl SysCall {
0,
0,
],
#[cfg(feature="v2p")]
SysCall::VirtToPhys(vaddr) => [
SysCallNumber::VirtToPhys as usize,
*vaddr,
0,
0,
0,
0,
0,
#[cfg(feature = "v2p")]
SysCall::VirtToPhys(vaddr) => {
[SysCallNumber::VirtToPhys as usize, *vaddr, 0, 0, 0, 0, 0, 0]
}
SysCall::ReturnScalar5(sender, arg1, arg2, arg3, arg4, arg5) => [
SysCallNumber::ReturnScalar5 as usize,
sender.to_usize(),
*arg1,
*arg2,
*arg3,
*arg4,
*arg5,
0,
],
SysCall::Invalid(a1, a2, a3, a4, a5, a6, a7) => [
Expand Down Expand Up @@ -1103,8 +1109,11 @@ impl SysCall {
SysCallNumber::JoinThread => SysCall::JoinThread(a1 as _),
SysCallNumber::SetExceptionHandler => SysCall::SetExceptionHandler(a1 as _, a2 as _),
SysCallNumber::AdjustProcessLimit => SysCall::AdjustProcessLimit(a1, a2, a3),
#[cfg(feature="v2p")]
#[cfg(feature = "v2p")]
SysCallNumber::VirtToPhys => SysCall::VirtToPhys(a1 as _),
SysCallNumber::ReturnScalar5 => {
SysCall::ReturnScalar5(MessageSender::from_usize(a1), a2, a3, a4, a5, a6)
}
SysCallNumber::Invalid => SysCall::Invalid(a1, a2, a3, a4, a5, a6, a7),
})
}
Expand Down Expand Up @@ -1872,7 +1881,7 @@ pub fn set_exception_handler(
*/

/// Translate a virtual address to a physical address
#[cfg(feature="v2p")]
#[cfg(feature = "v2p")]
pub fn virt_to_phys(va: usize) -> core::result::Result<usize, Error> {
rsyscall(SysCall::VirtToPhys(va)).and_then(|result| {
if let Result::Scalar1(pa) = result {
Expand Down

0 comments on commit c8bb039

Please sign in to comment.