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.

4747 lines
129 KiB

  1. /*++
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. minitape.h
  5. Abstract:
  6. Type definitions for minitape drivers.
  7. Revision History:
  8. --*/
  9. #ifndef _MINITAPE_
  10. #define _MINITAPE_
  11. #include "stddef.h"
  12. #define ASSERT( exp )
  13. #if DBG
  14. #define DebugPrint(x) ScsiDebugPrint x
  15. #else
  16. #define DebugPrint(x)
  17. #endif // DBG
  18. #ifndef IN
  19. #define IN
  20. #endif
  21. #ifndef OUT
  22. #define OUT
  23. #endif
  24. #ifndef OPTIONAL
  25. #define OPTIONAL
  26. #endif
  27. #ifndef NOTHING
  28. #define NOTHING
  29. #endif
  30. #ifndef CRITICAL
  31. #define CRITICAL
  32. #endif
  33. #ifndef ANYSIZE_ARRAY
  34. #define ANYSIZE_ARRAY 1 // winnt
  35. #endif
  36. // begin_winnt
  37. #if defined(_M_MRX000) && !(defined(MIDL_PASS) || defined(RC_INVOKED)) && defined(ENABLE_RESTRICTED)
  38. #define RESTRICTED_POINTER __restrict
  39. #else
  40. #define RESTRICTED_POINTER
  41. #endif
  42. #if defined(_M_MRX000) || defined(_M_ALPHA) || defined(_M_PPC) || defined(_M_IA64) || defined(_M_AMD64)
  43. #define UNALIGNED __unaligned
  44. #if defined(_WIN64)
  45. #define UNALIGNED64 __unaligned
  46. #else
  47. #define UNALIGNED64
  48. #endif
  49. #else
  50. #define UNALIGNED
  51. #define UNALIGNED64
  52. #endif
  53. #if defined(_WIN64) || defined(_M_ALPHA)
  54. #define MAX_NATURAL_ALIGNMENT sizeof(ULONGLONG)
  55. #define MEMORY_ALLOCATION_ALIGNMENT 16
  56. #else
  57. #define MAX_NATURAL_ALIGNMENT sizeof(ULONG)
  58. #define MEMORY_ALLOCATION_ALIGNMENT 8
  59. #endif
  60. //
  61. // TYPE_ALIGNMENT will return the alignment requirements of a given type for
  62. // the current platform.
  63. //
  64. #ifdef __cplusplus
  65. #if _MSC_VER >= 1300
  66. #define TYPE_ALIGNMENT( t ) __alignof(t)
  67. #endif
  68. #else
  69. #define TYPE_ALIGNMENT( t ) \
  70. FIELD_OFFSET( struct { char x; t test; }, test )
  71. #endif
  72. #if defined(_WIN64)
  73. #define PROBE_ALIGNMENT( _s ) (TYPE_ALIGNMENT( _s ) > TYPE_ALIGNMENT( ULONG ) ? \
  74. TYPE_ALIGNMENT( _s ) : TYPE_ALIGNMENT( ULONG ))
  75. #define PROBE_ALIGNMENT32( _s ) TYPE_ALIGNMENT( ULONG )
  76. #else
  77. #define PROBE_ALIGNMENT( _s ) TYPE_ALIGNMENT( ULONG )
  78. #endif
  79. //
  80. // C_ASSERT() can be used to perform many compile-time assertions:
  81. // type sizes, field offsets, etc.
  82. //
  83. // An assertion failure results in error C2118: negative subscript.
  84. //
  85. #define C_ASSERT(e) typedef char __C_ASSERT__[(e)?1:-1]
  86. #if !defined(_MAC) && (defined(_M_MRX000) || defined(_M_AMD64) || defined(_M_IA64)) && (_MSC_VER >= 1100) && !(defined(MIDL_PASS) || defined(RC_INVOKED))
  87. #define POINTER_64 __ptr64
  88. typedef unsigned __int64 POINTER_64_INT;
  89. #if defined(_WIN64)
  90. #define POINTER_32 __ptr32
  91. #else
  92. #define POINTER_32
  93. #endif
  94. #else
  95. #if defined(_MAC) && defined(_MAC_INT_64)
  96. #define POINTER_64 __ptr64
  97. typedef unsigned __int64 POINTER_64_INT;
  98. #else
  99. #define POINTER_64
  100. typedef unsigned long POINTER_64_INT;
  101. #endif
  102. #define POINTER_32
  103. #endif
  104. #if defined(_IA64_) || defined(_AMD64_)
  105. #define FIRMWARE_PTR
  106. #else
  107. #define FIRMWARE_PTR POINTER_32
  108. #endif
  109. #include <basetsd.h>
  110. // end_winnt
  111. #ifndef CONST
  112. #define CONST const
  113. #endif
  114. // begin_winnt
  115. #if (defined(_M_IX86) || defined(_M_IA64) || defined(_M_AMD64)) && !defined(MIDL_PASS)
  116. #define DECLSPEC_IMPORT __declspec(dllimport)
  117. #else
  118. #define DECLSPEC_IMPORT
  119. #endif
  120. #ifndef DECLSPEC_NORETURN
  121. #if (_MSC_VER >= 1200) && !defined(MIDL_PASS)
  122. #define DECLSPEC_NORETURN __declspec(noreturn)
  123. #else
  124. #define DECLSPEC_NORETURN
  125. #endif
  126. #endif
  127. #ifndef DECLSPEC_ALIGN
  128. #if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
  129. #define DECLSPEC_ALIGN(x) __declspec(align(x))
  130. #else
  131. #define DECLSPEC_ALIGN(x)
  132. #endif
  133. #endif
  134. #ifndef DECLSPEC_CACHEALIGN
  135. #define DECLSPEC_CACHEALIGN DECLSPEC_ALIGN(128)
  136. #endif
  137. #ifndef DECLSPEC_UUID
  138. #if (_MSC_VER >= 1100) && defined (__cplusplus)
  139. #define DECLSPEC_UUID(x) __declspec(uuid(x))
  140. #else
  141. #define DECLSPEC_UUID(x)
  142. #endif
  143. #endif
  144. #ifndef DECLSPEC_NOVTABLE
  145. #if (_MSC_VER >= 1100) && defined(__cplusplus)
  146. #define DECLSPEC_NOVTABLE __declspec(novtable)
  147. #else
  148. #define DECLSPEC_NOVTABLE
  149. #endif
  150. #endif
  151. #ifndef DECLSPEC_SELECTANY
  152. #if (_MSC_VER >= 1100)
  153. #define DECLSPEC_SELECTANY __declspec(selectany)
  154. #else
  155. #define DECLSPEC_SELECTANY
  156. #endif
  157. #endif
  158. #ifndef NOP_FUNCTION
  159. #if (_MSC_VER >= 1210)
  160. #define NOP_FUNCTION __noop
  161. #else
  162. #define NOP_FUNCTION (void)0
  163. #endif
  164. #endif
  165. #ifndef DECLSPEC_ADDRSAFE
  166. #if (_MSC_VER >= 1200) && (defined(_M_ALPHA) || defined(_M_AXP64))
  167. #define DECLSPEC_ADDRSAFE __declspec(address_safe)
  168. #else
  169. #define DECLSPEC_ADDRSAFE
  170. #endif
  171. #endif
  172. #ifndef FORCEINLINE
  173. #if (_MSC_VER >= 1200)
  174. #define FORCEINLINE __forceinline
  175. #else
  176. #define FORCEINLINE __inline
  177. #endif
  178. #endif
  179. #ifndef DECLSPEC_DEPRECATED
  180. #if (_MSC_VER >= 1300) && !defined(MIDL_PASS)
  181. #define DECLSPEC_DEPRECATED __declspec(deprecated)
  182. #define DEPRECATE_SUPPORTED
  183. #else
  184. #define DECLSPEC_DEPRECATED
  185. #undef DEPRECATE_SUPPORTED
  186. #endif
  187. #endif
  188. // end_winnt
  189. #ifdef DEPRECATE_DDK_FUNCTIONS
  190. #ifdef _NTDDK_
  191. #define DECLSPEC_DEPRECATED_DDK DECLSPEC_DEPRECATED
  192. #ifdef DEPRECATE_SUPPORTED
  193. #define PRAGMA_DEPRECATED_DDK 1
  194. #endif
  195. #else
  196. #define DECLSPEC_DEPRECATED_DDK
  197. #define PRAGMA_DEPRECATED_DDK 1
  198. #endif
  199. #else
  200. #define DECLSPEC_DEPRECATED_DDK
  201. #define PRAGMA_DEPRECATED_DDK 0
  202. #endif
  203. //
  204. // Void
  205. //
  206. // begin_winnt
  207. typedef void *PVOID;
  208. typedef void * POINTER_64 PVOID64;
  209. // end_winnt
  210. #if defined(_M_IX86)
  211. #define FASTCALL _fastcall
  212. #else
  213. #define FASTCALL
  214. #endif
  215. //
  216. // Basics
  217. //
  218. #ifndef VOID
  219. #define VOID void
  220. typedef char CHAR;
  221. typedef short SHORT;
  222. typedef long LONG;
  223. #endif
  224. //
  225. // UNICODE (Wide Character) types
  226. //
  227. #ifndef _MAC
  228. typedef wchar_t WCHAR; // wc, 16-bit UNICODE character
  229. #else
  230. // some Macintosh compilers don't define wchar_t in a convenient location, or define it as a char
  231. typedef unsigned short WCHAR; // wc, 16-bit UNICODE character
  232. #endif
  233. typedef WCHAR *PWCHAR;
  234. typedef WCHAR *LPWCH, *PWCH;
  235. typedef CONST WCHAR *LPCWCH, *PCWCH;
  236. typedef WCHAR *NWPSTR;
  237. typedef WCHAR *LPWSTR, *PWSTR;
  238. typedef WCHAR UNALIGNED *LPUWSTR, *PUWSTR;
  239. typedef CONST WCHAR *LPCWSTR, *PCWSTR;
  240. typedef CONST WCHAR UNALIGNED *LPCUWSTR, *PCUWSTR;
  241. //
  242. // ANSI (Multi-byte Character) types
  243. //
  244. typedef CHAR *PCHAR;
  245. typedef CHAR *LPCH, *PCH;
  246. typedef CONST CHAR *LPCCH, *PCCH;
  247. typedef CHAR *NPSTR;
  248. typedef CHAR *LPSTR, *PSTR;
  249. typedef CONST CHAR *LPCSTR, *PCSTR;
  250. //
  251. // Neutral ANSI/UNICODE types and macros
  252. //
  253. #ifdef UNICODE // r_winnt
  254. #ifndef _TCHAR_DEFINED
  255. typedef WCHAR TCHAR, *PTCHAR;
  256. typedef WCHAR TUCHAR, *PTUCHAR;
  257. #define _TCHAR_DEFINED
  258. #endif /* !_TCHAR_DEFINED */
  259. typedef LPWSTR LPTCH, PTCH;
  260. typedef LPWSTR PTSTR, LPTSTR;
  261. typedef LPCWSTR PCTSTR, LPCTSTR;
  262. typedef LPUWSTR PUTSTR, LPUTSTR;
  263. typedef LPCUWSTR PCUTSTR, LPCUTSTR;
  264. typedef LPWSTR LP;
  265. #define __TEXT(quote) L##quote // r_winnt
  266. #else /* UNICODE */ // r_winnt
  267. #ifndef _TCHAR_DEFINED
  268. typedef char TCHAR, *PTCHAR;
  269. typedef unsigned char TUCHAR, *PTUCHAR;
  270. #define _TCHAR_DEFINED
  271. #endif /* !_TCHAR_DEFINED */
  272. typedef LPSTR LPTCH, PTCH;
  273. typedef LPSTR PTSTR, LPTSTR, PUTSTR, LPUTSTR;
  274. typedef LPCSTR PCTSTR, LPCTSTR, PCUTSTR, LPCUTSTR;
  275. #define __TEXT(quote) quote // r_winnt
  276. #endif /* UNICODE */ // r_winnt
  277. #define TEXT(quote) __TEXT(quote) // r_winnt
  278. // end_winnt
  279. typedef double DOUBLE;
  280. typedef struct _QUAD { // QUAD is for those times we want
  281. double DoNotUseThisField; // an 8 byte aligned 8 byte long structure
  282. } QUAD; // which is NOT really a floating point
  283. // number. Use DOUBLE if you want an FP
  284. // number.
  285. //
  286. // Pointer to Basics
  287. //
  288. typedef SHORT *PSHORT; // winnt
  289. typedef LONG *PLONG; // winnt
  290. typedef QUAD *PQUAD;
  291. //
  292. // Unsigned Basics
  293. //
  294. // Tell windef.h that some types are already defined.
  295. #define BASETYPES
  296. typedef unsigned char UCHAR;
  297. typedef unsigned short USHORT;
  298. typedef unsigned long ULONG;
  299. typedef QUAD UQUAD;
  300. //
  301. // Pointer to Unsigned Basics
  302. //
  303. typedef UCHAR *PUCHAR;
  304. typedef USHORT *PUSHORT;
  305. typedef ULONG *PULONG;
  306. typedef UQUAD *PUQUAD;
  307. //
  308. // Signed characters
  309. //
  310. typedef signed char SCHAR;
  311. typedef SCHAR *PSCHAR;
  312. #ifndef NO_STRICT
  313. #ifndef STRICT
  314. #define STRICT 1
  315. #endif
  316. #endif
  317. //
  318. // Handle to an Object
  319. //
  320. // begin_winnt
  321. #ifdef STRICT
  322. typedef void *HANDLE;
  323. #define DECLARE_HANDLE(name) struct name##__ { int unused; }; typedef struct name##__ *name
  324. #else
  325. typedef PVOID HANDLE;
  326. #define DECLARE_HANDLE(name) typedef HANDLE name
  327. #endif
  328. typedef HANDLE *PHANDLE;
  329. //
  330. // Flag (bit) fields
  331. //
  332. typedef UCHAR FCHAR;
  333. typedef USHORT FSHORT;
  334. typedef ULONG FLONG;
  335. // Component Object Model defines, and macros
  336. #ifndef _HRESULT_DEFINED
  337. #define _HRESULT_DEFINED
  338. typedef LONG HRESULT;
  339. #endif // !_HRESULT_DEFINED
  340. #ifdef __cplusplus
  341. #define EXTERN_C extern "C"
  342. #else
  343. #define EXTERN_C extern
  344. #endif
  345. #if defined(_WIN32) || defined(_MPPC_)
  346. // Win32 doesn't support __export
  347. #ifdef _68K_
  348. #define STDMETHODCALLTYPE __cdecl
  349. #else
  350. #define STDMETHODCALLTYPE __stdcall
  351. #endif
  352. #define STDMETHODVCALLTYPE __cdecl
  353. #define STDAPICALLTYPE __stdcall
  354. #define STDAPIVCALLTYPE __cdecl
  355. #else
  356. #define STDMETHODCALLTYPE __export __stdcall
  357. #define STDMETHODVCALLTYPE __export __cdecl
  358. #define STDAPICALLTYPE __export __stdcall
  359. #define STDAPIVCALLTYPE __export __cdecl
  360. #endif
  361. #define STDAPI EXTERN_C HRESULT STDAPICALLTYPE
  362. #define STDAPI_(type) EXTERN_C type STDAPICALLTYPE
  363. #define STDMETHODIMP HRESULT STDMETHODCALLTYPE
  364. #define STDMETHODIMP_(type) type STDMETHODCALLTYPE
  365. // The 'V' versions allow Variable Argument lists.
  366. #define STDAPIV EXTERN_C HRESULT STDAPIVCALLTYPE
  367. #define STDAPIV_(type) EXTERN_C type STDAPIVCALLTYPE
  368. #define STDMETHODIMPV HRESULT STDMETHODVCALLTYPE
  369. #define STDMETHODIMPV_(type) type STDMETHODVCALLTYPE
  370. // end_winnt
  371. //
  372. // Low order two bits of a handle are ignored by the system and available
  373. // for use by application code as tag bits. The remaining bits are opaque
  374. // and used to store a serial number and table index.
  375. //
  376. #define OBJ_HANDLE_TAGBITS 0x00000003L
  377. //
  378. // Cardinal Data Types [0 - 2**N-2)
  379. //
  380. typedef char CCHAR; // winnt
  381. typedef short CSHORT;
  382. typedef ULONG CLONG;
  383. typedef CCHAR *PCCHAR;
  384. typedef CSHORT *PCSHORT;
  385. typedef CLONG *PCLONG;
  386. //
  387. // __int64 is only supported by 2.0 and later midl.
  388. // __midl is set by the 2.0 midl and not by 1.0 midl.
  389. //
  390. #define _ULONGLONG_
  391. #if (!defined (_MAC) && (!defined(MIDL_PASS) || defined(__midl)) && (!defined(_M_IX86) || (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 64)))
  392. typedef __int64 LONGLONG;
  393. typedef unsigned __int64 ULONGLONG;
  394. #define MAXLONGLONG (0x7fffffffffffffff)
  395. #else
  396. #if defined(_MAC) && defined(_MAC_INT_64)
  397. typedef __int64 LONGLONG;
  398. typedef unsigned __int64 ULONGLONG;
  399. #define MAXLONGLONG (0x7fffffffffffffff)
  400. #else
  401. typedef double LONGLONG;
  402. typedef double ULONGLONG;
  403. #endif //_MAC and int64
  404. #endif
  405. typedef LONGLONG *PLONGLONG;
  406. typedef ULONGLONG *PULONGLONG;
  407. // Update Sequence Number
  408. typedef LONGLONG USN;
  409. #if defined(MIDL_PASS)
  410. typedef struct _LARGE_INTEGER {
  411. #else // MIDL_PASS
  412. typedef union _LARGE_INTEGER {
  413. struct {
  414. ULONG LowPart;
  415. LONG HighPart;
  416. };
  417. struct {
  418. ULONG LowPart;
  419. LONG HighPart;
  420. } u;
  421. #endif //MIDL_PASS
  422. LONGLONG QuadPart;
  423. } LARGE_INTEGER;
  424. typedef LARGE_INTEGER *PLARGE_INTEGER;
  425. #if defined(MIDL_PASS)
  426. typedef struct _ULARGE_INTEGER {
  427. #else // MIDL_PASS
  428. typedef union _ULARGE_INTEGER {
  429. struct {
  430. ULONG LowPart;
  431. ULONG HighPart;
  432. };
  433. struct {
  434. ULONG LowPart;
  435. ULONG HighPart;
  436. } u;
  437. #endif //MIDL_PASS
  438. ULONGLONG QuadPart;
  439. } ULARGE_INTEGER;
  440. typedef ULARGE_INTEGER *PULARGE_INTEGER;
  441. //
  442. // Boolean
  443. //
  444. typedef UCHAR BOOLEAN; // winnt
  445. typedef BOOLEAN *PBOOLEAN; // winnt
  446. //
  447. // Constants
  448. //
  449. #define FALSE 0
  450. #define TRUE 1
  451. #ifndef NULL
  452. #ifdef __cplusplus
  453. #define NULL 0
  454. #define NULL64 0
  455. #else
  456. #define NULL ((void *)0)
  457. #define NULL64 ((void * POINTER_64)0)
  458. #endif
  459. #endif // NULL
  460. //
  461. // Macros used to eliminate compiler warning generated when formal
  462. // parameters or local variables are not declared.
  463. //
  464. // Use DBG_UNREFERENCED_PARAMETER() when a parameter is not yet
  465. // referenced but will be once the module is completely developed.
  466. //
  467. // Use DBG_UNREFERENCED_LOCAL_VARIABLE() when a local variable is not yet
  468. // referenced but will be once the module is completely developed.
  469. //
  470. // Use UNREFERENCED_PARAMETER() if a parameter will never be referenced.
  471. //
  472. // DBG_UNREFERENCED_PARAMETER and DBG_UNREFERENCED_LOCAL_VARIABLE will
  473. // eventually be made into a null macro to help determine whether there
  474. // is unfinished work.
  475. //
  476. #if ! defined(lint)
  477. #define UNREFERENCED_PARAMETER(P) (P)
  478. #define DBG_UNREFERENCED_PARAMETER(P) (P)
  479. #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) (V)
  480. #else // lint
  481. // Note: lint -e530 says don't complain about uninitialized variables for
  482. // this varible. Error 527 has to do with unreachable code.
  483. // -restore restores checking to the -save state
  484. #define UNREFERENCED_PARAMETER(P) \
  485. /*lint -save -e527 -e530 */ \
  486. { \
  487. (P) = (P); \
  488. } \
  489. /*lint -restore */
  490. #define DBG_UNREFERENCED_PARAMETER(P) \
  491. /*lint -save -e527 -e530 */ \
  492. { \
  493. (P) = (P); \
  494. } \
  495. /*lint -restore */
  496. #define DBG_UNREFERENCED_LOCAL_VARIABLE(V) \
  497. /*lint -save -e527 -e530 */ \
  498. { \
  499. (V) = (V); \
  500. } \
  501. /*lint -restore */
  502. #endif // lint
  503. //
  504. // Macro used to eliminate compiler warning 4715 within a switch statement
  505. // when all possible cases have already been accounted for.
  506. //
  507. // switch (a & 3) {
  508. // case 0: return 1;
  509. // case 1: return Foo();
  510. // case 2: return Bar();
  511. // case 3: return 1;
  512. // DEFAULT_UNREACHABLE;
  513. //
  514. #if (_MSC_VER > 1200)
  515. #define DEFAULT_UNREACHABLE default: __assume(0)
  516. #else
  517. //
  518. // Older compilers do not support __assume(), and there is no other free
  519. // method of eliminating the warning.
  520. //
  521. #define DEFAULT_UNREACHABLE
  522. #endif
  523. // end_winnt
  524. //
  525. // Define standard min and max macros
  526. //
  527. #ifndef NOMINMAX
  528. #ifndef min
  529. #define min(a,b) (((a) < (b)) ? (a) : (b))
  530. #endif
  531. #ifndef max
  532. #define max(a,b) (((a) > (b)) ? (a) : (b))
  533. #endif
  534. #endif // NOMINMAX
  535. //
  536. // IOCTL_TAPE_ERASE definitions
  537. //
  538. #define TAPE_ERASE_SHORT 0L
  539. #define TAPE_ERASE_LONG 1L
  540. typedef struct _TAPE_ERASE {
  541. ULONG Type;
  542. BOOLEAN Immediate;
  543. } TAPE_ERASE, *PTAPE_ERASE;
  544. //
  545. // IOCTL_TAPE_PREPARE definitions
  546. //
  547. #define TAPE_LOAD 0L
  548. #define TAPE_UNLOAD 1L
  549. #define TAPE_TENSION 2L
  550. #define TAPE_LOCK 3L
  551. #define TAPE_UNLOCK 4L
  552. #define TAPE_FORMAT 5L
  553. typedef struct _TAPE_PREPARE {
  554. ULONG Operation;
  555. BOOLEAN Immediate;
  556. } TAPE_PREPARE, *PTAPE_PREPARE;
  557. //
  558. // IOCTL_TAPE_WRITE_MARKS definitions
  559. //
  560. #define TAPE_SETMARKS 0L
  561. #define TAPE_FILEMARKS 1L
  562. #define TAPE_SHORT_FILEMARKS 2L
  563. #define TAPE_LONG_FILEMARKS 3L
  564. typedef struct _TAPE_WRITE_MARKS {
  565. ULONG Type;
  566. ULONG Count;
  567. BOOLEAN Immediate;
  568. } TAPE_WRITE_MARKS, *PTAPE_WRITE_MARKS;
  569. //
  570. // IOCTL_TAPE_GET_POSITION definitions
  571. //
  572. #define TAPE_ABSOLUTE_POSITION 0L
  573. #define TAPE_LOGICAL_POSITION 1L
  574. #define TAPE_PSEUDO_LOGICAL_POSITION 2L
  575. typedef struct _TAPE_GET_POSITION {
  576. ULONG Type;
  577. ULONG Partition;
  578. LARGE_INTEGER Offset;
  579. } TAPE_GET_POSITION, *PTAPE_GET_POSITION;
  580. //
  581. // IOCTL_TAPE_SET_POSITION definitions
  582. //
  583. #define TAPE_REWIND 0L
  584. #define TAPE_ABSOLUTE_BLOCK 1L
  585. #define TAPE_LOGICAL_BLOCK 2L
  586. #define TAPE_PSEUDO_LOGICAL_BLOCK 3L
  587. #define TAPE_SPACE_END_OF_DATA 4L
  588. #define TAPE_SPACE_RELATIVE_BLOCKS 5L
  589. #define TAPE_SPACE_FILEMARKS 6L
  590. #define TAPE_SPACE_SEQUENTIAL_FMKS 7L
  591. #define TAPE_SPACE_SETMARKS 8L
  592. #define TAPE_SPACE_SEQUENTIAL_SMKS 9L
  593. typedef struct _TAPE_SET_POSITION {
  594. ULONG Method;
  595. ULONG Partition;
  596. LARGE_INTEGER Offset;
  597. BOOLEAN Immediate;
  598. } TAPE_SET_POSITION, *PTAPE_SET_POSITION;
  599. //
  600. // IOCTL_TAPE_GET_DRIVE_PARAMS definitions
  601. //
  602. //
  603. // Definitions for FeaturesLow parameter
  604. //
  605. #define TAPE_DRIVE_FIXED 0x00000001
  606. #define TAPE_DRIVE_SELECT 0x00000002
  607. #define TAPE_DRIVE_INITIATOR 0x00000004
  608. #define TAPE_DRIVE_ERASE_SHORT 0x00000010
  609. #define TAPE_DRIVE_ERASE_LONG 0x00000020
  610. #define TAPE_DRIVE_ERASE_BOP_ONLY 0x00000040
  611. #define TAPE_DRIVE_ERASE_IMMEDIATE 0x00000080
  612. #define TAPE_DRIVE_TAPE_CAPACITY 0x00000100
  613. #define TAPE_DRIVE_TAPE_REMAINING 0x00000200
  614. #define TAPE_DRIVE_FIXED_BLOCK 0x00000400
  615. #define TAPE_DRIVE_VARIABLE_BLOCK 0x00000800
  616. #define TAPE_DRIVE_WRITE_PROTECT 0x00001000
  617. #define TAPE_DRIVE_EOT_WZ_SIZE 0x00002000
  618. #define TAPE_DRIVE_ECC 0x00010000
  619. #define TAPE_DRIVE_COMPRESSION 0x00020000
  620. #define TAPE_DRIVE_PADDING 0x00040000
  621. #define TAPE_DRIVE_REPORT_SMKS 0x00080000
  622. #define TAPE_DRIVE_GET_ABSOLUTE_BLK 0x00100000
  623. #define TAPE_DRIVE_GET_LOGICAL_BLK 0x00200000
  624. #define TAPE_DRIVE_SET_EOT_WZ_SIZE 0x00400000
  625. #define TAPE_DRIVE_EJECT_MEDIA 0x01000000
  626. #define TAPE_DRIVE_CLEAN_REQUESTS 0x02000000
  627. #define TAPE_DRIVE_SET_CMP_BOP_ONLY 0x04000000
  628. #define TAPE_DRIVE_RESERVED_BIT 0x80000000 //don't use this bit!
  629. // //can't be a low features bit!
  630. // //reserved; high features only
  631. //
  632. // Definitions for FeaturesHigh parameter
  633. //
  634. #define TAPE_DRIVE_LOAD_UNLOAD 0x80000001
  635. #define TAPE_DRIVE_TENSION 0x80000002
  636. #define TAPE_DRIVE_LOCK_UNLOCK 0x80000004
  637. #define TAPE_DRIVE_REWIND_IMMEDIATE 0x80000008
  638. #define TAPE_DRIVE_SET_BLOCK_SIZE 0x80000010
  639. #define TAPE_DRIVE_LOAD_UNLD_IMMED 0x80000020
  640. #define TAPE_DRIVE_TENSION_IMMED 0x80000040
  641. #define TAPE_DRIVE_LOCK_UNLK_IMMED 0x80000080
  642. #define TAPE_DRIVE_SET_ECC 0x80000100
  643. #define TAPE_DRIVE_SET_COMPRESSION 0x80000200
  644. #define TAPE_DRIVE_SET_PADDING 0x80000400
  645. #define TAPE_DRIVE_SET_REPORT_SMKS 0x80000800
  646. #define TAPE_DRIVE_ABSOLUTE_BLK 0x80001000
  647. #define TAPE_DRIVE_ABS_BLK_IMMED 0x80002000
  648. #define TAPE_DRIVE_LOGICAL_BLK 0x80004000
  649. #define TAPE_DRIVE_LOG_BLK_IMMED 0x80008000
  650. #define TAPE_DRIVE_END_OF_DATA 0x80010000
  651. #define TAPE_DRIVE_RELATIVE_BLKS 0x80020000
  652. #define TAPE_DRIVE_FILEMARKS 0x80040000
  653. #define TAPE_DRIVE_SEQUENTIAL_FMKS 0x80080000
  654. #define TAPE_DRIVE_SETMARKS 0x80100000
  655. #define TAPE_DRIVE_SEQUENTIAL_SMKS 0x80200000
  656. #define TAPE_DRIVE_REVERSE_POSITION 0x80400000
  657. #define TAPE_DRIVE_SPACE_IMMEDIATE 0x80800000
  658. #define TAPE_DRIVE_WRITE_SETMARKS 0x81000000
  659. #define TAPE_DRIVE_WRITE_FILEMARKS 0x82000000
  660. #define TAPE_DRIVE_WRITE_SHORT_FMKS 0x84000000
  661. #define TAPE_DRIVE_WRITE_LONG_FMKS 0x88000000
  662. #define TAPE_DRIVE_WRITE_MARK_IMMED 0x90000000
  663. #define TAPE_DRIVE_FORMAT 0xA0000000
  664. #define TAPE_DRIVE_FORMAT_IMMEDIATE 0xC0000000
  665. #define TAPE_DRIVE_HIGH_FEATURES 0x80000000 //mask for high features flag
  666. typedef struct _TAPE_GET_DRIVE_PARAMETERS {
  667. BOOLEAN ECC;
  668. BOOLEAN Compression;
  669. BOOLEAN DataPadding;
  670. BOOLEAN ReportSetmarks;
  671. ULONG DefaultBlockSize;
  672. ULONG MaximumBlockSize;
  673. ULONG MinimumBlockSize;
  674. ULONG MaximumPartitionCount;
  675. ULONG FeaturesLow;
  676. ULONG FeaturesHigh;
  677. ULONG EOTWarningZoneSize;
  678. } TAPE_GET_DRIVE_PARAMETERS, *PTAPE_GET_DRIVE_PARAMETERS;
  679. //
  680. // IOCTL_TAPE_SET_DRIVE_PARAMETERS definitions
  681. //
  682. typedef struct _TAPE_SET_DRIVE_PARAMETERS {
  683. BOOLEAN ECC;
  684. BOOLEAN Compression;
  685. BOOLEAN DataPadding;
  686. BOOLEAN ReportSetmarks;
  687. ULONG EOTWarningZoneSize;
  688. } TAPE_SET_DRIVE_PARAMETERS, *PTAPE_SET_DRIVE_PARAMETERS;
  689. //
  690. // IOCTL_TAPE_GET_MEDIA_PARAMETERS definitions
  691. //
  692. typedef struct _TAPE_GET_MEDIA_PARAMETERS {
  693. LARGE_INTEGER Capacity;
  694. LARGE_INTEGER Remaining;
  695. ULONG BlockSize;
  696. ULONG PartitionCount;
  697. BOOLEAN WriteProtected;
  698. } TAPE_GET_MEDIA_PARAMETERS, *PTAPE_GET_MEDIA_PARAMETERS;
  699. //
  700. // IOCTL_TAPE_SET_MEDIA_PARAMETERS definitions
  701. //
  702. typedef struct _TAPE_SET_MEDIA_PARAMETERS {
  703. ULONG BlockSize;
  704. } TAPE_SET_MEDIA_PARAMETERS, *PTAPE_SET_MEDIA_PARAMETERS;
  705. //
  706. // IOCTL_TAPE_CREATE_PARTITION definitions
  707. //
  708. #define TAPE_FIXED_PARTITIONS 0L
  709. #define TAPE_SELECT_PARTITIONS 1L
  710. #define TAPE_INITIATOR_PARTITIONS 2L
  711. typedef struct _TAPE_CREATE_PARTITION {
  712. ULONG Method;
  713. ULONG Count;
  714. ULONG Size;
  715. } TAPE_CREATE_PARTITION, *PTAPE_CREATE_PARTITION;
  716. //
  717. // WMI Methods
  718. //
  719. #define TAPE_QUERY_DRIVE_PARAMETERS 0L
  720. #define TAPE_QUERY_MEDIA_CAPACITY 1L
  721. #define TAPE_CHECK_FOR_DRIVE_PROBLEM 2L
  722. #define TAPE_QUERY_IO_ERROR_DATA 3L
  723. #define TAPE_QUERY_DEVICE_ERROR_DATA 4L
  724. typedef struct _TAPE_WMI_OPERATIONS {
  725. ULONG Method;
  726. ULONG DataBufferSize;
  727. PVOID DataBuffer;
  728. } TAPE_WMI_OPERATIONS, *PTAPE_WMI_OPERATIONS;
  729. //
  730. // Type of drive errors
  731. //
  732. typedef enum _TAPE_DRIVE_PROBLEM_TYPE {
  733. TapeDriveProblemNone, TapeDriveReadWriteWarning,
  734. TapeDriveReadWriteError, TapeDriveReadWarning,
  735. TapeDriveWriteWarning, TapeDriveReadError,
  736. TapeDriveWriteError, TapeDriveHardwareError,
  737. TapeDriveUnsupportedMedia, TapeDriveScsiConnectionError,
  738. TapeDriveTimetoClean, TapeDriveCleanDriveNow,
  739. TapeDriveMediaLifeExpired, TapeDriveSnappedTape
  740. } TAPE_DRIVE_PROBLEM_TYPE;
  741. typedef struct _TAPE_STATISTICS {
  742. ULONG Version;
  743. ULONG Flags;
  744. LARGE_INTEGER RecoveredWrites;
  745. LARGE_INTEGER UnrecoveredWrites;
  746. LARGE_INTEGER RecoveredReads;
  747. LARGE_INTEGER UnrecoveredReads;
  748. UCHAR CompressionRatioReads;
  749. UCHAR CompressionRatioWrites;
  750. } TAPE_STATISTICS, *PTAPE_STATISTICS;
  751. #define RECOVERED_WRITES_VALID 0x00000001
  752. #define UNRECOVERED_WRITES_VALID 0x00000002
  753. #define RECOVERED_READS_VALID 0x00000004
  754. #define UNRECOVERED_READS_VALID 0x00000008
  755. #define WRITE_COMPRESSION_INFO_VALID 0x00000010
  756. #define READ_COMPRESSION_INFO_VALID 0x00000020
  757. typedef struct _TAPE_GET_STATISTICS {
  758. ULONG Operation;
  759. } TAPE_GET_STATISTICS, *PTAPE_GET_STATISTICS;
  760. #define TAPE_RETURN_STATISTICS 0L
  761. #define TAPE_RETURN_ENV_INFO 1L
  762. #define TAPE_RESET_STATISTICS 2L
  763. //
  764. // IOCTL_STORAGE_GET_MEDIA_TYPES_EX will return an array of DEVICE_MEDIA_INFO
  765. // structures, one per supported type, embedded in the GET_MEDIA_TYPES struct.
  766. //
  767. typedef enum _STORAGE_MEDIA_TYPE {
  768. //
  769. // Following are defined in ntdddisk.h in the MEDIA_TYPE enum
  770. //
  771. // Unknown, // Format is unknown
  772. // F5_1Pt2_512, // 5.25", 1.2MB, 512 bytes/sector
  773. // F3_1Pt44_512, // 3.5", 1.44MB, 512 bytes/sector
  774. // F3_2Pt88_512, // 3.5", 2.88MB, 512 bytes/sector
  775. // F3_20Pt8_512, // 3.5", 20.8MB, 512 bytes/sector
  776. // F3_720_512, // 3.5", 720KB, 512 bytes/sector
  777. // F5_360_512, // 5.25", 360KB, 512 bytes/sector
  778. // F5_320_512, // 5.25", 320KB, 512 bytes/sector
  779. // F5_320_1024, // 5.25", 320KB, 1024 bytes/sector
  780. // F5_180_512, // 5.25", 180KB, 512 bytes/sector
  781. // F5_160_512, // 5.25", 160KB, 512 bytes/sector
  782. // RemovableMedia, // Removable media other than floppy
  783. // FixedMedia, // Fixed hard disk media
  784. // F3_120M_512, // 3.5", 120M Floppy
  785. // F3_640_512, // 3.5" , 640KB, 512 bytes/sector
  786. // F5_640_512, // 5.25", 640KB, 512 bytes/sector
  787. // F5_720_512, // 5.25", 720KB, 512 bytes/sector
  788. // F3_1Pt2_512, // 3.5" , 1.2Mb, 512 bytes/sector
  789. // F3_1Pt23_1024, // 3.5" , 1.23Mb, 1024 bytes/sector
  790. // F5_1Pt23_1024, // 5.25", 1.23MB, 1024 bytes/sector
  791. // F3_128Mb_512, // 3.5" MO 128Mb 512 bytes/sector
  792. // F3_230Mb_512, // 3.5" MO 230Mb 512 bytes/sector
  793. // F8_256_128, // 8", 256KB, 128 bytes/sector
  794. // F3_200Mb_512, // 3.5", 200M Floppy (HiFD)
  795. //
  796. DDS_4mm = 0x20, // Tape - DAT DDS1,2,... (all vendors)
  797. MiniQic, // Tape - miniQIC Tape
  798. Travan, // Tape - Travan TR-1,2,3,...
  799. QIC, // Tape - QIC
  800. MP_8mm, // Tape - 8mm Exabyte Metal Particle
  801. AME_8mm, // Tape - 8mm Exabyte Advanced Metal Evap
  802. AIT1_8mm, // Tape - 8mm Sony AIT
  803. DLT, // Tape - DLT Compact IIIxt, IV
  804. NCTP, // Tape - Philips NCTP
  805. IBM_3480, // Tape - IBM 3480
  806. IBM_3490E, // Tape - IBM 3490E
  807. IBM_Magstar_3590, // Tape - IBM Magstar 3590
  808. IBM_Magstar_MP, // Tape - IBM Magstar MP
  809. STK_DATA_D3, // Tape - STK Data D3
  810. SONY_DTF, // Tape - Sony DTF
  811. DV_6mm, // Tape - 6mm Digital Video
  812. DMI, // Tape - Exabyte DMI and compatibles
  813. SONY_D2, // Tape - Sony D2S and D2L
  814. CLEANER_CARTRIDGE, // Cleaner - All Drive types that support Drive Cleaners
  815. CD_ROM, // Opt_Disk - CD
  816. CD_R, // Opt_Disk - CD-Recordable (Write Once)
  817. CD_RW, // Opt_Disk - CD-Rewriteable
  818. DVD_ROM, // Opt_Disk - DVD-ROM
  819. DVD_R, // Opt_Disk - DVD-Recordable (Write Once)
  820. DVD_RW, // Opt_Disk - DVD-Rewriteable
  821. MO_3_RW, // Opt_Disk - 3.5" Rewriteable MO Disk
  822. MO_5_WO, // Opt_Disk - MO 5.25" Write Once
  823. MO_5_RW, // Opt_Disk - MO 5.25" Rewriteable (not LIMDOW)
  824. MO_5_LIMDOW, // Opt_Disk - MO 5.25" Rewriteable (LIMDOW)
  825. PC_5_WO, // Opt_Disk - Phase Change 5.25" Write Once Optical
  826. PC_5_RW, // Opt_Disk - Phase Change 5.25" Rewriteable
  827. PD_5_RW, // Opt_Disk - PhaseChange Dual Rewriteable
  828. ABL_5_WO, // Opt_Disk - Ablative 5.25" Write Once Optical
  829. PINNACLE_APEX_5_RW, // Opt_Disk - Pinnacle Apex 4.6GB Rewriteable Optical
  830. SONY_12_WO, // Opt_Disk - Sony 12" Write Once
  831. PHILIPS_12_WO, // Opt_Disk - Philips/LMS 12" Write Once
  832. HITACHI_12_WO, // Opt_Disk - Hitachi 12" Write Once
  833. CYGNET_12_WO, // Opt_Disk - Cygnet/ATG 12" Write Once
  834. KODAK_14_WO, // Opt_Disk - Kodak 14" Write Once
  835. MO_NFR_525, // Opt_Disk - Near Field Recording (Terastor)
  836. NIKON_12_RW, // Opt_Disk - Nikon 12" Rewriteable
  837. IOMEGA_ZIP, // Mag_Disk - Iomega Zip
  838. IOMEGA_JAZ, // Mag_Disk - Iomega Jaz
  839. SYQUEST_EZ135, // Mag_Disk - Syquest EZ135
  840. SYQUEST_EZFLYER, // Mag_Disk - Syquest EzFlyer
  841. SYQUEST_SYJET, // Mag_Disk - Syquest SyJet
  842. AVATAR_F2, // Mag_Disk - 2.5" Floppy
  843. MP2_8mm, // Tape - 8mm Hitachi
  844. DST_S, // Ampex DST Small Tapes
  845. DST_M, // Ampex DST Medium Tapes
  846. DST_L, // Ampex DST Large Tapes
  847. VXATape_1, // Ecrix 8mm Tape
  848. VXATape_2, // Ecrix 8mm Tape
  849. STK_9840, // STK 9840
  850. LTO_Ultrium, // IBM, HP, Seagate LTO Ultrium
  851. LTO_Accelis, // IBM, HP, Seagate LTO Accelis
  852. DVD_RAM, // Opt_Disk - DVD-RAM
  853. AIT_8mm, // AIT2 or higher
  854. ADR_1, // OnStream ADR Mediatypes
  855. ADR_2
  856. } STORAGE_MEDIA_TYPE, *PSTORAGE_MEDIA_TYPE;
  857. #define MEDIA_ERASEABLE 0x00000001
  858. #define MEDIA_WRITE_ONCE 0x00000002
  859. #define MEDIA_READ_ONLY 0x00000004
  860. #define MEDIA_READ_WRITE 0x00000008
  861. #define MEDIA_WRITE_PROTECTED 0x00000100
  862. #define MEDIA_CURRENTLY_MOUNTED 0x80000000
  863. //
  864. // Define the different storage bus types
  865. // Bus types below 128 (0x80) are reserved for Microsoft use
  866. //
  867. typedef enum _STORAGE_BUS_TYPE {
  868. BusTypeUnknown = 0x00,
  869. BusTypeScsi,
  870. BusTypeAtapi,
  871. BusTypeAta,
  872. BusType1394,
  873. BusTypeSsa,
  874. BusTypeFibre,
  875. BusTypeUsb,
  876. BusTypeRAID,
  877. BusTypeMaxReserved = 0x7F
  878. } STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE;
  879. typedef struct _DEVICE_MEDIA_INFO {
  880. union {
  881. struct {
  882. LARGE_INTEGER Cylinders;
  883. STORAGE_MEDIA_TYPE MediaType;
  884. ULONG TracksPerCylinder;
  885. ULONG SectorsPerTrack;
  886. ULONG BytesPerSector;
  887. ULONG NumberMediaSides;
  888. ULONG MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  889. } DiskInfo;
  890. struct {
  891. LARGE_INTEGER Cylinders;
  892. STORAGE_MEDIA_TYPE MediaType;
  893. ULONG TracksPerCylinder;
  894. ULONG SectorsPerTrack;
  895. ULONG BytesPerSector;
  896. ULONG NumberMediaSides;
  897. ULONG MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  898. } RemovableDiskInfo;
  899. struct {
  900. STORAGE_MEDIA_TYPE MediaType;
  901. ULONG MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  902. ULONG CurrentBlockSize;
  903. STORAGE_BUS_TYPE BusType;
  904. //
  905. // Bus specific information describing the medium supported.
  906. //
  907. union {
  908. struct {
  909. UCHAR MediumType;
  910. UCHAR DensityCode;
  911. } ScsiInformation;
  912. } BusSpecificData;
  913. } TapeInfo;
  914. } DeviceSpecific;
  915. } DEVICE_MEDIA_INFO, *PDEVICE_MEDIA_INFO;
  916. typedef struct _GET_MEDIA_TYPES {
  917. ULONG DeviceType; // FILE_DEVICE_XXX values
  918. ULONG MediaInfoCount;
  919. DEVICE_MEDIA_INFO MediaInfo[1];
  920. } GET_MEDIA_TYPES, *PGET_MEDIA_TYPES;
  921. //
  922. // IOCTL_STORAGE_PREDICT_FAILURE
  923. //
  924. // input - none
  925. //
  926. // output - STORAGE_PREDICT_FAILURE structure
  927. // PredictFailure returns zero if no failure predicted and non zero
  928. // if a failure is predicted.
  929. //
  930. // VendorSpecific returns 512 bytes of vendor specific information
  931. // if a failure is predicted
  932. //
  933. typedef struct _STORAGE_PREDICT_FAILURE
  934. {
  935. ULONG PredictFailure;
  936. UCHAR VendorSpecific[512];
  937. } STORAGE_PREDICT_FAILURE, *PSTORAGE_PREDICT_FAILURE;
  938. #define MAXIMUM_CDB_SIZE 12
  939. //
  940. // SCSI I/O Request Block
  941. //
  942. typedef struct _SCSI_REQUEST_BLOCK {
  943. USHORT Length; // offset 0
  944. UCHAR Function; // offset 2
  945. UCHAR SrbStatus; // offset 3
  946. UCHAR ScsiStatus; // offset 4
  947. UCHAR PathId; // offset 5
  948. UCHAR TargetId; // offset 6
  949. UCHAR Lun; // offset 7
  950. UCHAR QueueTag; // offset 8
  951. UCHAR QueueAction; // offset 9
  952. UCHAR CdbLength; // offset a
  953. UCHAR SenseInfoBufferLength; // offset b
  954. ULONG SrbFlags; // offset c
  955. ULONG DataTransferLength; // offset 10
  956. ULONG TimeOutValue; // offset 14
  957. PVOID DataBuffer; // offset 18
  958. PVOID SenseInfoBuffer; // offset 1c
  959. struct _SCSI_REQUEST_BLOCK *NextSrb; // offset 20
  960. PVOID OriginalRequest; // offset 24
  961. PVOID SrbExtension; // offset 28
  962. union {
  963. ULONG InternalStatus; // offset 2c
  964. ULONG QueueSortKey; // offset 2c
  965. };
  966. #if defined(_WIN64)
  967. //
  968. // Force PVOID alignment of Cdb
  969. //
  970. ULONG Reserved;
  971. #endif
  972. UCHAR Cdb[16]; // offset 30
  973. } SCSI_REQUEST_BLOCK, *PSCSI_REQUEST_BLOCK;
  974. #define SCSI_REQUEST_BLOCK_SIZE sizeof(SCSI_REQUEST_BLOCK)
  975. //
  976. // SCSI I/O Request Block for WMI Requests
  977. //
  978. typedef struct _SCSI_WMI_REQUEST_BLOCK {
  979. USHORT Length;
  980. UCHAR Function; // SRB_FUNCTION_WMI
  981. UCHAR SrbStatus;
  982. UCHAR WMISubFunction;
  983. UCHAR PathId; // If SRB_WMI_FLAGS_ADAPTER_REQUEST is set in
  984. UCHAR TargetId; // WMIFlags then PathId, TargetId and Lun are
  985. UCHAR Lun; // reserved fields.
  986. UCHAR Reserved1;
  987. UCHAR WMIFlags;
  988. UCHAR Reserved2[2];
  989. ULONG SrbFlags;
  990. ULONG DataTransferLength;
  991. ULONG TimeOutValue;
  992. PVOID DataBuffer;
  993. PVOID DataPath;
  994. PVOID Reserved3;
  995. PVOID OriginalRequest;
  996. PVOID SrbExtension;
  997. ULONG Reserved4;
  998. UCHAR Reserved5[16];
  999. } SCSI_WMI_REQUEST_BLOCK, *PSCSI_WMI_REQUEST_BLOCK;
  1000. //
  1001. // SRB Functions
  1002. //
  1003. #define SRB_FUNCTION_EXECUTE_SCSI 0x00
  1004. #define SRB_FUNCTION_CLAIM_DEVICE 0x01
  1005. #define SRB_FUNCTION_IO_CONTROL 0x02
  1006. #define SRB_FUNCTION_RECEIVE_EVENT 0x03
  1007. #define SRB_FUNCTION_RELEASE_QUEUE 0x04
  1008. #define SRB_FUNCTION_ATTACH_DEVICE 0x05
  1009. #define SRB_FUNCTION_RELEASE_DEVICE 0x06
  1010. #define SRB_FUNCTION_SHUTDOWN 0x07
  1011. #define SRB_FUNCTION_FLUSH 0x08
  1012. #define SRB_FUNCTION_ABORT_COMMAND 0x10
  1013. #define SRB_FUNCTION_RELEASE_RECOVERY 0x11
  1014. #define SRB_FUNCTION_RESET_BUS 0x12
  1015. #define SRB_FUNCTION_RESET_DEVICE 0x13
  1016. #define SRB_FUNCTION_TERMINATE_IO 0x14
  1017. #define SRB_FUNCTION_FLUSH_QUEUE 0x15
  1018. #define SRB_FUNCTION_REMOVE_DEVICE 0x16
  1019. #define SRB_FUNCTION_WMI 0x17
  1020. #define SRB_FUNCTION_LOCK_QUEUE 0x18
  1021. #define SRB_FUNCTION_UNLOCK_QUEUE 0x19
  1022. #define SRB_FUNCTION_RESET_LOGICAL_UNIT 0x20
  1023. //
  1024. // SRB Status
  1025. //
  1026. #define SRB_STATUS_PENDING 0x00
  1027. #define SRB_STATUS_SUCCESS 0x01
  1028. #define SRB_STATUS_ABORTED 0x02
  1029. #define SRB_STATUS_ABORT_FAILED 0x03
  1030. #define SRB_STATUS_ERROR 0x04
  1031. #define SRB_STATUS_BUSY 0x05
  1032. #define SRB_STATUS_INVALID_REQUEST 0x06
  1033. #define SRB_STATUS_INVALID_PATH_ID 0x07
  1034. #define SRB_STATUS_NO_DEVICE 0x08
  1035. #define SRB_STATUS_TIMEOUT 0x09
  1036. #define SRB_STATUS_SELECTION_TIMEOUT 0x0A
  1037. #define SRB_STATUS_COMMAND_TIMEOUT 0x0B
  1038. #define SRB_STATUS_MESSAGE_REJECTED 0x0D
  1039. #define SRB_STATUS_BUS_RESET 0x0E
  1040. #define SRB_STATUS_PARITY_ERROR 0x0F
  1041. #define SRB_STATUS_REQUEST_SENSE_FAILED 0x10
  1042. #define SRB_STATUS_NO_HBA 0x11
  1043. #define SRB_STATUS_DATA_OVERRUN 0x12
  1044. #define SRB_STATUS_UNEXPECTED_BUS_FREE 0x13
  1045. #define SRB_STATUS_PHASE_SEQUENCE_FAILURE 0x14
  1046. #define SRB_STATUS_BAD_SRB_BLOCK_LENGTH 0x15
  1047. #define SRB_STATUS_REQUEST_FLUSHED 0x16
  1048. #define SRB_STATUS_INVALID_LUN 0x20
  1049. #define SRB_STATUS_INVALID_TARGET_ID 0x21
  1050. #define SRB_STATUS_BAD_FUNCTION 0x22
  1051. #define SRB_STATUS_ERROR_RECOVERY 0x23
  1052. #define SRB_STATUS_NOT_POWERED 0x24
  1053. //
  1054. // This value is used by the port driver to indicate that a non-scsi-related
  1055. // error occured. Miniports must never return this status.
  1056. //
  1057. #define SRB_STATUS_INTERNAL_ERROR 0x30
  1058. //
  1059. // Srb status values 0x38 through 0x3f are reserved for internal port driver
  1060. // use.
  1061. //
  1062. //
  1063. // SRB Status Masks
  1064. //
  1065. #define SRB_STATUS_QUEUE_FROZEN 0x40
  1066. #define SRB_STATUS_AUTOSENSE_VALID 0x80
  1067. #define SRB_STATUS(Status) (Status & ~(SRB_STATUS_AUTOSENSE_VALID | SRB_STATUS_QUEUE_FROZEN))
  1068. //
  1069. // SRB Flag Bits
  1070. //
  1071. #define SRB_FLAGS_QUEUE_ACTION_ENABLE 0x00000002
  1072. #define SRB_FLAGS_DISABLE_DISCONNECT 0x00000004
  1073. #define SRB_FLAGS_DISABLE_SYNCH_TRANSFER 0x00000008
  1074. #define SRB_FLAGS_BYPASS_FROZEN_QUEUE 0x00000010
  1075. #define SRB_FLAGS_DISABLE_AUTOSENSE 0x00000020
  1076. #define SRB_FLAGS_DATA_IN 0x00000040
  1077. #define SRB_FLAGS_DATA_OUT 0x00000080
  1078. #define SRB_FLAGS_NO_DATA_TRANSFER 0x00000000
  1079. #define SRB_FLAGS_UNSPECIFIED_DIRECTION (SRB_FLAGS_DATA_IN | SRB_FLAGS_DATA_OUT)
  1080. #define SRB_FLAGS_NO_QUEUE_FREEZE 0x00000100
  1081. #define SRB_FLAGS_ADAPTER_CACHE_ENABLE 0x00000200
  1082. #define SRB_FLAGS_FREE_SENSE_BUFFER 0x00000400
  1083. #define SRB_FLAGS_IS_ACTIVE 0x00010000
  1084. #define SRB_FLAGS_ALLOCATED_FROM_ZONE 0x00020000
  1085. #define SRB_FLAGS_SGLIST_FROM_POOL 0x00040000
  1086. #define SRB_FLAGS_BYPASS_LOCKED_QUEUE 0x00080000
  1087. #define SRB_FLAGS_NO_KEEP_AWAKE 0x00100000
  1088. #define SRB_FLAGS_PORT_DRIVER_ALLOCSENSE 0x00200000
  1089. #define SRB_FLAGS_PORT_DRIVER_SENSEHASPORT 0x00400000
  1090. #define SRB_FLAGS_DONT_START_NEXT_PACKET 0x00800000
  1091. #define SRB_FLAGS_PORT_DRIVER_RESERVED 0x0F000000
  1092. #define SRB_FLAGS_CLASS_DRIVER_RESERVED 0xF0000000
  1093. #if DBG==1
  1094. //
  1095. // A signature used to validate the scsi port number
  1096. // at the end of a sense buffer.
  1097. //
  1098. #define SCSI_PORT_SIGNATURE 0x54524f50
  1099. #endif
  1100. //
  1101. // Queue Action
  1102. //
  1103. #define SRB_SIMPLE_TAG_REQUEST 0x20
  1104. #define SRB_HEAD_OF_QUEUE_TAG_REQUEST 0x21
  1105. #define SRB_ORDERED_QUEUE_TAG_REQUEST 0x22
  1106. #define SRB_WMI_FLAGS_ADAPTER_REQUEST 0x01
  1107. #ifndef _NTDDK_
  1108. #define SCSIPORT_API DECLSPEC_IMPORT
  1109. #else
  1110. #define SCSIPORT_API
  1111. #endif
  1112. SCSIPORT_API
  1113. VOID
  1114. ScsiDebugPrint(
  1115. ULONG DebugPrintLevel,
  1116. PCCHAR DebugMessage,
  1117. ...
  1118. );
  1119. //
  1120. // Command Descriptor Block. Passed by SCSI controller chip over the SCSI bus
  1121. //
  1122. typedef union _CDB {
  1123. //
  1124. // Generic 6-Byte CDB
  1125. //
  1126. struct _CDB6GENERIC {
  1127. UCHAR OperationCode;
  1128. UCHAR Immediate : 1;
  1129. UCHAR CommandUniqueBits : 4;
  1130. UCHAR LogicalUnitNumber : 3;
  1131. UCHAR CommandUniqueBytes[3];
  1132. UCHAR Link : 1;
  1133. UCHAR Flag : 1;
  1134. UCHAR Reserved : 4;
  1135. UCHAR VendorUnique : 2;
  1136. } CDB6GENERIC, *PCDB6GENERIC;
  1137. //
  1138. // Standard 6-byte CDB
  1139. //
  1140. struct _CDB6READWRITE {
  1141. UCHAR OperationCode; // 0x08, 0x0A - SCSIOP_READ, SCSIOP_WRITE
  1142. UCHAR LogicalBlockMsb1 : 5;
  1143. UCHAR LogicalUnitNumber : 3;
  1144. UCHAR LogicalBlockMsb0;
  1145. UCHAR LogicalBlockLsb;
  1146. UCHAR TransferBlocks;
  1147. UCHAR Control;
  1148. } CDB6READWRITE, *PCDB6READWRITE;
  1149. //
  1150. // SCSI-1 Inquiry CDB
  1151. //
  1152. struct _CDB6INQUIRY {
  1153. UCHAR OperationCode; // 0x12 - SCSIOP_INQUIRY
  1154. UCHAR Reserved1 : 5;
  1155. UCHAR LogicalUnitNumber : 3;
  1156. UCHAR PageCode;
  1157. UCHAR IReserved;
  1158. UCHAR AllocationLength;
  1159. UCHAR Control;
  1160. } CDB6INQUIRY, *PCDB6INQUIRY;
  1161. //
  1162. // SCSI-3 Inquiry CDB
  1163. //
  1164. struct _CDB6INQUIRY3 {
  1165. UCHAR OperationCode; // 0x12 - SCSIOP_INQUIRY
  1166. UCHAR EnableVitalProductData : 1;
  1167. UCHAR CommandSupportData : 1;
  1168. UCHAR Reserved1 : 6;
  1169. UCHAR PageCode;
  1170. UCHAR Reserved2;
  1171. UCHAR AllocationLength;
  1172. UCHAR Control;
  1173. } CDB6INQUIRY3, *PCDB6INQUIRY3;
  1174. struct _CDB6VERIFY {
  1175. UCHAR OperationCode; // 0x13 - SCSIOP_VERIFY
  1176. UCHAR Fixed : 1;
  1177. UCHAR ByteCompare : 1;
  1178. UCHAR Immediate : 1;
  1179. UCHAR Reserved : 2;
  1180. UCHAR LogicalUnitNumber : 3;
  1181. UCHAR VerificationLength[3];
  1182. UCHAR Control;
  1183. } CDB6VERIFY, *PCDB6VERIFY;
  1184. //
  1185. // SCSI Format CDB
  1186. //
  1187. struct _CDB6FORMAT {
  1188. UCHAR OperationCode; // 0x04 - SCSIOP_FORMAT_UNIT
  1189. UCHAR FormatControl : 5;
  1190. UCHAR LogicalUnitNumber : 3;
  1191. UCHAR FReserved1;
  1192. UCHAR InterleaveMsb;
  1193. UCHAR InterleaveLsb;
  1194. UCHAR FReserved2;
  1195. } CDB6FORMAT, *PCDB6FORMAT;
  1196. //
  1197. // Standard 10-byte CDB
  1198. struct _CDB10 {
  1199. UCHAR OperationCode;
  1200. UCHAR RelativeAddress : 1;
  1201. UCHAR Reserved1 : 2;
  1202. UCHAR ForceUnitAccess : 1;
  1203. UCHAR DisablePageOut : 1;
  1204. UCHAR LogicalUnitNumber : 3;
  1205. UCHAR LogicalBlockByte0;
  1206. UCHAR LogicalBlockByte1;
  1207. UCHAR LogicalBlockByte2;
  1208. UCHAR LogicalBlockByte3;
  1209. UCHAR Reserved2;
  1210. UCHAR TransferBlocksMsb;
  1211. UCHAR TransferBlocksLsb;
  1212. UCHAR Control;
  1213. } CDB10, *PCDB10;
  1214. //
  1215. // Standard 12-byte CDB
  1216. //
  1217. struct _CDB12 {
  1218. UCHAR OperationCode;
  1219. UCHAR RelativeAddress : 1;
  1220. UCHAR Reserved1 : 2;
  1221. UCHAR ForceUnitAccess : 1;
  1222. UCHAR DisablePageOut : 1;
  1223. UCHAR LogicalUnitNumber : 3;
  1224. UCHAR LogicalBlock[4];
  1225. UCHAR TransferLength[4];
  1226. UCHAR Reserved2;
  1227. UCHAR Control;
  1228. } CDB12, *PCDB12;
  1229. //
  1230. // CD Rom Audio CDBs
  1231. //
  1232. struct _PAUSE_RESUME {
  1233. UCHAR OperationCode; // 0x4B - SCSIOP_PAUSE_RESUME
  1234. UCHAR Reserved1 : 5;
  1235. UCHAR LogicalUnitNumber : 3;
  1236. UCHAR Reserved2[6];
  1237. UCHAR Action;
  1238. UCHAR Control;
  1239. } PAUSE_RESUME, *PPAUSE_RESUME;
  1240. //
  1241. // Read Table of Contents
  1242. //
  1243. struct _READ_TOC {
  1244. UCHAR OperationCode; // 0x43 - SCSIOP_READ_TOC
  1245. UCHAR Reserved0 : 1;
  1246. UCHAR Msf : 1;
  1247. UCHAR Reserved1 : 3;
  1248. UCHAR LogicalUnitNumber : 3;
  1249. UCHAR Format2 : 4;
  1250. UCHAR Reserved2 : 4;
  1251. UCHAR Reserved3[3];
  1252. UCHAR StartingTrack;
  1253. UCHAR AllocationLength[2];
  1254. UCHAR Control : 6;
  1255. UCHAR Format : 2;
  1256. } READ_TOC, *PREAD_TOC;
  1257. struct _READ_DISK_INFORMATION {
  1258. UCHAR OperationCode; // 0x51 - SCSIOP_READ_DISC_INFORMATION
  1259. UCHAR Reserved1 : 5;
  1260. UCHAR Lun : 3;
  1261. UCHAR Reserved2[5];
  1262. UCHAR AllocationLength[2];
  1263. UCHAR Control;
  1264. } READ_DISK_INFORMATION, *PREAD_DISK_INFORMATION;
  1265. struct _READ_TRACK_INFORMATION {
  1266. UCHAR OperationCode; // 0x52 - SCSIOP_READ_TRACK_INFORMATION
  1267. UCHAR Track : 1;
  1268. UCHAR Reserved1 : 3;
  1269. UCHAR Reserved2 : 1;
  1270. UCHAR Lun : 3;
  1271. UCHAR BlockAddress[4]; // or Track Number
  1272. UCHAR Reserved3;
  1273. UCHAR AllocationLength[2];
  1274. UCHAR Control;
  1275. } READ_TRACK_INFORMATION, *PREAD_TRACK_INFORMATION;
  1276. struct _RESERVE_TRACK_RZONE {
  1277. UCHAR OperationCode; // 0x53 - SCSIOP_RESERVE_TRACK_RZONE
  1278. UCHAR Reserved1[4];
  1279. UCHAR ReservationSize[4];
  1280. UCHAR Control;
  1281. } RESERVE_TRACK_RZONE, *PRESERVE_TRACK_RZONE;
  1282. struct _SEND_OPC_INFORMATION {
  1283. UCHAR OperationCode; // 0x54 - SCSIOP_SEND_OPC_INFORMATION
  1284. UCHAR DoOpc : 1; // perform OPC
  1285. UCHAR Reserved : 7;
  1286. UCHAR Reserved1[5];
  1287. UCHAR ParameterListLength[2];
  1288. UCHAR Reserved2;
  1289. } SEND_OPC_INFORMATION, *PSEND_OPC_INFORMATION;
  1290. struct _CLOSE_TRACK {
  1291. UCHAR OperationCode; // 0x5B - SCSIOP_CLOSE_TRACK_SESSION
  1292. UCHAR Immediate : 1;
  1293. UCHAR Reserved1 : 7;
  1294. UCHAR Track : 1;
  1295. UCHAR Session : 1;
  1296. UCHAR Reserved2 : 6;
  1297. UCHAR Reserved3;
  1298. UCHAR TrackNumber[2];
  1299. UCHAR Reserved4[3];
  1300. UCHAR Control;
  1301. } CLOSE_TRACK, *PCLOSE_TRACK;
  1302. struct _SEND_CUE_SHEET {
  1303. UCHAR OperationCode; // 0x5D - SCSIOP_SEND_CUE_SHEET
  1304. UCHAR Reserved[5];
  1305. UCHAR CueSheetSize[3];
  1306. UCHAR Control;
  1307. } SEND_CUE_SHEET, *PSEND_CUE_SHEET;
  1308. struct _READ_HEADER {
  1309. UCHAR OperationCode; // 0x44 - SCSIOP_READ_HEADER
  1310. UCHAR Reserved1 : 1;
  1311. UCHAR Msf : 1;
  1312. UCHAR Reserved2 : 3;
  1313. UCHAR Lun : 3;
  1314. UCHAR LogicalBlockAddress[4];
  1315. UCHAR Reserved3;
  1316. UCHAR AllocationLength[2];
  1317. UCHAR Control;
  1318. } READ_HEADER, *PREAD_HEADER;
  1319. struct _PLAY_AUDIO {
  1320. UCHAR OperationCode; // 0x45 - SCSIOP_PLAY_AUDIO
  1321. UCHAR Reserved1 : 5;
  1322. UCHAR LogicalUnitNumber : 3;
  1323. UCHAR StartingBlockAddress[4];
  1324. UCHAR Reserved2;
  1325. UCHAR PlayLength[2];
  1326. UCHAR Control;
  1327. } PLAY_AUDIO, *PPLAY_AUDIO;
  1328. struct _PLAY_AUDIO_MSF {
  1329. UCHAR OperationCode; // 0x47 - SCSIOP_PLAY_AUDIO_MSF
  1330. UCHAR Reserved1 : 5;
  1331. UCHAR LogicalUnitNumber : 3;
  1332. UCHAR Reserved2;
  1333. UCHAR StartingM;
  1334. UCHAR StartingS;
  1335. UCHAR StartingF;
  1336. UCHAR EndingM;
  1337. UCHAR EndingS;
  1338. UCHAR EndingF;
  1339. UCHAR Control;
  1340. } PLAY_AUDIO_MSF, *PPLAY_AUDIO_MSF;
  1341. struct _PLAY_CD {
  1342. UCHAR OperationCode; // 0xBC - SCSIOP_PLAY_CD
  1343. UCHAR Reserved1 : 1;
  1344. UCHAR CMSF : 1; // LBA = 0, MSF = 1
  1345. UCHAR ExpectedSectorType : 3;
  1346. UCHAR Lun : 3;
  1347. union {
  1348. struct _LBA {
  1349. UCHAR StartingBlockAddress[4];
  1350. UCHAR PlayLength[4];
  1351. } LBA;
  1352. struct _MSF {
  1353. UCHAR Reserved1;
  1354. UCHAR StartingM;
  1355. UCHAR StartingS;
  1356. UCHAR StartingF;
  1357. UCHAR EndingM;
  1358. UCHAR EndingS;
  1359. UCHAR EndingF;
  1360. UCHAR Reserved2;
  1361. } MSF;
  1362. };
  1363. UCHAR Audio : 1;
  1364. UCHAR Composite : 1;
  1365. UCHAR Port1 : 1;
  1366. UCHAR Port2 : 1;
  1367. UCHAR Reserved2 : 3;
  1368. UCHAR Speed : 1;
  1369. UCHAR Control;
  1370. } PLAY_CD, *PPLAY_CD;
  1371. struct _SCAN_CD {
  1372. UCHAR OperationCode; // 0xBA - SCSIOP_SCAN_CD
  1373. UCHAR RelativeAddress : 1;
  1374. UCHAR Reserved1 : 3;
  1375. UCHAR Direct : 1;
  1376. UCHAR Lun : 3;
  1377. UCHAR StartingAddress[4];
  1378. UCHAR Reserved2[3];
  1379. UCHAR Reserved3 : 6;
  1380. UCHAR Type : 2;
  1381. UCHAR Reserved4;
  1382. UCHAR Control;
  1383. } SCAN_CD, *PSCAN_CD;
  1384. struct _STOP_PLAY_SCAN {
  1385. UCHAR OperationCode; // 0x4E - SCSIOP_STOP_PLAY_SCAN
  1386. UCHAR Reserved1 : 5;
  1387. UCHAR Lun : 3;
  1388. UCHAR Reserved2[7];
  1389. UCHAR Control;
  1390. } STOP_PLAY_SCAN, *PSTOP_PLAY_SCAN;
  1391. //
  1392. // Read SubChannel Data
  1393. //
  1394. struct _SUBCHANNEL {
  1395. UCHAR OperationCode; // 0x42 - SCSIOP_READ_SUB_CHANNEL
  1396. UCHAR Reserved0 : 1;
  1397. UCHAR Msf : 1;
  1398. UCHAR Reserved1 : 3;
  1399. UCHAR LogicalUnitNumber : 3;
  1400. UCHAR Reserved2 : 6;
  1401. UCHAR SubQ : 1;
  1402. UCHAR Reserved3 : 1;
  1403. UCHAR Format;
  1404. UCHAR Reserved4[2];
  1405. UCHAR TrackNumber;
  1406. UCHAR AllocationLength[2];
  1407. UCHAR Control;
  1408. } SUBCHANNEL, *PSUBCHANNEL;
  1409. //
  1410. // Read CD. Used by Atapi for raw sector reads.
  1411. //
  1412. struct _READ_CD {
  1413. UCHAR OperationCode; // 0xBE - SCSIOP_READ_CD
  1414. UCHAR RelativeAddress : 1;
  1415. UCHAR Reserved0 : 1;
  1416. UCHAR ExpectedSectorType : 3;
  1417. UCHAR Lun : 3;
  1418. UCHAR StartingLBA[4];
  1419. UCHAR TransferBlocks[3];
  1420. UCHAR Reserved2 : 1;
  1421. UCHAR ErrorFlags : 2;
  1422. UCHAR IncludeEDC : 1;
  1423. UCHAR IncludeUserData : 1;
  1424. UCHAR HeaderCode : 2;
  1425. UCHAR IncludeSyncData : 1;
  1426. UCHAR SubChannelSelection : 3;
  1427. UCHAR Reserved3 : 5;
  1428. UCHAR Control;
  1429. } READ_CD, *PREAD_CD;
  1430. struct _READ_CD_MSF {
  1431. UCHAR OperationCode; // 0xB9 - SCSIOP_READ_CD_MSF
  1432. UCHAR RelativeAddress : 1;
  1433. UCHAR Reserved1 : 1;
  1434. UCHAR ExpectedSectorType : 3;
  1435. UCHAR Lun : 3;
  1436. UCHAR Reserved2;
  1437. UCHAR StartingM;
  1438. UCHAR StartingS;
  1439. UCHAR StartingF;
  1440. UCHAR EndingM;
  1441. UCHAR EndingS;
  1442. UCHAR EndingF;
  1443. UCHAR Reserved3;
  1444. UCHAR Reserved4 : 1;
  1445. UCHAR ErrorFlags : 2;
  1446. UCHAR IncludeEDC : 1;
  1447. UCHAR IncludeUserData : 1;
  1448. UCHAR HeaderCode : 2;
  1449. UCHAR IncludeSyncData : 1;
  1450. UCHAR SubChannelSelection : 3;
  1451. UCHAR Reserved5 : 5;
  1452. UCHAR Control;
  1453. } READ_CD_MSF, *PREAD_CD_MSF;
  1454. //
  1455. // Plextor Read CD-DA
  1456. //
  1457. struct _PLXTR_READ_CDDA {
  1458. UCHAR OperationCode; // Unknown -- vendor-unique?
  1459. UCHAR Reserved0 : 5;
  1460. UCHAR LogicalUnitNumber :3;
  1461. UCHAR LogicalBlockByte0;
  1462. UCHAR LogicalBlockByte1;
  1463. UCHAR LogicalBlockByte2;
  1464. UCHAR LogicalBlockByte3;
  1465. UCHAR TransferBlockByte0;
  1466. UCHAR TransferBlockByte1;
  1467. UCHAR TransferBlockByte2;
  1468. UCHAR TransferBlockByte3;
  1469. UCHAR SubCode;
  1470. UCHAR Control;
  1471. } PLXTR_READ_CDDA, *PPLXTR_READ_CDDA;
  1472. //
  1473. // NEC Read CD-DA
  1474. //
  1475. struct _NEC_READ_CDDA {
  1476. UCHAR OperationCode; // Unknown -- vendor-unique?
  1477. UCHAR Reserved0;
  1478. UCHAR LogicalBlockByte0;
  1479. UCHAR LogicalBlockByte1;
  1480. UCHAR LogicalBlockByte2;
  1481. UCHAR LogicalBlockByte3;
  1482. UCHAR Reserved1;
  1483. UCHAR TransferBlockByte0;
  1484. UCHAR TransferBlockByte1;
  1485. UCHAR Control;
  1486. } NEC_READ_CDDA, *PNEC_READ_CDDA;
  1487. //
  1488. // Mode sense
  1489. //
  1490. struct _MODE_SENSE {
  1491. UCHAR OperationCode; // 0x1A - SCSIOP_MODE_SENSE
  1492. UCHAR Reserved1 : 3;
  1493. UCHAR Dbd : 1;
  1494. UCHAR Reserved2 : 1;
  1495. UCHAR LogicalUnitNumber : 3;
  1496. UCHAR PageCode : 6;
  1497. UCHAR Pc : 2;
  1498. UCHAR Reserved3;
  1499. UCHAR AllocationLength;
  1500. UCHAR Control;
  1501. } MODE_SENSE, *PMODE_SENSE;
  1502. struct _MODE_SENSE10 {
  1503. UCHAR OperationCode; // 0x5A - SCSIOP_MODE_SENSE10
  1504. UCHAR Reserved1 : 3;
  1505. UCHAR Dbd : 1;
  1506. UCHAR Reserved2 : 1;
  1507. UCHAR LogicalUnitNumber : 3;
  1508. UCHAR PageCode : 6;
  1509. UCHAR Pc : 2;
  1510. UCHAR Reserved3[4];
  1511. UCHAR AllocationLength[2];
  1512. UCHAR Control;
  1513. } MODE_SENSE10, *PMODE_SENSE10;
  1514. //
  1515. // Mode select
  1516. //
  1517. struct _MODE_SELECT {
  1518. UCHAR OperationCode; // 0x15 - SCSIOP_MODE_SELECT
  1519. UCHAR SPBit : 1;
  1520. UCHAR Reserved1 : 3;
  1521. UCHAR PFBit : 1;
  1522. UCHAR LogicalUnitNumber : 3;
  1523. UCHAR Reserved2[2];
  1524. UCHAR ParameterListLength;
  1525. UCHAR Control;
  1526. } MODE_SELECT, *PMODE_SELECT;
  1527. struct _MODE_SELECT10 {
  1528. UCHAR OperationCode; // 0x55 - SCSIOP_MODE_SELECT10
  1529. UCHAR SPBit : 1;
  1530. UCHAR Reserved1 : 3;
  1531. UCHAR PFBit : 1;
  1532. UCHAR LogicalUnitNumber : 3;
  1533. UCHAR Reserved2[5];
  1534. UCHAR ParameterListLength[2];
  1535. UCHAR Control;
  1536. } MODE_SELECT10, *PMODE_SELECT10;
  1537. struct _LOCATE {
  1538. UCHAR OperationCode; // 0x2B - SCSIOP_LOCATE
  1539. UCHAR Immediate : 1;
  1540. UCHAR CPBit : 1;
  1541. UCHAR BTBit : 1;
  1542. UCHAR Reserved1 : 2;
  1543. UCHAR LogicalUnitNumber : 3;
  1544. UCHAR Reserved3;
  1545. UCHAR LogicalBlockAddress[4];
  1546. UCHAR Reserved4;
  1547. UCHAR Partition;
  1548. UCHAR Control;
  1549. } LOCATE, *PLOCATE;
  1550. struct _LOGSENSE {
  1551. UCHAR OperationCode; // 0x4D - SCSIOP_LOG_SENSE
  1552. UCHAR SPBit : 1;
  1553. UCHAR PPCBit : 1;
  1554. UCHAR Reserved1 : 3;
  1555. UCHAR LogicalUnitNumber : 3;
  1556. UCHAR PageCode : 6;
  1557. UCHAR PCBit : 2;
  1558. UCHAR Reserved2;
  1559. UCHAR Reserved3;
  1560. UCHAR ParameterPointer[2];
  1561. UCHAR AllocationLength[2];
  1562. UCHAR Control;
  1563. } LOGSENSE, *PLOGSENSE;
  1564. struct _LOGSELECT {
  1565. UCHAR OperationCode; // 0x4C - SCSIOP_LOG_SELECT
  1566. UCHAR SPBit : 1;
  1567. UCHAR PCRBit : 1;
  1568. UCHAR Reserved1 : 3;
  1569. UCHAR LogicalUnitNumber : 3;
  1570. UCHAR Reserved : 6;
  1571. UCHAR PCBit : 2;
  1572. UCHAR Reserved2[4];
  1573. UCHAR ParameterListLength[2];
  1574. UCHAR Control;
  1575. } LOGSELECT, *PLOGSELECT;
  1576. struct _PRINT {
  1577. UCHAR OperationCode; // 0x0A - SCSIOP_PRINT
  1578. UCHAR Reserved : 5;
  1579. UCHAR LogicalUnitNumber : 3;
  1580. UCHAR TransferLength[3];
  1581. UCHAR Control;
  1582. } PRINT, *PPRINT;
  1583. struct _SEEK {
  1584. UCHAR OperationCode; // 0x2B - SCSIOP_SEEK
  1585. UCHAR Reserved1 : 5;
  1586. UCHAR LogicalUnitNumber : 3;
  1587. UCHAR LogicalBlockAddress[4];
  1588. UCHAR Reserved2[3];
  1589. UCHAR Control;
  1590. } SEEK, *PSEEK;
  1591. struct _ERASE {
  1592. UCHAR OperationCode; // 0x19 - SCSIOP_ERASE
  1593. UCHAR Long : 1;
  1594. UCHAR Immediate : 1;
  1595. UCHAR Reserved1 : 3;
  1596. UCHAR LogicalUnitNumber : 3;
  1597. UCHAR Reserved2[3];
  1598. UCHAR Control;
  1599. } ERASE, *PERASE;
  1600. struct _START_STOP {
  1601. UCHAR OperationCode; // 0x1B - SCSIOP_START_STOP_UNIT
  1602. UCHAR Immediate: 1;
  1603. UCHAR Reserved1 : 4;
  1604. UCHAR LogicalUnitNumber : 3;
  1605. UCHAR Reserved2[2];
  1606. UCHAR Start : 1;
  1607. UCHAR LoadEject : 1;
  1608. UCHAR Reserved3 : 6;
  1609. UCHAR Control;
  1610. } START_STOP, *PSTART_STOP;
  1611. struct _MEDIA_REMOVAL {
  1612. UCHAR OperationCode; // 0x1E - SCSIOP_MEDIUM_REMOVAL
  1613. UCHAR Reserved1 : 5;
  1614. UCHAR LogicalUnitNumber : 3;
  1615. UCHAR Reserved2[2];
  1616. UCHAR Prevent : 1;
  1617. UCHAR Persistant : 1;
  1618. UCHAR Reserved3 : 6;
  1619. UCHAR Control;
  1620. } MEDIA_REMOVAL, *PMEDIA_REMOVAL;
  1621. //
  1622. // Tape CDBs
  1623. //
  1624. struct _SEEK_BLOCK {
  1625. UCHAR OperationCode; // 0x0C - SCSIOP_SEEK_BLOCK
  1626. UCHAR Immediate : 1;
  1627. UCHAR Reserved1 : 7;
  1628. UCHAR BlockAddress[3];
  1629. UCHAR Link : 1;
  1630. UCHAR Flag : 1;
  1631. UCHAR Reserved2 : 4;
  1632. UCHAR VendorUnique : 2;
  1633. } SEEK_BLOCK, *PSEEK_BLOCK;
  1634. struct _REQUEST_BLOCK_ADDRESS {
  1635. UCHAR OperationCode; // 0x02 - SCSIOP_REQUEST_BLOCK_ADDR
  1636. UCHAR Reserved1[3];
  1637. UCHAR AllocationLength;
  1638. UCHAR Link : 1;
  1639. UCHAR Flag : 1;
  1640. UCHAR Reserved2 : 4;
  1641. UCHAR VendorUnique : 2;
  1642. } REQUEST_BLOCK_ADDRESS, *PREQUEST_BLOCK_ADDRESS;
  1643. struct _PARTITION {
  1644. UCHAR OperationCode; // 0x0D - SCSIOP_PARTITION
  1645. UCHAR Immediate : 1;
  1646. UCHAR Sel: 1;
  1647. UCHAR PartitionSelect : 6;
  1648. UCHAR Reserved1[3];
  1649. UCHAR Control;
  1650. } PARTITION, *PPARTITION;
  1651. struct _WRITE_TAPE_MARKS {
  1652. UCHAR OperationCode; // Unknown -- vendor-unique?
  1653. UCHAR Immediate : 1;
  1654. UCHAR WriteSetMarks: 1;
  1655. UCHAR Reserved : 3;
  1656. UCHAR LogicalUnitNumber : 3;
  1657. UCHAR TransferLength[3];
  1658. UCHAR Control;
  1659. } WRITE_TAPE_MARKS, *PWRITE_TAPE_MARKS;
  1660. struct _SPACE_TAPE_MARKS {
  1661. UCHAR OperationCode; // Unknown -- vendor-unique?
  1662. UCHAR Code : 3;
  1663. UCHAR Reserved : 2;
  1664. UCHAR LogicalUnitNumber : 3;
  1665. UCHAR NumMarksMSB ;
  1666. UCHAR NumMarks;
  1667. UCHAR NumMarksLSB;
  1668. union {
  1669. UCHAR value;
  1670. struct {
  1671. UCHAR Link : 1;
  1672. UCHAR Flag : 1;
  1673. UCHAR Reserved : 4;
  1674. UCHAR VendorUnique : 2;
  1675. } Fields;
  1676. } Byte6;
  1677. } SPACE_TAPE_MARKS, *PSPACE_TAPE_MARKS;
  1678. //
  1679. // Read tape position
  1680. //
  1681. struct _READ_POSITION {
  1682. UCHAR Operation; // 0x43 - SCSIOP_READ_POSITION
  1683. UCHAR BlockType:1;
  1684. UCHAR Reserved1:4;
  1685. UCHAR Lun:3;
  1686. UCHAR Reserved2[7];
  1687. UCHAR Control;
  1688. } READ_POSITION, *PREAD_POSITION;
  1689. //
  1690. // ReadWrite for Tape
  1691. //
  1692. struct _CDB6READWRITETAPE {
  1693. UCHAR OperationCode; // Unknown -- vendor-unique?
  1694. UCHAR VendorSpecific : 5;
  1695. UCHAR Reserved : 3;
  1696. UCHAR TransferLenMSB;
  1697. UCHAR TransferLen;
  1698. UCHAR TransferLenLSB;
  1699. UCHAR Link : 1;
  1700. UCHAR Flag : 1;
  1701. UCHAR Reserved1 : 4;
  1702. UCHAR VendorUnique : 2;
  1703. } CDB6READWRITETAPE, *PCDB6READWRITETAPE;
  1704. //
  1705. // Medium changer CDB's
  1706. //
  1707. struct _INIT_ELEMENT_STATUS {
  1708. UCHAR OperationCode; // 0x07 - SCSIOP_INIT_ELEMENT_STATUS
  1709. UCHAR Reserved1 : 5;
  1710. UCHAR LogicalUnitNubmer : 3;
  1711. UCHAR Reserved2[3];
  1712. UCHAR Reserved3 : 7;
  1713. UCHAR NoBarCode : 1;
  1714. } INIT_ELEMENT_STATUS, *PINIT_ELEMENT_STATUS;
  1715. struct _INITIALIZE_ELEMENT_RANGE {
  1716. UCHAR OperationCode; // 0xE7 - SCSIOP_INIT_ELEMENT_RANGE
  1717. UCHAR Range : 1;
  1718. UCHAR Reserved1 : 4;
  1719. UCHAR LogicalUnitNubmer : 3;
  1720. UCHAR FirstElementAddress[2];
  1721. UCHAR Reserved2[2];
  1722. UCHAR NumberOfElements[2];
  1723. UCHAR Reserved3;
  1724. UCHAR Reserved4 : 7;
  1725. UCHAR NoBarCode : 1;
  1726. } INITIALIZE_ELEMENT_RANGE, *PINITIALIZE_ELEMENT_RANGE;
  1727. struct _POSITION_TO_ELEMENT {
  1728. UCHAR OperationCode; // 0x2B - SCSIOP_POSITION_TO_ELEMENT
  1729. UCHAR Reserved1 : 5;
  1730. UCHAR LogicalUnitNumber : 3;
  1731. UCHAR TransportElementAddress[2];
  1732. UCHAR DestinationElementAddress[2];
  1733. UCHAR Reserved2[2];
  1734. UCHAR Flip : 1;
  1735. UCHAR Reserved3 : 7;
  1736. UCHAR Control;
  1737. } POSITION_TO_ELEMENT, *PPOSITION_TO_ELEMENT;
  1738. struct _MOVE_MEDIUM {
  1739. UCHAR OperationCode; // 0xA5 - SCSIOP_MOVE_MEDIUM
  1740. UCHAR Reserved1 : 5;
  1741. UCHAR LogicalUnitNumber : 3;
  1742. UCHAR TransportElementAddress[2];
  1743. UCHAR SourceElementAddress[2];
  1744. UCHAR DestinationElementAddress[2];
  1745. UCHAR Reserved2[2];
  1746. UCHAR Flip : 1;
  1747. UCHAR Reserved3 : 7;
  1748. UCHAR Control;
  1749. } MOVE_MEDIUM, *PMOVE_MEDIUM;
  1750. struct _EXCHANGE_MEDIUM {
  1751. UCHAR OperationCode; // 0xA6 - SCSIOP_EXCHANGE_MEDIUM
  1752. UCHAR Reserved1 : 5;
  1753. UCHAR LogicalUnitNumber : 3;
  1754. UCHAR TransportElementAddress[2];
  1755. UCHAR SourceElementAddress[2];
  1756. UCHAR Destination1ElementAddress[2];
  1757. UCHAR Destination2ElementAddress[2];
  1758. UCHAR Flip1 : 1;
  1759. UCHAR Flip2 : 1;
  1760. UCHAR Reserved3 : 6;
  1761. UCHAR Control;
  1762. } EXCHANGE_MEDIUM, *PEXCHANGE_MEDIUM;
  1763. struct _READ_ELEMENT_STATUS {
  1764. UCHAR OperationCode; // 0xB8 - SCSIOP_READ_ELEMENT_STATUS
  1765. UCHAR ElementType : 4;
  1766. UCHAR VolTag : 1;
  1767. UCHAR LogicalUnitNumber : 3;
  1768. UCHAR StartingElementAddress[2];
  1769. UCHAR NumberOfElements[2];
  1770. UCHAR Reserved1;
  1771. UCHAR AllocationLength[3];
  1772. UCHAR Reserved2;
  1773. UCHAR Control;
  1774. } READ_ELEMENT_STATUS, *PREAD_ELEMENT_STATUS;
  1775. struct _SEND_VOLUME_TAG {
  1776. UCHAR OperationCode; // 0xB6 - SCSIOP_SEND_VOLUME_TAG
  1777. UCHAR ElementType : 4;
  1778. UCHAR Reserved1 : 1;
  1779. UCHAR LogicalUnitNumber : 3;
  1780. UCHAR StartingElementAddress[2];
  1781. UCHAR Reserved2;
  1782. UCHAR ActionCode : 5;
  1783. UCHAR Reserved3 : 3;
  1784. UCHAR Reserved4[2];
  1785. UCHAR ParameterListLength[2];
  1786. UCHAR Reserved5;
  1787. UCHAR Control;
  1788. } SEND_VOLUME_TAG, *PSEND_VOLUME_TAG;
  1789. struct _REQUEST_VOLUME_ELEMENT_ADDRESS {
  1790. UCHAR OperationCode; // Unknown -- vendor-unique?
  1791. UCHAR ElementType : 4;
  1792. UCHAR VolTag : 1;
  1793. UCHAR LogicalUnitNumber : 3;
  1794. UCHAR StartingElementAddress[2];
  1795. UCHAR NumberElements[2];
  1796. UCHAR Reserved1;
  1797. UCHAR AllocationLength[3];
  1798. UCHAR Reserved2;
  1799. UCHAR Control;
  1800. } REQUEST_VOLUME_ELEMENT_ADDRESS, *PREQUEST_VOLUME_ELEMENT_ADDRESS;
  1801. //
  1802. // Atapi 2.5 Changer 12-byte CDBs
  1803. //
  1804. struct _LOAD_UNLOAD {
  1805. UCHAR OperationCode; // 0xA6 - SCSIOP_LOAD_UNLOAD_SLOT
  1806. UCHAR Immediate : 1;
  1807. UCHAR Reserved1 : 4;
  1808. UCHAR Lun : 3;
  1809. UCHAR Reserved2[2];
  1810. UCHAR Start : 1;
  1811. UCHAR LoadEject : 1;
  1812. UCHAR Reserved3: 6;
  1813. UCHAR Reserved4[3];
  1814. UCHAR Slot;
  1815. UCHAR Reserved5[3];
  1816. } LOAD_UNLOAD, *PLOAD_UNLOAD;
  1817. struct _MECH_STATUS {
  1818. UCHAR OperationCode; // 0xBD - SCSIOP_MECHANISM_STATUS
  1819. UCHAR Reserved : 5;
  1820. UCHAR Lun : 3;
  1821. UCHAR Reserved1[6];
  1822. UCHAR AllocationLength[2];
  1823. UCHAR Reserved2[1];
  1824. UCHAR Control;
  1825. } MECH_STATUS, *PMECH_STATUS;
  1826. //
  1827. // C/DVD 0.9 CDBs
  1828. //
  1829. struct _SYNCHRONIZE_CACHE10 {
  1830. UCHAR OperationCode; // 0x35 - SCSIOP_SYNCHRONIZE_CACHE
  1831. UCHAR RelAddr : 1;
  1832. UCHAR Immediate : 1;
  1833. UCHAR Reserved : 3;
  1834. UCHAR Lun : 3;
  1835. UCHAR LogicalBlockAddress[4]; // Unused - set to zero
  1836. UCHAR Reserved2;
  1837. UCHAR BlockCount[2]; // Unused - set to zero
  1838. UCHAR Control;
  1839. } SYNCHRONIZE_CACHE10, *PSYNCHRONIZE_CACHE10;
  1840. struct _GET_EVENT_STATUS_NOTIFICATION {
  1841. UCHAR OperationCode; // 0x4A - SCSIOP_GET_EVENT_STATUS_NOTIFICATION
  1842. UCHAR Immediate : 1;
  1843. UCHAR Reserved : 4;
  1844. UCHAR Lun : 3;
  1845. UCHAR Reserved2[2];
  1846. UCHAR NotificationClassRequest;
  1847. UCHAR Reserved3[2];
  1848. UCHAR EventListLength[2];
  1849. UCHAR Control;
  1850. } GET_EVENT_STATUS_NOTIFICATION, *PGET_EVENT_STATUS_NOTIFICATION;
  1851. struct _READ_DVD_STRUCTURE {
  1852. UCHAR OperationCode; // 0xAD - SCSIOP_READ_DVD_STRUCTURE
  1853. UCHAR Reserved1 : 5;
  1854. UCHAR Lun : 3;
  1855. UCHAR RMDBlockNumber[4];
  1856. UCHAR LayerNumber;
  1857. UCHAR Format;
  1858. UCHAR AllocationLength[2];
  1859. UCHAR Reserved3 : 6;
  1860. UCHAR AGID : 2;
  1861. UCHAR Control;
  1862. } READ_DVD_STRUCTURE, *PREAD_DVD_STRUCTURE;
  1863. struct _SEND_DVD_STRUCTURE {
  1864. UCHAR OperationCode; // 0xBF - SCSIOP_SEND_DVD_STRUCTURE
  1865. UCHAR Reserved1 : 5;
  1866. UCHAR Lun : 3;
  1867. UCHAR Reserved2[5];
  1868. UCHAR Format;
  1869. UCHAR ParameterListLength[2];
  1870. UCHAR Reserved3;
  1871. UCHAR Control;
  1872. } SEND_DVD_STRUCTURE, *PSEND_DVD_STRUCTURE;
  1873. struct _SEND_KEY {
  1874. UCHAR OperationCode; // 0xA3 - SCSIOP_SEND_KEY
  1875. UCHAR Reserved1 : 5;
  1876. UCHAR Lun : 3;
  1877. UCHAR Reserved2[6];
  1878. UCHAR ParameterListLength[2];
  1879. UCHAR KeyFormat : 6;
  1880. UCHAR AGID : 2;
  1881. UCHAR Control;
  1882. } SEND_KEY, *PSEND_KEY;
  1883. struct _REPORT_KEY {
  1884. UCHAR OperationCode; // 0xA4 - SCSIOP_REPORT_KEY
  1885. UCHAR Reserved1 : 5;
  1886. UCHAR Lun : 3;
  1887. UCHAR LogicalBlockAddress[4]; // for title key
  1888. UCHAR Reserved2[2];
  1889. UCHAR AllocationLength[2];
  1890. UCHAR KeyFormat : 6;
  1891. UCHAR AGID : 2;
  1892. UCHAR Control;
  1893. } REPORT_KEY, *PREPORT_KEY;
  1894. struct _SET_READ_AHEAD {
  1895. UCHAR OperationCode; // 0xA7 - SCSIOP_SET_READ_AHEAD
  1896. UCHAR Reserved1 : 5;
  1897. UCHAR Lun : 3;
  1898. UCHAR TriggerLBA[4];
  1899. UCHAR ReadAheadLBA[4];
  1900. UCHAR Reserved2;
  1901. UCHAR Control;
  1902. } SET_READ_AHEAD, *PSET_READ_AHEAD;
  1903. struct _READ_FORMATTED_CAPACITIES {
  1904. UCHAR OperationCode; // 0x23 - SCSIOP_READ_FORMATTED_CAPACITY
  1905. UCHAR Reserved1 : 5;
  1906. UCHAR Lun : 3;
  1907. UCHAR Reserved2[5];
  1908. UCHAR AllocationLength[2];
  1909. UCHAR Control;
  1910. } READ_FORMATTED_CAPACITIES, *PREAD_FORMATTED_CAPACITIES;
  1911. //
  1912. // SCSI-3
  1913. //
  1914. struct _REPORT_LUNS {
  1915. UCHAR OperationCode; // 0xA0 - SCSIOP_REPORT_LUNS
  1916. UCHAR Reserved1[5];
  1917. UCHAR AllocationLength[4];
  1918. UCHAR Reserved2[1];
  1919. UCHAR Control;
  1920. } REPORT_LUNS, *PREPORT_LUNS;
  1921. struct _PERSISTENT_RESERVE_IN {
  1922. UCHAR OperationCode; // 0x5E - SCSIOP_PERSISTENT_RESERVE_IN
  1923. UCHAR ServiceAction : 5;
  1924. UCHAR Reserved1 : 3;
  1925. UCHAR Reserved2[5];
  1926. UCHAR AllocationLength[2];
  1927. UCHAR Control;
  1928. } PERSISTENT_RESERVE_IN, *PPERSISTENT_RESERVE_IN;
  1929. struct _PERSISTENT_RESERVE_OUT {
  1930. UCHAR OperationCode; // 0x5F - SCSIOP_PERSISTENT_RESERVE_OUT
  1931. UCHAR ServiceAction : 5;
  1932. UCHAR Reserved1 : 3;
  1933. UCHAR Type : 4;
  1934. UCHAR Scope : 4;
  1935. UCHAR Reserved2[4];
  1936. UCHAR ParameterListLength[2]; // 0x18
  1937. UCHAR Control;
  1938. } PERSISTENT_RESERVE_OUT, *PPERSISTENT_RESERVE_OUT;
  1939. //
  1940. // MMC / SFF-8090 commands
  1941. //
  1942. struct _GET_CONFIGURATION {
  1943. UCHAR OperationCode; // 0x46 - SCSIOP_GET_CONFIGURATION
  1944. UCHAR RequestType : 1; // SCSI_GET_CONFIGURATION_REQUEST_TYPE_*
  1945. UCHAR Reserved1 : 7; // includes obsolete LUN field
  1946. UCHAR StartingFeature[2];
  1947. UCHAR Reserved2[3];
  1948. UCHAR AllocationLength[2];
  1949. UCHAR Control;
  1950. } GET_CONFIGURATION, *PGET_CONFIGURATION;
  1951. struct _SET_CD_SPEED {
  1952. UCHAR OperationCode; // 0xB8 - SCSIOP_SET_CD_SPEED
  1953. UCHAR Reserved1;
  1954. UCHAR ReadSpeed[2]; // 1x == (75 * 2352)
  1955. UCHAR WriteSpeed[2]; // 1x == (75 * 2352)
  1956. UCHAR Reserved2[5];
  1957. UCHAR Control;
  1958. } SET_CD_SPEED, *PSET_CD_SPEED;
  1959. ULONG AsUlong[4];
  1960. UCHAR AsByte[16];
  1961. } CDB, *PCDB;
  1962. ////////////////////////////////////////////////////////////////////////////////
  1963. //
  1964. // GET_EVENT_STATUS_NOTIFICATION
  1965. //
  1966. #define NOTIFICATION_OPERATIONAL_CHANGE_CLASS_MASK 0x02
  1967. #define NOTIFICATION_POWER_MANAGEMENT_CLASS_MASK 0x04
  1968. #define NOTIFICATION_EXTERNAL_REQUEST_CLASS_MASK 0x08
  1969. #define NOTIFICATION_MEDIA_STATUS_CLASS_MASK 0x10
  1970. #define NOTIFICATION_MULTI_HOST_CLASS_MASK 0x20
  1971. #define NOTIFICATION_DEVICE_BUSY_CLASS_MASK 0x40
  1972. #define NOTIFICATION_NO_CLASS_EVENTS 0x0
  1973. #define NOTIFICATION_OPERATIONAL_CHANGE_CLASS_EVENTS 0x1
  1974. #define NOTIFICATION_POWER_MANAGEMENT_CLASS_EVENTS 0x2
  1975. #define NOTIFICATION_EXTERNAL_REQUEST_CLASS_EVENTS 0x3
  1976. #define NOTIFICATION_MEDIA_STATUS_CLASS_EVENTS 0x4
  1977. #define NOTIFICATION_MULTI_HOST_CLASS_EVENTS 0x5
  1978. #define NOTIFICATION_DEVICE_BUSY_CLASS_EVENTS 0x6
  1979. typedef struct _NOTIFICATION_EVENT_STATUS_HEADER {
  1980. UCHAR EventDataLength[2];
  1981. UCHAR NotificationClass : 3;
  1982. UCHAR Reserved : 4;
  1983. UCHAR NEA : 1;
  1984. UCHAR SupportedEventClasses;
  1985. UCHAR ClassEventData[0];
  1986. } NOTIFICATION_EVENT_STATUS_HEADER, *PNOTIFICATION_EVENT_STATUS_HEADER;
  1987. #define NOTIFICATION_OPERATIONAL_EVENT_NO_CHANGE 0x0
  1988. #define NOTIFICATION_OPERATIONAL_EVENT_CHANGE_REQUESTED 0x1
  1989. #define NOTIFICATION_OPERATIONAL_EVENT_CHANGE_OCCURRED 0x2
  1990. #define NOTIFICATION_OPERATIONAL_STATUS_AVAILABLE 0x0
  1991. #define NOTIFICATION_OPERATIONAL_STATUS_TEMPORARY_BUSY 0x1
  1992. #define NOTIFICATION_OPERATIONAL_STATUS_EXTENDED_BUSY 0x2
  1993. #define NOTIFICATION_OPERATIONAL_OPCODE_NONE
  1994. #define NOTIFICATION_OPERATIONAL_OPCODE_FEATURE_CHANGE 0x1
  1995. #define NOTIFICATION_OPERATIONAL_OPCODE_FEATURE_ADDED 0x2
  1996. #define NOTIFICATION_OPERATIONAL_OPCODE_UNIT_RESET 0x3
  1997. #define NOTIFICATION_OPERATIONAL_OPCODE_FIRMWARE_CHANGED 0x4
  1998. #define NOTIFICATION_OPERATIONAL_OPCODE_INQUIRY_CHANGED 0x5
  1999. //
  2000. // Class event data may be one (or none) of the following:
  2001. //
  2002. typedef struct _NOTIFICATION_OPERATIONAL_STATUS { // event class == 0x1
  2003. UCHAR OperationalEvent : 4;
  2004. UCHAR Reserved1 : 4;
  2005. UCHAR OperationalStatus : 4;
  2006. UCHAR Reserved2 : 3;
  2007. UCHAR PersistentPrevented : 1;
  2008. UCHAR Operation[2];
  2009. } NOTIFICATION_OPERATIONAL_STATUS, *PNOTIFICATION_OPERATIONAL_STATUS;
  2010. #define NOTIFICATION_POWER_EVENT_NO_CHANGE 0x0
  2011. #define NOTIFICATION_POWER_EVENT_CHANGE_SUCCEEDED 0x1
  2012. #define NOTIFICATION_POWER_EVENT_CHANGE_FAILED 0x2
  2013. #define NOTIFICATION_POWER_STATUS_ACTIVE 0x1
  2014. #define NOTIFICATION_POWER_STATUS_IDLE 0x2
  2015. #define NOTIFICATION_POWER_STATUS_STANDBY 0x3
  2016. #define NOTIFICATION_POWER_STATUS_SLEEP 0x4
  2017. typedef struct _NOTIFICATION_POWER_STATUS { // event class == 0x2
  2018. UCHAR PowerEvent : 4;
  2019. UCHAR Reserved : 4;
  2020. UCHAR PowerStatus;
  2021. UCHAR Reserved2[2];
  2022. } NOTIFICATION_POWER_STATUS, *PNOTIFICATION_POWER_STATUS;
  2023. #define NOTIFICATION_EXTERNAL_EVENT_NO_CHANGE 0x0
  2024. #define NOTIFICATION_EXTERNAL_EVENT_BUTTON_DOWN 0x1
  2025. #define NOTIFICATION_EXTERNAL_EVENT_BUTTON_UP 0x2
  2026. #define NOTIFICATION_EXTERNAL_EVENT_EXTERNAL 0x3 // respond with GET_CONFIGURATION?
  2027. #define NOTIFICATION_EXTERNAL_STATUS_READY 0x0
  2028. #define NOTIFICATION_EXTERNAL_STATUS_PREVENT 0x1
  2029. #define NOTIFICATION_EXTERNAL_REQUEST_NONE 0x0000
  2030. #define NOTIFICATION_EXTERNAL_REQUEST_QUEUE_OVERRUN 0x0001
  2031. #define NOTIFICATION_EXTERNAL_REQUEST_PLAY 0x0101
  2032. #define NOTIFICATION_EXTERNAL_REQUEST_REWIND_BACK 0x0102
  2033. #define NOTIFICATION_EXTERNAL_REQUEST_FAST_FORWARD 0x0103
  2034. #define NOTIFICATION_EXTERNAL_REQUEST_PAUSE 0x0104
  2035. #define NOTIFICATION_EXTERNAL_REQUEST_STOP 0x0106
  2036. #define NOTIFICATION_EXTERNAL_REQUEST_ASCII_LOW 0x0200
  2037. #define NOTIFICATION_EXTERNAL_REQUEST_ASCII_HIGH 0x02ff
  2038. typedef struct _NOTIFICATION_EXTERNAL_STATUS { // event class == 0x3
  2039. UCHAR ExternalEvent : 4;
  2040. UCHAR Reserved1 : 4;
  2041. UCHAR ExternalStatus : 4;
  2042. UCHAR Reserved2 : 3;
  2043. UCHAR PersistentPrevented : 1;
  2044. UCHAR Request[2];
  2045. } NOTIFICATION_EXTERNAL_STATUS, *PNOTIFICATION_EXTERNAL_STATUS;
  2046. #define NOTIFICATION_MEDIA_EVENT_NO_CHANGE 0x0
  2047. #define NOTIFICATION_MEDIA_EVENT_EJECT_REQUEST 0x1
  2048. #define NOTIFICATION_MEDIA_EVENT_NEW_MEDIA 0x2
  2049. #define NOTIFICATION_MEDIA_EVENT_MEDIA_REMOVAL 0x3
  2050. #define NOTIFICATION_MEDIA_EVENT_MEDIA_CHANGE 0x4
  2051. typedef struct _NOTIFICATION_MEDIA_STATUS { // event class == 0x4
  2052. UCHAR MediaEvent : 4;
  2053. UCHAR Reserved : 4;
  2054. union {
  2055. UCHAR PowerStatus; // OBSOLETE -- was improperly named in NT5 headers
  2056. UCHAR MediaStatus; // Use this for currently reserved fields
  2057. struct {
  2058. UCHAR DoorTrayOpen : 1;
  2059. UCHAR MediaPresent : 1;
  2060. UCHAR ReservedX : 6; // do not reference this directly!
  2061. };
  2062. };
  2063. UCHAR StartSlot;
  2064. UCHAR EndSlot;
  2065. } NOTIFICATION_MEDIA_STATUS, *PNOTIFICATION_MEDIA_STATUS;
  2066. #define NOTIFICATION_MULTI_HOST_EVENT_NO_CHANGE 0x0
  2067. #define NOTIFICATION_MULTI_HOST_EVENT_CONTROL_REQUEST 0x1
  2068. #define NOTIFICATION_MULTI_HOST_EVENT_CONTROL_GRANT 0x2
  2069. #define NOTIFICATION_MULTI_HOST_EVENT_CONTROL_RELEASE 0x3
  2070. #define NOTIFICATION_MULTI_HOST_STATUS_READY 0x0
  2071. #define NOTIFICATION_MULTI_HOST_STATUS_PREVENT 0x1
  2072. #define NOTIFICATION_MULTI_HOST_PRIORITY_NO_REQUESTS 0x0
  2073. #define NOTIFICATION_MULTI_HOST_PRIORITY_LOW 0x1
  2074. #define NOTIFICATION_MULTI_HOST_PRIORITY_MEDIUM 0x2
  2075. #define NOTIFICATION_MULTI_HOST_PRIORITY_HIGH 0x3
  2076. typedef struct _NOTIFICATION_MULTI_HOST_STATUS { // event class == 0x5
  2077. UCHAR MultiHostEvent : 4;
  2078. UCHAR Reserved1 : 4;
  2079. UCHAR MultiHostStatus : 4;
  2080. UCHAR Reserved2 : 3;
  2081. UCHAR PersistentPrevented : 1;
  2082. UCHAR Priority[2];
  2083. } NOTIFICATION_MULTI_HOST_STATUS, *PNOTIFICATION_MULTI_HOST_STATUS;
  2084. #define NOTIFICATION_BUSY_EVENT_NO_CHANGE 0x0
  2085. #define NOTIFICATION_BUSY_EVENT_BUSY 0x1
  2086. #define NOTIFICATION_BUSY_STATUS_NO_EVENT 0x0
  2087. #define NOTIFICATION_BUSY_STATUS_POWER 0x1
  2088. #define NOTIFICATION_BUSY_STATUS_IMMEDIATE 0x2
  2089. #define NOTIFICATION_BUSY_STATUS_DEFERRED 0x3
  2090. typedef struct _NOTIFICATION_BUSY_STATUS { // event class == 0x6
  2091. UCHAR DeviceBusyEvent : 4;
  2092. UCHAR Reserved : 4;
  2093. UCHAR DeviceBusyStatus;
  2094. UCHAR Time[2];
  2095. } NOTIFICATION_BUSY_STATUS, *PNOTIFICATION_BUSY_STATUS;
  2096. ////////////////////////////////////////////////////////////////////////////////
  2097. //
  2098. // Read DVD Structure Definitions and Constants
  2099. //
  2100. #define DVD_FORMAT_LEAD_IN 0x00
  2101. #define DVD_FORMAT_COPYRIGHT 0x01
  2102. #define DVD_FORMAT_DISK_KEY 0x02
  2103. #define DVD_FORMAT_BCA 0x03
  2104. #define DVD_FORMAT_MANUFACTURING 0x04
  2105. typedef struct _READ_DVD_STRUCTURES_HEADER {
  2106. UCHAR Length[2];
  2107. UCHAR Reserved[2];
  2108. UCHAR Data[0];
  2109. } READ_DVD_STRUCTURES_HEADER, *PREAD_DVD_STRUCTURES_HEADER;
  2110. //
  2111. // DiskKey, BCA & Manufacturer information will provide byte arrays as their
  2112. // data.
  2113. //
  2114. //
  2115. // CDVD 0.9 Send & Report Key Definitions and Structures
  2116. //
  2117. #define DVD_REPORT_AGID 0x00
  2118. #define DVD_CHALLENGE_KEY 0x01
  2119. #define DVD_KEY_1 0x02
  2120. #define DVD_KEY_2 0x03
  2121. #define DVD_TITLE_KEY 0x04
  2122. #define DVD_REPORT_ASF 0x05
  2123. #define DVD_INVALIDATE_AGID 0x3F
  2124. typedef struct _CDVD_KEY_HEADER {
  2125. UCHAR DataLength[2];
  2126. UCHAR Reserved[2];
  2127. UCHAR Data[0];
  2128. } CDVD_KEY_HEADER, *PCDVD_KEY_HEADER;
  2129. typedef struct _CDVD_REPORT_AGID_DATA {
  2130. UCHAR Reserved1[3];
  2131. UCHAR Reserved2 : 6;
  2132. UCHAR AGID : 2;
  2133. } CDVD_REPORT_AGID_DATA, *PCDVD_REPORT_AGID_DATA;
  2134. typedef struct _CDVD_CHALLENGE_KEY_DATA {
  2135. UCHAR ChallengeKeyValue[10];
  2136. UCHAR Reserved[2];
  2137. } CDVD_CHALLENGE_KEY_DATA, *PCDVD_CHALLENGE_KEY_DATA;
  2138. typedef struct _CDVD_KEY_DATA {
  2139. UCHAR Key[5];
  2140. UCHAR Reserved[3];
  2141. } CDVD_KEY_DATA, *PCDVD_KEY_DATA;
  2142. typedef struct _CDVD_REPORT_ASF_DATA {
  2143. UCHAR Reserved1[3];
  2144. UCHAR Success : 1;
  2145. UCHAR Reserved2 : 7;
  2146. } CDVD_REPORT_ASF_DATA, *PCDVD_REPORT_ASF_DATA;
  2147. typedef struct _CDVD_TITLE_KEY_HEADER {
  2148. UCHAR DataLength[2];
  2149. UCHAR Reserved1[1];
  2150. UCHAR Reserved2 : 3;
  2151. UCHAR CGMS : 2;
  2152. UCHAR CP_SEC : 1;
  2153. UCHAR CPM : 1;
  2154. UCHAR Zero : 1;
  2155. CDVD_KEY_DATA TitleKey;
  2156. } CDVD_TITLE_KEY_HEADER, *PCDVD_TITLE_KEY_HEADER;
  2157. //
  2158. // Read Formatted Capacity Data - returned in Big Endian Format
  2159. //
  2160. typedef struct _FORMATTED_CAPACITY_DESCRIPTOR {
  2161. UCHAR NumberOfBlocks[4];
  2162. UCHAR Maximum : 1;
  2163. UCHAR Valid : 1;
  2164. UCHAR BlockLength[3];
  2165. } FORMATTED_CAPACITY_DESCRIPTOR, *PFORMATTED_CAPACITY_DESCRIPTOR;
  2166. typedef struct _FORMATTED_CAPACITY_LIST {
  2167. UCHAR Reserved[3];
  2168. UCHAR CapacityListLength;
  2169. FORMATTED_CAPACITY_DESCRIPTOR Descriptors[0];
  2170. } FORMATTED_CAPACITY_LIST, *PFORMATTED_CAPACITY_LIST;
  2171. //
  2172. // PLAY_CD definitions and constants
  2173. //
  2174. #define CD_EXPECTED_SECTOR_ANY 0x0
  2175. #define CD_EXPECTED_SECTOR_CDDA 0x1
  2176. #define CD_EXPECTED_SECTOR_MODE1 0x2
  2177. #define CD_EXPECTED_SECTOR_MODE2 0x3
  2178. #define CD_EXPECTED_SECTOR_MODE2_FORM1 0x4
  2179. #define CD_EXPECTED_SECTOR_MODE2_FORM2 0x5
  2180. //
  2181. // Read Disk Information Definitions and Capabilities
  2182. //
  2183. #define DISK_STATUS_EMPTY 0x00
  2184. #define DISK_STATUS_INCOMPLETE 0x01
  2185. #define DISK_STATUS_COMPLETE 0x02
  2186. #define LAST_SESSION_EMPTY 0x00
  2187. #define LAST_SESSION_INCOMPLETE 0x01
  2188. #define LAST_SESSION_COMPLETE 0x03
  2189. #define DISK_TYPE_CDDA 0x01
  2190. #define DISK_TYPE_CDI 0x10
  2191. #define DISK_TYPE_XA 0x20
  2192. #define DISK_TYPE_UNDEFINED 0xFF
  2193. typedef struct _OPC_TABLE_ENTRY {
  2194. UCHAR Speed[2];
  2195. UCHAR OPCValue[6];
  2196. } OPC_TABLE_ENTRY, *POPC_TABLE_ENTRY;
  2197. typedef struct _DISK_INFORMATION {
  2198. UCHAR Length[2];
  2199. UCHAR DiskStatus : 2;
  2200. UCHAR LastSessionStatus : 2;
  2201. UCHAR Erasable : 1;
  2202. UCHAR Reserved1 : 3;
  2203. UCHAR FirstTrackNumber;
  2204. UCHAR NumberOfSessions;
  2205. UCHAR LastSessionFirstTrack;
  2206. UCHAR LastSessionLastTrack;
  2207. UCHAR Reserved2 : 5;
  2208. UCHAR GEN : 1;
  2209. UCHAR DBC_V : 1;
  2210. UCHAR DID_V : 1;
  2211. UCHAR DiskType;
  2212. UCHAR Reserved3[3];
  2213. UCHAR DiskIdentification[4];
  2214. UCHAR LastSessionLeadIn[4]; // MSF
  2215. UCHAR LastPossibleStartTime[4]; // MSF
  2216. UCHAR DiskBarCode[8];
  2217. UCHAR Reserved4;
  2218. UCHAR NumberOPCEntries;
  2219. OPC_TABLE_ENTRY OPCTable[0];
  2220. } DISK_INFORMATION, *PDISK_INFORMATION;
  2221. //
  2222. // Read Header definitions and structures
  2223. //
  2224. typedef struct _DATA_BLOCK_HEADER {
  2225. UCHAR DataMode;
  2226. UCHAR Reserved[4];
  2227. union {
  2228. UCHAR LogicalBlockAddress[4];
  2229. struct {
  2230. UCHAR Reserved;
  2231. UCHAR M;
  2232. UCHAR S;
  2233. UCHAR F;
  2234. } MSF;
  2235. };
  2236. } DATA_BLOCK_HEADER, *PDATA_BLOCK_HEADER;
  2237. #define DATA_BLOCK_MODE0 0x0
  2238. #define DATA_BLOCK_MODE1 0x1
  2239. #define DATA_BLOCK_MODE2 0x2
  2240. //
  2241. // Read TOC Format Codes
  2242. //
  2243. #define READ_TOC_FORMAT_TOC 0x00
  2244. #define READ_TOC_FORMAT_SESSION 0x01
  2245. #define READ_TOC_FORMAT_FULL_TOC 0x02
  2246. #define READ_TOC_FORMAT_PMA 0x03
  2247. #define READ_TOC_FORMAT_ATIP 0x04
  2248. typedef struct _TRACK_INFORMATION {
  2249. UCHAR Length[2];
  2250. UCHAR TrackNumber;
  2251. UCHAR SessionNumber;
  2252. UCHAR Reserved1;
  2253. UCHAR TrackMode : 4;
  2254. UCHAR Copy : 1;
  2255. UCHAR Damage : 1;
  2256. UCHAR Reserved2 : 2;
  2257. UCHAR DataMode : 4;
  2258. UCHAR FP : 1;
  2259. UCHAR Packet : 1;
  2260. UCHAR Blank : 1;
  2261. UCHAR RT : 1;
  2262. UCHAR NWA_V : 1;
  2263. UCHAR Reserved3 : 7;
  2264. UCHAR TrackStartAddress[4];
  2265. UCHAR NextWritableAddress[4];
  2266. UCHAR FreeBlocks[4];
  2267. UCHAR FixedPacketSize[4];
  2268. } TRACK_INFORMATION, *PTRACK_INFORMATION;
  2269. //
  2270. // Command Descriptor Block constants.
  2271. //
  2272. #define CDB6GENERIC_LENGTH 6
  2273. #define CDB10GENERIC_LENGTH 10
  2274. #define CDB12GENERIC_LENGTH 12
  2275. #define SETBITON 1
  2276. #define SETBITOFF 0
  2277. //
  2278. // Mode Sense/Select page constants.
  2279. //
  2280. #define MODE_PAGE_ERROR_RECOVERY 0x01
  2281. #define MODE_PAGE_DISCONNECT 0x02
  2282. #define MODE_PAGE_FORMAT_DEVICE 0x03
  2283. #define MODE_PAGE_RIGID_GEOMETRY 0x04
  2284. #define MODE_PAGE_FLEXIBILE 0x05 // disk
  2285. #define MODE_PAGE_WRITE_PARAMETERS 0x05 // cdrom
  2286. #define MODE_PAGE_VERIFY_ERROR 0x07
  2287. #define MODE_PAGE_CACHING 0x08
  2288. #define MODE_PAGE_PERIPHERAL 0x09
  2289. #define MODE_PAGE_CONTROL 0x0A
  2290. #define MODE_PAGE_MEDIUM_TYPES 0x0B
  2291. #define MODE_PAGE_NOTCH_PARTITION 0x0C
  2292. #define MODE_PAGE_CD_AUDIO_CONTROL 0x0E
  2293. #define MODE_PAGE_DATA_COMPRESS 0x0F
  2294. #define MODE_PAGE_DEVICE_CONFIG 0x10
  2295. #define MODE_PAGE_MEDIUM_PARTITION 0x11
  2296. #define MODE_PAGE_CDVD_FEATURE_SET 0x18
  2297. #define MODE_PAGE_POWER_CONDITION 0x1A
  2298. #define MODE_PAGE_FAULT_REPORTING 0x1C
  2299. #define MODE_PAGE_CDVD_INACTIVITY 0x1D // cdrom
  2300. #define MODE_PAGE_ELEMENT_ADDRESS 0x1D
  2301. #define MODE_PAGE_TRANSPORT_GEOMETRY 0x1E
  2302. #define MODE_PAGE_DEVICE_CAPABILITIES 0x1F
  2303. #define MODE_PAGE_CAPABILITIES 0x2A // cdrom
  2304. #define MODE_SENSE_RETURN_ALL 0x3f
  2305. #define MODE_SENSE_CURRENT_VALUES 0x00
  2306. #define MODE_SENSE_CHANGEABLE_VALUES 0x40
  2307. #define MODE_SENSE_DEFAULT_VAULES 0x80
  2308. #define MODE_SENSE_SAVED_VALUES 0xc0
  2309. //
  2310. // SCSI CDB operation codes
  2311. //
  2312. // 6-byte commands:
  2313. #define SCSIOP_TEST_UNIT_READY 0x00
  2314. #define SCSIOP_REZERO_UNIT 0x01
  2315. #define SCSIOP_REWIND 0x01
  2316. #define SCSIOP_REQUEST_BLOCK_ADDR 0x02
  2317. #define SCSIOP_REQUEST_SENSE 0x03
  2318. #define SCSIOP_FORMAT_UNIT 0x04
  2319. #define SCSIOP_READ_BLOCK_LIMITS 0x05
  2320. #define SCSIOP_REASSIGN_BLOCKS 0x07
  2321. #define SCSIOP_INIT_ELEMENT_STATUS 0x07
  2322. #define SCSIOP_READ6 0x08
  2323. #define SCSIOP_RECEIVE 0x08
  2324. #define SCSIOP_WRITE6 0x0A
  2325. #define SCSIOP_PRINT 0x0A
  2326. #define SCSIOP_SEND 0x0A
  2327. #define SCSIOP_SEEK6 0x0B
  2328. #define SCSIOP_TRACK_SELECT 0x0B
  2329. #define SCSIOP_SLEW_PRINT 0x0B
  2330. #define SCSIOP_SEEK_BLOCK 0x0C
  2331. #define SCSIOP_PARTITION 0x0D
  2332. #define SCSIOP_READ_REVERSE 0x0F
  2333. #define SCSIOP_WRITE_FILEMARKS 0x10
  2334. #define SCSIOP_FLUSH_BUFFER 0x10
  2335. #define SCSIOP_SPACE 0x11
  2336. #define SCSIOP_INQUIRY 0x12
  2337. #define SCSIOP_VERIFY6 0x13
  2338. #define SCSIOP_RECOVER_BUF_DATA 0x14
  2339. #define SCSIOP_MODE_SELECT 0x15
  2340. #define SCSIOP_RESERVE_UNIT 0x16
  2341. #define SCSIOP_RELEASE_UNIT 0x17
  2342. #define SCSIOP_COPY 0x18
  2343. #define SCSIOP_ERASE 0x19
  2344. #define SCSIOP_MODE_SENSE 0x1A
  2345. #define SCSIOP_START_STOP_UNIT 0x1B
  2346. #define SCSIOP_STOP_PRINT 0x1B
  2347. #define SCSIOP_LOAD_UNLOAD 0x1B
  2348. #define SCSIOP_RECEIVE_DIAGNOSTIC 0x1C
  2349. #define SCSIOP_SEND_DIAGNOSTIC 0x1D
  2350. #define SCSIOP_MEDIUM_REMOVAL 0x1E
  2351. // 10-byte commands
  2352. #define SCSIOP_READ_FORMATTED_CAPACITY 0x23
  2353. #define SCSIOP_READ_CAPACITY 0x25
  2354. #define SCSIOP_READ 0x28
  2355. #define SCSIOP_WRITE 0x2A
  2356. #define SCSIOP_SEEK 0x2B
  2357. #define SCSIOP_LOCATE 0x2B
  2358. #define SCSIOP_POSITION_TO_ELEMENT 0x2B
  2359. #define SCSIOP_WRITE_VERIFY 0x2E
  2360. #define SCSIOP_VERIFY 0x2F
  2361. #define SCSIOP_SEARCH_DATA_HIGH 0x30
  2362. #define SCSIOP_SEARCH_DATA_EQUAL 0x31
  2363. #define SCSIOP_SEARCH_DATA_LOW 0x32
  2364. #define SCSIOP_SET_LIMITS 0x33
  2365. #define SCSIOP_READ_POSITION 0x34
  2366. #define SCSIOP_SYNCHRONIZE_CACHE 0x35
  2367. #define SCSIOP_COMPARE 0x39
  2368. #define SCSIOP_COPY_COMPARE 0x3A
  2369. #define SCSIOP_WRITE_DATA_BUFF 0x3B
  2370. #define SCSIOP_READ_DATA_BUFF 0x3C
  2371. #define SCSIOP_CHANGE_DEFINITION 0x40
  2372. #define SCSIOP_READ_SUB_CHANNEL 0x42
  2373. #define SCSIOP_READ_TOC 0x43
  2374. #define SCSIOP_READ_HEADER 0x44
  2375. #define SCSIOP_PLAY_AUDIO 0x45
  2376. #define SCSIOP_GET_CONFIGURATION 0x46
  2377. #define SCSIOP_PLAY_AUDIO_MSF 0x47
  2378. #define SCSIOP_PLAY_TRACK_INDEX 0x48
  2379. #define SCSIOP_PLAY_TRACK_RELATIVE 0x49
  2380. #define SCSIOP_GET_EVENT_STATUS 0x4A
  2381. #define SCSIOP_PAUSE_RESUME 0x4B
  2382. #define SCSIOP_LOG_SELECT 0x4C
  2383. #define SCSIOP_LOG_SENSE 0x4D
  2384. #define SCSIOP_STOP_PLAY_SCAN 0x4E
  2385. #define SCSIOP_READ_DISK_INFORMATION 0x51
  2386. #define SCSIOP_READ_TRACK_INFORMATION 0x52
  2387. #define SCSIOP_RESERVE_TRACK_RZONE 0x53
  2388. #define SCSIOP_SEND_OPC_INFORMATION 0x54 // optimum power calibration
  2389. #define SCSIOP_MODE_SELECT10 0x55
  2390. #define SCSIOP_MODE_SENSE10 0x5A
  2391. #define SCSIOP_CLOSE_TRACK_SESSION 0x5B
  2392. #define SCSIOP_READ_BUFFER_CAPACITY 0x5C
  2393. #define SCSIOP_SEND_CUE_SHEET 0x5D
  2394. #define SCSIOP_PERSISTENT_RESERVE_IN 0x5E
  2395. #define SCSIOP_PERSISTENT_RESERVE_OUT 0x5F
  2396. // 12-byte commands
  2397. #define SCSIOP_REPORT_LUNS 0xA0
  2398. #define SCSIOP_BLANK 0xA1
  2399. #define SCSIOP_SEND_KEY 0xA3
  2400. #define SCSIOP_REPORT_KEY 0xA4
  2401. #define SCSIOP_MOVE_MEDIUM 0xA5
  2402. #define SCSIOP_LOAD_UNLOAD_SLOT 0xA6
  2403. #define SCSIOP_EXCHANGE_MEDIUM 0xA6
  2404. #define SCSIOP_SET_READ_AHEAD 0xA7
  2405. #define SCSIOP_READ_DVD_STRUCTURE 0xAD
  2406. #define SCSIOP_REQUEST_VOL_ELEMENT 0xB5
  2407. #define SCSIOP_SEND_VOLUME_TAG 0xB6
  2408. #define SCSIOP_READ_ELEMENT_STATUS 0xB8
  2409. #define SCSIOP_READ_CD_MSF 0xB9
  2410. #define SCSIOP_SCAN_CD 0xBA
  2411. #define SCSIOP_SET_CD_SPEED 0xBB
  2412. #define SCSIOP_PLAY_CD 0xBC
  2413. #define SCSIOP_MECHANISM_STATUS 0xBD
  2414. #define SCSIOP_READ_CD 0xBE
  2415. #define SCSIOP_SEND_DVD_STRUCTURE 0xBF
  2416. #define SCSIOP_INIT_ELEMENT_RANGE 0xE7
  2417. //
  2418. // If the IMMED bit is 1, status is returned as soon
  2419. // as the operation is initiated. If the IMMED bit
  2420. // is 0, status is not returned until the operation
  2421. // is completed.
  2422. //
  2423. #define CDB_RETURN_ON_COMPLETION 0
  2424. #define CDB_RETURN_IMMEDIATE 1
  2425. //
  2426. // Inquiry buffer structure. This is the data returned from the target
  2427. // after it receives an inquiry.
  2428. //
  2429. // This structure may be extended by the number of bytes specified
  2430. // in the field AdditionalLength. The defined size constant only
  2431. // includes fields through ProductRevisionLevel.
  2432. //
  2433. // The NT SCSI drivers are only interested in the first 36 bytes of data.
  2434. //
  2435. #define INQUIRYDATABUFFERSIZE 36
  2436. typedef struct _INQUIRYDATA {
  2437. UCHAR DeviceType : 5;
  2438. UCHAR DeviceTypeQualifier : 3;
  2439. UCHAR DeviceTypeModifier : 7;
  2440. UCHAR RemovableMedia : 1;
  2441. union {
  2442. UCHAR Versions;
  2443. struct {
  2444. UCHAR ANSIVersion : 3;
  2445. UCHAR ECMAVersion : 3;
  2446. UCHAR ISOVersion : 2;
  2447. };
  2448. };
  2449. UCHAR ResponseDataFormat : 4;
  2450. UCHAR HiSupport : 1;
  2451. UCHAR NormACA : 1;
  2452. UCHAR TerminateTask : 1;
  2453. UCHAR AERC : 1;
  2454. UCHAR AdditionalLength;
  2455. UCHAR Reserved;
  2456. UCHAR Addr16 : 1; // defined only for SIP devices.
  2457. UCHAR Addr32 : 1; // defined only for SIP devices.
  2458. UCHAR AckReqQ: 1; // defined only for SIP devices.
  2459. UCHAR MediumChanger : 1;
  2460. UCHAR MultiPort : 1;
  2461. UCHAR ReservedBit2 : 1;
  2462. UCHAR EnclosureServices : 1;
  2463. UCHAR ReservedBit3 : 1;
  2464. UCHAR SoftReset : 1;
  2465. UCHAR CommandQueue : 1;
  2466. UCHAR TransferDisable : 1; // defined only for SIP devices.
  2467. UCHAR LinkedCommands : 1;
  2468. UCHAR Synchronous : 1; // defined only for SIP devices.
  2469. UCHAR Wide16Bit : 1; // defined only for SIP devices.
  2470. UCHAR Wide32Bit : 1; // defined only for SIP devices.
  2471. UCHAR RelativeAddressing : 1;
  2472. UCHAR VendorId[8];
  2473. UCHAR ProductId[16];
  2474. UCHAR ProductRevisionLevel[4];
  2475. UCHAR VendorSpecific[20];
  2476. UCHAR Reserved3[40];
  2477. } INQUIRYDATA, *PINQUIRYDATA;
  2478. //
  2479. // Inquiry defines. Used to interpret data returned from target as result
  2480. // of inquiry command.
  2481. //
  2482. // DeviceType field
  2483. //
  2484. #define DIRECT_ACCESS_DEVICE 0x00 // disks
  2485. #define SEQUENTIAL_ACCESS_DEVICE 0x01 // tapes
  2486. #define PRINTER_DEVICE 0x02 // printers
  2487. #define PROCESSOR_DEVICE 0x03 // scanners, printers, etc
  2488. #define WRITE_ONCE_READ_MULTIPLE_DEVICE 0x04 // worms
  2489. #define READ_ONLY_DIRECT_ACCESS_DEVICE 0x05 // cdroms
  2490. #define SCANNER_DEVICE 0x06 // scanners
  2491. #define OPTICAL_DEVICE 0x07 // optical disks
  2492. #define MEDIUM_CHANGER 0x08 // jukebox
  2493. #define COMMUNICATION_DEVICE 0x09 // network
  2494. #define LOGICAL_UNIT_NOT_PRESENT_DEVICE 0x7F
  2495. #define DEVICE_QUALIFIER_ACTIVE 0x00
  2496. #define DEVICE_QUALIFIER_NOT_ACTIVE 0x01
  2497. #define DEVICE_QUALIFIER_NOT_SUPPORTED 0x03
  2498. //
  2499. // DeviceTypeQualifier field
  2500. //
  2501. #define DEVICE_CONNECTED 0x00
  2502. //
  2503. // Vital Product Data Pages
  2504. //
  2505. //
  2506. // Unit Serial Number Page (page code 0x80)
  2507. //
  2508. // Provides a product serial number for the target or the logical unit.
  2509. //
  2510. typedef struct _VPD_MEDIA_SERIAL_NUMBER_PAGE {
  2511. UCHAR DeviceType : 5;
  2512. UCHAR DeviceTypeQualifier : 3;
  2513. UCHAR PageCode;
  2514. UCHAR Reserved;
  2515. UCHAR PageLength;
  2516. UCHAR SerialNumber[0];
  2517. } VPD_MEDIA_SERIAL_NUMBER_PAGE, *PVPD_MEDIA_SERIAL_NUMBER_PAGE;
  2518. typedef struct _VPD_SERIAL_NUMBER_PAGE {
  2519. UCHAR DeviceType : 5;
  2520. UCHAR DeviceTypeQualifier : 3;
  2521. UCHAR PageCode;
  2522. UCHAR Reserved;
  2523. UCHAR PageLength;
  2524. UCHAR SerialNumber[0];
  2525. } VPD_SERIAL_NUMBER_PAGE, *PVPD_SERIAL_NUMBER_PAGE;
  2526. //
  2527. // Device Identification Page (page code 0x83)
  2528. // Provides the means to retrieve zero or more identification descriptors
  2529. // applying to the logical unit.
  2530. //
  2531. typedef enum _VPD_CODE_SET {
  2532. VpdCodeSetReserved = 0,
  2533. VpdCodeSetBinary = 1,
  2534. VpdCodeSetAscii = 2
  2535. } VPD_CODE_SET, *PVPD_CODE_SET;
  2536. typedef enum _VPD_ASSOCIATION {
  2537. VpdAssocDevice = 0,
  2538. VpdAssocPort = 1,
  2539. VpdAssocReserved1 = 3,
  2540. VpdAssocReserved2 = 4
  2541. } VPD_ASSOCIATION, *PVPD_ASSOCIATION;
  2542. typedef enum _VPD_IDENTIFIER_TYPE {
  2543. VpdIdentifierTypeVendorSpecific = 0,
  2544. VpdIdentifierTypeVendorId = 1,
  2545. VpdIdentifierTypeEUI64 = 2,
  2546. VpdIdentifierTypeFCPHName = 3,
  2547. VpdIdentifierTypePortRelative = 4
  2548. } VPD_IDENTIFIER_TYPE, *PVPD_IDENTIFIER_TYPE;
  2549. typedef struct _VPD_IDENTIFICATION_DESCRIPTOR {
  2550. UCHAR CodeSet : 4; // VPD_CODE_SET
  2551. UCHAR Reserved : 4;
  2552. UCHAR IdentifierType : 4; // VPD_IDENTIFIER_TYPE
  2553. UCHAR Association : 2;
  2554. UCHAR Reserved2 : 2;
  2555. UCHAR Reserved3;
  2556. UCHAR IdentifierLength;
  2557. UCHAR Identifier[0];
  2558. } VPD_IDENTIFICATION_DESCRIPTOR, *PVPD_IDENTIFICATION_DESCRIPTOR;
  2559. typedef struct _VPD_IDENTIFICATION_PAGE {
  2560. UCHAR DeviceType : 5;
  2561. UCHAR DeviceTypeQualifier : 3;
  2562. UCHAR PageCode;
  2563. UCHAR Reserved;
  2564. UCHAR PageLength;
  2565. //
  2566. // The following field is actually a variable length array of identification
  2567. // descriptors. Unfortunately there's no C notation for an array of
  2568. // variable length structures so we're forced to just pretend.
  2569. //
  2570. // VPD_IDENTIFICATION_DESCRIPTOR Descriptors[0];
  2571. UCHAR Descriptors[0];
  2572. } VPD_IDENTIFICATION_PAGE, *PVPD_IDENTIFICATION_PAGE;
  2573. //
  2574. // Supported Vital Product Data Pages Page (page code 0x00)
  2575. // Contains a list of the vital product data page cods supported by the target
  2576. // or logical unit.
  2577. //
  2578. typedef struct _VPD_SUPPORTED_PAGES_PAGE {
  2579. UCHAR DeviceType : 5;
  2580. UCHAR DeviceTypeQualifier : 3;
  2581. UCHAR PageCode;
  2582. UCHAR Reserved;
  2583. UCHAR PageLength;
  2584. UCHAR SupportedPageList[0];
  2585. } VPD_SUPPORTED_PAGES_PAGE, *PVPD_SUPPORTED_PAGES_PAGE;
  2586. #define VPD_MAX_BUFFER_SIZE 0xff
  2587. #define VPD_SUPPORTED_PAGES 0x00
  2588. #define VPD_SERIAL_NUMBER 0x80
  2589. #define VPD_DEVICE_IDENTIFIERS 0x83
  2590. #define VPD_MEDIA_SERIAL_NUMBER 0x84
  2591. //
  2592. // Persistent Reservation Definitions.
  2593. //
  2594. //
  2595. // PERSISTENT_RESERVE_* definitions
  2596. //
  2597. #define RESERVATION_ACTION_READ_KEYS 0x00
  2598. #define RESERVATION_ACTION_READ_RESERVATIONS 0x01
  2599. #define RESERVATION_ACTION_REGISTER 0x00
  2600. #define RESERVATION_ACTION_RESERVE 0x01
  2601. #define RESERVATION_ACTION_RELEASE 0x02
  2602. #define RESERVATION_ACTION_CLEAR 0x03
  2603. #define RESERVATION_ACTION_PREEMPT 0x04
  2604. #define RESERVATION_ACTION_PREEMPT_ABORT 0x05
  2605. #define RESERVATION_ACTION_REGISTER_IGNORE_EXISTING 0x06
  2606. #define RESERVATION_SCOPE_LU 0x00
  2607. #define RESERVATION_SCOPE_ELEMENT 0x02
  2608. #define RESERVATION_TYPE_WRITE_EXCLUSIVE 0x01
  2609. #define RESERVATION_TYPE_EXCLUSIVE 0x03
  2610. #define RESERVATION_TYPE_WRITE_EXCLUSIVE_REGISTRANTS 0x05
  2611. #define RESERVATION_TYPE_EXCLUSIVE_REGISTRANTS 0x06
  2612. //
  2613. // Structures for reserve in command.
  2614. //
  2615. typedef struct {
  2616. UCHAR Generation[4];
  2617. UCHAR AdditionalLength[4];
  2618. UCHAR ReservationKeyList[0][8];
  2619. } PRI_REGISTRATION_LIST, *PPRI_REGISTRATION_LIST;
  2620. typedef struct {
  2621. UCHAR ReservationKey[8];
  2622. UCHAR ScopeSpecificAddress[4];
  2623. UCHAR Reserved;
  2624. UCHAR Type : 4;
  2625. UCHAR Scope : 4;
  2626. UCHAR Obsolete[2];
  2627. } PRI_RESERVATION_DESCRIPTOR, *PPRI_RESERVATION_DESCRIPTOR;
  2628. typedef struct {
  2629. UCHAR Generation[4];
  2630. UCHAR AdditionalLength[4];
  2631. PRI_RESERVATION_DESCRIPTOR Reservations[0];
  2632. } PRI_RESERVATION_LIST, *PPRI_RESERVATION_LIST;
  2633. //
  2634. // Structures for reserve out command.
  2635. //
  2636. typedef struct {
  2637. UCHAR ReservationKey[8];
  2638. UCHAR ServiceActionReservationKey[8];
  2639. UCHAR ScopeSpecificAddress[4];
  2640. UCHAR ActivatePersistThroughPowerLoss : 1;
  2641. UCHAR Reserved1 : 7;
  2642. UCHAR Reserved2;
  2643. UCHAR Obsolete[2];
  2644. } PRO_PARAMETER_LIST, *PPRO_PARAMETER_LIST;
  2645. //
  2646. // Sense Data Format
  2647. //
  2648. typedef struct _SENSE_DATA {
  2649. UCHAR ErrorCode:7;
  2650. UCHAR Valid:1;
  2651. UCHAR SegmentNumber;
  2652. UCHAR SenseKey:4;
  2653. UCHAR Reserved:1;
  2654. UCHAR IncorrectLength:1;
  2655. UCHAR EndOfMedia:1;
  2656. UCHAR FileMark:1;
  2657. UCHAR Information[4];
  2658. UCHAR AdditionalSenseLength;
  2659. UCHAR CommandSpecificInformation[4];
  2660. UCHAR AdditionalSenseCode;
  2661. UCHAR AdditionalSenseCodeQualifier;
  2662. UCHAR FieldReplaceableUnitCode;
  2663. UCHAR SenseKeySpecific[3];
  2664. } SENSE_DATA, *PSENSE_DATA;
  2665. //
  2666. // Default request sense buffer size
  2667. //
  2668. #define SENSE_BUFFER_SIZE 18
  2669. //
  2670. // Maximum request sense buffer size
  2671. //
  2672. #define MAX_SENSE_BUFFER_SIZE 255
  2673. //
  2674. // Maximum number of additional sense bytes.
  2675. //
  2676. #define MAX_ADDITIONAL_SENSE_BYTES (MAX_SENSE_BUFFER_SIZE - SENSE_BUFFER_SIZE)
  2677. //
  2678. // Sense codes
  2679. //
  2680. #define SCSI_SENSE_NO_SENSE 0x00
  2681. #define SCSI_SENSE_RECOVERED_ERROR 0x01
  2682. #define SCSI_SENSE_NOT_READY 0x02
  2683. #define SCSI_SENSE_MEDIUM_ERROR 0x03
  2684. #define SCSI_SENSE_HARDWARE_ERROR 0x04
  2685. #define SCSI_SENSE_ILLEGAL_REQUEST 0x05
  2686. #define SCSI_SENSE_UNIT_ATTENTION 0x06
  2687. #define SCSI_SENSE_DATA_PROTECT 0x07
  2688. #define SCSI_SENSE_BLANK_CHECK 0x08
  2689. #define SCSI_SENSE_UNIQUE 0x09
  2690. #define SCSI_SENSE_COPY_ABORTED 0x0A
  2691. #define SCSI_SENSE_ABORTED_COMMAND 0x0B
  2692. #define SCSI_SENSE_EQUAL 0x0C
  2693. #define SCSI_SENSE_VOL_OVERFLOW 0x0D
  2694. #define SCSI_SENSE_MISCOMPARE 0x0E
  2695. #define SCSI_SENSE_RESERVED 0x0F
  2696. //
  2697. // Additional tape bit
  2698. //
  2699. #define SCSI_ILLEGAL_LENGTH 0x20
  2700. #define SCSI_EOM 0x40
  2701. #define SCSI_FILE_MARK 0x80
  2702. //
  2703. // Additional Sense codes
  2704. //
  2705. #define SCSI_ADSENSE_NO_SENSE 0x00
  2706. #define SCSI_ADSENSE_NO_SEEK_COMPLETE 0x02
  2707. #define SCSI_ADSENSE_LUN_NOT_READY 0x04
  2708. #define SCSI_ADSENSE_WRITE_ERROR 0x0C
  2709. #define SCSI_ADSENSE_TRACK_ERROR 0x14
  2710. #define SCSI_ADSENSE_SEEK_ERROR 0x15
  2711. #define SCSI_ADSENSE_REC_DATA_NOECC 0x17
  2712. #define SCSI_ADSENSE_REC_DATA_ECC 0x18
  2713. #define SCSI_ADSENSE_ILLEGAL_COMMAND 0x20
  2714. #define SCSI_ADSENSE_ILLEGAL_BLOCK 0x21
  2715. #define SCSI_ADSENSE_INVALID_CDB 0x24
  2716. #define SCSI_ADSENSE_INVALID_LUN 0x25
  2717. #define SCSI_ADSENSE_WRITE_PROTECT 0x27
  2718. #define SCSI_ADSENSE_MEDIUM_CHANGED 0x28
  2719. #define SCSI_ADSENSE_BUS_RESET 0x29
  2720. #define SCSI_ADSENSE_INSUFFICIENT_TIME_FOR_OPERATION 0x2E
  2721. #define SCSI_ADSENSE_INVALID_MEDIA 0x30
  2722. #define SCSI_ADSENSE_NO_MEDIA_IN_DEVICE 0x3a
  2723. #define SCSI_ADSENSE_POSITION_ERROR 0x3b
  2724. #define SCSI_ADSENSE_OPERATOR_REQUEST 0x5a // see below
  2725. #define SCSI_ADSENSE_FAILURE_PREDICTION_THRESHOLD_EXCEEDED 0x5d
  2726. #define SCSI_ADSENSE_ILLEGAL_MODE_FOR_THIS_TRACK 0x64
  2727. #define SCSI_ADSENSE_COPY_PROTECTION_FAILURE 0x6f
  2728. #define SCSI_ADSENSE_POWER_CALIBRATION_ERROR 0x73
  2729. #define SCSI_ADSENSE_VENDOR_UNIQUE 0x80 // and higher
  2730. #define SCSI_ADSENSE_MUSIC_AREA 0xA0
  2731. #define SCSI_ADSENSE_DATA_AREA 0xA1
  2732. #define SCSI_ADSENSE_VOLUME_OVERFLOW 0xA7
  2733. // for legacy apps:
  2734. #define SCSI_ADWRITE_PROTECT SCSI_ADSENSE_WRITE_PROTECT
  2735. #define SCSI_FAILURE_PREDICTION_THRESHOLD_EXCEEDED SCSI_ADSENSE_FAILURE_PREDICTION_THRESHOLD_EXCEEDED
  2736. //
  2737. // SCSI_ADSENSE_LUN_NOT_READY (0x04) qualifiers
  2738. //
  2739. #define SCSI_SENSEQ_CAUSE_NOT_REPORTABLE 0x00
  2740. #define SCSI_SENSEQ_BECOMING_READY 0x01
  2741. #define SCSI_SENSEQ_INIT_COMMAND_REQUIRED 0x02
  2742. #define SCSI_SENSEQ_MANUAL_INTERVENTION_REQUIRED 0x03
  2743. #define SCSI_SENSEQ_FORMAT_IN_PROGRESS 0x04
  2744. #define SCSI_SENSEQ_REBUILD_IN_PROGRESS 0x05
  2745. #define SCSI_SENSEQ_RECALCULATION_IN_PROGRESS 0x06
  2746. #define SCSI_SENSEQ_OPERATION_IN_PROGRESS 0x07
  2747. #define SCSI_SENSEQ_LONG_WRITE_IN_PROGRESS 0x08
  2748. //
  2749. // SCSI_ADSENSE_WRITE_ERROR (0x0C) qualifiers
  2750. //
  2751. #define SCSI_SENSEQ_LOSS_OF_STREAMING 0x09
  2752. #define SCSI_SENSEQ_PADDING_BLOCKS_ADDED 0x0A
  2753. //
  2754. // SCSI_ADSENSE_NO_SENSE (0x00) qualifiers
  2755. //
  2756. #define SCSI_SENSEQ_FILEMARK_DETECTED 0x01
  2757. #define SCSI_SENSEQ_END_OF_MEDIA_DETECTED 0x02
  2758. #define SCSI_SENSEQ_SETMARK_DETECTED 0x03
  2759. #define SCSI_SENSEQ_BEGINNING_OF_MEDIA_DETECTED 0x04
  2760. //
  2761. // SCSI_ADSENSE_ILLEGAL_BLOCK (0x21) qualifiers
  2762. //
  2763. #define SCSI_SENSEQ_ILLEGAL_ELEMENT_ADDR 0x01
  2764. //
  2765. // SCSI_ADSENSE_POSITION_ERROR (0x3b) qualifiers
  2766. //
  2767. #define SCSI_SENSEQ_DESTINATION_FULL 0x0d
  2768. #define SCSI_SENSEQ_SOURCE_EMPTY 0x0e
  2769. //
  2770. // SCSI_ADSENSE_INVALID_MEDIA (0x30) qualifiers
  2771. //
  2772. #define SCSI_SENSEQ_INCOMPATIBLE_MEDIA_INSTALLED 0x00
  2773. #define SCSI_SENSEQ_UNKNOWN_FORMAT 0x01
  2774. #define SCSI_SENSEQ_INCOMPATIBLE_FORMAT 0x02
  2775. #define SCSI_SENSEQ_CLEANING_CARTRIDGE_INSTALLED 0x03
  2776. //
  2777. // SCSI_ADSENSE_OPERATOR_REQUEST (0x5a) qualifiers
  2778. //
  2779. #define SCSI_SENSEQ_STATE_CHANGE_INPUT 0x00 // generic request
  2780. #define SCSI_SENSEQ_MEDIUM_REMOVAL 0x01
  2781. #define SCSI_SENSEQ_WRITE_PROTECT_ENABLE 0x02
  2782. #define SCSI_SENSEQ_WRITE_PROTECT_DISABLE 0x03
  2783. //
  2784. // SCSI_ADSENSE_COPY_PROTECTION_FAILURE (0x6f) qualifiers
  2785. //
  2786. #define SCSI_SENSEQ_AUTHENTICATION_FAILURE 0x00
  2787. #define SCSI_SENSEQ_KEY_NOT_PRESENT 0x01
  2788. #define SCSI_SENSEQ_KEY_NOT_ESTABLISHED 0x02
  2789. #define SCSI_SENSEQ_READ_OF_SCRAMBLED_SECTOR_WITHOUT_AUTHENTICATION 0x03
  2790. #define SCSI_SENSEQ_MEDIA_CODE_MISMATCHED_TO_LOGICAL_UNIT 0x04
  2791. #define SCSI_SENSEQ_LOGICAL_UNIT_RESET_COUNT_ERROR 0x05
  2792. //
  2793. // SCSI_ADSENSE_POWER_CALIBRATION_ERROR (0x73) qualifiers
  2794. //
  2795. #define SCSI_SENSEQ_POWER_CALIBRATION_AREA_ALMOST_FULL 0x01
  2796. #define SCSI_SENSEQ_POWER_CALIBRATION_AREA_FULL 0x02
  2797. #define SCSI_SENSEQ_POWER_CALIBRATION_AREA_ERROR 0x03
  2798. #define SCSI_SENSEQ_PMA_RMA_UPDATE_FAILURE 0x04
  2799. #define SCSI_SENSEQ_PMA_RMA_IS_FULL 0x05
  2800. #define SCSI_SENSEQ_PMA_RMA_ALMOST_FULL 0x06
  2801. //
  2802. // Read Capacity Data - returned in Big Endian format
  2803. //
  2804. typedef struct _READ_CAPACITY_DATA {
  2805. ULONG LogicalBlockAddress;
  2806. ULONG BytesPerBlock;
  2807. } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
  2808. //
  2809. // Read Block Limits Data - returned in Big Endian format
  2810. // This structure returns the maximum and minimum block
  2811. // size for a TAPE device.
  2812. //
  2813. typedef struct _READ_BLOCK_LIMITS {
  2814. UCHAR Reserved;
  2815. UCHAR BlockMaximumSize[3];
  2816. UCHAR BlockMinimumSize[2];
  2817. } READ_BLOCK_LIMITS_DATA, *PREAD_BLOCK_LIMITS_DATA;
  2818. //
  2819. // Mode data structures.
  2820. //
  2821. //
  2822. // Define Mode parameter header.
  2823. //
  2824. typedef struct _MODE_PARAMETER_HEADER {
  2825. UCHAR ModeDataLength;
  2826. UCHAR MediumType;
  2827. UCHAR DeviceSpecificParameter;
  2828. UCHAR BlockDescriptorLength;
  2829. }MODE_PARAMETER_HEADER, *PMODE_PARAMETER_HEADER;
  2830. typedef struct _MODE_PARAMETER_HEADER10 {
  2831. UCHAR ModeDataLength[2];
  2832. UCHAR MediumType;
  2833. UCHAR DeviceSpecificParameter;
  2834. UCHAR Reserved[2];
  2835. UCHAR BlockDescriptorLength[2];
  2836. }MODE_PARAMETER_HEADER10, *PMODE_PARAMETER_HEADER10;
  2837. #define MODE_FD_SINGLE_SIDE 0x01
  2838. #define MODE_FD_DOUBLE_SIDE 0x02
  2839. #define MODE_FD_MAXIMUM_TYPE 0x1E
  2840. #define MODE_DSP_FUA_SUPPORTED 0x10
  2841. #define MODE_DSP_WRITE_PROTECT 0x80
  2842. //
  2843. // Define the mode parameter block.
  2844. //
  2845. typedef struct _MODE_PARAMETER_BLOCK {
  2846. UCHAR DensityCode;
  2847. UCHAR NumberOfBlocks[3];
  2848. UCHAR Reserved;
  2849. UCHAR BlockLength[3];
  2850. }MODE_PARAMETER_BLOCK, *PMODE_PARAMETER_BLOCK;
  2851. //
  2852. // Define Disconnect-Reconnect page.
  2853. //
  2854. typedef struct _MODE_DISCONNECT_PAGE {
  2855. UCHAR PageCode : 6;
  2856. UCHAR Reserved : 1;
  2857. UCHAR PageSavable : 1;
  2858. UCHAR PageLength;
  2859. UCHAR BufferFullRatio;
  2860. UCHAR BufferEmptyRatio;
  2861. UCHAR BusInactivityLimit[2];
  2862. UCHAR BusDisconnectTime[2];
  2863. UCHAR BusConnectTime[2];
  2864. UCHAR MaximumBurstSize[2];
  2865. UCHAR DataTransferDisconnect : 2;
  2866. UCHAR Reserved2[3];
  2867. }MODE_DISCONNECT_PAGE, *PMODE_DISCONNECT_PAGE;
  2868. //
  2869. // Define mode caching page.
  2870. //
  2871. typedef struct _MODE_CACHING_PAGE {
  2872. UCHAR PageCode : 6;
  2873. UCHAR Reserved : 1;
  2874. UCHAR PageSavable : 1;
  2875. UCHAR PageLength;
  2876. UCHAR ReadDisableCache : 1;
  2877. UCHAR MultiplicationFactor : 1;
  2878. UCHAR WriteCacheEnable : 1;
  2879. UCHAR Reserved2 : 5;
  2880. UCHAR WriteRetensionPriority : 4;
  2881. UCHAR ReadRetensionPriority : 4;
  2882. UCHAR DisablePrefetchTransfer[2];
  2883. UCHAR MinimumPrefetch[2];
  2884. UCHAR MaximumPrefetch[2];
  2885. UCHAR MaximumPrefetchCeiling[2];
  2886. }MODE_CACHING_PAGE, *PMODE_CACHING_PAGE;
  2887. //
  2888. // Define write parameters cdrom page
  2889. //
  2890. typedef struct _MODE_CDROM_WRITE_PARAMETERS_PAGE {
  2891. UCHAR PageLength; // 0x32 ??
  2892. UCHAR WriteType : 4;
  2893. UCHAR TestWrite : 1;
  2894. UCHAR LinkSizeValid : 1;
  2895. UCHAR BufferUnderrunFreeEnabled : 1;
  2896. UCHAR Reserved2 : 1;
  2897. UCHAR TrackMode : 4;
  2898. UCHAR Copy : 1;
  2899. UCHAR FixedPacket : 1;
  2900. UCHAR MultiSession : 2;
  2901. UCHAR DataBlockType : 4;
  2902. UCHAR Reserved3 : 4;
  2903. UCHAR LinkSize;
  2904. UCHAR Reserved4;
  2905. UCHAR HostApplicationCode : 6;
  2906. UCHAR Reserved5 : 2;
  2907. UCHAR SessionFormat;
  2908. UCHAR Reserved6;
  2909. UCHAR PacketSize[4];
  2910. UCHAR AudioPauseLength[2];
  2911. UCHAR Reserved7 : 7;
  2912. UCHAR MediaCatalogNumberValid : 1;
  2913. UCHAR MediaCatalogNumber[13];
  2914. UCHAR MediaCatalogNumberZero;
  2915. UCHAR MediaCatalogNumberAFrame;
  2916. UCHAR Reserved8 : 7;
  2917. UCHAR ISRCValid : 1;
  2918. UCHAR ISRCCountry[2];
  2919. UCHAR ISRCOwner[3];
  2920. UCHAR ISRCRecordingYear[2];
  2921. UCHAR ISRCSerialNumber[5];
  2922. UCHAR ISRCZero;
  2923. UCHAR ISRCAFrame;
  2924. UCHAR ISRCReserved;
  2925. UCHAR SubHeaderData[4];
  2926. } MODE_CDROM_WRITE_PARAMETERS_PAGE, *PMODE_CDROM_WRITE_PARAMETERS_PAGE;
  2927. //
  2928. // Define mode flexible disk page.
  2929. //
  2930. typedef struct _MODE_FLEXIBLE_DISK_PAGE {
  2931. UCHAR PageCode : 6;
  2932. UCHAR Reserved : 1;
  2933. UCHAR PageSavable : 1;
  2934. UCHAR PageLength;
  2935. UCHAR TransferRate[2];
  2936. UCHAR NumberOfHeads;
  2937. UCHAR SectorsPerTrack;
  2938. UCHAR BytesPerSector[2];
  2939. UCHAR NumberOfCylinders[2];
  2940. UCHAR StartWritePrecom[2];
  2941. UCHAR StartReducedCurrent[2];
  2942. UCHAR StepRate[2];
  2943. UCHAR StepPluseWidth;
  2944. UCHAR HeadSettleDelay[2];
  2945. UCHAR MotorOnDelay;
  2946. UCHAR MotorOffDelay;
  2947. UCHAR Reserved2 : 5;
  2948. UCHAR MotorOnAsserted : 1;
  2949. UCHAR StartSectorNumber : 1;
  2950. UCHAR TrueReadySignal : 1;
  2951. UCHAR StepPlusePerCyclynder : 4;
  2952. UCHAR Reserved3 : 4;
  2953. UCHAR WriteCompenstation;
  2954. UCHAR HeadLoadDelay;
  2955. UCHAR HeadUnloadDelay;
  2956. UCHAR Pin2Usage : 4;
  2957. UCHAR Pin34Usage : 4;
  2958. UCHAR Pin1Usage : 4;
  2959. UCHAR Pin4Usage : 4;
  2960. UCHAR MediumRotationRate[2];
  2961. UCHAR Reserved4[2];
  2962. }MODE_FLEXIBLE_DISK_PAGE, *PMODE_FLEXIBLE_DISK_PAGE;
  2963. //
  2964. // Define mode format page.
  2965. //
  2966. typedef struct _MODE_FORMAT_PAGE {
  2967. UCHAR PageCode : 6;
  2968. UCHAR Reserved : 1;
  2969. UCHAR PageSavable : 1;
  2970. UCHAR PageLength;
  2971. UCHAR TracksPerZone[2];
  2972. UCHAR AlternateSectorsPerZone[2];
  2973. UCHAR AlternateTracksPerZone[2];
  2974. UCHAR AlternateTracksPerLogicalUnit[2];
  2975. UCHAR SectorsPerTrack[2];
  2976. UCHAR BytesPerPhysicalSector[2];
  2977. UCHAR Interleave[2];
  2978. UCHAR TrackSkewFactor[2];
  2979. UCHAR CylinderSkewFactor[2];
  2980. UCHAR Reserved2 : 4;
  2981. UCHAR SurfaceFirst : 1;
  2982. UCHAR RemovableMedia : 1;
  2983. UCHAR HardSectorFormating : 1;
  2984. UCHAR SoftSectorFormating : 1;
  2985. UCHAR Reserved3[3];
  2986. }MODE_FORMAT_PAGE, *PMODE_FORMAT_PAGE;
  2987. //
  2988. // Define rigid disk driver geometry page.
  2989. //
  2990. typedef struct _MODE_RIGID_GEOMETRY_PAGE {
  2991. UCHAR PageCode : 6;
  2992. UCHAR Reserved : 1;
  2993. UCHAR PageSavable : 1;
  2994. UCHAR PageLength;
  2995. UCHAR NumberOfCylinders[3];
  2996. UCHAR NumberOfHeads;
  2997. UCHAR StartWritePrecom[3];
  2998. UCHAR StartReducedCurrent[3];
  2999. UCHAR DriveStepRate[2];
  3000. UCHAR LandZoneCyclinder[3];
  3001. UCHAR RotationalPositionLock : 2;
  3002. UCHAR Reserved2 : 6;
  3003. UCHAR RotationOffset;
  3004. UCHAR Reserved3;
  3005. UCHAR RoataionRate[2];
  3006. UCHAR Reserved4[2];
  3007. }MODE_RIGID_GEOMETRY_PAGE, *PMODE_RIGID_GEOMETRY_PAGE;
  3008. //
  3009. // Define read write recovery page
  3010. //
  3011. typedef struct _MODE_READ_WRITE_RECOVERY_PAGE {
  3012. UCHAR PageCode : 6;
  3013. UCHAR Reserved1 : 1;
  3014. UCHAR PSBit : 1;
  3015. UCHAR PageLength;
  3016. UCHAR DCRBit : 1;
  3017. UCHAR DTEBit : 1;
  3018. UCHAR PERBit : 1;
  3019. UCHAR EERBit : 1;
  3020. UCHAR RCBit : 1;
  3021. UCHAR TBBit : 1;
  3022. UCHAR ARRE : 1;
  3023. UCHAR AWRE : 1;
  3024. UCHAR ReadRetryCount;
  3025. UCHAR Reserved4[4];
  3026. UCHAR WriteRetryCount;
  3027. UCHAR Reserved5[3];
  3028. } MODE_READ_WRITE_RECOVERY_PAGE, *PMODE_READ_WRITE_RECOVERY_PAGE;
  3029. //
  3030. // Define read recovery page - cdrom
  3031. //
  3032. typedef struct _MODE_READ_RECOVERY_PAGE {
  3033. UCHAR PageCode : 6;
  3034. UCHAR Reserved1 : 1;
  3035. UCHAR PSBit : 1;
  3036. UCHAR PageLength;
  3037. UCHAR DCRBit : 1;
  3038. UCHAR DTEBit : 1;
  3039. UCHAR PERBit : 1;
  3040. UCHAR Reserved2 : 1;
  3041. UCHAR RCBit : 1;
  3042. UCHAR TBBit : 1;
  3043. UCHAR Reserved3 : 2;
  3044. UCHAR ReadRetryCount;
  3045. UCHAR Reserved4[4];
  3046. } MODE_READ_RECOVERY_PAGE, *PMODE_READ_RECOVERY_PAGE;
  3047. //
  3048. // Define Informational Exception Control Page. Used for failure prediction
  3049. //
  3050. typedef struct _MODE_INFO_EXCEPTIONS
  3051. {
  3052. UCHAR PageCode : 6;
  3053. UCHAR Reserved1 : 1;
  3054. UCHAR PSBit : 1;
  3055. UCHAR PageLength;
  3056. union
  3057. {
  3058. UCHAR Flags;
  3059. struct
  3060. {
  3061. UCHAR LogErr : 1;
  3062. UCHAR Reserved2 : 1;
  3063. UCHAR Test : 1;
  3064. UCHAR Dexcpt : 1;
  3065. UCHAR Reserved3 : 3;
  3066. UCHAR Perf : 1;
  3067. };
  3068. };
  3069. UCHAR ReportMethod : 4;
  3070. UCHAR Reserved4 : 4;
  3071. UCHAR IntervalTimer[4];
  3072. UCHAR ReportCount[4];
  3073. } MODE_INFO_EXCEPTIONS, *PMODE_INFO_EXCEPTIONS;
  3074. //
  3075. // Begin C/DVD 0.9 definitions
  3076. //
  3077. //
  3078. // Power Condition Mode Page Format
  3079. //
  3080. typedef struct _POWER_CONDITION_PAGE {
  3081. UCHAR PageCode : 6; // 0x1A
  3082. UCHAR Reserved : 1;
  3083. UCHAR PSBit : 1;
  3084. UCHAR PageLength; // 0x0A
  3085. UCHAR Reserved2;
  3086. UCHAR Standby : 1;
  3087. UCHAR Idle : 1;
  3088. UCHAR Reserved3 : 6;
  3089. UCHAR IdleTimer[4];
  3090. UCHAR StandbyTimer[4];
  3091. } POWER_CONDITION_PAGE, *PPOWER_CONDITION_PAGE;
  3092. //
  3093. // CD-Audio Control Mode Page Format
  3094. //
  3095. typedef struct _CDDA_OUTPUT_PORT {
  3096. UCHAR ChannelSelection : 4;
  3097. UCHAR Reserved : 4;
  3098. UCHAR Volume;
  3099. } CDDA_OUTPUT_PORT, *PCDDA_OUTPUT_PORT;
  3100. typedef struct _CDAUDIO_CONTROL_PAGE {
  3101. UCHAR PageCode : 6; // 0x0E
  3102. UCHAR Reserved : 1;
  3103. UCHAR PSBit : 1;
  3104. UCHAR PageLength; // 0x0E
  3105. UCHAR Reserved2 : 1;
  3106. UCHAR StopOnTrackCrossing : 1; // Default 0
  3107. UCHAR Immediate : 1; // Always 1
  3108. UCHAR Reserved3 : 5;
  3109. UCHAR Reserved4[3];
  3110. UCHAR Obsolete[2];
  3111. CDDA_OUTPUT_PORT CDDAOutputPorts[4];
  3112. } CDAUDIO_CONTROL_PAGE, *PCDAUDIO_CONTROL_PAGE;
  3113. #define CDDA_CHANNEL_MUTED 0x0
  3114. #define CDDA_CHANNEL_ZERO 0x1
  3115. #define CDDA_CHANNEL_ONE 0x2
  3116. #define CDDA_CHANNEL_TWO 0x4
  3117. #define CDDA_CHANNEL_THREE 0x8
  3118. //
  3119. // C/DVD Feature Set Support & Version Page
  3120. //
  3121. typedef struct _CDVD_FEATURE_SET_PAGE {
  3122. UCHAR PageCode : 6; // 0x18
  3123. UCHAR Reserved : 1;
  3124. UCHAR PSBit : 1;
  3125. UCHAR PageLength; // 0x16
  3126. UCHAR CDAudio[2];
  3127. UCHAR EmbeddedChanger[2];
  3128. UCHAR PacketSMART[2];
  3129. UCHAR PersistantPrevent[2];
  3130. UCHAR EventStatusNotification[2];
  3131. UCHAR DigitalOutput[2];
  3132. UCHAR CDSequentialRecordable[2];
  3133. UCHAR DVDSequentialRecordable[2];
  3134. UCHAR RandomRecordable[2];
  3135. UCHAR KeyExchange[2];
  3136. UCHAR Reserved2[2];
  3137. } CDVD_FEATURE_SET_PAGE, *PCDVD_FEATURE_SET_PAGE;
  3138. //
  3139. // CDVD Inactivity Time-out Page Format
  3140. //
  3141. typedef struct _CDVD_INACTIVITY_TIMEOUT_PAGE {
  3142. UCHAR PageCode : 6; // 0x1D
  3143. UCHAR Reserved : 1;
  3144. UCHAR PSBit : 1;
  3145. UCHAR PageLength; // 0x08
  3146. UCHAR Reserved2[2];
  3147. UCHAR SWPP : 1;
  3148. UCHAR DISP : 1;
  3149. UCHAR Reserved3 : 6;
  3150. UCHAR Reserved4;
  3151. UCHAR GroupOneMinimumTimeout[2];
  3152. UCHAR GroupTwoMinimumTimeout[2];
  3153. } CDVD_INACTIVITY_TIMEOUT_PAGE, *PCDVD_INACTIVITY_TIMEOUT_PAGE;
  3154. //
  3155. // CDVD Capabilities & Mechanism Status Page
  3156. //
  3157. #define CDVD_LMT_CADDY 0
  3158. #define CDVD_LMT_TRAY 1
  3159. #define CDVD_LMT_POPUP 2
  3160. #define CDVD_LMT_RESERVED1 3
  3161. #define CDVD_LMT_CHANGER_INDIVIDUAL 4
  3162. #define CDVD_LMT_CHANGER_CARTRIDGE 5
  3163. #define CDVD_LMT_RESERVED2 6
  3164. #define CDVD_LMT_RESERVED3 7
  3165. typedef struct _CDVD_CAPABILITIES_PAGE {
  3166. UCHAR PageCode : 6; // 0x2A
  3167. UCHAR Reserved : 1;
  3168. UCHAR PSBit : 1; // offset 0
  3169. UCHAR PageLength; // 0x18 // offset 1
  3170. UCHAR CDRRead : 1;
  3171. UCHAR CDERead : 1;
  3172. UCHAR Method2 : 1;
  3173. UCHAR DVDROMRead : 1;
  3174. UCHAR DVDRRead : 1;
  3175. UCHAR DVDRAMRead : 1;
  3176. UCHAR Reserved2 : 2; // offset 2
  3177. UCHAR CDRWrite : 1;
  3178. UCHAR CDEWrite : 1;
  3179. UCHAR TestWrite : 1;
  3180. UCHAR Reserved3 : 1;
  3181. UCHAR DVDRWrite : 1;
  3182. UCHAR DVDRAMWrite : 1;
  3183. UCHAR Reserved4 : 2; // offset 3
  3184. UCHAR AudioPlay : 1;
  3185. UCHAR Composite : 1;
  3186. UCHAR DigitalPortOne : 1;
  3187. UCHAR DigitalPortTwo : 1;
  3188. UCHAR Mode2Form1 : 1;
  3189. UCHAR Mode2Form2 : 1;
  3190. UCHAR MultiSession : 1;
  3191. UCHAR Reserved5 : 1; // offset 4
  3192. UCHAR CDDA : 1;
  3193. UCHAR CDDAAccurate : 1;
  3194. UCHAR RWSupported : 1;
  3195. UCHAR RWDeinterleaved : 1;
  3196. UCHAR C2Pointers : 1;
  3197. UCHAR ISRC : 1;
  3198. UCHAR UPC : 1;
  3199. UCHAR ReadBarCodeCapable : 1; // offset 5
  3200. UCHAR Lock : 1;
  3201. UCHAR LockState : 1;
  3202. UCHAR PreventJumper : 1;
  3203. UCHAR Eject : 1;
  3204. UCHAR Reserved6 : 1;
  3205. UCHAR LoadingMechanismType : 3; // offset 6
  3206. UCHAR SeparateVolume : 1;
  3207. UCHAR SeperateChannelMute : 1;
  3208. UCHAR SupportsDiskPresent : 1;
  3209. UCHAR SWSlotSelection : 1;
  3210. UCHAR SideChangeCapable : 1;
  3211. UCHAR RWInLeadInReadable : 1;
  3212. UCHAR Reserved7 : 2; // offset 7
  3213. UCHAR ObsoleteReserved[2]; // offset 8
  3214. UCHAR NumberVolumeLevels[2]; // offset 10
  3215. UCHAR BufferSize[2]; // offset 12
  3216. UCHAR ObsoleteReserved2[2]; // offset 14
  3217. UCHAR ObsoleteReserved3; // offset 16
  3218. UCHAR Reserved8 : 1;
  3219. UCHAR BCK : 1;
  3220. UCHAR RCK : 1;
  3221. UCHAR LSBF : 1;
  3222. UCHAR Length : 2;
  3223. UCHAR Reserved9 : 2; // offset 17
  3224. UCHAR ObsoleteReserved4[2]; // offset 18
  3225. UCHAR ObsoleteReserved11[2]; // offset 20
  3226. //
  3227. // NOTE: This mode page is two bytes too small in the release
  3228. // version of the Windows2000 DDK. it also incorrectly
  3229. // put the CopyManagementRevision at offset 20 instead
  3230. // of offset 22, so fix that with a nameless union (for
  3231. // backwards-compatibility with those who "fixed" it on
  3232. // their own by looking at Reserved10[]).
  3233. //
  3234. union {
  3235. UCHAR CopyManagementRevision[2]; // offset 22
  3236. UCHAR Reserved10[2];
  3237. };
  3238. //UCHAR Reserved12[2]; // offset 24
  3239. } CDVD_CAPABILITIES_PAGE, *PCDVD_CAPABILITIES_PAGE;
  3240. typedef struct _LUN_LIST {
  3241. UCHAR LunListLength[4]; // sizeof LunSize * 8
  3242. UCHAR Reserved[4];
  3243. UCHAR Lun[0][8]; // 4 level of addressing. 2 bytes each.
  3244. } LUN_LIST, *PLUN_LIST;
  3245. #define LOADING_MECHANISM_CADDY 0x00
  3246. #define LOADING_MECHANISM_TRAY 0x01
  3247. #define LOADING_MECHANISM_POPUP 0x02
  3248. #define LOADING_MECHANISM_INDIVIDUAL_CHANGER 0x04
  3249. #define LOADING_MECHANISM_CARTRIDGE_CHANGER 0x05
  3250. //
  3251. // end C/DVD 0.9 mode page definitions
  3252. //
  3253. // Mode parameter list block descriptor -
  3254. // set the block length for reading/writing
  3255. //
  3256. //
  3257. #define MODE_BLOCK_DESC_LENGTH 8
  3258. #define MODE_HEADER_LENGTH 4
  3259. #define MODE_HEADER_LENGTH10 8
  3260. typedef struct _MODE_PARM_READ_WRITE {
  3261. MODE_PARAMETER_HEADER ParameterListHeader; // List Header Format
  3262. MODE_PARAMETER_BLOCK ParameterListBlock; // List Block Descriptor
  3263. } MODE_PARM_READ_WRITE_DATA, *PMODE_PARM_READ_WRITE_DATA;
  3264. //
  3265. // Tape definitions
  3266. //
  3267. typedef struct _TAPE_POSITION_DATA {
  3268. UCHAR Reserved1:2;
  3269. UCHAR BlockPositionUnsupported:1;
  3270. UCHAR Reserved2:3;
  3271. UCHAR EndOfPartition:1;
  3272. UCHAR BeginningOfPartition:1;
  3273. UCHAR PartitionNumber;
  3274. USHORT Reserved3;
  3275. UCHAR FirstBlock[4];
  3276. UCHAR LastBlock[4];
  3277. UCHAR Reserved4;
  3278. UCHAR NumberOfBlocks[3];
  3279. UCHAR NumberOfBytes[4];
  3280. } TAPE_POSITION_DATA, *PTAPE_POSITION_DATA;
  3281. //
  3282. // This structure is used to convert little endian
  3283. // ULONGs to SCSI CDB big endians values.
  3284. //
  3285. typedef union _EIGHT_BYTE {
  3286. struct {
  3287. UCHAR Byte0;
  3288. UCHAR Byte1;
  3289. UCHAR Byte2;
  3290. UCHAR Byte3;
  3291. UCHAR Byte4;
  3292. UCHAR Byte5;
  3293. UCHAR Byte6;
  3294. UCHAR Byte7;
  3295. };
  3296. ULONGLONG AsULongLong;
  3297. } EIGHT_BYTE, *PEIGHT_BYTE;
  3298. typedef union _FOUR_BYTE {
  3299. struct {
  3300. UCHAR Byte0;
  3301. UCHAR Byte1;
  3302. UCHAR Byte2;
  3303. UCHAR Byte3;
  3304. };
  3305. ULONG AsULong;
  3306. } FOUR_BYTE, *PFOUR_BYTE;
  3307. typedef union _TWO_BYTE {
  3308. struct {
  3309. UCHAR Byte0;
  3310. UCHAR Byte1;
  3311. };
  3312. USHORT AsUShort;
  3313. } TWO_BYTE, *PTWO_BYTE;
  3314. //
  3315. // Byte reversing macro for converting
  3316. // between big- and little-endian formats
  3317. //
  3318. #define REVERSE_BYTES_QUAD(Destination, Source) { \
  3319. PEIGHT_BYTE d = (PEIGHT_BYTE)(Destination); \
  3320. PEIGHT_BYTE s = (PEIGHT_BYTE)(Source); \
  3321. d->Byte7 = s->Byte0; \
  3322. d->Byte6 = s->Byte1; \
  3323. d->Byte5 = s->Byte2; \
  3324. d->Byte4 = s->Byte3; \
  3325. d->Byte3 = s->Byte4; \
  3326. d->Byte2 = s->Byte5; \
  3327. d->Byte1 = s->Byte6; \
  3328. d->Byte0 = s->Byte7; \
  3329. }
  3330. #define REVERSE_BYTES(Destination, Source) { \
  3331. PFOUR_BYTE d = (PFOUR_BYTE)(Destination); \
  3332. PFOUR_BYTE s = (PFOUR_BYTE)(Source); \
  3333. d->Byte3 = s->Byte0; \
  3334. d->Byte2 = s->Byte1; \
  3335. d->Byte1 = s->Byte2; \
  3336. d->Byte0 = s->Byte3; \
  3337. }
  3338. #define REVERSE_BYTES_SHORT(Destination, Source) { \
  3339. PTWO_BYTE d = (PTWO_BYTE)(Destination); \
  3340. PTWO_BYTE s = (PTWO_BYTE)(Source); \
  3341. d->Byte1 = s->Byte0; \
  3342. d->Byte0 = s->Byte1; \
  3343. }
  3344. //
  3345. // Byte reversing macro for converting
  3346. // USHORTS from big to little endian in place
  3347. //
  3348. #define REVERSE_SHORT(Short) { \
  3349. UCHAR tmp; \
  3350. PTWO_BYTE w = (PTWO_BYTE)(Short); \
  3351. tmp = w->Byte0; \
  3352. w->Byte0 = w->Byte1; \
  3353. w->Byte1 = tmp; \
  3354. }
  3355. //
  3356. // Byte reversing macro for convering
  3357. // ULONGS between big & little endian in place
  3358. //
  3359. #define REVERSE_LONG(Long) { \
  3360. UCHAR tmp; \
  3361. PFOUR_BYTE l = (PFOUR_BYTE)(Long); \
  3362. tmp = l->Byte3; \
  3363. l->Byte3 = l->Byte0; \
  3364. l->Byte0 = tmp; \
  3365. tmp = l->Byte2; \
  3366. l->Byte2 = l->Byte1; \
  3367. l->Byte1 = tmp; \
  3368. }
  3369. //
  3370. // This macro has the effect of Bit = log2(Data)
  3371. //
  3372. #define WHICH_BIT(Data, Bit) { \
  3373. UCHAR tmp; \
  3374. for (tmp = 0; tmp < 32; tmp++) { \
  3375. if (((Data) >> tmp) == 1) { \
  3376. break; \
  3377. } \
  3378. } \
  3379. ASSERT(tmp != 32); \
  3380. (Bit) = tmp; \
  3381. }
  3382. #if defined DebugPrint
  3383. #undef DebugPrint
  3384. #endif
  3385. #if DBG
  3386. #define DebugPrint(x) TapeDebugPrint x
  3387. #else
  3388. #define DebugPrint(x)
  3389. #endif // DBG
  3390. //
  3391. // Define Device Configuration Page
  3392. //
  3393. typedef struct _MODE_DEVICE_CONFIGURATION_PAGE {
  3394. UCHAR PageCode : 6;
  3395. UCHAR Reserved1 : 1;
  3396. UCHAR PS : 1;
  3397. UCHAR PageLength;
  3398. UCHAR ActiveFormat : 5;
  3399. UCHAR CAFBit : 1;
  3400. UCHAR CAPBit : 1;
  3401. UCHAR Reserved2 : 1;
  3402. UCHAR ActivePartition;
  3403. UCHAR WriteBufferFullRatio;
  3404. UCHAR ReadBufferEmptyRatio;
  3405. UCHAR WriteDelayTime[2];
  3406. UCHAR REW : 1;
  3407. UCHAR RBO : 1;
  3408. UCHAR SOCF : 2;
  3409. UCHAR AVC : 1;
  3410. UCHAR RSmk : 1;
  3411. UCHAR BIS : 1;
  3412. UCHAR DBR : 1;
  3413. UCHAR GapSize;
  3414. UCHAR Reserved3 : 3;
  3415. UCHAR SEW : 1;
  3416. UCHAR EEG : 1;
  3417. UCHAR EODdefined : 3;
  3418. UCHAR BufferSize[3];
  3419. UCHAR DCAlgorithm;
  3420. UCHAR Reserved4;
  3421. } MODE_DEVICE_CONFIGURATION_PAGE, *PMODE_DEVICE_CONFIGURATION_PAGE;
  3422. //
  3423. // Define Medium Partition Page
  3424. //
  3425. typedef struct _MODE_MEDIUM_PARTITION_PAGE {
  3426. UCHAR PageCode : 6;
  3427. UCHAR Reserved1 : 1;
  3428. UCHAR PSBit : 1;
  3429. UCHAR PageLength;
  3430. UCHAR MaximumAdditionalPartitions;
  3431. UCHAR AdditionalPartitionDefined;
  3432. UCHAR Reserved2 : 3;
  3433. UCHAR PSUMBit : 2;
  3434. UCHAR IDPBit : 1;
  3435. UCHAR SDPBit : 1;
  3436. UCHAR FDPBit : 1;
  3437. UCHAR MediumFormatRecognition;
  3438. UCHAR Reserved3[2];
  3439. UCHAR Partition0Size[2];
  3440. UCHAR Partition1Size[2];
  3441. } MODE_MEDIUM_PARTITION_PAGE, *PMODE_MEDIUM_PARTITION_PAGE;
  3442. //
  3443. // Define Data Compression Page
  3444. //
  3445. typedef struct _MODE_DATA_COMPRESSION_PAGE {
  3446. UCHAR PageCode : 6;
  3447. UCHAR Reserved1 : 2;
  3448. UCHAR PageLength;
  3449. UCHAR Reserved2 : 6;
  3450. UCHAR DCC : 1;
  3451. UCHAR DCE : 1;
  3452. UCHAR Reserved3 : 5;
  3453. UCHAR RED : 2;
  3454. UCHAR DDE : 1;
  3455. UCHAR CompressionAlgorithm[4];
  3456. UCHAR DecompressionAlgorithm[4];
  3457. UCHAR Reserved4[4];
  3458. } MODE_DATA_COMPRESSION_PAGE, *PMODE_DATA_COMPRESSION_PAGE;
  3459. //
  3460. // Define capabilites and mechanical status page.
  3461. //
  3462. typedef struct _MODE_CAPABILITIES_PAGE {
  3463. UCHAR PageCode : 6;
  3464. UCHAR Reserved1 : 2;
  3465. UCHAR PageLength;
  3466. UCHAR Reserved2[2];
  3467. UCHAR RO : 1;
  3468. UCHAR Reserved3 : 4;
  3469. UCHAR SPREV : 1;
  3470. UCHAR Reserved4 : 2;
  3471. UCHAR Reserved5 : 3;
  3472. UCHAR EFMT : 1;
  3473. UCHAR Reserved6 : 1;
  3474. UCHAR QFA : 1;
  3475. UCHAR Reserved7 : 2;
  3476. UCHAR LOCK : 1;
  3477. UCHAR LOCKED : 1;
  3478. UCHAR PREVENT : 1;
  3479. UCHAR UNLOAD : 1;
  3480. UCHAR Reserved8 : 2;
  3481. UCHAR ECC : 1;
  3482. UCHAR CMPRS : 1;
  3483. UCHAR Reserved9 : 1;
  3484. UCHAR BLK512 : 1;
  3485. UCHAR BLK1024 : 1;
  3486. UCHAR Reserved10 : 4;
  3487. UCHAR SLOWB : 1;
  3488. UCHAR MaximumSpeedSupported[2];
  3489. UCHAR MaximumStoredDefectedListEntries[2];
  3490. UCHAR ContinuousTransferLimit[2];
  3491. UCHAR CurrentSpeedSelected[2];
  3492. UCHAR BufferSize[2];
  3493. UCHAR Reserved11[2];
  3494. } MODE_CAPABILITIES_PAGE, *PMODE_CAPABILITIES_PAGE;
  3495. typedef struct _MODE_CAP_PAGE {
  3496. MODE_PARAMETER_HEADER ParameterListHeader;
  3497. MODE_PARAMETER_BLOCK ParameterListBlock;
  3498. MODE_CAPABILITIES_PAGE CapabilitiesPage;
  3499. } MODE_CAP_PAGE, *PMODE_CAP_PAGE;
  3500. //
  3501. // Mode parameter list header and medium partition page -
  3502. // used in creating partitions
  3503. //
  3504. typedef struct _MODE_MEDIUM_PART_PAGE {
  3505. MODE_PARAMETER_HEADER ParameterListHeader;
  3506. MODE_MEDIUM_PARTITION_PAGE MediumPartPage;
  3507. } MODE_MEDIUM_PART_PAGE, *PMODE_MEDIUM_PART_PAGE;
  3508. typedef struct _MODE_MEDIUM_PART_PAGE_PLUS {
  3509. MODE_PARAMETER_HEADER ParameterListHeader;
  3510. MODE_PARAMETER_BLOCK ParameterListBlock;
  3511. MODE_MEDIUM_PARTITION_PAGE MediumPartPage;
  3512. } MODE_MEDIUM_PART_PAGE_PLUS, *PMODE_MEDIUM_PART_PAGE_PLUS;
  3513. //
  3514. // Mode parameters for retrieving tape or media information
  3515. //
  3516. typedef struct _MODE_TAPE_MEDIA_INFORMATION {
  3517. MODE_PARAMETER_HEADER ParameterListHeader;
  3518. MODE_PARAMETER_BLOCK ParameterListBlock;
  3519. MODE_MEDIUM_PARTITION_PAGE MediumPartPage;
  3520. } MODE_TAPE_MEDIA_INFORMATION, *PMODE_TAPE_MEDIA_INFORMATION;
  3521. //
  3522. // Mode parameter list header and device configuration page -
  3523. // used in retrieving device configuration information
  3524. //
  3525. typedef struct _MODE_DEVICE_CONFIG_PAGE {
  3526. MODE_PARAMETER_HEADER ParameterListHeader;
  3527. MODE_DEVICE_CONFIGURATION_PAGE DeviceConfigPage;
  3528. } MODE_DEVICE_CONFIG_PAGE, *PMODE_DEVICE_CONFIG_PAGE;
  3529. typedef struct _MODE_DEVICE_CONFIG_PAGE_PLUS {
  3530. MODE_PARAMETER_HEADER ParameterListHeader;
  3531. MODE_PARAMETER_BLOCK ParameterListBlock;
  3532. MODE_DEVICE_CONFIGURATION_PAGE DeviceConfigPage;
  3533. } MODE_DEVICE_CONFIG_PAGE_PLUS, *PMODE_DEVICE_CONFIG_PAGE_PLUS ;
  3534. //
  3535. // Mode parameter list header and data compression page -
  3536. // used in retrieving data compression information
  3537. //
  3538. typedef struct _MODE_DATA_COMPRESS_PAGE {
  3539. MODE_PARAMETER_HEADER ParameterListHeader;
  3540. MODE_DATA_COMPRESSION_PAGE DataCompressPage;
  3541. } MODE_DATA_COMPRESS_PAGE, *PMODE_DATA_COMPRESS_PAGE;
  3542. typedef struct _MODE_DATA_COMPRESS_PAGE_PLUS {
  3543. MODE_PARAMETER_HEADER ParameterListHeader;
  3544. MODE_PARAMETER_BLOCK ParameterListBlock;
  3545. MODE_DATA_COMPRESSION_PAGE DataCompressPage;
  3546. } MODE_DATA_COMPRESS_PAGE_PLUS, *PMODE_DATA_COMPRESS_PAGE_PLUS;
  3547. //
  3548. // Tape/Minitape definition.
  3549. //
  3550. typedef
  3551. BOOLEAN
  3552. (*TAPE_VERIFY_INQUIRY_ROUTINE)(
  3553. IN PINQUIRYDATA InquiryData,
  3554. IN PMODE_CAPABILITIES_PAGE ModeCapabilitiesPage
  3555. );
  3556. typedef
  3557. VOID
  3558. (*TAPE_EXTENSION_INIT_ROUTINE)(
  3559. IN PVOID MinitapeExtension,
  3560. IN PINQUIRYDATA InquiryData,
  3561. IN PMODE_CAPABILITIES_PAGE ModeCapabilitiesPage
  3562. );
  3563. typedef enum _TAPE_STATUS {
  3564. TAPE_STATUS_SEND_SRB_AND_CALLBACK,
  3565. TAPE_STATUS_CALLBACK,
  3566. TAPE_STATUS_CHECK_TEST_UNIT_READY,
  3567. TAPE_STATUS_SUCCESS,
  3568. TAPE_STATUS_INSUFFICIENT_RESOURCES,
  3569. TAPE_STATUS_NOT_IMPLEMENTED,
  3570. TAPE_STATUS_INVALID_DEVICE_REQUEST,
  3571. TAPE_STATUS_INVALID_PARAMETER,
  3572. TAPE_STATUS_MEDIA_CHANGED,
  3573. TAPE_STATUS_BUS_RESET,
  3574. TAPE_STATUS_SETMARK_DETECTED,
  3575. TAPE_STATUS_FILEMARK_DETECTED,
  3576. TAPE_STATUS_BEGINNING_OF_MEDIA,
  3577. TAPE_STATUS_END_OF_MEDIA,
  3578. TAPE_STATUS_BUFFER_OVERFLOW,
  3579. TAPE_STATUS_NO_DATA_DETECTED,
  3580. TAPE_STATUS_EOM_OVERFLOW,
  3581. TAPE_STATUS_NO_MEDIA,
  3582. TAPE_STATUS_IO_DEVICE_ERROR,
  3583. TAPE_STATUS_UNRECOGNIZED_MEDIA,
  3584. TAPE_STATUS_DEVICE_NOT_READY,
  3585. TAPE_STATUS_MEDIA_WRITE_PROTECTED,
  3586. TAPE_STATUS_DEVICE_DATA_ERROR,
  3587. TAPE_STATUS_NO_SUCH_DEVICE,
  3588. TAPE_STATUS_INVALID_BLOCK_LENGTH,
  3589. TAPE_STATUS_IO_TIMEOUT,
  3590. TAPE_STATUS_DEVICE_NOT_CONNECTED,
  3591. TAPE_STATUS_DATA_OVERRUN,
  3592. TAPE_STATUS_DEVICE_BUSY,
  3593. TAPE_STATUS_REQUIRES_CLEANING,
  3594. TAPE_STATUS_CLEANER_CARTRIDGE_INSTALLED
  3595. } TAPE_STATUS, *PTAPE_STATUS;
  3596. typedef
  3597. VOID
  3598. (*TAPE_ERROR_ROUTINE)(
  3599. IN PVOID MinitapeExtension,
  3600. IN PSCSI_REQUEST_BLOCK Srb,
  3601. IN OUT PTAPE_STATUS TapeStatus
  3602. );
  3603. #define TAPE_RETRY_MASK 0x0000FFFF
  3604. #define IGNORE_ERRORS 0x00010000
  3605. #define RETURN_ERRORS 0x00020000
  3606. typedef
  3607. TAPE_STATUS
  3608. (*TAPE_PROCESS_COMMAND_ROUTINE)(
  3609. IN OUT PVOID MinitapeExtension,
  3610. IN OUT PVOID CommandExtension,
  3611. IN OUT PVOID CommandParameters,
  3612. IN OUT PSCSI_REQUEST_BLOCK Srb,
  3613. IN ULONG CallNumber,
  3614. IN TAPE_STATUS StatusOfLastCommand,
  3615. IN OUT PULONG RetryFlags
  3616. );
  3617. //
  3618. // NT 4.0 miniclass drivers will be using this.
  3619. //
  3620. typedef struct _TAPE_INIT_DATA {
  3621. TAPE_VERIFY_INQUIRY_ROUTINE VerifyInquiry;
  3622. BOOLEAN QueryModeCapabilitiesPage ;
  3623. ULONG MinitapeExtensionSize;
  3624. TAPE_EXTENSION_INIT_ROUTINE ExtensionInit; /* OPTIONAL */
  3625. ULONG DefaultTimeOutValue; /* OPTIONAL */
  3626. TAPE_ERROR_ROUTINE TapeError; /* OPTIONAL */
  3627. ULONG CommandExtensionSize;
  3628. TAPE_PROCESS_COMMAND_ROUTINE CreatePartition;
  3629. TAPE_PROCESS_COMMAND_ROUTINE Erase;
  3630. TAPE_PROCESS_COMMAND_ROUTINE GetDriveParameters;
  3631. TAPE_PROCESS_COMMAND_ROUTINE GetMediaParameters;
  3632. TAPE_PROCESS_COMMAND_ROUTINE GetPosition;
  3633. TAPE_PROCESS_COMMAND_ROUTINE GetStatus;
  3634. TAPE_PROCESS_COMMAND_ROUTINE Prepare;
  3635. TAPE_PROCESS_COMMAND_ROUTINE SetDriveParameters;
  3636. TAPE_PROCESS_COMMAND_ROUTINE SetMediaParameters;
  3637. TAPE_PROCESS_COMMAND_ROUTINE SetPosition;
  3638. TAPE_PROCESS_COMMAND_ROUTINE WriteMarks;
  3639. TAPE_PROCESS_COMMAND_ROUTINE PreProcessReadWrite;
  3640. } TAPE_INIT_DATA, *PTAPE_INIT_DATA;
  3641. typedef struct _TAPE_INIT_DATA_EX {
  3642. //
  3643. // Size of this structure.
  3644. //
  3645. ULONG InitDataSize;
  3646. //
  3647. // Keep the 4.0 init data as is, so support of these
  3648. // drivers can be as seamless as possible.
  3649. //
  3650. TAPE_VERIFY_INQUIRY_ROUTINE VerifyInquiry;
  3651. BOOLEAN QueryModeCapabilitiesPage ;
  3652. ULONG MinitapeExtensionSize;
  3653. TAPE_EXTENSION_INIT_ROUTINE ExtensionInit; /* OPTIONAL */
  3654. ULONG DefaultTimeOutValue; /* OPTIONAL */
  3655. TAPE_ERROR_ROUTINE TapeError; /* OPTIONAL */
  3656. ULONG CommandExtensionSize;
  3657. TAPE_PROCESS_COMMAND_ROUTINE CreatePartition;
  3658. TAPE_PROCESS_COMMAND_ROUTINE Erase;
  3659. TAPE_PROCESS_COMMAND_ROUTINE GetDriveParameters;
  3660. TAPE_PROCESS_COMMAND_ROUTINE GetMediaParameters;
  3661. TAPE_PROCESS_COMMAND_ROUTINE GetPosition;
  3662. TAPE_PROCESS_COMMAND_ROUTINE GetStatus;
  3663. TAPE_PROCESS_COMMAND_ROUTINE Prepare;
  3664. TAPE_PROCESS_COMMAND_ROUTINE SetDriveParameters;
  3665. TAPE_PROCESS_COMMAND_ROUTINE SetMediaParameters;
  3666. TAPE_PROCESS_COMMAND_ROUTINE SetPosition;
  3667. TAPE_PROCESS_COMMAND_ROUTINE WriteMarks;
  3668. TAPE_PROCESS_COMMAND_ROUTINE PreProcessReadWrite;
  3669. //
  3670. // New entry points / information for 5.0
  3671. //
  3672. // Returns supported media types for the device.
  3673. //
  3674. TAPE_PROCESS_COMMAND_ROUTINE TapeGetMediaTypes;
  3675. //
  3676. // Indicates the number of different types the drive supports.
  3677. //
  3678. ULONG MediaTypesSupported;
  3679. //
  3680. // Entry point for all WMI operations that the driver/device supports.
  3681. //
  3682. TAPE_PROCESS_COMMAND_ROUTINE TapeWMIOperations;
  3683. ULONG Reserved[2];
  3684. } TAPE_INIT_DATA_EX, *PTAPE_INIT_DATA_EX;
  3685. SCSIPORT_API
  3686. ULONG
  3687. TapeClassInitialize(
  3688. IN PVOID Argument1,
  3689. IN PVOID Argument2,
  3690. IN PTAPE_INIT_DATA_EX TapeInitData
  3691. );
  3692. SCSIPORT_API
  3693. BOOLEAN
  3694. TapeClassAllocateSrbBuffer(
  3695. IN OUT PSCSI_REQUEST_BLOCK Srb,
  3696. IN ULONG SrbBufferSize
  3697. );
  3698. SCSIPORT_API
  3699. VOID
  3700. TapeClassZeroMemory(
  3701. IN OUT PVOID Buffer,
  3702. IN ULONG BufferSize
  3703. );
  3704. SCSIPORT_API
  3705. ULONG
  3706. TapeClassCompareMemory(
  3707. IN OUT PVOID Source1,
  3708. IN OUT PVOID Source2,
  3709. IN ULONG Length
  3710. );
  3711. SCSIPORT_API
  3712. LARGE_INTEGER
  3713. TapeClassLiDiv(
  3714. IN LARGE_INTEGER Dividend,
  3715. IN LARGE_INTEGER Divisor
  3716. );
  3717. SCSIPORT_API
  3718. VOID
  3719. TapeDebugPrint(
  3720. ULONG DebugPrintLevel,
  3721. PCCHAR DebugMessage,
  3722. ...
  3723. );
  3724. //
  3725. // defines for QIC tape density codes
  3726. //
  3727. #define QIC_XX 0 // ????
  3728. #define QIC_24 5 // 0x05
  3729. #define QIC_120 15 // 0x0F
  3730. #define QIC_150 16 // 0x10
  3731. #define QIC_525 17 // 0x11
  3732. #define QIC_1350 18 // 0x12
  3733. #define QIC_1000 21 // 0x15
  3734. #define QIC_1000C 30 // 0x1E
  3735. #define QIC_2100 31 // 0x1F
  3736. #define QIC_2GB 34 // 0x22
  3737. #define QIC_5GB 40 // 0x28
  3738. //
  3739. // defines for QIC tape media codes
  3740. //
  3741. #define DCXXXX 0
  3742. #define DC300 1
  3743. #define DC300XLP 2
  3744. #define DC615 3
  3745. #define DC600 4
  3746. #define DC6037 5
  3747. #define DC6150 6
  3748. #define DC6250 7
  3749. #define DC6320 8
  3750. #define DC6525 9
  3751. #define DC9135SL 33 //0x21
  3752. #define DC9210 34 //0x22
  3753. #define DC9135 35 //0x23
  3754. #define DC9100 36 //0x24
  3755. #define DC9120 37 //0x25
  3756. #define DC9120SL 38 //0x26
  3757. #define DC9164 39 //0x27
  3758. #define DCXXXXFW 48 //0x30
  3759. #define DC9200SL 49 //0x31
  3760. #define DC9210XL 50 //0x32
  3761. #define DC10GB 51 //0x33
  3762. #define DC9200 52 //0x34
  3763. #define DC9120XL 53 //0x35
  3764. #define DC9210SL 54 //0x36
  3765. #define DC9164XL 55 //0x37
  3766. #define DC9200XL 64 //0x40
  3767. #define DC9400 65 //0x41
  3768. #define DC9500 66 //0x42
  3769. #define DC9500SL 70 //0x46
  3770. //
  3771. // defines for translation reference point
  3772. //
  3773. #define NOT_FROM_BOT 0
  3774. #define FROM_BOT 1
  3775. //
  3776. // info/structure returned by/from
  3777. // TapeLogicalBlockToPhysicalBlock( )
  3778. //
  3779. typedef struct _TAPE_PHYS_POSITION {
  3780. ULONG SeekBlockAddress;
  3781. ULONG SpaceBlockCount;
  3782. } TAPE_PHYS_POSITION, PTAPE_PHYS_POSITION;
  3783. //
  3784. // function prototypes
  3785. //
  3786. TAPE_PHYS_POSITION
  3787. TapeClassLogicalBlockToPhysicalBlock(
  3788. IN UCHAR DensityCode,
  3789. IN ULONG LogicalBlockAddress,
  3790. IN ULONG BlockLength,
  3791. IN BOOLEAN FromBOT
  3792. );
  3793. ULONG
  3794. TapeClassPhysicalBlockToLogicalBlock(
  3795. IN UCHAR DensityCode,
  3796. IN ULONG PhysicalBlockAddress,
  3797. IN ULONG BlockLength,
  3798. IN BOOLEAN FromBOT
  3799. );
  3800. //
  3801. // LOG SENSE Page codes
  3802. //
  3803. #define TapeAlertLogPage 0x2E
  3804. //
  3805. // Type of tape drive alert information
  3806. // supported by the drive.
  3807. // For example, if the type is TapeAlertInfoNone, the drive doesn't
  3808. // support any alert info. Need to use read\write error counters
  3809. // to predict drive problems. If the type is TapeAlertInfoRequestSense,
  3810. // request sense command can be used to determine drive problems.
  3811. //
  3812. typedef enum _TAPE_ALERT_INFO_TYPE {
  3813. TapeAlertInfoNone,
  3814. TapeAlertInfoRequestSense,
  3815. TapeAlertInfoLogPage
  3816. } TAPE_ALERT_INFO_TYPE;
  3817. //
  3818. // Tape alert information
  3819. //
  3820. #define READ_WARNING 1
  3821. #define WRITE_WARNING 2
  3822. #define HARD_ERROR 3
  3823. #define MEDIA_ERROR 4
  3824. #define READ_FAILURE 5
  3825. #define WRITE_FAILURE 6
  3826. #define MEDIA_LIFE 7
  3827. #define NOT_DATA_GRADE 8
  3828. #define WRITE_PROTECT 9
  3829. #define NO_REMOVAL 10
  3830. #define CLEANING_MEDIA 11
  3831. #define UNSUPPORTED_FORMAT 12
  3832. #define SNAPPED_TAPE 13
  3833. #define CLEAN_NOW 20
  3834. #define CLEAN_PERIODIC 21
  3835. #define EXPIRED_CLEANING_MEDIA 22
  3836. #define HARDWARE_A 30
  3837. #define HARDWARE_B 31
  3838. #define INTERFACE_ERROR 32
  3839. #define EJECT_MEDIA 33
  3840. #define DOWNLOAD_FAIL 34
  3841. //
  3842. // The following structs are duplicated from wmidata.h
  3843. // wmidata.h is generated from wmicore.mof file. Should
  3844. // the MOF file change for these structs, the corresponding
  3845. // change should be made in these structs also.
  3846. // Since minidrivers do not have access wmidata.h, we need
  3847. // to duplicate it here.
  3848. //
  3849. // ISSUE : 02/28/2000 - nramas : Should find a better way to
  3850. // handle the above. Duplication will cause problems in keeping
  3851. // these definitions in sync.
  3852. //
  3853. typedef struct _WMI_TAPE_DRIVE_PARAMETERS
  3854. {
  3855. // Maximum block size supported
  3856. ULONG MaximumBlockSize;
  3857. // Minimum block size supported
  3858. ULONG MinimumBlockSize;
  3859. // Default block size supported
  3860. ULONG DefaultBlockSize;
  3861. // Maximum number of partitions allowed.
  3862. ULONG MaximumPartitionCount;
  3863. // TRUE if drive supports compression.
  3864. BOOLEAN CompressionCapable;
  3865. // TRUE if compression is enabled.
  3866. BOOLEAN CompressionEnabled;
  3867. // TRUE if drive reports setmarks
  3868. BOOLEAN ReportSetmarks;
  3869. // TRUE if drive supports hardware error correction
  3870. BOOLEAN HardwareErrorCorrection;
  3871. } WMI_TAPE_DRIVE_PARAMETERS, *PWMI_TAPE_DRIVE_PARAMETERS;
  3872. typedef struct _WMI_TAPE_MEDIA_PARAMETERS
  3873. {
  3874. // Maximum capacity of the media
  3875. ULONGLONG MaximumCapacity;
  3876. // Available capacity of the media
  3877. ULONGLONG AvailableCapacity;
  3878. // Current blocksize
  3879. ULONG BlockSize;
  3880. // Current number of partitions
  3881. ULONG PartitionCount;
  3882. // TRUEif media is write protected
  3883. BOOLEAN MediaWriteProtected;
  3884. } WMI_TAPE_MEDIA_PARAMETERS, *PWMI_TAPE_MEDIA_PARAMETERS;
  3885. typedef struct _WMI_TAPE_PROBLEM_WARNING
  3886. {
  3887. // Tape drive problem warning event
  3888. ULONG DriveProblemType;
  3889. // Tape drive problem data
  3890. UCHAR TapeData[512];
  3891. } WMI_TAPE_PROBLEM_WARNING, *PWMI_TAPE_PROBLEM_WARNING;
  3892. typedef struct _WMI_TAPE_PROBLEM_IO_ERROR
  3893. {
  3894. // Read errors corrected without much delay
  3895. ULONG ReadCorrectedWithoutDelay;
  3896. // Read errors corrected with substantial delay
  3897. ULONG ReadCorrectedWithDelay;
  3898. // Total number of Read errors
  3899. ULONG ReadTotalErrors;
  3900. // Total number of read errors that were corrected
  3901. ULONG ReadTotalCorrectedErrors;
  3902. // Total number of uncorrected read errors
  3903. ULONG ReadTotalUncorrectedErrors;
  3904. // Number of times correction algorithm was processed for read
  3905. ULONG ReadCorrectionAlgorithmProcessed;
  3906. // Write errors corrected without much delay
  3907. ULONG WriteCorrectedWithoutDelay;
  3908. // Write errors corrected with substantial delay
  3909. ULONG WriteCorrectedWithDelay;
  3910. // Total number of Read errors
  3911. ULONG WriteTotalErrors;
  3912. // Total number of write errors that were corrected
  3913. ULONG WriteTotalCorrectedErrors;
  3914. // Total number of uncorrected write errors
  3915. ULONG WriteTotalUncorrectedErrors;
  3916. // Number of times correction algorithm was processed for write
  3917. ULONG WriteCorrectionAlgorithmProcessed;
  3918. // Errors not related to medium
  3919. ULONG NonMediumErrors;
  3920. } WMI_TAPE_PROBLEM_IO_ERROR, *PWMI_TAPE_PROBLEM_IO_ERROR;
  3921. typedef struct _WMI_TAPE_PROBLEM_DEVICE_ERROR
  3922. {
  3923. // WARNING : Drive is experiencing read problem.
  3924. BOOLEAN ReadWarning;
  3925. // WARNING : Drive is experiencing write problem.
  3926. BOOLEAN WriteWarning;
  3927. // Drive hardware problem
  3928. BOOLEAN HardError;
  3929. // Critical Error : Too many read errors.
  3930. BOOLEAN ReadFailure;
  3931. // Critical Error : Too many write errors.
  3932. BOOLEAN WriteFailure;
  3933. // Tape format not supported
  3934. BOOLEAN UnsupportedFormat;
  3935. // Tape is snapped. Replace media
  3936. BOOLEAN TapeSnapped;
  3937. // Drive Requires Cleaning
  3938. BOOLEAN DriveRequiresCleaning;
  3939. // It's time to clean the drive
  3940. BOOLEAN TimetoCleanDrive;
  3941. // Hardware error. Check drive
  3942. BOOLEAN DriveHardwareError;
  3943. // Some error in cabling, or connection.
  3944. BOOLEAN ScsiInterfaceError;
  3945. // Critical Error : Media life expired.
  3946. BOOLEAN MediaLife;
  3947. } WMI_TAPE_PROBLEM_DEVICE_ERROR, *PWMI_TAPE_PROBLEM_DEVICE_ERROR;
  3948. #endif /* _MINITAPE_ */