feat: add cpu

This commit is contained in:
2020-11-07 12:04:13 +08:00
parent 24c7f80367
commit 1bd0f3e5c9
6 changed files with 111 additions and 1 deletions

View File

@@ -7,6 +7,8 @@ Project or files:
. .
├── __concurrent ├── __concurrent
│   └── arc-swap │   └── arc-swap
├── __cpu
│   └── x86
├── __crypto ├── __crypto
│   ├── btc-address │   ├── btc-address
│   ├── crypto │   ├── crypto
@@ -122,7 +124,7 @@ Project or files:
├── vec.rs ├── vec.rs
└── while.rs └── while.rs
94 directories, 26 files 96 directories, 26 files
``` ```

72
__cpu/x86/Cargo.lock generated Normal file
View File

@@ -0,0 +1,72 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
[[package]]
name = "bit_field"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcb6dd1c2376d2e096796e234a70e17e94cc2d5d54ff8ce42b28cef1d0d359a4"
[[package]]
name = "bitflags"
version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
[[package]]
name = "cc"
version = "1.0.62"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1770ced377336a88a67c473594ccc14eca6f4559217c34f64aac8f83d641b40"
[[package]]
name = "raw-cpuid"
version = "8.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fdf7d9dbd43f3d81d94a49c1c3df73cc2b3827995147e6cf7f89d4ec5483e73"
dependencies = [
"bitflags",
"cc",
"rustc_version",
]
[[package]]
name = "rustc_version"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
dependencies = [
"semver",
]
[[package]]
name = "semver"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
dependencies = [
"semver-parser",
]
[[package]]
name = "semver-parser"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
[[package]]
name = "x86"
version = "0.1.0"
dependencies = [
"x86 0.34.0",
]
[[package]]
name = "x86"
version = "0.34.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c146cbc47471e076987378c159a7aa8fa434680c6fbddca59fe6f40f1591c819"
dependencies = [
"bit_field",
"bitflags",
"raw-cpuid",
]

11
__cpu/x86/Cargo.toml Normal file
View File

@@ -0,0 +1,11 @@
[package]
name = "x86"
version = "0.1.0"
authors = ["Hatter Jiang <jht5945@gmail.com>"]
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
x86 = "0.34"

4
__cpu/x86/README.md Normal file
View File

@@ -0,0 +1,4 @@
crate:
https://github.com/gz/rust-x86

1
__cpu/x86/rust-toolchain Normal file
View File

@@ -0,0 +1 @@
nightly

20
__cpu/x86/src/main.rs Normal file
View File

@@ -0,0 +1,20 @@
use x86::cpuid::CpuId;
fn main() {
let cpu_id = CpuId::new();
println!("Vendor: {:?}", cpu_id.get_vendor_info().map(|v| v.as_string().to_owned()));
println!("Feature: {:?}", cpu_id.get_feature_info());
println!("Cache: {:?}", cpu_id.get_cache_info());
cpu_id.get_cache_info().map(|c| {
for i in c {
println!("- {}", i.desc());
}
});
println!("Processor: {:?}", cpu_id.get_processor_serial());
println!("Cache parameters: {:?}", cpu_id.get_cache_parameters());
println!("Performace monitoring: {:?}", cpu_id.get_performance_monitoring_info());
println!("Performace monitoring, number of counters: {:?}", cpu_id.get_performance_monitoring_info().unwrap().number_of_counters());
println!("SGX: {:?}", cpu_id.get_sgx_info());
println!("SoC vendor: {:?}", cpu_id.get_soc_vendor_info());
println!("Extended function: {:?}", cpu_id.get_extended_function_info());
}