Cc: Andrew Jones <[email protected]>
Signed-off-by: Alexander Gordeev <[email protected]>
---
lib/pci-host-generic.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/lib/pci-host-generic.c b/lib/pci-host-generic.c
index 2d218a4..50cf09a 100644
--- a/lib/pci-host-generic.c
+++ b/lib/pci-host-generic.c
@@ -352,6 +352,35 @@ static phys_addr_t pci_alloc_res(struct pci_host_bridge
*host,
return addr;
}
+static void pci_dev_print(void *conf)
+{
+ u16 vendor_id = pci_config_readw(conf, PCI_VENDOR_ID);
+ u16 device_id = pci_config_readw(conf, PCI_DEVICE_ID);
+ u8 header = pci_config_readb(conf, PCI_HEADER_TYPE);
+ u8 progif = pci_config_readb(conf, PCI_CLASS_PROG);
+ u8 subcl = pci_config_readb(conf, PCI_CLASS_DEVICE);
+ u8 class = pci_config_readb(conf, PCI_CLASS_DEVICE + 1);
+
+ printf("conf %p vendor_id %04x device_id %04x type %d "
+ "progif %02x class %02x subcl %02x\n",
+ conf, vendor_id, device_id, header,
+ progif, class, subcl);
+}
+
+static void pci_dev_bar_print(int bar, pci_res_type_t type,
+ phys_addr_t addr, u64 size, bool is64)
+{
+ const char *desc = addr_space_desc[type];
+
+ if (is64) {
+ printf("\tBAR#%d,%d [%-7s %02x-%02x]\n",
+ bar, bar + 1, desc, addr, addr + size - 1);
+ } else {
+ printf("\tBAR#%d [%-7s %02x-%02x]\n",
+ bar, desc, addr, addr + size - 1);
+ }
+}
+
int pci_bus_scan(struct pci *pci)
{
void *conf;
@@ -365,6 +394,8 @@ int pci_bus_scan(struct pci *pci)
int nr_dev = 0;
for_each_pci_dev(pci, dev, conf) {
+ pci_dev_print(conf);
+
/* We are only interested in normal PCI devices */
if (pci_config_readb(conf, PCI_HEADER_TYPE) !=
PCI_HEADER_TYPE_NORMAL)
@@ -375,6 +406,9 @@ int pci_bus_scan(struct pci *pci)
break;
addr = pci_alloc_res(pci->sysdata, type, size);
pci_set_bar(conf, bar, addr, is64);
+
+ pci_dev_bar_print(bar, type, addr, size, is64);
+
if (is64)
bar++;
--
1.8.3.1
_______________________________________________
kvmarm mailing list
[email protected]
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm