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
70
71
72
73
74
75
76
77
78
79
|
#![cfg(any(target_arch="x86", target_arch="x86_64"))]
#![feature(const_fn)]
#![feature(asm)]
#![no_std]
#![cfg_attr(test, allow(unused_features))]
#[macro_use]
extern crate bitflags;
extern crate raw_cpuid;
#[cfg(feature = "performance-counter")]
#[macro_use]
extern crate phf;
macro_rules! check_flag {
($doc:meta, $fun:ident, $flag:expr) => (
#[$doc]
pub fn $fun(&self) -> bool {
self.contains($flag)
}
)
}
macro_rules! bit {
( $x:expr ) => {
1 << $x
};
}
pub mod bits16;
pub mod bits32;
pub mod bits64;
pub mod controlregs;
pub mod dtables;
pub mod io;
pub mod irq;
pub mod msr;
pub mod segmentation;
pub mod task;
pub mod tlb;
pub mod time;
#[cfg(feature = "performance-counter")]
pub mod perfcnt;
pub mod current {
#[cfg(target_arch="x86")]
pub use bits32::*;
#[cfg(target_arch="x86_64")]
pub use bits64::*;
}
pub mod cpuid {
pub use raw_cpuid::*;
}
mod std {
pub use core::fmt;
pub use core::ops;
pub use core::option;
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[repr(u8)]
/// x86 Protection levels
/// Note: This should not contain values larger than 2 bits, otherwise
/// segment descriptor code needs to be adjusted accordingly.
pub enum Ring {
Ring0 = 0b00,
Ring1 = 0b01,
Ring2 = 0b10,
Ring3 = 0b11,
}
#[inline(always)]
pub unsafe fn halt() {
asm!("hlt" :::: "volatile");
}
|