3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/mm/pool.c
6 * PURPOSE: Implements the kernel memory pool
7 * PROGRAMMER: David Welch (welch@mcmail.com)
10 /* INCLUDES ****************************************************************/
12 #include <ddk/ntddk.h>
13 #include <reactos/bugcodes.h>
14 #include <internal/ntoskrnl.h>
15 #include <internal/pool.h>
18 #include <internal/debug.h>
20 /* GLOBALS *****************************************************************/
22 #define TAG_NONE (ULONG)(('N'<<0) + ('o'<<8) + ('n'<<16) + ('e'<<24))
24 /* FUNCTIONS ***************************************************************/
27 EiAllocatePool(POOL_TYPE PoolType,
38 case NonPagedPoolMustSucceed:
39 case NonPagedPoolCacheAligned:
40 case NonPagedPoolCacheAlignedMustS:
42 ExAllocateNonPagedPoolWithTag(PoolType,
49 case PagedPoolCacheAligned:
50 Block = ExAllocatePagedPoolWithTag(PoolType,NumberOfBytes,Tag);
57 if ((PoolType==NonPagedPoolMustSucceed ||
58 PoolType==NonPagedPoolCacheAlignedMustS) && Block==NULL)
60 KEBUGCHECK(MUST_SUCCEED_POOL_EMPTY);
69 ExAllocatePool (POOL_TYPE PoolType, ULONG NumberOfBytes)
71 * FUNCTION: Allocates pool memory of a specified type and returns a pointer
72 * to the allocated block. This routine is used for general purpose allocation
76 * Specifies the type of memory to allocate which can be one
80 * NonPagedPoolMustSucceed
81 * NonPagedPoolCacheAligned
82 * NonPagedPoolCacheAlignedMustS
84 * PagedPoolCacheAligned
87 * Specifies the number of bytes to allocate
88 * RETURNS: The allocated block on success
93 Block = EiAllocatePool(PoolType,
96 (PVOID)__builtin_return_address(0));
105 ExAllocatePoolWithTag (ULONG PoolType, ULONG NumberOfBytes, ULONG Tag)
108 Block = EiAllocatePool(PoolType,
111 (PVOID)__builtin_return_address(0));
120 ExAllocatePoolWithQuota (POOL_TYPE PoolType, ULONG NumberOfBytes)
122 return(ExAllocatePoolWithQuotaTag(PoolType, NumberOfBytes, TAG_NONE));
130 ExAllocatePoolWithQuotaTag (IN POOL_TYPE PoolType,
131 IN ULONG NumberOfBytes,
136 Block = EiAllocatePool(PoolType,
139 (PVOID)__builtin_return_address(0));
149 ExFreePool(IN PVOID Block)
151 if (Block >= MmPagedPoolBase && Block < (MmPagedPoolBase + MmPagedPoolSize))
153 ExFreePagedPool(Block);
157 ExFreeNonPagedPool(Block);