Plx使用手册学习------16 PlxPci_PciBarSpaceRead

该博客详细介绍了如何使用PlxPci_PciBarSpaceRead函数从PLX芯片的PCI BAR空间读取数据。内容涵盖了函数参数的含义、数据访问限制以及直接访问本地总线的优缺点。正确使用此函数前,确保PCI到本地空间的设置正确,以避免不正确的数据或系统崩溃。


Syntax:
 

PLX_STATUS PlxPci_PciBarSpaceRead(
PLX_DEVICE_OBJECT *pDevice,
U8 BarIndex,
U32 offset,
VOID *pBuffer,
U32 ByteCount,
PLX_ACCESS_TYPE AccessType,
BOOLEAN bOffsetAsLocalAddr
);

PLX Chip Support:
All 9000 series & 8311
Description:
Reads from the specified PCI BAR space of a PLX chip (sometimes referred to as Direct Slave Read).

从PLX芯片的指定PCI条空间读取(有时称为直接从机读取)
Parameters:
pDevice
Pointer to an open device
BarIndex
The index of the PCI BAR to access. Valid values are in the range 0-5.

要访问的PCI条的索引。有效值在0-5范围内。
offset
If bOffsetAsLocalAddr is FALSE, offset is an offset from the PCI BAR space.

如果boffsetaslocaladdr为false,则offset是PCI条空间的偏移量。

The mapping will not be adjusted because the function assumes the space is already mapped correctly.

因为函数假定空间已正确映射所以不会调整映射。

The data range accessed must not be larger than the size of the PCI-to-Local Space window.

访问的数据范围不得大于PCI到本地空间窗口的大小。

If bOffsetAsLocalAddr is TRUE, offset is treated as the actual local bus base address to start reading from.

如果boffsetaslocaladdr为true,则偏移量被视为要开始读取的实际本地总线基址。

For 32-bit devices, this allows access to any location on the 4GB local bus space.

对于32位设备,这允许访问4GB本地总线空间上的任何位置。
pBuffer
A pointer to a user supplied buffer that will contain the retrieved data.

指向用户提供的缓冲区的指针,该缓冲区将包含检索到的数据。

This buffer must be large enough to hold the amount of data requested.

这个缓冲区必须足够大以容纳请求的数据量。
ByteCount
The number of bytes to read. Note: This a number of bytes, not units of data determined by AccessType.

要读取的字节数。注意:这是一个字节数,不是由AccessType确定的数据单位。
AccessType
Determines the size of each unit of data accessed: 8, 16, or 32-bit.
bOffsetAsLocalAddr (9000 & 8311 devices only)
Determines how the API treats the offset parameter.

确定API如何处理offset参数。

If FALSE, offset is treated as an offset from the PCI BAR space.
如果为false,则将偏移视为与PCI条空间的偏移。

If TRUE, offset is treated as the actual local bus address. The driver will adjust the space remap register to access the address.

如果为真,则将偏移量视为实际的本地总线地址。驱动程序将调整空间重新映射寄存器以访问地址。
Return Codes:

CodeDescription
ApiSuccessThe function returned successfully
ApiInvalidHandleThe function was passed an invalid device handle
ApiNullParamOne or more parameters is NULL
ApiPowerDownThe PLX device is in a power state that is lower than required for this function
ApiInsufficientResourcesThe API was unable to communicate with the driver due to insufficient resources
ApiInvalidAccessTypeAn invalid or unsupported PLX_ACCESS_TYPE parameter
ApiInvalidAddressThe offset parameter is not aligned based on the AccessType
ApiInvalidSizeThe transfer size parameter is 0 or is not aligned based on the AccessType

Notes:
This function requires that the PCI-to-Local space is valid, enabled, and the space bus descriptors are setup
properly.

此函数要求PCI到本地空间有效、已启用,并且空间总线描述符设置正确。

Incorrect settings may result in incorrect data or system crashes.

不正确的设置可能导致不正确的数据或系统崩溃。
For better performance, use the PlxPci_PciBarMap function and access local memory from an application
directly through a virtual address.

为了获得更好的性能,请使用plxpci_pcibarmap函数并直接通过虚拟地址从应用程序访问本地内存。

This will completely bypass the driver and provide direct access to the local bus.

这将完全绕过驱动程序并提供对本地总线的直接访问。

The disadvantage to the direct method is that the application will be responsible for manually configuring the PLX chip local space re-map window.

直接法的缺点是应用程序将负责手动配置PLX芯片的本地空间重新映射窗口。

This will affect code portability, but overall performance is greater than using the API function.

这将影响代码的可移植性,但总体性能比使用API函数要好。
The end result of this function is a read from the device’s local bus. If no device on the local bus responds,
system crashes may result.

此功能的最终结果是从设备的本地总线读取。如果本地总线上没有设备响应,则可能导致系统崩溃。

Please make sure that valid devices are accessible and addresses are correct before using this function.

此功能的最终结果是从设备的本地总线读取。如果本地总线上没有设备响应,则可能导致系统崩溃。
Usage:

U32 buffer[0x40];
// Read from an absolute local bus address
PlxPci_PciBarSpaceRead(
pDevice,
2,             // Use BAR 2
0x00100000,                      // Absolute local address of 1MB
buffer,                           // Destination buffer
sizeof(buffer),// Buffer size in bytes
BitSize32,// 32-bit accesses
TRUE// Treat offset as a local bus address
);

// Read from an offset into the PCI BAR
PlxPci_PciBarSpaceRead(
pDevice,
3, // Use BAR 3
0x00000100, // Offset from BAR to start reading from
buffer, // Destination buffer
sizeof(buffer), // Buffer size in bytes
BitSize16,     // 16-bit accesses
FALSE        // Treat Offset as an offset from BAR
);

 

PCI8系列 PCI9系列 PCI9054 linux驱动程序 PLX SDK Samples ================================================================ ABOUT This document provides a brief description of the samples included in the PLX SDK. Please refer to the source code in each sample & the PLX SDK User's Manual for additional details. The PLX samples are intended to demonstrate use of the PLX API. The samples are not intended for debug or real world applications, although they can be extended to complex applications. They should be treated as a reference for writing custom software that utilizes the PLX API. Not all samples work with all PLX devices. The PLX API supports numerous PLX chip families in PCI/PCIe, including 6000-series PCI-to-PCI bridges, 9000-series PCI-to-Local bus bridges, & 8000-series PCI/PCIe bridges & switches. Some samples are provided only for specific chip families. SAMPLES - ApiTest Simple application that calls various PLX APIs for a selected device & verifies return codes & parameters. The API calls made depend upon the type of device selected. - DSlave Demonstrates how to read/write from a PLX 9000 PCI BAR space using the PLX API/driver to perform the data transer. This operation is often referred to as "Direct Slave". - DSlave_BypassApi Similar to the 'DSlave' sample, except this sample uses the PLX API only to map a PCI BAR space directly to the application's virtual space. The application can then directly access the space via simple memory dereferencing, bypassing the PLX API/driver & resulting in greater performance, especially for small transfers. The application is responsible for initializing the BAR space, such as setup of translation/remap registers. - LocalToPciInt [9000-series & 8311] Demonstrates how to wait for a generic Local-to-PCI interrupt using the PLX Notification API. - NT_DmaTest [8000-series switches with DMA & NT support] Demonstrates using the DMA engine in a PLX 8000 switch to transfer data through a PLX
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值