ReactOS  0.4.15-dev-2996-gf777e6b
fxusbdeviceapikm.cpp File Reference
#include "fxusbpch.hpp"
#include "FxUsbDeviceApiKm.tmh"
Include dependency graph for fxusbdeviceapikm.cpp:

Go to the source code of this file.

Functions

_Must_inspect_result_ __drv_maxIRQL (DISPATCH_LEVEL) NTSTATUS WDFAPI WDFEXPORT(WdfUsbTargetDeviceRetrieveCurrentFrameNumber)(__in PWDF_DRIVER_GLOBALS DriverGlobals
 
 FxObjectHandleGetPtrAndGlobals (GetFxDriverGlobals(DriverGlobals), UsbDevice, FX_TYPE_IO_TARGET_USB_DEVICE,(PVOID *) &pUsbDevice, &pFxDriverGlobals)
 
 FxPointerNotNull (pFxDriverGlobals, CurrentFrameNumber)
 
return pUsbDevice GetCurrentFrameNumber (CurrentFrameNumber)
 
_Must_inspect_result_ __drv_maxIRQL (PASSIVE_LEVEL) NTSTATUS WDFAPI WDFEXPORT(WdfUsbTargetDeviceSendUrbSynchronously)(__in PWDF_DRIVER_GLOBALS DriverGlobals
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST __in_opt PWDF_REQUEST_SEND_OPTIONS __in_xcount ("union bug in SAL") PURB Urb)
 
 DoTraceLevelMessage (pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "WDFUSBDEVICE %p, Request %p, Memory %p", UsbDevice, Request, UrbMemory)
 
 FxPointerNotNull (pFxDriverGlobals, UrbMemory)
 
 FxObjectHandleGetPtr (pFxDriverGlobals, UrbMemory, IFX_TYPE_MEMORY,(PVOID *) &pMemory)
 
 FxObjectHandleGetPtr (pFxDriverGlobals, Request, FX_TYPE_REQUEST,(PVOID *) &pRequest)
 
 if (!NT_SUCCESS(status))
 
 if (UrbOffsets !=NULL &&UrbOffsets->BufferOffset > 0)
 
 if (bufferSize< sizeof(_URB_HEADER))
 
buf SetMemory (pMemory, UrbOffsets)
 
 if (NT_SUCCESS(status))
 
 DoTraceLevelMessage (pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "WDFUSBDEVICE %p, Request %p, Memory %p, %!STATUS!", UsbDevice, Request, UrbMemory, status)
 
__checkReturn __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFMEMORY __deref_opt_out_bcount (sizeof(URB)) PURB *Urb)
 

Variables

_Must_inspect_result_ __in WDFUSBDEVICE UsbDevice
 
_Must_inspect_result_ __in WDFUSBDEVICE __out PULONG CurrentFrameNumber
 
PFX_DRIVER_GLOBALS pFxDriverGlobals
 
FxUsbDevicepUsbDevice
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST Request
 
_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST __in_opt PWDF_REQUEST_SEND_OPTIONS RequestOptions
 
_Must_inspect_result_ __in WDFUSBDEVICE __in WDFREQUEST __in WDFMEMORY UrbMemory
 
_Must_inspect_result_ __in WDFUSBDEVICE __in WDFREQUEST __in WDFMEMORY __in_opt PWDFMEMORY_OFFSET UrbOffsets
 
IFxMemorypMemory
 
FxRequestBuffer buf
 
FxRequestpRequest
 
NTSTATUS status = pMemory->ValidateMemoryOffsets(UrbOffsets)
 
size_t bufferSize = pMemory->GetBufferSize()
 
__checkReturn __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES Attributes
 

Function Documentation

◆ __deref_opt_out_bcount()

