2 * Dump PCI device headers
12 static void dump_pci_device(struct backend
*be
, pciaddr_t a
, uint8_t hdrtype
)
14 unsigned int bus
= pci_bus(a
);
15 unsigned int dev
= pci_dev(a
);
16 unsigned int func
= pci_func(a
);
23 printf("Scanning PCI bus... %02x:%02x.%x\r", bus
, dev
, func
);
25 /* Assume doing a full device dump is actually safe... */
26 for (i
= 0; i
< sizeof data
; i
+= 4)
27 *(uint32_t *)(data
+i
) = pci_readl(a
+ i
);
29 snprintf(filename
, sizeof filename
, "pci/%02x:%02x.%x",
31 cpio_writefile(be
, filename
, data
, sizeof data
);
34 void dump_pci(struct backend
*be
)
37 unsigned int nbus
, ndev
, nfunc
, maxfunc
;
42 cfgtype
= pci_set_config_type(PCI_CFG_AUTO
);
43 if (cfgtype
== PCI_CFG_NONE
)
46 cpio_mkdir(be
, "pci");
48 for (nbus
= 0; nbus
< MAX_PCI_BUSES
; nbus
++) {
49 for (ndev
= 0; ndev
< MAX_PCI_DEVICES
; ndev
++) {
50 maxfunc
= 1; /* Assume a single-function device */
52 for (nfunc
= 0; nfunc
< maxfunc
; nfunc
++) {
53 a
= pci_mkaddr(nbus
, ndev
, nfunc
, 0);
56 if (did
== 0xffffffff || did
== 0xffff0000 ||
57 did
== 0x0000ffff || did
== 0x00000000)
60 hdrtype
= pci_readb(a
+ 0x0e);
62 maxfunc
= MAX_PCI_FUNC
; /* Multifunction device */
64 dump_pci_device(be
, a
, hdrtype
);
69 printf("Scanning PCI bus... done. \n");