Plx使用手册学习------1 PlxPci_CommonBufferMap

本文详细介绍了PLX_PCI系列芯片中公共缓冲区的映射过程,包括使用PlxPci_CommonBufferMap函数将缓冲区映射到用户虚拟空间的方法,以及可能遇到的错误情况和解决策略。同时,提供了具体的代码示例,帮助读者更好地理解和应用。

声明:

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
返回值:

CodeDescription翻译
ApiSuccessThe function returned successfully and at least one event ocurred函数成功返回,并且至少发生了一个事件
ApiNullParamOne or more parameters is NULL一个或多个参数为空
ApiInvalidDeviceInfoThe device object is not valid设备对象无效
ApiInvalidAddressBuffer address is invalid缓冲区地址无效
ApiInsufficientResourcesInsufficient resources for perform a mapping of the buffer资源不足,无法执行缓冲区的映射
ApiFailedBuffer 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);

 

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
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值