mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +00:00
Merge branch 'master' of github.com:betrusted-io/xous-core
This commit is contained in:
commit
6ff8c8518c
4 changed files with 47 additions and 24 deletions
|
|
@ -10,6 +10,15 @@ use xous_kernel::*;
|
||||||
/// This is the context that called SwitchTo
|
/// This is the context that called SwitchTo
|
||||||
static mut SWITCHTO_CALLER: Option<(PID, TID)> = None;
|
static mut SWITCHTO_CALLER: Option<(PID, TID)> = None;
|
||||||
|
|
||||||
|
fn retry_syscall(pid: PID, tid: TID) -> SysCallResult {
|
||||||
|
if cfg!(baremetal) {
|
||||||
|
arch::process::Process::with_current_mut(|p| p.retry_instruction(tid))?;
|
||||||
|
do_yield(pid, tid)
|
||||||
|
} else {
|
||||||
|
Ok(xous_kernel::Result::WouldBlock)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn do_yield(_pid: PID, tid: TID) -> SysCallResult {
|
fn do_yield(_pid: PID, tid: TID) -> SysCallResult {
|
||||||
// If we're not running on bare metal, treat this as a no-op.
|
// If we're not running on bare metal, treat this as a no-op.
|
||||||
if !cfg!(baremetal) {
|
if !cfg!(baremetal) {
|
||||||
|
|
@ -708,7 +717,6 @@ pub fn handle_inner(pid: PID, tid: TID, call: SysCall) -> SysCallResult {
|
||||||
SysCall::ReturnMemory(sender, buf) => return_memory(pid, tid, sender, buf),
|
SysCall::ReturnMemory(sender, buf) => return_memory(pid, tid, sender, buf),
|
||||||
SysCall::ReturnScalar1(sender, arg) => return_scalar(pid, tid, sender, arg),
|
SysCall::ReturnScalar1(sender, arg) => return_scalar(pid, tid, sender, arg),
|
||||||
SysCall::ReturnScalar2(sender, arg1, arg2) => return_scalar2(pid, tid, sender, arg1, arg2),
|
SysCall::ReturnScalar2(sender, arg1, arg2) => return_scalar2(pid, tid, sender, arg1, arg2),
|
||||||
// SysCall::ReturnScalar2(sender, arg, arg2) => return_memory(pid, tid, sender, arg, arg2),
|
|
||||||
SysCall::TrySendMessage(cid, message) => send_message(pid, tid, cid, message),
|
SysCall::TrySendMessage(cid, message) => send_message(pid, tid, cid, message),
|
||||||
SysCall::TerminateProcess => SystemServices::with_mut(|ss| {
|
SysCall::TerminateProcess => SystemServices::with_mut(|ss| {
|
||||||
ss.switch_from_thread(pid, tid)?;
|
ss.switch_from_thread(pid, tid)?;
|
||||||
|
|
@ -724,17 +732,22 @@ pub fn handle_inner(pid: PID, tid: TID, call: SysCall) -> SysCallResult {
|
||||||
SystemServices::with_mut(|ss| ss.shutdown().map(|_| xous_kernel::Result::Ok))
|
SystemServices::with_mut(|ss| ss.shutdown().map(|_| xous_kernel::Result::Ok))
|
||||||
}
|
}
|
||||||
|
|
||||||
// SysCall::Connect(sid) => {
|
SysCall::Connect(sid) => {
|
||||||
// SystemServices::with_mut(|ss| ss.connect_to_server(sid).map(xous_kernel::Result::ConnectionID))
|
let result = SystemServices::with_mut(|ss| {
|
||||||
// }
|
ss.connect_to_server(sid)
|
||||||
|
.map(xous_kernel::Result::ConnectionID)
|
||||||
|
});
|
||||||
|
match result {
|
||||||
|
Ok(o) => Ok(o),
|
||||||
|
Err(xous_kernel::Error::ServerNotFound) => retry_syscall(pid, tid),
|
||||||
|
Err(e) => Err(e),
|
||||||
|
}
|
||||||
|
}
|
||||||
SysCall::SendMessage(cid, message) => {
|
SysCall::SendMessage(cid, message) => {
|
||||||
let result = send_message(pid, tid, cid, message);
|
let result = send_message(pid, tid, cid, message);
|
||||||
match result {
|
match result {
|
||||||
Ok(o) => Ok(o),
|
Ok(o) => Ok(o),
|
||||||
Err(xous_kernel::Error::ServerQueueFull) => {
|
Err(xous_kernel::Error::ServerQueueFull) => retry_syscall(pid, tid),
|
||||||
arch::process::Process::with_current_mut(|p| p.retry_instruction(tid))?;
|
|
||||||
do_yield(pid, tid)
|
|
||||||
}
|
|
||||||
Err(e) => Err(e),
|
Err(e) => Err(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -377,7 +377,7 @@ fn send_borrow_message() {
|
||||||
|
|
||||||
// Perform a connection to the server
|
// Perform a connection to the server
|
||||||
// println!("CLIENT: Connecting to server...");
|
// println!("CLIENT: Connecting to server...");
|
||||||
let conn = xous_kernel::try_connect(sid).expect("couldn't connect to server");
|
let conn = xous_kernel::connect(sid).expect("couldn't connect to server");
|
||||||
|
|
||||||
// Convert the message into a "Carton" that can be shipped as a message
|
// Convert the message into a "Carton" that can be shipped as a message
|
||||||
// println!("CLIENT: Creating carton...");
|
// println!("CLIENT: Creating carton...");
|
||||||
|
|
@ -443,7 +443,7 @@ fn send_mutableborrow_message() {
|
||||||
let sid = server_addr_recv.recv().unwrap();
|
let sid = server_addr_recv.recv().unwrap();
|
||||||
|
|
||||||
// Perform a connection to the server
|
// Perform a connection to the server
|
||||||
let conn = xous_kernel::try_connect(sid).expect("couldn't connect to server");
|
let conn = xous_kernel::connect(sid).expect("couldn't connect to server");
|
||||||
|
|
||||||
// Convert the message into a "Carton" that can be shipped as a message
|
// Convert the message into a "Carton" that can be shipped as a message
|
||||||
let mut carton = xous_kernel::carton::Carton::from_bytes(&test_bytes);
|
let mut carton = xous_kernel::carton::Carton::from_bytes(&test_bytes);
|
||||||
|
|
@ -516,7 +516,7 @@ fn send_mutableborrow_message_repeat() {
|
||||||
let sid = server_addr_recv.recv().unwrap();
|
let sid = server_addr_recv.recv().unwrap();
|
||||||
|
|
||||||
// Perform a connection to the server
|
// Perform a connection to the server
|
||||||
let conn = xous_kernel::try_connect(sid).expect("couldn't connect to server");
|
let conn = xous_kernel::connect(sid).expect("couldn't connect to server");
|
||||||
|
|
||||||
// Convert the message into a "Carton" that can be shipped as a message
|
// Convert the message into a "Carton" that can be shipped as a message
|
||||||
for iteration in 0..loops {
|
for iteration in 0..loops {
|
||||||
|
|
|
||||||
|
|
@ -428,19 +428,24 @@ pub fn _xous_syscall(
|
||||||
|
|
||||||
let mut xsc_borrowed = xsc.borrow_mut();
|
let mut xsc_borrowed = xsc.borrow_mut();
|
||||||
let xsc_asmut = xsc_borrowed.as_mut().expect("not connected to server!");
|
let xsc_asmut = xsc_borrowed.as_mut().expect("not connected to server!");
|
||||||
_xous_syscall_to(
|
loop {
|
||||||
nr,
|
_xous_syscall_to(
|
||||||
a1,
|
nr,
|
||||||
a2,
|
a1,
|
||||||
a3,
|
a2,
|
||||||
a4,
|
a3,
|
||||||
a5,
|
a4,
|
||||||
a6,
|
a5,
|
||||||
a7,
|
a6,
|
||||||
&call,
|
a7,
|
||||||
&mut xsc_asmut.send.lock().unwrap(),
|
&call,
|
||||||
);
|
&mut xsc_asmut.send.lock().unwrap(),
|
||||||
_xous_syscall_result(&call, ret, *tid.borrow(), xsc_asmut);
|
);
|
||||||
|
_xous_syscall_result(&call, ret, *tid.borrow(), xsc_asmut);
|
||||||
|
if *ret != Result::WouldBlock {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -459,6 +459,9 @@ pub enum Result {
|
||||||
/// A scalar with two values
|
/// A scalar with two values
|
||||||
Scalar2(usize, usize),
|
Scalar2(usize, usize),
|
||||||
|
|
||||||
|
/// The syscall should be attempted again
|
||||||
|
WouldBlock,
|
||||||
|
|
||||||
UnknownResult(usize, usize, usize, usize, usize, usize, usize),
|
UnknownResult(usize, usize, usize, usize, usize, usize, usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -494,6 +497,7 @@ impl Result {
|
||||||
let s = sid.to_u32();
|
let s = sid.to_u32();
|
||||||
[15, s.0 as _, s.1 as _, s.2 as _, s.3 as _, *cid, 0, 0]
|
[15, s.0 as _, s.1 as _, s.2 as _, s.3 as _, *cid, 0, 0]
|
||||||
}
|
}
|
||||||
|
Result::WouldBlock => [16, 0, 0, 0, 0, 0, 0, 0],
|
||||||
Result::UnknownResult(arg1, arg2, arg3, arg4, arg5, arg6, arg7) => {
|
Result::UnknownResult(arg1, arg2, arg3, arg4, arg5, arg6, arg7) => {
|
||||||
[usize::MAX, *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7]
|
[usize::MAX, *arg1, *arg2, *arg3, *arg4, *arg5, *arg6, *arg7]
|
||||||
}
|
}
|
||||||
|
|
@ -567,6 +571,7 @@ impl Result {
|
||||||
SID::from_u32(src[1] as _, src[2] as _, src[3] as _, src[4] as _),
|
SID::from_u32(src[1] as _, src[2] as _, src[3] as _, src[4] as _),
|
||||||
src[5] as _,
|
src[5] as _,
|
||||||
),
|
),
|
||||||
|
16 => Result::WouldBlock,
|
||||||
_ => Result::UnknownResult(src[0], src[1], src[2], src[3], src[4], src[5], src[6]),
|
_ => Result::UnknownResult(src[0], src[1], src[2], src[3], src[4], src[5], src[6]),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue