initial work on I/O completion
[reactos.git] / reactos / include / ddk / extypes.h
1 /* $Id: extypes.h,v 1.13 2003/03/19 23:14:11 gdalsnes Exp $ */
2
3 #ifndef __INCLUDE_DDK_EXTYPES_H
4 #define __INCLUDE_DDK_EXTYPES_H
5
6 #ifdef __NTOSKRNL__
7 extern POBJECT_TYPE EXPORTED ExDesktopObjectType;
8 extern POBJECT_TYPE EXPORTED ExEventObjectType;
9 extern POBJECT_TYPE EXPORTED ExWindowStationObjectType;
10 extern POBJECT_TYPE EXPORTED ExIoCompletionType;
11 #else
12 extern POBJECT_TYPE IMPORTED ExDesktopObjectType;
13 extern POBJECT_TYPE IMPORTED ExEventObjectType;
14 extern POBJECT_TYPE IMPORTED ExWindowStationObjectType;
15 extern POBJECT_TYPE IMPORTED ExIoCompletionType;
16 #endif
17
18 typedef ULONG INTERLOCKED_RESULT;
19 typedef ULONG WORK_QUEUE_TYPE;
20
21 typedef ULONG ERESOURCE_THREAD, *PERESOURCE_THREAD;
22
23 typedef struct _OWNER_ENTRY
24 {
25 ERESOURCE_THREAD OwnerThread;
26 union
27 {
28 LONG OwnerCount;
29 ULONG TableSize;
30 } a;
31 } OWNER_ENTRY, *POWNER_ENTRY;
32
33 typedef struct _ERESOURCE
34 {
35 LIST_ENTRY SystemResourcesList;
36 POWNER_ENTRY OwnerTable;
37 SHORT ActiveCount;
38 USHORT Flag;
39 PKSEMAPHORE SharedWaiters;
40 PKEVENT ExclusiveWaiters;
41 OWNER_ENTRY OwnerThreads[2];
42 ULONG ContentionCount;
43 USHORT NumberOfSharedWaiters;
44 USHORT NumberOfExclusiveWaiters;
45 union
46 {
47 PVOID Address;
48 ULONG CreatorBackTraceIndex;
49 } a;
50 KSPIN_LOCK SpinLock;
51 } ERESOURCE, *PERESOURCE;
52
53
54 typedef struct
55 {
56 LONG Count;
57 struct _KTHREAD* Owner;
58 ULONG Contention;
59 KEVENT Event;
60 ULONG OldIrql;
61 } FAST_MUTEX, *PFAST_MUTEX;
62
63 typedef struct _ZONE_HEADER
64 {
65 SINGLE_LIST_ENTRY FreeList;
66 SINGLE_LIST_ENTRY SegmentList;
67 ULONG BlockSize;
68 ULONG TotalSegmentSize;
69 } ZONE_HEADER, *PZONE_HEADER;
70
71 typedef struct _ZONE_SEGMENT
72 {
73 SINGLE_LIST_ENTRY Entry;
74 ULONG size;
75 } ZONE_SEGMENT, *PZONE_SEGMENT;
76
77 typedef struct _ZONE_ENTRY
78 {
79 SINGLE_LIST_ENTRY Entry;
80 } ZONE_ENTRY, *PZONE_ENTRY;
81
82
83 typedef VOID STDCALL_FUNC
84 (*PWORKER_THREAD_ROUTINE)(PVOID Parameter);
85
86 typedef struct _WORK_QUEUE_ITEM
87 {
88 LIST_ENTRY Entry;
89 PWORKER_THREAD_ROUTINE Routine;
90 PVOID Context;
91 } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM;
92
93 typedef PVOID STDCALL_FUNC
94 (*PALLOCATE_FUNCTION)(POOL_TYPE PoolType,
95 ULONG NumberOfBytes,
96 ULONG Tag);
97
98 typedef VOID STDCALL_FUNC
99 (*PFREE_FUNCTION)(PVOID Buffer);
100
101 typedef union _SLIST_HEADER
102 {
103 ULONGLONG Alignment;
104 struct
105 {
106 SINGLE_LIST_ENTRY Next;
107 USHORT Depth;
108 USHORT Sequence;
109 } s;
110 } SLIST_HEADER, *PSLIST_HEADER;
111
112 typedef struct _NPAGED_LOOKASIDE_LIST
113 {
114 SLIST_HEADER ListHead;
115 USHORT MinimumDepth;
116 USHORT MaximumDepth;
117 ULONG TotalAllocates;
118 ULONG AllocateMisses;
119 ULONG TotalFrees;
120 ULONG FreeMisses;
121 POOL_TYPE Type;
122 ULONG Tag;
123 ULONG Size;
124 PALLOCATE_FUNCTION Allocate;
125 PFREE_FUNCTION Free;
126 LIST_ENTRY ListEntry;
127 ULONG LastTotalAllocates;
128 ULONG LastAllocateMisses;
129 ULONG Pad[2];
130 KSPIN_LOCK Lock;
131 } NPAGED_LOOKASIDE_LIST, *PNPAGED_LOOKASIDE_LIST;
132
133 typedef struct _PAGED_LOOKASIDE_LIST
134 {
135 SLIST_HEADER ListHead;
136 USHORT MinimumDepth;
137 USHORT MaximumDepth;
138 ULONG TotalAllocates;
139 ULONG AllocateMisses;
140 ULONG TotalFrees;
141 ULONG FreeMisses;
142 POOL_TYPE Type;
143 ULONG Tag;
144 ULONG Size;
145 PALLOCATE_FUNCTION Allocate;
146 PFREE_FUNCTION Free;
147 LIST_ENTRY ListEntry;
148 ULONG LastTotalAllocates;
149 ULONG LastAllocateMisses;
150 FAST_MUTEX Lock;
151 } PAGED_LOOKASIDE_LIST, *PPAGED_LOOKASIDE_LIST;
152
153
154 /* callback object (not functional in NT4)*/
155
156 typedef struct _CALLBACK_OBJECT *PCALLBACK_OBJECT;
157
158 typedef VOID STDCALL_FUNC
159 (*PCALLBACK_FUNCTION)(PVOID CallbackContext,
160 PVOID Argument1,
161 PVOID Argument2);
162
163 /* BEGIN REACTOS ONLY */
164
165 typedef enum _TRAVERSE_METHOD {
166 TraverseMethodPreorder,
167 TraverseMethodInorder,
168 TraverseMethodPostorder
169 } TRAVERSE_METHOD;
170
171 typedef LONG STDCALL_FUNC
172 (*PKEY_COMPARATOR)(IN PVOID Key1,
173 IN PVOID Key2);
174
175 typedef BOOLEAN STDCALL_FUNC
176 (*PTRAVERSE_ROUTINE)(IN PVOID Context,
177 IN PVOID Key,
178 IN PVOID Value);
179
180 struct _BINARY_TREE_NODE;
181
182 typedef struct _BINARY_TREE
183 {
184 struct _BINARY_TREE_NODE * RootNode;
185 PKEY_COMPARATOR Compare;
186 BOOLEAN UseNonPagedPool;
187 union {
188 NPAGED_LOOKASIDE_LIST NonPaged;
189 PAGED_LOOKASIDE_LIST Paged;
190 } List;
191 union {
192 KSPIN_LOCK NonPaged;
193 FAST_MUTEX Paged;
194 } Lock;
195 } BINARY_TREE, *PBINARY_TREE;
196
197
198 struct _SPLAY_TREE_NODE;
199
200 typedef struct _SPLAY_TREE
201 {
202 struct _SPLAY_TREE_NODE * RootNode;
203 PKEY_COMPARATOR Compare;
204 BOOLEAN Weighted;
205 BOOLEAN UseNonPagedPool;
206 union {
207 NPAGED_LOOKASIDE_LIST NonPaged;
208 PAGED_LOOKASIDE_LIST Paged;
209 } List;
210 union {
211 KSPIN_LOCK NonPaged;
212 FAST_MUTEX Paged;
213 } Lock;
214 PVOID Reserved[4];
215 } SPLAY_TREE, *PSPLAY_TREE;
216
217
218 typedef struct _HASH_TABLE
219 {
220 // Size of hash table in number of bits
221 ULONG HashTableSize;
222
223 // Use non-paged pool memory?
224 BOOLEAN UseNonPagedPool;
225
226 // Lock for this structure
227 union {
228 KSPIN_LOCK NonPaged;
229 FAST_MUTEX Paged;
230 } Lock;
231
232 // Pointer to array of hash buckets with splay trees
233 PSPLAY_TREE HashTrees;
234 } HASH_TABLE, *PHASH_TABLE;
235
236 /* END REACTOS ONLY */
237
238 #endif /* __INCLUDE_DDK_EXTYPES_H */
239
240 /* EOF */