__checkReturn __in WDFUSBDEVICE __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFMEMORY __deref_opt_out_bcount ( sizeof(URB )

Definition at line 382 of file fxusbdeviceapikm.cpp.

411 {
412  DDI_ENTRY();
413 
417 
419  UsbDevice,
421  (PVOID*) &pUsbDevice,
423 
424  //
425  // Basic parameter validation
426  //
428 
429  if (pUsbDevice->GetUSBDHandle() == NULL) {
431 
434  "USBDEVICE Must have been created with Client Contract Verion Info, %!STATUS!",
435  status);
436 
437  return status;
438  }
439 
441 
442  return status;
443 }
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
__checkReturn NTSTATUS CreateUrb(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out WDFMEMORY *UrbMemory, __deref_opt_out_bcount(sizeof(URB)) PURB *Urb)
LONG NTSTATUS
Definition: precomp.h:26
USBD_HANDLE GetUSBDHandle(VOID)
DriverGlobals
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
PFX_DRIVER_GLOBALS pFxDriverGlobals
FxUsbDevice * pUsbDevice
NTSTATUS status
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFUSBDEVICE * UsbDevice
Definition: wdfusb.h:901
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), UsbDevice, FX_TYPE_IO_TARGET_USB_DEVICE,(PVOID *) &pUsbDevice, &pFxDriverGlobals)
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
FxPointerNotNull(pFxDriverGlobals, CurrentFrameNumber)
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_ WDFREQUEST _In_ WDFMEMORY UrbMemory
Definition: wdfusb.h:1572
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "WDFUSBDEVICE %p, Request %p, Memory %p", UsbDevice, Request, UrbMemory)
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
Definition: ps.c:97

◆ __drv_maxIRQL() [1/2]

◆ __drv_maxIRQL() [2/2]

_Must_inspect_result_ __drv_maxIRQL ( PASSIVE_LEVEL  )

◆ __in_xcount()

_Must_inspect_result_ __in WDFUSBDEVICE __in_opt WDFREQUEST __in_opt PWDF_REQUEST_SEND_OPTIONS __in_xcount ( "union bug in SAL"  )

Definition at line 75 of file fxusbdeviceapikm.cpp.

78 {
83 
85  UsbDevice,
87  (PVOID*) &pUsbDevice,
89 
91  FxSyncRequest request(pFxDriverGlobals, &context, Request);
92 
93  //
94  // FxSyncRequest always succeesds for KM but can fail for UM.
95  //
96  status = request.Initialize();
97  if (!NT_SUCCESS(status)) {
99  "Failed to initialize FxSyncRequest");
100  return status;
101  }
102 
104  "WDFUSBDEVICE %p, Urb %p", UsbDevice, Urb);
105 
107 
109  if (!NT_SUCCESS(status)) {
110  return status;
111  }
112 
114  if (!NT_SUCCESS(status)) {
115  return status;
116  }
117 
118  buf.SetBuffer(Urb, 0);
119 
121  pUsbDevice,
122  request.m_TrueRequest,
123  &buf,
126 
127  if (NT_SUCCESS(status)) {
130  "WDFUSBDEVICE %p, WDFREQUEST %p being submitted",
131  UsbDevice, request.m_TrueRequest->GetTraceObjectHandle());
132 
134  }
135 
137  "Device %p, Urb %p, %!STATUS!",
138  UsbDevice, Urb, status);
139 
140  return status;
141 }
FX_URB_TYPE GetUrbType(VOID)
Definition: http.c:7251
LONG NTSTATUS
Definition: precomp.h:26
FxRequestBuffer buf
USBD_HANDLE GetUSBDHandle(VOID)
_In_ WDFREQUEST Request
Definition: wdfdevice.h:547
_Must_inspect_result_ NTSTATUS SubmitSync(__in FxRequestBase *Request, __in_opt PWDF_REQUEST_SEND_OPTIONS Options=NULL, __out_opt PULONG Action=NULL)
DriverGlobals
NTSTATUS __inline FxValidateRequestOptions(_In_ PFX_DRIVER_GLOBALS FxDriverGlobals, _In_ PWDF_REQUEST_SEND_OPTIONS Options, _In_opt_ FxRequestBase *Request=NULL)
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
FxRequest * request
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
PFX_DRIVER_GLOBALS pFxDriverGlobals
FxUsbDevice * pUsbDevice
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS status
_Must_inspect_result_ _In_ WDFDEVICE _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFUSBDEVICE * UsbDevice
Definition: wdfusb.h:901
_In_opt_ PVOID _In_ ULONG _In_ PVOID context
Definition: wdfdriver.h:113
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), UsbDevice, FX_TYPE_IO_TARGET_USB_DEVICE,(PVOID *) &pUsbDevice, &pFxDriverGlobals)
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
NTSTATUS FxFormatUrbRequest(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxIoTarget *Target, __in FxRequestBase *Request, __in FxRequestBuffer *Buffer, __in FX_URB_TYPE FxUrbType, __drv_when(FxUrbType==FxUrbTypeUsbdAllocated, __in) __drv_when(FxUrbType !=FxUrbTypeUsbdAllocated, __in_opt) USBD_HANDLE UsbdHandle)
Definition: usbutil.cpp:62
FxPointerNotNull(pFxDriverGlobals, CurrentFrameNumber)
Definition: tftpd.h:85
_Must_inspect_result_ _In_ WDFIOTARGET _In_opt_ WDFREQUEST _In_opt_ PWDF_MEMORY_DESCRIPTOR _In_opt_ PLONGLONG _In_opt_ PWDF_REQUEST_SEND_OPTIONS RequestOptions
Definition: wdfiotarget.h:859
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "WDFUSBDEVICE %p, Request %p, Memory %p", UsbDevice, Request, UrbMemory)
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
Definition: ps.c:97

