识别与PCI区域相关的`struct resource`

时间:2014-01-02 10:18:55

标签: linux-kernel pci

我正在迭代iomem_resource个孩子:

struct resource *p;
for (p = iomem_resource.child; p ; p = p->sibling)
    printk(KERN_NOTICE ":: %s %lx %lx-%lx", p->name, p->flags, p->start, p->end);

输出如下:

reserved 80000200 0-fff
System RAM 80000200 1000-9fbff
reserved 80000200 9fc00-9ffff
Video ROM 80002200 c0000-c7fff
Adapter ROM 80002200 e2000-eebff
reserved 80000200 f0000-fffff
System RAM 80000200 100000-3ffeffff
ACPI Tables 80000200 3fff0000-3fffffff
0000:00:02.0 21208 e0000000-e7ffffff
0000:00:03.0 20200 f0000000-f001ffff
0000:00:04.0 20200 f0400000-f07fffff
0000:00:04.0 21208 f0800000-f0803fff
0000:00:06.0 20200 f0804000-f0804fff
0000:00:0d.0 20200 f0806000-f0807fff
IOAPIC 0 80000200 fec00000-fec003ff
Local APIC 80000200 fee00000-fee00fff
reserved 200 fffc0000-ffffffff

我想识别PCI区域(如0000:00:02.0等)。据我所知,flags无济于事。

kernel/resource.c中,他们只是按名称识别“系统RAM”区域。 PCI区域的适当方法是什么?

1 个答案:

答案 0 :(得分:0)

识别PCI地址区域的正确方法似乎是直接迭代pci资源,而不是遍历iomem_resource

struct pci_dev *dev = 0;
struct resource *p;
for_each_pci_dev(dev)
{
    int i;
    for (i = 0; i < DEVICE_COUNT_RESOURCE; ++i)
        if ((p=dev->resource + i))
            printk(KERN_NOTICE "%lx-%lx %x", p->start, p->end, p->flags);
      // etc...
}