Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

367 lines
6.7 KiB

  1. /*
  2. Copyright (c) 1990-1996 Microsoft Corporation
  3. Module Name:
  4. cmddk.h
  5. Abstract:
  6. This module defines the structures, macros, and functions missing from
  7. ndis.h when you specify BINARY_COMPATIBLE=1 but do not include ntddk.h
  8. Revision History:
  9. Who When What
  10. -------- -------- ----------------------------------------------
  11. alid 10-14-96 Created
  12. --*/
  13. #ifndef _CMDDK_INCLUDED_
  14. #define _CMDDK_INCLUDED_
  15. //
  16. // needed by cxport.h taken from ntddk.h
  17. //
  18. typedef
  19. VOID
  20. (*PWORKER_THREAD_ROUTINE)(
  21. IN PVOID Parameter
  22. );
  23. typedef struct _WORK_QUEUE_ITEM {
  24. LIST_ENTRY List;
  25. PWORKER_THREAD_ROUTINE WorkerRoutine;
  26. PVOID Parameter;
  27. } WORK_QUEUE_ITEM, *PWORK_QUEUE_ITEM;
  28. NTKERNELAPI
  29. BOOLEAN
  30. KeCancelTimer (
  31. IN PKTIMER
  32. );
  33. //
  34. // Spin Lock
  35. //
  36. // typedef ULONG KSPIN_LOCK; // winnt ntndis
  37. // typedef KSPIN_LOCK *PKSPIN_LOCK;
  38. #define ExInterlockedPopEntryList ExfInterlockedPopEntryList
  39. #define ExInterlockedPushEntryList ExfInterlockedPushEntryList
  40. NTKERNELAPI
  41. PSINGLE_LIST_ENTRY
  42. FASTCALL
  43. ExInterlockedPopEntryList (
  44. IN PSINGLE_LIST_ENTRY ListHead,
  45. IN PKSPIN_LOCK Lock
  46. );
  47. NTKERNELAPI
  48. PSINGLE_LIST_ENTRY
  49. FASTCALL
  50. ExInterlockedPushEntryList (
  51. IN PSINGLE_LIST_ENTRY ListHead,
  52. IN PSINGLE_LIST_ENTRY ListEntry,
  53. IN PKSPIN_LOCK Lock
  54. );
  55. NTKERNELAPI
  56. VOID
  57. NTAPI
  58. KeInitializeSpinLock (
  59. IN PKSPIN_LOCK SpinLock
  60. );
  61. #if defined(_X86_)
  62. NTKERNELAPI
  63. VOID
  64. FASTCALL
  65. KefAcquireSpinLockAtDpcLevel (
  66. IN PKSPIN_LOCK SpinLock
  67. );
  68. NTKERNELAPI
  69. VOID
  70. FASTCALL
  71. KefReleaseSpinLockFromDpcLevel (
  72. IN PKSPIN_LOCK SpinLock
  73. );
  74. #define KeAcquireSpinLockAtDpcLevel(a) KefAcquireSpinLockAtDpcLevel(a)
  75. #define KeReleaseSpinLockFromDpcLevel(a) KefReleaseSpinLockFromDpcLevel(a)
  76. #else
  77. NTKERNELAPI
  78. VOID
  79. KeAcquireSpinLockAtDpcLevel (
  80. IN PKSPIN_LOCK SpinLock
  81. );
  82. NTKERNELAPI
  83. VOID
  84. KeReleaseSpinLockFromDpcLevel (
  85. IN PKSPIN_LOCK SpinLock
  86. );
  87. #endif
  88. #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || (defined(_X86_) && !defined(_NTHAL_))
  89. // begin_wdm
  90. #if defined(_X86_)
  91. __declspec(dllimport)
  92. KIRQL
  93. FASTCALL
  94. KfAcquireSpinLock (
  95. IN PKSPIN_LOCK SpinLock
  96. );
  97. __declspec(dllimport)
  98. VOID
  99. FASTCALL
  100. KfReleaseSpinLock (
  101. IN PKSPIN_LOCK SpinLock,
  102. IN KIRQL NewIrql
  103. );
  104. __declspec(dllimport)
  105. KIRQL
  106. FASTCALL
  107. KeAcquireSpinLockRaiseToSynch (
  108. IN PKSPIN_LOCK SpinLock
  109. );
  110. #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
  111. #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
  112. #else
  113. __declspec(dllimport)
  114. KIRQL
  115. KeAcquireSpinLockRaiseToDpc (
  116. IN PKSPIN_LOCK SpinLock
  117. );
  118. #define KeAcquireSpinLock(SpinLock, OldIrql) \
  119. *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock)
  120. __declspec(dllimport)
  121. VOID
  122. KeReleaseSpinLock (
  123. IN PKSPIN_LOCK SpinLock,
  124. IN KIRQL NewIrql
  125. );
  126. #endif
  127. // end_wdm
  128. #else
  129. #if defined(_X86_)
  130. KIRQL
  131. FASTCALL
  132. KfAcquireSpinLock (
  133. IN PKSPIN_LOCK SpinLock
  134. );
  135. VOID
  136. FASTCALL
  137. KfReleaseSpinLock (
  138. IN PKSPIN_LOCK SpinLock,
  139. IN KIRQL NewIrql
  140. );
  141. #define KeAcquireSpinLock(a,b) *(b) = KfAcquireSpinLock(a)
  142. #define KeReleaseSpinLock(a,b) KfReleaseSpinLock(a,b)
  143. KIRQL
  144. FASTCALL
  145. KeAcquireSpinLockRaiseToSynch (
  146. IN PKSPIN_LOCK SpinLock
  147. );
  148. #else
  149. KIRQL
  150. KeAcquireSpinLockRaiseToDpc (
  151. IN PKSPIN_LOCK SpinLock
  152. );
  153. KIRQL
  154. KeAcquireSpinLockRaiseToSynch (
  155. IN PKSPIN_LOCK SpinLock
  156. );
  157. #define KeAcquireSpinLock(SpinLock, OldIrql) \
  158. *(OldIrql) = KeAcquireSpinLockRaiseToDpc(SpinLock)
  159. VOID
  160. KeReleaseSpinLock (
  161. IN PKSPIN_LOCK SpinLock,
  162. IN KIRQL NewIrql
  163. );
  164. #endif
  165. #endif
  166. #if defined(NT_UP) && !DBG && !defined(_NTDDK_) && !defined(_NTIFS_)
  167. #if !defined(_NTDRIVER_)
  168. #define ExAcquireSpinLock(Lock, OldIrql) (*OldIrql) = KeRaiseIrqlToDpcLevel();
  169. #define ExReleaseSpinLock(Lock, OldIrql) KeLowerIrql((OldIrql))
  170. #else
  171. #define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql))
  172. #define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql))
  173. #endif
  174. #define ExAcquireSpinLockAtDpcLevel(Lock)
  175. #define ExReleaseSpinLockFromDpcLevel(Lock)
  176. #else
  177. // begin_wdm
  178. #define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql))
  179. #define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql))
  180. #define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock)
  181. #define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock)
  182. // end_wdm
  183. #endif
  184. NTKERNELAPI
  185. KIRQL
  186. KfRaiseIrqlToDpcLevel (
  187. VOID
  188. );
  189. #define KeRaiseIrqlToDpcLevel(OldIrql) (*(OldIrql) = KfRaiseIrqlToDpcLevel())
  190. NTKERNELAPI
  191. KIRQL
  192. KeRaiseIrqlToSynchLevel (
  193. VOID
  194. );
  195. // end_nthal end_wdm
  196. #if defined(NT_UP) && !defined(_NTDDK_) && !defined(_NTIFS_)
  197. #define ExAcquireSpinLock(Lock, OldIrql) KeRaiseIrqlToDpcLevel((OldIrql))
  198. #define ExReleaseSpinLock(Lock, OldIrql) KeLowerIrql((OldIrql))
  199. #define ExAcquireSpinLockAtDpcLevel(Lock)
  200. #define ExReleaseSpinLockFromDpcLevel(Lock)
  201. #else
  202. // begin_wdm
  203. #define ExAcquireSpinLock(Lock, OldIrql) KeAcquireSpinLock((Lock), (OldIrql))
  204. #define ExReleaseSpinLock(Lock, OldIrql) KeReleaseSpinLock((Lock), (OldIrql))
  205. #define ExAcquireSpinLockAtDpcLevel(Lock) KeAcquireSpinLockAtDpcLevel(Lock)
  206. #define ExReleaseSpinLockFromDpcLevel(Lock) KeReleaseSpinLockFromDpcLevel(Lock)
  207. // end_wdm
  208. #endif
  209. //
  210. // Event type
  211. //
  212. typedef enum _EVENT_TYPE {
  213. NotificationEvent,
  214. SynchronizationEvent
  215. } EVENT_TYPE;
  216. #if defined(_NTDRIVER_) || defined(_NTDDK_) || defined(_NTIFS_) || defined(_NTHAL_)
  217. // begin_wdm
  218. NTKERNELAPI
  219. VOID
  220. KeInitializeEvent (
  221. IN PRKEVENT Event,
  222. IN EVENT_TYPE Type,
  223. IN BOOLEAN State
  224. );
  225. NTKERNELAPI
  226. VOID
  227. KeClearEvent (
  228. IN PRKEVENT Event
  229. );
  230. // end_wdm
  231. #else
  232. #define KeInitializeEvent(_Event, _Type, _State) \
  233. (_Event)->Header.Type = (UCHAR)_Type; \
  234. (_Event)->Header.Size = sizeof(KEVENT) / sizeof(LONG); \
  235. (_Event)->Header.SignalState = _State; \
  236. InitializeListHead(&(_Event)->Header.WaitListHead)
  237. #define KeClearEvent(Event) (Event)->Header.SignalState = 0
  238. #endif
  239. LONG
  240. FASTCALL
  241. InterlockedIncrement(
  242. IN PLONG Addend
  243. );
  244. #ifndef ATMARP_WIN98
  245. NTSYSAPI
  246. ULONG
  247. NTAPI
  248. RtlCompareMemory (
  249. PVOID Source1,
  250. PVOID Source2,
  251. ULONG Length
  252. );
  253. #endif
  254. NTKERNELAPI
  255. PVOID
  256. ExAllocatePool(
  257. IN POOL_TYPE PoolType,
  258. IN ULONG NumberOfBytes
  259. );
  260. NTKERNELAPI
  261. VOID
  262. NTAPI
  263. ExFreePool(
  264. IN PVOID P
  265. );
  266. #endif // _CMDDK_INCLUDED_