Skip to content

Commit

Permalink
WIP fork syscall
Browse files Browse the repository at this point in the history
  • Loading branch information
xor-bits committed Feb 18, 2024
1 parent 60e763d commit 73674bd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions crates/kernel/src/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ pub fn syscall(args: &mut SyscallRegs) {
id::SEEK => call_id(seek, args),

id::SYSTEM => call_id(system, args),
id::FORK => call_id(fork, args),

other => {
debug!("invalid syscall ({other})");
Expand Down Expand Up @@ -863,3 +864,10 @@ pub fn system(args: &mut SyscallRegs) -> Result<usize> {

Ok(pid.num())
}

/// fork the current process
///
/// [`hyperion_syscall::fork`]
pub fn fork(_args: &mut SyscallRegs) -> Result<usize> {
todo!()
}
6 changes: 6 additions & 0 deletions crates/syscall/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub mod id {
pub const SEEK: usize = 32;

pub const SYSTEM: usize = 33;
pub const FORK: usize = 34;
}

//
Expand Down Expand Up @@ -383,3 +384,8 @@ pub fn system_with(path: &str, args: &[&str], cfg: LaunchConfig) -> Result<usize
)
}
}

/// fork the current process and return the PID
pub fn fork() -> Result<usize> {
unsafe { syscall_0(id::FORK) }
}

0 comments on commit 73674bd

Please sign in to comment.