From b53ff20fd108acd0423961eaccc58693f5b66981 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Thu, 30 Apr 2020 07:59:18 +0200 Subject: [PATCH] use the new x86 crate to solve issue #30 --- Cargo.lock | 12 ++++++------ src/arch/x86_64/kernel/processor.rs | 11 ++++++----- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3dbf1c4b98..cdaeb4fb12 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -35,7 +35,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "raw-cpuid" -version = "7.0.3" +version = "8.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -58,7 +58,7 @@ dependencies = [ "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", "multiboot 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "x86 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)", + "x86 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -76,12 +76,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "x86" -version = "0.32.0" +version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bit_field 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", + "raw-cpuid 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] @@ -91,8 +91,8 @@ dependencies = [ "checksum cfg-if 0.1.10 (registry+https://github.com/rust-lang/crates.io-index)" = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" "checksum log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)" = "14b6052be84e6b71ab17edffc2eeabf5c2c3ae1fdb464aae35ac50c67a44e1f7" "checksum multiboot 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "745e351d4f128ea9e266fe2dd04a1bd7349c60441d45ec8677520bae08e25d43" -"checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" +"checksum raw-cpuid 8.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "9e9c0f2091b865a94bc3c9d34896cc4bbda04453453c391f7eb224491be9ae1d" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" "checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" "checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" -"checksum x86 0.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f8cc872a9a776500ccc6f49799729858738c946b8865fa7e3d6b47cc5dc3a8a7" +"checksum x86 0.33.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2786ac694ed572ab5d2bbcd9e188805dba26b3501973dd69718914fb3d4a5a69" diff --git a/src/arch/x86_64/kernel/processor.rs b/src/arch/x86_64/kernel/processor.rs index 30ffb15eec..22847438e9 100644 --- a/src/arch/x86_64/kernel/processor.rs +++ b/src/arch/x86_64/kernel/processor.rs @@ -276,11 +276,12 @@ impl CpuFrequency { match cpuid.get_tsc_info() { Some(tsc_info) => { // check if tsc_info provides a correct value - if tsc_info.denominator() != 0 { - let mhz = (tsc_info.tsc_frequency() / 1000000u64) as u16; - self.set_detected_cpu_frequency(mhz, CpuFrequencySources::CpuIdTscInfo) - } else { - Err(()) + match tsc_info.tsc_frequency() { + Some(freq) => { + let mhz = (freq / 1000000u64) as u16; + self.set_detected_cpu_frequency(mhz, CpuFrequencySources::CpuIdTscInfo) + } + None => Err(()) } } None => Err(()),