diff --git a/.idea/DendrobatesTinctoriusAzureus.iml b/.idea/DendrobatesTinctoriusAzureus.iml
index 8f5daf7..d8e0190 100644
--- a/.idea/DendrobatesTinctoriusAzureus.iml
+++ b/.idea/DendrobatesTinctoriusAzureus.iml
@@ -18,11 +18,15 @@
-
+
+
+
+
+
diff --git a/Cargo.lock b/Cargo.lock
index 01cb3e0..47dd969 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -32,11 +32,12 @@ dependencies = [
]
[[package]]
-name = "cache_info"
+name = "cache_utils"
version = "0.1.0"
dependencies = [
"polling_serial 0.1.0",
"vga_buffer 0.1.0",
+ "x86_64 0.7.5 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
@@ -49,7 +50,7 @@ name = "dendrobates_tinctoreus_azureus"
version = "0.1.0"
dependencies = [
"bootloader 0.8.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "cache_info 0.1.0",
+ "cache_utils 0.1.0",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"linked_list_allocator 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
"polling_serial 0.1.0",
diff --git a/Cargo.toml b/Cargo.toml
index fbb1e95..3be773e 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -3,7 +3,7 @@
members = [
"vga_buffer",
"polling_serial",
- "cache_info",
+ "cache_utils",
]
[package]
@@ -29,7 +29,7 @@ vga_buffer = { path = "vga_buffer" }
polling_serial = { path = "polling_serial" }
volatile = "0.2.6"
linked_list_allocator = "0.6.4"
-cache_info = { path = "cache_info" }
+cache_utils = { path = "cache_utils" }
[dependencies.lazy_static]
version = "1.0"
diff --git a/cache_info/src/prefetcher.rs b/cache_info/src/prefetcher.rs
deleted file mode 100644
index 8b13789..0000000
--- a/cache_info/src/prefetcher.rs
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/cache_info/Cargo.toml b/cache_utils/Cargo.toml
similarity index 88%
rename from cache_info/Cargo.toml
rename to cache_utils/Cargo.toml
index 3ba7091..d76badb 100644
--- a/cache_info/Cargo.toml
+++ b/cache_utils/Cargo.toml
@@ -1,5 +1,5 @@
[package]
-name = "cache_info"
+name = "cache_utils"
version = "0.1.0"
authors = ["guillaume didier "]
edition = "2018"
@@ -9,3 +9,4 @@ edition = "2018"
[dependencies]
polling_serial = { path = "../polling_serial" }
vga_buffer = { path = "../vga_buffer" }
+x86_64 = "0.7.5"
diff --git a/cache_info/src/lib.rs b/cache_utils/src/lib.rs
similarity index 100%
rename from cache_info/src/lib.rs
rename to cache_utils/src/lib.rs
diff --git a/cache_utils/src/prefetcher.rs b/cache_utils/src/prefetcher.rs
new file mode 100644
index 0000000..4da983a
--- /dev/null
+++ b/cache_utils/src/prefetcher.rs
@@ -0,0 +1,19 @@
+use x86_64::registers::model_specific::Msr;
+
+const MSR_MISC_FEATURE8CONTROL: u32 = 0x1a4;
+
+pub fn prefetcher_status() -> bool {
+ let msr = Msr::new(MSR_MISC_FEATURE8CONTROL);
+ let value = unsafe { msr.read() };
+
+ value & 0xf != 0xf
+}
+
+pub fn enable_prefetchers(status: bool) {
+ let mut msr = Msr::new(MSR_MISC_FEATURE8CONTROL);
+ let mut value = unsafe { msr.read() } & !0xf;
+ if !status {
+ value |= 0xf;
+ }
+ unsafe { msr.write(value) };
+}
diff --git a/src/main.rs b/src/main.rs
index ff59d29..cb8da35 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -9,7 +9,7 @@
extern crate alloc;
use bootloader::{entry_point, BootInfo};
-use cache_info;
+use cache_utils;
use core::panic::PanicInfo;
use dendrobates_tinctoreus_azureus::allocator;
use polling_serial::serial_print;
@@ -81,7 +81,7 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialization failed");
- let caches = cache_info::get_cache_info();
+ let caches = cache_utils::get_cache_info();
serial_println!("Caches:");
serial_println!("{:#?}", caches);