Função UfxDeviceCreate (ufxclient.h)
Cria um objeto de dispositivo UFX, registra rotinas de retorno de chamada de evento e especifica recursos específicos para o controlador.
Sintaxe
NTSTATUS UfxDeviceCreate(
WDFDEVICE WdfDevice,
[in] PUFX_DEVICE_CALLBACKS Callbacks,
[in] PUFX_DEVICE_CAPABILITIES Capabilities,
[in, optional] PWDF_OBJECT_ATTRIBUTES Attributes,
[out] UFXDEVICE *UfxDevice
);
Parâmetros
WdfDevice
Um identificador para um objeto de dispositivo WDF.
[in] Callbacks
Uma estrutura do tipo UFX_DEVICE_CALLBACKS que contém ponteiros para rotinas de retorno de chamada fornecidas pelo driver a serem associadas ao objeto de dispositivo UFX.
[in] Capabilities
Um ponteiro para uma estrutura UFX_DEVICE_CAPABILITIES .
[in, optional] Attributes
Um ponteiro para uma estrutura WDF_OBJECT_ATTRIBUTES que contém atributos fornecidos pelo driver para o novo objeto. Esse parâmetro é opcional e pode ser WDF_NO_OBJECT_ATTRIBUTES.
[out] UfxDevice
Um ponteiro para um local que recebe um identificador para o novo objeto de dispositivo UFX.
Retornar valor
Se a operação for bem-sucedida, o método retornará STATUS_SUCCESS ou outro valor status para o qual NT_SUCCESS(status) é igual a TRUE. Caso contrário, retornará um valor status para o qual NT_SUCCESS(status) é igual a FALSE.
Comentários
O driver do cliente deve chamar WdfDeviceCreate antes de chamar UfxDeviceCreate. Normalmente, o driver cliente chama UfxDeviceCreate de sua rotina de retorno de chamada EvtDriverDeviceAdd .
O snippet de código a seguir mostra como chamar UfxDeviceCreate.
NTSTATUS
UfxDevice_DeviceCreate (
_In_ WDFDEVICE WdfDevice
)
/*++
Routine Description:
Routine that registers with UFX and creates the UFX device object.
Arguments:
WdfDevice - Wdf object representing the device.
Return Value:
NTSTATUS.
--*/
{
NTSTATUS Status;
PCONTROLLER_CONTEXT ControllerContext;
UFX_DEVICE_CALLBACKS UfxDeviceCallbacks;
UFX_DEVICE_CAPABILITIES UfxDeviceCapabilities;
PUFXDEVICE_CONTEXT UfxDeviceContext;
UFXDEVICE UfxDevice;
WDF_OBJECT_ATTRIBUTES Attributes;
PAGED_CODE();
TraceEntry();
ControllerContext = DeviceGetControllerContext(WdfDevice);
UFX_DEVICE_CAPABILITIES_INIT(&UfxDeviceCapabilities);
UfxDeviceCapabilities.MaxSpeed = UsbSuperSpeed;
UfxDeviceCapabilities.RemoteWakeSignalDelay = REMOTE_WAKEUP_TIMEOUT_INTERVAL_MS;
//
// Set bitmasks that define the IN and OUT endpoint numbers that are available on the controller
//
//
// #### TODO: Set the IN endpoint mask here if not all endpoint addresses are supported ####
//
// For illustration purposes sample will set default control endpoint 0, 1-4, 8
UfxDeviceCapabilities.InEndpointBitmap = 0x011F;
//
// #### TODO: Set the OUT endpoint mask here if not all endpoint addresses are supported ####
//
// For illustration purposes sample will set default control endpoint 0, 2-7
//
UfxDeviceCapabilities.OutEndpointBitmap = 0x00FD;
//
// Set the event callbacks for the ufxdevice
//
UFX_DEVICE_CALLBACKS_INIT(&UfxDeviceCallbacks);
UfxDeviceCallbacks.EvtDeviceHostConnect = UfxDevice_EvtDeviceHostConnect;
UfxDeviceCallbacks.EvtDeviceHostDisconnect = UfxDevice_EvtDeviceHostDisconnect;
UfxDeviceCallbacks.EvtDeviceAddressed = UfxDevice_EvtDeviceAddressed;
UfxDeviceCallbacks.EvtDeviceEndpointAdd = UfxDevice_EvtDeviceEndpointAdd;
UfxDeviceCallbacks.EvtDeviceDefaultEndpointAdd = UfxDevice_EvtDeviceDefaultEndpointAdd;
UfxDeviceCallbacks.EvtDeviceUsbStateChange = UfxDevice_EvtDeviceUsbStateChange;
UfxDeviceCallbacks.EvtDevicePortChange = UfxDevice_EvtDevicePortChange;
UfxDeviceCallbacks.EvtDevicePortDetect = UfxDevice_EvtDevicePortDetect;
UfxDeviceCallbacks.EvtDeviceRemoteWakeupSignal = UfxDevice_EvtDeviceRemoteWakeupSignal;
UfxDeviceCallbacks.EvtDeviceTestModeSet = UfxDevice_EvtDeviceTestModeSet;
UfxDeviceCallbacks.EvtDeviceSuperSpeedPowerFeature = UfxDevice_EvtDeviceSuperSpeedPowerFeature;
// Context associated with UFXDEVICE object
WDF_OBJECT_ATTRIBUTES_INIT_CONTEXT_TYPE(&Attributes, UFXDEVICE_CONTEXT);
Attributes.EvtCleanupCallback = UfxDevice_EvtCleanupCallback;
// Create the UFXDEVICE object
Status = UfxDeviceCreate(WdfDevice,
&UfxDeviceCallbacks,
&UfxDeviceCapabilities,
&Attributes,
&UfxDevice);
...
}
Requisitos
Requisito | Valor |
---|---|
Cliente mínimo com suporte | Windows 10 |
Plataforma de Destino | Windows |
Cabeçalho | ufxclient.h |
Biblioteca | ufxstub.lib |
IRQL | PASSIVE_LEVEL |