From f5f68bc2df75f683f6eb9224c3c5202d18f6041f Mon Sep 17 00:00:00 2001 From: Able Date: Tue, 17 Sep 2024 17:23:32 -0500 Subject: [PATCH] my changes and then boom --- sysdata/libraries/pci/src/lib.hb | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/sysdata/libraries/pci/src/lib.hb b/sysdata/libraries/pci/src/lib.hb index 7788ec648..aa911acde 100644 --- a/sysdata/libraries/pci/src/lib.hb +++ b/sysdata/libraries/pci/src/lib.hb @@ -22,7 +22,12 @@ get_ids := fn(bus: u8, device: u8, function: u8): PCI_ID { } PciDeviceInfo := struct { - pci_id: PCI_ID, + header_type: u8, + device: u8, + bus: u8, + device_id: PCI_ID, + class: u16, + rev_id: u8, } calculate_address := fn(bus: u8, device: u8, function: u8, offset: u8): int { @@ -34,6 +39,14 @@ calculate_address := fn(bus: u8, device: u8, function: u8, offset: u8): int { return address } +get_header_type := fn(bus: u8, device: u8, function: u8): u8 { + res := config_read32(bus, device, function, 0xC) + ret := res >> 16 + ret &= 0xFF + + return ret +} + check_device := fn(bus: u8, device: u8): PciDeviceInfo { pci_id := get_ids(bus, device, 0) @@ -42,16 +55,15 @@ check_device := fn(bus: u8, device: u8): PciDeviceInfo { } else { stn.log.info(":)\0") } - address := calculate_address(bus, device, 0, 0x8) reg2 := config_read32(bus, device, 0, 0x8) + class := reg2 >> 16 & 0xFFFF - b := "\0\0\0\0\0\0\0" - string.display_int(class, b) - stn.log.info(b) + header_type := get_header_type(bus, device, 0) - return PciDeviceInfo.(pci_id) + rev_id := reg2 & 0xFF + return PciDeviceInfo.(header_type, device, bus, pci_id, class, rev_id) } find_device := fn(vendor_id: int, device_id: int, pci_address: PCIAddress): PCI_ID {