添加per cpu变量支持 (#327)

This commit is contained in:
LoGin
2023-08-13 16:28:24 +08:00
committed by GitHub
parent 42c97fa7f4
commit c3dad0011d
5 changed files with 97 additions and 5 deletions

View File

@ -1,12 +1,13 @@
use core::arch::asm;
use super::asm::current::current_pcb;
use x86::cpuid::{cpuid, CpuIdResult};
/// @brief 获取当前cpu的apic id
#[inline]
pub fn current_cpu_id() -> u32 {
// TODO: apic重构后使用apic id来设置这里
current_pcb().cpu_id as u32
let cpuid_res: CpuIdResult = cpuid!(0x1);
let cpu_id = (cpuid_res.ebx >> 24) & 0xff;
return cpu_id;
}
/// @brief 通过pause指令让cpu休息一会儿。降低空转功耗