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

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

static UcxUsbDevice *NTAPI UcxDeviceFromManagementRequest (_In_ WDFREQUEST Request, _In_ ULONG IoControlCode)
 
VOID NTAPI UcxEvtDeviceMgmtIoInternalDeviceControl (_In_ WDFQUEUE Queue, _In_ WDFREQUEST Request, _In_ size_t OutputBufferLength, _In_ size_t InputBufferLength, _In_ ULONG IoControlCode)
 
VOID NTAPI UcxEvtPendDuringResetIoInternalDeviceControl (_In_ WDFQUEUE Queue, _In_ WDFREQUEST Request, _In_ size_t OutputBufferLength, _In_ size_t InputBufferLength, _In_ ULONG IoControlCode)
 
VOID NTAPI UcxEvtTreePurgeIoInternalDeviceControl (_In_ WDFQUEUE Queue, _In_ WDFREQUEST Request, _In_ size_t OutputBufferLength, _In_ size_t InputBufferLength, _In_ ULONG IoControlCode)
 
static VOID NTAPI UcxTreePurgeVisitor (_In_ UcxUsbDevice *Device, _In_opt_ PVOID Context)
 
static VOID NTAPI UcxParkDuringReset (_In_ UcxUsbDevice *Device, _In_ WDFREQUEST Request)
 
static VOID NTAPI UcxResumeIrpCompletion (_In_ PIRP Irp, _In_ NTSTATUS Status)
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file devicemgmt.cpp.

Function Documentation

◆ UcxDeviceFromManagementRequest()

static UcxUsbDevice *NTAPI UcxDeviceFromManagementRequest ( _In_ WDFREQUEST  Request,
_In_ ULONG  IoControlCode 
)
static

The device a device management request is about.

Definition at line 23 of file devicemgmt.cpp.

26{
28
30 return UcxUsbDevice::FromHandle((UCXUSBDEVICE)((PURB)Arg1)->UrbHeader.UsbdDeviceHandle);
31
33}
static UcxUsbDevice * FromHandle(_In_ UCXUSBDEVICE Handle)
Definition: devobj.cpp:18
_In_ UCXUSBDEVICE UsbDevice
Definition: hostctl.h:31
PVOID Arg1
Definition: ucxutil.h:103
Definition: usb.h:565
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST _In_ size_t _In_ size_t _In_ ULONG IoControlCode
_Must_inspect_result_ _In_ WDFDEVICE _In_ WDFREQUEST Request
#define IOCTL_INTERNAL_USB_SUBMIT_URB
Definition: usbioctl.h:32

Referenced by UcxEvtDeviceMgmtIoInternalDeviceControl().

◆ UcxEvtDeviceMgmtIoInternalDeviceControl()

VOID NTAPI UcxEvtDeviceMgmtIoInternalDeviceControl ( _In_ WDFQUEUE  Queue,
_In_ WDFREQUEST  Request,
_In_ size_t  OutputBufferLength,
_In_ size_t  InputBufferLength,
_In_ ULONG  IoControlCode 
)

Definition at line 37 of file devicemgmt.cpp.

