2 * reactos queued spinlock emulation of libcaptive
3 * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; exactly version 2 of June 1991 is required
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 /* no reactos prototype for KeAcquireQueuedSpinLock() and KeReleaseQueuedSpinLock() */
23 #include "reactos/ddk/types.h" /* for KIRQL */
24 #include "reactos/ddk/kefuncs.h" /* for KeGetCurrentIrql() */
25 #include <glib/gmessages.h>
28 typedef enum _KSPIN_LOCK_QUEUE_NUMBER {
29 LockQueueDispatcherLock,
30 LockQueueContextSwapLock,
32 LockQueueSystemSpaceLock,
35 LockQueueNonPagedPoolLock,
36 LockQueueIoCancelLock,
37 LockQueueWorkQueueLock,
39 LockQueueIoDatabaseLock,
40 LockQueueIoCompletionLock,
41 LockQueueNtfsStructLock,
42 LockQueueAfdWorkQueueLock,
45 } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER;
49 * KeAcquireQueuedSpinLock:
50 * @Number: Identification number of queued spinlock to acquire.
52 * Acquires a queued spinlock identified by @Number.
53 * Currently libcaptive doesn't use multithreading
54 * and thus this function is a NOP now. #GMutex would be needed otherwise.
56 * See http://www.compuware.co.jp/drivercentral/resources/spinlocks.asp
58 * Returns: IRQ level before this call. FIXME: What is expected in real? No W32 doc...
60 KIRQL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER Number)
64 return KeGetCurrentIrql();
69 * KeReleaseQueuedSpinLock:
70 * @Number: Identification number of queued spinlock to release.
71 * @OldIrql: Original IRQ level before KeAcquireQueuedSpinLock().
73 * Releases a queued spinlock acquired by KeAcquireQueuedSpinLock().
74 * Currently libcaptive doesn't use multithreading
75 * and thus this function is a NOP now. #GMutex would be needed otherwise.
77 VOID KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER Number,IN KIRQL OldIrql)
84 * KeAcquireQueuedSpinLockRaiseToSynch:
85 * @Number: Identification number of queued spinlock to acquire.
87 * Acquires a queued spinlock identified by @Number.
88 * Currently libcaptive doesn't use multithreading
89 * and thus this function is a NOP now. #GMutex would be needed otherwise.
91 * FIXME: This functions has unknown prototype and functionality, it was only guessed.
93 * See http://www.compuware.co.jp/drivercentral/resources/spinlocks.asp
95 * Returns: IRQ level before this call. FIXME: What is expected in real? No W32 doc...
97 KIRQL KeAcquireQueuedSpinLockRaiseToSynch(IN KSPIN_LOCK_QUEUE_NUMBER Number) /* FIXME: unknown prototype! */
101 return KeGetCurrentIrql();
105 typedef struct _KSPIN_LOCK_QUEUE {
106 struct _KSPIN_LOCK_QUEUE * volatile Next;
107 PKSPIN_LOCK volatile Lock;
108 } KSPIN_LOCK_QUEUE, *PKSPIN_LOCK_QUEUE;
110 typedef struct _KLOCK_QUEUE_HANDLE {
111 KSPIN_LOCK_QUEUE LockQueue;
113 } KLOCK_QUEUE_HANDLE,*PKLOCK_QUEUE_HANDLE;
117 * KeAcquireInStackQueuedSpinLock:
118 * @SpinLock: Spin lock structure to acquire.
119 * %NULL value is forbidden.
120 * @LockHandle: Handle to later pass to KeReleaseInStackQueuedSpinLock().
121 * %NULL value is forbidden.
123 * Acquires a queued spinlock @SpinLock.
124 * You must not mix this call with KeAcquireQueuedSpinLock() for the same @SpinLock.
125 * Currently libcaptive doesn't use multithreading
126 * and thus this function is a NOP now. #GMutex would be needed otherwise.
128 VOID KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock,IN PKLOCK_QUEUE_HANDLE LockHandle)
130 g_return_if_fail(SpinLock!=NULL);
131 g_return_if_fail(LockHandle!=NULL);
138 * KeReleaseInStackQueuedSpinLock:
139 * @LockHandle: Handle from the acquire by KeAcquireInStackQueuedSpinLock().
140 * %NULL value is forbidden.
142 * Releases a queued spinlock acquired by KeAcquireInStackQueuedSpinLock().
143 * Currently libcaptive doesn't use multithreading
144 * and thus this function is a NOP now. #GMutex would be needed otherwise.
146 VOID KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
148 g_return_if_fail(LockHandle!=NULL);