Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

region.h

Go to the documentation of this file.
00001 // 00002 // Region Allocation. 00003 // 00004 // Regions can be used to replace zones where it is not essential that the 00005 // specified spinlock be acquired. 00006 // 00007 00008 typedef struct _REGION_SEGMENT_HEADER { 00009 struct _REGION_SEGMENT_HEADER *NextSegment; 00010 PVOID Reserved; 00011 } REGION_SEGMENT_HEADER, *PREGION_SEGMENT_HEADER; 00012 00013 typedef struct _REGION_HEADER { 00014 SLIST_HEADER ListHead; 00015 PREGION_SEGMENT_HEADER FirstSegment; 00016 ULONG BlockSize; 00017 ULONG TotalSize; 00018 } REGION_HEADER, *PREGION_HEADER; 00019 00020 NTKERNELAPI 00021 VOID 00022 ExInitializeRegion( 00023 IN PREGION_HEADER Region, 00024 IN ULONG BlockSize, 00025 IN PVOID Segment, 00026 IN ULONG SegmentSize 00027 ); 00028 00029 NTKERNELAPI 00030 VOID 00031 ExInterlockedExtendRegion( 00032 IN PREGION_HEADER Region, 00033 IN PVOID Segment, 00034 IN ULONG SegmentSize, 00035 IN PKSPIN_LOCK Lock 00036 ); 00037 00038 //++ 00039 // 00040 // PVOID 00041 // ExInterlockedAllocateFromRegion( 00042 // IN PREGION_HEADER Region, 00043 // IN PKSPIN_LOCK Lock 00044 // ) 00045 // 00046 // Routine Description: 00047 // 00048 // This routine removes a free entry from the specified region and returns 00049 // the address of the entry. 00050 // 00051 // Arguments: 00052 // 00053 // Region - Supplies a pointer to the region header. 00054 // 00055 // Lock - Supplies a pointer to a spinlock. 00056 // 00057 // Return Value: 00058 // 00059 // The address of the removed entry is returned as the function value. 00060 // 00061 //-- 00062 00063 #if defined(_ALPHA_) || defined(_MIPS_) || defined(_X86_) 00064 00065 #define ExInterlockedAllocateFromRegion(Region, Lock) \ 00066 (PVOID)ExInterlockedPopEntrySList(&(Region)->ListHead, Lock) 00067 00068 #else 00069 00070 #define ExInterlockedAllocateFromRegion(Region, Lock) \ 00071 (PVOID)ExInterlockedPopEntryList((PSINGLE_LIST_ENTRY)&(Region)->ListHead.Next, Lock) 00072 00073 #endif 00074 00075 //++ 00076 // 00077 // PVOID 00078 // ExInterlockedFreeToRegion( 00079 // IN PREGION_HEADER Region, 00080 // IN PVOID Block, 00081 // IN PKSPIN_LOCK Lock 00082 // ) 00083 // 00084 // Routine Description: 00085 // 00086 // This routine inserts an entry at the front of the free list for the 00087 // specified region. 00088 // 00089 // Arguments: 00090 // 00091 // Region - Supplies a pointer to the region header. 00092 // 00093 // Block - Supplies a pointer to the entry that is inserted at the front 00094 // of the region free list. 00095 // 00096 // Lock - Supplies a pointer to a spinlock. 00097 // 00098 // Return Value: 00099 // 00100 // The previous firt entry in the region free list is returned as the 00101 // function value. a value of NULL implies the region went from empty 00102 // to at least one free block. 00103 // 00104 //-- 00105 00106 #if defined(_ALPHA_) || defined(_MIPS_) || defined(_X86_) 00107 00108 #define ExInterlockedFreeToRegion(Region, Block, Lock) \ 00109 ExInterlockedPushEntrySList(&(Region)->ListHead, ((PSINGLE_LIST_ENTRY)(Block)), Lock) 00110 00111 #else 00112 00113 #define ExInterlockedFreeToRegion(Region, Block, Lock) \ 00114 ExInterlockedPushEntryList((PSINGLE_LIST_ENTRY)&(Region)->ListHead.Next, ((PSINGLE_LIST_ENTRY)(Block)), Lock) 00115 00116 #endif 00117 00118 //++ 00119 // 00120 // BOOLEAN 00121 // ExIsFullRegion( 00122 // IN PREGION_HEADER Region 00123 // ) 00124 // 00125 // Routine Description: 00126 // 00127 // This routine determines if the specified region is full. A region is 00128 // considered full if the free list is empty. 00129 // 00130 // Arguments: 00131 // 00132 // Region - Supplies a pointer the region header. 00133 // 00134 // Return Value: 00135 // 00136 // TRUE if the region is full and FALSE otherwise. 00137 // 00138 //-- 00139 00140 #define ExIsFullRegion(Region) \ 00141 ((Region)->ListHead.Next == (PSINGLE_LIST_ENTRY)NULL) 00142 00143 //++ 00144 // 00145 // BOOLEAN 00146 // ExIsObjectInFirstRegionSegment( 00147 // IN PREGION_HEADER Region, 00148 // IN PVOID Object 00149 // ) 00150 // 00151 // Routine Description: 00152 // 00153 // This routine determines if the specified object is contained in the 00154 // first region segement. 00155 // 00156 // Arguments: 00157 // 00158 // Region - Supplies a pointer to the region header. 00159 // 00160 // Object - Supplies a pointer to an object. 00161 // 00162 // Return Value: 00163 // 00164 // TRUE if the Object came from the first segment of region. 00165 // 00166 //-- 00167 00168 #define ExIsObjectInFirstRegionSegment(Region, Object) ((BOOLEAN) \ 00169 (((PUCHAR)(Object) >= ((PUCHAR)((Region)->FirstSegment) + sizeof(REGION_SEGMENT_HEADER))) && \ 00170 ((PUCHAR)(Object) < ((PUCHAR)((Region)->FirstSegment) + (Region)->TotalSize + sizeof(REGION_SEGMENT_HEADER))))) 00171

Generated on Sat May 15 19:41:37 2004 for test by doxygen 1.3.7