diff --git a/ac97d/config.toml b/ac97d/config.toml index efc85ac560..106ce703a3 100644 --- a/ac97d/config.toml +++ b/ac97d/config.toml @@ -3,4 +3,3 @@ name = "AC97 Audio" class = 0x04 subclass = 0x01 command = ["ac97d"] -use_channel = true diff --git a/ahcid/src/main.rs b/ahcid/src/main.rs index 4636495228..f41f397e73 100644 --- a/ahcid/src/main.rs +++ b/ahcid/src/main.rs @@ -4,10 +4,10 @@ extern crate syscall; extern crate byteorder; -use std::{env, usize}; use std::fs::File; use std::io::{ErrorKind, Read, Write}; use std::os::unix::io::{FromRawFd, RawFd}; +use std::usize; use pcid_interface::{PciBar, PcidServerHandle}; use syscall::error::{Error, ENODEV}; @@ -81,7 +81,11 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! { let mut name = pci_config.func.name(); name.push_str("_ahci"); - let bar = pci_config.func.bars[5]; + let bar = match pci_config.func.bars[5] { + PciBar::Memory32(addr) => addr as usize, + PciBar::Memory64(addr) => addr as usize, + PciBar::None | PciBar::Port(_) => unreachable!(), + }; let bar_size = pci_config.func.bar_sizes[5]; let irq = pci_config.func.legacy_interrupt_line; @@ -92,11 +96,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! { let address = unsafe { common::physmap( - match bar { - PciBar::Memory32(addr) => addr as usize, - PciBar::Memory64(addr) => addr as usize, - PciBar::None | PciBar::Port(_) => unreachable!(), - }, + bar, bar_size as usize, common::Prot { read: true, write: true }, common::MemoryType::Uncacheable, diff --git a/bgad/config.toml b/bgad/config.toml index 7660b1215a..a07ff05bbc 100644 --- a/bgad/config.toml +++ b/bgad/config.toml @@ -4,7 +4,6 @@ class = 0x03 vendor = 0x1234 device = 0x1111 command = ["bgad"] -use_channel = true [[drivers]] name = "VirtualBox Graphics Array" @@ -12,4 +11,3 @@ class = 0x03 vendor = 0x80EE device = 0xBEEF command = ["bgad"] -use_channel = true diff --git a/e1000d/config.toml b/e1000d/config.toml index 5ab5ad0bd5..44ce84dd09 100644 --- a/e1000d/config.toml +++ b/e1000d/config.toml @@ -3,4 +3,3 @@ name = "E1000 NIC" class = 0x02 ids = { 0x8086 = [0x1004, 0x100e, 0x100f, 0x1503] } command = ["e1000d"] -use_channel = true diff --git a/ihdad/config.toml b/ihdad/config.toml index f19df27a2c..8be0418577 100644 --- a/ihdad/config.toml +++ b/ihdad/config.toml @@ -3,4 +3,3 @@ name = "Intel HD Audio" class = 0x04 subclass = 0x03 command = ["ihdad"] -use_channel = true diff --git a/ihdad/src/main.rs b/ihdad/src/main.rs index 789b0be20e..d91013cc47 100755 --- a/ihdad/src/main.rs +++ b/ihdad/src/main.rs @@ -171,7 +171,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! { 0 => panic!("BAR 0 is mapped to address 0"), _ => ptr, }, - other => panic!("Expected memory bar, found {}", other), + other => panic!("Expected memory bar, found {:?}", other), }; log::info!(" + IHDA {} on: {:#X} size: {}", name, bar_ptr, bar_size); diff --git a/initfs.toml b/initfs.toml index 0fc44e16e4..62479eaee7 100644 --- a/initfs.toml +++ b/initfs.toml @@ -6,7 +6,6 @@ name = "AHCI storage" class = 1 subclass = 6 command = ["ahcid"] -use_channel = true # ided [[drivers]] @@ -14,7 +13,6 @@ name = "IDE storage" class = 1 subclass = 1 command = ["ided"] -use_channel = true # nvmed [[drivers]] @@ -22,7 +20,6 @@ name = "NVME storage" class = 1 subclass = 8 command = ["nvmed"] -use_channel = true [[drivers]] name = "virtio-blk" @@ -31,7 +28,6 @@ subclass = 0 vendor = 6900 device = 4097 command = ["virtio-blkd"] -use_channel = true [[drivers]] name = "virtio-gpu" @@ -39,4 +35,3 @@ class = 3 vendor = 6900 device = 4176 command = ["virtio-gpud"] -use_channel = true diff --git a/ixgbed/config.toml b/ixgbed/config.toml index 67577f22d9..a10fba5a8f 100644 --- a/ixgbed/config.toml +++ b/ixgbed/config.toml @@ -3,4 +3,3 @@ name = "Intel 10G NIC" class = 0x02 ids = { 0x8086 = [0x10F7, 0x1514, 0x1517, 0x151C, 0x10F9, 0x10FB, 0x152a, 0x1529, 0x1507, 0x154D, 0x1557, 0x10FC, 0x10F8, 0x154F, 0x1528, 0x154A, 0x1558, 0x1560, 0x1563, 0x15D1, 0x15AA, 0x15AB, 0x15AC, 0x15AD, 0x15AE, 0x15B0, 0x15C2, 0x15C3, 0x15C4, 0x15C6, 0x15C7, 0x15C8, 0x15CE, 0x15E4, 0x15E5, 0x10ED, 0x1515, 0x1565, 0x15A8, 0x15C5] } command = ["ixgbed"] -use_channel = true diff --git a/pcid/src/config.rs b/pcid/src/config.rs index c74f05842a..83faddd586 100644 --- a/pcid/src/config.rs +++ b/pcid/src/config.rs @@ -19,5 +19,4 @@ pub struct DriverConfig { pub device: Option, pub device_id_range: Option>, pub command: Option>, - pub use_channel: Option, } diff --git a/pcid/src/main.rs b/pcid/src/main.rs index 5de73c48cc..e579a6d4ab 100644 --- a/pcid/src/main.rs +++ b/pcid/src/main.rs @@ -189,17 +189,15 @@ impl DriverHandler { } } } - fn handle_spawn(mut self, pcid_to_client_write: Option, pcid_from_client_read: Option, args: driver_interface::SubdriverArguments) { + fn handle_spawn(mut self, pcid_to_client_write: usize, pcid_from_client_read: usize, args: driver_interface::SubdriverArguments) { use driver_interface::*; - if let (Some(pcid_to_client_fd), Some(pcid_from_client_fd)) = (pcid_to_client_write, pcid_from_client_read) { - let mut pcid_to_client = unsafe { File::from_raw_fd(pcid_to_client_fd as RawFd) }; - let mut pcid_from_client = unsafe { File::from_raw_fd(pcid_from_client_fd as RawFd) }; + let mut pcid_to_client = unsafe { File::from_raw_fd(pcid_to_client_write as RawFd) }; + let mut pcid_from_client = unsafe { File::from_raw_fd(pcid_from_client_read as RawFd) }; while let Ok(msg) = recv(&mut pcid_from_client) { let response = self.respond(msg, &args); send(&mut pcid_to_client, &response).unwrap(); - } } } } @@ -256,8 +254,11 @@ fn handle_parsed_header(state: Arc, config: &Config, addr: PciAddress, he } for (i, bar) in header.bars().iter().enumerate() { - if !bar.is_none() { - string.push_str(&format!(" {}={}", i, bar)); + match bar { + PciBar::None => {}, + PciBar::Memory32(addr) => string.push_str(&format!(" {i}={addr:08X}")), + PciBar::Memory64(addr) => string.push_str(&format!(" {i}={addr:016X}")), + PciBar::Port(port) => string.push_str(&format!(" {i}=P{port:04X}")), } } @@ -411,34 +412,14 @@ fn handle_parsed_header(state: Arc, config: &Config, addr: PciAddress, he if let Some(program) = args.next() { let mut command = Command::new(program); for arg in args { - let arg = match arg.as_str() { - "$BUS" => format!("{:>02X}", addr.bus()), - "$DEV" => format!("{:>02X}", addr.device()), - "$FUNC" => format!("{:>02X}", addr.function()), - "$NAME" => func.name(), - "$BAR0" => format!("{}", bars[0]), - "$BAR1" => format!("{}", bars[1]), - "$BAR2" => format!("{}", bars[2]), - "$BAR3" => format!("{}", bars[3]), - "$BAR4" => format!("{}", bars[4]), - "$BAR5" => format!("{}", bars[5]), - "$BARSIZE0" => format!("{:>08X}", bar_sizes[0]), - "$BARSIZE1" => format!("{:>08X}", bar_sizes[1]), - "$BARSIZE2" => format!("{:>08X}", bar_sizes[2]), - "$BARSIZE3" => format!("{:>08X}", bar_sizes[3]), - "$BARSIZE4" => format!("{:>08X}", bar_sizes[4]), - "$BARSIZE5" => format!("{:>08X}", bar_sizes[5]), - "$IRQ" => format!("{}", irq), - "$VENID" => format!("{:>04X}", header.vendor_id()), - "$DEVID" => format!("{:>04X}", header.device_id()), - _ => arg.clone() - }; - command.arg(&arg); + if arg.starts_with("$") { + panic!("support for $VARIABLE has been removed. use pcid_interface instead"); + } + command.arg(arg); } info!("PCID SPAWN {:?}", command); - let (pcid_to_client_write, pcid_from_client_read, envs) = if driver.use_channel.unwrap_or(false) { // TODO: libc wrapper? let [fds1, fds2] = unsafe { let mut fds1 = [0 as libc::c_int; 2]; @@ -456,10 +437,10 @@ fn handle_parsed_header(state: Arc, config: &Config, addr: PciAddress, he let [pcid_to_client_read, pcid_to_client_write] = fds1; let [pcid_from_client_read, pcid_from_client_write] = fds2; - (Some(pcid_to_client_write), Some(pcid_from_client_read), vec! [("PCID_TO_CLIENT_FD", format!("{}", pcid_to_client_read)), ("PCID_FROM_CLIENT_FD", format!("{}", pcid_from_client_write))]) - } else { - (None, None, vec! []) - }; + let envs = vec![ + ("PCID_TO_CLIENT_FD", format!("{}", pcid_to_client_read)), + ("PCID_FROM_CLIENT_FD", format!("{}", pcid_from_client_write)), + ]; match command.envs(envs).spawn() { Ok(mut child) => { diff --git a/pcid/src/pci/bar.rs b/pcid/src/pci/bar.rs index 2698818f58..e51c0b31d2 100644 --- a/pcid/src/pci/bar.rs +++ b/pcid/src/pci/bar.rs @@ -1,5 +1,3 @@ -use std::fmt; - use serde::{Serialize, Deserialize}; #[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)] @@ -41,14 +39,3 @@ impl From for PciBar { } } } - -impl fmt::Display for PciBar { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - match self { - &PciBar::Memory32(address) => write!(f, "{:>08X}", address), - &PciBar::Memory64(address) => write!(f, "{:>016X}", address), - &PciBar::Port(address) => write!(f, "{:>04X}", address), - &PciBar::None => write!(f, "None") - } - } -} diff --git a/rtl8139d/config.toml b/rtl8139d/config.toml index 1688b9ce95..05c5322479 100644 --- a/rtl8139d/config.toml +++ b/rtl8139d/config.toml @@ -3,4 +3,3 @@ name = "RTL8139 NIC" class = 0x02 ids = { 0x10ec = [0x8139] } command = ["rtl8139d"] -use_channel = true diff --git a/rtl8139d/src/main.rs b/rtl8139d/src/main.rs index eac441a25f..fd26b06812 100644 --- a/rtl8139d/src/main.rs +++ b/rtl8139d/src/main.rs @@ -183,7 +183,7 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> Option { 0 => panic!("BAR {} is mapped to address 0", bir), _ => ptr, }, - other => panic!("Expected memory bar, found {}", other), + other => panic!("Expected memory bar, found {:?}", other), }; let address = unsafe { @@ -325,7 +325,7 @@ fn find_bar(pci_config: &SubdriverArguments) -> Option<(usize, usize)> { pci_config.func.bar_sizes[barnum].try_into().unwrap() )), }, - other => log::warn!("BAR {} is {} instead of memory BAR", barnum, other), + other => log::warn!("BAR {} is {:?} instead of memory BAR", barnum, other), } } None diff --git a/rtl8168d/config.toml b/rtl8168d/config.toml index d1ddbefe5c..ee98e345f3 100644 --- a/rtl8168d/config.toml +++ b/rtl8168d/config.toml @@ -3,4 +3,3 @@ name = "RTL8168 NIC" class = 0x02 ids = { 0x10ec = [0x8168, 0x8169] } command = ["rtl8168d"] -use_channel = true diff --git a/rtl8168d/src/main.rs b/rtl8168d/src/main.rs index 2eea0c80f1..53415a2d0f 100644 --- a/rtl8168d/src/main.rs +++ b/rtl8168d/src/main.rs @@ -181,7 +181,7 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> Option { 0 => panic!("BAR {} is mapped to address 0", bir), _ => ptr, }, - other => panic!("Expected memory bar, found {}", other), + other => panic!("Expected memory bar, found {:?}", other), }; let address = unsafe { @@ -323,7 +323,7 @@ fn find_bar(pci_config: &SubdriverArguments) -> Option<(usize, usize)> { pci_config.func.bar_sizes[barnum].try_into().unwrap() )), }, - other => log::warn!("BAR {} is {} instead of memory BAR", barnum, other), + other => log::warn!("BAR {} is {:?} instead of memory BAR", barnum, other), } } None diff --git a/vboxd/config.toml b/vboxd/config.toml index d41fca4576..1216625579 100644 --- a/vboxd/config.toml +++ b/vboxd/config.toml @@ -4,4 +4,3 @@ class = 0x08 vendor = 0x80EE device = 0xCAFE command = ["vboxd"] -use_channel = true diff --git a/virtio-netd/config.toml b/virtio-netd/config.toml index 9e70971f42..ebedb9e40c 100644 --- a/virtio-netd/config.toml +++ b/virtio-netd/config.toml @@ -4,4 +4,3 @@ class = 0x02 vendor = 0x1AF4 device = 0x1000 command = ["virtio-netd"] -use_channel = true diff --git a/xhcid/src/main.rs b/xhcid/src/main.rs index 8f33ddce1a..6e15e8b0da 100644 --- a/xhcid/src/main.rs +++ b/xhcid/src/main.rs @@ -98,7 +98,7 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle, address: usize) -> (Option 0 => panic!("BAR 0 is mapped to address 0"), _ => ptr, }, - other => panic!("Expected memory bar, found {}", other), + other => panic!("Expected memory bar, found {:?}", other), }; let all_pci_features = pcid_handle.fetch_all_features().expect("xhcid: failed to fetch pci features"); @@ -260,7 +260,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! { 0 => panic!("BAR 0 is mapped to address 0"), _ => ptr, }, - other => panic!("Expected memory bar, found {}", other), + other => panic!("Expected memory bar, found {:?}", other), }; let address = unsafe { @@ -272,7 +272,7 @@ fn daemon(daemon: redox_daemon::Daemon) -> ! { print!( "{}", - format!(" + XHCI {} on: {} IRQ: {}\n", name, bar, irq) + format!(" + XHCI {} on: {:016X} IRQ: {}\n", name, bar_ptr, irq) ); let scheme_name = format!("usb.{}", name);