From b332607d774948eb375ee724b404f12ac581f4b8 Mon Sep 17 00:00:00 2001 From: Dan Robertson Date: Sun, 4 Feb 2018 02:35:36 +0000 Subject: [PATCH] Allow using a device ID range in toml config --- pcid/src/config.rs | 3 +++ pcid/src/main.rs | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/pcid/src/config.rs b/pcid/src/config.rs index 44c5e71df9..8a36d8df1d 100644 --- a/pcid/src/config.rs +++ b/pcid/src/config.rs @@ -1,3 +1,5 @@ +use std::ops::Range; + #[derive(Debug, Default, Deserialize)] pub struct Config { pub drivers: Vec @@ -11,5 +13,6 @@ pub struct DriverConfig { pub interface: Option, pub vendor: Option, pub device: Option, + pub device_id_range: Option>, pub command: Option> } diff --git a/pcid/src/main.rs b/pcid/src/main.rs index a59a104fbe..ea8f3495a7 100644 --- a/pcid/src/main.rs +++ b/pcid/src/main.rs @@ -115,6 +115,11 @@ fn main() { if device != header.device_id { continue; } } + if let Some(ref device_id_range) = driver.device_id_range { + if header.device_id < device_id_range.start || + device_id_range.end <= header.device_id { continue; } + } + if let Some(ref args) = driver.command { // Enable bus mastering, memory space, and I/O space unsafe { @@ -149,6 +154,7 @@ fn main() { "$IRQ" => format!("{}", header.interrupt_line), "$VENID" => format!("{:>04X}",header.vendor_id), "$DEVID" => format!("{:>04X}",header.device_id), + "$SUBSYSID" => format!("{:>04X}",header.subsystem_id), _ => arg.clone() } };