ReactOS 0.4.16-dev-306-g647d351
zone.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS kernel
4 * FILE: ntoskrnl/ex/zone.c
5 * PURPOSE: Implements zone buffers
6 * PROGRAMMERS: Alex Ionescu (alex@relsoft.net)
7 * David Welch (welch@mcmail.com)
8 */
9
10/* INCLUDES ****************************************************************/
11
12#include <ntoskrnl.h>
13#define NDEBUG
14#include <debug.h>
15
16/* FUNCTIONS ***************************************************************/
17
18/*
19 * @implemented
20 */
26{
28 ULONG i;
29
30 /*
31 * BlockSize and Segment must be 8-byte aligned.
32 * Blocksize cannot exceed Segment Size.
33 */
34 if (((ULONG_PTR)Segment & 7) ||
35 (SegmentSize & 7) ||
36 (Zone->BlockSize > SegmentSize))
37 {
38 DPRINT1("Invalid ExExtendZone Alignment and/or Size\n");
40 }
41
42 /* Link the Zone and Segment */
44 &((PZONE_SEGMENT_HEADER)Segment)->SegmentList);
45
46 /* Get to the first entry */
48
49 /* Loop through the segments */
50 for (i = sizeof(ZONE_SEGMENT_HEADER);
51 i <= SegmentSize - Zone->BlockSize;
52 i+= Zone->BlockSize)
53 {
54 /* Link the Free and Segment Lists */
56
57 /* Go to the next entry */
58 Entry += Zone->BlockSize;
59 }
60
61 /* Update Segment Size */
62 Zone->TotalSegmentSize += i;
63
64 /* Return Success */
65 return STATUS_SUCCESS;
66}
67
68/*
69 * @implemented
70 */
77{
80
81 /* Get the lock */
83
84 /* Extend the Zone */
86
87 /* Release lock and return status */
89 return Status;
90}
91
92/*
93 * FUNCTION: Initializes a zone header
94 * ARGUMENTS:
95 * Zone = zone header to be initialized
96 * BlockSize = Size (in bytes) of the allocation size of the zone
97 * InitialSegment = Initial segment of storage allocated by the
98 * caller
99 * InitialSegmentSize = Initial size of the segment
100 *
101 * @implemented
102 */
104NTAPI
106 ULONG BlockSize,
107 PVOID InitialSegment,
108 ULONG InitialSegmentSize)
109{
110 ULONG i;
112
113 /*
114 * BlockSize and Segment must be 8-byte aligned.
115 * Blocksize cannot exceed Segment Size.
116 */
117 if (((ULONG_PTR)InitialSegment & 7) ||
118 (InitialSegmentSize & 7) ||
119 (BlockSize > InitialSegmentSize))
120 {
121 DPRINT1("Invalid ExInitializeZone Alignment and/or Size\n");
123 }
124
125 /* Set the Zone Header */
126 Zone->BlockSize = BlockSize;
127
128 /* Link empty list */
129 Zone->FreeList.Next = NULL;
130 Zone->SegmentList.Next = NULL;
132 &((PZONE_SEGMENT_HEADER)InitialSegment)->SegmentList);
133 ((PZONE_SEGMENT_HEADER)InitialSegment)->Reserved = NULL;
134
135 /* Get first entry */
136 Entry = (ULONG_PTR)InitialSegment + sizeof(ZONE_SEGMENT_HEADER);
137
138 /* Loop through the segments */
139 for (i = sizeof(ZONE_SEGMENT_HEADER);
140 i <= InitialSegmentSize - BlockSize;
141 i+= BlockSize)
142 {
143 /* Link the Free and Segment Lists */
145
146 /* Go to the next entry */
147 Entry += Zone->BlockSize;
148 }
149
150 /* Set Segment Size */
151 Zone->TotalSegmentSize = i;
152
153 /* Return success */
154 return STATUS_SUCCESS;
155}
156
157/* EOF */
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define NULL
Definition: types.h:112
#define ULONG_PTR
Definition: config.h:101
UCHAR KIRQL
Definition: env_spec_w32.h:591
KSPIN_LOCK * PKSPIN_LOCK
Definition: env_spec_w32.h:73
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define STATUS_SUCCESS
Definition: shellext.h:65
base of all file and directory entries
Definition: entries.h:83
Definition: ntbasedef.h:636
struct _SINGLE_LIST_ENTRY * Next
Definition: ntbasedef.h:637
ULONG TotalSegmentSize
Definition: extypes.h:337
ULONG BlockSize
Definition: extypes.h:336
SINGLE_LIST_ENTRY SegmentList
Definition: extypes.h:335
SINGLE_LIST_ENTRY FreeList
Definition: extypes.h:334
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock
Definition: wdfsync.h:127
_Inout_ PVOID Segment
Definition: exfuncs.h:1101
_Inout_ PVOID _In_ ULONG SegmentSize
Definition: exfuncs.h:1102
* PZONE_SEGMENT_HEADER
Definition: extypes.h:331
ZONE_SEGMENT_HEADER
Definition: extypes.h:331
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
FORCEINLINE VOID PushEntryList(_Inout_ PSINGLE_LIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PSINGLE_LIST_ENTRY Entry)
Definition: rtlfuncs.h:256
NTSTATUS NTAPI ExInterlockedExtendZone(PZONE_HEADER Zone, PVOID Segment, ULONG SegmentSize, PKSPIN_LOCK Lock)
Definition: zone.c:73
NTSTATUS NTAPI ExExtendZone(PZONE_HEADER Zone, PVOID Segment, ULONG SegmentSize)
Definition: zone.c:23
NTSTATUS NTAPI ExInitializeZone(PZONE_HEADER Zone, ULONG BlockSize, PVOID InitialSegment, ULONG InitialSegmentSize)
Definition: zone.c:105