ReactOS  0.4.15-dev-3302-ga37d9a4
fxpool.h
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxPool.h
8 
9 Abstract:
10 
11  This module contains private Pool package definitions
12 
13 Author:
14 
15 
16 
17 
18 Environment:
19 
20  Both kernel and user mode
21 
22 Revision History:
23 
24 
25  Made it mode agnostic
26 
27  New failure paths:
28  Initialization failures of paged/non-paged lock -
29 
30  Upon failure we disable pool tracking, rest of the behavior
31  remains unchanged, and FxPoolInitialize not being bubbled up
32  doesn't become an issue.
33 
34 --*/
35 
36 #ifndef _FXPOOL_H_
37 #define _FXPOOL_H_
38 
39 //
40 // Common pool header for small allocations (less than PAGE_SIZE)
41 //
43 
45 
47 
49 };
50 
52 
53 #define FX_POOL_HEADER_SIZE FIELD_OFFSET(FX_POOL_HEADER, AllocationStart)
54 
55 
56 //
57 // This structure described an indivdually tracked pool.
58 //
59 // The frameworks tracks pool on behalf of the frameworks (global),
60 // and per driver.
61 //
62 
63 struct FX_POOL {
66 
69 
70  // Current Pool Usage Information
73 
76 
77  // Peak Pool Usage Information
80 
83 };
84 
85 typedef FX_POOL *PFX_POOL;
86 
87 //
88 // This structure is allocated along with the pool item and
89 // is used to track it.
90 //
91 // Note: We would be messing up cache aligned if its greater
92 // than 16.
93 //
94 // Our struct is 7 DWORD's on an x86, and 11 DWORDS on 64 bit
95 // machines.
96 //
97 // This rounds up to 8 or 12 DWORDS.
98 //
99 //
100 struct DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) FX_POOL_TRACKER {
102  PFX_POOL Pool;
103  ULONG Tag;
104  SIZE_T Size;
106  PVOID CallersAddress;
107 };
108 
109 typedef FX_POOL_TRACKER *PFX_POOL_TRACKER;
110 
111 /*++
112 
113 Routine Description:
114 
115  Initialize the FX_POOL tracking object
116 
117 Arguments:
118 
119  Pool - FX_POOL object for tracking allocations
120 
121 Returns:
122 
123  status
124 
125 --*/
127 NTSTATUS
129  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
131  );
132 
133 /*++
134 
135 Routine Description:
136 
137  Destory the FX_POOL tracking object
138 
139 Arguments:
140 
141  Pool - FX_POOL object for tracking allocations
142 
143 --*/
144 VOID
146  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
148  );
149 
150 
151 extern "C"
155  VOID
156  );
157 
158 extern "C"
159 VOID
162  );
163 
164 BOOLEAN
167  );
168 
169 /*++
170 
171 Routine Description:
172 
173  Allocates system pool tracked in a FX_POOL tracking object.
174 
175 Arguments:
176 
177  Pool - FX_POOL object for tracking allocations
178 
179  Type - POOL_TYPE from ntddk.h
180 
181  Size - Size in bytes of the allocation
182 
183  Tag - Caller specified additional tag value for debugging/tracing
184 
185  PVOID - Caller's address, usefull for finding who allocated the memory
186 
187 Returns:
188 
189  NULL - Could not allocate pool
190  !NULL - Pointer to pool of minimum Size bytes
191 
192 --*/
193 PVOID
195  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
198  __in SIZE_T Size,
199  __in ULONG Tag,
200  __in PVOID CallersAddress
201  );
202 
203 /*++
204 
205 Routine Description:
206 
207  Release tracked pool
208 
209 Arguments:
210 
211  Pool - FX_POOL object allocation is tracked in
212 
213  ptr - Pointer to pool to release
214 
215 Returns:
216 
217 --*/
218 void
219 FxPoolFree(
220  __in_xcount(ptr is at an offset from AllocationStart) PVOID ptr
221  );
222 
223 /*++
224 
225 Routine Description:
226 
227  Dump the FX_POOL tracking object
228 
229 Arguments:
230 
231  Pool - FX_POOL object for tracking allocations
232 
233 Returns:
234 
235  STATUS_SUCCESS
236 
237 --*/
238 NTSTATUS
239 FxPoolDump(
240  __in PFX_DRIVER_GLOBALS FxDriverGlobals,
242  );
243 
244 /*++
245 
246 Routine Description:
247 
248  Initialize the pool support package at startup time.
249 
250  This must be called before the first allocation.
251 
252 Arguments:
253 
254 Returns:
255 
256  STATUS_SUCCESS
257 
258 --*/
260 NTSTATUS
262  __in PFX_DRIVER_GLOBALS FxDriverGlobals
263  );
264 /*++
265 
266 Routine Description:
267 
268  Destroy the pool support package at unload time
269 
270  This must be after the last free
271 
272 Arguments:
273 
274 Returns:
275 
276  status
277 
278 --*/
279 VOID
281  __in PFX_DRIVER_GLOBALS FxDriverGlobals
282  );
283 
284 
285 
286 #endif // _FXPOOL_H_
BOOLEAN FxIsPagedPoolType(__in POOL_TYPE Type)
Definition: wdfpool.cpp:43
SIZE_T NonPagedBytes
Definition: fxpool.h:71
ULONG PagedAllocations
Definition: fxpool.h:75
ULONG NonPagedAllocations
Definition: fxpool.h:74
_Must_inspect_result_ NTSTATUS FxPoolInitialize(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PFX_POOL Pool)
Definition: wdfpool.cpp:554
DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) ULONG AllocationStart[1]
LONG NTSTATUS
Definition: precomp.h:26
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
DriverGlobals
static int Link(const char **args)
Definition: vfdcmd.c:2414
#define __in_xcount(size)
Definition: specstrings.h:109
LIST_ENTRY NonPagedHead
Definition: fxpool.h:65
PVOID Base
Definition: fxpool.h:44
Definition: fxpool.h:63
VOID FxFreeDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: globals.cpp:1181
NTSTATUS FxPoolDump(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PFX_POOL Pool)
Definition: wdfpool.cpp:459
static PVOID ptr
Definition: dispmode.c:27
unsigned char BOOLEAN
_Must_inspect_result_ NTSTATUS FxPoolPackageInitialize(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
Definition: wdfpool.cpp:667
SIZE_T PeakPagedBytes
Definition: fxpool.h:79
ULONG PeakPagedAllocations
Definition: fxpool.h:82
MxLockNoDynam NonPagedLock
Definition: fxpool.h:64
INT POOL_TYPE
Definition: typedefs.h:78
GLintptr offset
Definition: glext.h:5920
PVOID FxPoolAllocator(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PFX_POOL Pool, __in POOL_TYPE Type, __in SIZE_T Size, __in ULONG Tag, __in PVOID CallersAddress)
Definition: wdfpool.cpp:76
Definition: bufpool.h:50
Type
Definition: Type.h:6
FX_POOL_HEADER * PFX_POOL_HEADER
Definition: fxpool.h:51
ULONG PeakNonPagedAllocations
Definition: fxpool.h:81
FX_POOL * PFX_POOL
Definition: fxpool.h:85
PFX_DRIVER_GLOBALS FxDriverGlobals
Definition: fxpool.h:46
LIST_ENTRY PagedHead
Definition: fxpool.h:68
VOID FxPoolDestroy(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PFX_POOL Pool)
Definition: wdfpool.cpp:627
Definition: typedefs.h:119
#define _Must_inspect_result_
Definition: ms_sal.h:558
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4061
_Must_inspect_result_ PWDF_DRIVER_GLOBALS FxAllocateDriverGlobals(VOID)
Definition: globals.cpp:1052
ULONG_PTR SIZE_T
Definition: typedefs.h:80
SIZE_T PagedBytes
Definition: fxpool.h:72
VOID FxPoolPackageDestroy(__in PFX_DRIVER_GLOBALS FxDriverGlobals)
Definition: wdfpool.cpp:689
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ _Strict_type_match_ POOL_TYPE PoolType
Definition: wdfdevice.h:3810
unsigned int ULONG
Definition: retypes.h:1
SIZE_T PeakNonPagedBytes
Definition: fxpool.h:78
MxPagedLockNoDynam PagedLock
Definition: fxpool.h:67
CardRegion * from
Definition: spigame.cpp:19
void FxPoolFree(__in_xcount(ptr is at an offset from AllocationStart) PVOID ptr)
Definition: wdfpool.cpp:361
#define __in
Definition: dbghelp.h:35
#define MEMORY_ALLOCATION_ALIGNMENT
Definition: ntbasedef.h:90
FX_POOL_TRACKER * PFX_POOL_TRACKER
Definition: fxpool.h:107