xref: /DragonOS/kernel/src/arch/riscv64/process/syscall.rs (revision 0f094e50dee4cc20efbbe32852a4c79e619c4806)
1 use riscv::register::sstatus::{FS, SPP};
2 use system_error::SystemError;
3 
4 use crate::{
5     arch::interrupt::TrapFrame,
6     mm::VirtAddr,
7     process::exec::{BinaryLoaderResult, ExecParam},
8     syscall::Syscall,
9 };
10 
11 impl Syscall {
arch_do_execve( regs: &mut TrapFrame, param: &ExecParam, load_result: &BinaryLoaderResult, user_sp: VirtAddr, argv_ptr: VirtAddr, ) -> Result<(), SystemError>12     pub fn arch_do_execve(
13         regs: &mut TrapFrame,
14         param: &ExecParam,
15         load_result: &BinaryLoaderResult,
16         user_sp: VirtAddr,
17         argv_ptr: VirtAddr,
18     ) -> Result<(), SystemError> {
19         // debug!("write proc_init_info to user stack done");
20 
21         regs.a0 = param.init_info().args.len();
22         regs.a1 = argv_ptr.data();
23 
24         // 设置系统调用返回时的寄存器状态
25         regs.sp = user_sp.data();
26 
27         regs.epc = load_result.entry_point().data();
28         regs.status.update_spp(SPP::User);
29         regs.status.update_fs(FS::Clean);
30         regs.status.update_sum(true);
31 
32         return Ok(());
33     }
34 
35     /// ## 用于控制和查询与体系结构相关的进程特定选项
36     #[allow(dead_code)]
arch_prctl(_option: usize, _arg2: usize) -> Result<usize, SystemError>37     pub fn arch_prctl(_option: usize, _arg2: usize) -> Result<usize, SystemError> {
38         unimplemented!("Syscall::arch_prctl")
39     }
40 }
41