xref: /DragonOS/kernel/src/arch/x86_64/cpu.rs (revision aa0367d69e15989684109c5b454e85da9ecb1975)
1 use core::arch::asm;
2 
3 use super::asm::current::current_pcb;
4 
5 /// @brief 获取当前cpu的apic id
6 #[inline]
7 pub fn current_cpu_id() -> u32 {
8     // TODO: apic重构后,使用apic id来设置这里
9     current_pcb().cpu_id as u32
10 }
11 
12 /// @brief 通过pause指令,让cpu休息一会儿。降低空转功耗
13 pub fn cpu_relax() {
14     unsafe {
15         asm!("pause");
16     }
17 }
18 
19 /// 重置cpu
20 pub fn cpu_reset() -> ! {
21     // 重启计算机
22     unsafe { x86::io::outb(0x64, 0xfe) };
23     loop {}
24 }
25