1 /*++
2 
3 Copyright (c) Microsoft Corporation.  All rights reserved.
4 
5 _WdfVersionBuild_
6 
7 Module Name:
8 
9     WdfCommonBuffer.h
10 
11 Abstract:
12 
13     WDF CommonBuffer support
14 
15 Environment:
16 
17     Kernel mode only.
18 
19 Notes:
20 
21 Revision History:
22 
23 --*/
24 
25 //
26 // NOTE: This header is generated by stubwork.  Please make any
27 //       modifications to the corresponding template files
28 //       (.x or .y) and use stubwork to regenerate the header
29 //
30 
31 #ifndef _WDFCOMMONBUFFER_H_
32 #define _WDFCOMMONBUFFER_H_
33 
34 #ifndef WDF_EXTERN_C
35   #ifdef __cplusplus
36     #define WDF_EXTERN_C       extern "C"
37     #define WDF_EXTERN_C_START extern "C" {
38     #define WDF_EXTERN_C_END   }
39   #else
40     #define WDF_EXTERN_C
41     #define WDF_EXTERN_C_START
42     #define WDF_EXTERN_C_END
43   #endif
44 #endif
45 
46 WDF_EXTERN_C_START
47 
48 
49 
50 #if (NTDDI_VERSION >= NTDDI_WIN2K)
51 
52 
53 
54 typedef struct _WDF_COMMON_BUFFER_CONFIG {
55     //
56     // Size of this structure in bytes
57     //
58     ULONG   Size;
59 
60     //
61     // Alignment requirement of the buffer address
62     //
63     ULONG   AlignmentRequirement;
64 
65 } WDF_COMMON_BUFFER_CONFIG, *PWDF_COMMON_BUFFER_CONFIG;
66 
67 FORCEINLINE
68 VOID
WDF_COMMON_BUFFER_CONFIG_INIT(_Out_ PWDF_COMMON_BUFFER_CONFIG Config,_In_ ULONG AlignmentRequirement)69 WDF_COMMON_BUFFER_CONFIG_INIT(
70     _Out_ PWDF_COMMON_BUFFER_CONFIG Config,
71     _In_  ULONG  AlignmentRequirement
72     )
73 {
74     RtlZeroMemory(Config, sizeof(WDF_COMMON_BUFFER_CONFIG));
75 
76     Config->Size = sizeof(WDF_COMMON_BUFFER_CONFIG);
77     Config->AlignmentRequirement = AlignmentRequirement;
78 }
79 
80 //
81 // WDF Function: WdfCommonBufferCreate
82 //
83 typedef
84 _Must_inspect_result_
85 _IRQL_requires_max_(PASSIVE_LEVEL)
86 WDFAPI
87 NTSTATUS
88 (STDCALL *PFN_WDFCOMMONBUFFERCREATE)(
89     _In_
90     PWDF_DRIVER_GLOBALS DriverGlobals,
91     _In_
92     WDFDMAENABLER DmaEnabler,
93     _In_
94     _When_(Length == 0, __drv_reportError(Length cannot be zero))
95     size_t Length,
96     _In_opt_
97     PWDF_OBJECT_ATTRIBUTES Attributes,
98     _Out_
99     WDFCOMMONBUFFER* CommonBuffer
100     );
101 
102 _Must_inspect_result_
_IRQL_requires_max_(PASSIVE_LEVEL)103 _IRQL_requires_max_(PASSIVE_LEVEL)
104 FORCEINLINE
105 NTSTATUS
106 WdfCommonBufferCreate(
107     _In_
108     WDFDMAENABLER DmaEnabler,
109     _In_
110     _When_(Length == 0, __drv_reportError(Length cannot be zero))
111     size_t Length,
112     _In_opt_
113     PWDF_OBJECT_ATTRIBUTES Attributes,
114     _Out_
115     WDFCOMMONBUFFER* CommonBuffer
116     )
117 {
118     return ((PFN_WDFCOMMONBUFFERCREATE) WdfFunctions[WdfCommonBufferCreateTableIndex])(WdfDriverGlobals, DmaEnabler, Length, Attributes, CommonBuffer);
119 }
120 
121 //
122 // WDF Function: WdfCommonBufferCreateWithConfig
123 //
124 typedef
125 _Must_inspect_result_
126 _IRQL_requires_max_(PASSIVE_LEVEL)
127 WDFAPI
128 NTSTATUS
129 (STDCALL *PFN_WDFCOMMONBUFFERCREATEWITHCONFIG)(
130     _In_
131     PWDF_DRIVER_GLOBALS DriverGlobals,
132     _In_
133     WDFDMAENABLER DmaEnabler,
134     _In_
135     _When_(Length == 0, __drv_reportError(Length cannot be zero))
136     size_t Length,
137     _In_
138     PWDF_COMMON_BUFFER_CONFIG Config,
139     _In_opt_
140     PWDF_OBJECT_ATTRIBUTES Attributes,
141     _Out_
142     WDFCOMMONBUFFER* CommonBuffer
143     );
144 
145 _Must_inspect_result_
_IRQL_requires_max_(PASSIVE_LEVEL)146 _IRQL_requires_max_(PASSIVE_LEVEL)
147 FORCEINLINE
148 NTSTATUS
149 WdfCommonBufferCreateWithConfig(
150     _In_
151     WDFDMAENABLER DmaEnabler,
152     _In_
153     _When_(Length == 0, __drv_reportError(Length cannot be zero))
154     size_t Length,
155     _In_
156     PWDF_COMMON_BUFFER_CONFIG Config,
157     _In_opt_
158     PWDF_OBJECT_ATTRIBUTES Attributes,
159     _Out_
160     WDFCOMMONBUFFER* CommonBuffer
161     )
162 {
163     return ((PFN_WDFCOMMONBUFFERCREATEWITHCONFIG) WdfFunctions[WdfCommonBufferCreateWithConfigTableIndex])(WdfDriverGlobals, DmaEnabler, Length, Config, Attributes, CommonBuffer);
164 }
165 
166 //
167 // WDF Function: WdfCommonBufferGetAlignedVirtualAddress
168 //
169 typedef
170 _IRQL_requires_max_(DISPATCH_LEVEL)
171 WDFAPI
172 PVOID
173 (STDCALL *PFN_WDFCOMMONBUFFERGETALIGNEDVIRTUALADDRESS)(
174     _In_
175     PWDF_DRIVER_GLOBALS DriverGlobals,
176     _In_
177     WDFCOMMONBUFFER CommonBuffer
178     );
179 
_IRQL_requires_max_(DISPATCH_LEVEL)180 _IRQL_requires_max_(DISPATCH_LEVEL)
181 FORCEINLINE
182 PVOID
183 WdfCommonBufferGetAlignedVirtualAddress(
184     _In_
185     WDFCOMMONBUFFER CommonBuffer
186     )
187 {
188     return ((PFN_WDFCOMMONBUFFERGETALIGNEDVIRTUALADDRESS) WdfFunctions[WdfCommonBufferGetAlignedVirtualAddressTableIndex])(WdfDriverGlobals, CommonBuffer);
189 }
190 
191 //
192 // WDF Function: WdfCommonBufferGetAlignedLogicalAddress
193 //
194 typedef
195 _IRQL_requires_max_(DISPATCH_LEVEL)
196 WDFAPI
197 PHYSICAL_ADDRESS
198 (STDCALL *PFN_WDFCOMMONBUFFERGETALIGNEDLOGICALADDRESS)(
199     _In_
200     PWDF_DRIVER_GLOBALS DriverGlobals,
201     _In_
202     WDFCOMMONBUFFER CommonBuffer
203     );
204 
_IRQL_requires_max_(DISPATCH_LEVEL)205 _IRQL_requires_max_(DISPATCH_LEVEL)
206 FORCEINLINE
207 PHYSICAL_ADDRESS
208 WdfCommonBufferGetAlignedLogicalAddress(
209     _In_
210     WDFCOMMONBUFFER CommonBuffer
211     )
212 {
213     return ((PFN_WDFCOMMONBUFFERGETALIGNEDLOGICALADDRESS) WdfFunctions[WdfCommonBufferGetAlignedLogicalAddressTableIndex])(WdfDriverGlobals, CommonBuffer);
214 }
215 
216 //
217 // WDF Function: WdfCommonBufferGetLength
218 //
219 typedef
220 _IRQL_requires_max_(DISPATCH_LEVEL)
221 WDFAPI
222 size_t
223 (STDCALL *PFN_WDFCOMMONBUFFERGETLENGTH)(
224     _In_
225     PWDF_DRIVER_GLOBALS DriverGlobals,
226     _In_
227     WDFCOMMONBUFFER CommonBuffer
228     );
229 
_IRQL_requires_max_(DISPATCH_LEVEL)230 _IRQL_requires_max_(DISPATCH_LEVEL)
231 FORCEINLINE
232 size_t
233 WdfCommonBufferGetLength(
234     _In_
235     WDFCOMMONBUFFER CommonBuffer
236     )
237 {
238     return ((PFN_WDFCOMMONBUFFERGETLENGTH) WdfFunctions[WdfCommonBufferGetLengthTableIndex])(WdfDriverGlobals, CommonBuffer);
239 }
240 
241 
242 
243 #endif // (NTDDI_VERSION >= NTDDI_WIN2K)
244 
245 
246 WDF_EXTERN_C_END
247 
248 #endif // _WDFCOMMONBUFFER_H_
249 
250