xous: add api support for Scalar5

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>
This commit is contained in:
Sean Cross 2022-11-05 18:39:06 +08:00
parent f861af7620
commit c8bb039c41
2 changed files with 31 additions and 17 deletions

View file

@ -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),
}
@ -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]
}
@ -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]),
}
}

View file

@ -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.
@ -516,8 +517,9 @@ pub enum SysCallNumber {
JoinThread = 36,
SetExceptionHandler = 37,
AdjustProcessLimit = 38,
#[cfg(feature="v2p")]
#[cfg(feature = "v2p")]
VirtToPhys = 39,
ReturnScalar5 = 40,
Invalid,
}
@ -562,8 +564,9 @@ impl SysCallNumber {
36 => JoinThread,
37 => SetExceptionHandler,
38 => AdjustProcessLimit,
#[cfg(feature="v2p")]
#[cfg(feature = "v2p")]
39 => VirtToPhys,
40 => ReturnScalar5,
_ => Invalid,
}
}
@ -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) => [
@ -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),
})
}
@ -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 {