4 int pci_probe(pci_probe_fn_t probe)
12 for (bus = 0; bus < 0x100; bus++)
13 for (dev = 0; dev < 0x20; dev++)
14 if (pci_read32(bus, dev, 0, 0) != 0xFFFFFFFF)
15 for (fn = 0; fn < 8; fn++)
19 if (pci_read32(bus, dev, fn, 0) == 0xFFFFFFFF)
22 if ((fn != 0) && !(pci_read8(bus, dev, 0, 0x0E) & 0x80))
28 pdev.vid = pci_read16(bus, dev, fn, 0);
29 pdev.did = pci_read16(bus, dev, fn, 2);
31 for (bar = 0; bar < 6; bar++)
33 unsigned long bardat = pci_read32(bus, dev, fn, 0x10 + bar*4);
36 pdev.bars[bar].type = PCI_BAR_NONE;
41 pdev.bars[bar].type = PCI_BAR_IO;
42 pdev.bars[bar].addr = bardat & ~0x3;
44 pdev.bars[bar].prefetchable = (bardat >> 3) & 1;
45 switch ((bardat >> 1) & 0x3)
48 pdev.bars[bar].type = PCI_BAR_MEMORY32;
49 pdev.bars[bar].addr = bardat & ~0xF;
52 pdev.bars[bar].type = PCI_BAR_MEMORY64;
54 pdev.bars[bar].type = PCI_BAR_NONE;
57 pdev.bars[bar].type = PCI_BAR_NONE;
63 devsfound += probe(&pdev);
69 static int _enumfn(pci_dev_t *pdev)
73 outputf("Found device: %02x:%02x.%1x: %04X:%04X",
74 pdev->bus, pdev->dev, pdev->fn,
75 pdev->vid, pdev->did);
76 for (bar = 0; bar < 6; bar++)
78 switch (pdev->bars[bar].type)
81 outputf(" BAR %d: I/O, Addr %04x", bar, pdev->bars[bar].addr);
83 case PCI_BAR_MEMORY32:
84 outputf(" BAR %d: Mem32, Addr %04x", bar, pdev->bars[bar].addr);
86 case PCI_BAR_MEMORY64:
87 outputf(" BAR %d: Mem64, Addr %04x", bar, pdev->bars[bar].addr);