Rename cache utils

This commit is contained in:
guillaume didier 2020-02-05 10:23:52 +01:00
parent cc016549b3
commit 2da2e7bf8e
8 changed files with 33 additions and 9 deletions

View File

@ -18,11 +18,15 @@
<sourceFolder url="file://$MODULE_DIR$/polling_serial/examples" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/polling_serial/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/polling_serial/benches" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/cache_info/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/cache_utils/src" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/cache_info/examples" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/cache_info/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/cache_info/benches" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/cache_utils/examples" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/cache_utils/tests" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/cache_utils/benches" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/cache_info/target" />
<excludeFolder url="file://$MODULE_DIR$/cache_utils/target" />
<excludeFolder url="file://$MODULE_DIR$/kernel/target" />
<excludeFolder url="file://$MODULE_DIR$/polling_serial/target" />
<excludeFolder url="file://$MODULE_DIR$/target" />

5
Cargo.lock generated
View File

@ -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",

View File

@ -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"

View File

@ -1 +0,0 @@

View File

@ -1,5 +1,5 @@
[package]
name = "cache_info"
name = "cache_utils"
version = "0.1.0"
authors = ["guillaume didier <guillaume.didier@inria.fr>"]
edition = "2018"
@ -9,3 +9,4 @@ edition = "2018"
[dependencies]
polling_serial = { path = "../polling_serial" }
vga_buffer = { path = "../vga_buffer" }
x86_64 = "0.7.5"

View File

@ -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) };
}

View File

@ -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);