mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
xous: add JoinThread syscall
The `JoinThread` call will eventually be used to let one thread wait on another. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
b617ed2f32
commit
6b70922381
1 changed files with 26 additions and 0 deletions
|
|
@ -318,6 +318,9 @@ pub enum SysCall {
|
||||||
/// in a future reconnection.
|
/// in a future reconnection.
|
||||||
Disconnect(CID),
|
Disconnect(CID),
|
||||||
|
|
||||||
|
/// Waits for a thread to finish, and returns the return value of that thread.
|
||||||
|
JoinThread(TID),
|
||||||
|
|
||||||
/// This syscall does not exist. It captures all possible
|
/// This syscall does not exist. It captures all possible
|
||||||
/// arguments so detailed analysis can be performed.
|
/// arguments so detailed analysis can be performed.
|
||||||
Invalid(usize, usize, usize, usize, usize, usize, usize),
|
Invalid(usize, usize, usize, usize, usize, usize, usize),
|
||||||
|
|
@ -359,6 +362,7 @@ pub enum SysCallNumber {
|
||||||
GetProcessId = 33,
|
GetProcessId = 33,
|
||||||
DestroyServer = 34,
|
DestroyServer = 34,
|
||||||
Disconnect = 35,
|
Disconnect = 35,
|
||||||
|
JoinThread = 36,
|
||||||
Invalid,
|
Invalid,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -400,6 +404,7 @@ impl SysCallNumber {
|
||||||
33 => GetProcessId,
|
33 => GetProcessId,
|
||||||
34 => DestroyServer,
|
34 => DestroyServer,
|
||||||
35 => Disconnect,
|
35 => Disconnect,
|
||||||
|
36 => JoinThread,
|
||||||
_ => Invalid,
|
_ => Invalid,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -721,6 +726,16 @@ impl SysCall {
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
],
|
],
|
||||||
|
SysCall::JoinThread(tid) => [
|
||||||
|
SysCallNumber::JoinThread as usize,
|
||||||
|
*tid as usize,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
],
|
||||||
SysCall::Invalid(a1, a2, a3, a4, a5, a6, a7) => [
|
SysCall::Invalid(a1, a2, a3, a4, a5, a6, a7) => [
|
||||||
SysCallNumber::Invalid as usize,
|
SysCallNumber::Invalid as usize,
|
||||||
*a1,
|
*a1,
|
||||||
|
|
@ -882,6 +897,7 @@ impl SysCall {
|
||||||
SysCall::DestroyServer(SID::from_u32(a1 as _, a2 as _, a3 as _, a4 as _))
|
SysCall::DestroyServer(SID::from_u32(a1 as _, a2 as _, a3 as _, a4 as _))
|
||||||
}
|
}
|
||||||
SysCallNumber::Disconnect => SysCall::Disconnect(a1 as _),
|
SysCallNumber::Disconnect => SysCall::Disconnect(a1 as _),
|
||||||
|
SysCallNumber::JoinThread => SysCall::JoinThread(a1 as _),
|
||||||
SysCallNumber::Invalid => SysCall::Invalid(a1, a2, a3, a4, a5, a6, a7),
|
SysCallNumber::Invalid => SysCall::Invalid(a1, a2, a3, a4, a5, a6, a7),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -1568,6 +1584,16 @@ pub unsafe fn disconnect(cid: CID) -> core::result::Result<(), Error> {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn join_thread(tid: TID) -> core::result::Result<usize, Error> {
|
||||||
|
rsyscall(SysCall::JoinThread(tid)).and_then(|result| {
|
||||||
|
if let Result::Scalar1(val) = result {
|
||||||
|
Ok(val)
|
||||||
|
} else {
|
||||||
|
Err(Error::InternalError)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
pub fn rsyscall(call: SysCall) -> SysCallResult {
|
pub fn rsyscall(call: SysCall) -> SysCallResult {
|
||||||
let mut ret = Result::Ok;
|
let mut ret = Result::Ok;
|
||||||
let args = call.as_args();
|
let args = call.as_args();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue