Skip to content

Commit

Permalink
Merge pull request #1552 from hermit-os/dependabot/cargo/raw-cpuid-11…
Browse files Browse the repository at this point in the history
….2.0

build(deps): Bump raw-cpuid from 10.7.0 to 11.2.0
  • Loading branch information
mkroening authored Jan 14, 2025
2 parents e37accd + 57ffdfb commit b00a5e1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ features = [
[target.'cfg(target_arch = "x86_64")'.dependencies]
free-list = { version = "0.3", features = ["x86_64"] }
multiboot = "0.8"
raw-cpuid = "10"
raw-cpuid = "11"
uart_16550 = "0.3"
x86_64 = "0.15"
memory_addresses = { version = "0.2.2", default-features = false, features = [
Expand Down
21 changes: 15 additions & 6 deletions src/arch/x86_64/kernel/processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl CpuFrequency {
self.set_detected_cpu_frequency(mhz, CpuFrequencySources::CommandLine)
}

unsafe fn detect_from_cpuid(&mut self, cpuid: &CpuId) -> Result<(), ()> {
unsafe fn detect_from_cpuid(&mut self, cpuid: &CpuId<CpuIdReaderNative>) -> Result<(), ()> {
let processor_frequency_info = cpuid.get_processor_frequency_info();

match processor_frequency_info {
Expand All @@ -336,14 +336,20 @@ impl CpuFrequency {
}
}

unsafe fn detect_from_cpuid_tsc_info(&mut self, cpuid: &CpuId) -> Result<(), ()> {
unsafe fn detect_from_cpuid_tsc_info(
&mut self,
cpuid: &CpuId<CpuIdReaderNative>,
) -> Result<(), ()> {
let tsc_info = cpuid.get_tsc_info().ok_or(())?;
let freq = tsc_info.tsc_frequency().ok_or(())?;
let mhz = (freq / 1_000_000u64) as u16;
self.set_detected_cpu_frequency(mhz, CpuFrequencySources::CpuIdTscInfo)
}

unsafe fn detect_from_cpuid_hypervisor_info(&mut self, cpuid: &CpuId) -> Result<(), ()> {
unsafe fn detect_from_cpuid_hypervisor_info(
&mut self,
cpuid: &CpuId<CpuIdReaderNative>,
) -> Result<(), ()> {
const KHZ_TO_HZ: u64 = 1000;
const MHZ_TO_HZ: u64 = 1_000_000;
let hypervisor_info = cpuid.get_hypervisor_info().ok_or(())?;
Expand All @@ -352,7 +358,10 @@ impl CpuFrequency {
self.set_detected_cpu_frequency(mhz, CpuFrequencySources::HypervisorTscInfo)
}

unsafe fn detect_from_cpuid_brand_string(&mut self, cpuid: &CpuId) -> Result<(), ()> {
unsafe fn detect_from_cpuid_brand_string(
&mut self,
cpuid: &CpuId<CpuIdReaderNative>,
) -> Result<(), ()> {
if let Some(processor_brand) = cpuid.get_processor_brand_string() {
let brand_string = processor_brand.as_str();
let ghz_find = brand_string.find("GHz");
Expand Down Expand Up @@ -524,7 +533,7 @@ struct CpuFeaturePrinter {
}

impl CpuFeaturePrinter {
fn new(cpuid: &CpuId) -> Self {
fn new(cpuid: &CpuId<CpuIdReaderNative>) -> Self {
CpuFeaturePrinter {
feature_info: cpuid
.get_feature_info()
Expand Down Expand Up @@ -704,7 +713,7 @@ impl CpuSpeedStep {
}
}

fn detect_features(&mut self, cpuid: &CpuId) {
fn detect_features(&mut self, cpuid: &CpuId<CpuIdReaderNative>) {
let feature_info = cpuid
.get_feature_info()
.expect("CPUID Feature Info not available!");
Expand Down

0 comments on commit b00a5e1

Please sign in to comment.