2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/mm/pool.c
5 * PURPOSE: Implements the kernel memory pool
6 * PROGRAMMER: David Welch (welch@mcmail.com)
9 /* INCLUDES ****************************************************************/
11 #include <internal/ntoskrnl.h>
12 #include <ddk/ntddk.h>
13 #include <internal/pool.h>
16 #include <internal/debug.h>
18 /* GLOBALS *****************************************************************/
20 #define TAG_NONE (ULONG)(('N'<<0) + ('o'<<8) + ('n'<<16) + ('e'<<24))
22 /* FUNCTIONS ***************************************************************/
24 PVOID
ExAllocatePool(POOL_TYPE PoolType
, ULONG NumberOfBytes
)
26 * FUNCTION: Allocates pool memory of a specified type and returns a pointer
27 * to the allocated block. This routine is used for general purpose allocation
31 * Specifies the type of memory to allocate which can be one
35 * NonPagedPoolMustSucceed
36 * NonPagedPoolCacheAligned
37 * NonPagedPoolCacheAlignedMustS
39 * PagedPoolCacheAligned
42 * Specifies the number of bytes to allocate
43 * RETURNS: The allocated block on success
47 return(ExAllocatePoolWithTag(PoolType
,NumberOfBytes
,TAG_NONE
));
50 PVOID
ExAllocatePoolWithTag(ULONG type
, ULONG size
, ULONG Tag
)
54 if (type
== NonPagedPoolCacheAligned
||
55 type
== NonPagedPoolCacheAlignedMustS
)
63 case NonPagedPoolMustSucceed
:
64 case NonPagedPoolCacheAligned
:
65 case NonPagedPoolCacheAlignedMustS
:
66 Block
= ExAllocateNonPagedPoolWithTag(type
,size
,Tag
);
70 case PagedPoolCacheAligned
:
71 Block
= ExAllocatePagedPoolWithTag(type
,size
,Tag
);
78 if ((type
==NonPagedPoolMustSucceed
|| type
==NonPagedPoolCacheAlignedMustS
)
81 KeBugCheck(MUST_SUCCEED_POOL_EMPTY
);
86 PVOID
ExAllocatePoolWithQuotaTag(POOL_TYPE PoolType
, ULONG NumberOfBytes
,
90 PKTHREAD current
= KeGetCurrentThread();
92 Block
= ExAllocatePoolWithTag(PoolType
,NumberOfBytes
,Tag
);
96 case NonPagedPoolMustSucceed
:
97 case NonPagedPoolCacheAligned
:
98 case NonPagedPoolCacheAlignedMustS
:
99 // current->NPagedPoolQuota = current->NPagedPoolQuota - NumberOfBytes;
103 case PagedPoolCacheAligned
:
104 // current->PagedPoolQuota = current->PagedPoolQuota - NumberOfBytes;
110 PVOID
ExAllocatePoolWithQuota(POOL_TYPE PoolType
, ULONG NumberOfBytes
)
112 return(ExAllocatePoolWithQuotaTag(PoolType
,NumberOfBytes
,TAG_NONE
));