43{
45 UcxController* Controller = Device->m_Controller;
46
50
51 if (!Controller->BlockReset())
52 {
53 DPRINT("UsbDevice %p IOCTL 0x%lx during controller reset\n", Device->m_Handle, IoControlCode);
54 Device->FailManagement(Request, IoControlCode);
55 return;
56 }
57
58 /* Only an enable may bring back a device the last controller reset deprogrammed */
59 if (Device->m_DeprogrammedByControllerReset)
60 {
62 {
63 DPRINT("UsbDevice %p IOCTL 0x%lx after a controller reset deprogrammed it\n",
64 Device->m_Handle, IoControlCode);
65 Device->FailManagement(Request, IoControlCode);
66 Controller->UnblockReset();
67 return;
68 }
69 DPRINT("UsbDevice %p enabled again after a controller reset\n", Device->m_Handle);
70 Device->m_DeprogrammedByControllerReset = FALSE;
71 }
72
73 Device->DispatchManagement(Request, IoControlCode);
74
75 /* The operation usually continues; it does not need the reference */
76 Controller->UnblockReset();
77}
static UcxUsbDevice *NTAPI UcxDeviceFromManagementRequest(_In_ WDFREQUEST Request, _In_ ULONG IoControlCode)
Definition: devicemgmt.cpp:23
#define FALSE
Definition: types.h:117
#define IOCTL_UCXHUB_DEVICE_ENABLE
Definition: hubucx.h:53
_Must_inspect_result_ _In_ PUCXHUB_DEVICE_CREATE_INFO _Out_ UCXUSBDEVICE * Device
Definition: hubucx.h:258
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:329
#define DPRINT
Definition: sndvol32.h:73
_Must_inspect_result_ _In_ WDFDEVICE _In_ PUCX_CONTROLLER_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ UCXCONTROLLER * Controller
_In_ PGUID _In_ ULONG OutputBufferLength
Definition: ucxcontroller.h:81
_In_ WDFREQUEST _In_ size_t _In_ size_t InputBufferLength
_Must_inspect_result_ _In_ WDFDEVICE _In_ PIRP _In_ WDFQUEUE Queue
Definition: wdfdevice.h:2231

◆ UcxEvtPendDuringResetIoInternalDeviceControl()

VOID NTAPI UcxEvtPendDuringResetIoInternalDeviceControl ( _In_ WDFQUEUE  Queue,
_In_ WDFREQUEST  Request,
_In_ size_t  OutputBufferLength,
_In_ size_t  InputBufferLength,
_In_ ULONG  IoControlCode 
)

Definition at line 245 of file devicemgmt.cpp.

251{
255 PURB Urb;
256
260
261 switch (IoControlCode)
262 {
266 break;
267
269 Status = (((PENDPOINTS_CONFIGURE)Arg1)->EndpointsToEnableCount != 0) ? STATUS_NO_SUCH_DEVICE
271 break;
272
274 Urb = (PURB)Arg1;
275 if (Urb->UrbHeader.Function != URB_FUNCTION_CLOSE_STATIC_STREAMS)
276 {
277 DPRINT1("Parked request %p has unexpected URB function 0x%x\n", Request, Urb->UrbHeader.Function);
280 break;
281 }
282
283 Device = UcxUsbDevice::FromHandle((UCXUSBDEVICE)Urb->UrbHeader.UsbdDeviceHandle);
284 if (Device->m_FailNextStreamClose)
285 {
286 Device->m_FailNextStreamClose = FALSE;
288 }
289 else
290 {
292 }
293 break;
294
295 default:
296 DPRINT1("Parked request %p has unexpected IOCTL 0x%lx\n", Request, IoControlCode);
299 break;
300 }
301
302 DPRINT("Parked request %p IOCTL 0x%lx released 0x%lx\n", Request, IoControlCode, Status);
303 WdfRequestComplete(Request, Status);
304}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
Status
Definition: gdiplustypes.h:24
#define IOCTL_UCXHUB_DEVICE_DISABLE
Definition: hubucx.h:58
#define IOCTL_UCXHUB_DEVICE_RESET
Definition: hubucx.h:54
#define IOCTL_UCXHUB_ENDPOINTS_CONFIGURE
Definition: hubucx.h:61
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _ENDPOINTS_CONFIGURE * PENDPOINTS_CONFIGURE
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define STATUS_NO_SUCH_DEVICE
Definition: udferr_usr.h:136
struct _URB * PURB
#define URB_FUNCTION_CLOSE_STATIC_STREAMS
Definition: usb.h:153
_In_opt_ PUSB_CONFIGURATION_DESCRIPTOR _Inout_ PUSBD_INTERFACE_LIST_ENTRY _Outptr_ PURB * Urb
Definition: usbdlib.h:333
#define NT_ASSERT
Definition: rtlfuncs.h:3334

◆ UcxEvtTreePurgeIoInternalDeviceControl()

VOID NTAPI UcxEvtTreePurgeIoInternalDeviceControl ( _In_ WDFQUEUE  Queue,
_In_ WDFREQUEST  Request,
_In_ size_t  OutputBufferLength,
_In_ size_t  InputBufferLength,
_In_ ULONG  IoControlCode 
)

Definition at line 309 of file devicemgmt.cpp.

315{
316 UcxController* Controller = UcxController::FromFdo(WdfIoQueueGetDevice(Queue));
318
321
323 {
324 DPRINT1("Tree purge queue got unexpected IOCTL 0x%lx\n", IoControlCode);
325 WdfRequestComplete(Request, STATUS_INVALID_DEVICE_REQUEST);
326 return;
327 }
328
329 WdfIoQueueStop(Queue, NULL, NULL);
330
331 /* This IOCTL must not fail */
332 Status = WdfRequestForwardToIoQueue(Request, Controller->m_DeviceMgmtQueue);
333 if (!NT_SUCCESS(Status))
334 {
335 DPRINT1("Tree purge request %p forward failed 0x%lx, completed anyway\n", Request, Status);
336 WdfRequestComplete(Request, STATUS_SUCCESS);
337 WdfIoQueueStart(Queue);
338 }
339}
static UcxController * FromFdo(_In_ WDFDEVICE Fdo)
Definition: hostctl.cpp:21
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define IOCTL_UCXHUB_DEVICE_TREE_PURGE_IO
Definition: hubucx.h:67

◆ UcxParkDuringReset()

static VOID NTAPI UcxParkDuringReset ( _In_ UcxUsbDevice *  Device,
_In_ WDFREQUEST  Request 
)
static

Definition at line 624 of file devicemgmt.cpp.

627{
629
630 Status = WdfRequestForwardToIoQueue(Request, Device->m_Controller->m_PendDuringResetQueue);
631 if (!NT_SUCCESS(Status))
632 DPRINT1("UsbDevice %p could not park request %p 0x%lx\n", Device->m_Handle, Request, Status);
633}

Referenced by UcxUsbDevice::PendDisable(), UcxUsbDevice::PendEndpointsConfigure(), and UcxUsbDevice::PendReset().

◆ UcxResumeIrpCompletion()

static VOID NTAPI UcxResumeIrpCompletion ( _In_ PIRP  Irp,
_In_ NTSTATUS  Status 
)
static

Definition at line 662 of file devicemgmt.cpp.

665{
666 Irp->IoStatus.Status = Status;
667 Irp->IoStatus.Information = 0;
669}
_In_ PIRP Irp
Definition: kse.h:79
#define IoCompleteRequest
Definition: irp.c:1272
#define IO_NO_INCREMENT
Definition: iotypes.h:598

Referenced by UcxUsbDevice::CompleteEnableIrp(), UcxUsbDevice::CompleteEndpointsConfigureIrp(), UcxUsbDevice::FinishEndpointResetRequest(), and UcxUsbDevice::OnHcdEndpointsConfigureDone().

◆ UcxTreePurgeVisitor()

static VOID NTAPI UcxTreePurgeVisitor ( _In_ UcxUsbDevice *  Device,
_In_opt_ PVOID  Context 
)
static

Definition at line 444 of file devicemgmt.cpp.

447{
448 PLIST_ENTRY Endpoints = (PLIST_ENTRY)Context;
451
452 Device->m_ChildrenMayLeavePurge = FALSE;
453 Device->m_EndpointsMayLeavePurge = FALSE;
454
455 for (Entry = Device->m_EndpointList.Flink; Entry != &Device->m_EndpointList; Entry = Entry->Flink)
456 {
458
459 WdfObjectReference(Endpoint->m_Handle);
460 InsertTailList(Endpoints, &Endpoint->m_TreePurgeLink);
461 }
462}
PLIST_ENTRY Entry
Definition: devhcd.cpp:1262
#define InsertTailList(ListHead, Entry)
_In_ UCXHUB_DEVICE_CONTEXT _In_ UCXENDPOINT Endpoint
Definition: hubucx.h:238
_In_ PIRP _In_ PIO_COMPLETION_ROUTINE _In_ PVOID Context
Definition: kse.h:81
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
struct _LIST_ENTRY * PLIST_ENTRY
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define WdfObjectReference(Handle)
Definition: wdfobject.h:803

Referenced by UcxUsbDevice::HandleHubTreePurge().