◆ DoTraceLevelMessage() [1/2]

DoTraceLevelMessage ( pFxDriverGlobals  ,
TRACE_LEVEL_VERBOSE  ,
TRACINGIOTARGET  ,
"WDFUSBDEVICE %  p,
Request p,
Memory %p ,
UsbDevice  ,
Request  ,
UrbMemory   
)

◆ DoTraceLevelMessage() [2/2]

DoTraceLevelMessage ( pFxDriverGlobals  ,
TRACE_LEVEL_VERBOSE  ,
TRACINGIOTARGET  ,
"WDFUSBDEVICE %  p,
Request p,
Memory p,
%!STATUS!"  ,
UsbDevice  ,
Request  ,
UrbMemory  ,
status   
)

◆ FxObjectHandleGetPtr() [1/2]

FxObjectHandleGetPtr ( pFxDriverGlobals  ,
UrbMemory  ,
IFX_TYPE_MEMORY  ,
(PVOID *) &  pMemory 
)

◆ FxObjectHandleGetPtr() [2/2]

FxObjectHandleGetPtr ( pFxDriverGlobals  ,
Request  ,
FX_TYPE_REQUEST  ,
(PVOID *) &  pRequest 
)

◆ FxObjectHandleGetPtrAndGlobals()

FxObjectHandleGetPtrAndGlobals ( GetFxDriverGlobals(DriverGlobals ,
UsbDevice  ,
FX_TYPE_IO_TARGET_USB_DEVICE  ,
(PVOID *) &  pUsbDevice,
pFxDriverGlobals 
)

◆ FxPointerNotNull() [1/2]

FxPointerNotNull ( pFxDriverGlobals  ,
CurrentFrameNumber   
)

◆ FxPointerNotNull() [2/2]

FxPointerNotNull ( pFxDriverGlobals  ,
UrbMemory   
)

◆ GetCurrentFrameNumber()

return pUsbDevice GetCurrentFrameNumber ( CurrentFrameNumber  )

◆ if() [1/4]

if ( NT_SUCCESSstatus)

Definition at line 193 of file fxusbdeviceapikm.cpp.

193  {
194  return status;
195  }
NTSTATUS status

◆ if() [2/4]

if ( UrbOffsets = NULL && UrbOffsets->BufferOffset,
 
)

Definition at line 198 of file fxusbdeviceapikm.cpp.

198  {
200  }
size_t bufferSize
_Must_inspect_result_ __in WDFUSBDEVICE __in WDFREQUEST __in WDFMEMORY __in_opt PWDFMEMORY_OFFSET UrbOffsets
size_t BufferOffset
Definition: wdfmemory.h:65

◆ if() [3/4]

if ( )

Definition at line 202 of file fxusbdeviceapikm.cpp.

202  {
205  "UrbMemory %p buffer size, %I64d, smaller then"
206  "_URB_HEADER, %!STATUS!",
208  return status;
209  }
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
PFX_DRIVER_GLOBALS pFxDriverGlobals
NTSTATUS status
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
IFxMemory * pMemory
_Must_inspect_result_ _In_ WDFUSBDEVICE _In_ WDFREQUEST _In_ WDFMEMORY UrbMemory
Definition: wdfusb.h:1572
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGIOTARGET, "WDFUSBDEVICE %p, Request %p, Memory %p", UsbDevice, Request, UrbMemory)
#define TRACINGIOTARGET
Definition: dbgtrace.h:72
virtual size_t GetBufferSize(VOID)=0
Definition: ps.c:97

