15

「cat /proc/bus/pci/devices」の最初のいくつかのフィールドは理解できます。

フィールド 1 - BusDevFunc
フィールド 2 - ベンダー ID + デバイス ID
フィールド 3 - 割り込みライン
フィールド 4 - BAR 0
およびその後の残りの BAR レジスタ (0 - 5)。

BAR レジスターが印刷された後、他のフィールドは何ですか? 具体的には、どの PCI 構成空間レジスター (オフセット) が出力されますか?

4

1 に答える 1

20

This is the corresponding code in the kernel:

static int show_device(struct seq_file *m, void *v)
{
    const struct pci_dev *dev = v;
    const struct pci_driver *drv;
    int i;

    if (dev == NULL)
        return 0;

    drv = pci_dev_driver(dev);
    seq_printf(m, "%02x%02x\t%04x%04x\t%x",
            dev->bus->number,
            dev->devfn,
            dev->vendor,
            dev->device,
            dev->irq);
    /* Here should be 7 and not PCI_NUM_RESOURCES as we need to preserve compatibility */
    for (i=0; i<7; i++) {
        resource_size_t start, end;
        pci_resource_to_user(dev, i, &dev->resource[i], &start, &end);
        seq_printf(m, "\t%16llx",
            (unsigned long long)(start |
            (dev->resource[i].flags & PCI_REGION_FLAG_MASK)));
    }
    for (i=0; i<7; i++) {
        resource_size_t start, end;
        pci_resource_to_user(dev, i, &dev->resource[i], &start, &end);
        seq_printf(m, "\t%16llx",
            dev->resource[i].start < dev->resource[i].end ?
            (unsigned long long)(end - start) + 1 : 0);
    }
    seq_putc(m, '\t');
    if (drv)
        seq_printf(m, "%s", drv->name);
    seq_putc(m, '\n');
    return 0;
}

After the IRQ, it appears to be the start addresses combined with the flags of the first 6 resource regions, followed by the lengths of those resource regions, followed by the name of the driver that has claimed the device.

于 2010-05-08T06:10:25.597 に答える