mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-28 04:43:23 +00:00
添加per cpu变量支持 (#327)
This commit is contained in:
@ -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休息一会儿。降低空转功耗
|
||||
|
Reference in New Issue
Block a user