PCI mmio从lspci分配不同的地址

时间:2021-03-21 13:55:32

标签: kernel linux-device-driver pci

我正在研究以太网 NIC 的 PCI 驱动程序。

这是我的代码

int rc = pcim_enable_device(pdev);
... 
abc = ffs(pci_select_bars(pdev, IORESOURCE_MEM))-1;

if (pci_resource_len(pdev, abc) < 256) {
    dev_err(&pdev->dev, "Invalid PCI region size(s), aborting\n");
    return -ENODEV;
}

rc = pcim_iomap_regions(pdev, BIT(abc), "modinfo");

void *mmio_addr = pcim_iomap_table(pdev)[abc];
printk("%x\n", mmio_addr);

在上面的行中,mmio_addr 不是 lspci -vvv 命令中显示的我相信 pcim_iomap_regions() 给出了 MMIO 的地址,可以在 dmesg 的 lspci 命令输出中看到我是得到 0x8006d000 但我的 MMIO 区域 2 和 3 是 c0404000 & c0400000。这是为什么?我的 PCI 以太网驱动程序实际上是我的模块,如以太网 PCI 的内核驱动程序所述。

0 个答案:

没有答案
相关问题