Merge branch 'pci_force_pcid_interface' into 'master'

Migrate all PCI drivers to pcid_interface

See merge request redox-os/drivers!133
This commit is contained in:
Jeremy Soller
2024-01-20 23:08:12 +00:00
32 changed files with 173 additions and 160 deletions
Generated
+6
View File
@@ -9,6 +9,7 @@ dependencies = [
"bitflags 1.3.2",
"common",
"log",
"pcid",
"redox-daemon",
"redox-log",
"redox_event 0.1.0",
@@ -46,6 +47,7 @@ dependencies = [
"common",
"log",
"partitionlib",
"pcid",
"redox-daemon",
"redox-log",
"redox_syscall 0.4.1",
@@ -166,6 +168,7 @@ name = "bgad"
version = "0.1.0"
dependencies = [
"orbclient",
"pcid",
"redox-daemon",
"redox_syscall 0.4.1",
]
@@ -376,6 +379,7 @@ dependencies = [
"bitflags 1.3.2",
"common",
"netutils",
"pcid",
"redox-daemon",
"redox_event 0.1.0",
"redox_syscall 0.4.1",
@@ -661,6 +665,7 @@ dependencies = [
"bitflags 1.3.2",
"common",
"netutils",
"pcid",
"redox-daemon",
"redox_event 0.1.0",
"redox_syscall 0.4.1",
@@ -1662,6 +1667,7 @@ version = "0.1.0"
dependencies = [
"common",
"orbclient",
"pcid",
"redox-daemon",
"redox_event 0.1.0",
"redox_syscall 0.4.1",
+2
View File
@@ -12,3 +12,5 @@ redox-log = "0.1"
redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.4"
spin = "0.9"
pcid = { path = "../pcid" }
+3 -3
View File
@@ -1,5 +1,5 @@
[[drivers]]
name = "AC97 Audio"
class = 4
subclass = 1
command = ["ac97d", "$NAME", "$BAR0", "$BAR1", "$IRQ"]
class = 0x04
subclass = 0x01
command = ["ac97d"]
+19 -11
View File
@@ -5,16 +5,17 @@ extern crate spin;
extern crate syscall;
extern crate event;
use std::{env, usize};
use std::fs::File;
use std::io::{ErrorKind, Read, Write, Result};
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use syscall::{Packet, SchemeBlockMut, EventFlags};
use std::cell::RefCell;
use std::sync::Arc;
use std::usize;
use event::EventQueue;
use pcid_interface::{PciBar, PcidServerHandle};
use redox_log::{OutputBuilder, RedoxLogger};
use syscall::{EventFlags, Packet, SchemeBlockMut};
pub mod device;
@@ -63,26 +64,33 @@ fn setup_logging() -> Option<&'static RedoxLogger> {
}
fn main() {
let mut args = env::args().skip(1);
let mut pcid_handle =
PcidServerHandle::connect_default().expect("ac97d: failed to setup channel to pcid");
let pci_config = pcid_handle
.fetch_config()
.expect("ac97d: failed to fetch config");
let mut name = args.next().expect("ac97: no name provided");
let mut name = pci_config.func.name();
name.push_str("_ac97");
let bar0_str = args.next().expect("ac97: no address provided");
let bar0 = u16::from_str_radix(&bar0_str, 16).expect("ac97: failed to parse address");
let bar0 = match pci_config.func.bars[0] {
PciBar::Port(port) => port,
_ => unreachable!(),
};
let bar1_str = args.next().expect("ac97: no address provided");
let bar1 = u16::from_str_radix(&bar1_str, 16).expect("ac97: failed to parse address");
let bar1 = match pci_config.func.bars[1] {
PciBar::Port(port) => port,
_ => unreachable!(),
};
let irq_str = args.next().expect("ac97: no irq provided");
let irq = irq_str.parse::<u8>().expect("ac97: failed to parse irq");
let irq = pci_config.func.legacy_interrupt_line;
print!("{}", format!(" + ac97 {} on: {:X}, {:X}, IRQ {}\n", name, bar0, bar1, irq));
// Daemonize
redox_daemon::Daemon::new(move |daemon| {
let _logger_ref = setup_logging();
unsafe { syscall::iopl(3) }.expect("ac97d: failed to set I/O privilege level to Ring 3");
let mut irq_file = File::open(format!("irq:{}", irq)).expect("ac97d: failed to open IRQ file");
+1
View File
@@ -14,3 +14,4 @@ redox_syscall = "0.4"
block-io-wrapper = { path = "../block-io-wrapper" }
common = { path = "../common" }
pcid = { path = "../pcid" }
+17 -12
View File
@@ -4,11 +4,12 @@
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};
use syscall::data::{Event, Packet};
use syscall::flag::EVENT_READ;
@@ -71,28 +72,32 @@ fn main() {
}
fn daemon(daemon: redox_daemon::Daemon) -> ! {
let mut args = env::args().skip(1);
let mut pcid_handle =
PcidServerHandle::connect_default().expect("ahcid: failed to setup channel to pcid");
let pci_config = pcid_handle
.fetch_config()
.expect("ahcid: failed to fetch config");
let mut name = args.next().expect("ahcid: no name provided");
let mut name = pci_config.func.name();
name.push_str("_ahci");
let bar_str = args.next().expect("ahcid: no address provided");
let bar = usize::from_str_radix(&bar_str, 16).expect("ahcid: failed to parse address");
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 bar_size_str = args.next().expect("ahcid: no address size provided");
let bar_size = usize::from_str_radix(&bar_size_str, 16).expect("ahcid: failed to parse address size");
let irq_str = args.next().expect("ahcid: no irq provided");
let irq = irq_str.parse::<u8>().expect("ahcid: failed to parse irq");
let irq = pci_config.func.legacy_interrupt_line;
let _logger_ref = setup_logging(&name);
info!(" + AHCI {} on: {:X} size: {} IRQ: {}", name, bar, bar_size, irq);
info!(" + AHCI {} on: {} size: {} IRQ: {}", name, bar, bar_size, irq);
let address = unsafe {
common::physmap(
bar,
bar_size,
bar_size as usize,
common::Prot { read: true, write: true },
common::MemoryType::Uncacheable,
).expect("ahcid: failed to map address")
+2
View File
@@ -7,3 +7,5 @@ edition = "2018"
orbclient = "0.3.27"
redox-daemon = "0.1"
redox_syscall = "0.4"
pcid = { path = "../pcid" }
+8 -8
View File
@@ -1,13 +1,13 @@
[[drivers]]
name = "QEMU Graphics Array"
class = 3
vendor = 4660
device = 4369
command = ["bgad", "$NAME", "$BAR0"]
class = 0x03
vendor = 0x1234
device = 0x1111
command = ["bgad"]
[[drivers]]
name = "VirtualBox Graphics Array"
class = 3
vendor = 33006
device = 48879
command = ["bgad", "$NAME", "$BAR0"]
class = 0x03
vendor = 0x80EE
device = 0xBEEF
command = ["bgad"]
+20 -14
View File
@@ -1,12 +1,10 @@
#![deny(warnings)]
extern crate orbclient;
extern crate syscall;
use std::env;
use std::fs::File;
use std::io::{Read, Write};
use pcid_interface::PcidServerHandle;
use syscall::call::iopl;
use syscall::data::Packet;
use syscall::scheme::SchemeMut;
@@ -18,15 +16,16 @@ mod bga;
mod scheme;
fn main() {
let mut args = env::args().skip(1);
let mut pcid_handle =
PcidServerHandle::connect_default().expect("bgad: failed to setup channel to pcid");
let pci_config = pcid_handle
.fetch_config()
.expect("bgad: failed to fetch config");
let mut name = args.next().expect("bgad: no name provided");
let mut name = pci_config.func.name();
name.push_str("_bga");
let bar_str = args.next().expect("bgad: no address provided");
let bar = usize::from_str_radix(&bar_str, 16).expect("bgad: failed to parse address");
print!("{}", format!(" + BGA {} on: {:X}\n", name, bar));
println!(" + BGA {}", name);
redox_daemon::Daemon::new(move |daemon| {
unsafe { iopl(3).unwrap() };
@@ -34,11 +33,11 @@ fn main() {
let mut socket = File::create(":bga").expect("bgad: failed to create bga scheme");
let mut bga = Bga::new();
print!("{}", format!(" - BGA {}x{}\n", bga.width(), bga.height()));
println!(" - BGA {}x{}", bga.width(), bga.height());
let mut scheme = BgaScheme {
bga,
display: File::open("input:producer").ok()
display: File::open("input:producer").ok(),
};
scheme.update_size();
@@ -49,12 +48,19 @@ fn main() {
loop {
let mut packet = Packet::default();
if socket.read(&mut packet).expect("bgad: failed to read events from bga scheme") == 0 {
if socket
.read(&mut packet)
.expect("bgad: failed to read events from bga scheme")
== 0
{
break;
}
scheme.handle(&mut packet);
socket.write(&packet).expect("bgad: failed to write responses to bga scheme");
socket
.write(&packet)
.expect("bgad: failed to write responses to bga scheme");
}
std::process::exit(0);
}).expect("bgad: failed to daemonize");
})
.expect("bgad: failed to daemonize");
}
+1
View File
@@ -11,3 +11,4 @@ redox_event = { git = "https://gitlab.redox-os.org/redox-os/event.git" }
redox_syscall = "0.4"
common = { path = "../common" }
pcid = { path = "../pcid" }
+2 -2
View File
@@ -1,5 +1,5 @@
[[drivers]]
name = "E1000 NIC"
class = 2
class = 0x02
ids = { 0x8086 = [0x1004, 0x100e, 0x100f, 0x1503] }
command = ["e1000d", "$NAME", "$BAR0", "$BARSIZE0", "$IRQ"]
command = ["e1000d"]
+15 -10
View File
@@ -3,13 +3,14 @@ extern crate netutils;
extern crate syscall;
use std::cell::RefCell;
use std::{env, process};
use std::fs::File;
use std::io::{ErrorKind, Read, Result, Write};
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::process;
use std::sync::Arc;
use event::EventQueue;
use pcid_interface::{PciBar, PcidServerHandle};
use syscall::{EventFlags, Packet, SchemeBlockMut};
pub mod device;
@@ -58,19 +59,23 @@ fn handle_update(
}
fn main() {
let mut args = env::args().skip(1);
let mut pcid_handle =
PcidServerHandle::connect_default().expect("e1000d: failed to setup channel to pcid");
let pci_config = pcid_handle
.fetch_config()
.expect("e1000d: failed to fetch config");
let mut name = args.next().expect("e1000d: no name provided");
let mut name = pci_config.func.name();
name.push_str("_e1000");
let bar_str = args.next().expect("e1000d: no address provided");
let bar = usize::from_str_radix(&bar_str, 16).expect("e1000d: failed to parse address");
let bar = match pci_config.func.bars[0] {
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[0] as usize;
let bar_size_str = args.next().expect("e1000d: no address size provided");
let bar_size = usize::from_str_radix(&bar_size_str, 16).expect("e1000d: failed to parse address size");
let irq_str = args.next().expect("e1000d: no irq provided");
let irq = irq_str.parse::<u8>().expect("e1000d: failed to parse irq");
let irq = pci_config.func.legacy_interrupt_line;
eprintln!(" + E1000 {} on: {:X} size: {} IRQ: {}", name, bar, bar_size, irq);
+2 -3
View File
@@ -1,6 +1,5 @@
[[drivers]]
name = "Intel HD Audio"
class = 4
subclass = 3
class = 0x04
subclass = 0x03
command = ["ihdad"]
use_channel = true
+1 -1
View File
@@ -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);
+1 -5
View File
@@ -5,7 +5,7 @@
name = "AHCI storage"
class = 1
subclass = 6
command = ["ahcid", "$NAME", "$BAR5", "$BARSIZE5", "$IRQ"]
command = ["ahcid"]
# ided
[[drivers]]
@@ -13,7 +13,6 @@ name = "IDE storage"
class = 1
subclass = 1
command = ["ided"]
use_channel = true
# nvmed
[[drivers]]
@@ -21,7 +20,6 @@ name = "NVME storage"
class = 1
subclass = 8
command = ["nvmed"]
use_channel = true
[[drivers]]
name = "virtio-blk"
@@ -30,7 +28,6 @@ subclass = 0
vendor = 6900
device = 4097
command = ["virtio-blkd"]
use_channel = true
[[drivers]]
name = "virtio-gpu"
@@ -38,4 +35,3 @@ class = 3
vendor = 6900
device = 4176
command = ["virtio-gpud"]
use_channel = true
+2
View File
@@ -1,6 +1,7 @@
[package]
name = "ixgbed"
version = "1.0.0"
edition = "2021"
[dependencies]
bitflags = "1.0"
@@ -10,3 +11,4 @@ redox_syscall = "0.4"
redox-daemon = "0.1"
common = { path = "../common" }
pcid = { path = "../pcid" }
+2 -3
View File
@@ -1,6 +1,5 @@
[[drivers]]
name = "Intel 10G NIC"
class = 2
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", "$NAME", "$BAR0", "$IRQ"]
command = ["ixgbed"]
+1 -1
View File
@@ -10,7 +10,7 @@ use syscall::scheme::SchemeBlockMut;
use common::dma::Dma;
use netutils::setcfg;
use ixgbe::*;
use crate::ixgbe::*;
pub struct Intel8259x {
base: usize,
+14 -7
View File
@@ -10,9 +10,10 @@ use std::fs::File;
use std::io::{ErrorKind, Read, Result, Write};
use std::os::unix::io::{AsRawFd, FromRawFd, RawFd};
use std::sync::Arc;
use std::{env, thread};
use std::thread;
use event::EventQueue;
use pcid_interface::{PciBar, PcidServerHandle};
use std::time::Duration;
use syscall::{EventFlags, Packet, SchemeBlockMut};
@@ -66,16 +67,22 @@ fn handle_update(
}
fn main() {
let mut args = env::args().skip(1);
let mut pcid_handle =
PcidServerHandle::connect_default().expect("ixgbed: failed to setup channel to pcid");
let pci_config = pcid_handle
.fetch_config()
.expect("ixgbed: failed to fetch config");
let mut name = args.next().expect("ixgbed: no name provided");
let mut name = pci_config.func.name();
name.push_str("_ixgbe");
let bar_str = args.next().expect("ixgbed: no address provided");
let bar = usize::from_str_radix(&bar_str, 16).expect("ixgbed: failed to parse address");
let bar = match pci_config.func.bars[0] {
PciBar::Memory32(addr) => addr as usize,
PciBar::Memory64(addr) => addr as usize,
PciBar::None | PciBar::Port(_) => unreachable!(),
};
let irq_str = args.next().expect("ixgbed: no irq provided");
let irq = irq_str.parse::<u8>().expect("ixgbed: failed to parse irq");
let irq = pci_config.func.legacy_interrupt_line;
println!(" + IXGBE {} on: {:X} IRQ: {}", name, bar, irq);
-1
View File
@@ -19,5 +19,4 @@ pub struct DriverConfig {
pub device: Option<u16>,
pub device_id_range: Option<Range<u16>>,
pub command: Option<Vec<String>>,
pub use_channel: Option<bool>,
}
+16 -35
View File
@@ -189,17 +189,15 @@ impl DriverHandler {
}
}
}
fn handle_spawn(mut self, pcid_to_client_write: Option<usize>, pcid_from_client_read: Option<usize>, 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<State>, 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<State>, 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<State>, 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) => {
-13
View File
@@ -1,5 +1,3 @@
use std::fmt;
use serde::{Serialize, Deserialize};
#[derive(Clone, Copy, Debug, PartialEq, Serialize, Deserialize)]
@@ -41,14 +39,3 @@ impl From<u32> 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")
}
}
}
+1 -2
View File
@@ -1,6 +1,5 @@
[[drivers]]
name = "RTL8139 NIC"
class = 2
class = 0x02
ids = { 0x10ec = [0x8139] }
command = ["rtl8139d"]
use_channel = true
+2 -2
View File
@@ -183,7 +183,7 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> Option<File> {
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
+1 -2
View File
@@ -1,6 +1,5 @@
[[drivers]]
name = "RTL8168 NIC"
class = 2
class = 0x02
ids = { 0x10ec = [0x8168, 0x8169] }
command = ["rtl8168d"]
use_channel = true
+2 -2
View File
@@ -181,7 +181,7 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> Option<File> {
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
+1
View File
@@ -10,3 +10,4 @@ redox_syscall = "0.4"
redox-daemon = "0.1"
common = { path = "../common" }
pcid = { path = "../pcid" }
+4 -4
View File
@@ -1,6 +1,6 @@
[[drivers]]
name = "VirtualBox Guest Device"
class = 8
vendor = 33006
device = 51966
command = ["vboxd", "$NAME", "$BAR0", "$BAR1", "$IRQ"]
class = 0x08
vendor = 0x80EE
device = 0xCAFE
command = ["vboxd"]
+18 -9
View File
@@ -5,11 +5,12 @@ extern crate orbclient;
extern crate syscall;
use event::EventQueue;
use std::{env, mem};
use std::mem;
use std::os::unix::io::AsRawFd;
use std::fs::File;
use std::io::{Result, Read, Write};
use pcid_interface::{PciBar, PcidServerHandle};
use syscall::call::iopl;
use syscall::flag::EventFlags;
use syscall::io::{Io, Mmio, Pio};
@@ -184,19 +185,27 @@ impl VboxGuestInfo {
}
fn main() {
let mut args = env::args().skip(1);
let mut pcid_handle =
PcidServerHandle::connect_default().expect("vboxd: failed to setup channel to pcid");
let pci_config = pcid_handle
.fetch_config()
.expect("vboxd: failed to fetch config");
let mut name = args.next().expect("vboxd: no name provided");
let mut name = pci_config.func.name();
name.push_str("_vbox");
let bar0_str = args.next().expect("vboxd: no address provided");
let bar0 = usize::from_str_radix(&bar0_str, 16).expect("vboxd: failed to parse address");
let bar0 = match pci_config.func.bars[0] {
PciBar::Port(port) => port,
_ => unreachable!(),
};
let bar1_str = args.next().expect("vboxd: no address provided");
let bar1 = usize::from_str_radix(&bar1_str, 16).expect("vboxd: failed to parse address");
let bar1 = match pci_config.func.bars[1] {
PciBar::Memory32(addr) => addr as usize,
PciBar::Memory64(addr) => addr as usize,
PciBar::None | PciBar::Port(_) => unreachable!(),
};
let irq_str = args.next().expect("vboxd: no irq provided");
let irq = irq_str.parse::<u8>().expect("vboxd: failed to parse irq");
let irq = pci_config.func.legacy_interrupt_line;
print!("{}", format!(" + VirtualBox {} on: {:X}, {:X}, IRQ {}\n", name, bar0, bar1, irq));
+3 -4
View File
@@ -1,7 +1,6 @@
[[drivers]]
name = "virtio-net"
class = 2
vendor = 6900
device = 4096
class = 0x02
vendor = 0x1AF4
device = 0x1000
command = ["virtio-netd"]
use_channel = true
+3 -3
View File
@@ -1,7 +1,7 @@
[[drivers]]
name = "XHCI"
class = 12
subclass = 3
interface = 48
class = 0x0C
subclass = 0x03
interface = 0x30
command = ["xhcid"]
use_channel = true
+3 -3
View File
@@ -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);