ReactOS 0.4.16-dev-117-g38f21f9
FxCommonBuffer Class Reference

#include <fxcommonbuffer.hpp>

Inheritance diagram for FxCommonBuffer:
Collaboration diagram for FxCommonBuffer:

Public Member Functions

 FxCommonBuffer (__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxDmaEnabler *pDmaEnabler)
 
virtual BOOLEAN Dispose (VOID)
 
_Must_inspect_result_ NTSTATUS AllocateCommonBuffer (__in size_t Length)
 
VOID FreeCommonBuffer (VOID)
 
__forceinline PHYSICAL_ADDRESS GetAlignedLogicalAddress (VOID)
 
__forceinline PVOID GetAlignedVirtualAddress (VOID)
 
__forceinline size_t GetLength (VOID)
 
__forceinline VOID SetAlignment (__in ULONG Alignment)
 
- 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)
 

Protected Attributes

PVOID m_BufferRawVA
 
PVOID m_BufferAlignedVA
 
PHYSICAL_ADDRESS m_BufferAlignedLA
 
PHYSICAL_ADDRESS m_BufferRawLA
 
FxDmaEnablerm_DmaEnabler
 
size_t m_Length
 
size_t m_RawLength
 
size_t m_Alignment
 
- Protected Attributes inherited from FxObject
union {
   CfxDeviceBase *   m_DeviceBase
 
   CfxDevice *   m_Device
 
}; 
 

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 54 of file fxcommonbuffer.hpp.

Constructor & Destructor Documentation

◆ FxCommonBuffer()

FxCommonBuffer::FxCommonBuffer ( __in PFX_DRIVER_GLOBALS  FxDriverGlobals,
__in FxDmaEnabler pDmaEnabler 
)

Definition at line 30 of file fxcommonbuffer.cpp.

33 :
35{
37 m_BufferRawVA = NULL; // allocated buffer base (unaligned)
38 m_BufferAlignedVA = NULL; // aligned buffer base
39 m_BufferAlignedLA.QuadPart = NULL; // aligned physical buffer base
40 m_BufferRawLA.QuadPart = NULL; // allocated buffer phy base (unaligned)
41 m_Length = 0;
42 m_RawLength = 0;
43
45
46 //
47 // By default use the alignment of the dma enabler.
48 //
50}
PHYSICAL_ADDRESS m_BufferRawLA
PHYSICAL_ADDRESS m_BufferAlignedLA
FxDmaEnabler * m_DmaEnabler
__inline size_t GetAlignment(VOID)
VOID MarkDisposeOverride(__in FxObjectLockState State=ObjectLock)
Definition: fxobject.hpp:1101
#define NULL
Definition: types.h:112
FxDmaEnabler * pDmaEnabler
@ ObjectDoNotLock
Definition: fxobject.hpp:128
@ FX_TYPE_COMMON_BUFFER
Definition: fxtypes.h:109
LONGLONG QuadPart
Definition: typedefs.h:114

Member Function Documentation

◆ AllocateCommonBuffer()

_Must_inspect_result_ NTSTATUS FxCommonBuffer::AllocateCommonBuffer ( __in size_t  Length)

Definition at line 61 of file fxcommonbuffer.cpp.

64{
69
70 //
71 // Must be running at PASIVE_LEVEL
72 //
74 if (!NT_SUCCESS(status)) {
75 return status;
76 }
77
79
80 //
81 // If required, add alignment to the length.
82 // If alignment is <= page-1, we actually don't need to do it b/c
83 // AllocateCommonBuffer allocates at least a page of memory, regardless
84 // of the requested Length. If driver version is < v1.11, we still add the
85 // alignment to the length for compatibility.
86 //
87 if (m_Alignment > PAGE_SIZE-1 ||
89
90 status = RtlSizeTAdd(Length, m_Alignment, &m_RawLength);
91 if (!NT_SUCCESS(status)) {
93 "WDFDMAENABLER %p AllocateCommonBuffer: overflow when adding Length "
94 "%I64d + Alignment %I64d", GetObjectHandle(), Length, m_Alignment);
96 return status;
97 }
98 }
99 else {
101 }
102
106 if (m_BufferRawVA) {
107
110
111 if (m_Alignment > PAGE_SIZE-1) {
112 //
113 // If the alignment mask is over a page-size then the aligned virtual
114 // and aligned logical could be pointing to different locations
115 // in memory. So ajdust the VA to match the LA address by adding
116 // the offset of alignedLA and RawLA to VA. By doing this we
117 // only guarantee alignment of LA when the page alignment exceeds PAGE_SIZE.
118 //
119 status = RtlULongLongSub(m_BufferAlignedLA.QuadPart,
121 &offset);
122 if (!NT_SUCCESS(status)) {
124 "WDFDMAENABLER %p AllocateCommonBuffer: overflow when subtracting "
125 "RawLA %I64x from AlignedLA %I64x",
128 return status;
129 }
130
131 status = RtlULongLongToULong(offset, &result);
132 if (!NT_SUCCESS(status)) {
134 "WDFDMAENABLER %p AllocateCommonBuffer: overflow when "
135 "converting from ULongLong %I64d to ULong",
138 return status;
139 }
140
142 }
143 else {
146 }
147 } else {
148 m_Length = 0;
149 m_RawLength = 0;
153 }
154
155 return status;
156}
LONG NTSTATUS
Definition: precomp.h:26
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 FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define PASSIVE_LEVEL
Definition: env_spec_w32.h:693
#define PAGE_SIZE
Definition: env_spec_w32.h:49
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
PFX_DRIVER_GLOBALS pFxDriverGlobals
return pObject GetObjectHandle()
FORCEINLINE ULONGLONG FX_ALIGN_LOGICAL_ADDRESS(__in PHYSICAL_ADDRESS LA, __in size_t AlignTo)
FORCEINLINE PVOID FX_ALIGN_VIRTUAL_ADDRESS(__in PVOID VA, __in size_t AlignTo)
FxVerifierDbgBreakPoint(pFxDriverGlobals)
__inline NTSTATUS FxVerifierCheckIrqlLevel(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in KIRQL Irql)
Definition: fxverifier.h:158
GLuint64EXT * result
Definition: glext.h:11304
GLintptr offset
Definition: glext.h:5920
#define ASSERT(a)
Definition: mode.c:44
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
_Must_inspect_result_ BOOLEAN IsVersionGreaterThanOrEqualTo(__in ULONG Major, __in ULONG Minor)
Definition: globalskm.cpp:92
Definition: ps.c:97
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define WDF_PTR_ADD_OFFSET(_ptr, _offset)
Definition: wdfcore.h:144

◆ Dispose()

BOOLEAN FxCommonBuffer::Dispose ( VOID  )
virtual

Reimplemented from FxObject.

Definition at line 53 of file fxcommonbuffer.cpp.

54{
56 return TRUE;
57}
VOID FreeCommonBuffer(VOID)
#define TRUE
Definition: types.h:120

◆ FreeCommonBuffer()

VOID FxCommonBuffer::FreeCommonBuffer ( VOID  )

Definition at line 159 of file fxcommonbuffer.cpp.

162{
163 //
164 // Free this CommonBuffer per DmaEnabler
165 //
166 if (m_BufferRawVA != NULL) {
170 }
171}
VOID FreeCommonBuffer(__in size_t Length, __in PVOID BufferVA, __in PHYSICAL_ADDRESS BufferPA)

Referenced by Dispose().

◆ GetAlignedLogicalAddress()

__forceinline PHYSICAL_ADDRESS FxCommonBuffer::GetAlignedLogicalAddress ( VOID  )
inline

Definition at line 82 of file fxcommonbuffer.hpp.

85 {
86 return m_BufferAlignedLA;
87 }

◆ GetAlignedVirtualAddress()

__forceinline PVOID FxCommonBuffer::GetAlignedVirtualAddress ( VOID  )
inline

Definition at line 91 of file fxcommonbuffer.hpp.

94 {
95 return m_BufferAlignedVA;
96 }

◆ GetLength()

__forceinline size_t FxCommonBuffer::GetLength ( VOID  )
inline

Definition at line 100 of file fxcommonbuffer.hpp.

103 {
104 return m_Length;
105 }

◆ SetAlignment()

__forceinline VOID FxCommonBuffer::SetAlignment ( __in ULONG  Alignment)
inline

Definition at line 109 of file fxcommonbuffer.hpp.

112 {
114 }
union Alignment_ Alignment

Member Data Documentation

◆ m_Alignment

size_t FxCommonBuffer::m_Alignment
protected

Definition at line 157 of file fxcommonbuffer.hpp.

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

◆ m_BufferAlignedLA

PHYSICAL_ADDRESS FxCommonBuffer::m_BufferAlignedLA
protected

◆ m_BufferAlignedVA

PVOID FxCommonBuffer::m_BufferAlignedVA
protected

◆ m_BufferRawLA

PHYSICAL_ADDRESS FxCommonBuffer::m_BufferRawLA
protected

Definition at line 136 of file fxcommonbuffer.hpp.

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

◆ m_BufferRawVA

PVOID FxCommonBuffer::m_BufferRawVA
protected

Definition at line 121 of file fxcommonbuffer.hpp.

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

◆ m_DmaEnabler

FxDmaEnabler* FxCommonBuffer::m_DmaEnabler
protected

Definition at line 141 of file fxcommonbuffer.hpp.

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

◆ m_Length

size_t FxCommonBuffer::m_Length
protected

Definition at line 146 of file fxcommonbuffer.hpp.

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

◆ m_RawLength

size_t FxCommonBuffer::m_RawLength
protected

Definition at line 152 of file fxcommonbuffer.hpp.

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


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