'cat / proc / bus / pci / devices'的前几个字段是可以理解的。
字段1 - BusDevFunc
字段2 - 供应商ID +设备ID
字段3 - 中断线
字段4 - BAR 0
其后BAR寄存器(0 - 5)之后。
打印出BAR寄存器后,其他字段是什么?具体来说,打印出哪个PCI配置空间寄存器(偏移)?
答案 0 :(得分:15)
这是内核中的相应代码:
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;
}
在IRQ之后,它似乎是起始地址与前6个资源区域的标志相结合,然后是这些资源区域的长度,后跟已声明该设备的驱动程序的名称。