ReactOS 0.4.16-dev-1946-g52006dd
FxDmaEnabler Class Reference

#include <fxdmaenabler.hpp>

Inheritance diagram for FxDmaEnabler:
Collaboration diagram for FxDmaEnabler:

Public Member Functions

 FxDmaEnabler (__in PFX_DRIVER_GLOBALS FxDriverGlobals)
 
 ~FxDmaEnabler ()
 
virtual BOOLEAN Dispose (VOID)
 
_Must_inspect_result_ NTSTATUS Initialize (__in PWDF_DMA_ENABLER_CONFIG Config, __inout FxDeviceBase *Device)
 
_Must_inspect_result_ NTSTATUS ConfigureSystemAdapter (__in PWDF_DMA_SYSTEM_PROFILE_CONFIG Config, __in WDF_DMA_DIRECTION ConfigDirection)
 
VOID AllocateCommonBuffer (__in size_t Length, __deref_out_opt PVOID *BufferVA, __out PHYSICAL_ADDRESS *BufferPA)
 
VOID FreeCommonBuffer (__in size_t Length, __in PVOID BufferVA, __in PHYSICAL_ADDRESS BufferPA)
 
_Must_inspect_result_ NTSTATUS PowerUp (VOID)
 
_Must_inspect_result_ NTSTATUS PowerDown (VOID)
 
VOID RevokeResources (VOID)
 
VOID InitializeTransferContext (__out PVOID Context, __in WDF_DMA_DIRECTION Direction)
 
__inline size_t GetMaximumLength (VOID)
 
__inline size_t GetAlignment (VOID)
 
__inline WDFDMAENABLER GetHandle (VOID)
 
__inline WDFDEVICE GetDeviceHandle (VOID)
 
__inline size_t GetMaxSGElements (VOID)
 
__inline VOID SetMaxSGElements (__in size_t MaximumSGElements)
 
__inline WDF_DMA_PROFILE GetProfile (VOID)
 
__inline BOOLEAN SupportsChainedMdls (VOID)
 
__inline BOOLEAN IsBusMaster (VOID)
 
__inline BOOLEAN IsPacketBased ()
 
__inline FxDmaDescriptionGetDmaDescription (__in WDF_DMA_DIRECTION Direction)
 
__inline FxDmaDescriptionGetWriteDmaDescription (VOID)
 
__inline FxDmaDescriptionGetReadDmaDescription (VOID)
 
BOOLEAN UsesDmaV3 (VOID)
 
USHORT GetTransferContextSize (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)
 

Public Attributes

FxTransactionedEntry m_TransactionLink
 
FxDmaDescription m_SimplexAdapterInfo
 
FxDmaDescription m_DuplexAdapterInfo [FxDuplexDmaDescriptionTypeMax]
 
NPAGED_LOOKASIDE_LIST Lookaside
 
struct {
   NPAGED_LOOKASIDE_LIST   Lookaside
 
ScatterGatherProfile
 
PSCATTER_GATHER_LIST List
 
struct {
   PSCATTER_GATHER_LIST   List
 
SystemProfile
 

Protected Attributes

PDEVICE_OBJECT m_FDO
 
PDEVICE_OBJECT m_PDO
 
union {
   FxDmaDescription   m_SimplexAdapterInfo
 
   FxDmaDescription   m_DuplexAdapterInfo [FxDuplexDmaDescriptionTypeMax]
 
}; 
 
WDF_DMA_PROFILE m_Profile
 
BOOLEAN m_IsAdded: 1
 
BOOLEAN m_IsConfigured: 1
 
BOOLEAN m_IsBusMaster: 1
 
BOOLEAN m_IsScatterGather: 1
 
BOOLEAN m_IsDuplexTransfer: 1
 
BOOLEAN m_IsSGListAllocated: 1
 
ULONG m_CommonBufferAlignment
 
ULONG m_MaximumLength
 
ULONG m_MaxSGElements
 
size_t m_SGListSize
 
union {
   struct {
      NPAGED_LOOKASIDE_LIST   Lookaside
 
   }   ScatterGatherProfile
 
   struct {
      PSCATTER_GATHER_LIST   List
 
   }   SystemProfile
 
m_SGList
 
- Protected Attributes inherited from FxObject
union {
   CfxDeviceBase *   m_DeviceBase
 
   CfxDevice *   m_Device
 
}; 
 

Private Member Functions

_Must_inspect_result_ NTSTATUS ConfigureBusMasterAdapters (__in PDEVICE_DESCRIPTION DeviceDescription, __in PWDF_DMA_ENABLER_CONFIG Config)
 
_Must_inspect_result_ NTSTATUS ConfigureDmaAdapter (__in PDEVICE_DESCRIPTION DeviceDescription, __in WDF_DMA_DIRECTION ConfigDirection)
 
_Must_inspect_result_ NTSTATUS InitializeResources (__inout FxDmaDescription *AdapterInfo)
 
VOID ReleaseResources (VOID)
 
VOID FreeResources (__inout FxDmaDescription *AdapterInfo)
 

Private Attributes

FxEvtDmaEnablerFillCallback m_EvtDmaEnablerFill
 
FxEvtDmaEnablerFlushCallback m_EvtDmaEnablerFlush
 
FxEvtDmaEnablerEnableCallback m_EvtDmaEnablerEnable
 
FxEvtDmaEnablerDisableCallback m_EvtDmaEnablerDisable
 
FxEvtDmaEnablerSelfManagedIoStartCallback m_EvtDmaEnablerSelfManagedIoStart
 
FxEvtDmaEnablerSelfManagedIoStopCallback m_EvtDmaEnablerSelfManagedIoStop
 
BOOLEAN m_DmaEnablerFillFailed
 
BOOLEAN m_DmaEnablerEnableFailed
 
BOOLEAN m_DmaEnablerSelfManagedIoStartFailed
 

Friends

class FxDmaTransactionBase
 
class FxDmaPacketTransaction
 
class FxDmaScatterGatherTransaction
 
class FxDmaSystemTransaction
 

Additional Inherited Members

- 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 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 FxObject
static PVOID _GetBase (__in FxObject *Object)
 

Detailed Description

Definition at line 66 of file fxdmaenabler.hpp.

Constructor & Destructor Documentation

◆ FxDmaEnabler()

FxDmaEnabler::FxDmaEnabler ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals)

Definition at line 33 of file fxdmaenabler.cpp.

35 :
36 FxNonPagedObject(FX_TYPE_DMA_ENABLER, sizeof(FxDmaEnabler), FxDriverGlobals)
37{
40
41 //
42 // Transaction link into list of FxDmaEnabler pointers maintained by
43 // FxDevice's pnp package.
44 //
46
47 m_FDO = NULL;
48 m_PDO = NULL;
54 m_SGListSize = 0;
55
57
64
68
70
72}
BOOLEAN m_IsSGListAllocated
FxDmaDescription m_SimplexAdapterInfo
BOOLEAN m_DmaEnablerFillFailed
BOOLEAN m_IsDuplexTransfer
BOOLEAN m_IsAdded
size_t m_SGListSize
FxDmaDescription m_DuplexAdapterInfo[FxDuplexDmaDescriptionTypeMax]
FxTransactionedEntry m_TransactionLink
PDEVICE_OBJECT m_PDO
FxEvtDmaEnablerSelfManagedIoStopCallback m_EvtDmaEnablerSelfManagedIoStop
FxEvtDmaEnablerEnableCallback m_EvtDmaEnablerEnable
FxEvtDmaEnablerDisableCallback m_EvtDmaEnablerDisable
FxEvtDmaEnablerSelfManagedIoStartCallback m_EvtDmaEnablerSelfManagedIoStart
FxEvtDmaEnablerFillCallback m_EvtDmaEnablerFill
BOOLEAN m_IsScatterGather
FxEvtDmaEnablerFlushCallback m_EvtDmaEnablerFlush
BOOLEAN m_DmaEnablerEnableFailed
BOOLEAN m_DmaEnablerSelfManagedIoStartFailed
PDEVICE_OBJECT m_FDO
ULONG m_MaxSGElements
ULONG m_CommonBufferAlignment
union FxDmaEnabler::@5118 m_SGList
PFN_WDF_DMA_ENABLER_DISABLE m_Method
PFN_WDF_DMA_ENABLER_ENABLE m_Method
PFN_WDF_DMA_ENABLER_FILL m_Method
PFN_WDF_DMA_ENABLER_FLUSH m_Method
PFN_WDF_DMA_ENABLER_SELFMANAGED_IO_START m_Method
PFN_WDF_DMA_ENABLER_SELFMANAGED_IO_STOP m_Method
VOID MarkDisposeOverride(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1101
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
@ ObjectDoNotLock
Definition: fxobject.hpp:128
@ FX_TYPE_DMA_ENABLER
Definition: fxtypes.h:107
VOID SetTransactionedObject(__in FxObject *Object)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define WDF_DMA_ENABLER_UNLIMITED_FRAGMENTS

◆ ~FxDmaEnabler()

FxDmaEnabler::~FxDmaEnabler ( )

Definition at line 74 of file fxdmaenabler.cpp.

75{
78 //
79 // Scatter Gather profile - cleanup the lookaside list
80 //
81 ExDeleteNPagedLookasideList(&m_SGList.ScatterGatherProfile.Lookaside);
82
83 } else if (!m_IsBusMaster) {
84 //
85 // System profile (not busmastering) - cleanup the preallocated
86 // SG list
87 //
88 ExFreePool(m_SGList.SystemProfile.List);
89
90 } else {
91 //
92 // Packet profile. No special cleanup to do.
93 //
94
95 }
96
97#if DBG
99#endif
101 }
102}
BOOLEAN m_IsBusMaster
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
VOID NTAPI ExDeleteNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside)
Definition: lookas.c:170

Member Function Documentation

◆ AllocateCommonBuffer()

VOID FxDmaEnabler::AllocateCommonBuffer ( __in size_t  Length,
__deref_out_opt PVOID BufferVA,
__out PHYSICAL_ADDRESS BufferPA 
)

Definition at line 1058 of file fxdmaenabler.cpp.

1063{
1064 ULONG result;
1065 PDMA_ADAPTER adapterObject;
1067
1068 *BufferVA = NULL;
1069 BufferPA->QuadPart = 0;
1070
1073 "WDFDMAENABLER %p AllocateCommonBuffer: could cast value %I64d to a "
1074 "ULONG", GetHandle(), Length);
1076 return;
1077 }
1078
1079 //
1080 // It doesn't matter which channel we use for allocating common buffers
1081 // because the addressing capability of all the channels of this DMA enablers
1082 // are same.
1083 //
1084 adapterObject = GetReadDmaDescription()->AdapterObject;
1085
1086 *BufferVA = adapterObject->DmaOperations->
1087 AllocateCommonBuffer( adapterObject,
1088 result,
1089 BufferPA,
1090 TRUE /* CacheEnabled */ );
1091}
__inline FxDmaDescription * GetReadDmaDescription(VOID)
VOID AllocateCommonBuffer(__in size_t Length, __deref_out_opt PVOID *BufferVA, __out PHYSICAL_ADDRESS *BufferPA)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxobject.hpp:734
#define TRACINGDMA
Definition: dbgtrace.h:71
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
PFX_DRIVER_GLOBALS pFxDriverGlobals
FxVerifierDbgBreakPoint(pFxDriverGlobals)
#define RtlSizeTToULong
GLuint64EXT * result
Definition: glext.h:11304
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
struct _DMA_OPERATIONS * DmaOperations
Definition: iotypes.h:2297
PDMA_ADAPTER AdapterObject
#define GetHandle(h)
Definition: treelist.c:116
uint32_t ULONG
Definition: typedefs.h:59

Referenced by FxCommonBuffer::AllocateCommonBuffer(), and AllocateCommonBuffer().

◆ ConfigureBusMasterAdapters()

_Must_inspect_result_ NTSTATUS FxDmaEnabler::ConfigureBusMasterAdapters ( __in PDEVICE_DESCRIPTION  DeviceDescription,
__in PWDF_DMA_ENABLER_CONFIG  Config 
)
private

Definition at line 611 of file fxdmaenabler.cpp.

615{
618
619 //
620 // Initialize map register management
621 //
622 DeviceDescription->MaximumLength = m_MaximumLength;
623
624 if (m_IsDuplexTransfer) {
627
628 if (!NT_SUCCESS(status)) {
629 goto End;
630 }
631
634 } else {
635 //
636 // Direction is ignored in this case.
637 //
638
641 }
642
643 if (!NT_SUCCESS(status)) {
644 goto End;
645 }
646
647 //
648 // Allocate a scatter gather lookaside list if we need one.
649 //
650
651 if (m_IsScatterGather) {
652 size_t sgLookasideListSize;
653
654 sgLookasideListSize = 0;
655
656 if (m_IsDuplexTransfer) {
659
660 alignment = readDmaDesc->AdapterObject->DmaOperations->
661 GetDmaAlignment(readDmaDesc->AdapterObject);
662
663 //
664 // GetDmaAlignment returns alignment in terms of bytes
665 // while we treat alignment as a mask (which is how it is set
666 // in _DEVICE_OBJECT as well.
667 // For example, for byte alignment GetDmaAlignment returns 1 while
668 // the alignment mask is 0x00000000
669 //
670 // For < 1.11 drivers we keep the same behaviour as before for
671 // compatibility.
672 //
673 if (GetDriverGlobals()->IsVersionGreaterThanOrEqualTo(1, 11) &&
674 alignment > 0) {
675 alignment -= 1;
676 }
677
679 alignment);
680
681 //
682 // We will create a lookaside list based on the larger of the read &
683 // write SGListSize. It's done this way so that we can allocate
684 // sglist buffer when the dma-transaction object is created, where
685 // we don't know the direction of DMA transfer, and make the
686 // transaction initialize call fail-proof.
687 //
688 sgLookasideListSize = FxSizeTMax(
689 readDmaDesc->PreallocatedSGListSize,
690 writeDmaDesc->PreallocatedSGListSize
691 );
692 } else {
693
694 FxDmaDescription *simplexDmaDesc = &m_SimplexAdapterInfo;
695
696 alignment = simplexDmaDesc->AdapterObject->DmaOperations->
697 GetDmaAlignment(simplexDmaDesc->AdapterObject);
698
699 //
700 // GetDmaAlignment returns alignment in terms of bytes
701 // while we treat alignment as a mask (which is how it is set
702 // in _DEVICE_OBJECT as well.
703 // For example, for byte alignment GetDmaAlignment returns 1 while
704 // the alignment mask is 0x00000000
705 //
706 // For < 1.11 drivers we keep the same behaviour as before for
707 // compatibility.
708 //
709 if (GetDriverGlobals()->IsVersionGreaterThanOrEqualTo(1, 11) &&
710 alignment > 0) {
711 alignment -= 1;
712 }
713
715 alignment);
716
717 sgLookasideListSize = simplexDmaDesc->PreallocatedSGListSize;
718 }
719
720 //
721 // Initialize a LookasideList for ScatterGather list
722 //
725
726 m_SGListSize = sgLookasideListSize;
727
728 ExInitializeNPagedLookasideList( &m_SGList.ScatterGatherProfile.Lookaside,
729 NULL, // Allocate OPTIONAL
730 NULL, // Free OPTIONAL
731 0, // Flag - Reserved. Must be zero.
734 0 ); // Depth - Reserved. Must be zero.
735
737 }
738 }
739
740 //
741 // The DMA enabler is configured now.
742 //
743
745
746End:
747
748 return status;
749}
_Check_return_ _Ret_maybenull_ _In_ size_t alignment
Definition: align.cpp:48
LONG NTSTATUS
Definition: precomp.h:26
ULONG m_MaximumLength
__inline FxDmaDescription * GetWriteDmaDescription(VOID)
_Must_inspect_result_ NTSTATUS ConfigureDmaAdapter(__in PDEVICE_DESCRIPTION DeviceDescription, __in WDF_DMA_DIRECTION ConfigDirection)
BOOLEAN m_IsConfigured
__inline size_t FxSizeTMax(__in size_t A, __in size_t B)
Definition: fxglobals.h:987
VOID NTAPI ExInitializeNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside, IN PALLOCATE_FUNCTION Allocate OPTIONAL, IN PFREE_FUNCTION Free OPTIONAL, IN ULONG Flags, IN SIZE_T Size, IN ULONG Tag, IN USHORT Depth)
Definition: lookas.c:218
#define ASSERT(a)
Definition: mode.c:44
ULONG AlignmentRequirement
Definition: env_spec_w32.h:420
size_t PreallocatedSGListSize
Definition: ps.c:97
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
Definition: wdfchildlist.h:476
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4071
@ WDF_DMA_ENABLER_CONFIG_NO_SGLIST_PREALLOCATION
@ WdfDmaDirectionReadFromDevice
Definition: wdfdmaenabler.h:65
@ WdfDmaDirectionWriteToDevice
Definition: wdfdmaenabler.h:66
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
Definition: wdfpdo.h:432

Referenced by Initialize().

◆ ConfigureDmaAdapter()

_Must_inspect_result_ NTSTATUS FxDmaEnabler::ConfigureDmaAdapter ( __in PDEVICE_DESCRIPTION  DeviceDescription,
__in WDF_DMA_DIRECTION  ConfigDirection 
)
private

Definition at line 753 of file fxdmaenabler.cpp.

757{
758 FxDmaDescription *dmaDesc;
760
761 //
762 // Select the adapter to configure.
763 //
764
766
767 //
768 // Copy the device-description we have built up so far
769 // into the read and write dma description field. These
770 // settings are common to both channels.
771 //
774 sizeof(DEVICE_DESCRIPTION));
775
776 //
777 // Then initialize resources that are private to read and write.
778 //
779
780 status = InitializeResources(dmaDesc);
781 return status;
782}
_Must_inspect_result_ NTSTATUS InitializeResources(__inout FxDmaDescription *AdapterInfo)
__inline FxDmaDescription * GetDmaDescription(__in WDF_DMA_DIRECTION Direction)
DEVICE_DESCRIPTION DeviceDescription
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ PWDF_DMA_SYSTEM_PROFILE_CONFIG _In_ WDF_DMA_DIRECTION ConfigDirection

Referenced by ConfigureBusMasterAdapters(), and ConfigureSystemAdapter().

◆ ConfigureSystemAdapter()

_Must_inspect_result_ NTSTATUS FxDmaEnabler::ConfigureSystemAdapter ( __in PWDF_DMA_SYSTEM_PROFILE_CONFIG  Config,
__in WDF_DMA_DIRECTION  ConfigDirection 
)

Definition at line 486 of file fxdmaenabler.cpp.

490{
491 DEVICE_DESCRIPTION deviceDescription;
492
494
495 //
496 // Check to make sure this direction isn't currently configured.
497 //
498 if (GetDmaDescription(ConfigDirection)->AdapterObject != NULL) {
500
502 "WDFDMAENABLER %p, profile %!WDF_DMA_PROFILE! "
503 "Enabler has already been configured for %!WDF_DMA_DIRECTION!, %!STATUS!",
506 status
507 );
508
510
511 return status;
512 }
513
514 //
515 // Initialize the adapter info from scratch given the Config structure
516 // then copy it to the appropriate channel and do the allocation.
517 //
518 RtlZeroMemory(&deviceDescription, sizeof(DEVICE_DESCRIPTION));
519
520 deviceDescription.Version = DEVICE_DESCRIPTION_VERSION3;
521 deviceDescription.MaximumLength = m_MaximumLength;
522
523 deviceDescription.DemandMode = Config->DemandMode;
524 deviceDescription.AutoInitialize = Config->LoopedTransfer;
525
526 deviceDescription.DmaWidth = Config->DmaWidth;
527
528 deviceDescription.DeviceAddress = Config->DeviceAddress;
529
530 //
531 // Pull the remainder of the description from the provided resource.
532 //
533 deviceDescription.InterfaceType = Internal;
534 deviceDescription.DmaChannel = Config->DmaDescriptor->u.Dma.Channel;
535 deviceDescription.DmaRequestLine = Config->DmaDescriptor->u.Dma.Port;
536
537
538 //
539 // Run the common adapter configuration.
540 //
542 &deviceDescription,
544 );
545
546 if (!NT_SUCCESS(status)) {
547 goto End;
548 }
549
550 //
551 // Allocate a single SGList to pass to MapTransferEx. Since we
552 // only run a single system transfer at a time we can use the same
553 // list for each transfer
554 //
555
556 {
557 size_t systemSGListSize = 0;
558
559 if (m_IsDuplexTransfer) {
560
561 systemSGListSize = max(GetReadDmaDescription()->PreallocatedSGListSize,
562 GetWriteDmaDescription()->PreallocatedSGListSize);
563 } else {
564
566 }
567
568 //
569 // Allocate the SG list.
570 //
571 m_SGList.SystemProfile.List =
573 systemSGListSize,
575
576 if (m_SGList.SystemProfile.List == NULL) {
580 "Unable to allocate scatter gather list for system DMA "
581 "enabler %p, %!STATUS!",
583 );
584 goto End;
585 }
586
588 m_SGListSize = systemSGListSize;
589 }
590
591 //
592 // For a simple enabler, both of these calls will return the same
593 // DMA description entry.
594 //
597 )->AdapterObject != NULL) &&
600 )->AdapterObject != NULL)) {
602 }
603
604End:
605
606 return status;
607}
WDF_DMA_PROFILE m_Profile
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define NonPagedPool
Definition: env_spec_w32.h:307
@ Internal
Definition: restypes.h:121
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
PHYSICAL_ADDRESS DeviceAddress
Definition: iotypes.h:2089
BOOLEAN AutoInitialize
Definition: iotypes.h:2073
DMA_WIDTH DmaWidth
Definition: iotypes.h:2081
INTERFACE_TYPE InterfaceType
Definition: iotypes.h:2080
BOOLEAN DemandMode
Definition: iotypes.h:2072
#define max(a, b)
Definition: svc.c:63
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
struct _SCATTER_GATHER_LIST * PSCATTER_GATHER_LIST
Definition: iotypes.h:2206
#define DEVICE_DESCRIPTION_VERSION3
Definition: iotypes.h:2066

◆ Dispose()

BOOLEAN FxDmaEnabler::Dispose ( VOID  )
virtual

Reimplemented from FxObject.

Definition at line 106 of file fxdmaenabler.cpp.

107{
109
110 if (m_IsAdded) {
113 }
114
115 return TRUE;
116}
virtual VOID RemoveDmaEnabler(__inout FxDmaEnabler *Enabler)
Definition: fxdevice.hpp:329
VOID ReleaseResources(VOID)
CfxDeviceBase * m_DeviceBase
Definition: fxobject.hpp:328

◆ FreeCommonBuffer()

VOID FxDmaEnabler::FreeCommonBuffer ( __in size_t  Length,
__in PVOID  BufferVA,
__in PHYSICAL_ADDRESS  BufferPA 
)

Definition at line 1095 of file fxdmaenabler.cpp.

1100{
1101 PDMA_ADAPTER adapterObject;
1102
1103 adapterObject = GetReadDmaDescription()->AdapterObject;
1104
1105 adapterObject->DmaOperations->
1106 FreeCommonBuffer( adapterObject,
1107 (ULONG) Length,
1108 BufferPA,
1109 BufferVA,
1110 TRUE /* CacheEnabled */ );
1111}
VOID FreeCommonBuffer(__in size_t Length, __in PVOID BufferVA, __in PHYSICAL_ADDRESS BufferPA)

Referenced by FreeCommonBuffer(), and FxCommonBuffer::FreeCommonBuffer().

◆ FreeResources()

VOID FxDmaEnabler::FreeResources ( __inout FxDmaDescription AdapterInfo)
private

Definition at line 887 of file fxdmaenabler.cpp.

890{
891 if (AdapterInfo->AdapterObject != NULL) {
892 AdapterInfo->AdapterObject->DmaOperations->PutDmaAdapter(AdapterInfo->AdapterObject);
893 AdapterInfo->AdapterObject = NULL;
894 }
895}

Referenced by ReleaseResources().

◆ GetAlignment()

__inline size_t FxDmaEnabler::GetAlignment ( VOID  )
inline

Definition at line 153 of file fxdmaenabler.hpp.

156 {
158 }

Referenced by FxCommonBuffer::FxCommonBuffer().

◆ GetDeviceHandle()

__inline WDFDEVICE FxDmaEnabler::GetDeviceHandle ( VOID  )
inline

Definition at line 171 of file fxdmaenabler.hpp.

174 {
175
176 return m_DeviceBase->GetHandle();
177 }
WDFDEVICE __inline GetHandle(VOID)
Definition: fxdevice.hpp:237

◆ GetDmaDescription()

__inline FxDmaDescription * FxDmaEnabler::GetDmaDescription ( __in WDF_DMA_DIRECTION  Direction)
inline

Definition at line 245 of file fxdmaenabler.hpp.

248 {
249 if (m_IsDuplexTransfer) {
251 }
252 else {
253 return &m_SimplexAdapterInfo;
254 }
255 }
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction

Referenced by ConfigureDmaAdapter(), ConfigureSystemAdapter(), InitializeTransferContext(), and UsesDmaV3().

◆ GetHandle()

__inline WDFDMAENABLER FxDmaEnabler::GetHandle ( VOID  )
inline

Definition at line 162 of file fxdmaenabler.hpp.

165 {
166 return (WDFDMAENABLER) GetObjectHandle();
167 }
return pObject GetObjectHandle()

Referenced by if(), and FxDmaPacketTransaction::StartTransfer().

◆ GetMaximumLength()

__inline size_t FxDmaEnabler::GetMaximumLength ( VOID  )
inline

Definition at line 140 of file fxdmaenabler.hpp.

143 {
144 //
145 // This value is same for all the channels and equal to the value
146 // provided in the DMA_ENABLER_CONFIG.
147 //
149 }

◆ GetMaxSGElements()

__inline size_t FxDmaEnabler::GetMaxSGElements ( VOID  )
inline

Definition at line 181 of file fxdmaenabler.hpp.

184 {
185 return m_MaxSGElements;
186 }

Referenced by FxDmaScatterGatherTransaction::_AdapterListControl().

◆ GetProfile()

__inline WDF_DMA_PROFILE FxDmaEnabler::GetProfile ( VOID  )
inline

Definition at line 199 of file fxdmaenabler.hpp.

202 {
203 return m_Profile;
204 }

◆ GetReadDmaDescription()

◆ GetTransferContextSize()

USHORT FxDmaEnabler::GetTransferContextSize ( VOID  )
inline

Definition at line 303 of file fxdmaenabler.hpp.

306 {
308 }
BOOLEAN UsesDmaV3(VOID)
#define DMA_TRANSFER_CONTEXT_SIZE_V1
Definition: iotypes.h:2148

◆ GetWriteDmaDescription()

__inline FxDmaDescription * FxDmaEnabler::GetWriteDmaDescription ( VOID  )
inline

◆ Initialize()

_Must_inspect_result_ NTSTATUS FxDmaEnabler::Initialize ( __in PWDF_DMA_ENABLER_CONFIG  Config,
__inout FxDeviceBase Device 
)

Definition at line 120 of file fxdmaenabler.cpp.

124{
126 DEVICE_DESCRIPTION deviceDescription;
128
129#ifndef __REACTOS__
130 ULONG mapRegistersAllocated;
131#endif
132 RtlZeroMemory(&deviceDescription, sizeof(DEVICE_DESCRIPTION));
133
134 //
135 // Default to version 2 description (except on ARM platforms)
136 //
137
138#ifdef _ARM_
139 deviceDescription.Version = DEVICE_DESCRIPTION_VERSION3;
140#else
141 deviceDescription.Version = DEVICE_DESCRIPTION_VERSION2;
142#endif
143
144 //
145 // Make sure the device's list of enablers has been created.
146 //
147
148 status = Device->AllocateDmaEnablerList();
149 if (!NT_SUCCESS(status)) {
151 "Unable to allocate DmaEnablerList for "
152 "WDFDEVICE %p, %!STATUS!",
153 Device->GetHandle(), status);
154 return status;
155 }
156
157 //
158 // Retain parent FxDeviceBase object
159 //
161
162 //
163 // Save the profile.
164 //
165 m_Profile = Config->Profile;
166
167 //
168 // Invariant parameters vis-a-vis kernel-mode bus-mastering DMA APIs
169 // (overrided below if using system-DMA
170 //
171 deviceDescription.Master = TRUE;
172 deviceDescription.Dma32BitAddresses = TRUE;
173 deviceDescription.InterfaceType = PCIBus;
174
175 //
176 // Assume enabler is a bus-master
177 //
179
180 //
181 // Expand the profile into settings.
182 //
183 switch (m_Profile) {
184 //
185 // Packet based profiles.
186 //
187
189 deviceDescription.ScatterGather = FALSE;
190 deviceDescription.Dma64BitAddresses = FALSE;
191 break;
193 deviceDescription.ScatterGather = FALSE;
194 deviceDescription.Dma64BitAddresses = TRUE;
195 break;
196
197 //
198 // Scatter-gather profiles
199 //
200
202 deviceDescription.ScatterGather = TRUE;
203 deviceDescription.Dma64BitAddresses = FALSE;
205 break;
207 deviceDescription.ScatterGather = TRUE;
208 deviceDescription.Dma64BitAddresses = FALSE;
211 break;
213 deviceDescription.ScatterGather = TRUE;
214 deviceDescription.Dma64BitAddresses = TRUE;
216 break;
218 deviceDescription.ScatterGather = TRUE;
219 deviceDescription.Dma64BitAddresses = TRUE;
222 break;
223
224 //
225 // Non-PC System-mode (non-bus-mastering) profiles. These
226 // require DMA v3.
227 //
228
230 deviceDescription.ScatterGather = FALSE;
231 deviceDescription.Master = FALSE;
232 deviceDescription.Dma32BitAddresses = FALSE;
233 deviceDescription.Dma64BitAddresses = FALSE;
234 deviceDescription.Version = DEVICE_DESCRIPTION_VERSION3;
237 break;
239 deviceDescription.ScatterGather = FALSE;
240 deviceDescription.Master = FALSE;
241 deviceDescription.Dma32BitAddresses = FALSE;
242 deviceDescription.Dma64BitAddresses = FALSE;
243 deviceDescription.Version = DEVICE_DESCRIPTION_VERSION3;
247 break;
248
249 //
250 // Unknown profile.
251 //
252
253 default:
254 //
255 // Just do quick exit as no resource have been allocated.
256 //
258 }
259
260 //
261 // Save the maximum length.
262 //
263 m_MaximumLength = (ULONG) Config->MaximumLength;
264
265 //
266 // An override of address width requires the DMA v3 engine. it also requires
267 // that we explicitly specify the DMA width the controller can support, but
268 // we do that down below.
269 //
270 if (Config->AddressWidthOverride != 0) {
271
272 //
273 // Address width override is not supported for system mode DMA, since
274 // the HAL runs the DMA controller in that case and it knows the
275 // controller's address limitations better than the driver does.
276 //
277 if (m_IsBusMaster == FALSE) {
281 "AddressWidthOverride set to %d. AddressWidthOverride "
282 "must be zero when using a system DMA profile "
283 "(%!WDF_DMA_PROFILE!) - %!STATUS!",
284 Config->AddressWidthOverride,
285 Config->Profile,
286 status
287 );
289 return status;
290 }
291
292 if ((deviceDescription.Dma64BitAddresses == FALSE) &&
293 (Config->AddressWidthOverride > 32)) {
297 "AddressWidthOverride set to %d. AddressWidthOverride "
298 "must be <= 32 when using a 32-bit DMA profile "
299 "(%!WDF_DMA_PROFILE!) - %!STATUS!",
300 Config->AddressWidthOverride,
301 Config->Profile,
302 status
303 );
305 return status;
306 }
307
308 //
309 // Handle the AddressWidthOverride. For Win8 use DMA v3 and pass the
310 // value through to the HAL. For Win7 downgrade to the next lower
311 // address width.
312 //
314 deviceDescription.Version = DEVICE_DESCRIPTION_VERSION3;
315 deviceDescription.DmaAddressWidth = Config->AddressWidthOverride;
316 }
317 else {
318
319 NT_ASSERTMSGW(L"Ensure driver is not doing something earlier that "
320 L"would require DMA v3 before we downgrade them to "
321 L"DMA v2",
322 (deviceDescription.Version == DEVICE_DESCRIPTION_VERSION2));
323
324 if (Config->AddressWidthOverride < 64) {
325 deviceDescription.Dma64BitAddresses = FALSE;
326 }
327
328 if (Config->AddressWidthOverride < 32) {
329 deviceDescription.Dma32BitAddresses = FALSE;
330 }
331
332 //
333 // DMA V2 can't handle an address width restriction smaller than
334 // 24 bits (ISA DMA). DMA V3 will fail that also - return the same
335 // error here that DMA V3 would have.
336 //
337 if (Config->AddressWidthOverride < 24) {
340 "AddressWidthOverride of less than 24 bits is not supported"
341 );
342 return STATUS_UNSUCCESSFUL;
343 }
344 else if ((Config->AddressWidthOverride != 64) &&
345 (Config->AddressWidthOverride != 32)) {
346
347 //
348 // Log a warning about downgrading DMA if we are actually
349 // downgrading. if the caller uses a 64-bit DMA
350 // profile with an override of 64, or 32-bit with an override
351 // of 32 then silently let it go through.
352 //
353
356 "DMA AddressWidthOverride requires Windows version 6.2 or "
357 "higher. Windows cannot support %d bit DMA is falling back to "
358 "the next lower supported width (%d-bit)",
359 Config->AddressWidthOverride,
360 (deviceDescription.Dma32BitAddresses ? 32 : 24)
361 );
362 }
363 }
364 }
365
366 //
367 // Allow for a specific version override (and fail if
368 // that override is inconsistent with the settings). On Win7 this will
369 // fail when we get the DMA adapter.
370 //
371 if (Config->WdmDmaVersionOverride != 0) {
372
373 if (Config->WdmDmaVersionOverride < deviceDescription.Version) {
375
376 //
377 // Driver is asking for a lower version of the DMA engine than the
378 // config settings imply it needs. Fail with invalid parameter.
379 //
380
382 "WdmDmaVersionOverride set to %d, conflicts with required version of %d, "
383 "%!STATUS!",
384 Config->WdmDmaVersionOverride,
385 deviceDescription.Version,
386 status
387 );
388
390 return status;
391 }
392
393 deviceDescription.Version = Config->WdmDmaVersionOverride;
394 }
395
396 //
397 // Propagate some settings from the old engine's location to the new ones.
398 //
399 if (deviceDescription.Version >= DEVICE_DESCRIPTION_VERSION3) {
400
401 if (deviceDescription.DmaAddressWidth == 0) {
402
403 if (deviceDescription.Dma64BitAddresses) {
404 deviceDescription.DmaAddressWidth = 64;
405 } else if (deviceDescription.Dma32BitAddresses) {
406 deviceDescription.DmaAddressWidth = 32;
407 } else {
408 //
409 // Assume ISA access width.
410 //
411
412 deviceDescription.DmaAddressWidth = 24;
413 }
414 }
415 }
416
417 //
418 // Get the FDO
419 //
421 ASSERT(m_FDO != NULL);
422
423 //
424 // Get the PDO. PDO may be NULL in the miniport case, but on
425 // x86 that will still allow for DMA (IoGetDmaAdapter special
426 // cases that on x86). On amd64 the attempt to get the DMA
427 // adapter later will fail cleanly.
428 //
430#ifndef __REACTOS__
431 mapRegistersAllocated = 0;
432#endif
433 //
434 // If this device is a bus-master then configure the profile
435 // right now, since we don't need to wait for PrepareHardware
436 // to find out the DMA resource.
437 //
438 if (m_IsBusMaster) {
439 status = ConfigureBusMasterAdapters(&deviceDescription, Config);
440 if (!NT_SUCCESS(status)) {
441 goto End;
442 }
443 }
444
445 //
446 // Retain the Power event callbacks.
447 //
448 m_EvtDmaEnablerFill.m_Method = Config->EvtDmaEnablerFill;
449 m_EvtDmaEnablerFlush.m_Method = Config->EvtDmaEnablerFlush;
450 m_EvtDmaEnablerEnable.m_Method = Config->EvtDmaEnablerEnable;
451 m_EvtDmaEnablerDisable.m_Method = Config->EvtDmaEnablerDisable;
452 m_EvtDmaEnablerSelfManagedIoStart.m_Method = Config->EvtDmaEnablerSelfManagedIoStart;
453 m_EvtDmaEnablerSelfManagedIoStop.m_Method = Config->EvtDmaEnablerSelfManagedIoStop;
454
455 //
456 // Add this DmaEnabler to the parent device's list of dma enablers.
457 //
459 m_IsAdded = TRUE;
460
461 //
462 // update hardware info for Telemetry
463 //
464 if (m_IsBusMaster) {
466 }
467
468 //
469 // Success:
470 //
472
473End:
474 //
475 // If errors then clean-up resources accumulated.
476 //
477 if (!NT_SUCCESS(status)) {
479 }
480
481 return status;
482}
virtual VOID SetDeviceTelemetryInfoFlags(_In_ FxDeviceInfoFlags Flag)
Definition: fxdevice.hpp:341
MdDeviceObject __inline GetPhysicalDevice(VOID)
Definition: fxdevice.hpp:228
MdDeviceObject __inline GetDeviceObject(VOID)
Definition: fxdevice.hpp:174
virtual VOID AddDmaEnabler(__inout FxDmaEnabler *Enabler)
Definition: fxdevice.hpp:317
_Must_inspect_result_ NTSTATUS ConfigureBusMasterAdapters(__in PDEVICE_DESCRIPTION DeviceDescription, __in PWDF_DMA_ENABLER_CONFIG Config)
#define L(x)
Definition: resources.c:13
__inline _Must_inspect_result_ BOOLEAN IsOsVersionGreaterThanOrEqualTo(__in ULONG Major, __in ULONG Minor)
Definition: fxglobals.h:1094
@ DeviceInfoDmaBusMaster
@ DeviceInfoDmaSystem
@ DeviceInfoDmaSystemDuplex
if(dx< 0)
Definition: linetemp.h:194
@ PCIBus
Definition: restypes.h:126
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
BOOLEAN Dma64BitAddresses
Definition: iotypes.h:2077
BOOLEAN ScatterGather
Definition: iotypes.h:2071
BOOLEAN Dma32BitAddresses
Definition: iotypes.h:2074
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
_Must_inspect_result_ _In_ WDFDEVICE Device
Definition: wdfchildlist.h:474
@ WdfDmaProfileScatterGather
Definition: wdfdmaenabler.h:55
@ WdfDmaProfilePacket
Definition: wdfdmaenabler.h:54
@ WdfDmaProfileScatterGatherDuplex
Definition: wdfdmaenabler.h:58
@ WdfDmaProfileSystem
Definition: wdfdmaenabler.h:60
@ WdfDmaProfileSystemDuplex
Definition: wdfdmaenabler.h:61
@ WdfDmaProfilePacket64
Definition: wdfdmaenabler.h:56
@ WdfDmaProfileScatterGather64Duplex
Definition: wdfdmaenabler.h:59
@ WdfDmaProfileScatterGather64
Definition: wdfdmaenabler.h:57
#define DEVICE_DESCRIPTION_VERSION2
Definition: iotypes.h:2065
#define NT_ASSERTMSGW
Definition: rtlfuncs.h:3329

◆ InitializeResources()

_Must_inspect_result_ NTSTATUS FxDmaEnabler::InitializeResources ( __inout FxDmaDescription AdapterInfo)
private

Definition at line 786 of file fxdmaenabler.cpp.

789{
792
793 NT_ASSERTMSG("expected caller to set DMA version",
794 AdapterInfo->DeviceDescription.Version != 0);
795
796 //
797 // Submit IoGetDmaAdapter and retain the DmaAdapter pointer.
798 //
799 AdapterInfo->AdapterObject =
801 &AdapterInfo->DeviceDescription,
802 (PULONG)&AdapterInfo->NumberOfMapRegisters);
803
804 if (AdapterInfo->AdapterObject == NULL) {
807 "Unable to allocate DmaAdapter object for "
808 "WDFDMAENABLER %p, %!STATUS!",
809 GetHandle(), status);
810 return status;
811 }
812
813 //
814 // Calculate the size of the SGList.
815 //
816 if (m_IsScatterGather) {
817
818 //
819 // For scatter gather DMA we ask the HAL how many bytes it needs for
820 // each SGList. The HAL allocates some scratch space of its own in
821 // each SGList, which BuildScatterGatherList depends on.
822 //
823 ULONG mapRegistersCount;
824
825 status = AdapterInfo->AdapterObject->DmaOperations->
826 CalculateScatterGatherList( AdapterInfo->AdapterObject,
827 NULL, // Optional MDL
828 NULL, // CurrentVa
829 AdapterInfo->NumberOfMapRegisters * PAGE_SIZE,
830 (PULONG) &AdapterInfo->PreallocatedSGListSize,
831 &mapRegistersCount);
832
833 if (!NT_SUCCESS(status)) {
836 "CalculateScatterGatherList failed for "
837 "WDFDMAENABLER %p, %!STATUS!", GetHandle(), status);
838 return status;
839 }
840
841 ASSERT(AdapterInfo->NumberOfMapRegisters == mapRegistersCount);
842
843 } else if (m_IsBusMaster) {
844
845 //
846 // For packet based DMA we only need a single SGList entry because
847 // the HAL moves all of the data into a single continguous buffer
848 //
849 AdapterInfo->PreallocatedSGListSize = sizeof(SCATTER_GATHER_LIST) +
851
852 } else {
853
854 //
855 // For system DMA we need a single SGList entry per map-register
856 //
857 AdapterInfo->PreallocatedSGListSize = sizeof(SCATTER_GATHER_LIST) +
858 (sizeof(SCATTER_GATHER_ELEMENT) *
859 AdapterInfo->NumberOfMapRegisters);
860 }
861
862 ASSERT(AdapterInfo->NumberOfMapRegisters > 1);
863
864 AdapterInfo->MaximumFragmentLength = FxSizeTMin(m_MaximumLength,
865 ((size_t) (AdapterInfo->NumberOfMapRegisters - 1)) << PAGE_SHIFT);
866
868 "WDFDMAENABLER %p, profile %!WDF_DMA_PROFILE! "
869 "DmaAdapterObject %p, MapRegisters %d, "
870 "MaximumFragmentLength %I64d ", GetHandle(), m_Profile,
871 AdapterInfo->AdapterObject,
872 AdapterInfo->NumberOfMapRegisters,
873 AdapterInfo->MaximumFragmentLength);
874
875 if (AdapterInfo->MaximumFragmentLength < m_MaximumLength) {
877 "The maximum transfer length for WDFDMAENABLER %p "
878 "is reduced to %I64d from %I64d due to mapregisters limit",
880 AdapterInfo->MaximumFragmentLength);
881 }
882
883 return STATUS_SUCCESS;
884}
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define PAGE_SHIFT
Definition: env_spec_w32.h:45
__inline size_t FxSizeTMin(__in size_t A, __in size_t B)
Definition: fxglobals.h:997
PDMA_ADAPTER NTAPI IoGetDmaAdapter(IN PDEVICE_OBJECT PhysicalDeviceObject, IN PDEVICE_DESCRIPTION DeviceDescription, IN OUT PULONG NumberOfMapRegisters)
Definition: pnpdma.c:23
uint32_t * PULONG
Definition: typedefs.h:59
struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST
Definition: iotypes.h:2206
#define NT_ASSERTMSG
Definition: rtlfuncs.h:3328

Referenced by ConfigureDmaAdapter().

◆ InitializeTransferContext()

VOID FxDmaEnabler::InitializeTransferContext ( __out PVOID  Context,
__in WDF_DMA_DIRECTION  Direction 
)

Definition at line 1114 of file fxdmaenabler.cpp.

1118{
1120
1122 "should not call this routine if enabler is not using DMAv3",
1123 UsesDmaV3()
1124 );
1125
1126 PDMA_OPERATIONS dmaOperations =
1127 adapter->DmaOperations;
1128
1130}
return adapter
PINITIALIZE_DMA_TRANSFER_CONTEXT InitializeDmaTransferContext
Definition: iotypes.h:2653

Referenced by FxDmaTransactionBase::Initialize(), and FxDmaPacketTransaction::ReserveAdapter().

◆ IsBusMaster()

◆ IsPacketBased()

__inline BOOLEAN FxDmaEnabler::IsPacketBased ( )
inline

Definition at line 237 of file fxdmaenabler.hpp.

239 {
240 return m_IsScatterGather ? FALSE : TRUE ;
241 }

◆ PowerDown()

_Must_inspect_result_ NTSTATUS FxDmaEnabler::PowerDown ( VOID  )

Definition at line 993 of file fxdmaenabler.cpp.

996{
998 NTSTATUS localStatus;
1000 WDFDMAENABLER handle = GetHandle();
1002
1004 "WDFDMAENABLER %p: PowerDown notification", GetHandle());
1005
1006 do {
1007
1009
1011
1012 if (!NT_SUCCESS(localStatus)) {
1014 status = (NT_SUCCESS(status)) ? localStatus : status;
1015 }
1016 }
1017
1020 {
1021 localStatus = m_EvtDmaEnablerDisable.Invoke( handle );
1022
1023 if (!NT_SUCCESS(localStatus)) {
1025 status = (NT_SUCCESS(status)) ? localStatus : status;
1026 }
1027 }
1028
1032 {
1033 localStatus = m_EvtDmaEnablerFlush.Invoke( handle );
1034
1035 if (!NT_SUCCESS(localStatus)) {
1037 status = (NT_SUCCESS(status)) ? localStatus : status;
1038 }
1039 }
1040
1041 } WHILE (0);
1042
1043 if (!NT_SUCCESS(status)) {
1045 "WDFDMAENABLER %p: PowerDown: "
1046 "%!WdfDmaEnablerCallback! failed %!STATUS!",
1047 GetHandle(), tag, status);
1048 }
1049
1050 return status;
1051}
NTSTATUS Invoke(__in WDFDMAENABLER Handle)
NTSTATUS Invoke(__in WDFDMAENABLER Handle)
NTSTATUS Invoke(__in WDFDMAENABLER Handle)
FxDmaEnablerCallbacks
@ FxEvtDmaEnablerDisable
@ FxEvtDmaEnablerFlush
@ FxEvtDmaEnablerSelfManagedIoStop
@ FxEvtDmaEnablerInvalid
#define WHILE(constant)
Definition: fxmacros.hpp:226
Definition: ecma_167.h:138

◆ PowerUp()

_Must_inspect_result_ NTSTATUS FxDmaEnabler::PowerUp ( VOID  )

Definition at line 934 of file fxdmaenabler.cpp.

937{
940 WDFDMAENABLER handle = GetHandle();
942
944 "WDFDMAENABLER %p: PowerUp notification", GetHandle());
945
946 do {
948
950
951 if (!NT_SUCCESS(status)) {
954 break;
955 }
956 }
957
959
961
962 if (!NT_SUCCESS(status)) {
965 break;
966 }
967 }
968
970
972
973 if (!NT_SUCCESS(status)) {
976 break;
977 }
978 }
979
980 } WHILE (0);
981
982 if (!NT_SUCCESS(status)) {
984 "WDFDMAENABLER %p: PowerUp: "
985 "%!WdfDmaEnablerCallback! failed %!STATUS!",
986 GetHandle(), tag, status);
987 }
988 return status;
989}
NTSTATUS Invoke(__in WDFDMAENABLER Handle)
NTSTATUS Invoke(__in WDFDMAENABLER Handle)
NTSTATUS Invoke(__in WDFDMAENABLER Handle)
@ FxEvtDmaEnablerSelfManagedIoStart
@ FxEvtDmaEnablerEnable
@ FxEvtDmaEnablerFill

◆ ReleaseResources()

VOID FxDmaEnabler::ReleaseResources ( VOID  )
private

Definition at line 898 of file fxdmaenabler.cpp.

901{
904
906
907}
VOID FreeResources(__inout FxDmaDescription *AdapterInfo)

Referenced by Dispose(), and Initialize().

◆ RevokeResources()

VOID FxDmaEnabler::RevokeResources ( VOID  )

Definition at line 910 of file fxdmaenabler.cpp.

913{
914 //
915 // Give back any system DMA resources allocated for this device
916 //
917
918 if (m_IsBusMaster == FALSE)
919 {
920
921
922
923
924
925 }
926}

◆ SetMaxSGElements()

__inline VOID FxDmaEnabler::SetMaxSGElements ( __in size_t  MaximumSGElements)
inline

Definition at line 190 of file fxdmaenabler.hpp.

193 {
194 m_MaxSGElements = (ULONG) MaximumSGElements;
195 }

◆ SupportsChainedMdls()

__inline BOOLEAN FxDmaEnabler::SupportsChainedMdls ( VOID  )
inline

Definition at line 208 of file fxdmaenabler.hpp.

211 {
212 //
213 // The only case where we don't support chained MDLS is DMAV2
214 // with packet mode.
215 //
216
217 if ((UsesDmaV3() == false) &&
218 (m_IsBusMaster == TRUE) &&
220 return false;
221 } else {
222 return true;
223 }
224 }

◆ UsesDmaV3()

Friends And Related Function Documentation

◆ FxDmaPacketTransaction

Definition at line 69 of file fxdmaenabler.hpp.

◆ FxDmaScatterGatherTransaction

Definition at line 70 of file fxdmaenabler.hpp.

◆ FxDmaSystemTransaction

Definition at line 71 of file fxdmaenabler.hpp.

◆ FxDmaTransactionBase

friend class FxDmaTransactionBase
friend

Definition at line 68 of file fxdmaenabler.hpp.

Member Data Documentation

◆ 

union { ... } FxDmaEnabler::@5117

◆ List

PSCATTER_GATHER_LIST FxDmaEnabler::List

Definition at line 418 of file fxdmaenabler.hpp.

◆ Lookaside

NPAGED_LOOKASIDE_LIST FxDmaEnabler::Lookaside

Definition at line 406 of file fxdmaenabler.hpp.

◆ m_CommonBufferAlignment

ULONG FxDmaEnabler::m_CommonBufferAlignment
protected

Definition at line 371 of file fxdmaenabler.hpp.

Referenced by ConfigureBusMasterAdapters(), FxDmaEnabler(), and GetAlignment().

◆ m_DmaEnablerEnableFailed

BOOLEAN FxDmaEnabler::m_DmaEnablerEnableFailed
private

Definition at line 444 of file fxdmaenabler.hpp.

Referenced by FxDmaEnabler(), PowerDown(), and PowerUp().

◆ m_DmaEnablerFillFailed

BOOLEAN FxDmaEnabler::m_DmaEnablerFillFailed
private

Definition at line 443 of file fxdmaenabler.hpp.

Referenced by FxDmaEnabler(), PowerDown(), and PowerUp().

◆ m_DmaEnablerSelfManagedIoStartFailed

BOOLEAN FxDmaEnabler::m_DmaEnablerSelfManagedIoStartFailed
private

Definition at line 445 of file fxdmaenabler.hpp.

Referenced by FxDmaEnabler(), and PowerUp().

◆ m_DuplexAdapterInfo

◆ m_EvtDmaEnablerDisable

FxEvtDmaEnablerDisableCallback FxDmaEnabler::m_EvtDmaEnablerDisable
private

Definition at line 436 of file fxdmaenabler.hpp.

Referenced by FxDmaEnabler(), Initialize(), and PowerDown().

◆ m_EvtDmaEnablerEnable

FxEvtDmaEnablerEnableCallback FxDmaEnabler::m_EvtDmaEnablerEnable
private

Definition at line 435 of file fxdmaenabler.hpp.

Referenced by FxDmaEnabler(), Initialize(), and PowerUp().

◆ m_EvtDmaEnablerFill

FxEvtDmaEnablerFillCallback FxDmaEnabler::m_EvtDmaEnablerFill
private

Definition at line 433 of file fxdmaenabler.hpp.

Referenced by FxDmaEnabler(), Initialize(), and PowerUp().

◆ m_EvtDmaEnablerFlush

FxEvtDmaEnablerFlushCallback FxDmaEnabler::m_EvtDmaEnablerFlush
private

Definition at line 434 of file fxdmaenabler.hpp.

Referenced by FxDmaEnabler(), Initialize(), and PowerDown().

◆ m_EvtDmaEnablerSelfManagedIoStart

FxEvtDmaEnablerSelfManagedIoStartCallback FxDmaEnabler::m_EvtDmaEnablerSelfManagedIoStart
private

Definition at line 437 of file fxdmaenabler.hpp.

Referenced by FxDmaEnabler(), Initialize(), and PowerUp().

◆ m_EvtDmaEnablerSelfManagedIoStop

FxEvtDmaEnablerSelfManagedIoStopCallback FxDmaEnabler::m_EvtDmaEnablerSelfManagedIoStop
private

Definition at line 438 of file fxdmaenabler.hpp.

Referenced by FxDmaEnabler(), Initialize(), and PowerDown().

◆ m_FDO

◆ m_IsAdded

BOOLEAN FxDmaEnabler::m_IsAdded
protected

Definition at line 343 of file fxdmaenabler.hpp.

Referenced by Dispose(), FxDmaEnabler(), and Initialize().

◆ m_IsBusMaster

BOOLEAN FxDmaEnabler::m_IsBusMaster
protected

◆ m_IsConfigured

BOOLEAN FxDmaEnabler::m_IsConfigured
protected

◆ m_IsDuplexTransfer

◆ m_IsScatterGather

BOOLEAN FxDmaEnabler::m_IsScatterGather
protected

◆ m_IsSGListAllocated

BOOLEAN FxDmaEnabler::m_IsSGListAllocated
protected

◆ m_MaximumLength

ULONG FxDmaEnabler::m_MaximumLength
protected

◆ m_MaxSGElements

◆ m_PDO

PDEVICE_OBJECT FxDmaEnabler::m_PDO
protected

Definition at line 320 of file fxdmaenabler.hpp.

Referenced by FxDmaEnabler(), Initialize(), and InitializeResources().

◆ m_Profile

WDF_DMA_PROFILE FxDmaEnabler::m_Profile
protected

◆ 

◆ m_SGListSize

size_t FxDmaEnabler::m_SGListSize
protected

◆ m_SimplexAdapterInfo

◆ m_TransactionLink

FxTransactionedEntry FxDmaEnabler::m_TransactionLink

Definition at line 314 of file fxdmaenabler.hpp.

Referenced by FxDmaEnabler().

◆ 

struct { ... } FxDmaEnabler::ScatterGatherProfile

◆ 

struct { ... } FxDmaEnabler::SystemProfile

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