Implement the typical use of waitpid
This commit is contained in:
parent
e680a84a57
commit
3e726a5d0d
1 changed files with 146 additions and 101 deletions
57
kernel/syscall/call.rs
Normal file
57
kernel/syscall/call.rs
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
use super::{Error, Result};
|
||||
|
||||
/// System call list
|
||||
/// See http://syscalls.kernelgrok.com/ for numbers
|
||||
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
|
||||
#[repr(C)]
|
||||
pub enum Call {
|
||||
/// Exit syscall
|
||||
Exit = 1,
|
||||
/// Read syscall
|
||||
Read = 3,
|
||||
/// Write syscall
|
||||
Write = 4,
|
||||
/// Open syscall
|
||||
Open = 5,
|
||||
/// Close syscall
|
||||
Close = 6,
|
||||
/// Wait for a process
|
||||
WaitPid = 7,
|
||||
/// Execute syscall
|
||||
Exec = 11,
|
||||
/// Get process ID
|
||||
GetPid = 20,
|
||||
/// Duplicate file descriptor
|
||||
Dup = 41,
|
||||
/// Set process break
|
||||
Brk = 45,
|
||||
/// Set process I/O privilege level
|
||||
Iopl = 110,
|
||||
/// Clone process
|
||||
Clone = 120,
|
||||
/// Yield to scheduler
|
||||
SchedYield = 158
|
||||
}
|
||||
|
||||
/// Convert numbers to calls
|
||||
/// See http://syscalls.kernelgrok.com/
|
||||
impl Call {
|
||||
pub fn from(number: usize) -> Result<Call> {
|
||||
match number {
|
||||
1 => Ok(Call::Exit),
|
||||
3 => Ok(Call::Read),
|
||||
4 => Ok(Call::Write),
|
||||
5 => Ok(Call::Open),
|
||||
6 => Ok(Call::Close),
|
||||
7 => Ok(Call::WaitPid),
|
||||
11 => Ok(Call::Exec),
|
||||
20 => Ok(Call::GetPid),
|
||||
41 => Ok(Call::Dup),
|
||||
45 => Ok(Call::Brk),
|
||||
110 => Ok(Call::Iopl),
|
||||
120 => Ok(Call::Clone),
|
||||
158 => Ok(Call::SchedYield),
|
||||
_ => Err(Error::NoCall)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue