Plx使用手册学习------7 PlxPci_DeviceOpen

本文介绍如何使用PLX PCI设备选择API进行设备的查找与打开操作。通过详细解析PlxPci_DeviceOpen函数,展示了如何利用PLX_DEVICE_KEY结构体设置搜索条件,及如何处理返回的状态码。

Syntax:

PLX_STATUS
PlxPci_DeviceOpen(
PLX_DEVICE_KEY *pKey,
PLX_DEVICE_OBJECT *pDevice
);

PLX Chip Support:
All devices
Description:
Selects a specific PCI device for later use with PLX API calls. The device is selected based on the criteria in
PLX_DEVICE_KEY.
Parameters:
pKey
Pointer to a PLX_DEVICE_KEY structure which contains one or more search criteria.
pDevice
Pointer to a PLX_DEVICE_OBJECT structure which will describe the selected PCI device.
Return Codes:

CodeDescription
ApiSuccessThe function returned successfully
ApiNullParamOne or more parameters is NULL
ApiNoActiveDriverA valid PLX driver is not loaded in the system
ApiInvalidDeviceInfoThe device object is invalid or the key does not match an installed device
ApiInvalidDriverVersionThe PLX driver version does not match the API library version
ApiObjectAlreadyAllocatedThe device object is already open or in use

Notes:
Use PlxPci_DeviceFind to query the driver for installed PCI devices and fill in the PLX_DEVICE_KEY
information.
If the function returns ApiSuccess, any missing key information will be filled in.

Usage:

PLX_STATUS rc;
PLX_DEVICE_KEY DeviceKey;
PLX_DEVICE_OBJECT Device;
// Clear key structure to select first device
memset(&DeviceKey, PCI_FIELD_IGNORE, sizeof(PLX_DEVICE_KEY));
// Open device
rc =
PlxPci_DeviceOpen(
&DeviceKey,
&Device
);
if (rc != ApiSuccess)
{
// Error
}
else
{
Cons_printf(
"Selected: %04x %04x [b:%02x s:%02x f:%02x]\n",
DeviceKey.DeviceId, DeviceKey.VendorId,
DeviceKey.bus, DeviceKey.slot, DeviceKey.function
);
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值