Skip to content

Commit

Permalink
xous: add api support for scalar5
Browse files Browse the repository at this point in the history
With the addition of scalar5, existing api calls must be updated to take
advantage of it. This will allow `send_message()` to return a `scalar5`.

Signed-off-by: Sean Cross <[email protected]>
  • Loading branch information
xobs committed Nov 5, 2022
1 parent da56475 commit c9f751f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions xous-rs/src/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ pub enum SysCall {
/// * **Ok**: The Scalar / Send message was successfully sent, or the Borrow has finished
/// * **Scalar1**: The Server returned a `Scalar1` value
/// * **Scalar2**: The Server returned a `Scalar2` value
/// * **Scalar5**: The Server returned a `Scalar5` value
/// * **BlockedProcess**: In Hosted mode, the target process is now blocked
///
/// # Errors
Expand All @@ -342,6 +343,7 @@ pub enum SysCall {
/// * **Ok**: The Scalar / Send message was successfully sent, or the Borrow has finished
/// * **Scalar1**: The Server returned a `Scalar1` value
/// * **Scalar2**: The Server returned a `Scalar2` value
/// * **Scalar5**: The Server returned a `Scalar5` value
/// * **BlockedProcess**: In Hosted mode, the target process is now blocked
///
/// # Errors
Expand Down Expand Up @@ -1210,6 +1212,7 @@ impl SysCall {
SysCall::TryConnect(_)
| SysCall::TryReceiveMessage(_)
| SysCall::ReturnToParent(_, _)
| SysCall::ReturnScalar5(_, _, _, _, _, _)
| SysCall::ReturnScalar2(_, _, _)
| SysCall::ReturnScalar1(_, _)
| SysCall::ReturnMemory(_, _, _, _)
Expand Down Expand Up @@ -1352,6 +1355,25 @@ pub fn return_scalar2(
}
}

/// Return 5 scalars to the provided message.
pub fn return_scalar5(
sender: MessageSender,
val1: usize,
val2: usize,
val3: usize,
val4: usize,
val5: usize,
) -> core::result::Result<(), Error> {
let result = rsyscall(SysCall::ReturnScalar5(sender, val1, val2, val3, val4, val5))?;
if let crate::Result::Ok = result {
Ok(())
} else if let Result::Error(e) = result {
Err(e)
} else {
Err(Error::InternalError)
}
}

/// Claim a hardware interrupt for this process.
pub fn claim_interrupt(
irq_no: usize,
Expand Down Expand Up @@ -1539,6 +1561,7 @@ pub fn try_send_message(connection: CID, message: Message) -> core::result::Resu
Ok(Result::Ok) => Ok(Result::Ok),
Ok(Result::Scalar1(a)) => Ok(Result::Scalar1(a)),
Ok(Result::Scalar2(a, b)) => Ok(Result::Scalar2(a, b)),
Ok(Result::Scalar5(a, b, c, d, e)) => Ok(Result::Scalar5(a, b, c, d, e)),
Ok(Result::MemoryReturned(offset, valid)) => Ok(Result::MemoryReturned(offset, valid)),
Err(e) => Err(e),
v => panic!("Unexpected return value: {:?}", v),
Expand Down Expand Up @@ -1581,6 +1604,7 @@ pub fn send_message(connection: CID, message: Message) -> core::result::Result<R
Ok(Result::Ok) => Ok(Result::Ok),
Ok(Result::Scalar1(a)) => Ok(Result::Scalar1(a)),
Ok(Result::Scalar2(a, b)) => Ok(Result::Scalar2(a, b)),
Ok(Result::Scalar5(a, b, c, d, e)) => Ok(Result::Scalar5(a, b, c, d, e)),
Ok(Result::MemoryReturned(offset, valid)) => Ok(Result::MemoryReturned(offset, valid)),
Err(e) => Err(e),
v => panic!("Unexpected return value: {:?}", v),
Expand Down

0 comments on commit c9f751f

Please sign in to comment.