Syntax:
PLX_STATUS
PlxPci_DmaTransferBlock(
PLX_DEVICE_OBJECT *pDevice,
U8 channel,
PLX_DMA_PARAMS *pDmaParams,
U64 Timeout_ms
);
PLX Chip Support:
9054, 9056, 9080*, 9656, 8311, & 8000 DMA
Description:为给定的DMA通道启动块DMA传输
Starts a Block DMA transfer for a given DMA channel.
Parameters:
pDevice
Pointer to an open device
channel
用于传输的开放式DMA信道号
The open DMA channel number to use for the transfer
pDmaParams
指向包含DMA传输参数的结构的指针
A pointer to a structure containing the DMA transfer parameters
Timeout_ms
指定函数等待DMA完成的超时(毫秒)。如果为0,则API在启动DMA传输后立即返回,并且不等待其完成。要让函数无限期地等待DMA完成,请使用值plx_timeout_infinite。
Specifies the timeout, in milliseconds, for the function to wait for DMA completion.If 0, the API returns immediately after starting the DMA transfer and does not wait for its completion.To have the function wait indefinitely for DMA completion, use the value PLX_TIMEOUT_INFINITE.
Return Codes:
Code | Description | 翻译 |
ApiSuccess | The function returned successfully | 函数返回成功 |
ApiNullParam | One or more parameters is NULL | 一个或多个参数为空 |
ApiInvalidDeviceInfo | The device object is not valid | 设备对象无效 |
ApiPowerDown | The PLX device is in a power state that is lower than required for this function | PLX设备处于低于此功能所需的电源状态。 |
ApiDmaChannelInvalid | The DMA channel is not supported by the PLX chip | PLX芯片不支持DMA信道 |
ApiDmaChannelUnavailable | The DMA channel was not previously opened by the caller | 调用方没有提前打开DMA通道 |
ApiDmaInProgress | A DMA transfer is currently in-progress | 目前正在进行DMA传输 |
ApiWaitTimeout | No interrupt was received to signal DMA completion | 没有接收到中断信号来完成DMA |
ApiUnsupportedFunction | The device does not support DMA or 64-bit DMA is required but not supported (9080) | 设备不支持DMA或需要64位DMA但不支持(9080) |
ApiDeviceInUse | The DMA channel is open but owned by another calling thread or process | DMA通道已打开,但由另一个调用线程或进程拥有 |
Notes:
Block DMA transfers are useful with contiguous host buffers described by a PCI address.
块DMA传输对于PCI地址描述的连续主机缓冲区很有用。
The DMA channel requires a valid PCI physical addresses, not user or virtual address.
DMA通道需要有效的PCI物理地址,而不是用户或虚拟地址。
Virtual addresses are those returned by 5-36 malloc(), for example, or a static buffer in an application.
例如,虚拟地址是由5-36 malloc()返回的地址,或者是应用程序中的静态缓冲区。
The physical address of the Common buffer provided by PLX drivers (refer to PlxPci_CommonBufferProperties), for example, is a valid DMA buffer.
例如,plx驱动程序提供的公共缓冲区的物理地址(请参阅plxpci_commonbufferproperties)是有效的dma缓冲区。
By default, the DMA done interrupt is automatically enabled when this function is called.
默认情况下,当调用此函数时,将自动启用dma done中断。
It may be disabled by setting the bIgnoreBlockInt field of PLX_DMA_PARAMS.
它可以通过设置PLX_DMA_PARAMS的bIgnoreBlockInt 字段来禁用。
In this case, the DMA interrupt is disabled and will not trigger the PLX driver’s Interrupt Service Routine (ISR).
在这种情况下,DMA中断被禁用,不会触发PLX驱动程序的中断服务程序(ISR)。
This also means DMA done notification events registered with PlxPci_NotificationRegisterFor will not signal when the DMA has completed.
这也意味着在PlxPci_NotificationRegisterFor 中注册的DMA done通知事件在DMA 完成时不会发出信号。
The PLX_DMA_PARAMS structure contains members whose meanings may differ or even be ignored depending on the DMA transfer type selected by the calling function.
PLX_DMA_PARAMS 结构包含的成员的含义可能不同,甚至可以忽略,这取决于调用函数选择的DMA传输类型
PLX_DMA_PARAMS:
Structure Element | Description | |
UserVa | Ignored. | |
AddrSource | (8000 DMA) Source PCI address | |
AddrDest | (8000 DMA) Destination PCI address | |
PciAddr | (9000 DMA) The PCI address to transfer to/from. 64-bit is supported | |
LocalAddr | (9000 DMA) The Local address for the transfer | |
ByteCount | The number of bytes to transfer. | |
Direction | (8000 DMA) Ignored. AddrSource & AddrDest fields inherently imply transfer direction (9000 DMA) Direction of the transfer. Refer to PLX_DMA_DIR | |
bConstAddrSrc | (8000 DMA) Keeps the source address constant | |
bConstAddrDest | (8000 DMA) Keeps the destination address constant | |
bForceFlush | (8000 DMA) DMA engine will issue a Zero-length TLP to flush final writes. | |
bIgnoreBlockInt | Will disable the DMA done interrupt. API DMA done notification will timeout in this case. |
Usage:
PLX_DMA_PARAMS DmaParams;
PLX_PHYSICAL_MEM PciBuffer;
// Get Common buffer information
PlxPci_CommonBufferProperties(
pDevice,
&PciBuffer
);
memset( &DmaParams, 0, sizeof(PLX_DMA_PARAMS) );
// Fill in DMA transfer parameters
DmaParams.TransferCount = 0x1000;
if (pDevObj->Key.PlxChipFamily == PLX_FAMILY_BRIDGE_P2L)
{
// 9000/8311 DMA
DmaParams.PciAddr = PciBuffer.PhysicalAddr;
DmaParams.LocalAddr = 0x0;
DmaParams.Direction = PLX_DMA_LOC_TO_PCI;
}
else
{
// 8000 DMA
DmaParams.AddrSource = PciBuffer.PhysicalAddr;
DmaParams.AddrDest = PciBuffer.PhysicalAddr + 0x5000;
}
rc =
PlxPci_DmaTransferBlock(
pDevice,
0, // Channel 0
&DmaParams, // DMA transfer parameters
(3 * 1000) // Specify time to wait for DMA completion
);
if (rc != ApiSuccess)
{
if (rc == ApiWaitTimeout)
// Timed out waiting for DMA completion
else
// ERROR - Unable to perform DMA transfer
}