aboutsummaryrefslogtreecommitdiff
path: root/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs79
1 files changed, 65 insertions, 14 deletions
diff --git a/src/lib.rs b/src/lib.rs
index f18a44d..ad45d7c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,21 +1,72 @@
-#![cfg(any(target_arch="x86", target_arch="x86_64"))]
-
-#![no_std]
-#![crate_name="cpu"]
-#![crate_type="rlib"]
+#![feature(const_fn)]
#![feature(asm)]
-#![feature(associated_consts)]
+#![no_std]
+#![cfg_attr(test, allow(unused_features))]
+
+#![crate_name = "x86"]
+#![crate_type = "lib"]
#[macro_use]
extern crate bitflags;
-pub use cpu::*;
+#[macro_use]
+extern crate raw_cpuid;
+
+#[cfg(feature = "performance-counter")]
+#[macro_use]
+extern crate phf;
+
+mod std {
+ pub use core::fmt;
+ pub use core::ops;
+ pub use core::option;
+}
+
+macro_rules! bit {
+ ( $x:expr ) => {
+ 1 << $x
+ };
+}
+
+macro_rules! check_flag {
+ ($doc:meta, $fun:ident, $flag:ident) => (
+ #[$doc]
+ pub fn $fun(&self) -> bool {
+ self.contains($flag)
+ }
+ )
+}
+
+macro_rules! is_bit_set {
+ ($field:expr, $bit:expr) => (
+ $field & (1 << $bit) > 0
+ )
+}
-#[cfg(target_arch="x86")]
-#[path = "x86.rs"]
-mod cpu;
-#[cfg(target_arch="x86_64")]
-#[path = "x86_64.rs"]
-mod cpu;
+macro_rules! check_bit_fn {
+ ($doc:meta, $fun:ident, $field:ident, $bit:expr) => (
+ #[$doc]
+ pub fn $fun(&self) -> bool {
+ is_bit_set!(self.$field, $bit)
+ }
+ )
+}
-pub mod std { pub use core::*; }
+pub mod io;
+pub mod controlregs;
+pub mod msr;
+pub mod time;
+pub mod irq;
+pub mod rflags;
+pub mod paging;
+pub mod segmentation;
+pub mod task;
+pub mod dtables;
+pub mod syscall;
+pub mod sgx;
+#[cfg(feature = "performance-counter")]
+pub mod perfcnt;
+pub mod cpuid {
+ pub use raw_cpuid::*;
+}
+pub mod tlb;