dendrobates-t-azureus/cache_utils/src/prefetcher.rs

20 lines
470 B
Rust
Raw Normal View History

2020-02-05 10:23:52 +01:00
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) };
}