Initial original import from: fuse-2.4.2-2.fc4
[captive.git] / src / libcaptive / halcaptive / queuedspinlock.c
1 /* $Id$
2  * reactos queued spinlock emulation of libcaptive
3  * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
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
8  * 
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.
13  * 
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
17  */
18
19
20 #include "config.h"
21
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>
26
27
28 typedef enum _KSPIN_LOCK_QUEUE_NUMBER {
29         LockQueueDispatcherLock,
30         LockQueueContextSwapLock,
31         LockQueuePfnLock,
32         LockQueueSystemSpaceLock,
33         LockQueueVacbLock,
34         LockQueueMasterLock,
35         LockQueueNonPagedPoolLock,
36         LockQueueIoCancelLock,
37         LockQueueWorkQueueLock,
38         LockQueueIoVpbLock,
39         LockQueueIoDatabaseLock,
40         LockQueueIoCompletionLock,
41         LockQueueNtfsStructLock,
42         LockQueueAfdWorkQueueLock,
43         LockQueueBcbLock,
44         LockQueueMaximumLock
45         } KSPIN_LOCK_QUEUE_NUMBER, *PKSPIN_LOCK_QUEUE_NUMBER;
46
47
48 /**
49  * KeAcquireQueuedSpinLock:
50  * @Number: Identification number of queued spinlock to acquire.
51  *
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.
55  *
56  * See http://www.compuware.co.jp/drivercentral/resources/spinlocks.asp
57  *
58  * Returns: IRQ level before this call. FIXME: What is expected in real? No W32 doc...
59  */
60 KIRQL KeAcquireQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER Number)
61 {
62         /* TODO:thread */
63
64         return KeGetCurrentIrql();
65 }
66
67
68 /**
69  * KeReleaseQueuedSpinLock:
70  * @Number: Identification number of queued spinlock to release.
71  * @OldIrql: Original IRQ level before KeAcquireQueuedSpinLock().
72  *
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.
76  */
77 VOID KeReleaseQueuedSpinLock(IN KSPIN_LOCK_QUEUE_NUMBER Number,IN KIRQL OldIrql)
78 {
79         /* TODO:thread */
80 }
81
82
83 /**
84  * KeAcquireQueuedSpinLockRaiseToSynch:
85  * @Number: Identification number of queued spinlock to acquire.
86  *
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.
90  *
91  * FIXME: This functions has unknown prototype and functionality, it was only guessed.
92  *
93  * See http://www.compuware.co.jp/drivercentral/resources/spinlocks.asp
94  *
95  * Returns: IRQ level before this call. FIXME: What is expected in real? No W32 doc...
96  */
97 KIRQL KeAcquireQueuedSpinLockRaiseToSynch(IN KSPIN_LOCK_QUEUE_NUMBER Number)    /* FIXME: unknown prototype! */
98 {
99         /* TODO:thread */
100
101         return KeGetCurrentIrql();
102 }
103
104
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;
109
110 typedef struct _KLOCK_QUEUE_HANDLE {
111         KSPIN_LOCK_QUEUE LockQueue;
112         KIRQL OldIrql;
113         } KLOCK_QUEUE_HANDLE,*PKLOCK_QUEUE_HANDLE;
114
115
116 /**
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.
122  *
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.
127  */
128 VOID KeAcquireInStackQueuedSpinLock(IN PKSPIN_LOCK SpinLock,IN PKLOCK_QUEUE_HANDLE LockHandle)
129 {
130         g_return_if_fail(SpinLock!=NULL);
131         g_return_if_fail(LockHandle!=NULL);
132
133         /* TODO:thread */
134 }
135
136
137 /**
138  * KeReleaseInStackQueuedSpinLock:
139  * @LockHandle: Handle from the acquire by KeAcquireInStackQueuedSpinLock().
140  * %NULL value is forbidden.
141  *
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.
145  */
146 VOID KeReleaseInStackQueuedSpinLock(IN PKLOCK_QUEUE_HANDLE LockHandle)
147 {
148         g_return_if_fail(LockHandle!=NULL);
149
150         /* TODO:thread */
151 }