ntoskrnl_var.h revision 127552
1123474Swpaul/*
2123474Swpaul * Copyright (c) 2003
3123474Swpaul *	Bill Paul <wpaul@windriver.com>.  All rights reserved.
4123474Swpaul *
5123474Swpaul * Redistribution and use in source and binary forms, with or without
6123474Swpaul * modification, are permitted provided that the following conditions
7123474Swpaul * are met:
8123474Swpaul * 1. Redistributions of source code must retain the above copyright
9123474Swpaul *    notice, this list of conditions and the following disclaimer.
10123474Swpaul * 2. Redistributions in binary form must reproduce the above copyright
11123474Swpaul *    notice, this list of conditions and the following disclaimer in the
12123474Swpaul *    documentation and/or other materials provided with the distribution.
13123474Swpaul * 3. All advertising materials mentioning features or use of this software
14123474Swpaul *    must display the following acknowledgement:
15123474Swpaul *	This product includes software developed by Bill Paul.
16123474Swpaul * 4. Neither the name of the author nor the names of any co-contributors
17123474Swpaul *    may be used to endorse or promote products derived from this software
18123474Swpaul *    without specific prior written permission.
19123474Swpaul *
20123474Swpaul * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21123474Swpaul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22123474Swpaul * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23123474Swpaul * ARE DISCLAIMED.  IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
24123474Swpaul * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25123474Swpaul * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26123474Swpaul * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27123474Swpaul * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28123474Swpaul * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29123474Swpaul * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30123474Swpaul * THE POSSIBILITY OF SUCH DAMAGE.
31123474Swpaul *
32123474Swpaul * $FreeBSD: head/sys/compat/ndis/ntoskrnl_var.h 127552 2004-03-29 02:15:29Z wpaul $
33123474Swpaul */
34123474Swpaul
35123474Swpaul#ifndef _NTOSKRNL_VAR_H_
36123474Swpaul#define _NTOSKRNL_VAR_H_
37123474Swpaul
38123512Swpaul/* Note: assumes x86 page size of 4K. */
39123512Swpaul#define PAGE_SHIFT	12
40123512Swpaul#define SPAN_PAGES(ptr, len)					\
41123512Swpaul	((uint32_t)((((uintptr_t)(ptr) & (PAGE_SIZE -1)) +	\
42123512Swpaul	(len) + (PAGE_SIZE - 1)) >> PAGE_SHIFT))
43123757Swpaul#define PAGE_ALIGN(ptr)						\
44123757Swpaul	((void *)((uintptr_t)(ptr) & ~(PAGE_SIZE - 1)))
45123757Swpaul#define BYTE_OFFSET(ptr)					\
46123757Swpaul	((uint32_t)((uintptr_t)(ptr) & (PAGE_SIZE - 1)))
47123757Swpaul#define MDL_INIT(b, baseva, len)					\
48123757Swpaul	(b)->nb_next = NULL;						\
49123757Swpaul	(b)->nb_size = (uint16_t)(sizeof(struct ndis_buffer) +		\
50123757Swpaul		(sizeof(uint32_t) * SPAN_PAGES((baseva), (len))));	\
51123757Swpaul	(b)->nb_flags = 0;						\
52123757Swpaul	(b)->nb_startva = (void *)PAGE_ALIGN((baseva));			\
53123757Swpaul	(b)->nb_byteoffset = BYTE_OFFSET((baseva));			\
54123757Swpaul	(b)->nb_bytecount = (uint32_t)(len);
55123757Swpaul#define MDL_VA(b)						\
56123757Swpaul	((void *)((char *)((b)->nb_startva) + (b)->nb_byteoffset))
57123512Swpaul
58124729Swpaul#define WDM_MAJOR		1
59124729Swpaul#define WDM_MINOR_WIN98		0x00
60124729Swpaul#define WDM_MINOR_WINME		0x05
61124729Swpaul#define WDM_MINOR_WIN2000	0x10
62124729Swpaul#define WDM_MINOR_WINXP		0x20
63124729Swpaul#define WDM_MINOR_WIN2003	0x30
64124729Swpaul
65124582Sobrien/*-
66124582Sobrien * The ndis_kspin_lock type is called KSPIN_LOCK in MS-Windows.
67124582Sobrien * According to the Windows DDK header files, KSPIN_LOCK is defined like this:
68124582Sobrien *	typedef ULONG_PTR KSPIN_LOCK;
69124582Sobrien *
70124582Sobrien * From basetsd.h (SDK, Feb. 2003):
71124582Sobrien * 	typedef [public] unsigned __int3264 ULONG_PTR, *PULONG_PTR;
72124582Sobrien * 	typedef unsigned __int64 ULONG_PTR, *PULONG_PTR;
73124582Sobrien * 	typedef _W64 unsigned long ULONG_PTR, *PULONG_PTR;
74124582Sobrien *
75124582Sobrien * The keyword __int3264 specifies an integral type that has the following
76124582Sobrien * properties:
77124582Sobrien *	+ It is 32-bit on 32-bit platforms
78124582Sobrien *	+ It is 64-bit on 64-bit platforms
79124582Sobrien *	+ It is 32-bit on the wire for backward compatibility.
80124582Sobrien *	  It gets truncated on the sending side and extended appropriately
81124582Sobrien *	  (signed or unsigned) on the receiving side.
82124582Sobrien *
83124582Sobrien * Thus register_t seems the proper mapping onto FreeBSD for spin locks.
84124582Sobrien */
85123474Swpaul
86124582Sobrientypedef register_t kspin_lock;
87124582Sobrien
88123474Swpaulstruct slist_entry {
89123474Swpaul	struct slist_entry	*sl_next;
90123474Swpaul};
91123474Swpaul
92123474Swpaultypedef struct slist_entry slist_entry;
93123474Swpaul
94123474Swpaulunion slist_header {
95123474Swpaul	uint64_t		slh_align;
96123474Swpaul	struct {
97123474Swpaul		struct slist_entry	*slh_next;
98123474Swpaul		uint16_t		slh_depth;
99123474Swpaul		uint16_t		slh_seq;
100123474Swpaul	} slh_list;
101123474Swpaul};
102123474Swpaul
103123474Swpaultypedef union slist_header slist_header;
104123474Swpaul
105123507Swpaulstruct list_entry {
106123507Swpaul        struct list_entry *nle_flink;
107123507Swpaul        struct list_entry *nle_blink;
108123507Swpaul};
109123507Swpaul
110123507Swpaultypedef struct list_entry list_entry;
111123507Swpaul
112125551Swpaul#define INIT_LIST_HEAD(l)	\
113125551Swpaul	l->nle_flink = l->nle_blink = l
114125551Swpaul
115125551Swpaul#define REMOVE_LIST_ENTRY(e)			\
116125551Swpaul	do {					\
117125551Swpaul		list_entry		*b;	\
118125551Swpaul		list_entry		*f;	\
119125551Swpaul						\
120125551Swpaul		f = e->nle_flink;		\
121125551Swpaul		b = e->nle_blink;		\
122125551Swpaul		b->nle_flink = f;		\
123125551Swpaul		f->nle_blink = b;		\
124125551Swpaul	} while (0)
125125551Swpaul
126125551Swpaul#define REMOVE_LIST_HEAD(l)			\
127125551Swpaul	do {					\
128125551Swpaul		list_entry		*f;	\
129125551Swpaul		list_entry		*e;	\
130125551Swpaul						\
131125551Swpaul		e = l->nle_flink;		\
132125551Swpaul		f = e->nle_flink;		\
133125551Swpaul		l->nle_flink = f;		\
134125551Swpaul		f->nle_blink = l;		\
135125551Swpaul	} while (0)
136125551Swpaul
137125551Swpaul#define REMOVE_LIST_TAIL(l)			\
138125551Swpaul	do {					\
139125551Swpaul		list_entry		*b;	\
140125551Swpaul		list_entry		*e;	\
141125551Swpaul						\
142125551Swpaul		e = l->nle_blink;		\
143125551Swpaul		b = e->nle_blink;		\
144125551Swpaul		l->nle_blink = b;		\
145125551Swpaul		b->nle_flink = l;		\
146125551Swpaul	} while (0)
147125551Swpaul
148125551Swpaul#define INSERT_LIST_TAIL(l, e)			\
149125551Swpaul	do {					\
150125551Swpaul		list_entry		*b;	\
151125551Swpaul						\
152125551Swpaul		b = l->nle_blink;		\
153125860Swpaul		e->nle_flink = l;		\
154125551Swpaul		e->nle_blink = b;		\
155125551Swpaul		b->nle_flink = e;		\
156125551Swpaul		l->nle_blink = e;		\
157125551Swpaul	} while (0)
158125551Swpaul
159125551Swpaul#define INSERT_LIST_HEAD(l, e)			\
160125551Swpaul	do {					\
161125551Swpaul		list_entry		*f;	\
162125551Swpaul						\
163125551Swpaul		f = l->nle_flink;		\
164125551Swpaul		e->nle_flink = f;		\
165125551Swpaul		e->nle_blink = l;		\
166125551Swpaul		f->nle_blink = e;		\
167125551Swpaul		l->nle_flink = e;		\
168125551Swpaul	} while (0)
169125551Swpaul
170125551Swpaulstruct nt_dispatch_header {
171125551Swpaul	uint8_t			dh_type;
172125551Swpaul	uint8_t			dh_abs;
173125551Swpaul	uint8_t			dh_size;
174125551Swpaul	uint8_t			dh_inserted;
175125551Swpaul	uint32_t		dh_sigstate;
176125551Swpaul	list_entry		dh_waitlisthead;
177125551Swpaul};
178125551Swpaul
179125551Swpaultypedef struct nt_dispatch_header nt_dispatch_header;
180125551Swpaul
181125551Swpaul#define OTYPE_EVENT		0
182125551Swpaul#define OTYPE_MUTEX		1
183125551Swpaul#define OTYPE_THREAD		2
184125551Swpaul#define OTYPE_TIMER		3
185125551Swpaul
186125551Swpaul/* Windows dispatcher levels. */
187125551Swpaul
188125551Swpaul#define PASSIVE_LEVEL		0
189125551Swpaul#define LOW_LEVEL		0
190125551Swpaul#define APC_LEVEL		1
191125551Swpaul#define DISPATCH_LEVEL		2
192125551Swpaul#define PROFILE_LEVEL		27
193125551Swpaul#define CLOCK1_LEVEL		28
194125551Swpaul#define CLOCK2_LEVEL		28
195125551Swpaul#define IPI_LEVEL		29
196125551Swpaul#define POWER_LEVEL		30
197125551Swpaul#define HIGH_LEVEL		31
198125551Swpaul
199125551Swpaul#define SYNC_LEVEL_UP		DISPATCH_LEVEL
200125551Swpaul#define SYNC_LEVEL_MP		(IPI_LEVEL - 1)
201125551Swpaul
202125551Swpaulstruct nt_objref {
203125551Swpaul	nt_dispatch_header	no_dh;
204125551Swpaul	void			*no_obj;
205125551Swpaul	TAILQ_ENTRY(nt_objref)	link;
206125551Swpaul};
207125551Swpaul
208125551SwpaulTAILQ_HEAD(nt_objref_head, nt_objref);
209125551Swpaul
210125551Swpaultypedef struct nt_objref nt_objref;
211125551Swpaul
212125551Swpaul#define EVENT_TYPE_NOTIFY	0
213125551Swpaul#define EVENT_TYPE_SYNC		1
214125551Swpaul
215126620Swpaul/*
216126620Swpaul * We need to use the timeout()/untimeout() API for ktimers
217126620Swpaul * since timers can be initialized, but not destroyed (so
218126620Swpaul * malloc()ing our own callout structures would mean a leak,
219126620Swpaul * since there'd be no way to free() them). This means we
220126620Swpaul * need to use struct callout_handle, which is really just a
221126620Swpaul * pointer. To make it easier to deal with, we use a union
222126620Swpaul * to overlay the callout_handle over the k_timerlistentry.
223126620Swpaul * The latter is a list_entry, which is two pointers, so
224126620Swpaul * there's enough space available to hide a callout_handle
225126620Swpaul * there.
226126620Swpaul */
227126620Swpaul
228125551Swpaulstruct ktimer {
229125551Swpaul	nt_dispatch_header	k_header;
230125551Swpaul	uint64_t		k_duetime;
231126620Swpaul	union {
232126620Swpaul		list_entry		k_timerlistentry;
233126620Swpaul		struct callout_handle	k_handle;
234126620Swpaul	} u;
235125551Swpaul	void			*k_dpc;
236125551Swpaul	uint32_t		k_period;
237125551Swpaul};
238125551Swpaul
239126620Swpaul#define k_timerlistentry	u.k_timerlistentry
240126620Swpaul#define k_handle		u.k_handle
241126620Swpaul
242126620Swpaultypedef struct ktimer ktimer;
243126620Swpaul
244125551Swpaulstruct nt_kevent {
245125551Swpaul	nt_dispatch_header	k_header;
246125551Swpaul};
247125551Swpaul
248125551Swpaultypedef struct nt_kevent nt_kevent;
249125551Swpaul
250125551Swpaul/* Kernel defered procedure call (i.e. timer callback) */
251125551Swpaul
252125551Swpaulstruct kdpc;
253125551Swpaultypedef void (*kdpc_func)(struct kdpc *, void *, void *, void *);
254125551Swpaul
255125551Swpaulstruct kdpc {
256125551Swpaul	uint16_t		k_type;
257125551Swpaul	uint8_t			k_num;
258125551Swpaul	uint8_t			k_importance;
259125551Swpaul	list_entry		k_dpclistentry;
260125551Swpaul	kdpc_func		k_deferedfunc;
261125551Swpaul	void			*k_deferredctx;
262125551Swpaul	void			*k_sysarg1;
263125551Swpaul	void			*k_sysarg2;
264127552Swpaul	register_t		k_lock;
265125551Swpaul};
266125551Swpaul
267126620Swpaultypedef struct kdpc kdpc;
268126620Swpaul
269125551Swpaul/*
270125551Swpaul * Note: the acquisition count is BSD-specific. The Microsoft
271125551Swpaul * documentation says that mutexes can be acquired recursively
272125551Swpaul * by a given thread, but that you must release the mutex as
273125551Swpaul * many times as you acquired it before it will be set to the
274125551Swpaul * signalled state (i.e. before any other threads waiting on
275125551Swpaul * the object will be woken up). However the Windows KMUTANT
276125551Swpaul * structure has no field for keeping track of the number of
277125551Swpaul * acquisitions, so we need to add one ourselves. As long as
278125551Swpaul * driver code treats the mutex as opaque, we should be ok.
279125551Swpaul */
280125551Swpaulstruct kmutant {
281125551Swpaul	nt_dispatch_header	km_header;
282126620Swpaul	union {
283126620Swpaul		list_entry		km_listentry;
284126620Swpaul		uint32_t		km_acquirecnt;
285126620Swpaul	} u;
286125551Swpaul	void			*km_ownerthread;
287125551Swpaul	uint8_t			km_abandoned;
288125551Swpaul	uint8_t			km_apcdisable;
289125551Swpaul};
290125551Swpaul
291126620Swpaul#define km_listentry		u.km_listentry
292126620Swpaul#define km_acquirecnt		u.km_acquirecnt
293126620Swpaul
294125551Swpaultypedef struct kmutant kmutant;
295125551Swpaul
296125860Swpaul#define LOOKASIDE_DEPTH 256
297125860Swpaul
298123474Swpaulstruct general_lookaside {
299123474Swpaul	slist_header		gl_listhead;
300123474Swpaul	uint16_t		gl_depth;
301123474Swpaul	uint16_t		gl_maxdepth;
302123474Swpaul	uint32_t		gl_totallocs;
303123474Swpaul	union {
304123474Swpaul		uint32_t		gl_allocmisses;
305123474Swpaul		uint32_t		gl_allochits;
306123474Swpaul	} u_a;
307123474Swpaul	uint32_t		gl_totalfrees;
308123474Swpaul	union {
309123474Swpaul		uint32_t		gl_freemisses;
310123474Swpaul		uint32_t		gl_freehits;
311123474Swpaul	} u_m;
312123474Swpaul	uint32_t		gl_type;
313123474Swpaul	uint32_t		gl_tag;
314123474Swpaul	uint32_t		gl_size;
315123474Swpaul	void			*gl_allocfunc;
316123474Swpaul	void			*gl_freefunc;
317123507Swpaul	list_entry		gl_listent;
318123474Swpaul	uint32_t		gl_lasttotallocs;
319123474Swpaul	union {
320123474Swpaul		uint32_t		gl_lastallocmisses;
321123474Swpaul		uint32_t		gl_lastallochits;
322123474Swpaul	} u_l;
323123474Swpaul	uint32_t		gl_rsvd[2];
324123474Swpaul};
325123474Swpaul
326123474Swpaultypedef struct general_lookaside general_lookaside;
327123474Swpaul
328123474Swpaulstruct npaged_lookaside_list {
329123474Swpaul	general_lookaside	nll_l;
330123474Swpaul	kspin_lock		nll_obsoletelock;
331123474Swpaul};
332123474Swpaul
333123474Swpaultypedef struct npaged_lookaside_list npaged_lookaside_list;
334123474Swpaultypedef struct npaged_lookaside_list paged_lookaside_list;
335123474Swpaul
336123474Swpaultypedef void * (*lookaside_alloc_func)(uint32_t, size_t, uint32_t);
337123474Swpaultypedef void (*lookaside_free_func)(void *);
338123474Swpaul
339125551Swpaulstruct irp;
340123474Swpaul
341125551Swpaulstruct kdevice_qentry {
342125551Swpaul	list_entry		kqe_devlistent;
343125551Swpaul	uint32_t		kqe_sortkey;
344125551Swpaul	uint8_t			kqe_inserted;
345125551Swpaul};
346125551Swpaul
347125551Swpaultypedef struct kdevice_qentry kdevice_qentry;
348125551Swpaul
349125551Swpaulstruct kdevice_queue {
350125551Swpaul	uint16_t		kq_type;
351125551Swpaul	uint16_t		kq_size;
352125551Swpaul	list_entry		kq_devlisthead;
353125551Swpaul	kspin_lock		kq_lock;
354125551Swpaul	uint8_t			kq_busy;
355125551Swpaul};
356125551Swpaul
357125551Swpaultypedef struct kdevice_queue kdevice_queue;
358125551Swpaul
359125551Swpaulstruct wait_ctx_block {
360125551Swpaul	kdevice_qentry		wcb_waitqueue;
361125551Swpaul	void			*wcb_devfunc;
362125551Swpaul	void			*wcb_devctx;
363125551Swpaul	uint32_t		wcb_mapregcnt;
364125551Swpaul	void			*wcb_devobj;
365125551Swpaul	void			*wcb_curirp;
366125551Swpaul	void			*wcb_bufchaindpc;
367125551Swpaul};
368125551Swpaul
369125551Swpaultypedef struct wait_ctx_block wait_ctx_block;
370125551Swpaul
371125551Swpaulstruct wait_block {
372125551Swpaul	list_entry		wb_waitlist;
373125551Swpaul	void			*wb_kthread;
374125551Swpaul	nt_dispatch_header	*wb_object;
375125551Swpaul	struct wait_block	*wb_next;
376125551Swpaul	uint16_t		wb_waitkey;
377125551Swpaul	uint16_t		wb_waittype;
378125551Swpaul};
379125551Swpaul
380125551Swpaultypedef struct wait_block wait_block;
381125551Swpaul
382125551Swpaul#define THREAD_WAIT_OBJECTS	3
383125551Swpaul#define MAX_WAIT_OBJECTS	64
384125551Swpaul
385125551Swpaul#define WAITTYPE_ALL		0
386125551Swpaul#define WAITTYPE_ANY		1
387125551Swpaul
388125551Swpaulstruct thread_context {
389125551Swpaul	void			*tc_thrctx;
390125551Swpaul	void			*tc_thrfunc;
391125551Swpaul};
392125551Swpaul
393125551Swpaultypedef struct thread_context thread_context;
394125551Swpaul
395125551Swpaulstruct device_object {
396125551Swpaul	uint16_t		do_type;
397125551Swpaul	uint16_t		do_size;
398125551Swpaul	uint32_t		do_refcnt;
399125551Swpaul	struct device_object	*do_drvobj;
400125551Swpaul	struct device_object	*do_nextdev;
401125551Swpaul	struct device_object	*do_attacheddev;
402125551Swpaul	struct irp		*do_currirp;
403125551Swpaul	void			*do_iotimer;
404125551Swpaul	uint32_t		do_flags;
405125551Swpaul	uint32_t		do_characteristics;
406125551Swpaul	void			*do_vpb;
407125551Swpaul	void			*do_devext;
408125551Swpaul	uint8_t			do_stacksize;
409125551Swpaul	union {
410125551Swpaul		list_entry		do_listent;
411125551Swpaul		wait_ctx_block		do_wcb;
412125551Swpaul	} queue;
413125551Swpaul	uint32_t		do_alignreq;
414125551Swpaul	kdevice_queue		do_devqueue;
415125551Swpaul	struct kdpc		do_dpc;
416125551Swpaul	uint32_t		do_activethreads;
417125551Swpaul	void			*do_securitydesc;
418125551Swpaul	struct nt_kevent	do_devlock;
419125551Swpaul	uint16_t		do_sectorsz;
420125551Swpaul	uint16_t		do_spare1;
421125551Swpaul	void			*do_devobj_ext;
422125551Swpaul	void			*do_rsvd;
423125551Swpaul};
424125551Swpaul
425125551Swpaultypedef struct device_object device_object;
426125551Swpaul
427125551Swpaulstruct irp {
428125551Swpaul	uint32_t		i_dummy;
429125551Swpaul};
430125551Swpaul
431125551Swpaultypedef struct irp irp;
432125551Swpaul
433125551Swpaultypedef uint32_t (*driver_dispatch)(device_object *, irp *);
434125551Swpaul
435125551Swpaul#define DEVPROP_DEVICE_DESCRIPTION	0x00000000
436125551Swpaul#define DEVPROP_HARDWARE_ID		0x00000001
437125551Swpaul#define DEVPROP_COMPATIBLE_IDS		0x00000002
438125551Swpaul#define DEVPROP_BOOTCONF		0x00000003
439125551Swpaul#define DEVPROP_BOOTCONF_TRANSLATED	0x00000004
440125551Swpaul#define DEVPROP_CLASS_NAME		0x00000005
441125551Swpaul#define DEVPROP_CLASS_GUID		0x00000006
442125551Swpaul#define DEVPROP_DRIVER_KEYNAME		0x00000007
443125551Swpaul#define DEVPROP_MANUFACTURER		0x00000008
444125551Swpaul#define DEVPROP_FRIENDLYNAME		0x00000009
445125551Swpaul#define DEVPROP_LOCATION_INFO		0x0000000A
446125551Swpaul#define DEVPROP_PHYSDEV_NAME		0x0000000B
447125551Swpaul#define DEVPROP_BUSTYPE_GUID		0x0000000C
448125551Swpaul#define DEVPROP_LEGACY_BUSTYPE		0x0000000D
449125551Swpaul#define DEVPROP_BUS_NUMBER		0x0000000E
450125551Swpaul#define DEVPROP_ENUMERATOR_NAME		0x0000000F
451125551Swpaul#define DEVPROP_ADDRESS			0x00000010
452125551Swpaul#define DEVPROP_UINUMBER		0x00000011
453125551Swpaul#define DEVPROP_INSTALL_STATE		0x00000012
454125551Swpaul#define DEVPROP_REMOVAL_POLICY		0x00000013
455125551Swpaul
456125551Swpaul#define STATUS_SUCCESS			0x00000000
457125551Swpaul#define STATUS_USER_APC			0x000000C0
458125551Swpaul#define STATUS_KERNEL_APC		0x00000100
459125551Swpaul#define STATUS_ALERTED			0x00000101
460125551Swpaul#define STATUS_TIMEOUT			0x00000102
461125551Swpaul#define STATUS_INVALID_PARAMETER	0xC000000D
462125551Swpaul#define STATUS_INVALID_DEVICE_REQUEST	0xC0000010
463125551Swpaul#define STATUS_BUFFER_TOO_SMALL		0xC0000023
464125551Swpaul#define STATUS_MUTANT_NOT_OWNED		0xC0000046
465125551Swpaul#define STATUS_INVALID_PARAMETER_2	0xC00000F0
466125551Swpaul
467125551Swpaul#define STATUS_WAIT_0			0x00000000
468125551Swpaul
469127284Swpaul/*
470127284Swpaul * FreeBSD's kernel stack is 2 pages in size by default. The
471127284Swpaul * Windows stack is larger, so we need to give our threads more
472127284Swpaul * stack pages. 4 should be enough, we use 8 just to extra safe.
473127284Swpaul */
474127284Swpaul#define NDIS_KSTACK_PAGES	8
475127284Swpaul
476123474Swpaulextern image_patch_table ntoskrnl_functbl[];
477125551Swpaulextern struct mtx *ntoskrnl_dispatchlock;
478123474Swpaul
479123474Swpaul__BEGIN_DECLS
480123474Swpaulextern int ntoskrnl_libinit(void);
481123474Swpaulextern int ntoskrnl_libfini(void);
482127248Swpaul__stdcall extern void ntoskrnl_init_dpc(kdpc *, void *, void *);
483127552Swpaul__stdcall extern uint8_t ntoskrnl_queue_dpc(kdpc *, void *, void *);
484127552Swpaul__stdcall extern uint8_t ntoskrnl_dequeue_dpc(kdpc *);
485127248Swpaul__stdcall extern void ntoskrnl_init_timer(ktimer *);
486127248Swpaul__stdcall extern void ntoskrnl_init_timer_ex(ktimer *, uint32_t);
487127248Swpaul__stdcall extern uint8_t ntoskrnl_set_timer(ktimer *, int64_t, kdpc *);
488127248Swpaul__stdcall extern uint8_t ntoskrnl_set_timer_ex(ktimer *, int64_t,
489127248Swpaul	uint32_t, kdpc *);
490127248Swpaul__stdcall extern uint8_t ntoskrnl_cancel_timer(ktimer *);
491127248Swpaul__stdcall extern uint8_t ntoskrnl_read_timer(ktimer *);
492127248Swpaul__stdcall uint32_t ntoskrnl_waitforobj(nt_dispatch_header *, uint32_t,
493127248Swpaul	uint32_t, uint8_t, int64_t *);
494127248Swpaul__stdcall void ntoskrnl_init_event(nt_kevent *, uint32_t, uint8_t);
495127248Swpaul__stdcall void ntoskrnl_clear_event(nt_kevent *);
496127248Swpaul__stdcall uint32_t ntoskrnl_read_event(nt_kevent *);
497127248Swpaul__stdcall uint32_t ntoskrnl_set_event(nt_kevent *, uint32_t, uint8_t);
498127248Swpaul__stdcall uint32_t ntoskrnl_reset_event(nt_kevent *);
499123474Swpaul__END_DECLS
500123474Swpaul
501123474Swpaul#endif /* _NTOSKRNL_VAR_H_ */
502