31 lines
574 B
Rust
31 lines
574 B
Rust
#![cfg(target_arch = "x86_64")]
|
|
#![allow(dead_code)]
|
|
|
|
use core::arch::x86_64::{__cpuid as do_cpuid, CpuidResult};
|
|
use core::arch::asm;
|
|
|
|
fn safe_cpuid(leaf: u32) -> CpuidResult {
|
|
return unsafe { do_cpuid(leaf) };
|
|
}
|
|
|
|
pub fn get_processor_id() -> u32 {
|
|
let cpuid_result = safe_cpuid(1);
|
|
return cpuid_result.ebx >> 24;
|
|
}
|
|
|
|
pub fn halt() -> ! {
|
|
loop {
|
|
unsafe {
|
|
asm!("cli");
|
|
asm!("hlt");
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn wait_for_interrupt() -> () {
|
|
unsafe { asm!("hlt"); }
|
|
}
|
|
|
|
pub fn breakpoint() -> () {
|
|
unsafe { asm!("int3"); }
|
|
} |