diff --git a/ableos/src/devices/pci/mod.rs b/ableos/src/devices/pci/mod.rs index 1afb0c27..5b7c1c45 100644 --- a/ableos/src/devices/pci/mod.rs +++ b/ableos/src/devices/pci/mod.rs @@ -32,6 +32,8 @@ pub struct PciDeviceInfo { pub bus: u8, pub device_id: DeviceID, pub full_class: PciFullClass, + pub prog_if: u8, + pub rev_id: u8, pub header_type: u8, pub bars: [u32; 6], pub supported_fns: [bool; 8], @@ -51,13 +53,16 @@ impl PciDeviceInfo { impl Display for PciDeviceInfo { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { let vendor_name = &self.device_id.vendor; + let device_id = &self.device_id.id; writeln!( f, - "Device {} | Bus {:X} | Vendor: {}", - self.device, self.bus, vendor_name + "Device: {} | Bus: 0x{:X} | Vendor: {} | Device ID: 0x{:X}", + self.device, self.bus, vendor_name, device_id, )?; writeln!(f, "{}", self.full_class)?; - writeln!(f, " Header type: {:X}", self.header_type)?; + writeln!(f, " Revision ID: {}", self.rev_id)?; + writeln!(f, " Prog IF: 0b{:b}", self.prog_if)?; + writeln!(f, " Header type: 0x{:X}", self.header_type)?; write!(f, " Supported functions: 0")?; for (i, b) in self.supported_fns.iter().enumerate().skip(1) { if *b { @@ -110,9 +115,11 @@ fn check_device(bus: u8, device: u8) -> Option { return None; } - let class = unsafe { pci_config_read(bus, device, 0, 0x8) }; - let class = (class >> 16) & 0x0000FFFF; - let pci_class = PciFullClass::from_u16(class as u16); + let reg2 = unsafe { pci_config_read(bus, device, 0, 0x8) }; + let rev_id = (reg2 & 0x000000FF) as u8; + let prog_if = ((reg2 >> 8) & 0x000000FF) as u8; + let class = ((reg2 >> 16) & 0x0000FFFF) as u16; + let pci_class = PciFullClass::from_u16(class); let header_type = get_header_type(bus, device, function); let mut supported_fns = [true, false, false, false, false, false, false, false]; @@ -148,6 +155,8 @@ fn check_device(bus: u8, device: u8) -> Option { }, // vendor_id, full_class: pci_class, + prog_if, + rev_id, header_type, bars, supported_fns,