Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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