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