1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#![cfg(feature = "instructions")]
use crate::VirtAddr;
pub mod interrupts;
pub mod port;
pub mod random;
pub mod segmentation;
pub mod tables;
pub mod tlb;
#[inline]
pub fn hlt() {
#[cfg(feature = "inline_asm")]
unsafe {
asm!("hlt", options(nomem, nostack));
}
#[cfg(not(feature = "inline_asm"))]
unsafe {
crate::asm::x86_64_asm_hlt();
}
}
#[inline]
pub fn nop() {
#[cfg(feature = "inline_asm")]
unsafe {
asm!("nop", options(nomem, nostack, preserves_flags));
}
#[cfg(not(feature = "inline_asm"))]
unsafe {
crate::asm::x86_64_asm_nop();
}
}
#[cfg(feature = "inline_asm")]
#[inline]
pub fn bochs_breakpoint() {
unsafe {
asm!("xchg bx, bx", options(nomem, nostack));
}
}
#[cfg(feature = "inline_asm")]
#[inline(always)]
pub fn read_rip() -> VirtAddr {
let rip: u64;
unsafe {
asm!(
"lea {}, [rip]", out(reg) rip, options(nostack, nomem)
);
}
VirtAddr::new(rip)
}