Commit b332607d authored by Dan Robertson's avatar Dan Robertson

Allow using a device ID range in toml config

parent 14614045
use std::ops::Range;
#[derive(Debug, Default, Deserialize)]
pub struct Config {
pub drivers: Vec<DriverConfig>
......@@ -11,5 +13,6 @@ pub struct DriverConfig {
pub interface: Option<u8>,
pub vendor: Option<u16>,
pub device: Option<u16>,
pub device_id_range: Option<Range<u16>>,
pub command: Option<Vec<String>>
}
......@@ -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()
}
};
......
Markdown is supported
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