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