zoukankan      html  css  js  c++  java
  • [译]6.1. Data Structures Featured in This Chapter 本章涉及到的数据结构

    目录:http://www.cnblogs.com/WuCountry/archive/2008/11/15/1333960.html
     
    [不提供插图,读者最好从网上下载源书]

    6.1. Data Structures Featured in This Chapter 本章涉及到的数据结构
    Here are a few key data structure types used by the PCI layer. There are many others, but the following ones are all we need to know for our overview in this book. The first one is defined in include/linux/mod_devicetable.h, and the other two are defined in include/linux/pci.h.
    这里有一些PCI层会使用到的关键数据结构类型。有很多其它的数据类型,但下面的这些是本书中一直提及到的。第一个是定义在include/linux/mod_devicetable.h中,其它的两个定义在include/linux/pci.h中。

    pci_device_id

    Device identifier. This is not a local ID used by Linux, but an ID defined accordingly to the PCI standard. The later section "Registering a PCI NIC Device Driver" shows the ID's definition, and the later section "Example of PCI NIC Driver Registration" presents an example.
    设备标识。这不是一个本地的由Linux所使用的ID,而是一个根据PCI标准定义的ID。在后面的一节“注册PCI NIC设备驱动”中会展示这个ID的定义,其后的“一个PCI NIC设备注册的例子”一节是会有一个例子。

    pci_dev

    Each PCI device is assigned a pci_dev instance, just as network devices are assigned net_device instances. This is the structure used by the kernel to refer to a PCI device.
    每一个PCI设备就是一个指定的pci_dev实例,只有网络设备才会指定为net_device实例。这个数据结构就是内核用于引用到一个PCI设备。

    pci_driver

    Defines the interface between the PCI layer and the device drivers. This structure consists mostly of function pointers. All PCI devices use it. See the later section "Example of PCI NIC Driver Registration" for its definition and an example of its initialization.
    用于在PCI层和设备驱动之间定义接口。这个结构包括了大多数函数指针。所有的CPI设备都使用它。在后面的一节中有一个它的定义和初始化的示例。


    PCI device drivers are defined by an instance of a pci_driver structure. Here is a description of its main fields, with special attention paid to the case of NIC devices. The function pointers are initialized by the device driver to point to appropriate functions within that driver.
    PCI设备驱动由一个pci_driver结构的实例所定义。这里对于它的主要成员有些说明,重点关注的是NIC设备这种情况。它的函数指针由设备驱动指向相关驱动的适当函数。

    char *name

    Name of the driver.
    设备名。


    const struct pci_device_id *id_table

    Vector of IDs the kernel will use to associate devices to this driver. The section "Example of PCI NIC Driver Registration" shows an example.
    一个内核会用于关联到设备驱动的向量ID。


    int (*probe)(struct pci_dev *dev, const struct pci_device_id *id)

    Function invoked by the PCI layer when it finds a match between a device ID for which it is seeking a driver and the id_table mentioned previously. This function should enable the hardware, allocate the net_device structure, and initialize and register the new device.[*] In this function, the driver also allocates any additional data structures (e.g., buffer rings used during transmission or reception) that it may need to work properly.
    当PCI设备在设备ID中查找一个匹配的设备时,就调由PCI层调用这个函数。这个ID用于查找前面提到过的驱动和id_table。这个函数应该让硬件使能,分配net_device结构,并初始化和注册新的设备。在这个函数中,驱动同样会分配一些让它正常工作的额外的数据结构(例如,用于数据传输和接收的缓存区)。

    [*] NIC registration is covered in Chapter 8.

    void (*remove)(struct pci_dev *dev)

    Function invoked by the PCI layer when the driver is unregistered from the kernel or when a hot-pluggable device is removed. It is the counterpart of probe and is used to clean up any data structure and state.
    当驱动从内核中移出,或者热插拨设备从系统中移走时,PCI层会调用这个函数。它是与探测器相对的功能,用于清除数据结构和状态。

    Network devices use this function to release the allocated I/O ports and I/O memory, to unregister the device, and to free the net_device data structure and any other auxiliary data structure that could have been allocated by the device driver, usually in its probe function.
    网络设备用这个函数来释放已经分配的IO端口和IO内存,反注册设备,并释放net_device数据结构和其它的可能已经分配给设备驱动的辅助数据结构,通常是它的探测函数。

    int (*suspend)(struct pci_dev *dev, pm_message_t state)

    int (*resume)(struct pci_dev *dev)

    Functions invoked by the PCI layer when the system goes into suspend mode and when it is resumed, respectively. See the later section "Power Management and Wake-on-LAN."
    这两个函数是系统进入挂起模式和从该模式中恢复时由PCI层调用的。


    int (*enable_wake)(struct pci_dev *dev, u32 state, int enable)

    With this function, a driver can enable or disable the capability of the device to wake the system up by generating specific Power Management Event signals. See the later section "Power Management and Wake-on-LAN."
    利用这两个函数,一个驱动可以使能或者去使能设备生成特殊的电源管理事件来唤醒系统的能力。

    struct pci_dynids dynids

    Dynamic IDs. See the following section.
    动态ID。

    See the later section "Example of PCI NIC Driver Registration" for an example of initialization of a pci_driver instance.

    ================================
      /\_/\                        
     (=^o^=)  Wu.Country@侠缘      
     (~)@(~)  一辈子,用心做一件事!
    --------------------------------
      学而不思则罔,思而不学则怠!  
    ================================
  • 相关阅读:
    二维动态规划(2)
    细节是否真的打败爱情,十年后你还会爱我吗?
    C++的四种cast操作符的区别类型转换
    纯虚函数
    二维动态规划
    1,2,...n n个数m个丢失,找出丢失的数
    虚拟内存管理技术
    C++ 面试题总结
    【转】图的邻接链表 adjacent list of graph
    CIOCPServer的数据结构定义及内存池方案
  • 原文地址:https://www.cnblogs.com/WuCountry/p/1401818.html
Copyright © 2011-2022 走看看