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.

426 lines
8.6 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1996 - 1998
  3. Module Name:
  4. mcd.h
  5. Abstract:
  6. These are the structures and defines that are used in the
  7. changer class drivers. The changer class driver is separated
  8. into two modules. Mcd.c contains code common to all medium
  9. changer drivers including the driver's major entry points.
  10. Author:
  11. chuckp (Chuck Park)
  12. Environment:
  13. Kernel mode
  14. Revision History :
  15. --*/
  16. #include "scsi.h"
  17. #include "ntddchgr.h"
  18. #include <classpnp.h>
  19. #include <wmidata.h>
  20. #include <wmistr.h>
  21. #ifdef DebugPrint
  22. #undef DebugPrint
  23. #endif
  24. #if DBG
  25. #define DebugPrint(x) ChangerClassDebugPrint x
  26. #else
  27. #define DebugPrint(x)
  28. #endif
  29. #define MAXIMUM_CHANGER_INQUIRY_DATA 252
  30. typedef
  31. NTSTATUS
  32. (*CHANGER_COMMAND_ROUTINE)(
  33. IN PDEVICE_OBJECT DeviceObject,
  34. IN PIRP Irp
  35. );
  36. typedef
  37. ULONG
  38. (*CHANGER_EXTENSION_SIZE)(
  39. IN VOID
  40. );
  41. typedef
  42. NTSTATUS
  43. (*CHANGER_INITIALIZE)(
  44. IN PDEVICE_OBJECT DeviceObject
  45. );
  46. typedef
  47. NTSTATUS
  48. (*CHANGER_PERFORM_DIAGNOSTICS)(
  49. IN PDEVICE_OBJECT DeviceObject,
  50. OUT PWMI_CHANGER_PROBLEM_DEVICE_ERROR changerDeviceError
  51. );
  52. typedef
  53. VOID
  54. (*CHANGER_ERROR_ROUTINE)(
  55. IN PDEVICE_OBJECT DeviceObject,
  56. IN PSCSI_REQUEST_BLOCK Srb,
  57. IN NTSTATUS *Status,
  58. IN BOOLEAN *Retry
  59. );
  60. typedef struct _MCD_INIT_DATA {
  61. //
  62. // Size of this structure.
  63. //
  64. ULONG InitDataSize;
  65. //
  66. // To return the size of the minidriver extension
  67. //
  68. CHANGER_EXTENSION_SIZE ChangerAdditionalExtensionSize;
  69. //
  70. // To perform minidriver specific initialization
  71. //
  72. CHANGER_INITIALIZE ChangerInitialize;
  73. //
  74. // To perform minidriver specific error processing
  75. //
  76. CHANGER_ERROR_ROUTINE ChangerError;
  77. //
  78. // To perform diagnostic tests on the device
  79. //
  80. CHANGER_PERFORM_DIAGNOSTICS ChangerPerformDiagnostics;
  81. //
  82. // Minidriver dispatch routines
  83. //
  84. CHANGER_COMMAND_ROUTINE ChangerGetParameters;
  85. CHANGER_COMMAND_ROUTINE ChangerGetStatus;
  86. CHANGER_COMMAND_ROUTINE ChangerGetProductData;
  87. CHANGER_COMMAND_ROUTINE ChangerSetAccess;
  88. CHANGER_COMMAND_ROUTINE ChangerGetElementStatus;
  89. CHANGER_COMMAND_ROUTINE ChangerInitializeElementStatus;
  90. CHANGER_COMMAND_ROUTINE ChangerSetPosition;
  91. CHANGER_COMMAND_ROUTINE ChangerExchangeMedium;
  92. CHANGER_COMMAND_ROUTINE ChangerMoveMedium;
  93. CHANGER_COMMAND_ROUTINE ChangerReinitializeUnit;
  94. CHANGER_COMMAND_ROUTINE ChangerQueryVolumeTags;
  95. } MCD_INIT_DATA, *PMCD_INIT_DATA;
  96. typedef struct _MODE_ELEMENT_ADDRESS_PAGE {
  97. UCHAR PageCode : 6;
  98. UCHAR Reserved1 : 1;
  99. UCHAR PS : 1;
  100. UCHAR PageLength;
  101. UCHAR MediumTransportElementAddress[2];
  102. UCHAR NumberTransportElements[2];
  103. UCHAR FirstStorageElementAddress[2];
  104. UCHAR NumberStorageElements[2];
  105. UCHAR FirstIEPortElementAddress[2];
  106. UCHAR NumberIEPortElements[2];
  107. UCHAR FirstDataXFerElementAddress[2];
  108. UCHAR NumberDataXFerElements[2];
  109. UCHAR Reserved2[2];
  110. } MODE_ELEMENT_ADDRESS_PAGE, *PMODE_ELEMENT_ADDRESS_PAGE;
  111. typedef struct _MODE_TRANSPORT_GEOMETRY_PAGE {
  112. UCHAR PageCode : 6;
  113. UCHAR Reserved1 : 1;
  114. UCHAR PS : 1;
  115. UCHAR PageLength;
  116. UCHAR Flip : 1;
  117. UCHAR Reserved2: 7;
  118. UCHAR TransportElementNumber;
  119. } MODE_TRANSPORT_GEOMETRY_PAGE, *PMODE_TRANSPORT_GEOMETRY_PAGE;
  120. //
  121. // Capabilities page decribes the various functions that the device
  122. // supports. Used in GetParameters.
  123. //
  124. typedef struct _MODE_DEVICE_CAPABILITIES_PAGE {
  125. UCHAR PageCode : 6;
  126. UCHAR Reserved1 : 1;
  127. UCHAR PS : 1;
  128. UCHAR PageLength;
  129. UCHAR MediumTransport : 1;
  130. UCHAR StorageLocation : 1;
  131. UCHAR IEPort : 1;
  132. UCHAR DataXFer : 1;
  133. UCHAR Reserved2 : 4;
  134. UCHAR Reserved3;
  135. UCHAR MTtoMT : 1;
  136. UCHAR MTtoST : 1;
  137. UCHAR MTtoIE : 1;
  138. UCHAR MTtoDT : 1;
  139. UCHAR Reserved4 : 4;
  140. UCHAR STtoMT : 1;
  141. UCHAR STtoST : 1;
  142. UCHAR STtoIE : 1;
  143. UCHAR STtoDT : 1;
  144. UCHAR Reserved5 : 4;
  145. UCHAR IEtoMT : 1;
  146. UCHAR IEtoST : 1;
  147. UCHAR IEtoIE : 1;
  148. UCHAR IEtoDT : 1;
  149. UCHAR Reserved6 : 4;
  150. UCHAR DTtoMT : 1;
  151. UCHAR DTtoST : 1;
  152. UCHAR DTtoIE : 1;
  153. UCHAR DTtoDT : 1;
  154. UCHAR Reserved7 : 4;
  155. UCHAR Reserved8[4];
  156. UCHAR XMTtoMT : 1;
  157. UCHAR XMTtoST : 1;
  158. UCHAR XMTtoIE : 1;
  159. UCHAR XMTtoDT : 1;
  160. UCHAR Reserved9 : 4;
  161. UCHAR XSTtoMT : 1;
  162. UCHAR XSTtoST : 1;
  163. UCHAR XSTtoIE : 1;
  164. UCHAR XSTtoDT : 1;
  165. UCHAR Reserved10 : 4;
  166. UCHAR XIEtoMT : 1;
  167. UCHAR XIEtoST : 1;
  168. UCHAR XIEtoIE : 1;
  169. UCHAR XIEtoDT : 1;
  170. UCHAR Reserved11 : 4;
  171. UCHAR XDTtoMT : 1;
  172. UCHAR XDTtoST : 1;
  173. UCHAR XDTtoIE : 1;
  174. UCHAR XDTtoDT : 1;
  175. UCHAR Reserved12 : 4;
  176. } MODE_DEVICE_CAPABILITIES_PAGE, *PMODE_DEVICE_CAPABILITIES_PAGE;
  177. #define MODE_PAGE_DISPLAY 0x22
  178. //
  179. // Structures describing return data from READ_ELEMENT_STATUS
  180. //
  181. typedef struct _ELEMENT_STATUS_HEADER {
  182. UCHAR FirstElementAddress[2];
  183. UCHAR NumberOfElements[2];
  184. UCHAR Reserved1;
  185. UCHAR ReportByteCount[3];
  186. } ELEMENT_STATUS_HEADER, *PELEMENT_STATUS_HEADER;
  187. typedef struct _ELEMENT_STATUS_PAGE {
  188. UCHAR ElementType;
  189. UCHAR Reserved1 : 6;
  190. UCHAR AVolTag : 1;
  191. UCHAR PVolTag : 1;
  192. UCHAR ElementDescriptorLength[2];
  193. UCHAR Reserved2;
  194. UCHAR DescriptorByteCount[3];
  195. } ELEMENT_STATUS_PAGE, *PELEMENT_STATUS_PAGE;
  196. typedef struct _ELEMENT_DESCRIPTOR {
  197. UCHAR ElementAddress[2];
  198. UCHAR Full : 1;
  199. UCHAR Reserved1 : 1;
  200. UCHAR Exception : 1;
  201. UCHAR Accessible : 1;
  202. UCHAR Reserved2 : 4;
  203. UCHAR Reserved3;
  204. UCHAR AdditionalSenseCode;
  205. UCHAR AddSenseCodeQualifier;
  206. UCHAR Lun : 3;
  207. UCHAR Reserved4 : 1;
  208. UCHAR LunValid : 1;
  209. UCHAR IdValid : 1;
  210. UCHAR Reserved5 : 1;
  211. UCHAR NotThisBus : 1;
  212. UCHAR BusAddress;
  213. UCHAR Reserved6;
  214. UCHAR Reserved7 : 6;
  215. UCHAR Invert : 1;
  216. UCHAR SValid : 1;
  217. UCHAR SourceStorageElementAddress[2];
  218. } ELEMENT_DESCRIPTOR, *PELEMENT_DESCRIPTOR;
  219. //
  220. // The following routines are the exported entry points for
  221. // all changer class drivers.
  222. //
  223. NTSTATUS
  224. DriverEntry(
  225. IN PDRIVER_OBJECT DriverObject,
  226. IN PUNICODE_STRING RegistryPath
  227. );
  228. NTSTATUS
  229. ChangerClassInitialize(
  230. IN PDRIVER_OBJECT DriverObject,
  231. IN PUNICODE_STRING RegistryPath,
  232. IN PMCD_INIT_DATA ChangerInitData
  233. );
  234. PVOID
  235. ChangerClassAllocatePool(
  236. IN POOL_TYPE PoolType,
  237. IN ULONG NumberOfBytes
  238. );
  239. VOID
  240. ChangerClassFreePool(
  241. IN PVOID PoolToFree
  242. );
  243. NTSTATUS
  244. ChangerClassSendSrbSynchronous(
  245. IN PDEVICE_OBJECT DeviceObject,
  246. IN PSCSI_REQUEST_BLOCK Srb,
  247. IN PVOID Buffer,
  248. IN ULONG BufferSize,
  249. IN BOOLEAN WriteToDevice
  250. );
  251. VOID
  252. ChangerClassDebugPrint(
  253. ULONG DebugPrintLevel,
  254. PCCHAR DebugMessage,
  255. ...
  256. );
  257. //
  258. // The following routines are provided by the changer
  259. // device-specific module. Each routine name is
  260. // prefixed with 'Changer.'
  261. ULONG
  262. ChangerAdditionalExtensionSize(
  263. VOID
  264. );
  265. NTSTATUS
  266. ChangerInitialize(
  267. IN PDEVICE_OBJECT DeviceObject
  268. );
  269. VOID
  270. ChangerError(
  271. PDEVICE_OBJECT DeviceObject,
  272. PSCSI_REQUEST_BLOCK Srb,
  273. NTSTATUS *Status,
  274. BOOLEAN *Retry
  275. );
  276. NTSTATUS
  277. ChangerGetParameters(
  278. IN PDEVICE_OBJECT DeviceObject,
  279. IN PIRP Irp
  280. );
  281. NTSTATUS
  282. ChangerGetStatus(
  283. IN PDEVICE_OBJECT DeviceObject,
  284. IN PIRP Irp
  285. );
  286. NTSTATUS
  287. ChangerGetProductData(
  288. IN PDEVICE_OBJECT DeviceObject,
  289. IN PIRP Irp
  290. );
  291. NTSTATUS
  292. ChangerSetAccess(
  293. IN PDEVICE_OBJECT DeviceObject,
  294. IN PIRP Irp
  295. );
  296. NTSTATUS
  297. ChangerGetElementStatus(
  298. IN PDEVICE_OBJECT DeviceObject,
  299. IN PIRP Irp
  300. );
  301. NTSTATUS
  302. ChangerInitializeElementStatus(
  303. IN PDEVICE_OBJECT DeviceObject,
  304. IN PIRP Irp
  305. );
  306. NTSTATUS
  307. ChangerSetPosition(
  308. IN PDEVICE_OBJECT DeviceObject,
  309. IN PIRP Irp
  310. );
  311. NTSTATUS
  312. ChangerExchangeMedium(
  313. IN PDEVICE_OBJECT DeviceObject,
  314. IN PIRP Irp
  315. );
  316. NTSTATUS
  317. ChangerMoveMedium(
  318. IN PDEVICE_OBJECT DeviceObject,
  319. IN PIRP Irp
  320. );
  321. NTSTATUS
  322. ChangerReinitializeUnit(
  323. IN PDEVICE_OBJECT DeviceObject,
  324. IN PIRP Irp
  325. );
  326. NTSTATUS
  327. ChangerQueryVolumeTags(
  328. IN PDEVICE_OBJECT DeviceObject,
  329. IN PIRP Irp
  330. );
  331. NTSTATUS
  332. ChangerPerformDiagnostics(
  333. IN PDEVICE_OBJECT DeviceObject,
  334. OUT PWMI_CHANGER_PROBLEM_DEVICE_ERROR changerDeviceError
  335. );