xous: hosted: read back memory for TrySendMessage

Like SendMessage, the TrySendMessage requires us to read back memory.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-08-30 17:38:24 +08:00
parent 7a2e5fbde8
commit 1a0bb99890

View file

@ -520,7 +520,8 @@ fn _xous_syscall_result(
// println!(" Waiting again"); // println!(" Waiting again");
continue; continue;
} }
if let crate::SysCall::SendMessage(_, ref msg) = call { match &call {
crate::SysCall::SendMessage(_, msg) | crate::SysCall::TrySendMessage(_, msg) => {
match msg { match msg {
crate::Message::MutableBorrow(crate::MemoryMessage { crate::Message::MutableBorrow(crate::MemoryMessage {
id: _id, id: _id,
@ -530,8 +531,9 @@ fn _xous_syscall_result(
}) => { }) => {
// Read the buffer back from the remote host. // Read the buffer back from the remote host.
use core::slice; use core::slice;
let mut data = let mut data = unsafe {
unsafe { slice::from_raw_parts_mut(buf.addr.get() as _, buf.size.get()) }; slice::from_raw_parts_mut(buf.addr.get() as _, buf.size.get())
};
stream.read_exact(&mut data).expect("Server shut down"); stream.read_exact(&mut data).expect("Server shut down");
// pkt.extend_from_slice(data); // pkt.extend_from_slice(data);
} }
@ -546,7 +548,8 @@ fn _xous_syscall_result(
use core::slice; use core::slice;
let mut check_data = Vec::new(); let mut check_data = Vec::new();
check_data.resize(buf.len(), 0); check_data.resize(buf.len(), 0);
let data = unsafe { slice::from_raw_parts_mut(buf.as_mut_ptr(), buf.len()) }; let data =
unsafe { slice::from_raw_parts_mut(buf.as_mut_ptr(), buf.len()) };
stream stream
.read_exact(&mut check_data) .read_exact(&mut check_data)
.expect("Server shut down"); .expect("Server shut down");
@ -564,6 +567,8 @@ fn _xous_syscall_result(
crate::Message::Scalar(_) => (), crate::Message::Scalar(_) => (),
} }
} }
_ => (),
}
// Now that we have the Stream mutex, temporarily take the Mailbox mutex to see if // Now that we have the Stream mutex, temporarily take the Mailbox mutex to see if
// this thread ID is there. If it is, there's no need to read via the network. // this thread ID is there. If it is, there's no need to read via the network.