◆ if() [4/4]

if ( NT_SUCCESS(status )

Definition at line 220 of file fxusbdeviceapikm.cpp.

220  {
221  FxUsbUrbContext* pContext;
222  pContext = (FxUsbUrbContext*) pRequest->GetContext();
223 
225  pContext->m_UsbParameters.Parameters.DeviceUrb.Buffer = UrbMemory;
226  }
VOID SetUsbType(__in WDF_USB_REQUEST_TYPE Type)
struct _WDF_USB_REQUEST_COMPLETION_PARAMS::@3672::@3675 DeviceUrb
union _WDF_USB_REQUEST_COMPLETION_PARAMS::@3672 Parameters
WDF_USB_REQUEST_COMPLETION_PARAMS m_UsbParameters
__inline FxRequestContext * GetContext(VOID)
_Must_inspect_result_ __in WDFUSBDEVICE __in WDFREQUEST __in WDFMEMORY UrbMemory
FxRequest * pRequest

◆ SetMemory()

buf SetMemory ( pMemory  ,
UrbOffsets   
)

Variable Documentation

◆ Attributes

◆ buf

Definition at line 165 of file fxusbdeviceapikm.cpp.

Referenced by __in_xcount().

◆ bufferSize

bufferSize = pMemory->GetBufferSize()

Definition at line 168 of file fxusbdeviceapikm.cpp.

Referenced by if().

◆ CurrentFrameNumber

Initial value:
{
#define DDI_ENTRY()
Definition: fxglobalskm.h:56

Definition at line 45 of file fxusbdeviceapikm.cpp.

◆ pFxDriverGlobals

PFX_DRIVER_GLOBALS pFxDriverGlobals

Definition at line 48 of file fxusbdeviceapikm.cpp.

Referenced by __deref_opt_out_bcount(), __in_xcount(), and if().

◆ pMemory

IFxMemory* pMemory

Definition at line 163 of file fxusbdeviceapikm.cpp.

Referenced by if().

◆ pRequest

FxRequest* pRequest

Definition at line 166 of file fxusbdeviceapikm.cpp.

Referenced by if().

◆ pUsbDevice

FxUsbDevice* pUsbDevice

Definition at line 49 of file fxusbdeviceapikm.cpp.

Referenced by __deref_opt_out_bcount(), and __in_xcount().

◆ Request

_Must_inspect_result_ __in WDFUSBDEVICE __in WDFREQUEST Request
Initial value:
{
#define DDI_ENTRY()
Definition: fxglobalskm.h:56

Definition at line 70 of file fxusbdeviceapikm.cpp.

◆ RequestOptions

◆ status

return status = pMemory->ValidateMemoryOffsets(UrbOffsets)

Definition at line 167 of file fxusbdeviceapikm.cpp.

Referenced by __deref_opt_out_bcount(), __in_xcount(), and if().

◆ UrbMemory

Definition at line 151 of file fxusbdeviceapikm.cpp.

Referenced by if().

◆ UrbOffsets

_Must_inspect_result_ __in WDFUSBDEVICE __in WDFREQUEST __in WDFMEMORY __in_opt PWDFMEMORY_OFFSET UrbOffsets
Initial value:
{
#define DDI_ENTRY()
Definition: fxglobalskm.h:56

Definition at line 159 of file fxusbdeviceapikm.cpp.

Referenced by if().

◆ UsbDevice

Initial value:
{
#define DDI_ENTRY()
Definition: fxglobalskm.h:56

Definition at line 41 of file fxusbdeviceapikm.cpp.