Start work on the cache info module
This commit is contained in:
parent
48559cec17
commit
6a0bd9b757
@ -18,6 +18,11 @@
|
||||
<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_info/examples" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/cache_info/tests" isTestSource="true" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/cache_info/benches" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/cache_info/target" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/kernel/target" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/polling_serial/target" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
|
8
Cargo.lock
generated
8
Cargo.lock
generated
@ -31,6 +31,13 @@ dependencies = [
|
||||
"bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cache_info"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"polling_serial 0.1.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cast"
|
||||
version = "0.2.2"
|
||||
@ -41,6 +48,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",
|
||||
"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",
|
||||
|
@ -3,6 +3,7 @@
|
||||
members = [
|
||||
"vga_buffer",
|
||||
"polling_serial",
|
||||
"cache_info",
|
||||
]
|
||||
|
||||
[package]
|
||||
@ -28,6 +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" }
|
||||
|
||||
[dependencies.lazy_static]
|
||||
version = "1.0"
|
||||
|
10
cache_info/Cargo.toml
Normal file
10
cache_info/Cargo.toml
Normal file
@ -0,0 +1,10 @@
|
||||
[package]
|
||||
name = "cache_info"
|
||||
version = "0.1.0"
|
||||
authors = ["guillaume didier <guillaume.didier@inria.fr>"]
|
||||
edition = "2018"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
polling_serial = { path = "../polling_serial" }
|
42
cache_info/src/lib.rs
Normal file
42
cache_info/src/lib.rs
Normal file
@ -0,0 +1,42 @@
|
||||
#![no_std]
|
||||
|
||||
/// Stuff to do in here :
|
||||
/// This module is meant to compute and return info about the caching structure
|
||||
/// Should include if needed the work for reverse engineering L3 complex addressing
|
||||
/// May also have a module to deal with prefetchers
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use core::arch::x86_64 as arch_x86;
|
||||
use polling_serial::serial_println;
|
||||
|
||||
pub fn test() {
|
||||
let x = Box::new(41);
|
||||
let cr = unsafe { arch_x86::__cpuid_count(0x04, 0) };
|
||||
serial_println!("{:?}", cr);
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum CacheType {
|
||||
Null = 0,
|
||||
Data = 1,
|
||||
Instruction = 2,
|
||||
Unified = 3,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub struct CacheInfo {
|
||||
cache_type: CacheType,
|
||||
level: u8,
|
||||
self_init: bool,
|
||||
fully_assoc: bool,
|
||||
core_for_cache: u16,
|
||||
core_in_package: u16,
|
||||
cache_line_size: u16,
|
||||
physical_line_partition: u16,
|
||||
associativity: u16,
|
||||
sets: u32,
|
||||
wbinvd_no_guarantee: bool,
|
||||
inclusive: bool,
|
||||
complex_cache_indexing: bool,
|
||||
}
|
@ -10,6 +10,7 @@ extern crate alloc;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use bootloader::{entry_point, BootInfo};
|
||||
use cache_info;
|
||||
use core::panic::PanicInfo;
|
||||
use dendrobates_tinctoreus_azureus::allocator;
|
||||
use polling_serial::serial_print;
|
||||
@ -84,6 +85,8 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
||||
|
||||
let x = Box::new(41);
|
||||
|
||||
cache_info::test();
|
||||
|
||||
serial_print!("Input a character: ");
|
||||
|
||||
let c = { polling_serial::SERIAL1.lock().read() };
|
||||
|
Loading…
Reference in New Issue
Block a user