ReactOS 0.4.15-dev-8207-gd73a838
FxDmaScatterGatherTransaction Class Reference

#include <fxdmatransaction.hpp>

Inheritance diagram for FxDmaScatterGatherTransaction:
Collaboration diagram for FxDmaScatterGatherTransaction:

Public Member Functions

 FxDmaScatterGatherTransaction (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT ExtraSize, __in FxDmaEnabler *DmaEnabler)
 
virtual BOOLEAN Dispose (VOID)
 
virtual _Must_inspect_result_ NTSTATUS InitializeResources (VOID)
 
virtual _Must_inspect_result_ NTSTATUS StartTransfer (VOID)
 
virtual _Must_inspect_result_ NTSTATUS TransferCompleted (VOID)
 
virtual _Must_inspect_result_ NTSTATUS StageTransfer (VOID)
 
virtual VOID ReleaseResources (__in BOOLEAN ForceRelease)
 
- Public Member Functions inherited from FxDmaTransactionBase
 FxDmaTransactionBase (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in USHORT ObjectSize, __in USHORT ExtraSize, __in FxDmaEnabler *DmaEnabler)
 
virtual BOOLEAN Dispose (VOID)
 
_Must_inspect_result_ NTSTATUS Initialize (__in PFN_WDF_PROGRAM_DMA ProgramDmaFunction, __in WDF_DMA_DIRECTION DmaDirection, __in PMDL Mdl, __in size_t Offset, __in ULONG Length)
 
virtual _Must_inspect_result_ NTSTATUS InitializeResources (VOID)=0
 
_Must_inspect_result_ NTSTATUS Execute (__in PVOID Context)
 
virtual _Must_inspect_result_ NTSTATUS StartTransfer (VOID)=0
 
virtual _Must_inspect_result_ NTSTATUS StageTransfer (VOID)=0
 
BOOLEAN DmaCompleted (__in size_t TransferredLength, __out NTSTATUS *ReturnStatus, __in FxDmaCompletionType CompletionType)
 
virtual _Must_inspect_result_ NTSTATUS TransferCompleted (VOID)=0
 
VOID ReleaseForReuse (__in BOOLEAN ForceRelease)
 
virtual VOID ReleaseResources (__in BOOLEAN ForceRelease)=0
 
VOID GetTransferInfo (__out_opt ULONG *MapRegisterCount, __out_opt ULONG *ScatterGatherElementCount)
 
__forceinline size_t GetBytesTransferred (VOID)
 
__forceinline FxDmaEnablerGetDmaEnabler (VOID)
 
__forceinline FxRequestGetRequest (VOID)
 
__forceinline BOOLEAN IsRequestReferenced (VOID)
 
__forceinline VOID SetRequest (__in FxRequest *Request)
 
__forceinline VOID ReferenceRequest (VOID)
 
__forceinline VOID ReleaseButRetainRequest (VOID)
 
__forceinline VOID ClearRequest (VOID)
 
__forceinline size_t GetMaximumFragmentLength (VOID)
 
__forceinline VOID SetMaximumFragmentLength (size_t MaximumFragmentLength)
 
__forceinline size_t GetCurrentFragmentLength (VOID)
 
__forceinline WDFDMATRANSACTION GetHandle (VOID)
 
PVOID GetTransferContext (VOID)
 
VOID SetImmediateExecution (__in BOOLEAN Value)
 
BOOLEAN CancelResourceAllocation (VOID)
 
FxDmaTransactionState GetTransactionState (VOID)
 
- Public Member Functions inherited from FxNonPagedObject
 FxNonPagedObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
 FxNonPagedObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
virtual ~FxNonPagedObject (VOID)
 
 _Acquires_lock_ (this->m_NPLock.m_Lock) __drv_maxIRQL(DISPATCH_LEVEL) __drv_setsIRQL(DISPATCH_LEVEL) VOID Lock(__out __drv_deref(__drv_savesIRQL) PKIRQL PreviousIrql)
 
 _Releases_lock_ (this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID Unlock(__in __drv_restoresIRQL KIRQL PreviousIrql)
 
 _Acquires_lock_ (this->m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) VOID LockAtDispatch(VOID)
 
 _Requires_lock_held_ (this->m_NPLock.m_Lock) _Releases_lock_(this -> m_NPLock.m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL) __inline VOID UnlockFromDispatch(VOID)
 
- Public Member Functions inherited from FxObject
PVOID GetCOMWrapper ()
 
void SetCOMWrapper (__drv_aliasesMem PVOID Wrapper)
 
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
virtual ~FxObject (VOID)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType Type)
 
PVOID __inline operator new (__in size_t Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __in USHORT ExtraSize=0)
 
VOID operator delete (__in PVOID Memory)
 
VOID SetNoContextHeader (VOID)
 
PVOID __inline GetObjectHandle (VOID)
 
__inline FxContextHeaderGetContextHeader (VOID)
 
__inline PFX_DRIVER_GLOBALS GetDriverGlobals (VOID)
 
WDFTYPE GetType (VOID)
 
USHORT GetObjectSize (VOID)
 
LONG GetRefCnt (VOID)
 
FxTagTrackerGetTagTracker (VOID)
 
CfxDeviceGetDevice (VOID)
 
CfxDeviceBaseGetDeviceBase (VOID)
 
VOID SetDeviceBase (__in CfxDeviceBase *DeviceBase)
 
__inline VOID CallCleanup (VOID)
 
ULONG __inline AddRef (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG Release (__in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG AddRefOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual ULONG ReleaseOverride (__in WDFOBJECT_OFFSET Offset, __in_opt PVOID Tag=NULL, __in LONG Line=0, __in_opt PSTR File=NULL)
 
virtual _Must_inspect_result_ NTSTATUS QueryInterface (__in FxQueryInterfaceParams *Params)
 
VOID MarkTraceState (VOID)
 
BOOLEAN __inline IsTraceState (VOID)
 
VOID __inline TraceDroppedEvent (__in FxObjectDroppedEvent Event)
 
VOID MarkPassiveDispose (__in FxObjectLockState State=ObjectLock)
 
VOID MarkPassiveCallbacks (__in FxObjectLockState State=ObjectLock)
 
VOID MarkForceDisposeThread (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsPassiveCallbacks (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsPassiveDispose (__in BOOLEAN AcquireLock=TRUE)
 
BOOLEAN IsForceDisposeThread (__in BOOLEAN AcquireLock=TRUE)
 
VOID MarkCommitted (VOID)
 
BOOLEAN IsCommitted (VOID)
 
VOID MarkDisposeOverride (__in FxObjectLockState State=ObjectLock)
 
VOID MarkNoDeleteDDI (__in FxObjectLockState State=ObjectLock)
 
BOOLEAN IsNoDeleteDDI (VOID)
 
_Must_inspect_result_ NTSTATUS Commit (__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
 
VOID DeleteFromFailedCreate (VOID)
 
VOID ClearEvtCallbacks (VOID)
 
BOOLEAN EarlyDispose (VOID)
 
virtual VOID DeleteObject (VOID)
 
virtual BOOLEAN Dispose (VOID)
 
_Must_inspect_result_ NTSTATUS AssignParentObject (__in FxObject *ParentObject)
 
_Must_inspect_result_ NTSTATUS AddContext (__in FxContextHeader *Header, __in PVOID *Context, __in PWDF_OBJECT_ATTRIBUTES Attributes)
 
_Must_inspect_result_ NTSTATUS RemoveParentAssignment (VOID)
 
_Must_inspect_result_ FxObjectGetParentObjectReferenced (__in PVOID Tag)
 
BOOLEAN IsDisposed (VOID)
 

Static Public Member Functions

static _Must_inspect_result_ NTSTATUS _Create (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in FxDmaEnabler *DmaEnabler, __out WDFDMATRANSACTION *Transaction)
 
- Static Public Member Functions inherited from FxDmaTransactionBase
static VOID _ComputeNextTransferAddress (__in PMDL CurrentMdl, __in size_t CurrentOffset, __in ULONG Transferred, __deref_out PMDL *NextMdl, __out size_t *NextOffset)
 
static _Must_inspect_result_ NTSTATUS _CalculateRequiredMapRegisters (__in PMDL Mdl, __in size_t CurrentOffset, __in ULONG Length, __in ULONG AvailableMapRegisters, __out_opt PULONG PossibleTransferLength, __out PULONG MapRegistersRequired)
 
- Static Public Member Functions inherited from FxObject
static FxObject_FromDisposeEntry (__in PSINGLE_LIST_ENTRY Entry)
 
static FxObject_GetObjectFromHandle (__in WDFOBJECT Handle, __inout PWDFOBJECT_OFFSET ObjectOffset)
 
static PVOID __inline _ToHandle (__in FxObject *Object)
 
static VOID __inline _ReferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static VOID __inline _DereferenceActual (__in WDFOBJECT Object, __in_opt PVOID Tag, __in LONG Line, __in PSTR File)
 
static PVOID _GetDebugBase (__in FxObject *Object)
 
static PFX_POOL_HEADER _CleanupPointer (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *Object)
 
static _Must_inspect_result_ NTSTATUS _GetEffectiveLock (__in FxObject *Object, __in_opt IFxHasCallbacks *Callbacks, __in BOOLEAN AutomaticLocking, __in BOOLEAN PassiveCallbacks, __out FxCallbackLock **CallbackLock, __out_opt FxObject **CallbackLockObject)
 
static _Must_inspect_result_ NTSTATUS _ObjectQuery (_In_ FxObject *Object, _In_ CONST GUID *Guid, _In_ ULONG QueryBufferLength, _Out_writes_bytes_(QueryBufferLength) PVOID QueryBuffer)
 

Protected Attributes

PSCATTER_GATHER_LIST m_SGList
 
PVOID m_LookasideBuffer
 
- Protected Attributes inherited from FxDmaTransactionBase
FxDmaTransactionState m_State
 
WDF_DMA_DIRECTION m_DmaDirection
 
FxDmaEnablerm_DmaEnabler
 
FxDmaDescriptionm_AdapterInfo
 
FxRequestm_EncodedRequest
 
FxDmaTransactionProgramOrReserveDma m_DmaAcquiredFunction
 
PVOID m_DmaAcquiredContext
 
PVOID m_TransferContext
 
PMDL m_StartMdl
 
PMDL m_CurrentFragmentMdl
 
size_t m_StartOffset
 
size_t m_CurrentFragmentOffset
 
size_t m_MaxFragmentLength
 
size_t m_TransactionLength
 
size_t m_Remaining
 
size_t m_Transferred
 
size_t m_CurrentFragmentLength
 
ULONG m_Flags
 
- Protected Attributes inherited from FxObject
union {
   CfxDeviceBase *   m_DeviceBase
 
   CfxDevice *   m_Device
 
}; 
 

Private Member Functions

_Must_inspect_result_ NTSTATUS GetScatterGatherList (__in PMDL Mdl, __in size_t CurrentOffset, __in ULONG Length, __in PDRIVER_LIST_CONTROL ExecutionRoutine, __in PVOID Context)
 
VOID PutScatterGatherList (__in PSCATTER_GATHER_LIST ScatterGather)
 
_Must_inspect_result_ NTSTATUS BuildScatterGatherList (__in PMDL Mdl, __in size_t CurrentOffset, __in ULONG Length, __in PDRIVER_LIST_CONTROL ExecutionRoutine, __in PVOID Context, __in PVOID ScatterGatherBuffer, __in ULONG ScatterGatherBufferLength)
 

Static Private Member Functions

static VOID _AdapterListControl (__in DEVICE_OBJECT *DeviceObject, __in IRP *Irp, __in SCATTER_GATHER_LIST *SgList, __in VOID *Context)
 

Additional Inherited Members

- Protected Member Functions inherited from FxDmaTransactionBase
virtual VOID Reuse (VOID)
 
- Protected Member Functions inherited from FxObject
 FxObject (__in WDFTYPE Type, __in USHORT Size, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObjectType ObjectType)
 
FxObjectDebugExtensionGetDebugExtension (VOID)
 
BOOLEAN IsDebug (VOID)
 
VOID AllocateTagTracker (__in WDFTYPE Type)
 
virtual VOID SelfDestruct (VOID)
 
PVOID __inline GetObjectHandleUnchecked (VOID)
 
VOID __inline DestroyChildren (VOID)
 
VOID DeleteEarlyDisposedObject (VOID)
 
- Static Protected Member Functions inherited from FxDmaTransactionBase
static PVOID GetStartVaFromOffset (__in PMDL Mdl, __in size_t Offset)
 
- Static Protected Member Functions inherited from FxObject
static PVOID _GetBase (__in FxObject *Object)
 

Detailed Description

Definition at line 500 of file fxdmatransaction.hpp.

Constructor & Destructor Documentation

◆ FxDmaScatterGatherTransaction()

FxDmaScatterGatherTransaction::FxDmaScatterGatherTransaction ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in USHORT  ExtraSize,
__in FxDmaEnabler DmaEnabler 
)

Definition at line 754 of file fxdmatransaction.cpp.

758 :
759 FxDmaTransactionBase(FxDriverGlobals,
761 ExtraSize,
763{
765 m_SGList = NULL;
766}
#define NULL
Definition: types.h:112
_Must_inspect_result_ _In_ WDFDMAENABLER DmaEnabler

Member Function Documentation

◆ _AdapterListControl()

VOID FxDmaScatterGatherTransaction::_AdapterListControl ( __in DEVICE_OBJECT DeviceObject,
__in IRP Irp,
__in SCATTER_GATHER_LIST SgList,
__in VOID Context 
)
staticprivate

Definition at line 1092 of file fxdmatransaction.cpp.

1098{
1100 WDFDMATRANSACTION dmaTransaction;
1101 FxDmaScatterGatherTransaction * pDmaTransaction;
1102
1105
1106 pDmaTransaction = (FxDmaScatterGatherTransaction*) Context;
1107 pFxDriverGlobals = pDmaTransaction->GetDriverGlobals();
1108 dmaTransaction = pDmaTransaction->GetHandle();
1109
1112 "Enter WDFDMATRANSACTION %p",
1113 dmaTransaction);
1114 }
1115
1116 ASSERT(pDmaTransaction != NULL);
1117 ASSERT(pDmaTransaction->m_DmaAcquiredFunction.Method.ProgramDma != NULL);
1118
1119 ASSERT(SgList->NumberOfElements <= pDmaTransaction->m_DmaEnabler->GetMaxSGElements());
1120
1121 pDmaTransaction->m_SGList = SgList;
1122
1123 //
1124 // We ignore the return value. The pattern we want the driver to follow is
1125 // that if it fails to program DMA transfer, it should call DmaCompletedFinal
1126 // to abort the transfer.
1127 //
1128 (VOID) pDmaTransaction->m_DmaAcquiredFunction.InvokeProgramDma(
1129 dmaTransaction,
1130 pDmaTransaction->m_DmaEnabler->m_DeviceBase->GetHandle(),
1131 pDmaTransaction->m_DmaAcquiredContext,
1132 pDmaTransaction->m_DmaDirection,
1133 SgList);
1134
1137 "Exit WDFDMATRANSACTION %p",
1138 dmaTransaction);
1139 }
1140}
#define VOID
Definition: acefi.h:82
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237
__inline size_t GetMaxSGElements(VOID)
FxDmaTransactionProgramOrReserveDma m_DmaAcquiredFunction
FxDmaEnabler * m_DmaEnabler
WDF_DMA_DIRECTION m_DmaDirection
__forceinline WDFDMATRANSACTION GetHandle(VOID)
BOOLEAN InvokeProgramDma(__in WDFDMATRANSACTION Transaction, __in WDFDEVICE Device, __in PVOID Context, __in WDF_DMA_DIRECTION Direction, __in PSCATTER_GATHER_LIST SgList)
union FxDmaTransactionProgramOrReserveDma::@4354 Method
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
CfxDeviceBase * m_DeviceBase
Definition: fxobject.hpp:328
_In_ PIRP Irp
Definition: csq.h:116
#define TRACINGDMA
Definition: dbgtrace.h:71
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define ASSERT(a)
Definition: mode.c:44
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
BOOLEAN FxVerifierOn
Definition: fxglobals.h:420
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION _In_ PSCATTER_GATHER_LIST SgList

Referenced by StageTransfer().

◆ _Create()

_Must_inspect_result_ NTSTATUS FxDmaScatterGatherTransaction::_Create ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in PWDF_OBJECT_ATTRIBUTES  Attributes,
__in FxDmaEnabler DmaEnabler,
__out WDFDMATRANSACTION *  Transaction 
)
static

