ReactOS  0.4.15-dev-3440-g915569a
fxspinlockapi.cpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxSpinLockAPI.cpp
8 
9 Abstract:
10 
11  This module implements external APIS to access FxSpinLock
12 
13 Author:
14 
15 
16 
17 Environment:
18 
19  Both kernel and user mode
20 
21 Revision History:
22 
23 --*/
24 
25 #include "fxsupportpch.hpp"
26 #include "fxspinlock.hpp"
27 
28 extern "C" {
29 // #include "FxSpinLockAPI.tmh"
30 }
31 
32 //
33 // Extern the entire file
34 //
35 extern "C" {
36 
40 STDCALL
41 WDFEXPORT(WdfSpinLockCreate)(
42  __in
44  __in_opt
46  __out
47  WDFSPINLOCK* SpinLock
48  )
49 {
50  DDI_ENTRY();
51 
55  WDFSPINLOCK lock;
57 
59 
60  //
61  // Get the parent's globals if it is present
62  //
66 
68  SpinLockAttributes->ParentObject,
70  (PVOID*)&pParent,
72  }
73 
75 
77  if (!NT_SUCCESS(status)) {
78  return status;
79  }
80 
82  extra = sizeof(FX_SPIN_LOCK_HISTORY);
83  }
84  else {
85  extra = 0;
86  }
87 
88  *SpinLock = NULL;
89 
92 
93  if (pLock == NULL) {
95  }
96 
98 
100  *SpinLock = lock;
101  }
102  else {
104  }
105 
106  return status;
107 }
108 
111 VOID
112 STDCALL
113 WDFEXPORT(WdfSpinLockAcquire)(
114  __in
116  __in
119  _Acquires_lock_(_Curr_)
120  WDFSPINLOCK SpinLock
121  )
122 {
123  DDI_ENTRY();
124 
126  FxSpinLock* pLock;
127 
129  SpinLock,
131  (PVOID*) &pLock,
133 
134  if (pLock->IsInterruptLock()) {
136  "WDFSPINLOCK %p is associated with an interrupt, "
137  "cannot be used for normal sync operations",
138  SpinLock);
140  return;
141  }
142 
143  pLock->AcquireLock(
145 }
146 
149 VOID
150 STDCALL
151 WDFEXPORT(WdfSpinLockRelease)(
152  __in
154  __in
157  _Releases_lock_(_Curr_)
158  WDFSPINLOCK SpinLock
159  )
160 {
161  DDI_ENTRY();
162 
164  FxSpinLock* pLock;
165 
167  SpinLock,
169  (PVOID*) &pLock,
171 
172  if (pLock->IsInterruptLock()) {
174  "WDFSPINLOCK %p is associated with an interrupt, "
175  "cannot be used for normal sync operations",
176  SpinLock);
178  return;
179  }
180 
181  pLock->ReleaseLock();
182 }
183 
184 } // extern "C"
#define DDI_ENTRY()
Definition: fxglobalskm.h:56
PFX_DRIVER_GLOBALS pFxDriverGlobals
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ NTSTATUS Commit(__in_opt PWDF_OBJECT_ATTRIBUTES Attributes, __out_opt WDFOBJECT *ObjectHandle, __in_opt FxObject *Parent=NULL, __in BOOLEAN AssignDriverAsDefaultParent=TRUE)
Definition: fxobject.cpp:904
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES SpinLockAttributes
Definition: wdfsync.h:225
#define __in_opt
Definition: dbghelp.h:38
#define __drv_restoresIRQL
Definition: driverspecs.h:321
LONG NTSTATUS
Definition: precomp.h:26
USHORT extra
__drv_raisesIRQL(DISPATCH_LEVEL) __drv_maxIRQL(DISPATCH_LEVEL) VOID STDCALL WDFEXPORT(WdfSpinLockAcquire)(__in PWDF_DRIVER_GLOBALS DriverGlobals
DriverGlobals
#define WDFEXPORT(a)
Definition: fxmacros.hpp:157
#define _Releases_lock_(a)
Definition: btrfs_drv.h:208
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFSPINLOCK * SpinLock
Definition: wdfsync.h:225
_Must_inspect_result_ NTSTATUS __inline FxValidateObjectAttributesForParentHandle(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
#define __out
Definition: dbghelp.h:62
_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES SpinLockAttributes
BOOLEAN FxVerifierLock
Definition: fxglobals.h:451
_Must_inspect_result_ __drv_maxIRQL(DISPATCH_LEVEL) NTSTATUS STDCALL WDFEXPORT(WdfSpinLockCreate)(__in PWDF_DRIVER_GLOBALS DriverGlobals
#define STDCALL
Definition: wdf.h:45
WDFSPINLOCK lock
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FxSpinLock * pLock
_Must_inspect_result_ NTSTATUS FxValidateObjectAttributes(__in PFX_DRIVER_GLOBALS FxDriverGlobals, __in PWDF_OBJECT_ATTRIBUTES Attributes, __in ULONG Flags=FX_VALIDATE_OPTION_NONE_SPECIFIED)
#define _Must_inspect_result_
Definition: ms_sal.h:558
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
_Must_inspect_result_ __in_opt PWDF_OBJECT_ATTRIBUTES __out WDFSPINLOCK * SpinLock
unsigned short USHORT
Definition: pedump.c:61
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define __drv_savesIRQL
Definition: driverspecs.h:325
#define NULL
Definition: types.h:112
__in __drv_savesIRQL _Requires_lock_not_held_(_Curr_) _Acquires_lock_(_Curr_) WDFSPINLOCK SpinLock)
VOID DeleteFromFailedCreate(VOID)
Definition: fxobject.cpp:391
void * _ReturnAddress(void)
__in __drv_restoresIRQL _Requires_lock_held_(_Curr_) _Releases_lock_(_Curr_) WDFSPINLOCK SpinLock)
FxObject * pParent
Definition: fxdpcapi.cpp:86
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), Device, FX_TYPE_DEVICE,(PVOID *)&pDevice, &pFxDriverGlobals)
NTSTATUS status
__inline PFX_DRIVER_GLOBALS GetFxDriverGlobals(__in PWDF_DRIVER_GLOBALS DriverGlobals)
Definition: fxglobals.h:597
BOOLEAN IsInterruptLock(VOID)
Definition: fxspinlock.hpp:81
FxPointerNotNull(pFxDriverGlobals, SpinLock)
#define _Acquires_lock_(lock)
#define TRACINGERROR
Definition: dbgtrace.h:63
#define __in
Definition: dbghelp.h:35
#define __drv_minIRQL(irql)
Definition: driverspecs.h:292
FxVerifierDbgBreakPoint(pFxDriverGlobals)
Definition: ps.c:97