第一部分是这个xdma.mod.c,这个主要作用就是PCI总线的注册和初始化
static struct pci_driver pci_driver = {
.name = DRV_MODULE_NAME,
.id_table = pci_ids,
.probe = probe_one,
.remove = remove_one,
.err_handler = &xdma_err_handler,
};
static int xdma_mod_init(void)
{
int rv;
pr_info("%s", version);
if (desc_blen_max > XDMA_DESC_BLEN_MAX)
desc_blen_max = XDMA_DESC_BLEN_MAX;
pr_info("desc_blen_max: 0x%x/%u, timeout: h2c %u c2h %u sec.\n",
desc_blen_max, desc_blen_max, h2c_timeout, c2h_timeout);
rv = xdma_cdev_init();
if (rv < 0)
return rv;
return pci_register_driver(&pci_driver);
}然后注册这么一个函数。这里面就可以看这个probe one函数是怎么弄这个中断的。
static int probe_one(struct pci_dev *pdev, const struct pci_device_id *id),const常量
probe函数里面分为很多种函数:
第一种:xpdev = xpdev_alloc(pdev);
第二种:hndl = xdma_device_open(DRV_MODULE_NAME, pdev, &xpdev->user_max,
&xpdev->h2c_channel_max, &xpdev->c2h_channel_max);
第三种:xdev = xdev_find_by_pdev(pdev);
第四种:xpdev->xdev = hndl;
rv = xpdev_create_interfaces(xpdev);
用户中断会进入到这个static irqreturn_t xdma_isr(int irq, void *dev_id)这个函数里面,这个是在libxdma.c里面。