Definition at line 770 of file fxdmatransaction.cpp.

776{
777 FxDmaScatterGatherTransaction* pTransaction;
778 WDFOBJECT hTransaction;
780
781 pTransaction = new (FxDriverGlobals, Attributes, DmaEnabler->GetTransferContextSize())
782 FxDmaScatterGatherTransaction(FxDriverGlobals,
783 DmaEnabler->GetTransferContextSize(),
784 DmaEnabler);
785
786 if (pTransaction == NULL) {
789 FxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGDMA,
790 "Could not allocate memory for WDFTRANSACTION, %!STATUS!", status);
791 return status;
792 }
793
794 //
795 // Commit and apply the attributes
796 //
797 status = pTransaction->Commit(Attributes, &hTransaction, DmaEnabler);
798
799 if (NT_SUCCESS(status) && DmaEnabler->m_IsSGListAllocated) {
800
801 //
802 // Allocate buffer for SGList from lookaside list.
803 //
804 pTransaction->m_LookasideBuffer = (SCATTER_GATHER_LIST *)
806 &DmaEnabler->m_SGList.ScatterGatherProfile.Lookaside
807 );
808
809 if (pTransaction->m_LookasideBuffer == NULL) {
812 "Unable to allocate memory for SG List, "
813 "WDFDMATRANSACTION %p, %!STATUS! ",
814 pTransaction->GetHandle(), status);
815 }
816 else {
817 //
818 // Take a reference on the enabler to ensure that it remains valid
819 // if the transaction's disposal is deferred.
820 //
821 DmaEnabler->ADDREF(pTransaction);
822 }
823 }
824
825 if (NT_SUCCESS(status)) {
826 *Transaction = (WDFDMATRANSACTION)hTransaction;
827 }
828 else {
829 //
830 // This will properly clean up the target's state and free it
831 //
832 pTransaction->DeleteFromFailedCreate();
833 }
834
835 return status;
836}
LONG NTSTATUS
Definition: precomp.h:26
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
_Must_inspect_result_ NTSTATUS Commit(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
Definition: fxobject.cpp:904
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
__inline PVOID FxAllocateFromNPagedLookasideList(_In_ PNPAGED_LOOKASIDE_LIST Lookaside, _In_opt_ size_t ElementSize=0)
Definition: fxglobalskm.h:565
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
Definition: ps.c:97
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ _In_opt_ PWDF_OBJECT_ATTRIBUTES Attributes
struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST
Definition: iotypes.h:2204

Referenced by switch().

◆ BuildScatterGatherList()

_Must_inspect_result_ NTSTATUS FxDmaScatterGatherTransaction::BuildScatterGatherList ( __in PMDL  Mdl,
__in size_t  CurrentOffset,
__in ULONG  Length,
__in PDRIVER_LIST_CONTROL  ExecutionRoutine,
__in PVOID  Context,
__in PVOID  ScatterGatherBuffer,
__in ULONG  ScatterGatherBufferLength 
)
inlineprivate

Definition at line 659 of file fxdmatransaction.hpp.

668 {
670 KIRQL irql;
671
673
674 if (m_DmaEnabler->UsesDmaV3()) {
675
676 PDMA_OPERATIONS dmaOperations =
678 ULONG flags = 0;
679
680 if (GetDriverGlobals()->IsVersionGreaterThanOrEqualTo(1,15)) {
681 //
682 // Though the correct behavior is to pass the m_Flags to the
683 // BuildScatterGatherListEx function, the code was not doing it
684 // for versions <= 1.13. To reduce any chance of regression,
685 // the m_Flags is honored for drivers that are 1.15
686 // or newer.
687 //
688 flags = m_Flags;
689 }
690
691 status = dmaOperations->BuildScatterGatherListEx(
695 Mdl,
696 CurrentOffset,
697 Length,
698 flags,
700 Context,
702 ScatterGatherBuffer,
703 ScatterGatherBufferLength,
704 NULL,
705 NULL,
706 NULL
707 );
708 }
709 else {
710
714 Mdl,
715 GetStartVaFromOffset(Mdl, CurrentOffset),
716 Length,
718 Context,
720 ScatterGatherBuffer,
721 ScatterGatherBufferLength);
722 }
723
724
726
727 return status;
728 }
unsigned char BOOLEAN
BOOLEAN UsesDmaV3(VOID)
PDEVICE_OBJECT m_FDO
_Must_inspect_result_ NTSTATUS BuildScatterGatherList(__in PMDL Mdl, __in size_t CurrentOffset, __in ULONG Length, __in PDRIVER_LIST_CONTROL ExecutionRoutine, __in PVOID Context, __in PVOID ScatterGatherBuffer, __in ULONG ScatterGatherBufferLength)
static PVOID GetStartVaFromOffset(__in PMDL Mdl, __in size_t Offset)
FxDmaDescription * m_AdapterInfo
KIRQL irql
Definition: wave.h:1
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
return pDmaTrans GetTransferContext()
GLbitfield flags
Definition: glext.h:7161
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
struct _DMA_OPERATIONS * DmaOperations
Definition: iotypes.h:2295
PBUILD_SCATTER_GATHER_LIST_EX BuildScatterGatherListEx
Definition: iotypes.h:2658
PDMA_ADAPTER AdapterObject
uint32_t ULONG
Definition: typedefs.h:59
_In_ WDFDEVICE _In_ PVOID _In_opt_ PMDL Mdl
_In_ PDEVICE_OBJECT _In_ ULONG _In_ PDRIVER_CONTROL ExecutionRoutine
Definition: iofuncs.h:1399

