ReactOS 0.4.17-dev-1281-g065abb3
hostctl.cpp File Reference
#include "ucx01000.h"
#include <debug.h>
Include dependency graph for hostctl.cpp:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static BOOLEAN NTAPI UcxIsAcceptedConfigSize (_In_ ULONG Size)
 
static BOOLEAN NTAPI UcxIsValidIdString (_In_opt_ PCUNICODE_STRING String)
 
static NTSTATUS NTAPI UcxCopyIdString (_In_ PCUNICODE_STRING Source, _Out_ PUNICODE_STRING Copy)
 
static VOID NTAPI UcxFreeIdString (_Inout_ PUNICODE_STRING String)
 
 _IRQL_requires_ (PASSIVE_LEVEL) NTSTATUS UcxController
 Sends a synchronous IOCTL to the specified device object.
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 10 of file hostctl.cpp.

Function Documentation

◆ _IRQL_requires_()

_IRQL_requires_ ( PASSIVE_LEVEL  )

Sends a synchronous IOCTL to the specified device object.

Parameters
[in]IoControlCodeThe IOCTL to send to the device.
[in]DeviceObjectPointer to the device object that will handle the IOCTL.
[in]InputBufferOptional pointer to a buffer containing input data for the IOCTL. When specified, the buffer should be at least of InputBufferLength size.
[in]InputBufferLengthSize in bytes, of the buffer pointed by InputBuffer.
[out]OutputBufferOptional pointer to a buffer that will receive output data from the IOCTL. When specified, the buffer should be at least of OutputBufferLength size.
[in]OutputBufferLengthSize in bytes, of the buffer pointed by OutputBuffer.
[in]FileObjectOptional pointer to a file object that may be necessary for the IOCTL.
Returns
An NTSTATUS code indicating success or failure of this function.
Note
Must be called at PASSIVE_LEVEL with all APCs enabled.

Definition at line 726 of file hostctl.cpp.

730{
731 PFN_UCX_HCD_ENABLE_FORWARD_PROGRESS HcdEnable;
734
735 PAGED_CODE();
736
737 KeWaitForSingleObject(&m_ForwardProgressMutex, Executive, KernelMode, FALSE, NULL);
738
739 /* The thread stays even when a later step fails */
740 Status = (m_WorkerThread == NULL) ? StartWorkerThread() : STATUS_SUCCESS;
741
742 if (NT_SUCCESS(Status) && !m_HcdReservedIoReady)
743 {
744 HcdEnable = HcdEnableForwardProgress();
745 if (HcdEnable != NULL)
746 {
747 Status = HcdEnable(m_Handle);
748 if (NT_SUCCESS(Status))
749 m_HcdReservedIoReady = TRUE;
750 else
751 DPRINT1("Controller %p HCD forward progress enable failed 0x%lx\n", this, Status);
752 }
753 }
754
755 if (NT_SUCCESS(Status))
756 {
758 if (Device->IsRootHub())
759 Status = m_RootHub->EnableForwardProgress();
760 else
761 Status = Device->EnableForwardProgress(Info);
762
763 if (!NT_SUCCESS(Status))
764 DPRINT1("Controller %p forward progress for device %p failed 0x%lx\n", this, Device, Status);
765 }
766
767 KeReleaseMutex(&m_ForwardProgressMutex, FALSE);
768 return Status;
769}
#define PAGED_CODE()
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
static UcxUsbDevice * FromHandle(_In_ UCXUSBDEVICE Handle)
Definition: devobj.cpp:18
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
Definition: env_spec_w32.h:478
Status
Definition: gdiplustypes.h:24
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
Definition: hubucx.h:258
VOID StartWorkerThread(OUT PTHREAD_CONTEXT Context)
Definition: NpfsHelpers.c:674
#define KernelMode
Definition: asm.h:38
LONG NTAPI KeReleaseMutex(IN PKMUTEX Mutex, IN BOOLEAN Wait)
Definition: mutex.c:189
#define STATUS_SUCCESS
Definition: shellext.h:65
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:690
@ Executive
Definition: ketypes.h:467

◆ UcxCopyIdString()

static NTSTATUS NTAPI UcxCopyIdString ( _In_ PCUNICODE_STRING  Source,
_Out_ PUNICODE_STRING  Copy 
)
static

NUL terminated copy owned by the controller.

Definition at line 322 of file hostctl.cpp.

325{
326 USHORT Size = Source->Length + sizeof(UNICODE_NULL);
327
329 if (Copy->Buffer == NULL)
330 {
331 Copy->Length = 0;
332 Copy->MaximumLength = 0;
334 }
335
336 RtlCopyMemory(Copy->Buffer, Source->Buffer, Source->Length);
337 Copy->Buffer[Source->Length / sizeof(WCHAR)] = UNICODE_NULL;
338 Copy->Length = Source->Length;
339 Copy->MaximumLength = Size;
340
341 return STATUS_SUCCESS;
342}
ULONG Copy
Definition: devhcd.cpp:1449
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
_In_ UINT _In_ UINT _In_ PNDIS_PACKET Source
Definition: ndis.h:3169
WCHAR * PWCH
Definition: ntbasedef.h:422
#define UNICODE_NULL
short WCHAR
Definition: pedump.c:58
unsigned short USHORT
Definition: pedump.c:61
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define UCX_POOL_TAG
Definition: ucxutil.h:11
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539

Referenced by UcxController::SetIdStrings().

◆ UcxFreeIdString()

static VOID NTAPI UcxFreeIdString ( _Inout_ PUNICODE_STRING  String)
static

Definition at line 347 of file hostctl.cpp.

349{
350 if (String->Buffer != NULL)
352
353 RtlZeroMemory(String, sizeof(*String));
354}
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFSTRING String
Definition: wdfdevice.h:2439

Referenced by UcxController::Destroy(), and UcxController::SetIdStrings().

◆ UcxIsAcceptedConfigSize()

static BOOLEAN NTAPI UcxIsAcceptedConfigSize ( _In_ ULONG  Size)
static

Config sizes the HCD may pass, one per UCX_CONTROLLER_CONFIG generation.

Definition at line 31 of file hostctl.cpp.

33{
34 return Size == UCX_CONFIG_SIZE_V1 ||
37}
#define UCX_CONFIG_SIZE_V3
Definition: hostctl.h:44
#define UCX_CONFIG_SIZE_V4
Definition: hostctl.h:45
#define UCX_CONFIG_SIZE_V1
Definition: hostctl.h:43

Referenced by UcxController::Create().

◆ UcxIsValidIdString()

static BOOLEAN NTAPI UcxIsValidIdString ( _In_opt_ PCUNICODE_STRING  String)
static

Leaves room for the terminator the copy adds.

Definition at line 306 of file hostctl.cpp.

308{
309 if (String == NULL || (String->Length % sizeof(WCHAR)) != 0)
310 return FALSE;
311
312 if (String->Length > MAXUSHORT - sizeof(UNICODE_NULL))
313 return FALSE;
314
315 return String->Length == 0 || String->Buffer != NULL;
316}
#define MAXUSHORT
Definition: typedefs.h:83

Referenced by UcxController::SetIdStrings().