Merge branch 'master' into 'master'
Simplify mapping of vendor and device ids in driver toml files by adding an ids field See merge request redox-os/drivers!44
This commit is contained in:
@@ -11,6 +11,7 @@ pub struct DriverConfig {
|
||||
pub class: Option<u8>,
|
||||
pub subclass: Option<u8>,
|
||||
pub interface: Option<u8>,
|
||||
pub ids: Option<BTreeMap<String, Vec<u16>>>,
|
||||
pub vendor: Option<u16>,
|
||||
pub device: Option<u16>,
|
||||
pub device_id_range: Option<Range<u16>>,
|
||||
|
||||
+24
-6
@@ -7,7 +7,7 @@ extern crate byteorder;
|
||||
extern crate syscall;
|
||||
extern crate toml;
|
||||
|
||||
use std::env;
|
||||
use std::{env, i64};
|
||||
use std::fs::{File, metadata, read_dir};
|
||||
use std::io::Read;
|
||||
use std::process::Command;
|
||||
@@ -80,12 +80,30 @@ fn handle_parsed_header(config: &Config, pci: &Pci, bus_num: u8,
|
||||
if interface != header.interface() { continue; }
|
||||
}
|
||||
|
||||
if let Some(vendor) = driver.vendor {
|
||||
if vendor != header.vendor_id() { continue; }
|
||||
}
|
||||
if let Some(ref ids) = driver.ids {
|
||||
let mut device_found = false;
|
||||
for (vendor, devices) in ids {
|
||||
let vendor_without_prefix = vendor.trim_left_matches("0x");
|
||||
let vendor = i64::from_str_radix(vendor_without_prefix, 16).unwrap() as u16;
|
||||
|
||||
if let Some(device) = driver.device {
|
||||
if device != header.device_id() { continue; }
|
||||
if vendor != header.vendor_id() { continue; }
|
||||
|
||||
for device in devices {
|
||||
if *device == header.device_id() {
|
||||
device_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if !device_found { continue; }
|
||||
} else {
|
||||
if let Some(vendor) = driver.vendor {
|
||||
if vendor != header.vendor_id() { continue; }
|
||||
}
|
||||
|
||||
if let Some(device) = driver.device {
|
||||
if device != header.device_id() { continue; }
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref device_id_range) = driver.device_id_range {
|
||||
|
||||
Reference in New Issue
Block a user