1 /* $Id: zone.c,v 1.4 2002/09/08 10:23:20 chorns Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/mm/zone.c
6 * PURPOSE: Implements zone buffers
7 * PROGRAMMER: David Welch (welch@mcmail.com)
10 /* INCLUDES ****************************************************************/
12 #include <ddk/ntddk.h>
14 /* FUNCTIONS ***************************************************************/
28 seg
= (PZONE_SEGMENT
)Segment
;
29 seg
->size
= SegmentSize
;
31 PushEntryList(&Zone
->SegmentList
,&seg
->Entry
);
33 entry
= (PZONE_ENTRY
)( ((PVOID
)seg
) + sizeof(ZONE_SEGMENT
) );
35 for (i
=0;i
<(SegmentSize
/ Zone
->BlockSize
);i
++)
37 PushEntryList(&Zone
->FreeList
,&entry
->Entry
);
38 entry
= (PZONE_ENTRY
)(((PVOID
)entry
) + sizeof(ZONE_ENTRY
) +
41 return(STATUS_SUCCESS
);
47 ExInterlockedExtendZone (
57 KeAcquireSpinLock(Lock
,&oldlvl
);
58 ret
= ExExtendZone(Zone
,Segment
,SegmentSize
);
59 KeReleaseSpinLock(Lock
,oldlvl
);
70 ULONG InitialSegmentSize
73 * FUNCTION: Initalizes a zone header
75 * Zone = zone header to be initialized
76 * BlockSize = Size (in bytes) of the allocation size of the zone
77 * InitialSegment = Initial segment of storage allocated by the
79 * InitialSegmentSize = Initial size of the segment
86 Zone
->FreeList
.Next
=NULL
;
87 Zone
->SegmentList
.Next
=NULL
;
88 Zone
->BlockSize
=BlockSize
;
89 Zone
->TotalSegmentSize
= InitialSegmentSize
;
91 seg
= (PZONE_SEGMENT
)InitialSegment
;
92 seg
->size
= InitialSegmentSize
;
94 PushEntryList(&Zone
->SegmentList
,&seg
->Entry
);
96 entry
= (PZONE_ENTRY
)( ((PVOID
)seg
) + sizeof(ZONE_SEGMENT
) );
98 for (i
=0;i
<(InitialSegmentSize
/ BlockSize
);i
++)
100 PushEntryList(&Zone
->FreeList
,&entry
->Entry
);
101 entry
= (PZONE_ENTRY
)(((PVOID
)entry
) + sizeof(ZONE_ENTRY
) + BlockSize
);
104 return(STATUS_SUCCESS
);