Referenced by BuildScatterGatherList(), and StageTransfer().

◆ Dispose()

BOOLEAN FxDmaScatterGatherTransaction::Dispose ( VOID  )
virtual

Reimplemented from FxDmaTransactionBase.

Definition at line 839 of file fxdmatransaction.cpp.

842{
843 BOOLEAN ret;
844
845 ret = FxDmaTransactionBase::Dispose(); // __super call
846
847 //
848 // Free Lookaside Buffer which held SGList
849 //
850 if (m_LookasideBuffer != NULL) {
851
855 );
857 m_DmaEnabler->RELEASE(this);
858 }
859
860 return ret;
861}
union FxDmaEnabler::@4840 m_SGList
struct FxDmaEnabler::@4840::@4841 ScatterGatherProfile
virtual BOOLEAN Dispose(VOID)
__inline VOID FxFreeToNPagedLookasideList(__in PNPAGED_LOOKASIDE_LIST Lookaside, __in PVOID Entry)
Definition: fxglobalskm.h:611
int ret

◆ GetScatterGatherList()

_Must_inspect_result_ NTSTATUS FxDmaScatterGatherTransaction::GetScatterGatherList ( __in PMDL  Mdl,
__in size_t  CurrentOffset,
__in ULONG  Length,
__in PDRIVER_LIST_CONTROL  ExecutionRoutine,
__in PVOID  Context 
)
inlineprivate

Definition at line 587 of file fxdmatransaction.hpp.

594 {
596 KIRQL irql;
597
599
600 if (m_DmaEnabler->UsesDmaV3())
601 {
602 PDMA_OPERATIONS dmaOperations =
604
605 status = dmaOperations->GetScatterGatherListEx(
609 Mdl,
610 CurrentOffset,
611 Length,
612 m_Flags,
614 Context,
616 NULL,
617 NULL,
618 NULL
619 );
620 }
621 else
622 {
626 Mdl,
627 GetStartVaFromOffset(Mdl, CurrentOffset),
628 Length,
630 Context,
632 }
633
635
636 return status;
637 }
_Must_inspect_result_ NTSTATUS GetScatterGatherList(__in PMDL Mdl, __in size_t CurrentOffset, __in ULONG Length, __in PDRIVER_LIST_CONTROL ExecutionRoutine, __in PVOID Context)
PGET_SCATTER_GATHER_LIST_EX GetScatterGatherListEx
Definition: iotypes.h:2657

Referenced by GetScatterGatherList(), and StageTransfer().

◆ InitializeResources()

_Must_inspect_result_ NTSTATUS FxDmaScatterGatherTransaction::InitializeResources ( VOID  )
virtual

Implements FxDmaTransactionBase.

Definition at line 865 of file fxdmatransaction.cpp.

