-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement the EXEC syscall interface in user space. Co-developed-by: Vijay Dhanraj <[email protected]> Signed-off-by: Peter Fang <[email protected]>
- Loading branch information
1 parent
047d5de
commit 25f859b
Showing
1 changed file
with
19 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,8 +4,9 @@ | |
// | ||
// Author: Chuanxiao Dong <[email protected]> | ||
|
||
use super::call::syscall1; | ||
use super::SYS_EXIT; | ||
use super::call::{syscall1, syscall3, SysCallError}; | ||
use super::{SYS_EXEC, SYS_EXIT}; | ||
use core::ffi::CStr; | ||
|
||
pub fn exit(code: u32) -> ! { | ||
// SAFETY: SYS_EXIT is supported syscall number by the svsm kernel. | ||
|
@@ -14,3 +15,19 @@ pub fn exit(code: u32) -> ! { | |
} | ||
unreachable!("Should never return from SYS_EXIT syscall"); | ||
} | ||
|
||
#[allow(dead_code)] | ||
#[derive(Debug)] | ||
pub struct Tid(u32); | ||
|
||
pub fn exec(file: &CStr, root: &CStr, flags: u32) -> Result<Tid, SysCallError> { | ||
unsafe { | ||
syscall3( | ||
SYS_EXEC, | ||
file.as_ptr() as u64, | ||
root.as_ptr() as u64, | ||
u64::from(flags), | ||
) | ||
.map(|ret| Tid(ret as u32)) | ||
} | ||
} |