diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000000..73ccf1a62a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "ixgbed"] + path = ixgbed + url = https://github.com/ackxolotl/ixgbed.git diff --git a/e1000d/config.toml b/e1000d/config.toml new file mode 100644 index 0000000000..0f5f3339b3 --- /dev/null +++ b/e1000d/config.toml @@ -0,0 +1,6 @@ +[[drivers]] +name = "E1000 NIC" +class = 2 +ids = { 0x8086 = [0x1004, 0x100e, 0x100f, 0x1503] } +command = ["e1000d", "$NAME", "$BAR0", "$IRQ"] + diff --git a/filesystem.toml b/filesystem.toml index ff38fb336a..20871a0272 100644 --- a/filesystem.toml +++ b/filesystem.toml @@ -1,49 +1,5 @@ ## Drivers for FS ## -# e1000d -[[drivers]] -name = "82543GC NIC" -class = 2 -vendor = 32902 -device = 4100 -command = ["e1000d", "$NAME", "$BAR0", "$IRQ"] - -[[drivers]] -name = "82540EM NIC" -class = 2 -vendor = 32902 -device = 4110 -command = ["e1000d", "$NAME", "$BAR0", "$IRQ"] - -[[drivers]] -name = "82545EM NIC" -class = 2 -vendor = 32902 -device = 4111 -command = ["e1000d", "$NAME", "$BAR0", "$IRQ"] - -[[drivers]] -name = "82579V NIC" -class = 2 -vendor = 32902 -device = 5379 -command = ["e1000d", "$NAME", "$BAR0", "$IRQ"] - -# ihdad -[[drivers]] -name = "Intel HD Audio" -class = 4 -subclass = 3 -command = ["ihdad", "$NAME", "$BAR0", "$IRQ", "$VENID", "$DEVID"] - -# rtl8168d -[[drivers]] -name = "RTL8168 NIC" -class = 2 -vendor = 4332 -device = 33128 -command = ["rtl8168d", "$NAME", "$BAR2", "$IRQ"] - # xhcid # [[drivers]] # name = "XHCI" diff --git a/ihdad/config.toml b/ihdad/config.toml new file mode 100644 index 0000000000..2bee08c1f4 --- /dev/null +++ b/ihdad/config.toml @@ -0,0 +1,6 @@ +[[drivers]] +name = "Intel HD Audio" +class = 4 +subclass = 3 +command = ["ihdad", "$NAME", "$BAR0", "$IRQ", "$VENID", "$DEVID"] + diff --git a/ixgbed b/ixgbed new file mode 160000 index 0000000000..26c0142179 --- /dev/null +++ b/ixgbed @@ -0,0 +1 @@ +Subproject commit 26c0142179a8fbcae22d1d48979681fe029c04e3 diff --git a/pcid/src/config.rs b/pcid/src/config.rs index 8a36d8df1d..ee7756c82e 100644 --- a/pcid/src/config.rs +++ b/pcid/src/config.rs @@ -11,6 +11,7 @@ pub struct DriverConfig { pub class: Option, pub subclass: Option, pub interface: Option, + pub ids: Option>>, pub vendor: Option, pub device: Option, pub device_id_range: Option>, diff --git a/pcid/src/main.rs b/pcid/src/main.rs index 259664612a..bf5581fc0d 100644 --- a/pcid/src/main.rs +++ b/pcid/src/main.rs @@ -7,8 +7,8 @@ extern crate byteorder; extern crate syscall; extern crate toml; -use std::env; -use std::fs::File; +use std::{env, i64}; +use std::fs::{File, metadata, read_dir}; use std::io::Read; use std::process::Command; use syscall::iopl; @@ -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 { @@ -161,11 +179,28 @@ fn main() { let mut args = env::args().skip(1); if let Some(config_path) = args.next() { - if let Ok(mut config_file) = File::open(&config_path) { - let mut config_data = String::new(); - if let Ok(_) = config_file.read_to_string(&mut config_data) { - config = toml::from_str(&config_data).unwrap_or(Config::default()); + if metadata(&config_path).unwrap().is_file() { + if let Ok(mut config_file) = File::open(&config_path) { + let mut config_data = String::new(); + if let Ok(_) = config_file.read_to_string(&mut config_data) { + config = toml::from_str(&config_data).unwrap_or(Config::default()); + } } + } else { + let paths = read_dir(&config_path).unwrap(); + + let mut config_data = String::new(); + + for path in paths { + if let Ok(mut config_file) = File::open(&path.unwrap().path()) { + let mut tmp = String::new(); + if let Ok(_) = config_file.read_to_string(&mut tmp) { + config_data.push_str(&tmp); + } + } + } + + config = toml::from_str(&config_data).unwrap_or(Config::default()); } } diff --git a/rtl8168d/config.toml b/rtl8168d/config.toml new file mode 100644 index 0000000000..04a3626044 --- /dev/null +++ b/rtl8168d/config.toml @@ -0,0 +1,6 @@ +[[drivers]] +name = "RTL8168 NIC" +class = 2 +ids = { 0x10ec = [0x8168] } +command = ["rtl8168d", "$NAME", "$BAR2", "$IRQ"] +