xref: /DragonOS/kernel/src/arch/x86_64/cpu.rs (revision 83ed0ebc293d5a10245089f627f52770fd5b9dd4)
1 use x86::cpuid::{cpuid, CpuIdResult};
2 
3 /// @brief 获取当前cpu的apic id
4 #[inline]
5 pub fn current_cpu_id() -> u32 {
6     let cpuid_res: CpuIdResult = cpuid!(0x1);
7     let cpu_id = (cpuid_res.ebx >> 24) & 0xff;
8     return cpu_id;
9 }
10 
11 /// 重置cpu
12 pub unsafe fn cpu_reset() -> ! {
13     // 重启计算机
14     unsafe { x86::io::outb(0x64, 0xfe) };
15     loop {}
16 }
17