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.

327 lines
8.2 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. private.h
  5. Abstract:
  6. Prototypes and definitions for the scsi scanner device driver.
  7. Author:
  8. Ray Patrick (raypat)
  9. Environment:
  10. kernel mode only
  11. Notes:
  12. Revision History:
  13. --*/
  14. #ifndef _SCSISCAN_PRIAVATE_
  15. #define _SCSISCAN_PRIAVATE_
  16. // Includes
  17. #include "debug.h"
  18. #include "scsiscan.h"
  19. // Defines
  20. #define MAXIMUM_RETRIES 4
  21. #define SCSISCAN_TIMEOUT 600
  22. #define SRB SCSI_REQUEST_BLOCK
  23. #define PSRB PSCSI_REQUEST_BLOCK
  24. // Typedefs
  25. typedef struct _SCSISCAN_DEVICE_EXTENSION {
  26. ULONG Signature;
  27. PDEVICE_OBJECT pStackDeviceObject;
  28. PDEVICE_OBJECT pPhysicalDeviceObject;
  29. ULONG SrbFlags;
  30. UCHAR PortNumber;
  31. ULONG TimeOutValue;
  32. ULONG ErrorCount;
  33. ULONG SelecTimeoutCount;
  34. ULONG LastSrbError;
  35. ULONG DeviceInstance;
  36. ULONG PnpDeviceNumber;
  37. USHORT DeviceFlags;
  38. PSTORAGE_ADAPTER_DESCRIPTOR pAdapterDescriptor;
  39. UNICODE_STRING DeviceName;
  40. //UNICODE_STRING SymbolicLinkName;
  41. KEVENT PendingIoEvent;
  42. ULONG PendingIoCount;
  43. BOOLEAN AcceptingRequests;
  44. PVOID DeviceLock;
  45. ULONG OpenInstanceCount;
  46. PIRP pPowerIrp;
  47. DEVICE_POWER_STATE CurrentDevicePowerState;
  48. //
  49. // Records whether we actually created the symbolic link name
  50. // at driver load time. If we didn't create it, we won't try
  51. // to distroy it when we unload.
  52. //
  53. BOOLEAN CreatedSymbolicLink;
  54. //
  55. // This points to the symbolic link name that was
  56. // linked to the actual nt device name.
  57. //
  58. UNICODE_STRING SymbolicLinkName;
  59. //
  60. // This points to the class name used to create the
  61. // device and the symbolic link. We carry this
  62. // around for a short while...
  63. UNICODE_STRING ClassName;
  64. //
  65. // Name of the device interface
  66. //
  67. UNICODE_STRING InterfaceNameString;
  68. } SCSISCAN_DEVICE_EXTENSION, *PSCSISCAN_DEVICE_EXTENSION;
  69. typedef struct _TRANSFER_CONTEXT {
  70. ULONG Signature;
  71. PSCSISCAN_CMD pCmd;
  72. SRB Srb;
  73. PUCHAR pTransferBuffer;
  74. ULONG TransferLength;
  75. LONG RemainingTransferLength;
  76. LONG NBytesTransferred;
  77. ULONG RetryCount;
  78. PUCHAR pSenseBuffer;
  79. PMDL pSenseMdl;
  80. PMDL pSrbStatusMdl;
  81. } TRANSFER_CONTEXT, *PTRANSFER_CONTEXT;
  82. typedef struct _COMPLETION_CONTEXT {
  83. ULONG Signature;
  84. PDEVICE_OBJECT pDeviceObject;
  85. SRB Srb;
  86. }COMPLETION_CONTEXT, *PCOMPLETION_CONTEXT;
  87. #ifdef _WIN64
  88. // For 32bit client on 64bit OS.
  89. typedef struct _SCSISCAN_CMD_32 {
  90. ULONG Reserved1;
  91. ULONG Size;
  92. ULONG SrbFlags;
  93. UCHAR CdbLength;
  94. UCHAR SenseLength;
  95. UCHAR Reserved2;
  96. UCHAR Reserved3;
  97. ULONG TransferLength;
  98. UCHAR Cdb[16];
  99. UCHAR * POINTER_32 pSrbStatus;
  100. UCHAR * POINTER_32 pSenseBuffer;
  101. } SCSISCAN_CMD_32, *PSCSISCAN_CMD_32;
  102. #endif // _WIN64
  103. //
  104. // Prototypes
  105. //
  106. NTSTATUS
  107. DriverEntry( // in scsiscan.c
  108. IN PDRIVER_OBJECT DriverObject,
  109. IN PUNICODE_STRING RegistryPath
  110. );
  111. NTSTATUS SSPnp ( // in scsiscan.c
  112. IN PDEVICE_OBJECT pDeviceObject,
  113. IN PIRP pIrp
  114. );
  115. NTSTATUS
  116. SSPnpAddDevice( // in scsiscan.c
  117. IN PDRIVER_OBJECT DriverObject,
  118. IN PDEVICE_OBJECT PhysicalDevice
  119. );
  120. NTSTATUS
  121. SSOpen( // in scsiscan.c
  122. IN PDEVICE_OBJECT pDeviceObject,
  123. IN PIRP pIrp
  124. );
  125. NTSTATUS
  126. SSClose( // in scsiscan.c
  127. IN PDEVICE_OBJECT pDeviceObject,
  128. IN PIRP pIrp
  129. );
  130. NTSTATUS
  131. SSReadWrite( // in scsiscan.c
  132. IN PDEVICE_OBJECT pDeviceObject,
  133. IN PIRP pIrp
  134. );
  135. NTSTATUS
  136. SSDeviceControl( // in scsiscan.c
  137. IN PDEVICE_OBJECT pDeviceObject,
  138. IN PIRP pIrp
  139. );
  140. NTSTATUS
  141. SSGetInfo( // in scsiscan.c
  142. IN PDEVICE_OBJECT pDeviceObject,
  143. IN ULONG ControlCode,
  144. OUT PVOID *ppv
  145. );
  146. VOID
  147. SSSendScannerRequest( // in scsiscan.c
  148. PDEVICE_OBJECT pDeviceObject,
  149. PIRP pIrp,
  150. PTRANSFER_CONTEXT pTransferContext,
  151. BOOLEAN Retry
  152. );
  153. NTSTATUS
  154. SSReadWriteIoComplete( // in scsiscan.c
  155. IN PDEVICE_OBJECT pDeviceObject,
  156. IN PIRP pIrp,
  157. IN PVOID Context
  158. );
  159. NTSTATUS
  160. SSIoctlIoComplete( // in scsiscan.c
  161. IN PDEVICE_OBJECT pDeviceObject,
  162. IN PIRP pIrp,
  163. IN PVOID Context
  164. );
  165. NTSTATUS
  166. SSDeviceControl( // in scsiscan.c
  167. IN PDEVICE_OBJECT pDeviceObject,
  168. IN PIRP pIrp
  169. );
  170. VOID
  171. SSAdjustTransferSize( // in scsiscan.c
  172. PSCSISCAN_DEVICE_EXTENSION pde,
  173. PTRANSFER_CONTEXT pTransferContext
  174. );
  175. PTRANSFER_CONTEXT // in scsiscan.c
  176. SSBuildTransferContext(
  177. PSCSISCAN_DEVICE_EXTENSION pde,
  178. PIRP pIrp,
  179. PSCSISCAN_CMD pCmd,
  180. ULONG CmdLength,
  181. PMDL pTransferMdl,
  182. BOOLEAN AllowMultipleTransfer
  183. );
  184. NTSTATUS // in scsiscan.c
  185. SSCreateSymbolicLink(
  186. PSCSISCAN_DEVICE_EXTENSION pde
  187. );
  188. NTSTATUS // in scsiscan.c
  189. SSDestroySymbolicLink(
  190. PSCSISCAN_DEVICE_EXTENSION pde
  191. );
  192. VOID // in scsiscan.c
  193. SSIncrementIoCount(
  194. IN PDEVICE_OBJECT pDeviceObject
  195. );
  196. LONG // in scsiscan.c
  197. SSDecrementIoCount(
  198. IN PDEVICE_OBJECT DeviceObject
  199. );
  200. NTSTATUS // in scsiscan.c
  201. SSDeferIrpCompletion(
  202. IN PDEVICE_OBJECT pDeviceObject,
  203. IN PIRP pIrp,
  204. IN PVOID Context
  205. );
  206. NTSTATUS // in scsiscan.c
  207. SSPower(
  208. IN PDEVICE_OBJECT pDeviceObject,
  209. IN PIRP pIrp
  210. );
  211. VOID // in scsiscan.c
  212. SSUnload(
  213. IN PDRIVER_OBJECT pDriverObject
  214. );
  215. VOID
  216. SSSetTransferLengthToCdb(
  217. PCDB pCdb,
  218. ULONG TransferLength
  219. ); // in scsiscan.c
  220. NTSTATUS
  221. SSCallNextDriverSynch(
  222. IN PSCSISCAN_DEVICE_EXTENSION pde,
  223. IN PIRP pIrp
  224. );
  225. NTSTATUS
  226. ClassGetDescriptor( // in class.c
  227. IN PDEVICE_OBJECT DeviceObject,
  228. IN PSTORAGE_PROPERTY_ID PropertyId,
  229. OUT PVOID *pDescriptor
  230. );
  231. BOOLEAN
  232. ClassInterpretSenseInfo( // in class.c
  233. IN PDEVICE_OBJECT pDeviceObject,
  234. IN PSRB pSrb,
  235. IN UCHAR MajorFunctionCode,
  236. IN ULONG IoDeviceCode,
  237. IN ULONG RetryCount,
  238. OUT NTSTATUS *Status
  239. );
  240. VOID // in class.c
  241. ClassReleaseQueue(
  242. IN PDEVICE_OBJECT pDeviceObject
  243. );
  244. NTSTATUS
  245. ClassAsynchronousCompletion( // in class.c
  246. PDEVICE_OBJECT pDeviceObject,
  247. PIRP pIrp,
  248. PCOMPLETION_CONTEXT pContext
  249. );
  250. NTSTATUS
  251. ClassGetInfo( // in class.c
  252. IN PDEVICE_OBJECT pDeviceObject,
  253. OUT PSCSISCAN_INFO pTargetInfo
  254. );
  255. NTSTATUS
  256. ScsiScanHandleInterface(
  257. PDEVICE_OBJECT DeviceObject,
  258. PUNICODE_STRING InterfaceName,
  259. BOOLEAN Create
  260. );
  261. #endif // _SCSISCAN_PRIAVATE_