xref: /reactos/win32ss/drivers/videoprt/spinlock.c (revision c2c66aff)
1*c2c66affSColin Finck /*
2*c2c66affSColin Finck  * VideoPort driver
3*c2c66affSColin Finck  *
4*c2c66affSColin Finck  * Copyright (C) 2002, 2003, 2004 ReactOS Team
5*c2c66affSColin Finck  *
6*c2c66affSColin Finck  * This library is free software; you can redistribute it and/or
7*c2c66affSColin Finck  * modify it under the terms of the GNU Lesser General Public
8*c2c66affSColin Finck  * License as published by the Free Software Foundation; either
9*c2c66affSColin Finck  * version 2.1 of the License, or (at your option) any later version.
10*c2c66affSColin Finck  *
11*c2c66affSColin Finck  * This library is distributed in the hope that it will be useful,
12*c2c66affSColin Finck  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13*c2c66affSColin Finck  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14*c2c66affSColin Finck  * Lesser General Public License for more details.
15*c2c66affSColin Finck  *
16*c2c66affSColin Finck  * You should have received a copy of the GNU Lesser General Public
17*c2c66affSColin Finck  * License along with this library; if not, write to the Free Software
18*c2c66affSColin Finck  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
19*c2c66affSColin Finck  *
20*c2c66affSColin Finck  */
21*c2c66affSColin Finck 
22*c2c66affSColin Finck #include "videoprt.h"
23*c2c66affSColin Finck 
24*c2c66affSColin Finck #define NDEBUG
25*c2c66affSColin Finck #include <debug.h>
26*c2c66affSColin Finck 
27*c2c66affSColin Finck /*
28*c2c66affSColin Finck  * @implemented
29*c2c66affSColin Finck  */
30*c2c66affSColin Finck 
31*c2c66affSColin Finck VP_STATUS NTAPI
VideoPortCreateSpinLock(IN PVOID HwDeviceExtension,OUT PSPIN_LOCK * SpinLock)32*c2c66affSColin Finck VideoPortCreateSpinLock(
33*c2c66affSColin Finck    IN PVOID HwDeviceExtension,
34*c2c66affSColin Finck    OUT PSPIN_LOCK *SpinLock)
35*c2c66affSColin Finck {
36*c2c66affSColin Finck    TRACE_(VIDEOPRT, "VideoPortCreateSpinLock\n");
37*c2c66affSColin Finck    *SpinLock = ExAllocatePool(NonPagedPool, sizeof(KSPIN_LOCK));
38*c2c66affSColin Finck    if (*SpinLock == NULL)
39*c2c66affSColin Finck       return ERROR_NOT_ENOUGH_MEMORY;
40*c2c66affSColin Finck    KeInitializeSpinLock((PKSPIN_LOCK)*SpinLock);
41*c2c66affSColin Finck    return NO_ERROR;
42*c2c66affSColin Finck }
43*c2c66affSColin Finck 
44*c2c66affSColin Finck /*
45*c2c66affSColin Finck  * @implemented
46*c2c66affSColin Finck  */
47*c2c66affSColin Finck 
48*c2c66affSColin Finck VP_STATUS NTAPI
VideoPortDeleteSpinLock(IN PVOID HwDeviceExtension,IN PSPIN_LOCK SpinLock)49*c2c66affSColin Finck VideoPortDeleteSpinLock(
50*c2c66affSColin Finck    IN PVOID HwDeviceExtension,
51*c2c66affSColin Finck    IN PSPIN_LOCK SpinLock)
52*c2c66affSColin Finck {
53*c2c66affSColin Finck    TRACE_(VIDEOPRT, "VideoPortDeleteSpinLock\n");
54*c2c66affSColin Finck    ExFreePool(SpinLock);
55*c2c66affSColin Finck    return NO_ERROR;
56*c2c66affSColin Finck }
57*c2c66affSColin Finck 
58*c2c66affSColin Finck /*
59*c2c66affSColin Finck  * @implemented
60*c2c66affSColin Finck  */
61*c2c66affSColin Finck 
62*c2c66affSColin Finck VOID NTAPI
VideoPortAcquireSpinLock(IN PVOID HwDeviceExtension,IN PSPIN_LOCK SpinLock,OUT PUCHAR OldIrql)63*c2c66affSColin Finck VideoPortAcquireSpinLock(
64*c2c66affSColin Finck    IN PVOID HwDeviceExtension,
65*c2c66affSColin Finck    IN PSPIN_LOCK SpinLock,
66*c2c66affSColin Finck    OUT PUCHAR OldIrql)
67*c2c66affSColin Finck {
68*c2c66affSColin Finck    TRACE_(VIDEOPRT, "VideoPortAcquireSpinLock\n");
69*c2c66affSColin Finck    KeAcquireSpinLock((PKSPIN_LOCK)SpinLock, OldIrql);
70*c2c66affSColin Finck }
71*c2c66affSColin Finck 
72*c2c66affSColin Finck /*
73*c2c66affSColin Finck  * @implemented
74*c2c66affSColin Finck  */
75*c2c66affSColin Finck 
76*c2c66affSColin Finck VOID NTAPI
VideoPortAcquireSpinLockAtDpcLevel(IN PVOID HwDeviceExtension,IN PSPIN_LOCK SpinLock)77*c2c66affSColin Finck VideoPortAcquireSpinLockAtDpcLevel(
78*c2c66affSColin Finck    IN PVOID HwDeviceExtension,
79*c2c66affSColin Finck    IN PSPIN_LOCK SpinLock)
80*c2c66affSColin Finck {
81*c2c66affSColin Finck    TRACE_(VIDEOPRT, "VideoPortAcquireSpinLockAtDpcLevel\n");
82*c2c66affSColin Finck    KeAcquireSpinLockAtDpcLevel((PKSPIN_LOCK)SpinLock);
83*c2c66affSColin Finck }
84*c2c66affSColin Finck 
85*c2c66affSColin Finck /*
86*c2c66affSColin Finck  * @implemented
87*c2c66affSColin Finck  */
88*c2c66affSColin Finck 
89*c2c66affSColin Finck VOID NTAPI
VideoPortReleaseSpinLock(IN PVOID HwDeviceExtension,IN PSPIN_LOCK SpinLock,IN UCHAR NewIrql)90*c2c66affSColin Finck VideoPortReleaseSpinLock(
91*c2c66affSColin Finck    IN PVOID HwDeviceExtension,
92*c2c66affSColin Finck    IN PSPIN_LOCK SpinLock,
93*c2c66affSColin Finck    IN UCHAR NewIrql)
94*c2c66affSColin Finck {
95*c2c66affSColin Finck    TRACE_(VIDEOPRT, "VideoPortReleaseSpinLock\n");
96*c2c66affSColin Finck    KeReleaseSpinLock((PKSPIN_LOCK)SpinLock, NewIrql);
97*c2c66affSColin Finck }
98*c2c66affSColin Finck 
99*c2c66affSColin Finck /*
100*c2c66affSColin Finck  * @implemented
101*c2c66affSColin Finck  */
102*c2c66affSColin Finck 
103*c2c66affSColin Finck VOID NTAPI
VideoPortReleaseSpinLockFromDpcLevel(IN PVOID HwDeviceExtension,IN PSPIN_LOCK SpinLock)104*c2c66affSColin Finck VideoPortReleaseSpinLockFromDpcLevel(
105*c2c66affSColin Finck    IN PVOID HwDeviceExtension,
106*c2c66affSColin Finck    IN PSPIN_LOCK SpinLock)
107*c2c66affSColin Finck {
108*c2c66affSColin Finck    TRACE_(VIDEOPRT, "VideoPortReleaseSpinLockFromDpcLevel\n");
109*c2c66affSColin Finck    KeReleaseSpinLockFromDpcLevel((PKSPIN_LOCK)SpinLock);
110*c2c66affSColin Finck }
111