Skip to content

Commit

Permalink
fix: i7-620M and half of pcie stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
zleyyij committed Feb 11, 2024
1 parent 6a8cc62 commit e93f90c
Show file tree
Hide file tree
Showing 4 changed files with 37,874 additions and 4 deletions.
24 changes: 20 additions & 4 deletions src/cpu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ impl CpuCache {
/// Create a new cache and parse the cpu databases into memory
pub fn new() -> Self {
let intel_cpus = get_intel_cpus();
// for cpu in intel_cpus.clone() {
// println!("{:#?}", cpu);
// }
for cpu in intel_cpus.clone() {
println!("{}", cpu.name);
}
debug!("Intel CPU list deserialized");
let amd_cpus = get_amd_cpus();
debug!("Amd CPU list deserialized");
Expand Down Expand Up @@ -111,7 +111,6 @@ fn find_model(input: &str) -> String {
high_score = score;
}
}
// best_fit
// because some edge cases exist where the model is either vaguely reported or split among multiple tokens, those are handled here
// they are organized by blocks, each block should contain an explanation and a solution

Expand All @@ -135,6 +134,19 @@ fn find_model(input: &str) -> String {
}
}

// Intel Core iX-123M processors are sometimes represented in the format of
// iX CPU M 123
{
if input.contains("Intel") && input.contains(" M ") && best_fit.len() == 3 {
let tokens = input.split(" ");
let i_tag = tokens.filter(|t| t.len() == 2 && t.starts_with('i')).nth(0);
if let Some(t) = i_tag {
return format!("{}-{}M", t, best_fit);

}
}
}

best_fit.to_string()
}

Expand Down Expand Up @@ -196,6 +208,10 @@ mod tests {
"Intel® Core™ i7 processor 14700K",
"Intel(R) Core(TM) i7-14700K",
),
(
"Intel® Core™ i7-620M Processor",
"Intel(R) Core(TM) i7 CPU M 620 @ 2.67Ghz"
),
];

for pairing in pairings {
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod cpu;
mod usb;
mod pcie;

use axum::extract::Query;
use axum::http::HeaderValue;
Expand Down
30 changes: 30 additions & 0 deletions src/pcie/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use nom::bytes::complete::{tag, take, take_until};
use nom::character::complete::char;
use nom::sequence::{delimited, preceded};
use nom::IResult;

// the input file was obtained from https://pci-ids.ucw.cz/
const FILE_INPUT: &str = include_str!("./pci.ids.txt");

/// Vendors are at the root of the file
pub struct Vendor {
pub id: String,
pub name: String,
pub devices: Vec<Device>
}

/// Devices are placed directly under the relevant [Vendor] in the tree,
/// and are marked with one tab before, the device ID, then two spaces and the device name
pub struct Device {
pub id: String,
pub name: String,
pub subsystems: Vec<Subsystem>
}

/// Subsystems are placed directly under the relevant [Device] in the tree,
/// and are marked with two tabs before, the [Vendor] ID, a space, then the subsystem ID,
/// then two spaces, then the name of the subsystem
pub struct Subsystem {
pub id: String,
pub name: String,
}
Loading

0 comments on commit e93f90c

Please sign in to comment.