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