xref: /DragonOS/kernel/src/arch/riscv64/process/mod.rs (revision 83ed0ebc293d5a10245089f627f52770fd5b9dd4)
1 use alloc::{string::String, sync::Arc, vec::Vec};
2 
3 use crate::{
4     process::{fork::KernelCloneArgs, KernelStack, ProcessControlBlock, ProcessManager},
5     syscall::SystemError,
6 };
7 
8 use super::interrupt::TrapFrame;
9 
10 pub mod kthread;
11 pub mod syscall;
12 
13 pub unsafe fn arch_switch_to_user(path: String, argv: Vec<String>, envp: Vec<String>) -> ! {
14     unimplemented!("RiscV64 arch_switch_to_user")
15 }
16 
17 impl ProcessManager {
18     pub fn arch_init() {
19         unimplemented!("ProcessManager::arch_init")
20     }
21 
22     /// fork的过程中复制线程
23     ///
24     /// 由于这个过程与具体的架构相关,所以放在这里
25     pub fn copy_thread(
26         current_pcb: &Arc<ProcessControlBlock>,
27         new_pcb: &Arc<ProcessControlBlock>,
28         clone_args: KernelCloneArgs,
29         current_trapframe: &TrapFrame,
30     ) -> Result<(), SystemError> {
31         unimplemented!("ProcessManager::copy_thread")
32     }
33 
34     /// 切换进程
35     ///
36     /// ## 参数
37     ///
38     /// - `prev`:上一个进程的pcb
39     /// - `next`:下一个进程的pcb
40     pub unsafe fn switch_process(prev: Arc<ProcessControlBlock>, next: Arc<ProcessControlBlock>) {
41         unimplemented!("ProcessManager::switch_process")
42     }
43 }
44 
45 impl ProcessControlBlock {
46     /// 获取当前进程的pcb
47     pub fn arch_current_pcb() -> Arc<Self> {
48         unimplemented!("ProcessControlBlock::arch_current_pcb")
49     }
50 }
51 
52 /// PCB中与架构相关的信息
53 #[derive(Debug)]
54 #[allow(dead_code)]
55 pub struct ArchPCBInfo {
56     // todo: add arch related fields
57 }
58 
59 #[allow(dead_code)]
60 impl ArchPCBInfo {
61     /// 创建一个新的ArchPCBInfo
62     ///
63     /// ## 参数
64     ///
65     /// - `kstack`:内核栈的引用
66     ///
67     /// ## 返回值
68     ///
69     /// 返回一个新的ArchPCBInfo
70     pub fn new(kstack: &KernelStack) -> Self {
71         unimplemented!("ArchPCBInfo::new")
72     }
73     // ### 从另一个ArchPCBInfo处clone,但是保留部分字段不变
74     pub fn clone_from(&mut self, from: &Self) {
75         unimplemented!("ArchPCBInfo::clone_from")
76     }
77 }
78