如上图所示:所有的根总线都链接在pci_root_buses链表中. Pci_bus ->device链表链接着该总线下的所有设备.而pci_bus->children链表链接着它的下层总线. 对于pci_dev来说,pci_dev->bus指向它所属的pci_bus. Pci_dev->bus_list链接在它所属bus的device链表上.此外,所有pci设备都链接在pci_device链表中. 三:...
pci_lock_config(flags); \ res = bus->ops->read(bus, devfn, pos, len, &data); \ *value = (type)data; \ pci_unlock_config(flags); \ return res; \ } 而其中的 pci_lock_config(flags); 实现为: #ifdef CONFIG_PCI_LOCKLESS_CONFIG # define pci_lock_config(f) do { (void)(f);...
pci_scan_device(struct pci_bus *bus, int devfn) { struct pci_dev *dev; u32 l; u8 hdr_type; int delay = 1; //--读PCI设备制造商的ID-- if (pci_bus_read_config_dword(bus, devfn, PCI_VENDOR_ID, &l)) return NULL; /* some broken boards return 0 or ~0 if a slot is empty...
void pci_read_config_byte(unsigned char bus, unsigned char dev, unsigned char offset, unsigned char *val) { unsigned char fun = 0; outl((0x80000000 | ((bus)<<16) |((dev)<<11) | ((fun)<<8) | (offset & ~0x3)), PCI_CFG_CTRL); *val = inl(PCI_CFG_DATA) >> ((offset &...
pci_bus_read_config_byte(bus, devfn,pos, &pos);//目前ttl = PCI_FIND_CAP_TTL =48;while((*ttl)--) {if(pos<0x40)break;pos&= ~3; pci_bus_read_config_word(bus, devfn,pos, &ent); id = ent &0xff;if(id ==0xff)break;if(id == cap) //获取ID为PCI_CAP_ID_EXP的capatility...
intpci_write_config_dword(struct pci_dev *dev,intwhere, u32 val); 上面这组读写接口实际上会调用下面这组接口,当驱动不能访问pci_dev的时候也可以直接调用下面这组接口 1 2 3 4 5 6 intpci_bus_read_config_byte(struct pci_bus *bus,unsignedintdevfn,intwhere, u8 *val); ...
intpci_read_config_byte(struct pci_dev*dev,int where,u8*val)intpci_read_config_word(struct pci_dev*dev,int where,u16*val)intpci_read_config_dword(struct pci_dev*dev,int where,u32*val)intpci_write_config_byte(struct pci_dev*dev,int where,u8 val)intpci_write_config_word(struct pci_...
0xcfc #define PCI_CFG_CTRL 0xcf8 void pci_read_config_byte(unsigned char bus, unsigned char dev, unsigned char offset, unsigned char *val){ unsigned char fun = 0;outl((0x80000000 | ((bus)<<16) |((dev)<<11) | ((fun)<<8) | (offset & ~0x3)), PCI_CFG_CTRL);
每次要访问PCI配置空间时,先设置CONFIG_ADDRESS寄存器,这时CONFIG_DATA存储器的内容就对应着该PCI配置空间中的相应的寄存器。 访问PCI配置空间方法二 第二种访问配置空间的方法是通过HalGetBusData和HalSetBusData两个内核函数。这两个函数将方法进行了封装,不需要程序员对PCI空间进行直接读取。
Feel free to use these functions instead of the above in case the driver does not have access to a struct pci_dev at any paticular moment in time: int pci_bus_read_config_byte (struct pci_bus *bus, unsigned int devfn, int where, u8 *val); int pci_bus_read_config_word (struct ...