PCI 总线操作一 :总线command
PCI协议中定义了一组特殊的总线控制Pin---C/BE[3::0]#。这组pin属于功能复用pin,在数据传输周期,对应的bit指定AD(4 bytes)线上的对应byte;在寻址周期,当master需要申请访问总线上的target的时候,总线command就被译码到C/BE[3::0]#线上。
下面是pci协议定义的pci 总线command译码和类型说明。
C/BE[3::0]# | Command Type |
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 | Interrupt Acknowledge Special Cycle I/O Read I/O Write Reserved Reserved Memory Read Memory Write Reserved Reserved Configuration Read Configuration Write Memory Read Multiple Dual Address Cycle Memory Read Line Memory Write and Invalidate
|
总线command详细说明如下:
Interrupt ACK: 表示到系统中断控制器的信号。
Special cycle : 提供了PCI总线上一个简单的信息广播机制。主要用作边带传输时候。
IO read : 用来读取设备映射到IO地址空间的数据。AD线上表示数据地址(1byte)。
IO Write : 用来写入数据到设备映射的IO地址空间。AD线上表示数据地址(1byte)。
Memory Read: 用来读取设备映射到memory地址空间的数据。
Memory Read: 用来写入数据到设备映射的memory地址空间去。
Configuration Read: 用来读取设备的配置空间。配置周期,设备的IDSEL被声告、且AD[1:0]为00,则表示该设备被选中。 在配置周期的寻址阶段,AD[7:2]表示定址到配置空间64Dwordregister中的一个,其中BE[]选中对应的DWORD中的某特byte。AD线上的31:11则不会被总线关注。
Configuration Write: 用来传输数据到设备的配置空间去。原理大概和ConfigurationRead差不多的。
Memory Write and Invalidate: 与memory write类似,但是会和Cache有关联。Master会在单个的PCI传输中,将所有的byte写入寻址的cacheline中,除非被target中断了。所以在该command中的数据阶段BE#必须全部使能。在write-backcache中该command能够invalidate ‘dirty(cache中被改过的数据)’line ,而不需要真正的完成一个write-back周期,以此来节约数据访问时间,优化性能。
Command使用规则
1、 所有的设备都要响应configurationcommand,host bridge除外。而其他command就没这个规定了。
2、 与系统内存的大块数据传输,master最好推荐使用memorywrite and invalidate, memory read line和memory read multiple。而这种情况下使用memoryread 或者memory write会牺牲性能的。
3、 Memory read的command:
Memory Read command | When reading data in an address range that has side-effects (not prefetchable) or a reading a single DWORD.
|
Memory Read Line command | Reading more than a DWORD up to the next cacheline boundary in a prefetchable address space. 限制在cacheline定义的大小内。 |
Memory Read Multiple command | Reading a block which crosses a cacheline boundary (stay one cacheline ahead of the master if possible) of data in a prefetchable address range.可能要超过cacheline的大小 |
由于host bridge和其他的p2p bridge处理command 不同,所有不同的comand会对系统性能产生不同的效果。比如master要从PCI2PCI bridge的另一边的target中读得三个Dword。对于memory read ,master读完第一个DWORD之后,不会从该target中去读第二个DWORD,因为下一个Dword对应的byte enable没有获得,因此只能在读到一个DWORD之后终止传输。如果master使用memory read line 命令或者memory read multiple命令,数据是可预读取的,Bridge可以获得比master实际需要的更多的数据。例如memory read line command可以使bridge轻易的从targe中获得burst data,数据大小可以达到cacheline定义的最大值