xref: /DragonOS/kernel/src/arch/x86_64/cpu.rs (revision c75089286e9d49cef8d039446bf570c1bd4d2550)
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 fn cpu_reset() -> ! {
13     // 重启计算机
14     unsafe { x86::io::outb(0x64, 0xfe) };
15     loop {}
16 }
17