zoukankan      html  css  js  c++  java
  • MODULE_DEVICE_TABLE【转】

    转自:http://blog.csdn.net/tangkegagalikaiwu/article/details/8444249

    This pci_device_id structure needs to be exported to user space to allow the hotplug and module loading systems know what module works with what hardware devices. The macroMODULE_DEVICE_TABLE accomplishes this. An example is:

    MODULE_DEVICE_TABLE(pci, i810_ids);

    This statement creates a local variable called _ _mod_pci_device_table that points to the list ofstructpci_device_id. Later in the kernel build process, the depmod program searches all modules for the symbol _ _mod_pci_device_table. If that symbol is found, it pulls the data out of the module and adds it to the file/lib/modules/KERNEL_VERSION/modules.pcimap. After depmod completes, all PCI devices that are supported by modules in the kernel are listed, along with their module names, in that file. When the kernel tells the hotplug system that a new PCI device has been found, the hotplug system uses the modules.pcimap file to find the proper driver to load.

    /* Define these values to match your devices */ 

    #define USB_SKEL_VENDOR_ID  0xfff0 
    #define USB_SKEL_PRODUCT_ID 0xfff0 
    /* table of devices that work with this driver */ 
    static struct usb_device_id skel_table [] = { 
         { USB_DEVICE(USB_SKEL_VENDOR_ID, USB_SKEL_PRODUCT_ID) }, 
         { }                    /* Terminating entry */ 
    }; 
    MODULE_DEVICE_TABLE (usb, skel_table); 

        MODULE_DEVICE_TABLE的第一个参数是设备的类型,如果是USB设备,那自然是usb(如果是PCI设备,那将是pci,这两个子系统用同一个宏来注册所支持的设备。这涉及PCI设备的驱动了,在此先不深究)。后面一个参数是设备表,这个设备表的最后一个元素是空的,用于标识结束。代码定义了USB_SKEL_VENDOR_ID是0xfff0,USB_SKEL_PRODUCT_ID是0xfff0,也就是说,当有一个设备接到集线器时,usb子系统就会检查这个设备的vendor ID和product ID,如果它们的值是0xfff0时,那么子系统就会调用这个skeleton模块作为设备的驱动。

    如果有几个驱动文件同时调用了MODULE_DEVICE_TABLE(pci,***),那么hotplug调用哪个哪个驱动?是不是就是调用该宏的本模块,本module,本驱动。应该是的,看上面红色字部分  along with their module names

    类似的有:

      1. MODULE_LICENSE("许可证");  
      2. MODULE_AUTHOR("模块作者");  
      3. MODULE_DESCRIPTION("模块用途描述");  
      4. MODULE_VERSION("代码修订号");  
      5. MODULE_ALIAS("模块的别名");  
      6. MODULE_DEVICE_TABLE("模块支持的设备")
  • 相关阅读:
    session笔记-韩顺平
    带宽
    cookie-韩顺平
    分层模式开发+MVC模式开发--韩顺平雇员数据库管理
    韩顺平-雇员管理系统-学习小结
    常用的PHP数据库操作方法(MYSQL版)
    使用Three.js 基本组件以及流程
    three.js 相机
    多线程的操作与数据绑定
    矩阵-
  • 原文地址:https://www.cnblogs.com/sky-heaven/p/5063527.html
Copyright © 2011-2022 走看看