pcie接口相对来讲还是打交道比较多的接口。无论是intel还是xilinx的ip也都接触到过。谈及pcie,就不可避免地涉及bar空间。当然厂商的ip还是包装的可以的,我们直接配置就行。但在使用时关于bar空间的配置,往往牵涉到这么几个概念:
io/mem
prefetchable
32位/64位
早前这东西不假思索,抄抄之前的设计照着配置就好了。乍看pcieext-cocotb中的实现,不禁思索,这些参数软件是如何识别的呢?像下面ep常涉及的配置空间:
配置空间中所涉及到的只有6个base address registers,似乎并无很明显的指示~ 》协议解读
先来看看spec中关于base address registers的定义:
关于如何区分是mem空间还是io空间,spec中定义了:
bit0:为1表示memory space,为0则表示i/o space。
(i/o空间仅支持32位,且现在pcie设备里也较少使用,这里不再展开,感兴趣小伙伴可自行翻看spec)
对于memory类型空间,bit[3:0]均为只读。在bit[2:1]中定义了memory类型空间
可见,当bit[2]为1时表示64位地址空间,否则为32位地址空间。
而当bit[3]为1时,表示该bar空间为prefetchable,为0则不是非prefetchable。
看到这里,上面的疑问也基本可以解答了。在cocotbext-pcie中的配置方式也有所验证:
》prefetchable
关于prefetchable这个属性,一直也没有非常清晰的认识。按照spec中的定义:
a function is permitted to mark a range as prefetchable if there are no side effects on reads, the function returns all bytes on reads regardless of the byte enables, and host bridges can merge processor writes into this range without causing errors.
any device that has a range that behaves like normal memory should mark the range as prefetchable. a linear frame buffer in a graphics device is an example of a range that should be marked prefetchable.
一般而言,在pcie设备里,bar空间基本用于实现寄存器读写,是基本符合上面所描述的情况的,所以配置成prefetchable还是有必要的。而且在spec中,也提到了: pci express adapters with memory space bars that request a large amount of non-prefetchable memory space(e.g., over 64 mb) may cause shortages of that space on certain scalable platforms, since many platforms support a total of only 1 gb or less of non-prefetchable memory space.this may limit the number of such adapters that
can be supported on those platforms. for this reason, it is especially encouraged for bars requesting large amounts of memory space to have their prefetchable bit set, since prefetchable memory space is more bountiful on most scalable platforms.
on pci express systems that meet the criteria enumerated below, setting the prefetchable bit in a candidate bar will still permit correct operation even if the bar’s range includes some locations that have read side-effects or cannot tolerate write merging. this is primarily due to the fact that pci express memory reads always contain an
explicit length, and pci express switches never prefetch or do byte merging. generally only 64-bit bars are good candidates, since only legacy endpoints are permitted to set the prefetchable bit in 32-bit bars, and most scalable platforms map all 32-bit memory bars into non-prefetchable memory space regardless of the prefetchable bit value.
这里贴上spec中的原话,总结起来:尽可能配置成64 bit prefetchable.
》bar空间的初始化
对于bar空间,其核心除了上述的属性检测外另一重点便是为bar空间分配指定大小的地址空间。
对于base address registers,bar空间的大小只能配置成2的n次方。以32位memory 空间为例,其可配置的范围是16byte~2gb(低四bit用于设置bar空间属性)。
对于指定大小所占用的位,其只读并且始终为0,若没有被使用,则其会返回全0。在初始化时软件可以向bar空间写全1然后回读。
对于读会的数据,将低4bit清零,然后所有bit取反后加1即为对应的bar空间大小。分配好地址空间好将base地址写回到base address registers中~
南非航空将出售A340飞机来改善其财务状况
亚信电子最新TSN/EtherCAT与IO-Link技术整体解决方案
单片机c语言的自动变量和静态变量解析
单片机方案开发注意事项及如何挑选PIC单片机进行学习
角速度传感器在扫地机器人避障上的应用
PCIe—Bar空间是怎么生效的
在曲阜市场中,有哪些OLED品牌?
生鲜配送柜如何使用4G工业路由器实现无接触配送
区块链未来将如何改变招聘方式
从历史看64位Linux的应用
KVM延长器、切换器配合使用机房管理远程管控方案
基于可变步长的多通道噪声主动控制方案
一个个原厂官网搜资料要跪了?世强元件电商新版本 解决工程师困扰
美国无人飞行器Parrot AR.Drone2.0 GPS拆解
恩智浦目前唯一采用5nm的汽车芯片厂商,计划明年交付首款样品
fireflyNCC S1烧写工具--常见问题简介
一骑绝尘领先行业 西部数据发布全新企业级存储解决方案新品
Xilinx SDK的系统性能工具确实能帮助你完善你的系统性能
路由器安全性低和开放的修护措施
买手机一定不要盲目跟风,这6部可入手(小米MIX、华为Mate9 Pro、魅族Pro 6Plus)