xous: syscall: add BlockingScalar to syscall handling

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2020-09-22 21:33:09 +08:00
parent 81a927e31f
commit 673577a10e
4 changed files with 26 additions and 71 deletions

View file

@ -19,7 +19,7 @@ forget-memory-messages = []
# so you can run log commands such as `info!()`. # so you can run log commands such as `info!()`.
logging = ["log"] logging = ["log"]
default = ["logging"] default = []
[target.'cfg(any(windows,unix))'.dependencies] [target.'cfg(any(windows,unix))'.dependencies]
lazy_static = "1.4" lazy_static = "1.4"

View file

@ -567,9 +567,9 @@ fn _xous_syscall_result(
// it gets converted into a MemoryMessage. Now that the call is // it gets converted into a MemoryMessage. Now that the call is
// complete, free the memory. // complete, free the memory.
mem::unmap_memory_post(*buf).unwrap(); mem::unmap_memory_post(*buf).unwrap();
}, }
// Nothing to do for Immutable borrow, since the memory can't change // Nothing to do for Immutable borrow, since the memory can't change
crate::Message::Scalar(_) => (), crate::Message::Scalar(_) | crate::Message::BlockingScalar(_) => (),
} }
} }
_ => (), _ => (),
@ -620,30 +620,15 @@ fn _xous_syscall_to(
match call { match call {
crate::SysCall::SendMessage(_, ref msg) | crate::SysCall::TrySendMessage(_, ref msg) => { crate::SysCall::SendMessage(_, ref msg) | crate::SysCall::TrySendMessage(_, ref msg) => {
match msg { match msg {
crate::Message::MutableBorrow(crate::MemoryMessage { crate::Message::MutableBorrow(m)
id: _id, | crate::Message::Borrow(m)
buf, | crate::Message::Move(m) => {
offset: _offset,
valid: _valid,
})
| crate::Message::Borrow(crate::MemoryMessage {
id: _id,
buf,
offset: _offset,
valid: _valid,
})
| crate::Message::Move(crate::MemoryMessage {
id: _id,
buf,
offset: _offset,
valid: _valid,
}) => {
use core::slice; use core::slice;
let data: &[u8] = let data: &[u8] =
unsafe { slice::from_raw_parts(buf.addr.get() as _, buf.size.get()) }; unsafe { slice::from_raw_parts(m.buf.addr.get() as _, m.buf.size.get()) };
pkt.extend_from_slice(data); pkt.extend_from_slice(data);
} }
crate::Message::Scalar(_) => (), crate::Message::Scalar(_) | crate::Message::BlockingScalar(_) => (),
} }
} }
_ => (), _ => (),

View file

@ -305,6 +305,16 @@ impl Message {
Message::BlockingScalar(_) | Message::Scalar(_) => false, Message::BlockingScalar(_) | Message::Scalar(_) => false,
} }
} }
pub fn message_type(&self) -> usize {
match *self {
Message::MutableBorrow(_) => 1,
Message::Borrow(_) => 2,
Message::Move(_) => 3,
Message::Scalar(_) => 4,
Message::BlockingScalar(_) => 5,
}
}
} }
#[repr(C)] #[repr(C)]

View file

@ -487,40 +487,20 @@ impl SysCall {
] ]
} }
SysCall::SendMessage(a1, ref a2) => match a2 { SysCall::SendMessage(a1, ref a2) => match a2 {
Message::MutableBorrow(mm) => [ Message::MutableBorrow(mm) | Message::Borrow(mm) | Message::Move(mm) => [
SysCallNumber::SendMessage as usize, SysCallNumber::SendMessage as usize,
*a1, *a1,
1, a2.message_type(),
mm.id as usize, mm.id as usize,
mm.buf.as_ptr() as usize, mm.buf.as_ptr() as usize,
mm.buf.len(), mm.buf.len(),
mm.offset.map(|x| x.get()).unwrap_or(0) as usize, mm.offset.map(|x| x.get()).unwrap_or(0) as usize,
mm.valid.map(|x| x.get()).unwrap_or(0) as usize, mm.valid.map(|x| x.get()).unwrap_or(0) as usize,
], ],
Message::Borrow(mm) => [ Message::Scalar(sc) | Message::BlockingScalar(sc) => [
SysCallNumber::SendMessage as usize, SysCallNumber::SendMessage as usize,
*a1, *a1,
2, a2.message_type(),
mm.id as usize,
mm.buf.as_ptr() as usize,
mm.buf.len(),
mm.offset.map(|x| x.get()).unwrap_or(0) as usize,
mm.valid.map(|x| x.get()).unwrap_or(0) as usize,
],
Message::Move(mm) => [
SysCallNumber::SendMessage as usize,
*a1,
3,
mm.id as usize,
mm.buf.as_ptr() as usize,
mm.buf.len(),
mm.offset.map(|x| x.get()).unwrap_or(0) as usize,
mm.valid.map(|x| x.get()).unwrap_or(0) as usize,
],
Message::Scalar(sc) => [
SysCallNumber::SendMessage as usize,
*a1,
4,
sc.id as usize, sc.id as usize,
sc.arg1, sc.arg1,
sc.arg2, sc.arg2,
@ -569,40 +549,20 @@ impl SysCall {
] ]
} }
SysCall::TrySendMessage(a1, ref a2) => match a2 { SysCall::TrySendMessage(a1, ref a2) => match a2 {
Message::MutableBorrow(mm) => [ Message::MutableBorrow(mm) | Message::Borrow(mm) | Message::Move(mm) => [
SysCallNumber::TrySendMessage as usize, SysCallNumber::TrySendMessage as usize,
*a1, *a1,
1, a2.message_type(),
mm.id as usize, mm.id as usize,
mm.buf.as_ptr() as usize, mm.buf.as_ptr() as usize,
mm.buf.len(), mm.buf.len(),
mm.offset.map(|x| x.get()).unwrap_or(0) as usize, mm.offset.map(|x| x.get()).unwrap_or(0) as usize,
mm.valid.map(|x| x.get()).unwrap_or(0) as usize, mm.valid.map(|x| x.get()).unwrap_or(0) as usize,
], ],
Message::Borrow(mm) => [ Message::Scalar(sc) | Message::BlockingScalar(sc) => [
SysCallNumber::TrySendMessage as usize, SysCallNumber::TrySendMessage as usize,
*a1, *a1,
2, a2.message_type(),
mm.id as usize,
mm.buf.as_ptr() as usize,
mm.buf.len(),
mm.offset.map(|x| x.get()).unwrap_or(0) as usize,
mm.valid.map(|x| x.get()).unwrap_or(0) as usize,
],
Message::Move(mm) => [
SysCallNumber::TrySendMessage as usize,
*a1,
3,
mm.id as usize,
mm.buf.as_ptr() as usize,
mm.buf.len(),
mm.offset.map(|x| x.get()).unwrap_or(0) as usize,
mm.valid.map(|x| x.get()).unwrap_or(0) as usize,
],
Message::Scalar(sc) => [
SysCallNumber::TrySendMessage as usize,
*a1,
4,
sc.id as usize, sc.id as usize,
sc.arg1, sc.arg1,
sc.arg2, sc.arg2,