Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

304 lines
11 KiB

  1. /****************************************************************************
  2. **
  3. ** Copyright 1999 Adaptec, Inc., All Rights Reserved.
  4. **
  5. ** This software contains the valuable trade secrets of Adaptec. The
  6. ** software is protected under copyright laws as an unpublished work of
  7. ** Adaptec. Notice is for informational purposes only and does not imply
  8. ** publication. The user of this software may make copies of the software
  9. ** for use with parts manufactured by Adaptec or under license from Adaptec
  10. ** and for no other use.
  11. **
  12. ****************************************************************************/
  13. /****************************************************************************
  14. **
  15. ** Module Name: imapipub.h
  16. **
  17. ** Description: Definitions of all the IOCTLs and their structures that
  18. ** can be used with IMAPIW2K.SYS. Note that the structures
  19. ** are used for either KMD->KMD submission, or for ring-3
  20. ** to KMD submission.
  21. **
  22. ** Programmers: Daniel Evers (dle)
  23. ** Tom Halloran (tgh)
  24. ** Don Lilly (drl)
  25. ** Daniel Polfer (dap)
  26. **
  27. ** History: 8/25/99 (dap) Opened history and added header.
  28. **
  29. ** Notes: This file created using 4 spaces per tab.
  30. **
  31. ****************************************************************************/
  32. #ifndef __IMAPIPUB_H_
  33. #define __IMAPIPUB_H_
  34. #if _MSC_VER > 1000
  35. #pragma once
  36. #endif
  37. #ifndef DEVICE_TYPE
  38. #define DEVICE_TYPE ULONG
  39. #endif
  40. #include <ntddstor.h> // sdk
  41. #ifdef __cplusplus
  42. extern "C" {
  43. #endif
  44. /*
  45. ** Globally unique identifer for the interface class of our device.
  46. */
  47. // {1186654D-47B8-48b9-BEB9-7DF113AE3C67}
  48. static const GUID IMAPIDeviceInterfaceGuid =
  49. { 0x1186654d, 0x47b8, 0x48b9, { 0xbe, 0xb9, 0x7d, 0xf1, 0x13, 0xae, 0x3c, 0x67 } };
  50. // v 20.20 had everything in this file pack(1)'d, which caused all sorts of
  51. // alignment faults. what was Roxio thinking?
  52. #define IMAPIAPI_VERSION_HI 48
  53. #define IMAPIAPI_VERSION_LO 48
  54. #define FILE_DEVICE_IMAPI 0x90DA
  55. /*
  56. ** ----------------------------------------------------------------------------
  57. ** IOCTL_IMAPIDRV_INIT
  58. ** ----------------------------------------------------------------------------
  59. */
  60. #define IOCTL_IMAPIDRV_INIT ((ULONG)CTL_CODE(FILE_DEVICE_IMAPI,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS))
  61. typedef struct tag_IMAPIDRV_INIT
  62. {
  63. // (OUT) The version number for this API. Use this version to make sure
  64. // the structures and IOCTLs are compatible.
  65. ULONG Version;
  66. // Not currently used.
  67. ULONG Reserved;
  68. }
  69. IMAPIDRV_INIT, *PIMAPIDRV_INIT;
  70. /*
  71. ** ----------------------------------------------------------------------------
  72. ** IOCTL_IMAPIDRV_ENUMERATE -
  73. ** This IOCTL returns information about a specific drive. It gives global info
  74. ** such as the driver's UniqueID for the device, and its Inquiry data, etc.,
  75. ** and it also gives an instantaneous snap-shot of the devices state information.
  76. ** This state information is accurate at the moment it is collected, but can
  77. ** change immediately. Therefore the state info is best used for making general
  78. ** decisions such as if the device is in use (bOpenedExclusive), wait a while
  79. ** before seeing if it is available.
  80. ** ----------------------------------------------------------------------------
  81. */
  82. #define IOCTL_IMAPIDRV_INFO ((ULONG)CTL_CODE(FILE_DEVICE_IMAPI,0x810,METHOD_BUFFERED,FILE_READ_ACCESS | FILE_WRITE_ACCESS))
  83. #define UNIQUE_ID_LEN 256
  84. typedef enum tag_IMAPIDRV_DEVSTATE
  85. {
  86. eDevState_Started = 0x00, //IRP_MN_START_DEVICE
  87. eDevState_RemovePending = 0x01, //IRP_MN_QUERY_REMOVE_DEVICE,
  88. eDevState_Removed = 0x02, //IRP_MN_REMOVE_DEVICE,
  89. eDevState_Stopped = 0x04, //IRP_MN_STOP_DEVICE,
  90. eDevState_StopPending = 0x05, //IRP_MN_QUERY_STOP_DEVICE,
  91. eDevState_Unknown = 0xff
  92. }
  93. IMAPIDRV_DEVSTATE;
  94. typedef struct tag_IMAPIDRV_DEVICE
  95. {
  96. ULONG DeviceType;
  97. ULONG userDriveNumber; // for use by user mode side of things
  98. PVOID pUserUse; // for use by user mode side of things
  99. STORAGE_BUS_TYPE BusType;
  100. USHORT BusMajorVersion; // bus-specific data
  101. USHORT BusMinorVersion; // bus-specific data
  102. ULONG AlignmentMask;
  103. ULONG MaximumTransferLength;
  104. ULONG MaximumPhysicalPages;
  105. ULONG BufferUnderrunFreeCapable; // whether the drive support B.U.F. operation
  106. ULONG bInitialized; // 0 - no initialized yet, non-zero - initialized
  107. ULONG bOpenedExclusive; // 0 - not opened, non-zero - currently open by someone
  108. ULONG bBurning; // 0 - no burn process active, non-zero - the drive has started a burn process
  109. IMAPIDRV_DEVSTATE curDeviceState; // started, removed, etc., state of device
  110. DWORD idwRecorderType; // CD-R == 0x01, CD-RW == 0x10
  111. ULONG maxWriteSpeed; // 1, 2, 3, meaning 1X, 2X, etc. where X == 150KB/s (typical audio CD stream rate)
  112. BYTE scsiInquiryData[36]; // first portion of data returned from Inquiry CDB // CPF - needs to be 36 long to include revision info
  113. UCHAR UniqueId[UNIQUE_ID_LEN]; // ID assigned when IMAPI driver registered an interface for this device
  114. }
  115. IMAPIDRV_DEVICE, *PIMAPIDRV_DEVICE;
  116. typedef struct tag_IMAPIDRV_INFO
  117. {
  118. ULONG Version;
  119. ULONG NumberOfDevices;
  120. IMAPIDRV_DEVICE DeviceData;
  121. }
  122. IMAPIDRV_INFO, *PIMAPIDRV_INFO;
  123. // defines for idwRecorderType
  124. #define RECORDER_TYPE_CDR 0x00000001
  125. #define RECORDER_TYPE_CDRW 0x00000010
  126. /*
  127. ** ----------------------------------------------------------------------------
  128. ** IOCTL_IMAPIDRV_OPENEXCLUSIVE
  129. ** ----------------------------------------------------------------------------
  130. */
  131. #define IOCTL_IMAPIDRV_OPENEXCLUSIVE ((ULONG)CTL_CODE(FILE_DEVICE_IMAPI,0x820,METHOD_BUFFERED,FILE_ANY_ACCESS))
  132. typedef struct tag_IMAPIDRV_OPENEXCLUSIVE
  133. {
  134. HANDLE Handle;
  135. CHAR UniqueId[UNIQUE_ID_LEN]; // zero terminated string
  136. }
  137. IMAPIDRV_OPENEXCLUSIVE, *PIMAPIDRV_OPENEXCLUSIVE;
  138. /*
  139. ** ----------------------------------------------------------------------------
  140. ** IOCTL_IMAPIDRV_SENDCOMMAND
  141. ** ----------------------------------------------------------------------------
  142. */
  143. #define IOCTL_IMAPIDRV_SENDCOMMAND ((ULONG)CTL_CODE(FILE_DEVICE_IMAPI,0x830,METHOD_BUFFERED,FILE_READ_ACCESS | FILE_WRITE_ACCESS))
  144. /*
  145. ** IMAPISRB - The SCSI REQUEST BLOCK for IMAPI. It is simplified compared to
  146. ** the request block used in NT. It is handle based, for one thing, and it
  147. ** doesn't have a lot of fluff. See the NT docs, however, for information on
  148. ** individual fields.
  149. */
  150. #define MAX_SENSE_BYTES 18 // max. number of bytes in sense data
  151. typedef struct tag_IMAPIDRV_SRB
  152. {
  153. USHORT Version;
  154. UCHAR Function;
  155. UCHAR SrbStatus;
  156. UCHAR ScsiStatus;
  157. UCHAR CdbLength;
  158. UCHAR Reserved;
  159. UCHAR Reserved1;
  160. ULONG DataTransferLength;
  161. ULONG TimeOutValue;
  162. ULONG SrbFlags;
  163. PVOID DataBuffer;
  164. UCHAR Cdb[16];
  165. UCHAR SenseInfoBuffer[MAX_SENSE_BYTES];
  166. }
  167. IMAPIDRV_SRB, *PIMAPIDRV_SRB;
  168. /*
  169. ** IMAPISRB Functions - Subset of NT SCSI_REQUEST_BLOCK functions.
  170. */
  171. #define IMAPISRB_FUNCTION_EXECUTE_SCSI 0x00
  172. #define IMAPISRB_FUNCTION_FLUSH 0x08
  173. #define IMAPISRB_FUNCTION_ABORT_COMMAND 0x10
  174. #define IMAPISRB_FUNCTION_RESET_BUS 0x12
  175. #define IMAPISRB_FUNCTION_RESET_DEVICE 0x13
  176. /*
  177. ** IMAPISRB Status Codes - Same as NT SCSI_REQUEST_BLOCK codes.
  178. */
  179. #define IMAPISRB_STATUS_PENDING 0x00
  180. #define IMAPISRB_STATUS_SUCCESS 0x01
  181. #define IMAPISRB_STATUS_ABORTED 0x02
  182. #define IMAPISRB_STATUS_ABORT_FAILED 0x03
  183. #define IMAPISRB_STATUS_ERROR 0x04
  184. #define IMAPISRB_STATUS_BUSY 0x05
  185. #define IMAPISRB_STATUS_INVALID_REQUEST 0x06
  186. #define IMAPISRB_STATUS_INVALID_PATH_ID 0x07
  187. #define IMAPISRB_STATUS_NO_DEVICE 0x08
  188. #define IMAPISRB_STATUS_TIMEOUT 0x09
  189. #define IMAPISRB_STATUS_SELECTION_TIMEOUT 0x0A
  190. #define IMAPISRB_STATUS_COMMAND_TIMEOUT 0x0B
  191. #define IMAPISRB_STATUS_MESSAGE_REJECTED 0x0D
  192. #define IMAPISRB_STATUS_BUS_RESET 0x0E
  193. #define IMAPISRB_STATUS_PARITY_ERROR 0x0F
  194. #define IMAPISRB_STATUS_REQUEST_SENSE_FAILED 0x10
  195. #define IMAPISRB_STATUS_NO_HBA 0x11
  196. #define IMAPISRB_STATUS_DATA_OVERRUN 0x12
  197. #define IMAPISRB_STATUS_UNEXPECTED_BUS_FREE 0x13
  198. #define IMAPISRB_STATUS_PHASE_SEQUENCE_FAILURE 0x14
  199. #define IMAPISRB_STATUS_BAD_SRB_BLOCK_LENGTH 0x15
  200. #define IMAPISRB_STATUS_REQUEST_FLUSHED 0x16
  201. #define IMAPISRB_STATUS_INVALID_LUN 0x20
  202. #define IMAPISRB_STATUS_INVALID_TARGET_ID 0x21
  203. #define IMAPISRB_STATUS_BAD_FUNCTION 0x22
  204. #define IMAPISRB_STATUS_ERROR_RECOVERY 0x23
  205. #define IMAPISRB_STATUS_NOT_POWERED 0x24
  206. /*
  207. ** IMAPISRB Status Masks
  208. */
  209. #define IMAPISRB_STATUS_QUEUE_FROZEN 0x40
  210. #define IMAPISRB_STATUS_AUTOSENSE_VALID 0x80
  211. #define IMAPISRB_STATUS(Status) (Status & ~(IMAPISRB_STATUS_AUTOSENSE_VALID | IMAPISRB_STATUS_QUEUE_FROZEN))
  212. /*
  213. ** SCSI Status values
  214. */
  215. #define IMAPISRB_SCSISTATUS_GOOD 0x00
  216. #define IMAPISRB_SCSISTATUS_CHECK_CONDITION 0x02
  217. #define IMAPISRB_SCSISTATUS_BUSY 0x08
  218. #define IMAPISRB_SCSISTATUS_INTERMEDIATE 0x10
  219. #define IMAPISRB_SCSISTATUS_RESERVATION_CONFLICT 0x18 // used if another app already opened the device exclusive
  220. #define IMAPISRB_SCSISTATUS_QUEUE_FULL 0x28
  221. /*
  222. ** IMAPISRB Flag Bits - Subset of NT SCSI_REQUEST_BLOCK flag bits.
  223. */
  224. #define SRB_FLAGS_DATA_IN 0x00000040
  225. #define SRB_FLAGS_DATA_OUT 0x00000080
  226. #define SRB_FLAGS_NO_DATA_TRANSFER 0x00000000
  227. /*
  228. ** ----------------------------------------------------------------------------
  229. ** IOCTL_IMAPIDRV_CLOSE
  230. ** ----------------------------------------------------------------------------
  231. */
  232. #define IOCTL_IMAPIDRV_CLOSE ((ULONG)CTL_CODE(FILE_DEVICE_IMAPI,0x840,METHOD_BUFFERED,FILE_ANY_ACCESS))
  233. /*
  234. ** ----------------------------------------------------------------------------
  235. ** IOCTL_IMAPIDRV_PNPEVENT
  236. ** ----------------------------------------------------------------------------
  237. */
  238. #define IOCTL_IMAPIDRV_PNPEVENT ((ULONG)CTL_CODE(FILE_DEVICE_IMAPI,0x860,METHOD_BUFFERED,FILE_ANY_ACCESS))
  239. /*
  240. ** ----------------------------------------------------------------------------
  241. ** IOCTL_IMAPIDRV_CLEAR_PNPEVENT
  242. ** ----------------------------------------------------------------------------
  243. */
  244. #define IOCTL_IMAPIDRV_CLEAR_PNPEVENT ((ULONG)CTL_CODE(FILE_DEVICE_IMAPI,0x870,METHOD_BUFFERED,FILE_ANY_ACCESS))
  245. #ifdef __cplusplus
  246. }
  247. #endif
  248. #endif //__IMAPIPUB_H__