linux中PCI子系统补充

不少网络接口卡都是PCI设备,必须与Linux PCI子系统协同工做。新的PCI设备是PCI Express设备.PCI设备都有只读的配置空间,能够经过lspci命令来读取。node

       #lspci -xxx能够查看PCI配置空间内容的十六进制表示linux

       #lspci -xxxx能够查看扩展PCI配置空间内容的十六进制表示网络

固然linux PCI API提供了3个读取配置空间的方法,位于文件对象

drivers/pci/access.c中:接口

pci_read_config_byte, pci_read_config_word, pci_read_config_dwordip

还有写配置的方法ci

pci_write_config_byte, pci_write _config_word, pci_write _config_dwordrem

       在Linux PCI子系统中,PCI设备用pci_device_id对象表示,位于文件it

include/linux/mod_devicetable.h:io

struct pci_device_id {

        __u32 vendor, device;           /* Vendor and device ID or PCI_ANY_ID*/

        __u32 subvendor, subdevice;     /* Subsystem ID's or PCI_ANY_ID */

        __u32 class, class_mask;        /* (class,subclass,prog-if) triplet */

        kernel_ulong_t driver_data;     /* Data private to the driver */

};

       每一个pci设备驱动程序都声明了一个pci_drier对象,位于文件include/linux/pci.h

struct pci_driver {

        struct list_head node;

        const char *name;

        const struct pci_device_id *id_table;   /* must be non-NULL for probe to be called */

        int  (*probe)  (struct pci_dev *dev, const struct pci_device_id *id);   /* New device inserted */

        void (*remove) (struct pci_dev *dev);   /* Device removed (NULL if not a hot-plug capable driver) */

        int  (*suspend) (struct pci_dev *dev, pm_message_t state);      /* Device suspended */

        int  (*suspend_late) (struct pci_dev *dev, pm_message_t state);

        int  (*resume_early) (struct pci_dev *dev);

        int  (*resume) (struct pci_dev *dev);                   /* Device woken up */

        void (*shutdown) (struct pci_dev *dev);

        int (*sriov_configure) (struct pci_dev *dev, int num_vfs); /* PF pdev */

        const struct pci_error_handlers *err_handler;

        const struct attribute_group **groups;

        struct device_driver    driver;

        struct pci_dynids dynids;

}; 

相关文章
相关标签/搜索