mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
xous: add reply_and_receive_next_legacy call
This call is used to return values while simultaneously listening for new messages. The -legacy suffix is used to disambiguate scalar values, so we know whether to send Scalar1, Scalar2, or Scalar5 messages. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
64c88f9942
commit
d88254b1b1
2 changed files with 39 additions and 6 deletions
|
|
@ -92,7 +92,7 @@ impl MemoryMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
#[derive(Debug, PartialEq, Clone, Copy)]
|
#[derive(Debug, PartialEq, Clone, Copy, Default)]
|
||||||
/// A simple scalar message. This is similar to a `move` message.
|
/// A simple scalar message. This is similar to a `move` message.
|
||||||
pub struct ScalarMessage {
|
pub struct ScalarMessage {
|
||||||
pub id: MessageId,
|
pub id: MessageId,
|
||||||
|
|
@ -239,6 +239,15 @@ impl Message {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn scalar_message_mut(&mut self) -> Option<&mut ScalarMessage> {
|
||||||
|
match self {
|
||||||
|
Message::MutableBorrow(_)
|
||||||
|
| Message::Borrow(_)
|
||||||
|
| Message::Move(_)
|
||||||
|
| Message::Scalar(_) => None,
|
||||||
|
Message::BlockingScalar(scalar) => Some(scalar),
|
||||||
|
}
|
||||||
|
}
|
||||||
pub(crate) fn message_type(&self) -> usize {
|
pub(crate) fn message_type(&self) -> usize {
|
||||||
match *self {
|
match *self {
|
||||||
Message::MutableBorrow(_) => 1,
|
Message::MutableBorrow(_) => 1,
|
||||||
|
|
|
||||||
|
|
@ -850,15 +850,15 @@ impl SysCall {
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
],
|
],
|
||||||
SysCall::ReplyAndReceiveNext(sender, result, arg1, arg2, arg3, arg4) => [
|
SysCall::ReplyAndReceiveNext(sender, arg0, arg1, arg2, arg3, arg4, return_type) => [
|
||||||
SysCallNumber::ReturnMemory as usize,
|
SysCallNumber::ReplyAndReceiveNext as usize,
|
||||||
sender.to_usize(),
|
sender.to_usize(),
|
||||||
*result,
|
*arg0,
|
||||||
*arg1,
|
*arg1,
|
||||||
*arg2,
|
*arg2,
|
||||||
*arg3,
|
*arg3,
|
||||||
*arg4,
|
*arg4,
|
||||||
0,
|
*return_type,
|
||||||
],
|
],
|
||||||
|
|
||||||
SysCall::CreateThread(init) => {
|
SysCall::CreateThread(init) => {
|
||||||
|
|
@ -1086,7 +1086,7 @@ impl SysCall {
|
||||||
MemorySize::new(a5),
|
MemorySize::new(a5),
|
||||||
),
|
),
|
||||||
SysCallNumber::ReplyAndReceiveNext => {
|
SysCallNumber::ReplyAndReceiveNext => {
|
||||||
SysCall::ReplyAndReceiveNext(MessageSender::from_usize(a1), a2, a3, a4, a5, a6)
|
SysCall::ReplyAndReceiveNext(MessageSender::from_usize(a1), a2, a3, a4, a5, a6, a7)
|
||||||
}
|
}
|
||||||
SysCallNumber::CreateThread => {
|
SysCallNumber::CreateThread => {
|
||||||
SysCall::CreateThread(crate::arch::args_to_thread(a1, a2, a3, a4, a5, a6, a7)?)
|
SysCall::CreateThread(crate::arch::args_to_thread(a1, a2, a3, a4, a5, a6, a7)?)
|
||||||
|
|
@ -1936,6 +1936,30 @@ pub fn reply_and_receive_next(
|
||||||
server: SID,
|
server: SID,
|
||||||
msg: &mut Option<MessageEnvelope>,
|
msg: &mut Option<MessageEnvelope>,
|
||||||
) -> core::result::Result<(), crate::Error> {
|
) -> core::result::Result<(), crate::Error> {
|
||||||
|
reply_and_receive_next_legacy(server, msg, &mut 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Reply to the message, if one exists, and receive the next one.
|
||||||
|
/// If no message exists, delegate the call to `receive_syscall()`.
|
||||||
|
/// Allow specifying the scalar return type.
|
||||||
|
///
|
||||||
|
/// This is named `_legacy` because it is meant to work with calls that
|
||||||
|
/// expect both `Scalar1` and `Scalar2` values, in addition to `Scalar5`.
|
||||||
|
///
|
||||||
|
/// ## Arguments
|
||||||
|
///
|
||||||
|
/// * **server**: The SID of the server to receive messages from
|
||||||
|
/// * **msg**: An Option<MessageEnvelope> specifying the message to return.
|
||||||
|
/// * **return_type**: If 1 or 2, responds to a BlockingScalarMessage
|
||||||
|
/// with a Scalar1 or a Scalar2. Otherwise, will respond
|
||||||
|
/// as normal.
|
||||||
|
pub fn reply_and_receive_next_legacy(
|
||||||
|
server: SID,
|
||||||
|
msg: &mut Option<MessageEnvelope>,
|
||||||
|
return_type: &mut usize,
|
||||||
|
) -> core::result::Result<(), crate::Error> {
|
||||||
|
let rt = *return_type;
|
||||||
|
*return_type = 0;
|
||||||
if let Some(envelope) = msg.take() {
|
if let Some(envelope) = msg.take() {
|
||||||
// If the message inside is nonblocking, then there's nothing to return.
|
// If the message inside is nonblocking, then there's nothing to return.
|
||||||
// Delegate reception to the `receive_message()` call
|
// Delegate reception to the `receive_message()` call
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue