ReactOS  0.4.15-dev-2704-gd5265b0
FxUsbDeviceControlContext Struct Reference

#include <fxusbdevice.hpp>

Inheritance diagram for FxUsbDeviceControlContext:
Collaboration diagram for FxUsbDeviceControlContext:

Public Member Functions

 FxUsbDeviceControlContext (__in FX_URB_TYPE FxUrbType)
 
 ~FxUsbDeviceControlContext (VOID)
 
__checkReturn NTSTATUS AllocateUrb (__in USBD_HANDLE USBDHandle)
 
virtual VOID Dispose (VOID)
 
virtual VOID CopyParameters (__in FxRequestBase *Request)
 
VOID StoreAndReferenceMemory (__in FxUsbDevice *Device, __in FxRequestBuffer *Buffer, __in PWDF_USB_CONTROL_SETUP_PACKET SetupPacket)
 
virtual VOID ReleaseAndRestore (__in FxRequestBase *Request)
 
USBD_STATUS GetUsbdStatus (VOID)
 
- Public Member Functions inherited from FxUsbRequestContext
 FxUsbRequestContext (__in FX_REQUEST_CONTEXT_TYPE Type)
 
VOID SetUsbType (__in WDF_USB_REQUEST_TYPE Type)
 
VOID __inline InitUsbParameters (VOID)
 
- Public Member Functions inherited from FxRequestContext
 FxRequestContext (__in FX_REQUEST_CONTEXT_TYPE Type)
 
virtual ~FxRequestContext (VOID)
 
virtual VOID StoreAndReferenceMemory (__in FxRequestBuffer *Buffer)
 
__inline BOOLEAN IsType (__in FX_REQUEST_CONTEXT_TYPE Type)
 
VOID FormatWriteParams (__in_opt IFxMemory *WriteMemory, __in_opt PWDFMEMORY_OFFSET WriteOffsets)
 
VOID FormatReadParams (__in_opt IFxMemory *ReadMemory, __in_opt PWDFMEMORY_OFFSET ReadOffsets)
 
VOID FormatOtherParams (__in FxInternalIoctlParams *InternalIoctlParams)
 
- Public Member Functions inherited from FxStump
PVOID operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
PVOID operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in POOL_TYPE PoolType)
 
VOID operator delete (__in PVOID pointer)
 
PVOID operator new[] (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
VOID operator delete[] (__in PVOID pointer)
 

Public Attributes

_URB_CONTROL_TRANSFER m_UrbLegacy
 
_URB_CONTROL_TRANSFERm_Urb
 
PMDL m_PartialMdl
 
BOOLEAN m_UnlockPages
 
- Public Attributes inherited from FxUsbRequestContext
WDF_USB_REQUEST_COMPLETION_PARAMS m_UsbParameters
 
UMURB m_UmUrb
 
- Public Attributes inherited from FxRequestContext
WDF_REQUEST_COMPLETION_PARAMS m_CompletionParams
 
IFxMemorym_RequestMemory
 
FX_REQUEST_CONTEXT_TYPE m_RequestType
 

Private Attributes

USBD_HANDLE m_USBDHandle
 

Additional Inherited Members

- Protected Member Functions inherited from FxRequestContext
VOID __inline InitCompletionParams (VOID)
 
- Protected Member Functions inherited from FxStump
 FxStump (VOID)
 
- Static Protected Member Functions inherited from FxRequestContext
static VOID _StoreAndReferenceMemoryWorker (__in PVOID Tag, __deref_out_opt IFxMemory **PPMemory, __in FxRequestBuffer *Buffer)
 

Detailed Description

Definition at line 31 of file fxusbdevice.hpp.

Constructor & Destructor Documentation

◆ FxUsbDeviceControlContext()

FxUsbDeviceControlContext::FxUsbDeviceControlContext ( __in FX_URB_TYPE  FxUrbType)

Definition at line 36 of file fxusbdevice.cpp.

38  :
40 {
44 
45  if (FxUrbType == FxUrbTypeLegacy) {
46  m_Urb = &m_UrbLegacy;
47  }
48  else {
49  m_Urb = NULL;
50  }
51 }
#define FALSE
Definition: types.h:117
_URB_CONTROL_TRANSFER * m_Urb
Definition: fxusbdevice.hpp:86
#define NULL
Definition: types.h:112
_URB_CONTROL_TRANSFER m_UrbLegacy
Definition: fxusbdevice.hpp:81
FxUsbRequestContext(__in FX_REQUEST_CONTEXT_TYPE Type)

◆ ~FxUsbDeviceControlContext()

FxUsbDeviceControlContext::~FxUsbDeviceControlContext ( VOID  )

Definition at line 53 of file fxusbdevice.cpp.

56 {
57  if (m_Urb && (m_Urb != &m_UrbLegacy)) {
59  }
60  m_Urb = NULL;
62 }
VOID USBD_UrbFree(_In_ USBD_HANDLE USBDHandle, _In_ PURB Urb)
Definition: usbstubum.cpp:33
_URB_CONTROL_TRANSFER * m_Urb
Definition: fxusbdevice.hpp:86
Definition: usb.h:529
#define NULL
Definition: types.h:112
_URB_CONTROL_TRANSFER m_UrbLegacy
Definition: fxusbdevice.hpp:81

Member Function Documentation

◆ AllocateUrb()

__checkReturn NTSTATUS FxUsbDeviceControlContext::AllocateUrb ( __in USBD_HANDLE  USBDHandle)

Definition at line 66 of file fxusbdevice.cpp.

69 {
71 
72  ASSERT(USBDHandle != NULL);
73  ASSERT(m_Urb == NULL);
74 
75  status = USBD_UrbAllocate(USBDHandle, (PURB*)&m_Urb);
76 
77  if (!NT_SUCCESS(status)) {
78  goto Done;
79  }
80 
81  m_USBDHandle = USBDHandle;
82 
83 Done:
84  return status;
85 }
LONG NTSTATUS
Definition: precomp.h:26
#define ASSERT(a)
Definition: mode.c:44
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_URB_CONTROL_TRANSFER * m_Urb
Definition: fxusbdevice.hpp:86
Definition: usb.h:529
#define NULL
Definition: types.h:112
NTSTATUS USBD_UrbAllocate(_In_ USBD_HANDLE USBDHandle, _Outptr_result_bytebuffer_(sizeof(URB)) PURB *Urb)
Definition: usbstubum.cpp:46
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by FxUsbDevice::FormatControlRequest().

◆ CopyParameters()

VOID FxUsbDeviceControlContext::CopyParameters ( __in FxRequestBase Request)
virtual

Reimplemented from FxUsbRequestContext.

Definition at line 100 of file fxusbdevice.cpp.

103 {
104 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
107 #elif (FX_CORE_MODE == FX_CORE_USER_MODE)
110 #endif
112 }
struct _UMURB_CONTROL_TRANSFER UmUrbControlTransfer
Definition: umusb.h:200
union _WDF_USB_REQUEST_COMPLETION_PARAMS::@3696 Parameters
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
virtual VOID CopyParameters(__in FxRequestBase *Request)
struct _WDF_USB_REQUEST_COMPLETION_PARAMS::@3696::@3698 DeviceControlTransfer
WDF_USB_REQUEST_COMPLETION_PARAMS m_UsbParameters
_URB_CONTROL_TRANSFER * m_Urb
Definition: fxusbdevice.hpp:86
WDF_REQUEST_COMPLETION_PARAMS m_CompletionParams
ULONG TransferBufferLength
Definition: usb.h:470

◆ Dispose()

VOID FxUsbDeviceControlContext::Dispose ( VOID  )
virtual

Reimplemented from FxRequestContext.

Definition at line 88 of file fxusbdevice.cpp.

91 {
92  if (m_Urb && (m_Urb != &m_UrbLegacy)){
94  m_Urb = NULL;
96  }
97 }
VOID USBD_UrbFree(_In_ USBD_HANDLE USBDHandle, _In_ PURB Urb)
Definition: usbstubum.cpp:33
_URB_CONTROL_TRANSFER * m_Urb
Definition: fxusbdevice.hpp:86
Definition: usb.h:529
#define NULL
Definition: types.h:112
_URB_CONTROL_TRANSFER m_UrbLegacy
Definition: fxusbdevice.hpp:81

◆ GetUsbdStatus()

USBD_STATUS FxUsbDeviceControlContext::GetUsbdStatus ( VOID  )
virtual

Implements FxUsbRequestContext.

Definition at line 138 of file fxusbdevice.cpp.

141 {
142  return m_Urb->Hdr.Status;
143 }
struct _URB_HEADER Hdr
Definition: usb.h:467
_URB_CONTROL_TRANSFER * m_Urb
Definition: fxusbdevice.hpp:86

◆ ReleaseAndRestore()

VOID FxUsbDeviceControlContext::ReleaseAndRestore ( __in FxRequestBase Request)
virtual

Reimplemented from FxRequestContext.

Definition at line 115 of file fxusbdevice.cpp.

118 {
119  //
120  // Check now because Init will NULL out the field
121  //
122  if (m_PartialMdl != NULL) {
123  if (m_UnlockPages) {
126  }
127 
128 #if (FX_CORE_MODE == FX_CORE_KERNEL_MODE)
129  FxMdlFree(Request->GetDriverGlobals(), m_PartialMdl);
130 #endif
131  m_PartialMdl = NULL;
132  }
133 
135 }
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
#define FALSE
Definition: types.h:117
virtual VOID ReleaseAndRestore(__in FxRequestBase *Request)
VOID __inline FxMdlFree(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PMDL Mdl)
Definition: fxmdl.h:60
static __inline VOID MxUnlockPages(__in PMDL Mdl)
Definition: mxgeneralkm.h:357
#define NULL
Definition: types.h:112

◆ StoreAndReferenceMemory()

VOID FxUsbDeviceControlContext::StoreAndReferenceMemory ( __in FxUsbDevice Device,
__in FxRequestBuffer Buffer,
__in PWDF_USB_CONTROL_SETUP_PACKET  SetupPacket 
)

Definition at line 688 of file fxusbdevicekm.cpp.

693 {
695 
696  RtlZeroMemory(m_Urb, sizeof(*m_Urb));
697 
699  m_Urb->Hdr.Length = sizeof(*m_Urb);
700 
702 
703  //
704  // Set the values using what is stored in the buffer
705  //
706  Buffer->AssignValues(&m_Urb->TransferBuffer,
709 
711  &SetupPacket->Generic.Bytes[0],
712  sizeof(m_Urb->SetupPacket));
713 
714  //
715  // also indicate the length of the buffer in the header
716  //
717  ((PWDF_USB_CONTROL_SETUP_PACKET) &m_Urb->SetupPacket[0])->Packet.wLength =
719 
720  //
721  // Control transfers are always short OK. USBD_TRANSFER_DIRECTION_IN may
722  // be OR'ed in later.
723  //
725 
726  //
727  // Get the direction out of the setup packet
728  //
729  if (SetupPacket->Packet.bm.Request.Dir == BMREQUEST_DEVICE_TO_HOST) {
731  }
732 
733  if (Device->OnUSBD()) {
734  m_Urb->PipeHandle = Device->GetControlPipeHandle();
735  }
736  else {
737  //
738  // USBPORT supports this flag
739  //
741  }
742 
743  //
744  // If we have built a partial MDL, use that instead. TransferBufferLength
745  // is still valid because the Offsets or length in Buffer will have been
746  // used to create this PartialMdl by the caller.
747  //
748  if (m_PartialMdl != NULL) {
750  }
751 }
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_opt_ WDFREQUEST _In_opt_ PWDF_REQUEST_SEND_OPTIONS _In_ PWDF_USB_CONTROL_SETUP_PACKET SetupPacket
Definition: wdfusb.h:1331
#define USBD_TRANSFER_DIRECTION_IN
Definition: usb.h:160
if(dx==0 &&dy==0)
Definition: linetemp.h:174
struct _URB_HEADER Hdr
Definition: usb.h:467
#define BMREQUEST_DEVICE_TO_HOST
Definition: usb100.h:32
VOID SetUsbType(__in WDF_USB_REQUEST_TYPE Type)
Definition: bufpool.h:45
PMDL TransferBufferMDL
Definition: usb.h:472
virtual VOID StoreAndReferenceMemory(__in FxRequestBuffer *Buffer)
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
_URB_CONTROL_TRANSFER * m_Urb
Definition: fxusbdevice.hpp:86
#define USBD_SHORT_TRANSFER_OK
Definition: usb.h:154
UCHAR SetupPacket[8]
Definition: usb.h:475
unsigned short USHORT
Definition: pedump.c:61
USBD_PIPE_HANDLE PipeHandle
Definition: usb.h:468
#define USBD_DEFAULT_PIPE_TRANSFER
Definition: usb.h:156
#define NULL
Definition: types.h:112
union _WDF_USB_CONTROL_SETUP_PACKET * PWDF_USB_CONTROL_SETUP_PACKET
#define URB_FUNCTION_CONTROL_TRANSFER
Definition: usb.h:94
ULONG TransferFlags
Definition: usb.h:469
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
PVOID TransferBuffer
Definition: usb.h:471
ULONG TransferBufferLength
Definition: usb.h:470

Referenced by FxUsbDevice::FormatControlRequest().

Member Data Documentation

◆ m_PartialMdl

PMDL FxUsbDeviceControlContext::m_PartialMdl

◆ m_UnlockPages

BOOLEAN FxUsbDeviceControlContext::m_UnlockPages

◆ m_Urb

◆ m_UrbLegacy

_URB_CONTROL_TRANSFER FxUsbDeviceControlContext::m_UrbLegacy

◆ m_USBDHandle

USBD_HANDLE FxUsbDeviceControlContext::m_USBDHandle
private

The documentation for this struct was generated from the following files: