29#define RtlSizeTToULong RtlULongPtrToULong
130 ULONG mapRegistersAllocated;
151 "Unable to allocate DmaEnablerList for "
152 "WDFDEVICE %p, %!STATUS!",
270 if (
Config->AddressWidthOverride != 0) {
281 "AddressWidthOverride set to %d. AddressWidthOverride "
282 "must be zero when using a system DMA profile "
283 "(%!WDF_DMA_PROFILE!) - %!STATUS!",
284 Config->AddressWidthOverride,
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,
319 NT_ASSERTMSGW(
L"Ensure driver is not doing something earlier that "
320 L"would require DMA v3 before we downgrade them to "
324 if (
Config->AddressWidthOverride < 64) {
328 if (
Config->AddressWidthOverride < 32) {
337 if (
Config->AddressWidthOverride < 24) {
340 "AddressWidthOverride of less than 24 bits is not supported"
344 else if ((
Config->AddressWidthOverride != 64) &&
345 (
Config->AddressWidthOverride != 32)) {
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,
371 if (
Config->WdmDmaVersionOverride != 0) {
373 if (
Config->WdmDmaVersionOverride < deviceDescription.
Version) {
382 "WdmDmaVersionOverride set to %d, conflicts with required version of %d, "
384 Config->WdmDmaVersionOverride,
431 mapRegistersAllocated = 0;
502 "WDFDMAENABLER %p, profile %!WDF_DMA_PROFILE! "
503 "Enabler has already been configured for %!WDF_DMA_DIRECTION!, %!STATUS!",
557 size_t systemSGListSize = 0;
580 "Unable to allocate scatter gather list for system DMA "
581 "enabler %p, %!STATUS!",
597 )->AdapterObject !=
NULL) &&
600 )->AdapterObject !=
NULL)) {
652 size_t sgLookasideListSize;
654 sgLookasideListSize = 0;
794 AdapterInfo->DeviceDescription.Version != 0);
799 AdapterInfo->AdapterObject =
801 &AdapterInfo->DeviceDescription,
802 (
PULONG)&AdapterInfo->NumberOfMapRegisters);
804 if (AdapterInfo->AdapterObject ==
NULL) {
807 "Unable to allocate DmaAdapter object for "
808 "WDFDMAENABLER %p, %!STATUS!",
823 ULONG mapRegistersCount;
825 status = AdapterInfo->AdapterObject->DmaOperations->
826 CalculateScatterGatherList( AdapterInfo->AdapterObject,
829 AdapterInfo->NumberOfMapRegisters *
PAGE_SIZE,
830 (
PULONG) &AdapterInfo->PreallocatedSGListSize,
836 "CalculateScatterGatherList failed for "
841 ASSERT(AdapterInfo->NumberOfMapRegisters == mapRegistersCount);
859 AdapterInfo->NumberOfMapRegisters);
862 ASSERT(AdapterInfo->NumberOfMapRegisters > 1);
865 ((
size_t) (AdapterInfo->NumberOfMapRegisters - 1)) <<
PAGE_SHIFT);
868 "WDFDMAENABLER %p, profile %!WDF_DMA_PROFILE! "
869 "DmaAdapterObject %p, MapRegisters %d, "
871 AdapterInfo->AdapterObject,
872 AdapterInfo->NumberOfMapRegisters,
873 AdapterInfo->MaximumFragmentLength);
877 "The maximum transfer length for WDFDMAENABLER %p "
878 "is reduced to %I64d from %I64d due to mapregisters limit",
880 AdapterInfo->MaximumFragmentLength);
891 if (AdapterInfo->AdapterObject !=
NULL) {
892 AdapterInfo->AdapterObject->DmaOperations->PutDmaAdapter(AdapterInfo->AdapterObject);
893 AdapterInfo->AdapterObject =
NULL;
944 "WDFDMAENABLER %p: PowerUp notification",
GetHandle());
984 "WDFDMAENABLER %p: PowerUp: "
985 "%!WdfDmaEnablerCallback! failed %!STATUS!",
1004 "WDFDMAENABLER %p: PowerDown notification",
GetHandle());
1045 "WDFDMAENABLER %p: PowerDown: "
1046 "%!WdfDmaEnablerCallback! failed %!STATUS!",
1069 BufferPA->QuadPart = 0;
1073 "WDFDMAENABLER %p AllocateCommonBuffer: could cast value %I64d to a "
1122 "should not call this routine if enabler is not using DMAv3",
_Check_return_ _Ret_maybenull_ _In_ size_t alignment
virtual VOID RemoveDmaEnabler(__inout FxDmaEnabler *Enabler)
virtual VOID SetDeviceTelemetryInfoFlags(_In_ FxDeviceInfoFlags Flag)
MdDeviceObject __inline GetPhysicalDevice(VOID)
MdDeviceObject __inline GetDeviceObject(VOID)
virtual VOID AddDmaEnabler(__inout FxDmaEnabler *Enabler)
BOOLEAN m_IsSGListAllocated
FxDmaDescription m_SimplexAdapterInfo
BOOLEAN m_DmaEnablerFillFailed
VOID InitializeTransferContext(__out PVOID Context, __in WDF_DMA_DIRECTION Direction)
WDF_DMA_PROFILE m_Profile
_Must_inspect_result_ NTSTATUS ConfigureSystemAdapter(__in PWDF_DMA_SYSTEM_PROFILE_CONFIG Config, __in WDF_DMA_DIRECTION ConfigDirection)
BOOLEAN m_IsDuplexTransfer
_Must_inspect_result_ NTSTATUS PowerDown(VOID)
__inline FxDmaDescription * GetWriteDmaDescription(VOID)
FxDmaDescription m_DuplexAdapterInfo[FxDuplexDmaDescriptionTypeMax]
FxTransactionedEntry m_TransactionLink
_Must_inspect_result_ NTSTATUS ConfigureDmaAdapter(__in PDEVICE_DESCRIPTION DeviceDescription, __in WDF_DMA_DIRECTION ConfigDirection)
__inline FxDmaDescription * GetReadDmaDescription(VOID)
VOID AllocateCommonBuffer(__in size_t Length, __deref_out_opt PVOID *BufferVA, __out PHYSICAL_ADDRESS *BufferPA)
FxEvtDmaEnablerSelfManagedIoStopCallback m_EvtDmaEnablerSelfManagedIoStop
FxEvtDmaEnablerEnableCallback m_EvtDmaEnablerEnable
_Must_inspect_result_ NTSTATUS Initialize(__in PWDF_DMA_ENABLER_CONFIG Config, __inout FxDeviceBase *Device)
VOID RevokeResources(VOID)
_Must_inspect_result_ NTSTATUS InitializeResources(__inout FxDmaDescription *AdapterInfo)
FxEvtDmaEnablerDisableCallback m_EvtDmaEnablerDisable
FxEvtDmaEnablerSelfManagedIoStartCallback m_EvtDmaEnablerSelfManagedIoStart
FxEvtDmaEnablerFillCallback m_EvtDmaEnablerFill
virtual BOOLEAN Dispose(VOID)
BOOLEAN m_IsScatterGather
__inline FxDmaDescription * GetDmaDescription(__in WDF_DMA_DIRECTION Direction)
_Must_inspect_result_ NTSTATUS ConfigureBusMasterAdapters(__in PDEVICE_DESCRIPTION DeviceDescription, __in PWDF_DMA_ENABLER_CONFIG Config)
FxEvtDmaEnablerFlushCallback m_EvtDmaEnablerFlush
VOID FreeCommonBuffer(__in size_t Length, __in PVOID BufferVA, __in PHYSICAL_ADDRESS BufferPA)
_Must_inspect_result_ NTSTATUS PowerUp(VOID)
BOOLEAN m_DmaEnablerEnableFailed
BOOLEAN m_DmaEnablerSelfManagedIoStartFailed
ULONG m_CommonBufferAlignment
union FxDmaEnabler::@5118 m_SGList
VOID FreeResources(__inout FxDmaDescription *AdapterInfo)
FxDmaEnabler(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
VOID ReleaseResources(VOID)
PFN_WDF_DMA_ENABLER_DISABLE m_Method
NTSTATUS Invoke(__in WDFDMAENABLER Handle)
PFN_WDF_DMA_ENABLER_ENABLE m_Method
NTSTATUS Invoke(__in WDFDMAENABLER Handle)
PFN_WDF_DMA_ENABLER_FILL m_Method
NTSTATUS Invoke(__in WDFDMAENABLER Handle)
PFN_WDF_DMA_ENABLER_FLUSH m_Method
NTSTATUS Invoke(__in WDFDMAENABLER Handle)
NTSTATUS Invoke(__in WDFDMAENABLER Handle)
PFN_WDF_DMA_ENABLER_SELFMANAGED_IO_START m_Method
PFN_WDF_DMA_ENABLER_SELFMANAGED_IO_STOP m_Method
NTSTATUS Invoke(__in WDFDMAENABLER Handle)
__inline PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
CfxDeviceBase * m_DeviceBase
VOID MarkDisposeOverride(__in FxObjectLockState State=ObjectLock)
#define NT_SUCCESS(StatCode)
#define ExAllocatePoolWithTag(hernya, size, tag)
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
PFX_DRIVER_GLOBALS pFxDriverGlobals
FxVerifierDbgBreakPoint(pFxDriverGlobals)
@ FxEvtDmaEnablerSelfManagedIoStart
@ FxEvtDmaEnablerSelfManagedIoStop
__inline _Must_inspect_result_ BOOLEAN IsOsVersionGreaterThanOrEqualTo(__in ULONG Major, __in ULONG Minor)
__inline size_t FxSizeTMax(__in size_t A, __in size_t B)
__inline size_t FxSizeTMin(__in size_t A, __in size_t B)
@ DeviceInfoDmaSystemDuplex
VOID NTAPI ExDeleteNPagedLookasideList(IN PNPAGED_LOOKASIDE_LIST Lookaside)
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)
#define _Must_inspect_result_
_In_ ULONG _In_ ULONG _In_ ULONG Length
PDMA_ADAPTER NTAPI IoGetDmaAdapter(IN PDEVICE_OBJECT PhysicalDeviceObject, IN PDEVICE_DESCRIPTION DeviceDescription, IN OUT PULONG NumberOfMapRegisters)
#define TRACE_LEVEL_WARNING
#define TRACE_LEVEL_VERBOSE
#define TRACE_LEVEL_ERROR
VOID SetTransactionedObject(__in FxObject *Object)
BOOLEAN Dma64BitAddresses
PHYSICAL_ADDRESS DeviceAddress
INTERFACE_TYPE InterfaceType
BOOLEAN Dma32BitAddresses
ULONG AlignmentRequirement
struct _DMA_OPERATIONS * DmaOperations
PINITIALIZE_DMA_TRANSFER_CONTEXT InitializeDmaTransferContext
PDMA_ADAPTER AdapterObject
DEVICE_DESCRIPTION DeviceDescription
size_t PreallocatedSGListSize
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_INVALID_PARAMETER
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
_Must_inspect_result_ _In_ WDFDEVICE Device
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_CHILD_LIST_CONFIG Config
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
@ WDF_DMA_ENABLER_CONFIG_NO_SGLIST_PREALLOCATION
@ WdfDmaProfileScatterGather
@ WdfDmaProfileScatterGatherDuplex
@ WdfDmaProfileSystemDuplex
@ WdfDmaProfileScatterGather64Duplex
@ WdfDmaProfileScatterGather64
#define WDF_DMA_ENABLER_UNLIMITED_FRAGMENTS
enum _WDF_DMA_DIRECTION WDF_DMA_DIRECTION
_Must_inspect_result_ _In_ WDFDMAENABLER _In_ PWDF_DMA_SYSTEM_PROFILE_CONFIG _In_ WDF_DMA_DIRECTION ConfigDirection
@ WdfDmaDirectionReadFromDevice
@ WdfDmaDirectionWriteToDevice
WDF_EXTERN_C_START typedef _In_ WDFDEVICE _In_ WDFCONTEXT _In_ WDF_DMA_DIRECTION Direction
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING DeviceDescription
ActualNumberDriverObjects * sizeof(PDRIVER_OBJECT)) PDRIVER_OBJECT *DriverObjectList
struct _SCATTER_GATHER_LIST SCATTER_GATHER_LIST
struct _SCATTER_GATHER_LIST * PSCATTER_GATHER_LIST
#define DEVICE_DESCRIPTION_VERSION2
#define DEVICE_DESCRIPTION_VERSION3