868{
870 PMDL nextMdl;
871 size_t nextOffset;
872 ULONG mapRegistersRequired;
873 size_t remLength, transferLength, transferred, possibleLength=0;
875
877
878 //
879 // If the caller has specified a limit on the number of scatter-gather
880 // elements each transfer can support then make sure it's within the
881 // limit by breaking up the whole transfer into m_MaxFragmentLength and
882 // computing the number of map-registers required for each fragment.
883 // This check may not be valid if the driver starts to do partial
884 // transfers. So driver that do partial transfer with sg-element limit
885 // should be capable of handling STATUS_WDF_TOO_FRAGMENTED failures during
886 // dma execution.
887 //
888 remLength = m_TransactionLength;
889 transferred = 0;
890 nextMdl = m_StartMdl;
891 nextOffset = m_StartOffset;
892 transferLength = 0;
893
894 while (remLength != 0) {
895
897 nextOffset,
898 (ULONG) transferLength,
899 &nextMdl,
900 &nextOffset);
901
902 transferLength = FxSizeTMin(remLength, m_MaxFragmentLength);
903
905 nextOffset,
906 (ULONG) transferLength,
908 (PULONG) &possibleLength,
909 &mapRegistersRequired
910 );
911
912 if (!NT_SUCCESS(status)) {
915 "CalculateScatterGatherList failed for "
916 "WDFDMATRANSACTION %p, %!STATUS!", GetHandle(), status);
918 return status;
919 }
920
921 if (mapRegistersRequired > m_DmaEnabler->m_MaxSGElements) {
924 "WDFDMATRANSACTION %p for MDL %p is more fragmented (%d) "
925 "than the limit (%I64d) specified by the driver, %!STATUS! ",
926 GetHandle(), nextMdl, mapRegistersRequired,
928 return status;
929 }
930
931 transferred += transferLength;
932 remLength -= transferLength;
933 }
934
935 return status;
936}
ULONG m_MaxSGElements
static _Must_inspect_result_ NTSTATUS _CalculateRequiredMapRegisters(__in PMDL Mdl, __in size_t CurrentOffset, __in ULONG Length, __in ULONG AvailableMapRegisters, __out_opt PULONG PossibleTransferLength, __out PULONG MapRegistersRequired)
static VOID _ComputeNextTransferAddress(__in PMDL CurrentMdl, __in size_t CurrentOffset, __in ULONG Transferred, __deref_out PMDL *NextMdl, __out size_t *NextOffset)
FxVerifierDbgBreakPoint(pFxDriverGlobals)
__inline size_t FxSizeTMin(__in size_t A, __in size_t B)
Definition: fxglobals.h:997
#define STATUS_SUCCESS
Definition: shellext.h:65
#define GetHandle(h)
Definition: treelist.c:116
uint32_t * PULONG
Definition: typedefs.h:59
#define STATUS_WDF_TOO_FRAGMENTED
Definition: wdfstatus.h:180

◆ PutScatterGatherList()

VOID FxDmaScatterGatherTransaction::PutScatterGatherList ( __in PSCATTER_GATHER_LIST  ScatterGather)
inlineprivate

Definition at line 640 of file fxdmatransaction.hpp.

643 {
644 KIRQL irql;
645
647
653
654 return;
655 }
VOID PutScatterGatherList(__in PSCATTER_GATHER_LIST ScatterGather)
_In_ struct _IRP _In_ struct _SCATTER_GATHER_LIST * ScatterGather
Definition: iotypes.h:2375

Referenced by PutScatterGatherList(), ReleaseResources(), and TransferCompleted().

◆ ReleaseResources()

VOID FxDmaScatterGatherTransaction::ReleaseResources ( __in BOOLEAN  ForceRelease)
virtual

Implements FxDmaTransactionBase.

Definition at line 939 of file fxdmatransaction.cpp.

942{
943 if (m_SGList != NULL) {
945 m_SGList = NULL;
946 }
948}

◆ StageTransfer()

_Must_inspect_result_ NTSTATUS FxDmaScatterGatherTransaction::StageTransfer ( VOID  )
virtual

Implements FxDmaTransactionBase.

Definition at line 966 of file fxdmatransaction.cpp.

969{
971 ULONG mapRegistersRequired;
972 WDFDMATRANSACTION dmaTransaction;
974
975 //
976 // Use an invalid value to make the function fail if the var is not
977 // updated correctly below.
978 //
979 mapRegistersRequired = 0xFFFFFFFF;
980
981 //
982 // Client driver could complete and delete the object in
983 // EvtProgramDmaFunction. So, save the handle because we need it
984 // for tracing after we invoke the callback.
985 //
986 dmaTransaction = GetHandle();
987
990 "Enter WDFDMATRANSACTION %p ", GetHandle());
991 }
992
993 //
994 // Given the first MDL and the bytes transfered, find the next MDL
995 // and byteoffset within that MDL.
996 //
1002
1003 //
1004 // Get the next possible transfer size.
1005 //
1007
1008 //
1009 // Fix m_CurrentFragmentLength to meet the map registers limit. This is done
1010 // in case the MDL is a chained MDL for an highly fragmented buffer.
1011 //
1017 &mapRegistersRequired);
1018 //
1019 // We have already validated the entire transfer during initialize
1020 // to see each transfer meets the sglimit. So this call shouldn't fail.
1021 // But, if the driver does partial transfer and changes the fragment
1022 // boundaries then it's possible for the sg-elements to vary. So, check
1023 // one more time to see if we are within the bounds before building
1024 // the sglist and calling into the driver.
1025 //
1027
1028 if (mapRegistersRequired > m_DmaEnabler->m_MaxSGElements) {
1031 "WDFDMATRANSACTION %p for MDL %p is more fragmented (%d) "
1032 "than the limit (%I64d) specified by the driver, %!STATUS! ",
1033 dmaTransaction, m_CurrentFragmentMdl, mapRegistersRequired,
1035 return status;
1036 }
1037
1038
1040
1042
1047#pragma prefast(suppress: __WARNING_CLASS_MISMATCH_NONE, "This warning requires a wrapper class for the DRIVER_LIST_CONTROL type.")
1049 this,
1052
1053 } else {
1054
1058#pragma prefast(suppress: __WARNING_CLASS_MISMATCH_NONE, "This warning requires a wrapper class for the DRIVER_LIST_CONTROL type.")
1060 this);
1061 }
1062
1063 if (!NT_SUCCESS(status)) {
1065 "Build or GetScatterGatherList failed for "
1066 "WDFDMATRANSACTION %p, %!STATUS!",
1067 dmaTransaction, status);
1068 //
1069 // Readjust remaining bytes transfered.
1070 //
1072 return status;
1073 }
1074
1075 //
1076 // Before GetScatterGatherList returns, _AdapterListControl can get called
1077 // on another thread and the driver could delete the transaction object.
1078 // So don't touch the object after this point.
1079 //
1080
1083 "Exit WDFDMATRANSACTION %p, "
1084 "%!STATUS!", dmaTransaction, status);
1085 }
1086
1087 return status;
1088}
BOOLEAN m_IsSGListAllocated
static VOID _AdapterListControl(__in DEVICE_OBJECT *DeviceObject, __in IRP *Irp, __in SCATTER_GATHER_LIST *SgList, __in VOID *Context)
boolean suppress
Definition: jpeglib.h:1006
size_t PreallocatedSGListSize
#define __WARNING_CLASS_MISMATCH_NONE
Definition: suppress.h:563

Referenced by StartTransfer().

◆ StartTransfer()

_Must_inspect_result_ NTSTATUS FxDmaScatterGatherTransaction::StartTransfer ( VOID  )
virtual

Implements FxDmaTransactionBase.

Definition at line 952 of file fxdmatransaction.cpp.

955{
959 ASSERT(m_Transferred == 0);
960
961 return StageTransfer();
962}
virtual _Must_inspect_result_ NTSTATUS StageTransfer(VOID)

◆ TransferCompleted()

_Must_inspect_result_ NTSTATUS FxDmaScatterGatherTransaction::TransferCompleted ( VOID  )
virtual

Implements FxDmaTransactionBase.

Definition at line 1144 of file fxdmatransaction.cpp.

1147{
1148 //
1149 // All we have to do is release the scatter-gather list.
1150 //
1151 if (m_SGList != NULL) {
1152
1154 m_SGList = NULL;
1155 }
1156
1157 return STATUS_SUCCESS;
1158}

Member Data Documentation

◆ m_LookasideBuffer

PVOID FxDmaScatterGatherTransaction::m_LookasideBuffer
protected

◆ m_SGList

PSCATTER_GATHER_LIST FxDmaScatterGatherTransaction::m_SGList
protected

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