1*b5b571e0SLoGin use core::hint::spin_loop; 2*b5b571e0SLoGin 3c3dad001SLoGin use x86::cpuid::{cpuid, CpuIdResult}; 4bacd691cSlogin 58cb2e9b3SLoGin use crate::smp::cpu::ProcessorId; 6e2841179SLoGin 7e2841179SLoGin /// 获取当前cpu的apic id 866f67c6aSlogin #[inline] current_cpu_id() -> ProcessorId9e2841179SLoGinpub fn current_cpu_id() -> ProcessorId { 10c3dad001SLoGin let cpuid_res: CpuIdResult = cpuid!(0x1); 11c3dad001SLoGin let cpu_id = (cpuid_res.ebx >> 24) & 0xff; 12e2841179SLoGin return ProcessorId::new(cpu_id); 1366f67c6aSlogin } 1461de2cdcSlogin 15ab5c8ca4Slogin /// 重置cpu cpu_reset() -> !164fda81ceSLoGinpub unsafe fn cpu_reset() -> ! { 17ab5c8ca4Slogin // 重启计算机 18ab5c8ca4Slogin unsafe { x86::io::outb(0x64, 0xfe) }; 19*b5b571e0SLoGin loop { 20*b5b571e0SLoGin spin_loop(); 21*b5b571e0SLoGin } 22ab5c8ca4Slogin } 23