ReactOS  0.4.15-dev-3446-g30010a5
fxcommonbuffer.hpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxCommonBuffer.hpp
8 
9 Abstract:
10 
11  WDF CommonBuffer Object support
12 
13 Environment:
14 
15  Kernel mode only.
16 
17 Notes:
18 
19 
20 Revision 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 //
32 PVOID
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 
56 public:
57 
59  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
61  );
62 
63  virtual
64  BOOLEAN
65  Dispose(
66  VOID
67  );
68 
70  NTSTATUS
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 
116 protected:
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  //
152  size_t m_RawLength;
153 
154  //
155  // Alignment of the allocated buffer.
156  //
157  size_t m_Alignment;
158 
159 };
160 
161 #endif // _FXCOMMONBUFFER_H_
__forceinline VOID SetAlignment(__in ULONG Alignment)
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
LONG NTSTATUS
Definition: precomp.h:26
PHYSICAL_ADDRESS m_BufferAlignedLA
__forceinline size_t GetLength(VOID)
union Alignment_ Alignment
unsigned char BOOLEAN
FORCEINLINE PVOID FX_ALIGN_VIRTUAL_ADDRESS(__in PVOID VA, __in size_t AlignTo)
virtual BOOLEAN Dispose(VOID)
VOID FreeCommonBuffer(VOID)
PHYSICAL_ADDRESS m_BufferRawLA
__forceinline PHYSICAL_ADDRESS GetAlignedLogicalAddress(VOID)
FORCEINLINE ULONGLONG FX_ALIGN_LOGICAL_ADDRESS(__in PHYSICAL_ADDRESS LA, __in size_t AlignTo)
uint64_t ULONGLONG
Definition: typedefs.h:67
FxDmaEnabler * m_DmaEnabler
__forceinline PVOID GetAlignedVirtualAddress(VOID)
#define _Must_inspect_result_
Definition: ms_sal.h:558
FxDmaEnabler * pDmaEnabler
_Must_inspect_result_ NTSTATUS AllocateCommonBuffer(__in size_t Length)
#define FORCEINLINE
Definition: wdftypes.h:67
FxCommonBuffer(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxDmaEnabler *pDmaEnabler)
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
#define __in
Definition: dbghelp.h:35