Adds PCI config dump helper
You can probably do this from userspace too, via devarch's PIO hooks.
diff --git a/kern/arch/x86/pci.c b/kern/arch/x86/pci.c
index 6847516..1aa5435 100644
--- a/kern/arch/x86/pci.c
+++ b/kern/arch/x86/pci.c
@@ -552,3 +552,13 @@
}
return -1;
}
+
+void pci_dump_config(struct pci_device *pcidev, size_t len)
+{
+ if (len > 256)
+ printk("FYI, printing more than 256 bytes of PCI space\n");
+ printk("PCI Config space for %02x:%02x:%02x\n---------------------\n",
+ pcidev->bus, pcidev->dev, pcidev->func);
+ for (int i = 0; i < len; i += 4)
+ printk("0x%03x | %08x\n", i, pcidev_read32(pcidev, i));
+}
diff --git a/kern/arch/x86/pci.h b/kern/arch/x86/pci.h
index 3aaf051..fa1d4df 100644
--- a/kern/arch/x86/pci.h
+++ b/kern/arch/x86/pci.h
@@ -413,6 +413,7 @@
uint16_t pci_get_device(struct pci_device *pcidev);
uint16_t pci_get_subvendor(struct pci_device *pcidev);
uint16_t pci_get_subdevice(struct pci_device *pcidev);
+void pci_dump_config(struct pci_device *pcidev, size_t len);
/* MSI functions, msi.c */
int pci_msi_enable(struct pci_device *p, uint64_t vec);