00057 :
00058
00059 This function initializes a zone header. Once successfully
00060 initialized, blocks can be allocated and freed from
the zone, and
00061
the zone can be extended.
00062
00063 Arguments:
00064
00065 Zone - Supplies
the address of a zone header to be initialized.
00066
00067
BlockSize - Supplies
the block size of
the allocatable unit within
00068
the zone. The size must be larger that
the size of
the
00069 initial segment, and must be 64-bit aligned.
00070
00071 InitialSegment - Supplies
the address of a segment of storage. The
00072 first
ZONE_SEGMENT_HEADER-sized portion of
the segment
00073
is used by
the zone allocator. The remainder of
00074
the segment
is carved up into fixed size
00075 (
BlockSize) blocks and
is made available
for
00076 allocation and deallocation from
the zone. The
00077 address of
the segment must be aligned on a 64-bit
00078 boundary.
00079
00080 InitialSegmentSize - Supplies
the size in bytes of
the InitialSegment.
00081
00082 Return Value:
00083
00084 STATUS_UNSUCCESSFUL -
BlockSize or InitialSegment was not aligned on
00085 64-bit boundaries, or
BlockSize was larger than
00086
the initial segment size.
00087
00088 STATUS_SUCCESS - The zone was successfully initialized.
00089
00090 --*/
00091
00092 {
00093 ULONG i;
00094 PCH p;
00095
00096
if ( (
BlockSize & 7) || ((ULONG_PTR)InitialSegment & 7) ||
00097 (
BlockSize > InitialSegmentSize) ) {
00098
#if DBG
00099
DbgPrint(
"EX: ExInitializeZone( %x, %x, %x, %x ) - Invalid parameters.\n",
00100 Zone, BlockSize, InitialSegment, InitialSegmentSize
00101 );
00102 DbgBreakPoint();
00103
#endif
00104
return STATUS_INVALID_PARAMETER;
00105 }
00106
00107 Zone->BlockSize =
BlockSize;
00108
00109 Zone->SegmentList.Next = &((
PZONE_SEGMENT_HEADER) InitialSegment)->SegmentList;
00110 ((
PZONE_SEGMENT_HEADER) InitialSegment)->SegmentList.Next =
NULL;
00111 ((
PZONE_SEGMENT_HEADER) InitialSegment)->Reserved =
NULL;
00112
00113 Zone->FreeList.Next =
NULL;
00114
00115 p = (PCH)InitialSegment +
sizeof(
ZONE_SEGMENT_HEADER);
00116
00117
for (i =
sizeof(
ZONE_SEGMENT_HEADER);
00118 i <= InitialSegmentSize -
BlockSize;
00119 i +=
BlockSize
00120 ) {
00121 ((PSINGLE_LIST_ENTRY)p)->Next = Zone->FreeList.Next;
00122 Zone->FreeList.Next = (PSINGLE_LIST_ENTRY)p;
00123 p +=
BlockSize;
00124 }
00125 Zone->TotalSegmentSize = i;
00126
00127
#if 0
00128
DbgPrint(
"EX: ExInitializeZone( %lx, %lx, %lu, %lu, %lx )\n",
00129 Zone, InitialSegment, InitialSegmentSize,
00130 BlockSize, p
00131 );
00132
#endif
00133
00134
return STATUS_SUCCESS;
00135 }