mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
xous: add GetProcessID and GetThreadID syscalls
Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
1a309114c7
commit
530e105fe4
2 changed files with 53 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "xous"
|
||||
version = "0.1.1"
|
||||
version = "0.1.2"
|
||||
authors = ["Sean Cross <sean@xobs.io>"]
|
||||
edition = "2018"
|
||||
license = "MIT OR Apache-2.0"
|
||||
|
|
|
|||
|
|
@ -299,6 +299,12 @@ pub enum SysCall {
|
|||
/// disclosing SIDs.
|
||||
ConnectForProcess(PID, SID),
|
||||
|
||||
/// Get the current Thread ID
|
||||
GetThreadId,
|
||||
|
||||
/// Get the current Process ID
|
||||
GetProcessId,
|
||||
|
||||
/// This syscall does not exist. It captures all possible
|
||||
/// arguments so detailed analysis can be performed.
|
||||
Invalid(usize, usize, usize, usize, usize, usize, usize),
|
||||
|
|
@ -336,6 +342,8 @@ pub enum SysCallNumber {
|
|||
CreateServer = 29,
|
||||
ConnectForProcess = 30,
|
||||
CreateServerId = 31,
|
||||
GetThreadId = 32,
|
||||
GetProcessId = 33,
|
||||
Invalid,
|
||||
}
|
||||
|
||||
|
|
@ -373,6 +381,8 @@ impl SysCallNumber {
|
|||
29 => CreateServer,
|
||||
30 => ConnectForProcess,
|
||||
31 => CreateServerId,
|
||||
32 => GetThreadId,
|
||||
33 => GetProcessId,
|
||||
_ => Invalid,
|
||||
}
|
||||
}
|
||||
|
|
@ -668,6 +678,24 @@ impl SysCall {
|
|||
0,
|
||||
0,
|
||||
],
|
||||
SysCall::GetThreadId => [SysCallNumber::GetThreadId as usize,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
],
|
||||
SysCall::GetProcessId => [SysCallNumber::GetProcessId as usize,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
],
|
||||
SysCall::Invalid(a1, a2, a3, a4, a5, a6, a7) => [
|
||||
SysCallNumber::Invalid as usize,
|
||||
*a1,
|
||||
|
|
@ -867,6 +895,8 @@ impl SysCall {
|
|||
SID::from_u32(a2 as _, a3 as _, a4 as _, a5 as _),
|
||||
),
|
||||
SysCallNumber::CreateServerId => SysCall::CreateServerId,
|
||||
SysCallNumber::GetThreadId => SysCall::GetThreadId,
|
||||
SysCallNumber::GetProcessId => SysCall::GetProcessId,
|
||||
SysCallNumber::Invalid => SysCall::Invalid(a1, a2, a3, a4, a5, a6, a7),
|
||||
})
|
||||
}
|
||||
|
|
@ -1375,6 +1405,28 @@ pub fn wait_process(joiner: crate::arch::ProcessHandle) -> SysCallResult {
|
|||
crate::arch::wait_process(joiner)
|
||||
}
|
||||
|
||||
/// Get the current process ID
|
||||
pub fn current_pid() -> SysCallResult {
|
||||
rsyscall(SysCall::GetProcessId).and_then(|result| {
|
||||
if let Result::ProcessID(pid) = result {
|
||||
Ok(Result::ProcessID(pid))
|
||||
} else {
|
||||
Err(Error::InternalError)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Get the current thread ID
|
||||
pub fn current_tid() -> SysCallResult {
|
||||
rsyscall(SysCall::GetProcessId).and_then(|result| {
|
||||
if let Result::ThreadID(tid) = result {
|
||||
Ok(Result::ThreadID(tid))
|
||||
} else {
|
||||
Err(Error::InternalError)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
pub fn rsyscall(call: SysCall) -> SysCallResult {
|
||||
let mut ret = Result::Ok;
|
||||
let args = call.as_args();
|
||||
|
|
|
|||
Loading…
Reference in a new issue