mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
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:
parent
7a2e5fbde8
commit
1a0bb99890
1 changed files with 46 additions and 41 deletions
|
|
@ -520,49 +520,54 @@ fn _xous_syscall_result(
|
||||||
// println!(" Waiting again");
|
// println!(" Waiting again");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let crate::SysCall::SendMessage(_, ref msg) = call {
|
match &call {
|
||||||
match msg {
|
crate::SysCall::SendMessage(_, msg) | crate::SysCall::TrySendMessage(_, msg) => {
|
||||||
crate::Message::MutableBorrow(crate::MemoryMessage {
|
match msg {
|
||||||
id: _id,
|
crate::Message::MutableBorrow(crate::MemoryMessage {
|
||||||
buf,
|
id: _id,
|
||||||
offset: _offset,
|
buf,
|
||||||
valid: _valid,
|
offset: _offset,
|
||||||
}) => {
|
valid: _valid,
|
||||||
// Read the buffer back from the remote host.
|
}) => {
|
||||||
use core::slice;
|
// Read the buffer back from the remote host.
|
||||||
let mut data =
|
use core::slice;
|
||||||
unsafe { slice::from_raw_parts_mut(buf.addr.get() as _, buf.size.get()) };
|
let mut data = unsafe {
|
||||||
stream.read_exact(&mut data).expect("Server shut down");
|
slice::from_raw_parts_mut(buf.addr.get() as _, buf.size.get())
|
||||||
// pkt.extend_from_slice(data);
|
};
|
||||||
|
stream.read_exact(&mut data).expect("Server shut down");
|
||||||
|
// pkt.extend_from_slice(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
crate::Message::Borrow(crate::MemoryMessage {
|
||||||
|
id: _id,
|
||||||
|
buf,
|
||||||
|
offset: _offset,
|
||||||
|
valid: _valid,
|
||||||
|
}) => {
|
||||||
|
// Read the buffer back from the remote host and ensure it's the same
|
||||||
|
use core::slice;
|
||||||
|
let mut check_data = Vec::new();
|
||||||
|
check_data.resize(buf.len(), 0);
|
||||||
|
let data =
|
||||||
|
unsafe { slice::from_raw_parts_mut(buf.as_mut_ptr(), buf.len()) };
|
||||||
|
stream
|
||||||
|
.read_exact(&mut check_data)
|
||||||
|
.expect("Server shut down");
|
||||||
|
|
||||||
|
assert_eq!(data, check_data.as_slice());
|
||||||
|
}
|
||||||
|
|
||||||
|
crate::Message::Move(crate::MemoryMessage {
|
||||||
|
id: _id,
|
||||||
|
buf: _buf,
|
||||||
|
offset: _offset,
|
||||||
|
valid: _valid,
|
||||||
|
}) => (),
|
||||||
|
// Nothing to do for Immutable borrow, since the memory can't change
|
||||||
|
crate::Message::Scalar(_) => (),
|
||||||
}
|
}
|
||||||
|
|
||||||
crate::Message::Borrow(crate::MemoryMessage {
|
|
||||||
id: _id,
|
|
||||||
buf,
|
|
||||||
offset: _offset,
|
|
||||||
valid: _valid,
|
|
||||||
}) => {
|
|
||||||
// Read the buffer back from the remote host and ensure it's the same
|
|
||||||
use core::slice;
|
|
||||||
let mut check_data = Vec::new();
|
|
||||||
check_data.resize(buf.len(), 0);
|
|
||||||
let data = unsafe { slice::from_raw_parts_mut(buf.as_mut_ptr(), buf.len()) };
|
|
||||||
stream
|
|
||||||
.read_exact(&mut check_data)
|
|
||||||
.expect("Server shut down");
|
|
||||||
|
|
||||||
assert_eq!(data, check_data.as_slice());
|
|
||||||
}
|
|
||||||
|
|
||||||
crate::Message::Move(crate::MemoryMessage {
|
|
||||||
id: _id,
|
|
||||||
buf: _buf,
|
|
||||||
offset: _offset,
|
|
||||||
valid: _valid,
|
|
||||||
}) => (),
|
|
||||||
// Nothing to do for Immutable borrow, since the memory can't change
|
|
||||||
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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue