声明:
PLX_STATUS PlxPci_CommonBufferMap(
PLX_DEVICE_OBJECT *pDevice,
VOID **pVa
);
PLX芯片支持: 所有PLX仪器;
功能:将公共缓冲区映射到用户虚拟空间并返回基本虚拟地址
Maps the common buffer into user virtual space and return the base virtual address.
参数:
pDevice: 指向一个开启的设备
Pointer to an open device
pVa 指向存储虚拟地址的缓冲区的指针
A pointer to a buffer to hold the virtual address
返回值:
| Code | Description | 翻译 |
| ApiSuccess | The function returned successfully and at least one event ocurred | 函数成功返回,并且至少发生了一个事件 |
| ApiNullParam | One or more parameters is NULL | 一个或多个参数为空 |
| ApiInvalidDeviceInfo | The device object is not valid | 设备对象无效 |
| ApiInvalidAddress | Buffer address is invalid | 缓冲区地址无效 |
| ApiInsufficientResources | Insufficient resources for perform a mapping of the buffer | 资源不足,无法执行缓冲区的映射 |
| ApiFailed | Buffer was not allocated properly | 未正确分配缓冲区 |
Mapping of the common buffer into user virtual space may fail due to insufficient Page-Table Enties (PTEs).
由于页表实体(PTE)不足,将公共缓冲区映射到用户虚拟空间可能会失败。
The larger the buffer size, the greater the number of PTEs required to map it into user space.
缓冲区大小越大,将其映射到用户空间所需的PTE的数量就越大。
The buffer should be unmapped before calling PlxPci_DeviceClose to close the device.
在调用plxpci_device close关闭设备之前,应取消缓冲区映射。
The virtual address will cease to be valid after closing the device or after unmapping the buffer.
关闭设备或取消缓冲区映射后,虚拟地址将不再有效。
Refer to PlxPci_CommonBufferUnmap
请参阅plxpci_commonbufferunmap。
示例:
U8 value;
VOID *pBuffer;
PLX_STATUS rc;
PLX_PHYSICAL_MEM BufferInfo;
// Get the common buffer information
rc =
PlxPci_CommonBufferProperties(
pDevice,
&BufferInfo
);
if (rc != ApiSucess)
{
// Error – Unable to get common buffer properties
}
// Map the buffer into user space
rc =
PlxPci_CommonBufferMap(
pDevice,
&pBuffer
);
if (rc != ApiSucess)
{
// Error – Unable to map common buffer to user virtual space
}
// Write 32-bit value to buffer
*(U32*)((U8*)pBuffer + 0x100) = 0x12345;
// Read 8-bit value from buffer
value = *(U8*)((U8*)pBuffer + 0x54);
本文详细介绍了PLX_PCI系列芯片中公共缓冲区的映射过程,包括使用PlxPci_CommonBufferMap函数将缓冲区映射到用户虚拟空间的方法,以及可能遇到的错误情况和解决策略。同时,提供了具体的代码示例,帮助读者更好地理解和应用。
899

被折叠的 条评论
为什么被折叠?



