Source code of Windows XP (NT5)
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.

412 lines
8.1 KiB

  1. /*++
  2. Copyright (c) 1999 Microsoft Corporation
  3. Module Name:
  4. verifeir.h
  5. Abstract:
  6. This module contains the internal structure definitions and APIs used by
  7. Driver Verifier.
  8. Author:
  9. Jordan Tigani (jtigani) 2-May-2000
  10. Silviu Calinoiu (silviuc) 9-May-2000
  11. Revision History:
  12. --*/
  13. #ifndef _VERIFIER_
  14. #define _VERIFIER_
  15. //
  16. // Resource types handled by deadlock detection package.
  17. //
  18. typedef enum _VI_DEADLOCK_RESOURCE_TYPE {
  19. VfDeadlockUnknown = 0,
  20. VfDeadlockMutex,
  21. VfDeadlockFastMutex,
  22. VfDeadlockFastMutexUnsafe,
  23. VfDeadlockSpinLock,
  24. VfDeadlockQueuedSpinLock,
  25. VfDeadlockTypeMaximum
  26. } VI_DEADLOCK_RESOURCE_TYPE, *PVI_DEADLOCK_RESOURCE_TYPE;
  27. //
  28. // HAL Verifier functions
  29. //
  30. struct _DMA_ADAPTER *
  31. VfGetDmaAdapter(
  32. IN PDEVICE_OBJECT PhysicalDeviceObject,
  33. IN struct _DEVICE_DESCRIPTION *DeviceDescription,
  34. IN OUT PULONG NumberOfMapRegisters
  35. );
  36. PVOID
  37. VfAllocateCrashDumpRegisters(
  38. IN PADAPTER_OBJECT AdapterObject,
  39. IN PULONG NumberOfMapRegisters
  40. );
  41. #if !defined(NO_LEGACY_DRIVERS)
  42. VOID
  43. VfPutDmaAdapter(
  44. struct _DMA_ADAPTER * DmaAdapter
  45. );
  46. PVOID
  47. VfAllocateCommonBuffer(
  48. IN struct _DMA_ADAPTER * DmaAdapter,
  49. IN ULONG Length,
  50. OUT PPHYSICAL_ADDRESS LogicalAddress,
  51. IN BOOLEAN CacheEnabled
  52. );
  53. VOID
  54. VfFreeCommonBuffer(
  55. IN struct _DMA_ADAPTER * DmaAdapter,
  56. IN ULONG Length,
  57. IN PHYSICAL_ADDRESS LogicalAddress,
  58. IN PVOID VirtualAddress,
  59. IN BOOLEAN CacheEnabled
  60. );
  61. NTSTATUS
  62. VfAllocateAdapterChannel(
  63. IN struct _DMA_ADAPTER * DmaAdapter,
  64. IN PDEVICE_OBJECT DeviceObject,
  65. IN ULONG NumberOfMapRegisters,
  66. IN PDRIVER_CONTROL ExecutionRoutine,
  67. IN PVOID Context
  68. );
  69. PHYSICAL_ADDRESS
  70. VfMapTransfer(
  71. IN struct _DMA_ADAPTER * DmaAdapter,
  72. IN PMDL Mdl,
  73. IN PVOID MapRegisterBase,
  74. IN PVOID CurrentVa,
  75. IN OUT PULONG Length,
  76. IN BOOLEAN WriteToDevice
  77. );
  78. BOOLEAN
  79. VfFlushAdapterBuffers(
  80. IN struct _DMA_ADAPTER * DmaAdapter,
  81. IN PMDL Mdl,
  82. IN PVOID MapRegisterBase,
  83. IN PVOID CurrentVa,
  84. IN ULONG Length,
  85. IN BOOLEAN WriteToDevice
  86. );
  87. VOID
  88. VfFreeAdapterChannel(
  89. IN struct _DMA_ADAPTER * DmaAdapter
  90. );
  91. VOID
  92. VfFreeMapRegisters(
  93. IN struct _DMA_ADAPTER * DmaAdapter,
  94. PVOID MapRegisterBase,
  95. ULONG NumberOfMapRegisters
  96. );
  97. ULONG
  98. VfGetDmaAlignment(
  99. IN struct _DMA_ADAPTER * DmaAdapter
  100. );
  101. ULONG
  102. VfReadDmaCounter(
  103. IN struct _DMA_ADAPTER * DmaAdapter
  104. );
  105. NTSTATUS
  106. VfGetScatterGatherList (
  107. IN struct _DMA_ADAPTER * DmaAdapter,
  108. IN PDEVICE_OBJECT DeviceObject,
  109. IN PMDL Mdl,
  110. IN PVOID CurrentVa,
  111. IN ULONG Length,
  112. IN PVOID ExecutionRoutine,
  113. IN PVOID Context,
  114. IN BOOLEAN WriteToDevice
  115. );
  116. VOID
  117. VfPutScatterGatherList(
  118. IN struct _DMA_ADAPTER * DmaAdapter,
  119. IN struct _SCATTER_GATHER_LIST * ScatterGather,
  120. IN BOOLEAN WriteToDevice
  121. );
  122. PADAPTER_OBJECT
  123. VfLegacyGetAdapter(
  124. IN struct _DEVICE_DESCRIPTION *DeviceDescription,
  125. IN OUT PULONG NumberOfMapRegisters
  126. );
  127. #endif
  128. LARGE_INTEGER
  129. VfQueryPerformanceCounter(
  130. IN PLARGE_INTEGER PerformanceFrequency OPTIONAL
  131. );
  132. VOID
  133. VfHalDeleteDevice(
  134. IN PDEVICE_OBJECT DeviceObject
  135. );
  136. VOID
  137. VfDisableHalVerifier (
  138. VOID
  139. );
  140. //
  141. // Resource interfaces for deadlock detection package.
  142. //
  143. VOID
  144. VfDeadlockDetectionInitialize(
  145. IN LOGICAL VerifyAllDrivers,
  146. IN LOGICAL VerifyKernel
  147. );
  148. VOID
  149. VfDeadlockDetectionCleanup (
  150. VOID
  151. );
  152. BOOLEAN
  153. VfDeadlockInitializeResource(
  154. IN PVOID Resource,
  155. IN VI_DEADLOCK_RESOURCE_TYPE Type,
  156. IN PVOID Caller,
  157. IN BOOLEAN DoNotAcquireLock
  158. );
  159. VOID
  160. VfDeadlockAcquireResource(
  161. IN PVOID Resource,
  162. IN VI_DEADLOCK_RESOURCE_TYPE Type,
  163. IN PKTHREAD Thread,
  164. IN BOOLEAN TryAcquire,
  165. IN PVOID Caller
  166. );
  167. VOID
  168. VfDeadlockReleaseResource(
  169. IN PVOID Resource,
  170. IN VI_DEADLOCK_RESOURCE_TYPE Type,
  171. IN PKTHREAD Thread,
  172. IN PVOID Caller
  173. );
  174. //
  175. // Used for resource garbage collection.
  176. //
  177. VOID
  178. VfDeadlockDeleteMemoryRange(
  179. IN PVOID Address,
  180. IN SIZE_T Size
  181. );
  182. //
  183. // Notification from the pool manager so deadlock hierarchies can be terminated.
  184. //
  185. VOID
  186. VerifierDeadlockFreePool(
  187. IN PVOID Address,
  188. IN SIZE_T NumberOfBytes
  189. );
  190. //
  191. // Verifier versions to catch file I/O above PASSIVE_LEVEL
  192. //
  193. NTSTATUS
  194. VerifierNtCreateFile(
  195. OUT PHANDLE FileHandle,
  196. IN ACCESS_MASK DesiredAccess,
  197. IN POBJECT_ATTRIBUTES ObjectAttributes,
  198. OUT PIO_STATUS_BLOCK IoStatusBlock,
  199. IN PLARGE_INTEGER AllocationSize OPTIONAL,
  200. IN ULONG FileAttributes,
  201. IN ULONG ShareAccess,
  202. IN ULONG CreateDisposition,
  203. IN ULONG CreateOptions,
  204. IN PVOID EaBuffer OPTIONAL,
  205. IN ULONG EaLength
  206. );
  207. NTSTATUS
  208. VerifierNtWriteFile(
  209. IN HANDLE FileHandle,
  210. IN HANDLE Event OPTIONAL,
  211. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  212. IN PVOID ApcContext OPTIONAL,
  213. OUT PIO_STATUS_BLOCK IoStatusBlock,
  214. IN PVOID Buffer,
  215. IN ULONG Length,
  216. IN PLARGE_INTEGER ByteOffset OPTIONAL,
  217. IN PULONG Key OPTIONAL
  218. );
  219. NTSTATUS
  220. VerifierNtReadFile(
  221. IN HANDLE FileHandle,
  222. IN HANDLE Event OPTIONAL,
  223. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  224. IN PVOID ApcContext OPTIONAL,
  225. OUT PIO_STATUS_BLOCK IoStatusBlock,
  226. OUT PVOID Buffer,
  227. IN ULONG Length,
  228. IN PLARGE_INTEGER ByteOffset OPTIONAL,
  229. IN PULONG Key OPTIONAL
  230. );
  231. typedef enum {
  232. //
  233. // Bugs in this class are severe enough that the hardware should be removed
  234. // from a running production machine.
  235. //
  236. VFFAILURE_FAIL_IN_FIELD = 0,
  237. //
  238. // Bugs of this class are severe enough for WHQL to deny a logo for the
  239. // failing whateverware.
  240. //
  241. VFFAILURE_FAIL_LOGO = 1,
  242. //
  243. // Bugs of this class stop the machine only if it is running under a kernel
  244. // debugger.
  245. //
  246. VFFAILURE_FAIL_UNDER_DEBUGGER = 2
  247. } VF_FAILURE_CLASS, *PVF_FAILURE_CLASS;
  248. //
  249. // Example usage: (note - perMinorFlags statically preinitialized to zero)
  250. //
  251. // VfFailDeviceNode(
  252. // PhysicalDeviceObject
  253. // major,
  254. // minor,
  255. // VFFAILURE_FAIL_LOGO,
  256. // &perMinorFlags,
  257. // "Device %DevObj mishandled register %Ulong",
  258. // "%Ulong%DevObj",
  259. // value,
  260. // deviceObject
  261. // );
  262. //
  263. VOID
  264. VfFailDeviceNode(
  265. IN PDEVICE_OBJECT PhysicalDeviceObject,
  266. IN ULONG BugCheckMajorCode,
  267. IN ULONG BugCheckMinorCode,
  268. IN VF_FAILURE_CLASS FailureClass,
  269. IN OUT PULONG AssertionControl,
  270. IN PSTR DebuggerMessageText,
  271. IN PSTR ParameterFormatString,
  272. ...
  273. );
  274. //
  275. // Example usage: (note - perMinorFlags statically preinitialized to zero)
  276. //
  277. // VfFailDriver(
  278. // major,
  279. // minor,
  280. // VFFAILURE_FAIL_LOGO,
  281. // &perMinorFlags,
  282. // "Driver at %Routine returned %Ulong",
  283. // "%Ulong%Routine",
  284. // value,
  285. // routine
  286. // );
  287. //
  288. VOID
  289. VfFailDriver(
  290. IN ULONG BugCheckMajorCode,
  291. IN ULONG BugCheckMinorCode,
  292. IN VF_FAILURE_CLASS FailureClass,
  293. IN OUT PULONG AssertionControl,
  294. IN PSTR DebuggerMessageText,
  295. IN PSTR ParameterFormatString,
  296. ...
  297. );
  298. //
  299. // Example usage: (note - perMinorFlags statically preinitialized to zero)
  300. //
  301. // VfFailSystemBIOS(
  302. // major,
  303. // minor,
  304. // VFFAILURE_FAIL_LOGO,
  305. // &perMinorFlags,
  306. // "Driver at %Routine returned %Ulong",
  307. // "%Ulong%Routine",
  308. // value,
  309. // routine
  310. // );
  311. //
  312. VOID
  313. VfFailSystemBIOS(
  314. IN ULONG BugCheckMajorCode,
  315. IN ULONG BugCheckMinorCode,
  316. IN VF_FAILURE_CLASS FailureClass,
  317. IN OUT PULONG AssertionControl,
  318. IN PSTR DebuggerMessageText,
  319. IN PSTR ParameterFormatString,
  320. ...
  321. );
  322. typedef enum {
  323. //
  324. // Driver object
  325. //
  326. VFOBJTYPE_DRIVER = 0,
  327. //
  328. // Physical Device Object pointing to hardware
  329. //
  330. VFOBJTYPE_DEVICE,
  331. //
  332. // System BIOS (no object)
  333. //
  334. VFOBJTYPE_SYSTEM_BIOS
  335. } VF_OBJECT_TYPE;
  336. BOOLEAN
  337. VfIsVerificationEnabled(
  338. IN VF_OBJECT_TYPE VfObjectType,
  339. IN PVOID Object OPTIONAL
  340. );
  341. #endif