1 use crate::include::bindings::bindings::process_control_block; 2 3 use core::{arch::asm, sync::atomic::compiler_fence}; 4 5 /// @brief 获取指向当前进程的pcb的可变引用 6 #[inline] current_pcb() -> &'static mut process_control_block7pub fn current_pcb() -> &'static mut process_control_block { 8 let ret: Option<&mut process_control_block>; 9 10 unsafe { 11 let mut tmp: u64 = !(32767u64); 12 compiler_fence(core::sync::atomic::Ordering::SeqCst); 13 asm!("and {0}, rsp", inout(reg)(tmp),); 14 compiler_fence(core::sync::atomic::Ordering::SeqCst); 15 ret = (tmp as *mut process_control_block).as_mut(); 16 } 17 18 ret.unwrap() 19 } 20