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.

744 lines
24 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntddstor.h
  5. Abstract:
  6. This is the include file that defines all common constants and types
  7. accessing the storage class drivers
  8. Author:
  9. Peter Wieland 19-Jun-1996
  10. Revision History:
  11. --*/
  12. //
  13. // Interface GUIDs
  14. //
  15. // need these GUIDs outside conditional includes so that user can
  16. // #include <ntddstor.h> in precompiled header
  17. // #include <initguid.h> in a single source file
  18. // #include <ntddstor.h> in that source file a second time to instantiate the GUIDs
  19. //
  20. #ifdef DEFINE_GUID
  21. //
  22. // Make sure FAR is defined...
  23. //
  24. #ifndef FAR
  25. #ifdef _WIN32
  26. #define FAR
  27. #else
  28. #define FAR _far
  29. #endif
  30. #endif
  31. // begin_wioctlguids
  32. DEFINE_GUID(GUID_DEVINTERFACE_DISK, 0x53f56307L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  33. DEFINE_GUID(GUID_DEVINTERFACE_CDROM, 0x53f56308L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  34. DEFINE_GUID(GUID_DEVINTERFACE_PARTITION, 0x53f5630aL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  35. DEFINE_GUID(GUID_DEVINTERFACE_TAPE, 0x53f5630bL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  36. DEFINE_GUID(GUID_DEVINTERFACE_WRITEONCEDISK, 0x53f5630cL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  37. DEFINE_GUID(GUID_DEVINTERFACE_VOLUME, 0x53f5630dL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  38. DEFINE_GUID(GUID_DEVINTERFACE_MEDIUMCHANGER, 0x53f56310L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  39. DEFINE_GUID(GUID_DEVINTERFACE_FLOPPY, 0x53f56311L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  40. DEFINE_GUID(GUID_DEVINTERFACE_CDCHANGER, 0x53f56312L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  41. DEFINE_GUID(GUID_DEVINTERFACE_STORAGEPORT, 0x2accfe60L, 0xc130, 0x11d2, 0xb0, 0x82, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
  42. // end_wioctlguids
  43. // begin_wioctlobsoleteguids
  44. #define DiskClassGuid GUID_DEVINTERFACE_DISK
  45. #define CdRomClassGuid GUID_DEVINTERFACE_CDROM
  46. #define PartitionClassGuid GUID_DEVINTERFACE_PARTITION
  47. #define TapeClassGuid GUID_DEVINTERFACE_TAPE
  48. #define WriteOnceDiskClassGuid GUID_DEVINTERFACE_WRITEONCEDISK
  49. #define VolumeClassGuid GUID_DEVINTERFACE_VOLUME
  50. #define MediumChangerClassGuid GUID_DEVINTERFACE_MEDIUMCHANGER
  51. #define FloppyClassGuid GUID_DEVINTERFACE_FLOPPY
  52. #define CdChangerClassGuid GUID_DEVINTERFACE_CDCHANGER
  53. #define StoragePortClassGuid GUID_DEVINTERFACE_STORAGEPORT
  54. // end_wioctlobsoleteguids
  55. #endif
  56. // begin_winioctl
  57. #ifndef _NTDDSTOR_H_
  58. #define _NTDDSTOR_H_
  59. #ifdef __cplusplus
  60. extern "C" {
  61. #endif
  62. //
  63. // IoControlCode values for storage devices
  64. //
  65. #define IOCTL_STORAGE_BASE FILE_DEVICE_MASS_STORAGE
  66. //
  67. // The following device control codes are common for all class drivers. They
  68. // should be used in place of the older IOCTL_DISK, IOCTL_CDROM and IOCTL_TAPE
  69. // common codes
  70. //
  71. #define IOCTL_STORAGE_CHECK_VERIFY CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
  72. #define IOCTL_STORAGE_CHECK_VERIFY2 CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_ANY_ACCESS)
  73. #define IOCTL_STORAGE_MEDIA_REMOVAL CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
  74. #define IOCTL_STORAGE_EJECT_MEDIA CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
  75. #define IOCTL_STORAGE_LOAD_MEDIA CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
  76. #define IOCTL_STORAGE_LOAD_MEDIA2 CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_ANY_ACCESS)
  77. #define IOCTL_STORAGE_RESERVE CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
  78. #define IOCTL_STORAGE_RELEASE CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
  79. #define IOCTL_STORAGE_FIND_NEW_DEVICES CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
  80. #define IOCTL_STORAGE_EJECTION_CONTROL CTL_CODE(IOCTL_STORAGE_BASE, 0x0250, METHOD_BUFFERED, FILE_ANY_ACCESS)
  81. #define IOCTL_STORAGE_MCN_CONTROL CTL_CODE(IOCTL_STORAGE_BASE, 0x0251, METHOD_BUFFERED, FILE_ANY_ACCESS)
  82. #define IOCTL_STORAGE_GET_MEDIA_TYPES CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
  83. #define IOCTL_STORAGE_GET_MEDIA_TYPES_EX CTL_CODE(IOCTL_STORAGE_BASE, 0x0301, METHOD_BUFFERED, FILE_ANY_ACCESS)
  84. #define IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER CTL_CODE(IOCTL_STORAGE_BASE, 0x0304, METHOD_BUFFERED, FILE_ANY_ACCESS)
  85. #define IOCTL_STORAGE_GET_HOTPLUG_INFO CTL_CODE(IOCTL_STORAGE_BASE, 0x0305, METHOD_BUFFERED, FILE_ANY_ACCESS)
  86. #define IOCTL_STORAGE_SET_HOTPLUG_INFO CTL_CODE(IOCTL_STORAGE_BASE, 0x0306, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  87. #define IOCTL_STORAGE_RESET_BUS CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
  88. #define IOCTL_STORAGE_RESET_DEVICE CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
  89. #define IOCTL_STORAGE_BREAK_RESERVATION CTL_CODE(IOCTL_STORAGE_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS)
  90. #define IOCTL_STORAGE_GET_DEVICE_NUMBER CTL_CODE(IOCTL_STORAGE_BASE, 0x0420, METHOD_BUFFERED, FILE_ANY_ACCESS)
  91. #define IOCTL_STORAGE_PREDICT_FAILURE CTL_CODE(IOCTL_STORAGE_BASE, 0x0440, METHOD_BUFFERED, FILE_ANY_ACCESS)
  92. // end_winioctl
  93. #define IOCTL_STORAGE_QUERY_PROPERTY CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS)
  94. // begin_winioctl
  95. //
  96. // These ioctl codes are obsolete. They are defined here to avoid resuing them
  97. // and to allow class drivers to respond to them more easily.
  98. //
  99. #define OBSOLETE_IOCTL_STORAGE_RESET_BUS CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  100. #define OBSOLETE_IOCTL_STORAGE_RESET_DEVICE CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
  101. //
  102. // IOCTL_STORAGE_GET_HOTPLUG_INFO
  103. //
  104. typedef struct _STORAGE_HOTPLUG_INFO {
  105. ULONG Size; // version
  106. BOOLEAN MediaRemovable; // ie. zip, jaz, cdrom, mo, etc. vs hdd
  107. BOOLEAN MediaHotplug; // ie. does the device succeed a lock even though its not lockable media?
  108. BOOLEAN DeviceHotplug; // ie. 1394, USB, etc.
  109. BOOLEAN WriteCacheEnableOverride; // This field should not be relied upon because it is no longer used
  110. } STORAGE_HOTPLUG_INFO, *PSTORAGE_HOTPLUG_INFO;
  111. //
  112. // IOCTL_STORAGE_GET_DEVICE_NUMBER
  113. //
  114. // input - none
  115. //
  116. // output - STORAGE_DEVICE_NUMBER structure
  117. // The values in the STORAGE_DEVICE_NUMBER structure are guaranteed
  118. // to remain unchanged until the system is rebooted. They are not
  119. // guaranteed to be persistant across boots.
  120. //
  121. typedef struct _STORAGE_DEVICE_NUMBER {
  122. //
  123. // The FILE_DEVICE_XXX type for this device.
  124. //
  125. DEVICE_TYPE DeviceType;
  126. //
  127. // The number of this device
  128. //
  129. ULONG DeviceNumber;
  130. //
  131. // If the device is partitionable, the partition number of the device.
  132. // Otherwise -1
  133. //
  134. ULONG PartitionNumber;
  135. } STORAGE_DEVICE_NUMBER, *PSTORAGE_DEVICE_NUMBER;
  136. //
  137. // Define the structures for scsi resets
  138. //
  139. typedef struct _STORAGE_BUS_RESET_REQUEST {
  140. UCHAR PathId;
  141. } STORAGE_BUS_RESET_REQUEST, *PSTORAGE_BUS_RESET_REQUEST;
  142. //
  143. // IOCTL_STORAGE_MEDIA_REMOVAL disables the mechanism
  144. // on a storage device that ejects media. This function
  145. // may or may not be supported on storage devices that
  146. // support removable media.
  147. //
  148. // TRUE means prevent media from being removed.
  149. // FALSE means allow media removal.
  150. //
  151. typedef struct _PREVENT_MEDIA_REMOVAL {
  152. BOOLEAN PreventMediaRemoval;
  153. } PREVENT_MEDIA_REMOVAL, *PPREVENT_MEDIA_REMOVAL;
  154. // begin_ntminitape
  155. typedef struct _TAPE_STATISTICS {
  156. ULONG Version;
  157. ULONG Flags;
  158. LARGE_INTEGER RecoveredWrites;
  159. LARGE_INTEGER UnrecoveredWrites;
  160. LARGE_INTEGER RecoveredReads;
  161. LARGE_INTEGER UnrecoveredReads;
  162. UCHAR CompressionRatioReads;
  163. UCHAR CompressionRatioWrites;
  164. } TAPE_STATISTICS, *PTAPE_STATISTICS;
  165. #define RECOVERED_WRITES_VALID 0x00000001
  166. #define UNRECOVERED_WRITES_VALID 0x00000002
  167. #define RECOVERED_READS_VALID 0x00000004
  168. #define UNRECOVERED_READS_VALID 0x00000008
  169. #define WRITE_COMPRESSION_INFO_VALID 0x00000010
  170. #define READ_COMPRESSION_INFO_VALID 0x00000020
  171. typedef struct _TAPE_GET_STATISTICS {
  172. ULONG Operation;
  173. } TAPE_GET_STATISTICS, *PTAPE_GET_STATISTICS;
  174. #define TAPE_RETURN_STATISTICS 0L
  175. #define TAPE_RETURN_ENV_INFO 1L
  176. #define TAPE_RESET_STATISTICS 2L
  177. //
  178. // IOCTL_STORAGE_GET_MEDIA_TYPES_EX will return an array of DEVICE_MEDIA_INFO
  179. // structures, one per supported type, embedded in the GET_MEDIA_TYPES struct.
  180. //
  181. typedef enum _STORAGE_MEDIA_TYPE {
  182. //
  183. // Following are defined in ntdddisk.h in the MEDIA_TYPE enum
  184. //
  185. // Unknown, // Format is unknown
  186. // F5_1Pt2_512, // 5.25", 1.2MB, 512 bytes/sector
  187. // F3_1Pt44_512, // 3.5", 1.44MB, 512 bytes/sector
  188. // F3_2Pt88_512, // 3.5", 2.88MB, 512 bytes/sector
  189. // F3_20Pt8_512, // 3.5", 20.8MB, 512 bytes/sector
  190. // F3_720_512, // 3.5", 720KB, 512 bytes/sector
  191. // F5_360_512, // 5.25", 360KB, 512 bytes/sector
  192. // F5_320_512, // 5.25", 320KB, 512 bytes/sector
  193. // F5_320_1024, // 5.25", 320KB, 1024 bytes/sector
  194. // F5_180_512, // 5.25", 180KB, 512 bytes/sector
  195. // F5_160_512, // 5.25", 160KB, 512 bytes/sector
  196. // RemovableMedia, // Removable media other than floppy
  197. // FixedMedia, // Fixed hard disk media
  198. // F3_120M_512, // 3.5", 120M Floppy
  199. // F3_640_512, // 3.5" , 640KB, 512 bytes/sector
  200. // F5_640_512, // 5.25", 640KB, 512 bytes/sector
  201. // F5_720_512, // 5.25", 720KB, 512 bytes/sector
  202. // F3_1Pt2_512, // 3.5" , 1.2Mb, 512 bytes/sector
  203. // F3_1Pt23_1024, // 3.5" , 1.23Mb, 1024 bytes/sector
  204. // F5_1Pt23_1024, // 5.25", 1.23MB, 1024 bytes/sector
  205. // F3_128Mb_512, // 3.5" MO 128Mb 512 bytes/sector
  206. // F3_230Mb_512, // 3.5" MO 230Mb 512 bytes/sector
  207. // F8_256_128, // 8", 256KB, 128 bytes/sector
  208. // F3_200Mb_512, // 3.5", 200M Floppy (HiFD)
  209. //
  210. DDS_4mm = 0x20, // Tape - DAT DDS1,2,... (all vendors)
  211. MiniQic, // Tape - miniQIC Tape
  212. Travan, // Tape - Travan TR-1,2,3,...
  213. QIC, // Tape - QIC
  214. MP_8mm, // Tape - 8mm Exabyte Metal Particle
  215. AME_8mm, // Tape - 8mm Exabyte Advanced Metal Evap
  216. AIT1_8mm, // Tape - 8mm Sony AIT
  217. DLT, // Tape - DLT Compact IIIxt, IV
  218. NCTP, // Tape - Philips NCTP
  219. IBM_3480, // Tape - IBM 3480
  220. IBM_3490E, // Tape - IBM 3490E
  221. IBM_Magstar_3590, // Tape - IBM Magstar 3590
  222. IBM_Magstar_MP, // Tape - IBM Magstar MP
  223. STK_DATA_D3, // Tape - STK Data D3
  224. SONY_DTF, // Tape - Sony DTF
  225. DV_6mm, // Tape - 6mm Digital Video
  226. DMI, // Tape - Exabyte DMI and compatibles
  227. SONY_D2, // Tape - Sony D2S and D2L
  228. CLEANER_CARTRIDGE, // Cleaner - All Drive types that support Drive Cleaners
  229. CD_ROM, // Opt_Disk - CD
  230. CD_R, // Opt_Disk - CD-Recordable (Write Once)
  231. CD_RW, // Opt_Disk - CD-Rewriteable
  232. DVD_ROM, // Opt_Disk - DVD-ROM
  233. DVD_R, // Opt_Disk - DVD-Recordable (Write Once)
  234. DVD_RW, // Opt_Disk - DVD-Rewriteable
  235. MO_3_RW, // Opt_Disk - 3.5" Rewriteable MO Disk
  236. MO_5_WO, // Opt_Disk - MO 5.25" Write Once
  237. MO_5_RW, // Opt_Disk - MO 5.25" Rewriteable (not LIMDOW)
  238. MO_5_LIMDOW, // Opt_Disk - MO 5.25" Rewriteable (LIMDOW)
  239. PC_5_WO, // Opt_Disk - Phase Change 5.25" Write Once Optical
  240. PC_5_RW, // Opt_Disk - Phase Change 5.25" Rewriteable
  241. PD_5_RW, // Opt_Disk - PhaseChange Dual Rewriteable
  242. ABL_5_WO, // Opt_Disk - Ablative 5.25" Write Once Optical
  243. PINNACLE_APEX_5_RW, // Opt_Disk - Pinnacle Apex 4.6GB Rewriteable Optical
  244. SONY_12_WO, // Opt_Disk - Sony 12" Write Once
  245. PHILIPS_12_WO, // Opt_Disk - Philips/LMS 12" Write Once
  246. HITACHI_12_WO, // Opt_Disk - Hitachi 12" Write Once
  247. CYGNET_12_WO, // Opt_Disk - Cygnet/ATG 12" Write Once
  248. KODAK_14_WO, // Opt_Disk - Kodak 14" Write Once
  249. MO_NFR_525, // Opt_Disk - Near Field Recording (Terastor)
  250. NIKON_12_RW, // Opt_Disk - Nikon 12" Rewriteable
  251. IOMEGA_ZIP, // Mag_Disk - Iomega Zip
  252. IOMEGA_JAZ, // Mag_Disk - Iomega Jaz
  253. SYQUEST_EZ135, // Mag_Disk - Syquest EZ135
  254. SYQUEST_EZFLYER, // Mag_Disk - Syquest EzFlyer
  255. SYQUEST_SYJET, // Mag_Disk - Syquest SyJet
  256. AVATAR_F2, // Mag_Disk - 2.5" Floppy
  257. MP2_8mm, // Tape - 8mm Hitachi
  258. DST_S, // Ampex DST Small Tapes
  259. DST_M, // Ampex DST Medium Tapes
  260. DST_L, // Ampex DST Large Tapes
  261. VXATape_1, // Ecrix 8mm Tape
  262. VXATape_2, // Ecrix 8mm Tape
  263. STK_9840, // STK 9840
  264. LTO_Ultrium, // IBM, HP, Seagate LTO Ultrium
  265. LTO_Accelis, // IBM, HP, Seagate LTO Accelis
  266. DVD_RAM, // Opt_Disk - DVD-RAM
  267. AIT_8mm, // AIT2 or higher
  268. ADR_1, // OnStream ADR Mediatypes
  269. ADR_2
  270. } STORAGE_MEDIA_TYPE, *PSTORAGE_MEDIA_TYPE;
  271. #define MEDIA_ERASEABLE 0x00000001
  272. #define MEDIA_WRITE_ONCE 0x00000002
  273. #define MEDIA_READ_ONLY 0x00000004
  274. #define MEDIA_READ_WRITE 0x00000008
  275. #define MEDIA_WRITE_PROTECTED 0x00000100
  276. #define MEDIA_CURRENTLY_MOUNTED 0x80000000
  277. //
  278. // Define the different storage bus types
  279. // Bus types below 128 (0x80) are reserved for Microsoft use
  280. //
  281. typedef enum _STORAGE_BUS_TYPE {
  282. BusTypeUnknown = 0x00,
  283. BusTypeScsi,
  284. BusTypeAtapi,
  285. BusTypeAta,
  286. BusType1394,
  287. BusTypeSsa,
  288. BusTypeFibre,
  289. BusTypeUsb,
  290. BusTypeRAID,
  291. BusTypeMaxReserved = 0x7F
  292. } STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE;
  293. typedef struct _DEVICE_MEDIA_INFO {
  294. union {
  295. struct {
  296. LARGE_INTEGER Cylinders;
  297. STORAGE_MEDIA_TYPE MediaType;
  298. ULONG TracksPerCylinder;
  299. ULONG SectorsPerTrack;
  300. ULONG BytesPerSector;
  301. ULONG NumberMediaSides;
  302. ULONG MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  303. } DiskInfo;
  304. struct {
  305. LARGE_INTEGER Cylinders;
  306. STORAGE_MEDIA_TYPE MediaType;
  307. ULONG TracksPerCylinder;
  308. ULONG SectorsPerTrack;
  309. ULONG BytesPerSector;
  310. ULONG NumberMediaSides;
  311. ULONG MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  312. } RemovableDiskInfo;
  313. struct {
  314. STORAGE_MEDIA_TYPE MediaType;
  315. ULONG MediaCharacteristics; // Bitmask of MEDIA_XXX values.
  316. ULONG CurrentBlockSize;
  317. STORAGE_BUS_TYPE BusType;
  318. //
  319. // Bus specific information describing the medium supported.
  320. //
  321. union {
  322. struct {
  323. UCHAR MediumType;
  324. UCHAR DensityCode;
  325. } ScsiInformation;
  326. } BusSpecificData;
  327. } TapeInfo;
  328. } DeviceSpecific;
  329. } DEVICE_MEDIA_INFO, *PDEVICE_MEDIA_INFO;
  330. typedef struct _GET_MEDIA_TYPES {
  331. ULONG DeviceType; // FILE_DEVICE_XXX values
  332. ULONG MediaInfoCount;
  333. DEVICE_MEDIA_INFO MediaInfo[1];
  334. } GET_MEDIA_TYPES, *PGET_MEDIA_TYPES;
  335. //
  336. // IOCTL_STORAGE_PREDICT_FAILURE
  337. //
  338. // input - none
  339. //
  340. // output - STORAGE_PREDICT_FAILURE structure
  341. // PredictFailure returns zero if no failure predicted and non zero
  342. // if a failure is predicted.
  343. //
  344. // VendorSpecific returns 512 bytes of vendor specific information
  345. // if a failure is predicted
  346. //
  347. typedef struct _STORAGE_PREDICT_FAILURE
  348. {
  349. ULONG PredictFailure;
  350. UCHAR VendorSpecific[512];
  351. } STORAGE_PREDICT_FAILURE, *PSTORAGE_PREDICT_FAILURE;
  352. // end_ntminitape
  353. // end_winioctl
  354. //
  355. // Property Query Structures
  356. //
  357. //
  358. // IOCTL_STORAGE_QUERY_PROPERTY
  359. //
  360. // Input Buffer:
  361. // a STORAGE_PROPERTY_QUERY structure which describes what type of query
  362. // is being done, what property is being queried for, and any additional
  363. // parameters which a particular property query requires.
  364. //
  365. // Output Buffer:
  366. // Contains a buffer to place the results of the query into. Since all
  367. // property descriptors can be cast into a STORAGE_DESCRIPTOR_HEADER,
  368. // the IOCTL can be called once with a small buffer then again using
  369. // a buffer as large as the header reports is necessary.
  370. //
  371. //
  372. // Types of queries
  373. //
  374. typedef enum _STORAGE_QUERY_TYPE {
  375. PropertyStandardQuery = 0, // Retrieves the descriptor
  376. PropertyExistsQuery, // Used to test whether the descriptor is supported
  377. PropertyMaskQuery, // Used to retrieve a mask of writeable fields in the descriptor
  378. PropertyQueryMaxDefined // use to validate the value
  379. } STORAGE_QUERY_TYPE, *PSTORAGE_QUERY_TYPE;
  380. //
  381. // define some initial property id's
  382. //
  383. typedef enum _STORAGE_PROPERTY_ID {
  384. StorageDeviceProperty = 0,
  385. StorageAdapterProperty,
  386. StorageDeviceIdProperty
  387. } STORAGE_PROPERTY_ID, *PSTORAGE_PROPERTY_ID;
  388. //
  389. // Query structure - additional parameters for specific queries can follow
  390. // the header
  391. //
  392. typedef struct _STORAGE_PROPERTY_QUERY {
  393. //
  394. // ID of the property being retrieved
  395. //
  396. STORAGE_PROPERTY_ID PropertyId;
  397. //
  398. // Flags indicating the type of query being performed
  399. //
  400. STORAGE_QUERY_TYPE QueryType;
  401. //
  402. // Space for additional parameters if necessary
  403. //
  404. UCHAR AdditionalParameters[1];
  405. } STORAGE_PROPERTY_QUERY, *PSTORAGE_PROPERTY_QUERY;
  406. //
  407. // Standard property descriptor header. All property pages should use this
  408. // as their first element or should contain these two elements
  409. //
  410. typedef struct _STORAGE_DESCRIPTOR_HEADER {
  411. ULONG Version;
  412. ULONG Size;
  413. } STORAGE_DESCRIPTOR_HEADER, *PSTORAGE_DESCRIPTOR_HEADER;
  414. //
  415. // Device property descriptor - this is really just a rehash of the inquiry
  416. // data retrieved from a scsi device
  417. //
  418. // This may only be retrieved from a target device. Sending this to the bus
  419. // will result in an error
  420. //
  421. typedef struct _STORAGE_DEVICE_DESCRIPTOR {
  422. //
  423. // Sizeof(STORAGE_DEVICE_DESCRIPTOR)
  424. //
  425. ULONG Version;
  426. //
  427. // Total size of the descriptor, including the space for additional
  428. // data and id strings
  429. //
  430. ULONG Size;
  431. //
  432. // The SCSI-2 device type
  433. //
  434. UCHAR DeviceType;
  435. //
  436. // The SCSI-2 device type modifier (if any) - this may be zero
  437. //
  438. UCHAR DeviceTypeModifier;
  439. //
  440. // Flag indicating whether the device's media (if any) is removable. This
  441. // field should be ignored for media-less devices
  442. //
  443. BOOLEAN RemovableMedia;
  444. //
  445. // Flag indicating whether the device can support mulitple outstanding
  446. // commands. The actual synchronization in this case is the responsibility
  447. // of the port driver.
  448. //
  449. BOOLEAN CommandQueueing;
  450. //
  451. // Byte offset to the zero-terminated ascii string containing the device's
  452. // vendor id string. For devices with no such ID this will be zero
  453. //
  454. ULONG VendorIdOffset;
  455. //
  456. // Byte offset to the zero-terminated ascii string containing the device's
  457. // product id string. For devices with no such ID this will be zero
  458. //
  459. ULONG ProductIdOffset;
  460. //
  461. // Byte offset to the zero-terminated ascii string containing the device's
  462. // product revision string. For devices with no such string this will be
  463. // zero
  464. //
  465. ULONG ProductRevisionOffset;
  466. //
  467. // Byte offset to the zero-terminated ascii string containing the device's
  468. // serial number. For devices with no serial number this will be zero
  469. //
  470. ULONG SerialNumberOffset;
  471. //
  472. // Contains the bus type (as defined above) of the device. It should be
  473. // used to interpret the raw device properties at the end of this structure
  474. // (if any)
  475. //
  476. STORAGE_BUS_TYPE BusType;
  477. //
  478. // The number of bytes of bus-specific data which have been appended to
  479. // this descriptor
  480. //
  481. ULONG RawPropertiesLength;
  482. //
  483. // Place holder for the first byte of the bus specific property data
  484. //
  485. UCHAR RawDeviceProperties[1];
  486. } STORAGE_DEVICE_DESCRIPTOR, *PSTORAGE_DEVICE_DESCRIPTOR;
  487. //
  488. // Adapter properties
  489. //
  490. // This descriptor can be retrieved from a target device object of from the
  491. // device object for the bus. Retrieving from the target device object will
  492. // forward the request to the underlying bus
  493. //
  494. typedef struct _STORAGE_ADAPTER_DESCRIPTOR {
  495. ULONG Version;
  496. ULONG Size;
  497. ULONG MaximumTransferLength;
  498. ULONG MaximumPhysicalPages;
  499. ULONG AlignmentMask;
  500. BOOLEAN AdapterUsesPio;
  501. BOOLEAN AdapterScansDown;
  502. BOOLEAN CommandQueueing;
  503. BOOLEAN AcceleratedTransfer;
  504. UCHAR BusType;
  505. USHORT BusMajorVersion;
  506. USHORT BusMinorVersion;
  507. } STORAGE_ADAPTER_DESCRIPTOR, *PSTORAGE_ADAPTER_DESCRIPTOR;
  508. //
  509. // Storage identification descriptor.
  510. // The definitions here are based on the SCSI/SBP vital product data
  511. // device identifier page.
  512. //
  513. typedef enum _STORAGE_IDENTIFIER_CODE_SET {
  514. StorageIdCodeSetReserved = 0,
  515. StorageIdCodeSetBinary = 1,
  516. StorageIdCodeSetAscii = 2
  517. } STORAGE_IDENTIFIER_CODE_SET, *PSTORAGE_IDENTIFIER_CODE_SET;
  518. typedef enum _STORAGE_IDENTIFIER_TYPE {
  519. StorageIdTypeVendorSpecific = 0,
  520. StorageIdTypeVendorId = 1,
  521. StorageIdTypeEUI64 = 2,
  522. StorageIdTypeFCPHName = 3,
  523. StorageIdTypePortRelative = 4
  524. } STORAGE_IDENTIFIER_TYPE, *PSTORAGE_IDENTIFIER_TYPE;
  525. typedef enum _STORAGE_ASSOCIATION_TYPE {
  526. StorageIdAssocDevice = 0,
  527. StorageIdAssocPort = 1
  528. } STORAGE_ASSOCIATION_TYPE, *PSTORAGE_ASSOCIATION_TYPE;
  529. typedef struct _STORAGE_IDENTIFIER {
  530. STORAGE_IDENTIFIER_CODE_SET CodeSet;
  531. STORAGE_IDENTIFIER_TYPE Type;
  532. USHORT IdentifierSize;
  533. USHORT NextOffset;
  534. //
  535. // Add new fields here since existing code depends on
  536. // the above layout not changing.
  537. //
  538. STORAGE_ASSOCIATION_TYPE Association;
  539. //
  540. // The identifier is a variable length array of bytes.
  541. //
  542. UCHAR Identifier[1];
  543. } STORAGE_IDENTIFIER, *PSTORAGE_IDENTIFIER;
  544. typedef struct _STORAGE_DEVICE_ID_DESCRIPTOR {
  545. ULONG Version;
  546. ULONG Size;
  547. //
  548. // The number of identifiers reported by the device.
  549. //
  550. ULONG NumberOfIdentifiers;
  551. //
  552. // The following field is actually a variable length array of identification
  553. // descriptors. Unfortunately there's no C notation for an array of
  554. // variable length structures so we're forced to just pretend.
  555. //
  556. UCHAR Identifiers[1];
  557. } STORAGE_DEVICE_ID_DESCRIPTOR, *PSTORAGE_DEVICE_ID_DESCRIPTOR;
  558. #pragma warning(push)
  559. #pragma warning(disable:4200)
  560. typedef struct _STORAGE_MEDIA_SERIAL_NUMBER_DATA {
  561. USHORT Reserved;
  562. //
  563. // the SerialNumberLength will be set to zero
  564. // if the command is supported and the media
  565. // does not have a valid serial number.
  566. //
  567. USHORT SerialNumberLength;
  568. //
  569. // the following data is binary, and is not guaranteed
  570. // to be NULL terminated. this is an excercise for the
  571. // caller.
  572. //
  573. UCHAR SerialNumber[0];
  574. } STORAGE_MEDIA_SERIAL_NUMBER_DATA, *PSTORAGE_MEDIA_SERIAL_NUMBER_DATA;
  575. #pragma warning(push)
  576. // begin_winioctl
  577. #ifdef __cplusplus
  578. }
  579. #endif
  580. #endif // _NTDDSTOR_H_
  581. // end_winioctl