UfxEndpointCreate 函式 (ufxclient.h)
建立端點物件。
語法
NTSTATUS UfxEndpointCreate(
[in] UFXDEVICE UfxDevice,
[in, out] PUFXENDPOINT_INIT EndpointInit,
[in, optional] PWDF_OBJECT_ATTRIBUTES Attributes,
[in] PWDF_IO_QUEUE_CONFIG TransferQueueConfig,
[in, optional] PWDF_OBJECT_ATTRIBUTES TransferQueueAttributes,
[in] PWDF_IO_QUEUE_CONFIG CommandQueueConfig,
[in, optional] PWDF_OBJECT_ATTRIBUTES CommandQueueAttributes,
[out] UFXENDPOINT *UfxEndpoint
);
參數
[in] UfxDevice
呼叫 UfxDeviceCreate所建立驅動程式之UFX裝置物件的句柄。
[in, out] EndpointInit
UFX 在呼叫中傳遞的不透明結構 ,EVT_UFX_DEVICE_ENDPOINT_ADD 或 EVT_UFX_DEVICE_DEFAULT_ENDPOINT_ADD。
[in, optional] Attributes
呼叫端配置 WDF_OBJECT_ATTRIBUTES 結構的指標。 這個結構必須使用 WDF_OBJECT_ATTRIBUTES_INIT 或 WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE初始化。 這個參數是選擇性的,而且可以 WDF_NO_OBJECT_ATTRIBUTES。
[in] TransferQueueConfig
配置 WDF_IO_QUEUE_CONFIG 結構的呼叫端指標。 這個結構必須使用 WDF_IO_QUEUE_CONFIG_INIT初始化。
[in, optional] TransferQueueAttributes
呼叫端配置 WDF_OBJECT_ATTRIBUTES 結構的指標。 這個結構必須使用 WDF_OBJECT_ATTRIBUTES_INIT 或 WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE初始化。 這個參數是選擇性的,而且可以 WDF_NO_OBJECT_ATTRIBUTES。
[in] CommandQueueConfig
配置 WDF_IO_QUEUE_CONFIG 結構的呼叫端指標。 這個結構必須使用 WDF_IO_QUEUE_CONFIG_INIT初始化。
[in, optional] CommandQueueAttributes
呼叫端配置 WDF_OBJECT_ATTRIBUTES 結構的指標。 這個結構必須使用 WDF_OBJECT_ATTRIBUTES_INIT 或 WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE初始化。 這個參數是選擇性的,而且可以 WDF_NO_OBJECT_ATTRIBUTES。
[out] UfxEndpoint
接收UFXENDPOINT物件句柄的位置指標。
傳回值
如果作業成功,方法會傳回STATUS_SUCCESS,或NT_SUCCESS (状态) 等於 TRUE 的另一個狀態值。 否則會傳回狀態值,NT_SUCCESS (状态) 等於 FALSE。
備註
傳輸佇列會處理與端點傳輸相關的下列 IOCTL:
- IOCTL_INTERNAL_USBFN_CONTROL_STATUS_HANDSHAKE_IN
- IOCTL_INTERNAL_USBFN_CONTROL_STATUS_HANDSHAKE_OUT
- IOCTL_INTERNAL_USBFN_TRANSFER_IN
- IOCTL_INTERNAL_USBFN_TRANSFER_IN_APPEND_ZERO_PKT
- IOCTL_INTERNAL_USBFN_TRANSFER_OUT
命令佇列會處理下列 IOCTLs:
- IOCTL_INTERNAL_USBFN_GET_PIPE_STATE
- IOCTL_INTERNAL_USBFN_SET_PIPE_STATE
- IOCTL_INTERNAL_USBFN_DESCRIPTOR_UPDATE
NTSTATUS
UfxEndpointAdd (
_In_ UFXDEVICE Device,
_In_ PUSB_ENDPOINT_DESCRIPTOR Descriptor,
_Inout_ PUFXENDPOINT_INIT EndpointInit
)
/*++
Routine Description:
Creates a UFXENDPOINT object, and initializes its contexts.
Parameters Description:
Device - UFXDEVICE associated with the endpoint.
Descriptor - Endpoint descriptor for this endpoint.
EndpointInit - Opaque structure from UFX.
Return Value:
STATUS_SUCCESS if successful, appropriate NTSTATUS message otherwise.
--*/
{
NTSTATUS Status;
WDF_OBJECT_ATTRIBUTES Attributes;
WDF_IO_QUEUE_CONFIG TransferQueueConfig;
WDF_OBJECT_ATTRIBUTES TransferQueueAttributes;
WDF_IO_QUEUE_CONFIG CommandQueueConfig;
WDF_OBJECT_ATTRIBUTES CommandQueueAttributes;
UFXENDPOINT Endpoint;
PUFXENDPOINT_CONTEXT EpContext;
PUFXDEVICE_CONTEXT DeviceContext;
UFX_ENDPOINT_CALLBACKS Callbacks;
PENDPOINT_QUEUE_CONTEXT QueueContext;
WDFQUEUE Queue;
TraceEntry();
DeviceContext = UfxDeviceGetContext(Device);
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&Attributes, UFXENDPOINT_CONTEXT);
Attributes.ExecutionLevel = WdfExecutionLevelPassive;
Attributes.EvtCleanupCallback = UfxEndpoint_Cleanup;
//
// Note: Execution level needs to be passive to avoid deadlocks with WdfRequestComplete.
//
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&TransferQueueAttributes, ENDPOINT_QUEUE_CONTEXT);
TransferQueueAttributes.ExecutionLevel = WdfExecutionLevelPassive;
WDF_IO_QUEUE_CONFIG_INIT(&TransferQueueConfig, WdfIoQueueDispatchManual);
TransferQueueConfig.AllowZeroLengthRequests = TRUE;
TransferQueueConfig.EvtIoStop = EndpointQueue_EvtIoStop;
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&CommandQueueAttributes, ENDPOINT_QUEUE_CONTEXT);
CommandQueueAttributes.ExecutionLevel = WdfExecutionLevelPassive;
WDF_IO_QUEUE_CONFIG_INIT(&CommandQueueConfig, WdfIoQueueDispatchSequential);
CommandQueueConfig.EvtIoInternalDeviceControl = EvtEndpointCommandQueue;
UFX_ENDPOINT_CALLBACKS_INIT(&Callbacks);
UfxEndpointInitSetEventCallbacks(EndpointInit, &Callbacks);
Status = UfxEndpointCreate(
Device,
EndpointInit,
&Attributes,
&TransferQueueConfig,
&TransferQueueAttributes,
&CommandQueueConfig,
&CommandQueueAttributes,
&Endpoint);
CHK_NT_MSG(Status, "Failed to create ufxendpoint!");
Status = WdfCollectionAdd(DeviceContext->Endpoints, Endpoint);
CHK_NT_MSG(Status, "Failed to add endpoint to collection!");
EpContext = UfxEndpointGetContext(Endpoint);
EpContext->UfxDevice = Device;
EpContext->WdfDevice = DeviceContext->FdoWdfDevice;
RtlCopyMemory(&EpContext->Descriptor, Descriptor, sizeof(*Descriptor));
Queue = UfxEndpointGetTransferQueue(Endpoint);
QueueContext = EndpointQueueGetContext(Queue);
QueueContext->Endpoint = Endpoint;
Queue = UfxEndpointGetCommandQueue(Endpoint);
QueueContext = EndpointQueueGetContext(Queue);
QueueContext->Endpoint = Endpoint;
Status = TransferInitialize(Endpoint);
CHK_NT_MSG(Status, "Failed to initialize endpoint transfers");
//
// This can happen if we're handling a SetInterface command.
//
if (DeviceContext->UsbState == UsbfnDeviceStateConfigured) {
UfxEndpointConfigure(Endpoint);
}
Status = WdfIoQueueReadyNotify(
UfxEndpointGetTransferQueue(Endpoint),
TransferReadyNotify,
Endpoint);
CHK_NT_MSG(Status, "Failed to register ready notify");
End:
TraceExit();
return Status;
}
規格需求
需求 | 值 |
---|---|
最低支援的用戶端 | Windows 10 |
目標平台 | Windows |
標頭 | ufxclient.h |
程式庫 | ufxstub.lib |
IRQL | PASSIVE_LEVEL |