1c3dad001SLoGin use x86::cpuid::{cpuid, CpuIdResult}; 2bacd691cSlogin 3*8cb2e9b3SLoGin use crate::smp::cpu::ProcessorId; 4e2841179SLoGin 5e2841179SLoGin /// 获取当前cpu的apic id 666f67c6aSlogin #[inline] 7e2841179SLoGin pub fn current_cpu_id() -> ProcessorId { 8c3dad001SLoGin let cpuid_res: CpuIdResult = cpuid!(0x1); 9c3dad001SLoGin let cpu_id = (cpuid_res.ebx >> 24) & 0xff; 10e2841179SLoGin return ProcessorId::new(cpu_id); 1166f67c6aSlogin } 1261de2cdcSlogin 13ab5c8ca4Slogin /// 重置cpu 144fda81ceSLoGin pub unsafe fn cpu_reset() -> ! { 15ab5c8ca4Slogin // 重启计算机 16ab5c8ca4Slogin unsafe { x86::io::outb(0x64, 0xfe) }; 17ab5c8ca4Slogin loop {} 18ab5c8ca4Slogin } 19