Commit b8b4624a authored by Stefan Lankes's avatar Stefan Lankes
Browse files

Bump x86 from 0.40.0 to 0.41.0

- Bumps x86 from 0.40.0 to 0.41.0.
- The new version breaks the interface and requires source code modifications.
- see https://github.com/gz/rust-cpuid/blob/aaaa6e6fc07d04850f6119732b950d3a8383173b/CHANGELOG.md
parent a4708b7b
......@@ -162,9 +162,9 @@ dependencies = [
[[package]]
name = "raw-cpuid"
version = "9.1.1"
version = "10.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1733f6f80c9c24268736a501cd00d41a9849b4faa7a9f9334c096e5d10553206"
checksum = "929f54e29691d4e6a9cc558479de70db7aa3d98cd6fe7ab86d7507aa2886b9d2"
dependencies = [
"bitflags",
]
......@@ -210,9 +210,9 @@ checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3"
[[package]]
name = "x86"
version = "0.40.0"
version = "0.41.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "702d51a8a099ea6b47826796377591d2ed47116c7f0454f0d08d1d9872944880"
checksum = "edcf43654d533a571fe7f7116373098a95ebc01279efdc5038fc45d3b220cb5a"
dependencies = [
"bit_field",
"bitflags",
......
......@@ -60,12 +60,12 @@ scopeguard = { version = "1.1", default-features = false }
[target.'cfg(target_arch = "x86_64")'.dependencies]
multiboot = "0.6"
x86 = { version = "0.40", default-features = false }
x86 = { version = "0.41", default-features = false }
[dev-dependencies]
float-cmp = "0.8"
num-traits = { version = "0.2", default-features = false }
x86 = { version = "0.40", default-features = false }
x86 = { version = "0.41", default-features = false }
# The development profile, used for `cargo build`.
[profile.dev]
......
......@@ -291,29 +291,26 @@ impl CpuFrequency {
}
unsafe fn detect_from_cpuid_brand_string(&mut self, cpuid: &CpuId) -> Result<(), ()> {
let extended_function_info = cpuid
.get_extended_function_info()
.expect("CPUID Extended Function Info not available!");
let brand_string = extended_function_info
.processor_brand_string()
.expect("CPUID Brand String not available!");
let ghz_find = brand_string.find("GHz");
if let Some(ghz_find) = ghz_find {
let index = ghz_find - 4;
let thousand_char = brand_string.chars().nth(index).unwrap();
let decimal_char = brand_string.chars().nth(index + 1).unwrap();
let hundred_char = brand_string.chars().nth(index + 2).unwrap();
let ten_char = brand_string.chars().nth(index + 3).unwrap();
if let (Some(thousand), '.', Some(hundred), Some(ten)) = (
thousand_char.to_digit(10),
decimal_char,
hundred_char.to_digit(10),
ten_char.to_digit(10),
) {
let mhz = (thousand * 1000 + hundred * 100 + ten * 10) as u16;
return self.set_detected_cpu_frequency(mhz, CpuFrequencySources::CpuIdTscInfo);
if let Some(processor_brand) = cpuid.get_processor_brand_string() {
let brand_string = processor_brand.as_str();
let ghz_find = brand_string.find("GHz");
if let Some(ghz_find) = ghz_find {
let index = ghz_find - 4;
let thousand_char = brand_string.chars().nth(index).unwrap();
let decimal_char = brand_string.chars().nth(index + 1).unwrap();
let hundred_char = brand_string.chars().nth(index + 2).unwrap();
let ten_char = brand_string.chars().nth(index + 3).unwrap();
if let (Some(thousand), '.', Some(hundred), Some(ten)) = (
thousand_char.to_digit(10),
decimal_char,
hundred_char.to_digit(10),
ten_char.to_digit(10),
) {
let mhz = (thousand * 1000 + hundred * 100 + ten * 10) as u16;
return self.set_detected_cpu_frequency(mhz, CpuFrequencySources::CpuIdTscInfo);
}
}
}
......@@ -447,7 +444,7 @@ impl fmt::Display for CpuFrequency {
struct CpuFeaturePrinter {
feature_info: FeatureInfo,
extended_feature_info: ExtendedFeatures,
extended_function_info: ExtendedFunctionInfo,
extend_processor_identifiers: ExtendedProcessorFeatureIdentifiers,
}
impl CpuFeaturePrinter {
......@@ -459,9 +456,9 @@ impl CpuFeaturePrinter {
extended_feature_info: cpuid
.get_extended_feature_info()
.expect("CPUID Extended Feature Info not available!"),
extended_function_info: cpuid
.get_extended_function_info()
.expect("CPUID Extended Function Info not available!"),
extend_processor_identifiers: cpuid
.get_extended_processor_and_feature_identifiers()
.expect("Extended Processor and Processor Feature Identifiers not available"),
}
}
}
......@@ -519,7 +516,7 @@ impl fmt::Display for CpuFeaturePrinter {
if self.feature_info.has_vmx() {
write!(f, "VMX ")?;
}
if self.extended_function_info.has_rdtscp() {
if self.extend_processor_identifiers.has_rdtscp() {
write!(f, "RDTSCP ")?;
}
if self.feature_info.has_monitor_mwait() {
......@@ -718,18 +715,17 @@ pub fn detect_features() {
let extended_feature_info = cpuid
.get_extended_feature_info()
.expect("CPUID Extended Feature Info not available!");
let extended_function_info = cpuid
.get_extended_function_info()
.expect("CPUID Extended Function Info not available!");
let processor_capacity_info = cpuid
.get_processor_capacity_feature_info()
.expect("Processor Capacity Parameters and Extended Feature Identification not available!");
let extend_processor_identifiers = cpuid
.get_extended_processor_and_feature_identifiers()
.expect("Extended Processor and Processor Feature Identifiers not available");
unsafe {
PHYSICAL_ADDRESS_BITS = extended_function_info
.physical_address_bits()
.expect("CPUID Physical Address Bits not available!");
LINEAR_ADDRESS_BITS = extended_function_info
.linear_address_bits()
.expect("CPUID Linear Address Bits not available!");
SUPPORTS_1GIB_PAGES = extended_function_info.has_1gib_pages();
PHYSICAL_ADDRESS_BITS = processor_capacity_info.physical_address_bits();
LINEAR_ADDRESS_BITS = processor_capacity_info.linear_address_bits();
SUPPORTS_1GIB_PAGES = extend_processor_identifiers.has_1gib_pages();
SUPPORTS_AVX = feature_info.has_avx();
SUPPORTS_RDRAND = feature_info.has_rdrand();
SUPPORTS_TSC_DEADLINE = feature_info.has_tsc_deadline();
......@@ -738,7 +734,7 @@ pub fn detect_features() {
RUN_ON_HYPERVISOR = feature_info.has_hypervisor();
SUPPORTS_FSGS = extended_feature_info.has_fsgsbase();
if extended_function_info.has_rdtscp() {
if extend_processor_identifiers.has_rdtscp() {
TIMESTAMP_FUNCTION = get_timestamp_rdtscp;
}
......@@ -852,15 +848,11 @@ pub fn print_information() {
infoheader!(" CPU INFORMATION ");
let cpuid = CpuId::new();
let extended_function_info = cpuid
.get_extended_function_info()
.expect("CPUID Extended Function Info not available!");
let brand_string = extended_function_info
.processor_brand_string()
.expect("CPUID Brand String not available!");
let feature_printer = CpuFeaturePrinter::new(&cpuid);
infoentry!("Model", brand_string);
if let Some(brand_string) = cpuid.get_processor_brand_string() {
infoentry!("Model", brand_string.as_str());
}
unsafe {
infoentry!("Frequency", CPU_FREQUENCY);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment