ReactOS 0.4.16-dev-197-g92996da
fxcommonbuffer.hpp
Go to the documentation of this file.
1/*++
2
3Copyright (c) Microsoft Corporation
4
5Module Name:
6
7 FxCommonBuffer.hpp
8
9Abstract:
10
11 WDF CommonBuffer Object support
12
13Environment:
14
15 Kernel mode only.
16
17Notes:
18
19
20Revision History:
21
22--*/
23
24#ifndef _FXCOMMONBUFFER_H_
25#define _FXCOMMONBUFFER_H_
26
27//
28// Calculate an "aligned" address (Logical or Virtual) per
29// a specific alignment value.
30//
34 __in PVOID VA,
35 __in size_t AlignTo
36 )
37{
38 return (PVOID)(((ULONG_PTR)VA + AlignTo) & ~AlignTo);
39}
40
45 __in size_t AlignTo
46 )
47{
48 return (LA.QuadPart + AlignTo) & ~((ULONGLONG)AlignTo);
49}
50
51//
52// Declare the FxCommonBuffer class
53//
55
56public:
57
59 __in PFX_DRIVER_GLOBALS FxDriverGlobals,
61 );
62
63 virtual
65 Dispose(
66 VOID
67 );
68
72 __in size_t Length
73 );
74
75 VOID
77 VOID
78 );
79
80 __forceinline
83 VOID
84 )
85 {
86 return m_BufferAlignedLA;
87 }
88
89 __forceinline
90 PVOID
92 VOID
93 )
94 {
95 return m_BufferAlignedVA;
96 }
97
98 __forceinline
99 size_t
101 VOID
102 )
103 {
104 return m_Length;
105 }
106
107 __forceinline
108 VOID
111 )
112 {
114 }
115
116protected:
117
118 //
119 // Unaligned virtual address
120 //
122
123 //
124 // Aligned virtual address
125 //
127
128 //
129 // Aligned logical address
130 //
132
133 //
134 // Unaligned logical address
135 //
137
138 //
139 // Pointer to the DMA enabler
140 //
142
143 //
144 // Length specified by the caller
145 //
146 size_t m_Length;
147
148 //
149 // Actual length used to allocate buffer after adding the alignement
150 // value.
151 //
153
154 //
155 // Alignment of the allocated buffer.
156 //
158
159};
160
161#endif // _FXCOMMONBUFFER_H_
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
virtual BOOLEAN Dispose(VOID)
_Must_inspect_result_ NTSTATUS AllocateCommonBuffer(__in size_t Length)
PHYSICAL_ADDRESS m_BufferRawLA
__forceinline VOID SetAlignment(__in ULONG Alignment)
PHYSICAL_ADDRESS m_BufferAlignedLA
__forceinline size_t GetLength(VOID)
VOID FreeCommonBuffer(VOID)
__forceinline PHYSICAL_ADDRESS GetAlignedLogicalAddress(VOID)
__forceinline PVOID GetAlignedVirtualAddress(VOID)
FxDmaEnabler * m_DmaEnabler
#define __in
Definition: dbghelp.h:35
#define ULONG_PTR
Definition: config.h:101
union Alignment_ Alignment
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)
FxDmaEnabler * pDmaEnabler
#define _Must_inspect_result_
Definition: ms_sal.h:558
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
uint32_t ULONG
Definition: typedefs.h:59
uint64_t ULONGLONG
Definition: typedefs.h:67
#define FORCEINLINE
Definition: wdftypes.h:67