Unverified Commit c11736f7 authored by Jeremy Soller's avatar Jeremy Soller Committed by GitHub

Merge pull request #21 from ghatdev/master

pcid: fix error E0133
parents b7fe49cc dd5f83cd
......@@ -41,11 +41,13 @@ fn main() {
if let Some(header) = func.header() {
let pci_class = PciClass::from(header.class);
let mut string = format!("PCI {:>02X}/{:>02X}/{:>02X} {:>04X}:{:>04X} {:>02X}.{:>02X}.{:>02X}.{:>02X} {:?}",
let mut string = unsafe {
format!("PCI {:>02X}/{:>02X}/{:>02X} {:>04X}:{:>04X} {:>02X}.{:>02X}.{:>02X}.{:>02X} {:?}",
bus.num, dev.num, func.num,
header.vendor_id, header.device_id,
header.class, header.subclass, header.interface, header.revision,
pci_class);
pci_class)
};
match pci_class {
PciClass::Storage => match header.subclass {
......@@ -78,6 +80,7 @@ fn main() {
_ => ()
}
unsafe {
for i in 0..header.bars.len() {
match PciBar::from(header.bars[i]) {
PciBar::None => (),
......@@ -85,6 +88,7 @@ fn main() {
PciBar::Port(address) => string.push_str(&format!(" {}={:>04X}", i, address))
}
}
}
string.push('\n');
......@@ -124,13 +128,16 @@ fn main() {
let mut command = Command::new(program);
for arg in args {
let bar_arg = |i| -> String {
unsafe {
match PciBar::from(header.bars[i]) {
PciBar::None => String::new(),
PciBar::Memory(address) => format!("{:>08X}", address),
PciBar::Port(address) => format!("{:>04X}", address)
}
}
};
let arg = match arg.as_str() {
let arg = unsafe {
match arg.as_str() {
"$BUS" => format!("{:>02X}", bus.num),
"$DEV" => format!("{:>02X}", dev.num),
"$FUNC" => format!("{:>02X}", func.num),
......@@ -145,6 +152,7 @@ fn main() {
"$VENID" => format!("{:>04X}",header.vendor_id),
"$DEVID" => format!("{:>04X}",header.device_id),
_ => arg.clone()
}
};
command.arg(&arg);
}
......
use std::ops::{Deref, DerefMut};
use std::{slice, mem};
#[derive(Debug, Default)]
#[derive(Default)]
#[repr(packed)]
pub struct PciHeader {
pub vendor_id: u16,
......
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