【问题标题】:PCI device (64bits) configuration Memory accessPCI 设备(64 位)配置 内存访问
【发布时间】:2016-04-22 07:03:32
【问题描述】:

我正在使用通过 PCI 连接的 64 位 FPGA。我正在使用下一个功能:

unsigned long pci_resource_[start|len|end|flags](struct pci_dev *pdev, int bar); 

但是,我没有得到正确的结果,因为这些函数适用于 32 位 PCI 设备。

还有其他可以使用 64 位的函数吗?你可以看到我从 lspci 得到的信息

0002:01:00.0 Memory controller: Xilinx Corporation Device 7022
    Subsystem: Xilinx Corporation Device 0007
    Flags: bus master, fast devsel, latency 0
    Memory at <ignored> (64-bit, prefetchable)
    Memory at c40000000 (64-bit, prefetchable) [size=64K]
    Capabilities: [40] Power Management version 3
    Capabilities: [48] MSI: Enable- Count=1/8 Maskable- 64bit+
    Capabilities: [60] Express Endpoint, MSI 00
    Capabilities: [100] Device Serial Number 00-00-00-00-00-00-00-00

【问题讨论】:

    标签: linux linux-device-driver pci


    【解决方案1】:

    我不确定您说的是哪个 Linux 版本。但是在当前的Linux树(4.5)中,pci_resource_start被定义为:

    #define pci_resource_start(dev, bar)    ((dev)->resource[(bar)].start)
    

    嵌入结构是

    /* Linux/include/linux/pci.h */
    struct resource resource[DEVICE_COUNT_RESOURCE]; /* I/O and memory regions + expansion ROMs */
    
    /* Linux/include/linux/ioport.h */
    struct resource {
        resource_size_t start;
        resource_size_t end;
        const char *name;
        unsigned long flags;
        struct resource *parent, *sibling, *child;
    };
    
    /* Linux/include/linux/types.h */
    typedef phys_addr_t resource_size_t;
    
    /* Linux/include/linux/types.h */
    #ifdef CONFIG_PHYS_ADDR_T_64BIT
    typedef u64 phys_addr_t;
    #else
    typedef u32 phys_addr_t;
    #endif
    

    因此,如果您使用的是 64 位系统并且 Linux 是使用 CONFIG_PHYS_ADDR_T_64BIT 编译的,那么您很好。

    【讨论】:

    • 非常感谢您的回答。我正在使用内核版本 3.16。如果我有接下来的两个 PCI 设备会发生什么?一个具有 32 位内存,另一个具有 64 位内存:内存位于 c20100000(32 位,可预取)[大小=1M] 内存位于 c40000000(64 位,可预取)[大小=64K]
    • @manolotunez 我没有使用 32 位设备的经验。实际上,我很惊讶地看到 32 位资源映射超过 4GB。
    猜你喜欢
    • 2012-07-06
    • 2012-12-01
    • 2021-07-16
    • 1970-01-01
    • 2010-09-07
    • 2013-06-06
    • 2014-12-17
    • 2011-03-01
    • 1970-01-01
    相关资源
    最近更新 更多