pcie的pci_scan_bus

pcie的资源主要有三种,分别是io/mem/bus.再调用pci_create_root_bus的时候,这三种资源要提前准备好
[   13.419865] pci_bus 0002:80: root bus resource [mem 0xa8800000-0xaffeffff window]
[   13.419865] pci_bus 0002:80: root bus resource [mem 0xa8800000-0xaffeffff window]
[   13.434941] pci_bus 0002:80: root bus resource [io  0x0000-0xffff window]
[   13.434941] pci_bus 0002:80: root bus resource [io  0x0000-0xffff window]
[   13.448617] pci_bus 0002:80: root bus resource [bus 80-87]
[   13.448617] pci_bus 0002:80: root bus resource [bus 80-87]

例如在pci_scan_bus中首先添加到resources中
struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops,
                    void *sysdata)
{
    LIST_HEAD(resources);
    struct pci_bus *b;

    pci_add_resource(&resources, &ioport_resource);
    pci_add_resource(&resources, &iomem_resource);
    pci_add_resource(&resources, &busn_resource);
    b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources);
    if (b) {
        pci_scan_child_bus(b);
    } else {
        pci_free_resource_list(&resources);
    }
    return b;
}
重点看一下资源是如何添加到resources 中
void pci_add_resource(struct list_head *resources, struct resource *res)
{
    pci_add_resource_offset(resources, res, 0);
}
void pci_add_resource_offset(struct list_head *resources, struct resource *res,
                 resource_size_t offset)
{
    struct resource_entry *entry;

    entry = resource_list_create_entry(res, 0);
    if (!entry) {
        printk(KERN_ERR "PCI: can't add host bridge window %pR\n", res);
        return;
    }

    entry->offset = offset;
    resource_list_add_tail(entry, resources);
}
在pci_add_resource_offset中首先通过resource_list_create_entry 申请memory,并给resource_entry 中的__res 赋值
struct resource_entry *resource_list_create_entry(struct resource *res,
                          size_t extra_size)
{
    struct resource_entry *entry;

    entry = kzalloc(sizeof(*entry) + extra_size, GFP_KERNEL);
    if (entry) {
        INIT_LIST_HEAD(&entry->node);
        entry->res = res ? res : &entry->__res;
    }

    return entry;
}
一般res 不为null。
在pci_add_resource_offset 得到entry中再给offset赋值0.最后将resources 插入到resources 列表中.
回到pci_scan_bus 中将io/mem/bus 资源插入到resources 这个list中后,然后将可以通过pci_create_root_bus来创建root bus后,就可以通过pci_scan_child_bus来scan 子总线.
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Vivado是Xilinx公司推出的综合开发环境,用于实现FPGA芯片的设计。其中,Vivado PCIe cfg_fc_ph指的是PCIe Endpoint的配置。PCIe(Peripheral Component Interconnect Express,外设组件互连扩展)是一种高速的、低延迟的计算机总线,特别适用于连接外部设备和处理器之间的高速数据传输。而PCIe Endpoint是PCIe总线上接口的一种,其附加在计算机外围的设备上,可作为计算机系统的内部或外部设备使用。 PCIe Endpoint在Vivado中的配置是通过cfg_fc_ph寄存器进行的。该寄存器用于控制PCIe传输,其中,cfg表示该寄存器用于配置Endpoint设备,fc表示该寄存器用于流控方式的选择,ph表示该寄存器是PHY在物理层面生成和检测的传输的标志。具体来说,cfg_fc_ph寄存器主要包括以下配置信息: 1. PCIe Endpoint设备的ID信息,包括Vendor ID(Vid)、Device ID(Did)等; 2. 物理层面的传输控制信息,包括不同的流控方式(如成功传输Acknowledge、端到端流控等); 3. 数据传输和传输层面的配置信息,包括传输协议、数据立即传输等。 通过设置cfg_fc_ph寄存器中的这些信息,可以实现对PCIe传输的控制和配置,确保数据传输的准确性和高效性。而在Vivado中,可以通过IP核来创建和配置PCIe Endpoint设备,以实现与计算机系统的高速数据传输。同时,Vivado也提供了强大的仿真和调试功能,以支持对PCIe传输的可靠性验证和故障排查,以确保PCIe设备的稳定性和可靠性。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值