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.

373 lines
6.3 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. class.h
  5. Abstract:
  6. These are the structures and defines that are used in the
  7. SCSI class drivers.
  8. Author:
  9. Mike Glass (mglass)
  10. Jeff Havens (jhavens)
  11. Revision History:
  12. --*/
  13. #ifndef _CLASS_
  14. #include <ntdddisk.h>
  15. #include <ntddcdrm.h>
  16. #include <ntddtape.h>
  17. #include <ntddchgr.h>
  18. #include <ntddstor.h>
  19. #include "ntddscsi.h"
  20. #include <stdio.h>
  21. // begin_ntminitape
  22. #if DBG
  23. #define DebugPrint(x) ScsiDebugPrint x
  24. #else
  25. #define DebugPrint(x)
  26. #endif // DBG
  27. // end_ntminitape
  28. #ifdef POOL_TAGGING
  29. #undef ExAllocatePool
  30. #undef ExAllocatePoolWithQuota
  31. #define ExAllocatePool(a,b) ExAllocatePoolWithTag(a,b,'HscS')
  32. #define ExAllocatePoolWithQuota(a,b) ExAllocatePoolWithQuotaTag(a,b,'HscS')
  33. #endif
  34. #define MAXIMUM_RETRIES 4
  35. typedef
  36. VOID
  37. (*PCLASS_ERROR) (
  38. IN PDEVICE_OBJECT DeviceObject,
  39. IN PSCSI_REQUEST_BLOCK Srb,
  40. IN OUT NTSTATUS *Status,
  41. IN OUT BOOLEAN *Retry
  42. );
  43. typedef struct _DEVICE_EXTENSION {
  44. //
  45. // Back pointer to device object
  46. //
  47. PDEVICE_OBJECT DeviceObject;
  48. //
  49. // Pointer to port device object
  50. //
  51. PDEVICE_OBJECT PortDeviceObject;
  52. //
  53. // Length of partition in bytes
  54. //
  55. LARGE_INTEGER PartitionLength;
  56. //
  57. // Number of bytes before start of partition
  58. //
  59. LARGE_INTEGER StartingOffset;
  60. //
  61. // Bytes to skew all requests, since DM Driver has been placed on an IDE drive.
  62. //
  63. ULONG DMByteSkew;
  64. //
  65. // Sectors to skew all requests.
  66. //
  67. ULONG DMSkew;
  68. //
  69. // Flag to indicate whether DM driver has been located on an IDE drive.
  70. //
  71. BOOLEAN DMActive;
  72. //
  73. // Pointer to the specific class error routine.
  74. //
  75. PCLASS_ERROR ClassError;
  76. //
  77. // SCSI port driver capabilities
  78. //
  79. PIO_SCSI_CAPABILITIES PortCapabilities;
  80. //
  81. // Buffer for drive parameters returned in IO device control.
  82. //
  83. PDISK_GEOMETRY DiskGeometry;
  84. //
  85. // Back pointer to device object of physical device
  86. //
  87. PDEVICE_OBJECT PhysicalDevice;
  88. //
  89. // Request Sense Buffer
  90. //
  91. PSENSE_DATA SenseData;
  92. //
  93. // Request timeout in seconds;
  94. //
  95. ULONG TimeOutValue;
  96. //
  97. // System device number
  98. //
  99. ULONG DeviceNumber;
  100. //
  101. // Add default Srb Flags.
  102. //
  103. ULONG SrbFlags;
  104. //
  105. // Total number of SCSI protocol errors on the device.
  106. //
  107. ULONG ErrorCount;
  108. //
  109. // Spinlock for split requests
  110. //
  111. KSPIN_LOCK SplitRequestSpinLock;
  112. //
  113. // Zone header and spin lock for zoned SRB requests.
  114. //
  115. PZONE_HEADER SrbZone;
  116. PKSPIN_LOCK SrbZoneSpinLock;
  117. //
  118. // Lock count for removable media.
  119. //
  120. LONG LockCount;
  121. //
  122. // Scsi port number
  123. //
  124. UCHAR PortNumber;
  125. //
  126. // SCSI path id
  127. //
  128. UCHAR PathId;
  129. //
  130. // SCSI bus target id
  131. //
  132. UCHAR TargetId;
  133. //
  134. // SCSI bus logical unit number
  135. //
  136. UCHAR Lun;
  137. //
  138. // Log2 of sector size
  139. //
  140. UCHAR SectorShift;
  141. //
  142. // Flag to indicate that the device has write caching enabled.
  143. //
  144. BOOLEAN WriteCache;
  145. //
  146. // Build SCSI 1 or SCSI 2 CDBs
  147. //
  148. BOOLEAN UseScsi1;
  149. } DEVICE_EXTENSION, *PDEVICE_EXTENSION;
  150. //
  151. // Define context structure for asynchronous completions.
  152. //
  153. typedef struct _COMPLETION_CONTEXT {
  154. PDEVICE_OBJECT DeviceObject;
  155. SCSI_REQUEST_BLOCK Srb;
  156. }COMPLETION_CONTEXT, *PCOMPLETION_CONTEXT;
  157. NTSTATUS
  158. ScsiClassGetCapabilities(
  159. IN PDEVICE_OBJECT PortDeviceObject,
  160. OUT PIO_SCSI_CAPABILITIES *PortCapabilities
  161. );
  162. NTSTATUS
  163. ScsiClassGetInquiryData(
  164. IN PDEVICE_OBJECT PortDeviceObject,
  165. IN PSCSI_ADAPTER_BUS_INFO *ConfigInfo
  166. );
  167. NTSTATUS
  168. ScsiClassReadDriveCapacity(
  169. IN PDEVICE_OBJECT DeviceObject
  170. );
  171. VOID
  172. ScsiClassReleaseQueue(
  173. IN PDEVICE_OBJECT DeviceObject
  174. );
  175. NTSTATUS
  176. ScsiClassRemoveDevice(
  177. IN PDEVICE_OBJECT PortDeviceObject,
  178. IN UCHAR PathId,
  179. IN UCHAR TargetId,
  180. IN UCHAR Lun
  181. );
  182. NTSTATUS
  183. ScsiClassAsynchronousCompletion(
  184. PDEVICE_OBJECT DeviceObject,
  185. PIRP Irp,
  186. PVOID Context
  187. );
  188. VOID
  189. ScsiClassSplitRequest(
  190. IN PDEVICE_OBJECT DeviceObject,
  191. IN PIRP Irp,
  192. IN ULONG MaximumBytes
  193. );
  194. NTSTATUS
  195. ScsiClassDeviceControl(
  196. PDEVICE_OBJECT DeviceObject,
  197. PIRP Irp
  198. );
  199. NTSTATUS
  200. ScsiClassIoComplete(
  201. IN PDEVICE_OBJECT DeviceObject,
  202. IN PIRP Irp,
  203. IN PVOID Context
  204. );
  205. NTSTATUS
  206. ScsiClassIoCompleteAssociated(
  207. IN PDEVICE_OBJECT DeviceObject,
  208. IN PIRP Irp,
  209. IN PVOID Context
  210. );
  211. BOOLEAN
  212. ScsiClassInterpretSenseInfo(
  213. IN PDEVICE_OBJECT DeviceObject,
  214. IN PSCSI_REQUEST_BLOCK Srb,
  215. IN UCHAR MajorFunctionCode,
  216. IN ULONG IoDeviceCode,
  217. IN ULONG RetryCount,
  218. OUT NTSTATUS *Status
  219. );
  220. NTSTATUS
  221. ScsiClassSendSrbSynchronous(
  222. PDEVICE_OBJECT DeviceObject,
  223. PSCSI_REQUEST_BLOCK Srb,
  224. PVOID BufferAddress,
  225. ULONG BufferLength,
  226. BOOLEAN WriteToDevice
  227. );
  228. NTSTATUS
  229. ScsiClassSendSrbAsynchronous(
  230. PDEVICE_OBJECT DeviceObject,
  231. PSCSI_REQUEST_BLOCK Srb,
  232. PIRP Irp,
  233. PVOID BufferAddress,
  234. ULONG BufferLength,
  235. BOOLEAN WriteToDevice
  236. );
  237. VOID
  238. ScsiClassBuildRequest(
  239. PDEVICE_OBJECT DeviceObject,
  240. PIRP Irp
  241. );
  242. ULONG
  243. ScsiClassModeSense(
  244. IN PDEVICE_OBJECT DeviceObject,
  245. IN PCHAR ModeSenseBuffer,
  246. IN ULONG Length,
  247. IN UCHAR PageMode
  248. );
  249. BOOLEAN
  250. ScsiClassModeSelect(
  251. IN PDEVICE_OBJECT DeviceObject,
  252. IN PCHAR ModeSelectBuffer,
  253. IN ULONG Length,
  254. IN BOOLEAN SavePage
  255. );
  256. PVOID
  257. ScsiClassFindModePage(
  258. IN PCHAR ModeSenseBuffer,
  259. IN ULONG Length,
  260. IN UCHAR PageMode
  261. );
  262. NTSTATUS
  263. ScsiClassClaimDevice(
  264. IN PDEVICE_OBJECT PortDeviceObject,
  265. IN PSCSI_INQUIRY_DATA LunInfo,
  266. IN BOOLEAN Release,
  267. OUT PDEVICE_OBJECT *NewPortDeviceObject OPTIONAL
  268. );
  269. NTSTATUS
  270. ScsiClassInternalIoControl (
  271. IN PDEVICE_OBJECT DeviceObject,
  272. IN PIRP Irp
  273. );
  274. #endif /* _CLASS_ */