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.

454 lines
12 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1992 - 1998
  3. Module Name:
  4. tape.h
  5. Abstract:
  6. These are the structures and defines that are used in the
  7. SCSI tape class drivers. The tape class driver is separated
  8. into two modules. An export driver called SCSITAPE.SYS which
  9. provides a OS dependant wrapper for the OS independant and
  10. a tape drive specific minitape driver. The interface between
  11. these two drivers is also defined in this file.
  12. Revision History:
  13. --*/
  14. #include "scsi.h"
  15. // begin_ntminitape
  16. #if defined DebugPrint
  17. #undef DebugPrint
  18. #endif
  19. #if DBG
  20. #define DebugPrint(x) TapeDebugPrint x
  21. #else
  22. #define DebugPrint(x)
  23. #endif // DBG
  24. //
  25. // Define Device Configuration Page
  26. //
  27. typedef struct _MODE_DEVICE_CONFIGURATION_PAGE {
  28. UCHAR PageCode : 6;
  29. UCHAR Reserved1 : 1;
  30. UCHAR PS : 1;
  31. UCHAR PageLength;
  32. UCHAR ActiveFormat : 5;
  33. UCHAR CAFBit : 1;
  34. UCHAR CAPBit : 1;
  35. UCHAR Reserved2 : 1;
  36. UCHAR ActivePartition;
  37. UCHAR WriteBufferFullRatio;
  38. UCHAR ReadBufferEmptyRatio;
  39. UCHAR WriteDelayTime[2];
  40. UCHAR REW : 1;
  41. UCHAR RBO : 1;
  42. UCHAR SOCF : 2;
  43. UCHAR AVC : 1;
  44. UCHAR RSmk : 1;
  45. UCHAR BIS : 1;
  46. UCHAR DBR : 1;
  47. UCHAR GapSize;
  48. UCHAR Reserved3 : 3;
  49. UCHAR SEW : 1;
  50. UCHAR EEG : 1;
  51. UCHAR EODdefined : 3;
  52. UCHAR BufferSize[3];
  53. UCHAR DCAlgorithm;
  54. UCHAR Reserved4;
  55. } MODE_DEVICE_CONFIGURATION_PAGE, *PMODE_DEVICE_CONFIGURATION_PAGE;
  56. //
  57. // Define Medium Partition Page
  58. //
  59. typedef struct _MODE_MEDIUM_PARTITION_PAGE {
  60. UCHAR PageCode : 6;
  61. UCHAR Reserved1 : 1;
  62. UCHAR PSBit : 1;
  63. UCHAR PageLength;
  64. UCHAR MaximumAdditionalPartitions;
  65. UCHAR AdditionalPartitionDefined;
  66. UCHAR Reserved2 : 3;
  67. UCHAR PSUMBit : 2;
  68. UCHAR IDPBit : 1;
  69. UCHAR SDPBit : 1;
  70. UCHAR FDPBit : 1;
  71. UCHAR MediumFormatRecognition;
  72. UCHAR Reserved3[2];
  73. UCHAR Partition0Size[2];
  74. UCHAR Partition1Size[2];
  75. } MODE_MEDIUM_PARTITION_PAGE, *PMODE_MEDIUM_PARTITION_PAGE;
  76. //
  77. // Define Data Compression Page
  78. //
  79. typedef struct _MODE_DATA_COMPRESSION_PAGE {
  80. UCHAR PageCode : 6;
  81. UCHAR Reserved1 : 2;
  82. UCHAR PageLength;
  83. UCHAR Reserved2 : 6;
  84. UCHAR DCC : 1;
  85. UCHAR DCE : 1;
  86. UCHAR Reserved3 : 5;
  87. UCHAR RED : 2;
  88. UCHAR DDE : 1;
  89. UCHAR CompressionAlgorithm[4];
  90. UCHAR DecompressionAlgorithm[4];
  91. UCHAR Reserved4[4];
  92. } MODE_DATA_COMPRESSION_PAGE, *PMODE_DATA_COMPRESSION_PAGE;
  93. //
  94. // Define capabilites and mechanical status page.
  95. //
  96. typedef struct _MODE_CAPABILITIES_PAGE {
  97. UCHAR PageCode : 6;
  98. UCHAR Reserved1 : 2;
  99. UCHAR PageLength;
  100. UCHAR Reserved2[2];
  101. UCHAR RO : 1;
  102. UCHAR Reserved3 : 4;
  103. UCHAR SPREV : 1;
  104. UCHAR Reserved4 : 2;
  105. UCHAR Reserved5 : 3;
  106. UCHAR EFMT : 1;
  107. UCHAR Reserved6 : 1;
  108. UCHAR QFA : 1;
  109. UCHAR Reserved7 : 2;
  110. UCHAR LOCK : 1;
  111. UCHAR LOCKED : 1;
  112. UCHAR PREVENT : 1;
  113. UCHAR UNLOAD : 1;
  114. UCHAR Reserved8 : 2;
  115. UCHAR ECC : 1;
  116. UCHAR CMPRS : 1;
  117. UCHAR Reserved9 : 1;
  118. UCHAR BLK512 : 1;
  119. UCHAR BLK1024 : 1;
  120. UCHAR Reserved10 : 4;
  121. UCHAR SLOWB : 1;
  122. UCHAR MaximumSpeedSupported[2];
  123. UCHAR MaximumStoredDefectedListEntries[2];
  124. UCHAR ContinuousTransferLimit[2];
  125. UCHAR CurrentSpeedSelected[2];
  126. UCHAR BufferSize[2];
  127. UCHAR Reserved11[2];
  128. } MODE_CAPABILITIES_PAGE, *PMODE_CAPABILITIES_PAGE;
  129. typedef struct _MODE_CAP_PAGE {
  130. MODE_PARAMETER_HEADER ParameterListHeader;
  131. MODE_PARAMETER_BLOCK ParameterListBlock;
  132. MODE_CAPABILITIES_PAGE CapabilitiesPage;
  133. } MODE_CAP_PAGE, *PMODE_CAP_PAGE;
  134. //
  135. // Mode parameter list header and medium partition page -
  136. // used in creating partitions
  137. //
  138. typedef struct _MODE_MEDIUM_PART_PAGE {
  139. MODE_PARAMETER_HEADER ParameterListHeader;
  140. MODE_MEDIUM_PARTITION_PAGE MediumPartPage;
  141. } MODE_MEDIUM_PART_PAGE, *PMODE_MEDIUM_PART_PAGE;
  142. typedef struct _MODE_MEDIUM_PART_PAGE_PLUS {
  143. MODE_PARAMETER_HEADER ParameterListHeader;
  144. MODE_PARAMETER_BLOCK ParameterListBlock;
  145. MODE_MEDIUM_PARTITION_PAGE MediumPartPage;
  146. } MODE_MEDIUM_PART_PAGE_PLUS, *PMODE_MEDIUM_PART_PAGE_PLUS;
  147. //
  148. // Mode parameters for retrieving tape or media information
  149. //
  150. typedef struct _MODE_TAPE_MEDIA_INFORMATION {
  151. MODE_PARAMETER_HEADER ParameterListHeader;
  152. MODE_PARAMETER_BLOCK ParameterListBlock;
  153. MODE_MEDIUM_PARTITION_PAGE MediumPartPage;
  154. } MODE_TAPE_MEDIA_INFORMATION, *PMODE_TAPE_MEDIA_INFORMATION;
  155. //
  156. // Mode parameter list header and device configuration page -
  157. // used in retrieving device configuration information
  158. //
  159. typedef struct _MODE_DEVICE_CONFIG_PAGE {
  160. MODE_PARAMETER_HEADER ParameterListHeader;
  161. MODE_DEVICE_CONFIGURATION_PAGE DeviceConfigPage;
  162. } MODE_DEVICE_CONFIG_PAGE, *PMODE_DEVICE_CONFIG_PAGE;
  163. typedef struct _MODE_DEVICE_CONFIG_PAGE_PLUS {
  164. MODE_PARAMETER_HEADER ParameterListHeader;
  165. MODE_PARAMETER_BLOCK ParameterListBlock;
  166. MODE_DEVICE_CONFIGURATION_PAGE DeviceConfigPage;
  167. } MODE_DEVICE_CONFIG_PAGE_PLUS, *PMODE_DEVICE_CONFIG_PAGE_PLUS ;
  168. //
  169. // Mode parameter list header and data compression page -
  170. // used in retrieving data compression information
  171. //
  172. typedef struct _MODE_DATA_COMPRESS_PAGE {
  173. MODE_PARAMETER_HEADER ParameterListHeader;
  174. MODE_DATA_COMPRESSION_PAGE DataCompressPage;
  175. } MODE_DATA_COMPRESS_PAGE, *PMODE_DATA_COMPRESS_PAGE;
  176. typedef struct _MODE_DATA_COMPRESS_PAGE_PLUS {
  177. MODE_PARAMETER_HEADER ParameterListHeader;
  178. MODE_PARAMETER_BLOCK ParameterListBlock;
  179. MODE_DATA_COMPRESSION_PAGE DataCompressPage;
  180. } MODE_DATA_COMPRESS_PAGE_PLUS, *PMODE_DATA_COMPRESS_PAGE_PLUS;
  181. //
  182. // Tape/Minitape definition.
  183. //
  184. typedef
  185. BOOLEAN
  186. (*TAPE_VERIFY_INQUIRY_ROUTINE)(
  187. IN PINQUIRYDATA InquiryData,
  188. IN PMODE_CAPABILITIES_PAGE ModeCapabilitiesPage
  189. );
  190. typedef
  191. VOID
  192. (*TAPE_EXTENSION_INIT_ROUTINE)(
  193. IN PVOID MinitapeExtension,
  194. IN PINQUIRYDATA InquiryData,
  195. IN PMODE_CAPABILITIES_PAGE ModeCapabilitiesPage
  196. );
  197. typedef enum _TAPE_STATUS {
  198. TAPE_STATUS_SEND_SRB_AND_CALLBACK,
  199. TAPE_STATUS_CALLBACK,
  200. TAPE_STATUS_CHECK_TEST_UNIT_READY,
  201. TAPE_STATUS_SUCCESS,
  202. TAPE_STATUS_INSUFFICIENT_RESOURCES,
  203. TAPE_STATUS_NOT_IMPLEMENTED,
  204. TAPE_STATUS_INVALID_DEVICE_REQUEST,
  205. TAPE_STATUS_INVALID_PARAMETER,
  206. TAPE_STATUS_MEDIA_CHANGED,
  207. TAPE_STATUS_BUS_RESET,
  208. TAPE_STATUS_SETMARK_DETECTED,
  209. TAPE_STATUS_FILEMARK_DETECTED,
  210. TAPE_STATUS_BEGINNING_OF_MEDIA,
  211. TAPE_STATUS_END_OF_MEDIA,
  212. TAPE_STATUS_BUFFER_OVERFLOW,
  213. TAPE_STATUS_NO_DATA_DETECTED,
  214. TAPE_STATUS_EOM_OVERFLOW,
  215. TAPE_STATUS_NO_MEDIA,
  216. TAPE_STATUS_IO_DEVICE_ERROR,
  217. TAPE_STATUS_UNRECOGNIZED_MEDIA,
  218. TAPE_STATUS_DEVICE_NOT_READY,
  219. TAPE_STATUS_MEDIA_WRITE_PROTECTED,
  220. TAPE_STATUS_DEVICE_DATA_ERROR,
  221. TAPE_STATUS_NO_SUCH_DEVICE,
  222. TAPE_STATUS_INVALID_BLOCK_LENGTH,
  223. TAPE_STATUS_IO_TIMEOUT,
  224. TAPE_STATUS_DEVICE_NOT_CONNECTED,
  225. TAPE_STATUS_DATA_OVERRUN,
  226. TAPE_STATUS_DEVICE_BUSY,
  227. TAPE_STATUS_REQUIRES_CLEANING,
  228. TAPE_STATUS_CLEANER_CARTRIDGE_INSTALLED
  229. } TAPE_STATUS, *PTAPE_STATUS;
  230. typedef
  231. VOID
  232. (*TAPE_ERROR_ROUTINE)(
  233. IN PVOID MinitapeExtension,
  234. IN PSCSI_REQUEST_BLOCK Srb,
  235. IN OUT PTAPE_STATUS TapeStatus
  236. );
  237. #define TAPE_RETRY_MASK 0x0000FFFF
  238. #define IGNORE_ERRORS 0x00010000
  239. #define RETURN_ERRORS 0x00020000
  240. typedef
  241. TAPE_STATUS
  242. (*TAPE_PROCESS_COMMAND_ROUTINE)(
  243. IN OUT PVOID MinitapeExtension,
  244. IN OUT PVOID CommandExtension,
  245. IN OUT PVOID CommandParameters,
  246. IN OUT PSCSI_REQUEST_BLOCK Srb,
  247. IN ULONG CallNumber,
  248. IN TAPE_STATUS StatusOfLastCommand,
  249. IN OUT PULONG RetryFlags
  250. );
  251. //
  252. // NT 4.0 miniclass drivers will be using this.
  253. //
  254. typedef struct _TAPE_INIT_DATA {
  255. TAPE_VERIFY_INQUIRY_ROUTINE VerifyInquiry;
  256. BOOLEAN QueryModeCapabilitiesPage ;
  257. ULONG MinitapeExtensionSize;
  258. TAPE_EXTENSION_INIT_ROUTINE ExtensionInit; /* OPTIONAL */
  259. ULONG DefaultTimeOutValue; /* OPTIONAL */
  260. TAPE_ERROR_ROUTINE TapeError; /* OPTIONAL */
  261. ULONG CommandExtensionSize;
  262. TAPE_PROCESS_COMMAND_ROUTINE CreatePartition;
  263. TAPE_PROCESS_COMMAND_ROUTINE Erase;
  264. TAPE_PROCESS_COMMAND_ROUTINE GetDriveParameters;
  265. TAPE_PROCESS_COMMAND_ROUTINE GetMediaParameters;
  266. TAPE_PROCESS_COMMAND_ROUTINE GetPosition;
  267. TAPE_PROCESS_COMMAND_ROUTINE GetStatus;
  268. TAPE_PROCESS_COMMAND_ROUTINE Prepare;
  269. TAPE_PROCESS_COMMAND_ROUTINE SetDriveParameters;
  270. TAPE_PROCESS_COMMAND_ROUTINE SetMediaParameters;
  271. TAPE_PROCESS_COMMAND_ROUTINE SetPosition;
  272. TAPE_PROCESS_COMMAND_ROUTINE WriteMarks;
  273. TAPE_PROCESS_COMMAND_ROUTINE PreProcessReadWrite;
  274. } TAPE_INIT_DATA, *PTAPE_INIT_DATA;
  275. typedef struct _TAPE_INIT_DATA_EX {
  276. //
  277. // Size of this structure.
  278. //
  279. ULONG InitDataSize;
  280. //
  281. // Keep the 4.0 init data as is, so support of these
  282. // drivers can be as seamless as possible.
  283. //
  284. TAPE_VERIFY_INQUIRY_ROUTINE VerifyInquiry;
  285. BOOLEAN QueryModeCapabilitiesPage ;
  286. ULONG MinitapeExtensionSize;
  287. TAPE_EXTENSION_INIT_ROUTINE ExtensionInit; /* OPTIONAL */
  288. ULONG DefaultTimeOutValue; /* OPTIONAL */
  289. TAPE_ERROR_ROUTINE TapeError; /* OPTIONAL */
  290. ULONG CommandExtensionSize;
  291. TAPE_PROCESS_COMMAND_ROUTINE CreatePartition;
  292. TAPE_PROCESS_COMMAND_ROUTINE Erase;
  293. TAPE_PROCESS_COMMAND_ROUTINE GetDriveParameters;
  294. TAPE_PROCESS_COMMAND_ROUTINE GetMediaParameters;
  295. TAPE_PROCESS_COMMAND_ROUTINE GetPosition;
  296. TAPE_PROCESS_COMMAND_ROUTINE GetStatus;
  297. TAPE_PROCESS_COMMAND_ROUTINE Prepare;
  298. TAPE_PROCESS_COMMAND_ROUTINE SetDriveParameters;
  299. TAPE_PROCESS_COMMAND_ROUTINE SetMediaParameters;
  300. TAPE_PROCESS_COMMAND_ROUTINE SetPosition;
  301. TAPE_PROCESS_COMMAND_ROUTINE WriteMarks;
  302. TAPE_PROCESS_COMMAND_ROUTINE PreProcessReadWrite;
  303. //
  304. // New entry points / information for 5.0
  305. //
  306. // Returns supported media types for the device.
  307. //
  308. TAPE_PROCESS_COMMAND_ROUTINE TapeGetMediaTypes;
  309. //
  310. // Indicates the number of different types the drive supports.
  311. //
  312. ULONG MediaTypesSupported;
  313. //
  314. // Entry point for all WMI operations that the driver/device supports.
  315. //
  316. TAPE_PROCESS_COMMAND_ROUTINE TapeWMIOperations;
  317. ULONG Reserved[2];
  318. } TAPE_INIT_DATA_EX, *PTAPE_INIT_DATA_EX;
  319. SCSIPORT_API
  320. ULONG
  321. TapeClassInitialize(
  322. IN PVOID Argument1,
  323. IN PVOID Argument2,
  324. IN PTAPE_INIT_DATA_EX TapeInitData
  325. );
  326. SCSIPORT_API
  327. BOOLEAN
  328. TapeClassAllocateSrbBuffer(
  329. IN OUT PSCSI_REQUEST_BLOCK Srb,
  330. IN ULONG SrbBufferSize
  331. );
  332. SCSIPORT_API
  333. VOID
  334. TapeClassZeroMemory(
  335. IN OUT PVOID Buffer,
  336. IN ULONG BufferSize
  337. );
  338. SCSIPORT_API
  339. ULONG
  340. TapeClassCompareMemory(
  341. IN OUT PVOID Source1,
  342. IN OUT PVOID Source2,
  343. IN ULONG Length
  344. );
  345. SCSIPORT_API
  346. LARGE_INTEGER
  347. TapeClassLiDiv(
  348. IN LARGE_INTEGER Dividend,
  349. IN LARGE_INTEGER Divisor
  350. );
  351. SCSIPORT_API
  352. VOID
  353. TapeDebugPrint(
  354. ULONG DebugPrintLevel,
  355. PCCHAR DebugMessage,
  356. ...
  357. );
  358. // end_ntminitape