xref: /reactos/sdk/include/psdk/ntddstor.h (revision 34593d93)
1 /*
2  * ntddstor.h
3  *
4  * Storage class IOCTL interface.
5  *
6  * This file is part of the w32api package.
7  *
8  * Contributors:
9  *   Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10  *
11  * THIS SOFTWARE IS NOT COPYRIGHTED
12  *
13  * This source code is offered for use in the public domain. You may
14  * use, modify or distribute it freely.
15  *
16  * This code is distributed in the hope that it will be useful but
17  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18  * DISCLAIMED. This includes but is not limited to warranties of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20  *
21  */
22 
23 #ifndef _NTDDSTOR_H_
24 #define _NTDDSTOR_H_
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #if defined(DEFINE_GUID)
31 
32 DEFINE_GUID(GUID_DEVINTERFACE_DISK,
33   0x53f56307L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
34 
35 DEFINE_GUID(GUID_DEVINTERFACE_CDROM,
36   0x53f56308L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
37 
38 DEFINE_GUID(GUID_DEVINTERFACE_PARTITION,
39   0x53f5630aL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
40 
41 DEFINE_GUID(GUID_DEVINTERFACE_TAPE,
42   0x53f5630bL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
43 
44 DEFINE_GUID(GUID_DEVINTERFACE_WRITEONCEDISK,
45   0x53f5630cL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
46 
47 DEFINE_GUID(GUID_DEVINTERFACE_VOLUME,
48   0x53f5630dL, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
49 
50 DEFINE_GUID(GUID_DEVINTERFACE_MEDIUMCHANGER,
51   0x53f56310L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
52 
53 DEFINE_GUID(GUID_DEVINTERFACE_FLOPPY,
54   0x53f56311L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
55 
56 DEFINE_GUID(GUID_DEVINTERFACE_CDCHANGER,
57   0x53f56312L, 0xb6bf, 0x11d0, 0x94, 0xf2, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
58 
59 DEFINE_GUID(GUID_DEVINTERFACE_STORAGEPORT,
60   0x2accfe60L, 0xc130, 0x11d2, 0xb0, 0x82, 0x00, 0xa0, 0xc9, 0x1e, 0xfb, 0x8b);
61 
62 DEFINE_GUID(GUID_DEVINTERFACE_HIDDEN_VOLUME,
63   0x7f108a28L, 0x9833, 0x4b3b, 0xb7, 0x80, 0x2c, 0x6b, 0x5f, 0xa5, 0xc0, 0x62);
64 
65 #define WDI_STORAGE_PREDICT_FAILURE_DPS_GUID \
66   {0xe9f2d03aL, 0x747c, 0x41c2, {0xbb, 0x9a, 0x02, 0xc6, 0x2b, 0x6d, 0x5f, 0xcb}};
67 
68 /* Aliases for storage guids */
69 #define DiskClassGuid               GUID_DEVINTERFACE_DISK
70 #define CdRomClassGuid              GUID_DEVINTERFACE_CDROM
71 #define PartitionClassGuid          GUID_DEVINTERFACE_PARTITION
72 #define TapeClassGuid               GUID_DEVINTERFACE_TAPE
73 #define WriteOnceDiskClassGuid      GUID_DEVINTERFACE_WRITEONCEDISK
74 #define VolumeClassGuid             GUID_DEVINTERFACE_VOLUME
75 #define MediumChangerClassGuid      GUID_DEVINTERFACE_MEDIUMCHANGER
76 #define FloppyClassGuid             GUID_DEVINTERFACE_FLOPPY
77 #define CdChangerClassGuid          GUID_DEVINTERFACE_CDCHANGER
78 #define StoragePortClassGuid        GUID_DEVINTERFACE_STORAGEPORT
79 #define HiddenVolumeClassGuid       GUID_DEVINTERFACE_HIDDEN_VOLUME
80 
81 #endif /* defined(DEFINE_GUID) */
82 
83 #if defined(DEFINE_DEVPROPKEY)
84 DEFINE_DEVPROPKEY(DEVPKEY_Storage_Portable,           0x4d1ebee8, 0x803, 0x4774, 0x98, 0x42, 0xb7, 0x7d, 0xb5, 0x2, 0x65, 0xe9, 2);
85 DEFINE_DEVPROPKEY(DEVPKEY_Storage_Removable_Media,    0x4d1ebee8, 0x803, 0x4774, 0x98, 0x42, 0xb7, 0x7d, 0xb5, 0x2, 0x65, 0xe9, 3);
86 DEFINE_DEVPROPKEY(DEVPKEY_Storage_System_Critical,    0x4d1ebee8, 0x803, 0x4774, 0x98, 0x42, 0xb7, 0x7d, 0xb5, 0x2, 0x65, 0xe9, 4);
87 DEFINE_DEVPROPKEY(DEVPKEY_Storage_Disk_Number,        0x4d1ebee8, 0x803, 0x4774, 0x98, 0x42, 0xb7, 0x7d, 0xb5, 0x2, 0x65, 0xe9, 5);
88 DEFINE_DEVPROPKEY(DEVPKEY_Storage_Partition_Number,   0x4d1ebee8, 0x803, 0x4774, 0x98, 0x42, 0xb7, 0x7d, 0xb5, 0x2, 0x65, 0xe9, 6);
89 DEFINE_DEVPROPKEY(DEVPKEY_Storage_Mbr_Type,           0x4d1ebee8, 0x803, 0x4774, 0x98, 0x42, 0xb7, 0x7d, 0xb5, 0x2, 0x65, 0xe9, 7);
90 DEFINE_DEVPROPKEY(DEVPKEY_Storage_Gpt_Type,           0x4d1ebee8, 0x803, 0x4774, 0x98, 0x42, 0xb7, 0x7d, 0xb5, 0x2, 0x65, 0xe9, 8);
91 DEFINE_DEVPROPKEY(DEVPKEY_Storage_Gpt_Name,           0x4d1ebee8, 0x803, 0x4774, 0x98, 0x42, 0xb7, 0x7d, 0xb5, 0x2, 0x65, 0xe9, 9);
92 #endif
93 
94 #ifndef _WINIOCTL_
95 
96 #define IOCTL_STORAGE_BASE                FILE_DEVICE_MASS_STORAGE
97 
98 #define IOCTL_STORAGE_CHECK_VERIFY \
99   CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_READ_ACCESS)
100 
101 #define IOCTL_STORAGE_CHECK_VERIFY2 \
102   CTL_CODE(IOCTL_STORAGE_BASE, 0x0200, METHOD_BUFFERED, FILE_ANY_ACCESS)
103 
104 #define IOCTL_STORAGE_MEDIA_REMOVAL \
105   CTL_CODE(IOCTL_STORAGE_BASE, 0x0201, METHOD_BUFFERED, FILE_READ_ACCESS)
106 
107 #define IOCTL_STORAGE_EJECT_MEDIA \
108   CTL_CODE(IOCTL_STORAGE_BASE, 0x0202, METHOD_BUFFERED, FILE_READ_ACCESS)
109 
110 #define IOCTL_STORAGE_LOAD_MEDIA \
111   CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_READ_ACCESS)
112 
113 #define IOCTL_STORAGE_LOAD_MEDIA2 \
114   CTL_CODE(IOCTL_STORAGE_BASE, 0x0203, METHOD_BUFFERED, FILE_ANY_ACCESS)
115 
116 #define IOCTL_STORAGE_RESERVE \
117   CTL_CODE(IOCTL_STORAGE_BASE, 0x0204, METHOD_BUFFERED, FILE_READ_ACCESS)
118 
119 #define IOCTL_STORAGE_RELEASE \
120   CTL_CODE(IOCTL_STORAGE_BASE, 0x0205, METHOD_BUFFERED, FILE_READ_ACCESS)
121 
122 #define IOCTL_STORAGE_FIND_NEW_DEVICES \
123   CTL_CODE(IOCTL_STORAGE_BASE, 0x0206, METHOD_BUFFERED, FILE_READ_ACCESS)
124 
125 #define IOCTL_STORAGE_EJECTION_CONTROL \
126   CTL_CODE(IOCTL_STORAGE_BASE, 0x0250, METHOD_BUFFERED, FILE_ANY_ACCESS)
127 
128 #define IOCTL_STORAGE_MCN_CONTROL \
129   CTL_CODE(IOCTL_STORAGE_BASE, 0x0251, METHOD_BUFFERED, FILE_ANY_ACCESS)
130 
131 #define IOCTL_STORAGE_GET_MEDIA_TYPES \
132   CTL_CODE(IOCTL_STORAGE_BASE, 0x0300, METHOD_BUFFERED, FILE_ANY_ACCESS)
133 
134 #define IOCTL_STORAGE_GET_MEDIA_TYPES_EX \
135   CTL_CODE(IOCTL_STORAGE_BASE, 0x0301, METHOD_BUFFERED, FILE_ANY_ACCESS)
136 
137 #define IOCTL_STORAGE_RESET_BUS \
138   CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS)
139 
140 #define IOCTL_STORAGE_RESET_DEVICE \
141   CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS)
142 
143 #define IOCTL_STORAGE_GET_DEVICE_NUMBER \
144   CTL_CODE(IOCTL_STORAGE_BASE, 0x0420, METHOD_BUFFERED, FILE_ANY_ACCESS)
145 
146 #define IOCTL_STORAGE_PREDICT_FAILURE \
147   CTL_CODE(IOCTL_STORAGE_BASE, 0x0440, METHOD_BUFFERED, FILE_ANY_ACCESS)
148 
149 #endif /* _WINIOCTL_ */
150 
151 #define IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER \
152   CTL_CODE(IOCTL_STORAGE_BASE, 0x0304, METHOD_BUFFERED, FILE_ANY_ACCESS)
153 
154 #define IOCTL_STORAGE_GET_HOTPLUG_INFO \
155   CTL_CODE(IOCTL_STORAGE_BASE, 0x0305, METHOD_BUFFERED, FILE_ANY_ACCESS)
156 
157 #define IOCTL_STORAGE_SET_HOTPLUG_INFO \
158   CTL_CODE(IOCTL_STORAGE_BASE, 0x0306, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
159 
160 #define OBSOLETE_IOCTL_STORAGE_RESET_BUS \
161   CTL_CODE(IOCTL_STORAGE_BASE, 0x0400, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
162 
163 #define OBSOLETE_IOCTL_STORAGE_RESET_DEVICE \
164   CTL_CODE(IOCTL_STORAGE_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
165 
166 #define IOCTL_STORAGE_BREAK_RESERVATION \
167   CTL_CODE(IOCTL_STORAGE_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS)
168 
169 #define IOCTL_STORAGE_PERSISTENT_RESERVE_IN \
170   CTL_CODE(IOCTL_STORAGE_BASE, 0x0406, METHOD_BUFFERED, FILE_READ_ACCESS)
171 
172 #define IOCTL_STORAGE_PERSISTENT_RESERVE_OUT \
173   CTL_CODE(IOCTL_STORAGE_BASE, 0x0407, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
174 
175 #define IOCTL_STORAGE_READ_CAPACITY \
176   CTL_CODE(IOCTL_STORAGE_BASE, 0x0450, METHOD_BUFFERED, FILE_READ_ACCESS)
177 
178 #define IOCTL_STORAGE_QUERY_PROPERTY \
179   CTL_CODE(IOCTL_STORAGE_BASE, 0x0500, METHOD_BUFFERED, FILE_ANY_ACCESS)
180 
181 #define IOCTL_STORAGE_MANAGE_DATA_SET_ATTRIBUTES \
182   CTL_CODE(IOCTL_STORAGE_BASE, 0x0501, METHOD_BUFFERED, FILE_WRITE_ACCESS)
183 
184 #define IOCTL_STORAGE_GET_LB_PROVISIONING_MAP_RESOURCES \
185   CTL_CODE(IOCTL_STORAGE_BASE, 0x0502, METHOD_BUFFERED, FILE_READ_ACCESS)
186 
187 #define IOCTL_STORAGE_GET_BC_PROPERTIES \
188   CTL_CODE(IOCTL_STORAGE_BASE, 0x0600, METHOD_BUFFERED, FILE_READ_ACCESS)
189 
190 #define IOCTL_STORAGE_ALLOCATE_BC_STREAM \
191   CTL_CODE(IOCTL_STORAGE_BASE, 0x0601, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
192 
193 #define IOCTL_STORAGE_FREE_BC_STREAM \
194   CTL_CODE(IOCTL_STORAGE_BASE, 0x0602, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
195 
196 #define IOCTL_STORAGE_CHECK_PRIORITY_HINT_SUPPORT \
197   CTL_CODE(IOCTL_STORAGE_BASE, 0x0620, METHOD_BUFFERED, FILE_ANY_ACCESS)
198 
199 #define IOCTL_STORAGE_START_DATA_INTEGRITY_CHECK \
200   CTL_CODE(IOCTL_STORAGE_BASE, 0x0621, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
201 
202 #define IOCTL_STORAGE_STOP_DATA_INTEGRITY_CHECK  \
203   CTL_CODE(IOCTL_STORAGE_BASE, 0x0622, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
204 
205 #define IOCTL_STORAGE_FIRMWARE_GET_INFO \
206   CTL_CODE(IOCTL_STORAGE_BASE, 0x0700, METHOD_BUFFERED, FILE_ANY_ACCESS)
207 
208 #define IOCTL_STORAGE_FIRMWARE_DOWNLOAD \
209   CTL_CODE(IOCTL_STORAGE_BASE, 0x0701, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
210 
211 #define IOCTL_STORAGE_FIRMWARE_ACTIVATE \
212   CTL_CODE(IOCTL_STORAGE_BASE, 0x0702, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
213 
214 #define IOCTL_STORAGE_ENABLE_IDLE_POWER \
215   CTL_CODE(IOCTL_STORAGE_BASE, 0x0720, METHOD_BUFFERED, FILE_ANY_ACCESS)
216 
217 #define IOCTL_STORAGE_GET_IDLE_POWERUP_REASON \
218   CTL_CODE(IOCTL_STORAGE_BASE, 0x0721, METHOD_BUFFERED, FILE_ANY_ACCESS)
219 
220 #define IOCTL_STORAGE_POWER_ACTIVE \
221   CTL_CODE(IOCTL_STORAGE_BASE, 0x0722, METHOD_BUFFERED, FILE_ANY_ACCESS)
222 
223 #define IOCTL_STORAGE_POWER_IDLE \
224   CTL_CODE(IOCTL_STORAGE_BASE, 0x0723, METHOD_BUFFERED, FILE_ANY_ACCESS)
225 
226 #define IOCTL_STORAGE_EVENT_NOTIFICATION \
227   CTL_CODE(IOCTL_STORAGE_BASE, 0x0724, METHOD_BUFFERED, FILE_ANY_ACCESS)
228 
229 #define IOCTL_STORAGE_DEVICE_POWER_CAP \
230   CTL_CODE(IOCTL_STORAGE_BASE, 0x0725, METHOD_BUFFERED, FILE_ANY_ACCESS)
231 
232 #define IOCTL_STORAGE_RPMB_COMMAND \
233   CTL_CODE(IOCTL_STORAGE_BASE, 0x0726, METHOD_BUFFERED, FILE_ANY_ACCESS)
234 
235 #define IOCTL_STORAGE_ATTRIBUTE_MANAGEMENT \
236   CTL_CODE(IOCTL_STORAGE_BASE, 0x0727, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
237 
238 #define IOCTL_STORAGE_DIAGNOSTIC \
239   CTL_CODE(IOCTL_STORAGE_BASE, 0x0728, METHOD_BUFFERED, FILE_ANY_ACCESS)
240 
241 #define IOCTL_STORAGE_GET_PHYSICAL_ELEMENT_STATUS \
242   CTL_CODE(IOCTL_STORAGE_BASE, 0x0729, METHOD_BUFFERED, FILE_ANY_ACCESS)
243 
244 #define IOCTL_STORAGE_REMOVE_ELEMENT_AND_TRUNCATE \
245   CTL_CODE(IOCTL_STORAGE_BASE, 0x0730, METHOD_BUFFERED, FILE_ANY_ACCESS)
246 
247 #define IOCTL_STORAGE_GET_DEVICE_INTERNAL_LOG \
248   CTL_CODE(IOCTL_STORAGE_BASE, 0x0731, METHOD_BUFFERED, FILE_ANY_ACCESS)
249 
250 #define RECOVERED_WRITES_VALID         0x00000001
251 #define UNRECOVERED_WRITES_VALID       0x00000002
252 #define RECOVERED_READS_VALID          0x00000004
253 #define UNRECOVERED_READS_VALID        0x00000008
254 #define WRITE_COMPRESSION_INFO_VALID   0x00000010
255 #define READ_COMPRESSION_INFO_VALID    0x00000020
256 
257 #define TAPE_RETURN_STATISTICS         0L
258 #define TAPE_RETURN_ENV_INFO           1L
259 #define TAPE_RESET_STATISTICS          2L
260 
261 /* DEVICE_MEDIA_INFO.DeviceSpecific.DiskInfo.MediaCharacteristics constants */
262 #define MEDIA_ERASEABLE                   0x00000001
263 #define MEDIA_WRITE_ONCE                  0x00000002
264 #define MEDIA_READ_ONLY                   0x00000004
265 #define MEDIA_READ_WRITE                  0x00000008
266 #define MEDIA_WRITE_PROTECTED             0x00000100
267 #define MEDIA_CURRENTLY_MOUNTED           0x80000000
268 
269 #define StorageIdTypeNAA StorageIdTypeFCPHName
270 
271 #define DeviceDsmActionFlag_NonDestructive  0x80000000
272 
273 #define IsDsmActionNonDestructive(_Action) ((BOOLEAN)((_Action & DeviceDsmActionFlag_NonDestructive) != 0))
274 
275 #define DeviceDsmAction_None                    0x0u
276 #define DeviceDsmAction_Trim                    0x1u
277 #define DeviceDsmAction_Notification            (0x00000002u | DeviceDsmActionFlag_NonDestructive)
278 #define DeviceDsmAction_OffloadRead             (0x00000003u | DeviceDsmActionFlag_NonDestructive)
279 #define DeviceDsmAction_OffloadWrite            (0x00000004u)
280 #define DeviceDsmAction_Allocation              (0x00000005u | DeviceDsmActionFlag_NonDestructive)
281 #define DeviceDsmAction_Repair                  (0x00000006u | DeviceDsmActionFlag_NonDestructive)
282 #define DeviceDsmAction_Scrub                   (0x00000007u | DeviceDsmActionFlag_NonDestructive)
283 #define DeviceDsmAction_DrtQuery                (0x00000008u | DeviceDsmActionFlag_NonDestructive)
284 #define DeviceDsmAction_DrtClear                (0x00000009u | DeviceDsmActionFlag_NonDestructive)
285 #define DeviceDsmAction_DrtDisable              (0x0000000Au | DeviceDsmActionFlag_NonDestructive)
286 #define DeviceDsmAction_TieringQuery            (0x0000000Bu | DeviceDsmActionFlag_NonDestructive)
287 #define DeviceDsmAction_Map                     (0x0000000Cu | DeviceDsmActionFlag_NonDestructive)
288 #define DeviceDsmAction_RegenerateParity        (0x0000000Du | DeviceDsmActionFlag_NonDestructive)
289 #define DeviceDsmAction_NvCache_Change_Priority (0x0000000Eu | DeviceDsmActionFlag_NonDestructive)
290 #define DeviceDsmAction_NvCache_Evict           (0x0000000Fu | DeviceDsmActionFlag_NonDestructive)
291 #define DeviceDsmAction_TopologyIdQuery         (0x00000010u | DeviceDsmActionFlag_NonDestructive)
292 #define DeviceDsmAction_GetPhysicalAddresses    (0x00000011u | DeviceDsmActionFlag_NonDestructive)
293 #define DeviceDsmAction_ScopeRegen              (0x00000012u | DeviceDsmActionFlag_NonDestructive)
294 #define DeviceDsmAction_ReportZones             (0x00000013u | DeviceDsmActionFlag_NonDestructive)
295 #define DeviceDsmAction_OpenZone                (0x00000014u | DeviceDsmActionFlag_NonDestructive)
296 #define DeviceDsmAction_FinishZone              (0x00000015u | DeviceDsmActionFlag_NonDestructive)
297 #define DeviceDsmAction_CloseZone               (0x00000016u | DeviceDsmActionFlag_NonDestructive)
298 #define DeviceDsmAction_ResetWritePointer       (0x00000017u)
299 #define DeviceDsmAction_GetRangeErrorInfo       (0x00000018u | DeviceDsmActionFlag_NonDestructive)
300 #define DeviceDsmAction_WriteZeroes             (0x00000019u)
301 #define DeviceDsmAction_LostQuery               (0x0000001Au | DeviceDsmActionFlag_NonDestructive)
302 #define DeviceDsmAction_GetFreeSpace            (0x0000001Bu | DeviceDsmActionFlag_NonDestructive)
303 #define DeviceDsmAction_ConversionQuery         (0x0000001Cu | DeviceDsmActionFlag_NonDestructive)
304 #define DeviceDsmAction_VdtSet                  (0x0000001Du)
305 
306 #define DEVICE_DSM_FLAG_ENTIRE_DATA_SET_RANGE    0x00000001
307 
308 #define DEVICE_DSM_NOTIFY_FLAG_BEGIN             0x00000001
309 #define DEVICE_DSM_NOTIFY_FLAG_END               0x00000002
310 
311 #define IOCTL_STORAGE_BC_VERSION                 1
312 
313 #define STORAGE_PRIORITY_HINT_SUPPORTED          0x0001
314 
315 typedef struct _STORAGE_HOTPLUG_INFO {
316   ULONG Size;
317   BOOLEAN MediaRemovable;
318   BOOLEAN MediaHotplug;
319   BOOLEAN DeviceHotplug;
320   BOOLEAN WriteCacheEnableOverride;
321 } STORAGE_HOTPLUG_INFO, *PSTORAGE_HOTPLUG_INFO;
322 
323 typedef struct _STORAGE_DEVICE_NUMBER {
324   DEVICE_TYPE DeviceType;
325   ULONG DeviceNumber;
326   ULONG PartitionNumber;
327 } STORAGE_DEVICE_NUMBER, *PSTORAGE_DEVICE_NUMBER;
328 
329 typedef struct _STORAGE_BUS_RESET_REQUEST {
330   UCHAR PathId;
331 } STORAGE_BUS_RESET_REQUEST, *PSTORAGE_BUS_RESET_REQUEST;
332 
333 typedef struct _STORAGE_BREAK_RESERVATION_REQUEST {
334   ULONG Length;
335   UCHAR _unused;
336   UCHAR PathId;
337   UCHAR TargetId;
338   UCHAR Lun;
339 } STORAGE_BREAK_RESERVATION_REQUEST, *PSTORAGE_BREAK_RESERVATION_REQUEST;
340 
341 #ifndef _WINIOCTL_
342 typedef struct _PREVENT_MEDIA_REMOVAL {
343   BOOLEAN PreventMediaRemoval;
344 } PREVENT_MEDIA_REMOVAL, *PPREVENT_MEDIA_REMOVAL;
345 #endif
346 
347 typedef struct _CLASS_MEDIA_CHANGE_CONTEXT {
348   ULONG MediaChangeCount;
349   ULONG NewState;
350 } CLASS_MEDIA_CHANGE_CONTEXT, *PCLASS_MEDIA_CHANGE_CONTEXT;
351 
352 typedef struct _TAPE_STATISTICS {
353   ULONG Version;
354   ULONG Flags;
355   LARGE_INTEGER RecoveredWrites;
356   LARGE_INTEGER UnrecoveredWrites;
357   LARGE_INTEGER RecoveredReads;
358   LARGE_INTEGER UnrecoveredReads;
359   UCHAR CompressionRatioReads;
360   UCHAR CompressionRatioWrites;
361 } TAPE_STATISTICS, *PTAPE_STATISTICS;
362 
363 typedef struct _TAPE_GET_STATISTICS {
364   ULONG Operation;
365 } TAPE_GET_STATISTICS, *PTAPE_GET_STATISTICS;
366 
367 typedef enum _STORAGE_MEDIA_TYPE {
368   DDS_4mm = 0x20,
369   MiniQic,
370   Travan,
371   QIC,
372   MP_8mm,
373   AME_8mm,
374   AIT1_8mm,
375   DLT,
376   NCTP,
377   IBM_3480,
378   IBM_3490E,
379   IBM_Magstar_3590,
380   IBM_Magstar_MP,
381   STK_DATA_D3,
382   SONY_DTF,
383   DV_6mm,
384   DMI,
385   SONY_D2,
386   CLEANER_CARTRIDGE,
387   CD_ROM,
388   CD_R,
389   CD_RW,
390   DVD_ROM,
391   DVD_R,
392   DVD_RW,
393   MO_3_RW,
394   MO_5_WO,
395   MO_5_RW,
396   MO_5_LIMDOW,
397   PC_5_WO,
398   PC_5_RW,
399   PD_5_RW,
400   ABL_5_WO,
401   PINNACLE_APEX_5_RW,
402   SONY_12_WO,
403   PHILIPS_12_WO,
404   HITACHI_12_WO,
405   CYGNET_12_WO,
406   KODAK_14_WO,
407   MO_NFR_525,
408   NIKON_12_RW,
409   IOMEGA_ZIP,
410   IOMEGA_JAZ,
411   SYQUEST_EZ135,
412   SYQUEST_EZFLYER,
413   SYQUEST_SYJET,
414   AVATAR_F2,
415   MP2_8mm,
416   DST_S,
417   DST_M,
418   DST_L,
419   VXATape_1,
420   VXATape_2,
421 #if (NTDDI_VERSION < NTDDI_WINXP)
422   STK_EAGLE,
423 #else
424   STK_9840,
425 #endif
426   LTO_Ultrium,
427   LTO_Accelis,
428   DVD_RAM,
429   AIT_8mm,
430   ADR_1,
431   ADR_2,
432   STK_9940,
433   SAIT,
434   VXATape
435 } STORAGE_MEDIA_TYPE, *PSTORAGE_MEDIA_TYPE;
436 
437 typedef enum _STORAGE_BUS_TYPE {
438   BusTypeUnknown = 0x00,
439   BusTypeScsi,
440   BusTypeAtapi,
441   BusTypeAta,
442   BusType1394,
443   BusTypeSsa,
444   BusTypeFibre,
445   BusTypeUsb,
446   BusTypeRAID,
447   BusTypeiScsi,
448   BusTypeSas,
449   BusTypeSata,
450   BusTypeSd,
451   BusTypeMmc,
452   BusTypeVirtual,
453   BusTypeFileBackedVirtual,
454   BusTypeMax,
455   BusTypeMaxReserved = 0x7F
456 } STORAGE_BUS_TYPE, *PSTORAGE_BUS_TYPE;
457 
458 typedef struct _DEVICE_MEDIA_INFO {
459   union {
460     struct {
461       LARGE_INTEGER Cylinders;
462       STORAGE_MEDIA_TYPE MediaType;
463       ULONG TracksPerCylinder;
464       ULONG SectorsPerTrack;
465       ULONG BytesPerSector;
466       ULONG NumberMediaSides;
467       ULONG MediaCharacteristics;
468     } DiskInfo;
469     struct {
470       LARGE_INTEGER Cylinders;
471       STORAGE_MEDIA_TYPE MediaType;
472       ULONG TracksPerCylinder;
473       ULONG SectorsPerTrack;
474       ULONG BytesPerSector;
475       ULONG NumberMediaSides;
476       ULONG MediaCharacteristics;
477     } RemovableDiskInfo;
478     struct {
479       STORAGE_MEDIA_TYPE MediaType;
480       ULONG MediaCharacteristics;
481       ULONG CurrentBlockSize;
482       STORAGE_BUS_TYPE BusType;
483       union {
484         struct {
485           UCHAR MediumType;
486           UCHAR DensityCode;
487         } ScsiInformation;
488       } BusSpecificData;
489     } TapeInfo;
490   } DeviceSpecific;
491 } DEVICE_MEDIA_INFO, *PDEVICE_MEDIA_INFO;
492 
493 typedef struct _GET_MEDIA_TYPES {
494   ULONG DeviceType;
495   ULONG MediaInfoCount;
496   DEVICE_MEDIA_INFO MediaInfo[1];
497 } GET_MEDIA_TYPES, *PGET_MEDIA_TYPES;
498 
499 typedef struct _STORAGE_PREDICT_FAILURE {
500   ULONG PredictFailure;
501   UCHAR VendorSpecific[512];
502 } STORAGE_PREDICT_FAILURE, *PSTORAGE_PREDICT_FAILURE;
503 
504 typedef enum _STORAGE_QUERY_TYPE {
505   PropertyStandardQuery = 0,
506   PropertyExistsQuery,
507   PropertyMaskQuery,
508   PropertyQueryMaxDefined
509 } STORAGE_QUERY_TYPE, *PSTORAGE_QUERY_TYPE;
510 
511 typedef enum _STORAGE_PROPERTY_ID {
512   StorageDeviceProperty = 0,
513   StorageAdapterProperty,
514   StorageDeviceIdProperty,
515   StorageDeviceUniqueIdProperty,
516   StorageDeviceWriteCacheProperty,
517   StorageMiniportProperty,
518   StorageAccessAlignmentProperty,
519   StorageDeviceSeekPenaltyProperty,
520   StorageDeviceTrimProperty,
521   StorageDeviceWriteAggregationProperty,
522   StorageDeviceDeviceTelemetryProperty,
523   StorageDeviceLBProvisioningProperty,
524   StorageDevicePowerProperty,
525   StorageDeviceCopyOffloadProperty,
526   StorageDeviceResiliencyProperty,
527   StorageDeviceMediumProductType,
528   StorageAdapterRpmbProperty,
529   StorageAdapterCryptoProperty,
530   StorageDeviceTieringProperty,
531   StorageDeviceFaultDomainProperty,
532   StorageDeviceClusportProperty,
533   StorageDeviceDependantDevicesProperty,
534   StorageDeviceIoCapabilityProperty = 48,
535   StorageAdapterProtocolSpecificProperty,
536   StorageDeviceProtocolSpecificProperty,
537   StorageAdapterTemperatureProperty,
538   StorageDeviceTemperatureProperty,
539   StorageAdapterPhysicalTopologyProperty,
540   StorageDevicePhysicalTopologyProperty,
541   StorageDeviceAttributesProperty,
542   StorageDeviceManagementStatus,
543   StorageAdapterSerialNumberProperty,
544   StorageDeviceLocationProperty,
545   StorageDeviceNumaProperty,
546   StorageDeviceZonedDeviceProperty,
547   StorageDeviceUnsafeShutdownCount,
548   StorageDeviceEnduranceProperty,
549 } STORAGE_PROPERTY_ID, *PSTORAGE_PROPERTY_ID;
550 
551 typedef struct _STORAGE_PROPERTY_QUERY {
552   STORAGE_PROPERTY_ID PropertyId;
553   STORAGE_QUERY_TYPE QueryType;
554   UCHAR AdditionalParameters[1];
555 } STORAGE_PROPERTY_QUERY, *PSTORAGE_PROPERTY_QUERY;
556 
557 typedef _Struct_size_bytes_(Size) struct _STORAGE_DESCRIPTOR_HEADER {
558   ULONG Version;
559   ULONG Size;
560 } STORAGE_DESCRIPTOR_HEADER, *PSTORAGE_DESCRIPTOR_HEADER;
561 
562 typedef _Struct_size_bytes_(Size) struct _STORAGE_DEVICE_DESCRIPTOR {
563   ULONG Version;
564   ULONG Size;
565   UCHAR DeviceType;
566   UCHAR DeviceTypeModifier;
567   BOOLEAN RemovableMedia;
568   BOOLEAN CommandQueueing;
569   ULONG VendorIdOffset;
570   ULONG ProductIdOffset;
571   ULONG ProductRevisionOffset;
572   ULONG SerialNumberOffset;
573   STORAGE_BUS_TYPE BusType;
574   ULONG RawPropertiesLength;
575   UCHAR RawDeviceProperties[1];
576 } STORAGE_DEVICE_DESCRIPTOR, *PSTORAGE_DEVICE_DESCRIPTOR;
577 
578 typedef _Struct_size_bytes_(Size) struct _STORAGE_ADAPTER_DESCRIPTOR {
579   ULONG Version;
580   ULONG Size;
581   ULONG MaximumTransferLength;
582   ULONG MaximumPhysicalPages;
583   ULONG AlignmentMask;
584   BOOLEAN AdapterUsesPio;
585   BOOLEAN AdapterScansDown;
586   BOOLEAN CommandQueueing;
587   BOOLEAN AcceleratedTransfer;
588 #if (NTDDI_VERSION < NTDDI_WINXP)
589   BOOLEAN BusType;
590 #else
591   UCHAR BusType;
592 #endif
593   USHORT BusMajorVersion;
594   USHORT BusMinorVersion;
595 #if (NTDDI_VERSION >= NTDDI_WIN8)
596   UCHAR SrbType;
597   UCHAR AddressType;
598 #endif
599 } STORAGE_ADAPTER_DESCRIPTOR, *PSTORAGE_ADAPTER_DESCRIPTOR;
600 
601 typedef _Struct_size_bytes_(Size) struct _STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR {
602   ULONG Version;
603   ULONG Size;
604   ULONG BytesPerCacheLine;
605   ULONG BytesOffsetForCacheAlignment;
606   ULONG BytesPerLogicalSector;
607   ULONG BytesPerPhysicalSector;
608   ULONG BytesOffsetForSectorAlignment;
609 } STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR, *PSTORAGE_ACCESS_ALIGNMENT_DESCRIPTOR;
610 
611 typedef _Struct_size_bytes_(Size) struct _STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR {
612   ULONG Version;
613   ULONG Size;
614   ULONG MediumProductType;
615 } STORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR, *PSTORAGE_MEDIUM_PRODUCT_TYPE_DESCRIPTOR;
616 
617 typedef enum _STORAGE_PORT_CODE_SET {
618   StoragePortCodeSetReserved = 0,
619   StoragePortCodeSetStorport = 1,
620   StoragePortCodeSetSCSIport = 2,
621   StoragePortCodeSetSpaceport= 3,
622   StoragePortCodeSetATAport  = 4,
623   StoragePortCodeSetUSBport  = 5,
624   StoragePortCodeSetSBP2port = 6,
625   StoragePortCodeSetSDport   = 7
626 } STORAGE_PORT_CODE_SET, *PSTORAGE_PORT_CODE_SET;
627 
628 typedef struct _STORAGE_MINIPORT_DESCRIPTOR {
629   ULONG Version;
630   ULONG Size;
631   STORAGE_PORT_CODE_SET Portdriver;
632   BOOLEAN LUNResetSupported;
633   BOOLEAN TargetResetSupported;
634 #if (NTDDI_VERSION >= NTDDI_WIN8)
635   USHORT IoTimeoutValue;
636 #endif
637 #if (NTDDI_VERSION >= NTDDI_WINBLUE)
638   BOOLEAN ExtraIoInfoSupported;
639   UCHAR Reserved0[3];
640   ULONG Reserved1;
641 #endif
642 } STORAGE_MINIPORT_DESCRIPTOR, *PSTORAGE_MINIPORT_DESCRIPTOR;
643 
644 typedef struct _DEVICE_LB_PROVISIONING_DESCRIPTOR {
645   ULONG Version;
646   ULONG Size;
647   UCHAR ThinProvisioningEnabled:1;
648   UCHAR ThinProvisioningReadZeros:1;
649   UCHAR AnchorSupported:3;
650   UCHAR UnmapGranularityAlignmentValid:1;
651   UCHAR Reserved0:2;
652   UCHAR Reserved1[7];
653   ULONGLONG OptimalUnmapGranularity;
654   ULONGLONG UnmapGranularityAlignment;
655 #if (NTDDI_VERSION >= NTDDI_WINBLUE)
656   ULONG MaxUnmapLbaCount;
657   ULONG MaxUnmapBlockDescriptorCount;
658 #endif
659 } DEVICE_LB_PROVISIONING_DESCRIPTOR, *PDEVICE_LB_PROVISIONING_DESCRIPTOR;
660 
661 #define DEVICE_LB_PROVISIONING_DESCRIPTOR_V1_SIZE RTL_SIZEOF_THROUGH_FIELD(DEVICE_LB_PROVISIONING_DESCRIPTOR, UnmapGranularityAlignment)
662 
663 typedef struct _DEVICE_POWER_DESCRIPTOR {
664   ULONG Version;
665   ULONG Size;
666   BOOLEAN DeviceAttentionSupported;
667   BOOLEAN AsynchronousNotificationSupported;
668   BOOLEAN IdlePowerManagementEnabled;
669   BOOLEAN D3ColdEnabled;
670   BOOLEAN D3ColdSupported;
671   BOOLEAN NoVerifyDuringIdlePower;
672   UCHAR Reserved[2];
673   ULONG IdleTimeoutInMS;
674 } DEVICE_POWER_DESCRIPTOR, *PDEVICE_POWER_DESCRIPTOR;
675 
676 typedef struct _DEVICE_COPY_OFFLOAD_DESCRIPTOR {
677   ULONG Version;
678   ULONG Size;
679   ULONG MaximumTokenLifetime;
680   ULONG DefaultTokenLifetime;
681   ULONGLONG MaximumTransferSize;
682   ULONGLONG OptimalTransferCount;
683   ULONG MaximumDataDescriptors;
684   ULONG MaximumTransferLengthPerDescriptor;
685   ULONG OptimalTransferLengthPerDescriptor;
686   USHORT OptimalTransferLengthGranularity;
687   UCHAR Reserved[2];
688 } DEVICE_COPY_OFFLOAD_DESCRIPTOR, *PDEVICE_COPY_OFFLOAD_DESCRIPTOR;
689 
690 typedef _Struct_size_bytes_(Size) struct _STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR {
691   ULONG Version;
692   ULONG Size;
693   ULONG LunMaxIoCount;
694   ULONG AdapterMaxIoCount;
695 } STORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR, *PSTORAGE_DEVICE_IO_CAPABILITY_DESCRIPTOR;
696 
697 typedef enum _STORAGE_IDENTIFIER_CODE_SET {
698   StorageIdCodeSetReserved = 0,
699   StorageIdCodeSetBinary = 1,
700   StorageIdCodeSetAscii = 2,
701   StorageIdCodeSetUtf8 = 3
702 } STORAGE_IDENTIFIER_CODE_SET, *PSTORAGE_IDENTIFIER_CODE_SET;
703 
704 typedef enum _STORAGE_IDENTIFIER_TYPE {
705   StorageIdTypeVendorSpecific = 0,
706   StorageIdTypeVendorId = 1,
707   StorageIdTypeEUI64 = 2,
708   StorageIdTypeFCPHName = 3,
709   StorageIdTypePortRelative = 4,
710   StorageIdTypeTargetPortGroup = 5,
711   StorageIdTypeLogicalUnitGroup = 6,
712   StorageIdTypeMD5LogicalUnitIdentifier = 7,
713   StorageIdTypeScsiNameString = 8
714 } STORAGE_IDENTIFIER_TYPE, *PSTORAGE_IDENTIFIER_TYPE;
715 
716 typedef enum _STORAGE_ID_NAA_FORMAT {
717   StorageIdNAAFormatIEEEExtended = 2,
718   StorageIdNAAFormatIEEERegistered = 3,
719   StorageIdNAAFormatIEEEERegisteredExtended = 5
720 } STORAGE_ID_NAA_FORMAT, *PSTORAGE_ID_NAA_FORMAT;
721 
722 typedef enum _STORAGE_ASSOCIATION_TYPE {
723   StorageIdAssocDevice = 0,
724   StorageIdAssocPort = 1,
725   StorageIdAssocTarget = 2
726 } STORAGE_ASSOCIATION_TYPE, *PSTORAGE_ASSOCIATION_TYPE;
727 
728 typedef struct _STORAGE_IDENTIFIER {
729   STORAGE_IDENTIFIER_CODE_SET CodeSet;
730   STORAGE_IDENTIFIER_TYPE Type;
731   USHORT IdentifierSize;
732   USHORT NextOffset;
733   STORAGE_ASSOCIATION_TYPE Association;
734   UCHAR Identifier[1];
735 } STORAGE_IDENTIFIER, *PSTORAGE_IDENTIFIER;
736 
737 typedef _Struct_size_bytes_(Size) struct _STORAGE_DEVICE_ID_DESCRIPTOR {
738   ULONG Version;
739   ULONG Size;
740   ULONG NumberOfIdentifiers;
741   UCHAR Identifiers[1];
742 } STORAGE_DEVICE_ID_DESCRIPTOR, *PSTORAGE_DEVICE_ID_DESCRIPTOR;
743 
744 typedef struct _DEVICE_SEEK_PENALTY_DESCRIPTOR {
745   ULONG Version;
746   ULONG Size;
747   BOOLEAN IncursSeekPenalty;
748 } DEVICE_SEEK_PENALTY_DESCRIPTOR, *PDEVICE_SEEK_PENALTY_DESCRIPTOR;
749 
750 typedef struct _DEVICE_WRITE_AGGREGATION_DESCRIPTOR {
751   ULONG Version;
752   ULONG Size;
753   BOOLEAN BenefitsFromWriteAggregation;
754 } DEVICE_WRITE_AGGREGATION_DESCRIPTOR, *PDEVICE_WRITE_AGGREGATION_DESCRIPTOR;
755 
756 typedef struct _DEVICE_TRIM_DESCRIPTOR {
757   ULONG Version;
758   ULONG Size;
759   BOOLEAN TrimEnabled;
760 } DEVICE_TRIM_DESCRIPTOR, *PDEVICE_TRIM_DESCRIPTOR;
761 
762 typedef ULONG DEVICE_DATA_MANAGEMENT_SET_ACTION;
763 
764 #define DEVICE_DSM_FLAG_TRIM_NOT_FS_ALLOCATED 0x80000000
765 
766 typedef struct _DEVICE_DATA_SET_RANGE {
767   LONGLONG StartingOffset;
768   ULONGLONG LengthInBytes;
769 } DEVICE_DATA_SET_RANGE, *PDEVICE_DATA_SET_RANGE;
770 
771 typedef struct _DEVICE_MANAGE_DATA_SET_ATTRIBUTES {
772   ULONG Size;
773   DEVICE_DATA_MANAGEMENT_SET_ACTION Action;
774   ULONG Flags;
775   ULONG ParameterBlockOffset;
776   ULONG ParameterBlockLength;
777   ULONG DataSetRangesOffset;
778   ULONG DataSetRangesLength;
779 } DEVICE_MANAGE_DATA_SET_ATTRIBUTES, *PDEVICE_MANAGE_DATA_SET_ATTRIBUTES;
780 
781 typedef struct _DEVICE_DSM_NOTIFICATION_PARAMETERS {
782   ULONG Size;
783   ULONG Flags;
784   ULONG NumFileTypeIDs;
785   GUID FileTypeID[1];
786 } DEVICE_DSM_NOTIFICATION_PARAMETERS, *PDEVICE_DSM_NOTIFICATION_PARAMETERS;
787 
788 typedef struct _STORAGE_GET_BC_PROPERTIES_OUTPUT {
789   ULONG MaximumRequestsPerPeriod;
790   ULONG MinimumPeriod;
791   ULONGLONG MaximumRequestSize;
792   ULONG EstimatedTimePerRequest;
793   ULONG NumOutStandingRequests;
794   ULONGLONG RequestSize;
795 } STORAGE_GET_BC_PROPERTIES_OUTPUT, *PSTORAGE_GET_BC_PROPERTIES_OUTPUT;
796 
797 typedef struct _STORAGE_ALLOCATE_BC_STREAM_INPUT {
798   ULONG Version;
799   ULONG RequestsPerPeriod;
800   ULONG Period;
801   BOOLEAN RetryFailures;
802   BOOLEAN Discardable;
803   BOOLEAN Reserved1[2];
804   ULONG AccessType;
805   ULONG AccessMode;
806 } STORAGE_ALLOCATE_BC_STREAM_INPUT, *PSTORAGE_ALLOCATE_BC_STREAM_INPUT;
807 
808 typedef struct _STORAGE_ALLOCATE_BC_STREAM_OUTPUT {
809   ULONGLONG RequestSize;
810   ULONG NumOutStandingRequests;
811 } STORAGE_ALLOCATE_BC_STREAM_OUTPUT, *PSTORAGE_ALLOCATE_BC_STREAM_OUTPUT;
812 
813 typedef struct _STORAGE_PRIORITY_HINT_SUPPORT {
814   ULONG SupportFlags;
815 } STORAGE_PRIORITY_HINT_SUPPORT, *PSTORAGE_PRIORITY_HINT_SUPPORT;
816 
817 #ifdef _MSC_VER
818 #pragma warning(push)
819 #pragma warning(disable:4200)
820 #endif
821 
822 // #if defined(_MSC_EXTENSIONS)
823 
824 typedef struct _STORAGE_MEDIA_SERIAL_NUMBER_DATA {
825   USHORT Reserved;
826   USHORT SerialNumberLength;
827   UCHAR SerialNumber[0];
828 } STORAGE_MEDIA_SERIAL_NUMBER_DATA, *PSTORAGE_MEDIA_SERIAL_NUMBER_DATA;
829 
830 typedef struct _PERSISTENT_RESERVE_COMMAND {
831   ULONG Version;
832   ULONG Size;
833   __MINGW_EXTENSION union {
834     struct {
835       UCHAR ServiceAction:5;
836       UCHAR Reserved1:3;
837       USHORT AllocationLength;
838     } PR_IN;
839     struct {
840       UCHAR ServiceAction:5;
841       UCHAR Reserved1:3;
842       UCHAR Type:4;
843       UCHAR Scope:4;
844       UCHAR ParameterList[0];
845     } PR_OUT;
846   } DUMMYUNIONNAME;
847 } PERSISTENT_RESERVE_COMMAND, *PPERSISTENT_RESERVE_COMMAND;
848 
849 // #endif /* defined(_MSC_EXTENSIONS) */
850 
851 #ifdef _MSC_VER
852 #pragma warning(pop) /* disable:4200 */
853 #endif
854 
855 typedef _Struct_size_bytes_(Size) struct _STORAGE_READ_CAPACITY {
856   ULONG Version;
857   ULONG Size;
858   ULONG BlockLength;
859   LARGE_INTEGER NumberOfBlocks;
860   LARGE_INTEGER DiskLength;
861 } STORAGE_READ_CAPACITY, *PSTORAGE_READ_CAPACITY;
862 
863 typedef enum _WRITE_CACHE_TYPE {
864   WriteCacheTypeUnknown,
865   WriteCacheTypeNone,
866   WriteCacheTypeWriteBack,
867   WriteCacheTypeWriteThrough
868 } WRITE_CACHE_TYPE;
869 
870 typedef enum _WRITE_CACHE_ENABLE {
871   WriteCacheEnableUnknown,
872   WriteCacheDisabled,
873   WriteCacheEnabled
874 } WRITE_CACHE_ENABLE;
875 
876 typedef enum _WRITE_CACHE_CHANGE {
877   WriteCacheChangeUnknown,
878   WriteCacheNotChangeable,
879   WriteCacheChangeable
880 } WRITE_CACHE_CHANGE;
881 
882 typedef enum _WRITE_THROUGH {
883   WriteThroughUnknown,
884   WriteThroughNotSupported,
885   WriteThroughSupported
886 } WRITE_THROUGH;
887 
888 typedef _Struct_size_bytes_(Size) struct _STORAGE_WRITE_CACHE_PROPERTY {
889   ULONG Version;
890   ULONG Size;
891   WRITE_CACHE_TYPE WriteCacheType;
892   WRITE_CACHE_ENABLE WriteCacheEnabled;
893   WRITE_CACHE_CHANGE WriteCacheChangeable;
894   WRITE_THROUGH WriteThroughSupported;
895   BOOLEAN FlushCacheSupported;
896   BOOLEAN UserDefinedPowerProtection;
897   BOOLEAN NVCacheEnabled;
898 } STORAGE_WRITE_CACHE_PROPERTY, *PSTORAGE_WRITE_CACHE_PROPERTY;
899 
900 typedef struct _STORAGE_LB_PROVISIONING_MAP_RESOURCES {
901   ULONG Size;
902   ULONG Version;
903   UCHAR AvailableMappingResourcesValid:1;
904   UCHAR UsedMappingResourcesValid:1;
905   UCHAR Reserved0:6;
906   UCHAR Reserved1[3];
907   UCHAR AvailableMappingResourcesScope:2;
908   UCHAR UsedMappingResourcesScope:2;
909   UCHAR Reserved2:4;
910   UCHAR Reserved3[3];
911   ULONGLONG AvailableMappingResources;
912   ULONGLONG UsedMappingResources;
913 } STORAGE_LB_PROVISIONING_MAP_RESOURCES, *PSTORAGE_LB_PROVISIONING_MAP_RESOURCES;
914 
915 typedef struct _DEVICE_MANAGE_DATA_SET_ATTRIBUTES_OUTPUT {
916   ULONG Size;
917   DEVICE_DATA_MANAGEMENT_SET_ACTION Action;
918   ULONG Flags;
919   ULONG OperationStatus;
920   ULONG ExtendedError;
921   ULONG TargetDetailedError;
922   ULONG ReservedStatus;
923   ULONG OutputBlockOffset;
924   ULONG OutputBlockLength;
925 } DEVICE_MANAGE_DATA_SET_ATTRIBUTES_OUTPUT, *PDEVICE_MANAGE_DATA_SET_ATTRIBUTES_OUTPUT;
926 
927 typedef struct _DEVICE_DATA_SET_LB_PROVISIONING_STATE {
928   ULONG Size;
929   ULONG Version;
930   ULONGLONG SlabSizeInBytes;
931   ULONG SlabOffsetDeltaInBytes;
932   ULONG SlabAllocationBitMapBitCount;
933   ULONG SlabAllocationBitMapLength;
934   ULONG SlabAllocationBitMap[ANYSIZE_ARRAY];
935 } DEVICE_DATA_SET_LB_PROVISIONING_STATE, *PDEVICE_DATA_SET_LB_PROVISIONING_STATE,
936   DEVICE_DSM_ALLOCATION_OUTPUT, *PDEVICE_DSM_ALLOCATION_OUTPUT;
937 
938 #define DEVICE_DSM_ALLOCATION_OUTPUT_V1 (sizeof(DEVICE_DSM_ALLOCATION_OUTPUT))
939 #define DEVICE_DATA_SET_LB_PROVISIONING_STATE_VERSION_V1 DEVICE_DSM_ALLOCATION_OUTPUT_V1
940 
941 typedef struct _DEVICE_DATA_SET_LB_PROVISIONING_STATE_V2 {
942   ULONG Size;
943   ULONG Version;
944   ULONGLONG SlabSizeInBytes;
945   ULONGLONG SlabOffsetDeltaInBytes;
946   ULONG SlabAllocationBitMapBitCount;
947   ULONG SlabAllocationBitMapLength;
948   ULONG SlabAllocationBitMap[ANYSIZE_ARRAY];
949 } DEVICE_DATA_SET_LB_PROVISIONING_STATE_V2, *PDEVICE_DATA_SET_LB_PROVISIONING_STATE_V2,
950   DEVICE_DSM_ALLOCATION_OUTPUT2, *PDEVICE_DSM_ALLOCATION_OUTPUT2;
951 
952 #define DEVICE_DSM_ALLOCATION_OUTPUT_V2 (sizeof(DEVICE_DSM_ALLOCATION_OUTPUT2))
953 #define DEVICE_DATA_SET_LB_PROVISIONING_STATE_VERSION_V2 DEVICE_DSM_ALLOCATION_OUTPUT_V2
954 
955 #define DeviceDsmDefinition_Allocation {DeviceDsmAction_Allocation,                  \
956                                         TRUE,                                        \
957                                         __alignof(DEVICE_DSM_ALLOCATION_PARAMETERS), \
958                                         sizeof(DEVICE_DSM_ALLOCATION_PARAMETERS),    \
959                                         TRUE,                                        \
960                                         __alignof(DEVICE_DSM_ALLOCATION_OUTPUT2),    \
961                                         sizeof(DEVICE_DSM_ALLOCATION_OUTPUT2)}
962 
963 #define DEVICE_DSM_FLAG_ALLOCATION_CONSOLIDATEABLE_ONLY 0x40000000
964 
965 typedef struct _DEVICE_DATA_SET_LBP_STATE_PARAMETERS {
966   ULONG Version;
967   ULONG Size;
968   ULONG Flags;
969   ULONG OutputVersion;
970 } DEVICE_DATA_SET_LBP_STATE_PARAMETERS, *PDEVICE_DATA_SET_LBP_STATE_PARAMETERS,
971   DEVICE_DSM_ALLOCATION_PARAMETERS, *PDEVICE_DSM_ALLOCATION_PARAMETERS;
972 
973 typedef struct _STORAGE_EVENT_NOTIFICATION {
974   ULONG Version;
975   ULONG Size;
976   ULONGLONG Events;
977 } STORAGE_EVENT_NOTIFICATION, *PSTORAGE_EVENT_NOTIFICATION;
978 
979 #define STORAGE_EVENT_NOTIFICATION_VERSION_V1 1
980 
981 #define STORAGE_EVENT_MEDIA_STATUS     0x0000000000000001
982 #define STORAGE_EVENT_DEVICE_STATUS    0x0000000000000002
983 #define STORAGE_EVENT_DEVICE_OPERATION 0x0000000000000004
984 #define STORAGE_EVENT_ALL (STORAGE_EVENT_MEDIA_STATUS | STORAGE_EVENT_DEVICE_STATUS | STORAGE_EVENT_DEVICE_OPERATION)
985 
986 #define STORAGE_OFFLOAD_MAX_TOKEN_LENGTH        512
987 #define STORAGE_OFFLOAD_TOKEN_ID_LENGTH         0x1F8
988 #define STORAGE_OFFLOAD_TOKEN_TYPE_ZERO_DATA    0xFFFF0001
989 
990 typedef struct _STORAGE_OFFLOAD_TOKEN {
991   UCHAR TokenType[4];
992   UCHAR Reserved[2];
993   UCHAR TokenIdLength[2];
994   union {
995       struct {
996           UCHAR Reserved2[STORAGE_OFFLOAD_TOKEN_ID_LENGTH];
997       } StorageOffloadZeroDataToken;
998       UCHAR Token[STORAGE_OFFLOAD_TOKEN_ID_LENGTH];
999   } DUMMYUNIONNAME;
1000 } STORAGE_OFFLOAD_TOKEN, *PSTORAGE_OFFLOAD_TOKEN;
1001 
1002 #define MAKE_ZERO_TOKEN(T) (                                  \
1003     ((PSTORAGE_OFFLOAD_TOKEN)T)->TokenType[0] = 0xFF,         \
1004     ((PSTORAGE_OFFLOAD_TOKEN)T)->TokenType[1] = 0xFF,         \
1005     ((PSTORAGE_OFFLOAD_TOKEN)T)->TokenType[2] = 0x00,         \
1006     ((PSTORAGE_OFFLOAD_TOKEN)T)->TokenType[3] = 0x01,         \
1007     ((PSTORAGE_OFFLOAD_TOKEN)T)->TokenIdLength[0] = 0x01,     \
1008     ((PSTORAGE_OFFLOAD_TOKEN)T)->TokenIdLength[1] = 0xF8      \
1009 )
1010 
1011 #define IS_ZERO_TOKEN(T) (                                    \
1012     (((PSTORAGE_OFFLOAD_TOKEN)T)->TokenType[0] == 0xFF     && \
1013      ((PSTORAGE_OFFLOAD_TOKEN)T)->TokenType[1] == 0xFF     && \
1014      ((PSTORAGE_OFFLOAD_TOKEN)T)->TokenType[2] == 0x00     && \
1015      ((PSTORAGE_OFFLOAD_TOKEN)T)->TokenType[3] == 0x01     && \
1016      ((PSTORAGE_OFFLOAD_TOKEN)T)->TokenIdLength[0] == 0x01 && \
1017      ((PSTORAGE_OFFLOAD_TOKEN)T)->TokenIdLength[1] == 0xF8)   \
1018 )
1019 
1020 typedef struct _DEVICE_DSM_OFFLOAD_READ_PARAMETERS {
1021   ULONG Flags;
1022   ULONG TimeToLive;
1023   ULONG Reserved[2];
1024 } DEVICE_DSM_OFFLOAD_READ_PARAMETERS, *PDEVICE_DSM_OFFLOAD_READ_PARAMETERS;
1025 
1026 #define STORAGE_OFFLOAD_READ_RANGE_TRUNCATED 0x00000001
1027 
1028 typedef struct _STORAGE_OFFLOAD_READ_OUTPUT {
1029   ULONG OffloadReadFlags;
1030   ULONG Reserved;
1031   ULONGLONG LengthProtected;
1032   ULONG TokenLength;
1033   STORAGE_OFFLOAD_TOKEN Token;
1034 } STORAGE_OFFLOAD_READ_OUTPUT, *PSTORAGE_OFFLOAD_READ_OUTPUT;
1035 
1036 #define DeviceDsmDefinition_OffloadRead {DeviceDsmAction_OffloadRead,                   \
1037                                          FALSE,                                         \
1038                                          __alignof(DEVICE_DSM_OFFLOAD_READ_PARAMETERS), \
1039                                          sizeof(DEVICE_DSM_OFFLOAD_READ_PARAMETERS),    \
1040                                          FALSE,                                         \
1041                                          __alignof(STORAGE_OFFLOAD_READ_OUTPUT),        \
1042                                          sizeof(STORAGE_OFFLOAD_READ_OUTPUT)}
1043 
1044 typedef struct _DEVICE_DSM_OFFLOAD_WRITE_PARAMETERS {
1045   ULONG Flags;
1046   ULONG Reserved;
1047   ULONGLONG TokenOffset;
1048   STORAGE_OFFLOAD_TOKEN Token;
1049 } DEVICE_DSM_OFFLOAD_WRITE_PARAMETERS, *PDEVICE_DSM_OFFLOAD_WRITE_PARAMETERS;
1050 
1051 #define STORAGE_OFFLOAD_WRITE_RANGE_TRUNCATED   0x0001
1052 #define STORAGE_OFFLOAD_TOKEN_INVALID           0x0002
1053 
1054 typedef struct _STORAGE_OFFLOAD_WRITE_OUTPUT {
1055   ULONG OffloadWriteFlags;
1056   ULONG Reserved;
1057   ULONGLONG LengthCopied;
1058 } STORAGE_OFFLOAD_WRITE_OUTPUT, *PSTORAGE_OFFLOAD_WRITE_OUTPUT;
1059 
1060 #define DeviceDsmDefinition_OffloadWrite {DeviceDsmAction_OffloadWrite,                   \
1061                                           FALSE,                                          \
1062                                           __alignof(DEVICE_DSM_OFFLOAD_WRITE_PARAMETERS), \
1063                                           sizeof(DEVICE_DSM_OFFLOAD_WRITE_PARAMETERS),    \
1064                                           FALSE,                                          \
1065                                           __alignof(STORAGE_OFFLOAD_WRITE_OUTPUT),        \
1066                                           sizeof(STORAGE_OFFLOAD_WRITE_OUTPUT)}
1067 
1068 
1069 #define READ_COPY_NUMBER_KEY                    0x52434e00  //'RCN'
1070 #define READ_COPY_NUMBER_BYPASS_CACHE_FLAG      0x00000100
1071 
1072 #define IsKeyReadCopyNumber(_k)                 (((_k) & 0xFFFFFE00) == READ_COPY_NUMBER_KEY)
1073 
1074 #define IsKeyReadCopyNumberBypassCache(_k)      ((_k) & READ_COPY_NUMBER_BYPASS_CACHE_FLAG)
1075 #define SetReadCopyNumberBypassCacheToKey(_k)   ((_k) |= READ_COPY_NUMBER_BYPASS_CACHE_FLAG)
1076 
1077 #define ReadCopyNumberToKey(_c)                 (READ_COPY_NUMBER_KEY | (UCHAR)(_c))
1078 #define ReadCopyNumberFromKey(_k)               (UCHAR)((_k) & 0x000000FF)
1079 
1080 typedef struct _STORAGE_IDLE_POWER {
1081   ULONG Version;
1082   ULONG Size;
1083   ULONG WakeCapableHint:1;
1084   ULONG D3ColdSupported:1;
1085   ULONG Reserved:30;
1086   ULONG D3IdleTimeout;
1087 } STORAGE_IDLE_POWER, *PSTORAGE_IDLE_POWER;
1088 
1089 
1090 // for IOCTL_STORAGE_GET_IDLE_POWERUP_REASON
1091 
1092 typedef enum _STORAGE_POWERUP_REASON_TYPE {
1093   StoragePowerupUnknown = 0,
1094   StoragePowerupIO,
1095   StoragePowerupDeviceAttention
1096 } STORAGE_POWERUP_REASON_TYPE, *PSTORAGE_POWERUP_REASON_TYPE;
1097 
1098 typedef struct _STORAGE_IDLE_POWERUP_REASON
1099 {
1100   ULONG Version;
1101   ULONG Size;
1102   STORAGE_POWERUP_REASON_TYPE PowerupReason;
1103 } STORAGE_IDLE_POWERUP_REASON, *PSTORAGE_IDLE_POWERUP_REASON;
1104 
1105 #define STORAGE_IDLE_POWERUP_REASON_VERSION_V1 1
1106 
1107 #ifdef __cplusplus
1108 }
1109 #endif
1110 
1111 #endif /* _NTDDSTOR_H_ */
1112