xref: /reactos/sdk/include/ddk/storport.h (revision 8a978a17)
1 /*
2  * storport.h
3  *
4  * StorPort 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 _NTSTORPORT_
24 #define _NTSTORPORT_
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #if defined(_STORPORT_)
31 #define STORPORT_API
32 #else
33 #define STORPORT_API DECLSPEC_IMPORT
34 #endif
35 
36 #define DIRECT_ACCESS_DEVICE                0x00
37 #define SEQUENTIAL_ACCESS_DEVICE            0x01
38 #define PRINTER_DEVICE                      0x02
39 #define PROCESSOR_DEVICE                    0x03
40 #define WRITE_ONCE_READ_MULTIPLE_DEVICE     0x04
41 #define READ_ONLY_DIRECT_ACCESS_DEVICE      0x05
42 #define SCANNER_DEVICE                      0x06
43 #define OPTICAL_DEVICE                      0x07
44 #define MEDIUM_CHANGER                      0x08
45 #define COMMUNICATION_DEVICE                0x09
46 #define ARRAY_CONTROLLER_DEVICE             0x0C
47 #define SCSI_ENCLOSURE_DEVICE               0x0D
48 #define REDUCED_BLOCK_DEVICE                0x0E
49 #define OPTICAL_CARD_READER_WRITER_DEVICE   0x0F
50 #define BRIDGE_CONTROLLER_DEVICE            0x10
51 #define OBJECT_BASED_STORAGE_DEVICE         0x11
52 #define LOGICAL_UNIT_NOT_PRESENT_DEVICE     0x7F
53 
54 #define DEVICE_CONNECTED                    0x00
55 
56 #define CDB6GENERIC_LENGTH                  6
57 #define CDB10GENERIC_LENGTH                 10
58 #define CDB12GENERIC_LENGTH                 12
59 
60 #define INQUIRYDATABUFFERSIZE                36
61 #define SENSE_BUFFER_SIZE                    18
62 #define MAX_SENSE_BUFFER_SIZE               255
63 
64 #define FILE_DEVICE_SCSI 0x0000001b
65 #define IOCTL_SCSI_EXECUTE_IN   ((FILE_DEVICE_SCSI << 16) + 0x0011)
66 #define IOCTL_SCSI_EXECUTE_OUT  ((FILE_DEVICE_SCSI << 16) + 0x0012)
67 #define IOCTL_SCSI_EXECUTE_NONE ((FILE_DEVICE_SCSI << 16) + 0x0013)
68 
69 #define MODE_PAGE_VENDOR_SPECIFIC           0x00
70 #define MODE_PAGE_ERROR_RECOVERY            0x01
71 #define MODE_PAGE_DISCONNECT                0x02
72 #define MODE_PAGE_FORMAT_DEVICE             0x03
73 #define MODE_PAGE_MRW                       0x03
74 #define MODE_PAGE_RIGID_GEOMETRY            0x04
75 #define MODE_PAGE_FLEXIBILE                 0x05
76 #define MODE_PAGE_WRITE_PARAMETERS          0x05
77 #define MODE_PAGE_VERIFY_ERROR              0x07
78 #define MODE_PAGE_CACHING                   0x08
79 #define MODE_PAGE_PERIPHERAL                0x09
80 #define MODE_PAGE_CONTROL                   0x0A
81 #define MODE_PAGE_MEDIUM_TYPES              0x0B
82 #define MODE_PAGE_NOTCH_PARTITION           0x0C
83 #define MODE_PAGE_CD_AUDIO_CONTROL          0x0E
84 #define MODE_PAGE_DATA_COMPRESS             0x0F
85 #define MODE_PAGE_DEVICE_CONFIG             0x10
86 #define MODE_PAGE_XOR_CONTROL               0x10
87 #define MODE_PAGE_MEDIUM_PARTITION          0x11
88 #define MODE_PAGE_ENCLOSURE_SERVICES_MANAGEMENT 0x14
89 #define MODE_PAGE_EXTENDED                  0x15
90 #define MODE_PAGE_EXTENDED_DEVICE_SPECIFIC  0x16
91 #define MODE_PAGE_CDVD_FEATURE_SET          0x18
92 #define MODE_PAGE_PROTOCOL_SPECIFIC_LUN     0x18
93 #define MODE_PAGE_PROTOCOL_SPECIFIC_PORT    0x19
94 #define MODE_PAGE_POWER_CONDITION           0x1A
95 #define MODE_PAGE_LUN_MAPPING               0x1B
96 #define MODE_PAGE_FAULT_REPORTING           0x1C
97 #define MODE_PAGE_CDVD_INACTIVITY           0x1D
98 #define MODE_PAGE_ELEMENT_ADDRESS           0x1D
99 #define MODE_PAGE_TRANSPORT_GEOMETRY        0x1E
100 #define MODE_PAGE_DEVICE_CAPABILITIES       0x1F
101 #define MODE_PAGE_CAPABILITIES              0x2A
102 #define MODE_SENSE_RETURN_ALL               0x3F
103 
104 #define MODE_SENSE_CURRENT_VALUES           0x00
105 #define MODE_SENSE_CHANGEABLE_VALUES        0x40
106 #define MODE_SENSE_DEFAULT_VAULES           0x80
107 #define MODE_SENSE_SAVED_VALUES             0xc0
108 
109 #define SCSIOP_TEST_UNIT_READY              0x00
110 #define SCSIOP_REZERO_UNIT                  0x01
111 #define SCSIOP_REWIND                       0x01
112 #define SCSIOP_REQUEST_BLOCK_ADDR           0x02
113 #define SCSIOP_REQUEST_SENSE                0x03
114 #define SCSIOP_FORMAT_UNIT                  0x04
115 #define SCSIOP_READ_BLOCK_LIMITS            0x05
116 #define SCSIOP_REASSIGN_BLOCKS              0x07
117 #define SCSIOP_INIT_ELEMENT_STATUS          0x07
118 #define SCSIOP_READ6                        0x08
119 #define SCSIOP_RECEIVE                      0x08
120 #define SCSIOP_WRITE6                       0x0A
121 #define SCSIOP_PRINT                        0x0A
122 #define SCSIOP_SEND                         0x0A
123 #define SCSIOP_SEEK6                        0x0B
124 #define SCSIOP_TRACK_SELECT                 0x0B
125 #define SCSIOP_SLEW_PRINT                   0x0B
126 #define SCSIOP_SET_CAPACITY                 0x0B
127 #define SCSIOP_SEEK_BLOCK                   0x0C
128 #define SCSIOP_PARTITION                    0x0D
129 #define SCSIOP_READ_REVERSE                 0x0F
130 #define SCSIOP_WRITE_FILEMARKS              0x10
131 #define SCSIOP_FLUSH_BUFFER                 0x10
132 #define SCSIOP_SPACE                        0x11
133 #define SCSIOP_INQUIRY                      0x12
134 #define SCSIOP_VERIFY6                      0x13
135 #define SCSIOP_RECOVER_BUF_DATA             0x14
136 #define SCSIOP_MODE_SELECT                  0x15
137 #define SCSIOP_RESERVE_UNIT                 0x16
138 #define SCSIOP_RELEASE_UNIT                 0x17
139 #define SCSIOP_COPY                         0x18
140 #define SCSIOP_ERASE                        0x19
141 #define SCSIOP_MODE_SENSE                   0x1A
142 #define SCSIOP_START_STOP_UNIT              0x1B
143 #define SCSIOP_STOP_PRINT                   0x1B
144 #define SCSIOP_LOAD_UNLOAD                  0x1B
145 #define SCSIOP_RECEIVE_DIAGNOSTIC           0x1C
146 #define SCSIOP_SEND_DIAGNOSTIC              0x1D
147 #define SCSIOP_MEDIUM_REMOVAL               0x1E
148 #define SCSIOP_READ_FORMATTED_CAPACITY      0x23
149 #define SCSIOP_READ_CAPACITY                0x25
150 #define SCSIOP_READ                         0x28
151 #define SCSIOP_WRITE                        0x2A
152 #define SCSIOP_SEEK                         0x2B
153 #define SCSIOP_LOCATE                       0x2B
154 #define SCSIOP_POSITION_TO_ELEMENT          0x2B
155 #define SCSIOP_WRITE_VERIFY                 0x2E
156 #define SCSIOP_VERIFY                       0x2F
157 #define SCSIOP_SEARCH_DATA_HIGH             0x30
158 #define SCSIOP_SEARCH_DATA_EQUAL            0x31
159 #define SCSIOP_SEARCH_DATA_LOW              0x32
160 #define SCSIOP_SET_LIMITS                   0x33
161 #define SCSIOP_READ_POSITION                0x34
162 #define SCSIOP_SYNCHRONIZE_CACHE            0x35
163 #define SCSIOP_COMPARE                      0x39
164 #define SCSIOP_COPY_COMPARE                 0x3A
165 #define SCSIOP_WRITE_DATA_BUFF              0x3B
166 #define SCSIOP_READ_DATA_BUFF               0x3C
167 #define SCSIOP_WRITE_LONG                   0x3F
168 #define SCSIOP_CHANGE_DEFINITION            0x40
169 #define SCSIOP_WRITE_SAME                   0x41
170 #define SCSIOP_READ_SUB_CHANNEL             0x42
171 #define SCSIOP_READ_TOC                     0x43
172 #define SCSIOP_READ_HEADER                  0x44
173 #define SCSIOP_REPORT_DENSITY_SUPPORT       0x44
174 #define SCSIOP_PLAY_AUDIO                   0x45
175 #define SCSIOP_GET_CONFIGURATION            0x46
176 #define SCSIOP_PLAY_AUDIO_MSF               0x47
177 #define SCSIOP_PLAY_TRACK_INDEX             0x48
178 #define SCSIOP_PLAY_TRACK_RELATIVE          0x49
179 #define SCSIOP_GET_EVENT_STATUS             0x4A
180 #define SCSIOP_PAUSE_RESUME                 0x4B
181 #define SCSIOP_LOG_SELECT                   0x4C
182 #define SCSIOP_LOG_SENSE                    0x4D
183 #define SCSIOP_STOP_PLAY_SCAN               0x4E
184 #define SCSIOP_XDWRITE                      0x50
185 #define SCSIOP_XPWRITE                      0x51
186 #define SCSIOP_READ_DISK_INFORMATION        0x51
187 #define SCSIOP_READ_DISC_INFORMATION        0x51
188 #define SCSIOP_READ_TRACK_INFORMATION       0x52
189 #define SCSIOP_XDWRITE_READ                 0x53
190 #define SCSIOP_RESERVE_TRACK_RZONE          0x53
191 #define SCSIOP_SEND_OPC_INFORMATION         0x54
192 #define SCSIOP_MODE_SELECT10                0x55
193 #define SCSIOP_RESERVE_UNIT10               0x56
194 #define SCSIOP_RESERVE_ELEMENT              0x56
195 #define SCSIOP_RELEASE_UNIT10               0x57
196 #define SCSIOP_RELEASE_ELEMENT              0x57
197 #define SCSIOP_REPAIR_TRACK                 0x58
198 #define SCSIOP_MODE_SENSE10                 0x5A
199 #define SCSIOP_CLOSE_TRACK_SESSION          0x5B
200 #define SCSIOP_READ_BUFFER_CAPACITY         0x5C
201 #define SCSIOP_SEND_CUE_SHEET               0x5D
202 #define SCSIOP_PERSISTENT_RESERVE_IN        0x5E
203 #define SCSIOP_PERSISTENT_RESERVE_OUT       0x5F
204 #define SCSIOP_XDWRITE_EXTENDED16           0x80
205 #define SCSIOP_WRITE_FILEMARKS16            0x80
206 #define SCSIOP_REBUILD16                    0x81
207 #define SCSIOP_READ_REVERSE16               0x81
208 #define SCSIOP_REGENERATE16                 0x82
209 #define SCSIOP_EXTENDED_COPY                0x83
210 #define SCSIOP_RECEIVE_COPY_RESULTS         0x84
211 #define SCSIOP_ATA_PASSTHROUGH16            0x85
212 #define SCSIOP_ACCESS_CONTROL_IN            0x86
213 #define SCSIOP_ACCESS_CONTROL_OUT           0x87
214 #define SCSIOP_READ16                       0x88
215 #define SCSIOP_WRITE16                      0x8A
216 #define SCSIOP_READ_ATTRIBUTES              0x8C
217 #define SCSIOP_WRITE_ATTRIBUTES             0x8D
218 #define SCSIOP_WRITE_VERIFY16               0x8E
219 #define SCSIOP_VERIFY16                     0x8F
220 #define SCSIOP_PREFETCH16                   0x90
221 #define SCSIOP_SYNCHRONIZE_CACHE16          0x91
222 #define SCSIOP_SPACE16                      0x91
223 #define SCSIOP_LOCK_UNLOCK_CACHE16          0x92
224 #define SCSIOP_LOCATE16                     0x92
225 #define SCSIOP_WRITE_SAME16                 0x93
226 #define SCSIOP_ERASE16                      0x93
227 #define SCSIOP_READ_CAPACITY16              0x9E
228 #define SCSIOP_SERVICE_ACTION_IN16          0x9E
229 #define SCSIOP_SERVICE_ACTION_OUT16         0x9F
230 #define SCSIOP_REPORT_LUNS                  0xA0
231 #define SCSIOP_BLANK                        0xA1
232 #define SCSIOP_ATA_PASSTHROUGH12            0xA1
233 #define SCSIOP_SEND_EVENT                   0xA2
234 #define SCSIOP_SEND_KEY                     0xA3
235 #define SCSIOP_MAINTENANCE_IN               0xA3
236 #define SCSIOP_REPORT_KEY                   0xA4
237 #define SCSIOP_MAINTENANCE_OUT              0xA4
238 #define SCSIOP_MOVE_MEDIUM                  0xA5
239 #define SCSIOP_LOAD_UNLOAD_SLOT             0xA6
240 #define SCSIOP_EXCHANGE_MEDIUM              0xA6
241 #define SCSIOP_SET_READ_AHEAD               0xA7
242 #define SCSIOP_MOVE_MEDIUM_ATTACHED         0xA7
243 #define SCSIOP_READ12                       0xA8
244 #define SCSIOP_GET_MESSAGE                  0xA8
245 #define SCSIOP_SERVICE_ACTION_OUT12         0xA9
246 #define SCSIOP_WRITE12                      0xAA
247 #define SCSIOP_SEND_MESSAGE                 0xAB
248 #define SCSIOP_SERVICE_ACTION_IN12          0xAB
249 #define SCSIOP_GET_PERFORMANCE              0xAC
250 #define SCSIOP_READ_DVD_STRUCTURE           0xAD
251 #define SCSIOP_WRITE_VERIFY12               0xAE
252 #define SCSIOP_VERIFY12                     0xAF
253 #define SCSIOP_SEARCH_DATA_HIGH12           0xB0
254 #define SCSIOP_SEARCH_DATA_EQUAL12          0xB1
255 #define SCSIOP_SEARCH_DATA_LOW12            0xB2
256 #define SCSIOP_SET_LIMITS12                 0xB3
257 #define SCSIOP_READ_ELEMENT_STATUS_ATTACHED 0xB4
258 #define SCSIOP_REQUEST_VOL_ELEMENT          0xB5
259 #define SCSIOP_SEND_VOLUME_TAG              0xB6
260 #define SCSIOP_SET_STREAMING                0xB6
261 #define SCSIOP_READ_DEFECT_DATA             0xB7
262 #define SCSIOP_READ_ELEMENT_STATUS          0xB8
263 #define SCSIOP_READ_CD_MSF                  0xB9
264 #define SCSIOP_SCAN_CD                      0xBA
265 #define SCSIOP_REDUNDANCY_GROUP_IN          0xBA
266 #define SCSIOP_SET_CD_SPEED                 0xBB
267 #define SCSIOP_REDUNDANCY_GROUP_OUT         0xBB
268 #define SCSIOP_PLAY_CD                      0xBC
269 #define SCSIOP_SPARE_IN                     0xBC
270 #define SCSIOP_MECHANISM_STATUS             0xBD
271 #define SCSIOP_SPARE_OUT                    0xBD
272 #define SCSIOP_READ_CD                      0xBE
273 #define SCSIOP_VOLUME_SET_IN                0xBE
274 #define SCSIOP_SEND_DVD_STRUCTURE           0xBF
275 #define SCSIOP_VOLUME_SET_OUT               0xBF
276 #define SCSIOP_INIT_ELEMENT_RANGE           0xE7
277 
278 #define SCSISTAT_GOOD                       0x00
279 #define SCSISTAT_CHECK_CONDITION            0x02
280 #define SCSISTAT_CONDITION_MET              0x04
281 #define SCSISTAT_BUSY                       0x08
282 #define SCSISTAT_INTERMEDIATE               0x10
283 #define SCSISTAT_INTERMEDIATE_COND_MET      0x14
284 #define SCSISTAT_RESERVATION_CONFLICT       0x18
285 #define SCSISTAT_COMMAND_TERMINATED         0x22
286 #define SCSISTAT_QUEUE_FULL                 0x28
287 
288 #define SETBITON                            1
289 #define SETBITOFF                           0
290 
291 #define SP_RETURN_NOT_FOUND                 0
292 #define SP_RETURN_FOUND                     1
293 #define SP_RETURN_ERROR                     2
294 #define SP_RETURN_BAD_CONFIG                3
295 
296 #define SRB_FUNCTION_EXECUTE_SCSI           0x00
297 #define SRB_FUNCTION_CLAIM_DEVICE           0x01
298 #define SRB_FUNCTION_IO_CONTROL             0x02
299 #define SRB_FUNCTION_RECEIVE_EVENT          0x03
300 #define SRB_FUNCTION_RELEASE_QUEUE          0x04
301 #define SRB_FUNCTION_ATTACH_DEVICE          0x05
302 #define SRB_FUNCTION_RELEASE_DEVICE         0x06
303 #define SRB_FUNCTION_SHUTDOWN               0x07
304 #define SRB_FUNCTION_FLUSH                  0x08
305 #define SRB_FUNCTION_ABORT_COMMAND          0x10
306 #define SRB_FUNCTION_RELEASE_RECOVERY       0x11
307 #define SRB_FUNCTION_RESET_BUS              0x12
308 #define SRB_FUNCTION_RESET_DEVICE           0x13
309 #define SRB_FUNCTION_TERMINATE_IO           0x14
310 #define SRB_FUNCTION_FLUSH_QUEUE            0x15
311 #define SRB_FUNCTION_REMOVE_DEVICE          0x16
312 #define SRB_FUNCTION_WMI                    0x17
313 #define SRB_FUNCTION_LOCK_QUEUE             0x18
314 #define SRB_FUNCTION_UNLOCK_QUEUE           0x19
315 #define SRB_FUNCTION_RESET_LOGICAL_UNIT     0x20
316 #define SRB_FUNCTION_SET_LINK_TIMEOUT       0x21
317 #define SRB_FUNCTION_LINK_TIMEOUT_OCCURRED  0x22
318 #define SRB_FUNCTION_LINK_TIMEOUT_COMPLETE  0x23
319 #define SRB_FUNCTION_POWER                  0x24
320 #define SRB_FUNCTION_PNP                    0x25
321 #define SRB_FUNCTION_DUMP_POINTERS          0x26
322 
323 #define SRB_STATUS_PENDING                  0x00
324 #define SRB_STATUS_SUCCESS                  0x01
325 #define SRB_STATUS_ABORTED                  0x02
326 #define SRB_STATUS_ABORT_FAILED             0x03
327 #define SRB_STATUS_ERROR                    0x04
328 #define SRB_STATUS_BUSY                     0x05
329 #define SRB_STATUS_INVALID_REQUEST          0x06
330 #define SRB_STATUS_INVALID_PATH_ID          0x07
331 #define SRB_STATUS_NO_DEVICE                0x08
332 #define SRB_STATUS_TIMEOUT                  0x09
333 #define SRB_STATUS_SELECTION_TIMEOUT        0x0A
334 #define SRB_STATUS_COMMAND_TIMEOUT          0x0B
335 #define SRB_STATUS_MESSAGE_REJECTED         0x0D
336 #define SRB_STATUS_BUS_RESET                0x0E
337 #define SRB_STATUS_PARITY_ERROR             0x0F
338 #define SRB_STATUS_REQUEST_SENSE_FAILED     0x10
339 #define SRB_STATUS_NO_HBA                   0x11
340 #define SRB_STATUS_DATA_OVERRUN             0x12
341 #define SRB_STATUS_UNEXPECTED_BUS_FREE      0x13
342 #define SRB_STATUS_PHASE_SEQUENCE_FAILURE   0x14
343 #define SRB_STATUS_BAD_SRB_BLOCK_LENGTH     0x15
344 #define SRB_STATUS_REQUEST_FLUSHED          0x16
345 #define SRB_STATUS_INVALID_LUN              0x20
346 #define SRB_STATUS_INVALID_TARGET_ID        0x21
347 #define SRB_STATUS_BAD_FUNCTION             0x22
348 #define SRB_STATUS_ERROR_RECOVERY           0x23
349 #define SRB_STATUS_NOT_POWERED              0x24
350 #define SRB_STATUS_LINK_DOWN                0x25
351 #define SRB_STATUS_INTERNAL_ERROR           0x30
352 #define SRB_STATUS_QUEUE_FROZEN             0x40
353 #define SRB_STATUS_AUTOSENSE_VALID          0x80
354 #define SRB_STATUS(Status)                  (Status & ~(SRB_STATUS_AUTOSENSE_VALID | SRB_STATUS_QUEUE_FROZEN))
355 
356 #define SRB_FLAGS_QUEUE_ACTION_ENABLE       0x00000002
357 #define SRB_FLAGS_DISABLE_DISCONNECT        0x00000004
358 #define SRB_FLAGS_DISABLE_SYNCH_TRANSFER    0x00000008
359 
360 #define SRB_FLAGS_BYPASS_FROZEN_QUEUE       0x00000010
361 #define SRB_FLAGS_DISABLE_AUTOSENSE         0x00000020
362 #define SRB_FLAGS_DATA_IN                   0x00000040
363 #define SRB_FLAGS_DATA_OUT                  0x00000080
364 #define SRB_FLAGS_NO_DATA_TRANSFER          0x00000000
365 #define SRB_FLAGS_UNSPECIFIED_DIRECTION     (SRB_FLAGS_DATA_IN | SRB_FLAGS_DATA_OUT)
366 
367 #define SRB_FLAGS_NO_QUEUE_FREEZE           0x00000100
368 #define SRB_FLAGS_ADAPTER_CACHE_ENABLE      0x00000200
369 #define SRB_FLAGS_FREE_SENSE_BUFFER         0x00000400
370 
371 #define SRB_FLAGS_IS_ACTIVE                 0x00010000
372 #define SRB_FLAGS_ALLOCATED_FROM_ZONE       0x00020000
373 #define SRB_FLAGS_SGLIST_FROM_POOL          0x00040000
374 #define SRB_FLAGS_BYPASS_LOCKED_QUEUE       0x00080000
375 
376 #define SRB_FLAGS_NO_KEEP_AWAKE             0x00100000
377 #define SRB_FLAGS_PORT_DRIVER_ALLOCSENSE    0x00200000
378 
379 #define SRB_FLAGS_PORT_DRIVER_SENSEHASPORT  0x00400000
380 #define SRB_FLAGS_DONT_START_NEXT_PACKET    0x00800000
381 
382 #define SRB_FLAGS_PORT_DRIVER_RESERVED      0x0F000000
383 #define SRB_FLAGS_CLASS_DRIVER_RESERVED     0xF0000000
384 
385 #define SRB_SIMPLE_TAG_REQUEST              0x20
386 #define SRB_HEAD_OF_QUEUE_TAG_REQUEST       0x21
387 #define SRB_ORDERED_QUEUE_TAG_REQUEST       0x22
388 
389 #define SRB_WMI_FLAGS_ADAPTER_REQUEST       0x01
390 #define SRB_POWER_FLAGS_ADAPTER_REQUEST     0x01
391 #define SRB_PNP_FLAGS_ADAPTER_REQUEST       0x01
392 
393 #define STOR_MAP_NO_BUFFERS                 (0)
394 #define STOR_MAP_ALL_BUFFERS                (1)
395 #define STOR_MAP_NON_READ_WRITE_BUFFERS     (2)
396 
397 #define VPD_SUPPORTED_PAGES                 0x00
398 #define VPD_SERIAL_NUMBER                   0x80
399 #define VPD_DEVICE_IDENTIFIERS              0x83
400 #define VPD_MEDIA_SERIAL_NUMBER             0x84
401 #define VPD_SOFTWARE_INTERFACE_IDENTIFIERS  0x84
402 #define VPD_NETWORK_MANAGEMENT_ADDRESSES    0x85
403 #define VPD_EXTENDED_INQUIRY_DATA           0x86
404 #define VPD_MODE_PAGE_POLICY                0x87
405 #define VPD_SCSI_PORTS                      0x88
406 
407 #define SCSI_SENSE_NO_SENSE                 0x00
408 #define SCSI_SENSE_RECOVERED_ERROR          0x01
409 #define SCSI_SENSE_NOT_READY                0x02
410 #define SCSI_SENSE_MEDIUM_ERROR             0x03
411 #define SCSI_SENSE_HARDWARE_ERROR           0x04
412 #define SCSI_SENSE_ILLEGAL_REQUEST          0x05
413 #define SCSI_SENSE_UNIT_ATTENTION           0x06
414 #define SCSI_SENSE_DATA_PROTECT             0x07
415 #define SCSI_SENSE_BLANK_CHECK              0x08
416 #define SCSI_SENSE_UNIQUE                   0x09
417 #define SCSI_SENSE_COPY_ABORTED             0x0A
418 #define SCSI_SENSE_ABORTED_COMMAND          0x0B
419 #define SCSI_SENSE_EQUAL                    0x0C
420 #define SCSI_SENSE_VOL_OVERFLOW             0x0D
421 #define SCSI_SENSE_MISCOMPARE               0x0E
422 #define SCSI_SENSE_RESERVED                 0x0F
423 
424 typedef enum _STOR_SYNCHRONIZATION_MODEL
425 {
426     StorSynchronizeHalfDuplex,
427     StorSynchronizeFullDuplex
428 } STOR_SYNCHRONIZATION_MODEL;
429 
430 typedef enum _STOR_DMA_WIDTH
431 {
432     DmaUnknown,
433     Dma32Bit,
434     Dma64BitScatterGather,
435     Dma64Bit
436 } STOR_DMA_WIDTH;
437 
438 typedef enum _STOR_SPINLOCK
439 {
440     DpcLock = 1,
441     StartIoLock,
442     InterruptLock
443 } STOR_SPINLOCK;
444 
445 typedef enum _SCSI_ADAPTER_CONTROL_TYPE
446 {
447     ScsiQuerySupportedControlTypes = 0,
448     ScsiStopAdapter,
449     ScsiRestartAdapter,
450     ScsiSetBootConfig,
451     ScsiSetRunningConfig,
452     ScsiAdapterControlMax,
453     MakeAdapterControlTypeSizeOfUlong = 0xffffffff
454 } SCSI_ADAPTER_CONTROL_TYPE, *PSCSI_ADAPTER_CONTROL_TYPE;
455 
456 typedef enum _SCSI_ADAPTER_CONTROL_STATUS
457 {
458     ScsiAdapterControlSuccess = 0,
459     ScsiAdapterControlUnsuccessful
460 } SCSI_ADAPTER_CONTROL_STATUS, *PSCSI_ADAPTER_CONTROL_STATUS;
461 
462 typedef enum _SCSI_NOTIFICATION_TYPE
463 {
464     RequestComplete,
465     NextRequest,
466     NextLuRequest,
467     ResetDetected,
468     _obsolete1,
469     _obsolete2,
470     RequestTimerCall,
471     BusChangeDetected,
472     WMIEvent,
473     WMIReregister,
474     LinkUp,
475     LinkDown,
476     QueryTickCount,
477     BufferOverrunDetected,
478     TraceNotification,
479     GetExtendedFunctionTable,
480     EnablePassiveInitialization = 0x1000,
481     InitializeDpc,
482     IssueDpc,
483     AcquireSpinLock,
484     ReleaseSpinLock
485 } SCSI_NOTIFICATION_TYPE, *PSCSI_NOTIFICATION_TYPE;
486 
487 typedef enum _STOR_DEVICE_POWER_STATE
488 {
489     StorPowerDeviceUnspecified = 0,
490     StorPowerDeviceD0,
491     StorPowerDeviceD1,
492     StorPowerDeviceD2,
493     StorPowerDeviceD3,
494     StorPowerDeviceMaximum
495 } STOR_DEVICE_POWER_STATE, *PSTOR_DEVICE_POWER_STATE;
496 
497 typedef enum _STOR_POWER_ACTION
498 {
499     StorPowerActionNone = 0,
500     StorPowerActionReserved,
501     StorPowerActionSleep,
502     StorPowerActionHibernate,
503     StorPowerActionShutdown,
504     StorPowerActionShutdownReset,
505     StorPowerActionShutdownOff,
506     StorPowerActionWarmEject
507 } STOR_POWER_ACTION, *PSTOR_POWER_ACTION;
508 
509 typedef enum _STOR_PNP_ACTION
510 {
511     StorStartDevice = 0x0,
512     StorRemoveDevice = 0x2,
513     StorStopDevice = 0x4,
514     StorQueryCapabilities = 0x9,
515     StorQueryResourceRequirements = 0xB,
516     StorFilterResourceRequirements = 0xD,
517     StorSurpriseRemoval = 0x17
518 } STOR_PNP_ACTION, *PSTOR_PNP_ACTION;
519 
520 typedef enum _VPD_CODE_SET
521 {
522     VpdCodeSetReserved = 0,
523     VpdCodeSetBinary = 1,
524     VpdCodeSetAscii = 2,
525     VpdCodeSetUTF8 = 3
526 } VPD_CODE_SET, *PVPD_CODE_SET;
527 
528 typedef enum _VPD_ASSOCIATION
529 {
530     VpdAssocDevice = 0,
531     VpdAssocPort = 1,
532     VpdAssocTarget = 2,
533     VpdAssocReserved1 = 3,
534     VpdAssocReserved2 = 4
535 } VPD_ASSOCIATION, *PVPD_ASSOCIATION;
536 
537 typedef enum _VPD_IDENTIFIER_TYPE
538 {
539     VpdIdentifierTypeVendorSpecific = 0,
540     VpdIdentifierTypeVendorId = 1,
541     VpdIdentifierTypeEUI64 = 2,
542     VpdIdentifierTypeFCPHName = 3,
543     VpdIdentifierTypePortRelative = 4,
544     VpdIdentifierTypeTargetPortGroup = 5,
545     VpdIdentifierTypeLogicalUnitGroup = 6,
546     VpdIdentifierTypeMD5LogicalUnitId = 7,
547     VpdIdentifierTypeSCSINameString = 8
548 } VPD_IDENTIFIER_TYPE, *PVPD_IDENTIFIER_TYPE;
549 
550 typedef enum _STORPORT_FUNCTION_CODE
551 {
552     ExtFunctionAllocatePool,
553     ExtFunctionFreePool,
554     ExtFunctionAllocateMdl,
555     ExtFunctionFreeMdl,
556     ExtFunctionBuildMdlForNonPagedPool,
557     ExtFunctionGetSystemAddress,
558     ExtFunctionGetOriginalMdl,
559     ExtFunctionCompleteServiceIrp,
560     ExtFunctionGetDeviceObjects,
561     ExtFunctionBuildScatterGatherList,
562     ExtFunctionPutScatterGatherList,
563     ExtFunctionAcquireMSISpinLock,
564     ExtFunctionReleaseMSISpinLock,
565     ExtFunctionGetMessageInterruptInformation,
566     ExtFunctionInitializePerformanceOptimizations,
567     ExtFunctionGetStartIoPerformanceParameters,
568     ExtFunctionLogSystemEvent,
569 #if (NTDDI_VERSION >= NTDDI_WIN7)
570     ExtFunctionGetCurrentProcessorNumber,
571     ExtFunctionGetActiveGroupCount,
572     ExtFunctionGetGroupAffinity,
573     ExtFunctionGetActiveNodeCount,
574     ExtFunctionGetNodeAffinity,
575     ExtFunctionGetHighestNodeNumber,
576     ExtFunctionGetLogicalProcessorRelationship,
577     ExtFunctionAllocateContiguousMemorySpecifyCacheNode,
578     ExtFunctionFreeContiguousMemorySpecifyCache
579 #endif
580 } STORPORT_FUNCTION_CODE, *PSTORPORT_FUNCTION_CODE;
581 
582 typedef enum _STOR_EVENT_ASSOCIATION_ENUM
583 {
584     StorEventAdapterAssociation = 0,
585     StorEventLunAssociation,
586     StorEventTargetAssociation,
587     StorEventInvalidAssociation
588 } STOR_EVENT_ASSOCIATION_ENUM;
589 
590 typedef enum _GETSGSTATUS
591 {
592     SG_ALLOCATED = 0,
593     SG_BUFFER_TOO_SMALL
594 } GETSGSTATUS, *PGETSGSTATUS;
595 
596 typedef struct _SCSI_REQUEST_BLOCK
597 {
598     USHORT Length;
599     UCHAR Function;
600     UCHAR SrbStatus;
601     UCHAR ScsiStatus;
602     UCHAR PathId;
603     UCHAR TargetId;
604     UCHAR Lun;
605     UCHAR QueueTag;
606     UCHAR QueueAction;
607     UCHAR CdbLength;
608     UCHAR SenseInfoBufferLength;
609     ULONG SrbFlags;
610     ULONG DataTransferLength;
611     ULONG TimeOutValue;
612     PVOID DataBuffer;
613     PVOID SenseInfoBuffer;
614     struct _SCSI_REQUEST_BLOCK *NextSrb;
615     PVOID OriginalRequest;
616     PVOID SrbExtension;
617     union
618     {
619         ULONG InternalStatus;
620         ULONG QueueSortKey;
621         ULONG LinkTimeoutValue;
622     };
623 #if defined(_WIN64)
624     ULONG Reserved;
625 #endif
626     UCHAR Cdb[16];
627 } SCSI_REQUEST_BLOCK, *PSCSI_REQUEST_BLOCK;
628 
629 typedef struct _SCSI_WMI_REQUEST_BLOCK
630 {
631     USHORT Length;
632     UCHAR Function;
633     UCHAR SrbStatus;
634     UCHAR WMISubFunction;
635     UCHAR PathId;
636     UCHAR TargetId;
637     UCHAR Lun;
638     UCHAR Reserved1;
639     UCHAR WMIFlags;
640     UCHAR Reserved2[2];
641     ULONG SrbFlags;
642     ULONG DataTransferLength;
643     ULONG TimeOutValue;
644     PVOID DataBuffer;
645     PVOID DataPath;
646     PVOID Reserved3;
647     PVOID OriginalRequest;
648     PVOID SrbExtension;
649     ULONG Reserved4;
650 #if (NTDDI_VERSION >= NTDDI_WS03SP1) && defined(_WIN64)
651     ULONG Reserved6;
652 #endif
653     UCHAR Reserved5[16];
654 } SCSI_WMI_REQUEST_BLOCK, *PSCSI_WMI_REQUEST_BLOCK;
655 
656 typedef struct _SCSI_POWER_REQUEST_BLOCK
657 {
658     USHORT Length;
659     UCHAR Function;
660     UCHAR SrbStatus;
661     UCHAR SrbPowerFlags;
662     UCHAR PathId;
663     UCHAR TargetId;
664     UCHAR Lun;
665     STOR_DEVICE_POWER_STATE DevicePowerState;
666     ULONG SrbFlags;
667     ULONG DataTransferLength;
668     ULONG TimeOutValue;
669     PVOID DataBuffer;
670     PVOID SenseInfoBuffer;
671     struct _SCSI_REQUEST_BLOCK *NextSrb;
672     PVOID OriginalRequest;
673     PVOID SrbExtension;
674     STOR_POWER_ACTION PowerAction;
675 #if defined(_WIN64)
676     ULONG Reserved;
677 #endif
678     UCHAR Reserved5[16];
679 } SCSI_POWER_REQUEST_BLOCK, *PSCSI_POWER_REQUEST_BLOCK;
680 
681 typedef struct _STOR_DEVICE_CAPABILITIES
682 {
683     USHORT Version;
684     ULONG DeviceD1:1;
685     ULONG DeviceD2:1;
686     ULONG LockSupported:1;
687     ULONG EjectSupported:1;
688     ULONG Removable:1;
689     ULONG DockDevice:1;
690     ULONG UniqueID:1;
691     ULONG SilentInstall:1;
692     ULONG SurpriseRemovalOK:1;
693     ULONG NoDisplayInUI:1;
694 } STOR_DEVICE_CAPABILITIES, *PSTOR_DEVICE_CAPABILITIES;
695 
696 typedef struct _SCSI_PNP_REQUEST_BLOCK
697 {
698     USHORT Length;
699     UCHAR Function;
700     UCHAR SrbStatus;
701     UCHAR PnPSubFunction;
702     UCHAR PathId;
703     UCHAR TargetId;
704     UCHAR Lun;
705     STOR_PNP_ACTION PnPAction;
706     ULONG SrbFlags;
707     ULONG DataTransferLength;
708     ULONG TimeOutValue;
709     PVOID DataBuffer;
710     PVOID SenseInfoBuffer;
711     struct _SCSI_REQUEST_BLOCK *NextSrb;
712     PVOID OriginalRequest;
713     PVOID SrbExtension;
714     ULONG SrbPnPFlags;
715 #if defined(_WIN64)
716     ULONG Reserved;
717 #endif
718     UCHAR Reserved4[16];
719 } SCSI_PNP_REQUEST_BLOCK, *PSCSI_PNP_REQUEST_BLOCK;
720 
721 #include <pshpack1.h>
722 typedef union _CDB
723 {
724     struct _CDB6GENERIC
725     {
726         UCHAR OperationCode;
727         UCHAR Immediate:1;
728         UCHAR CommandUniqueBits:4;
729         UCHAR LogicalUnitNumber:3;
730         UCHAR CommandUniqueBytes[3];
731         UCHAR Link:1;
732         UCHAR Flag:1;
733         UCHAR Reserved:4;
734         UCHAR VendorUnique:2;
735     } CDB6GENERIC, *PCDB6GENERIC;
736     struct _CDB6READWRITE
737     {
738         UCHAR OperationCode;
739         UCHAR LogicalBlockMsb1:5;
740         UCHAR LogicalUnitNumber:3;
741         UCHAR LogicalBlockMsb0;
742         UCHAR LogicalBlockLsb;
743         UCHAR TransferBlocks;
744         UCHAR Control;
745     } CDB6READWRITE, *PCDB6READWRITE;
746     struct _CDB6INQUIRY
747     {
748         UCHAR OperationCode;
749         UCHAR Reserved1:5;
750         UCHAR LogicalUnitNumber:3;
751         UCHAR PageCode;
752         UCHAR IReserved;
753         UCHAR AllocationLength;
754         UCHAR Control;
755     } CDB6INQUIRY, *PCDB6INQUIRY;
756     struct _CDB6INQUIRY3
757     {
758         UCHAR OperationCode;
759         UCHAR EnableVitalProductData:1;
760         UCHAR CommandSupportData:1;
761         UCHAR Reserved1:6;
762         UCHAR PageCode;
763         UCHAR Reserved2;
764         UCHAR AllocationLength;
765         UCHAR Control;
766     } CDB6INQUIRY3, *PCDB6INQUIRY3;
767     struct _CDB6VERIFY
768     {
769         UCHAR OperationCode;
770         UCHAR Fixed:1;
771         UCHAR ByteCompare:1;
772         UCHAR Immediate:1;
773         UCHAR Reserved:2;
774         UCHAR LogicalUnitNumber:3;
775         UCHAR VerificationLength[3];
776         UCHAR Control;
777     } CDB6VERIFY, *PCDB6VERIFY;
778     struct _CDB6FORMAT
779     {
780         UCHAR OperationCode;
781         UCHAR FormatControl:5;
782         UCHAR LogicalUnitNumber:3;
783         UCHAR FReserved1;
784         UCHAR InterleaveMsb;
785         UCHAR InterleaveLsb;
786         UCHAR FReserved2;
787     } CDB6FORMAT, *PCDB6FORMAT;
788     struct _CDB10
789     {
790         UCHAR OperationCode;
791         UCHAR RelativeAddress:1;
792         UCHAR Reserved1:2;
793         UCHAR ForceUnitAccess:1;
794         UCHAR DisablePageOut:1;
795         UCHAR LogicalUnitNumber:3;
796         UCHAR LogicalBlockByte0;
797         UCHAR LogicalBlockByte1;
798         UCHAR LogicalBlockByte2;
799         UCHAR LogicalBlockByte3;
800         UCHAR Reserved2;
801         UCHAR TransferBlocksMsb;
802         UCHAR TransferBlocksLsb;
803         UCHAR Control;
804     } CDB10, *PCDB10;
805     struct _CDB12
806     {
807         UCHAR OperationCode;
808         UCHAR RelativeAddress:1;
809         UCHAR Reserved1:2;
810         UCHAR ForceUnitAccess:1;
811         UCHAR DisablePageOut:1;
812         UCHAR LogicalUnitNumber:3;
813         UCHAR LogicalBlock[4];
814         UCHAR TransferLength[4];
815         UCHAR Reserved2;
816         UCHAR Control;
817     } CDB12, *PCDB12;
818     struct _CDB16
819     {
820         UCHAR OperationCode;
821         UCHAR Reserved1:3;
822         UCHAR ForceUnitAccess:1;
823         UCHAR DisablePageOut:1;
824         UCHAR Protection:3;
825         UCHAR LogicalBlock[8];
826         UCHAR TransferLength[4];
827         UCHAR Reserved2;
828         UCHAR Control;
829     } CDB16, *PCDB16;
830     struct _PAUSE_RESUME
831     {
832         UCHAR OperationCode;
833         UCHAR Reserved1:5;
834         UCHAR LogicalUnitNumber:3;
835         UCHAR Reserved2[6];
836         UCHAR Action;
837         UCHAR Control;
838     } PAUSE_RESUME, *PPAUSE_RESUME;
839     struct _READ_TOC
840     {
841         UCHAR OperationCode;
842         UCHAR Reserved0:1;
843         UCHAR Msf:1;
844         UCHAR Reserved1:3;
845         UCHAR LogicalUnitNumber:3;
846         UCHAR Format2:4;
847         UCHAR Reserved2:4;
848         UCHAR Reserved3[3];
849         UCHAR StartingTrack;
850         UCHAR AllocationLength[2];
851         UCHAR Control:6;
852         UCHAR Format:2;
853     } READ_TOC, *PREAD_TOC;
854     struct _READ_DISK_INFORMATION
855     {
856         UCHAR OperationCode;
857         UCHAR Reserved1:5;
858         UCHAR Lun:3;
859         UCHAR Reserved2[5];
860         UCHAR AllocationLength[2];
861         UCHAR Control;
862     } READ_DISK_INFORMATION, *PREAD_DISK_INFORMATION;
863     struct _READ_TRACK_INFORMATION
864     {
865         UCHAR OperationCode;
866         UCHAR Track:1;
867         UCHAR Reserved1:3;
868         UCHAR Reserved2:1;
869         UCHAR Lun:3;
870         UCHAR BlockAddress[4];
871         UCHAR Reserved3;
872         UCHAR AllocationLength[2];
873         UCHAR Control;
874     } READ_TRACK_INFORMATION, *PREAD_TRACK_INFORMATION;
875     struct _RESERVE_TRACK_RZONE
876     {
877         UCHAR OperationCode;
878         UCHAR Reserved1[4];
879         UCHAR ReservationSize[4];
880         UCHAR Control;
881     } RESERVE_TRACK_RZONE, *PRESERVE_TRACK_RZONE;
882     struct _SEND_OPC_INFORMATION
883     {
884         UCHAR OperationCode;
885         UCHAR DoOpc:1;
886         UCHAR Reserved1:7;
887         UCHAR Exclude0:1;
888         UCHAR Exclude1:1;
889         UCHAR Reserved2:6;
890         UCHAR Reserved3[4];
891         UCHAR ParameterListLength[2];
892         UCHAR Reserved4;
893     } SEND_OPC_INFORMATION, *PSEND_OPC_INFORMATION;
894     struct _REPAIR_TRACK
895     {
896         UCHAR OperationCode;
897         UCHAR Immediate:1;
898         UCHAR Reserved1:7;
899         UCHAR Reserved2[2];
900         UCHAR TrackNumber[2];
901         UCHAR Reserved3[3];
902         UCHAR Control;
903     } REPAIR_TRACK, *PREPAIR_TRACK;
904     struct _CLOSE_TRACK
905     {
906         UCHAR OperationCode;
907         UCHAR Immediate:1;
908         UCHAR Reserved1:7;
909         UCHAR Track:1;
910         UCHAR Session:1;
911         UCHAR Reserved2:6;
912         UCHAR Reserved3;
913         UCHAR TrackNumber[2];
914         UCHAR Reserved4[3];
915         UCHAR Control;
916     } CLOSE_TRACK, *PCLOSE_TRACK;
917     struct _READ_BUFFER_CAPACITY
918     {
919         UCHAR OperationCode;
920         UCHAR BlockInfo:1;
921         UCHAR Reserved1:7;
922         UCHAR Reserved2[5];
923         UCHAR AllocationLength[2];
924         UCHAR Control;
925     } READ_BUFFER_CAPACITY, *PREAD_BUFFER_CAPACITY;
926     struct _SEND_CUE_SHEET
927     {
928         UCHAR OperationCode;
929         UCHAR Reserved[5];
930         UCHAR CueSheetSize[3];
931         UCHAR Control;
932     } SEND_CUE_SHEET, *PSEND_CUE_SHEET;
933     struct _READ_HEADER
934     {
935         UCHAR OperationCode;
936         UCHAR Reserved1:1;
937         UCHAR Msf:1;
938         UCHAR Reserved2:3;
939         UCHAR Lun:3;
940         UCHAR LogicalBlockAddress[4];
941         UCHAR Reserved3;
942         UCHAR AllocationLength[2];
943         UCHAR Control;
944     } READ_HEADER, *PREAD_HEADER;
945     struct _PLAY_AUDIO
946     {
947         UCHAR OperationCode;
948         UCHAR Reserved1:5;
949         UCHAR LogicalUnitNumber:3;
950         UCHAR StartingBlockAddress[4];
951         UCHAR Reserved2;
952         UCHAR PlayLength[2];
953         UCHAR Control;
954     } PLAY_AUDIO, *PPLAY_AUDIO;
955     struct _PLAY_AUDIO_MSF
956     {
957         UCHAR OperationCode;
958         UCHAR Reserved1:5;
959         UCHAR LogicalUnitNumber:3;
960         UCHAR Reserved2;
961         UCHAR StartingM;
962         UCHAR StartingS;
963         UCHAR StartingF;
964         UCHAR EndingM;
965         UCHAR EndingS;
966         UCHAR EndingF;
967         UCHAR Control;
968     } PLAY_AUDIO_MSF, *PPLAY_AUDIO_MSF;
969     struct _BLANK_MEDIA
970     {
971         UCHAR OperationCode;
972         UCHAR BlankType:3;
973         UCHAR Reserved1:1;
974         UCHAR Immediate:1;
975         UCHAR Reserved2:3;
976         UCHAR AddressOrTrack[4];
977         UCHAR Reserved3[5];
978         UCHAR Control;
979     } BLANK_MEDIA, *PBLANK_MEDIA;
980     struct _PLAY_CD
981     {
982         UCHAR OperationCode;
983         UCHAR Reserved1:1;
984         UCHAR CMSF:1;
985         UCHAR ExpectedSectorType:3;
986         UCHAR Lun:3;
987         _ANONYMOUS_UNION union
988         {
989             struct _LBA
990             {
991                 UCHAR StartingBlockAddress[4];
992                 UCHAR PlayLength[4];
993             } LBA;
994             struct _MSF
995             {
996                 UCHAR Reserved1;
997                 UCHAR StartingM;
998                 UCHAR StartingS;
999                 UCHAR StartingF;
1000                 UCHAR EndingM;
1001                 UCHAR EndingS;
1002                 UCHAR EndingF;
1003                 UCHAR Reserved2;
1004             } MSF;
1005         } DUMMYUNIONNAME;
1006         UCHAR Audio:1;
1007         UCHAR Composite:1;
1008         UCHAR Port1:1;
1009         UCHAR Port2:1;
1010         UCHAR Reserved2:3;
1011         UCHAR Speed:1;
1012         UCHAR Control;
1013     } PLAY_CD, *PPLAY_CD;
1014     struct _SCAN_CD
1015     {
1016         UCHAR OperationCode;
1017         UCHAR RelativeAddress:1;
1018         UCHAR Reserved1:3;
1019         UCHAR Direct:1;
1020         UCHAR Lun:3;
1021         UCHAR StartingAddress[4];
1022         UCHAR Reserved2[3];
1023         UCHAR Reserved3:6;
1024         UCHAR Type:2;
1025         UCHAR Reserved4;
1026         UCHAR Control;
1027     } SCAN_CD, *PSCAN_CD;
1028     struct _STOP_PLAY_SCAN
1029     {
1030         UCHAR OperationCode;
1031         UCHAR Reserved1:5;
1032         UCHAR Lun:3;
1033         UCHAR Reserved2[7];
1034         UCHAR Control;
1035     } STOP_PLAY_SCAN, *PSTOP_PLAY_SCAN;
1036     struct _SUBCHANNEL
1037     {
1038         UCHAR OperationCode;
1039         UCHAR Reserved0:1;
1040         UCHAR Msf:1;
1041         UCHAR Reserved1:3;
1042         UCHAR LogicalUnitNumber:3;
1043         UCHAR Reserved2:6;
1044         UCHAR SubQ:1;
1045         UCHAR Reserved3:1;
1046         UCHAR Format;
1047         UCHAR Reserved4[2];
1048         UCHAR TrackNumber;
1049         UCHAR AllocationLength[2];
1050         UCHAR Control;
1051     } SUBCHANNEL, *PSUBCHANNEL;
1052     struct _READ_CD
1053     {
1054         UCHAR OperationCode;
1055         UCHAR RelativeAddress:1;
1056         UCHAR Reserved0:1;
1057         UCHAR ExpectedSectorType:3;
1058         UCHAR Lun:3;
1059         UCHAR StartingLBA[4];
1060         UCHAR TransferBlocks[3];
1061         UCHAR Reserved2:1;
1062         UCHAR ErrorFlags:2;
1063         UCHAR IncludeEDC:1;
1064         UCHAR IncludeUserData:1;
1065         UCHAR HeaderCode:2;
1066         UCHAR IncludeSyncData:1;
1067         UCHAR SubChannelSelection:3;
1068         UCHAR Reserved3:5;
1069         UCHAR Control;
1070     } READ_CD, *PREAD_CD;
1071     struct _READ_CD_MSF
1072     {
1073         UCHAR OperationCode;
1074         UCHAR RelativeAddress:1;
1075         UCHAR Reserved1:1;
1076         UCHAR ExpectedSectorType:3;
1077         UCHAR Lun:3;
1078         UCHAR Reserved2;
1079         UCHAR StartingM;
1080         UCHAR StartingS;
1081         UCHAR StartingF;
1082         UCHAR EndingM;
1083         UCHAR EndingS;
1084         UCHAR EndingF;
1085         UCHAR Reserved3;
1086         UCHAR Reserved4:1;
1087         UCHAR ErrorFlags:2;
1088         UCHAR IncludeEDC:1;
1089         UCHAR IncludeUserData:1;
1090         UCHAR HeaderCode:2;
1091         UCHAR IncludeSyncData:1;
1092         UCHAR SubChannelSelection:3;
1093         UCHAR Reserved5:5;
1094         UCHAR Control;
1095     } READ_CD_MSF, *PREAD_CD_MSF;
1096     struct _PLXTR_READ_CDDA
1097     {
1098         UCHAR OperationCode;
1099         UCHAR Reserved0:5;
1100         UCHAR LogicalUnitNumber:3;
1101         UCHAR LogicalBlockByte0;
1102         UCHAR LogicalBlockByte1;
1103         UCHAR LogicalBlockByte2;
1104         UCHAR LogicalBlockByte3;
1105         UCHAR TransferBlockByte0;
1106         UCHAR TransferBlockByte1;
1107         UCHAR TransferBlockByte2;
1108         UCHAR TransferBlockByte3;
1109         UCHAR SubCode;
1110         UCHAR Control;
1111     } PLXTR_READ_CDDA, *PPLXTR_READ_CDDA;
1112     struct _NEC_READ_CDDA
1113     {
1114         UCHAR OperationCode;
1115         UCHAR Reserved0;
1116         UCHAR LogicalBlockByte0;
1117         UCHAR LogicalBlockByte1;
1118         UCHAR LogicalBlockByte2;
1119         UCHAR LogicalBlockByte3;
1120         UCHAR Reserved1;
1121         UCHAR TransferBlockByte0;
1122         UCHAR TransferBlockByte1;
1123         UCHAR Control;
1124     } NEC_READ_CDDA, *PNEC_READ_CDDA;
1125     struct _MODE_SENSE
1126     {
1127         UCHAR OperationCode;
1128         UCHAR Reserved1:3;
1129         UCHAR Dbd:1;
1130         UCHAR Reserved2:1;
1131         UCHAR LogicalUnitNumber:3;
1132         UCHAR PageCode:6;
1133         UCHAR Pc:2;
1134         UCHAR Reserved3;
1135         UCHAR AllocationLength;
1136         UCHAR Control;
1137     } MODE_SENSE, *PMODE_SENSE;
1138     struct _MODE_SENSE10
1139     {
1140         UCHAR OperationCode;
1141         UCHAR Reserved1:3;
1142         UCHAR Dbd:1;
1143         UCHAR Reserved2:1;
1144         UCHAR LogicalUnitNumber:3;
1145         UCHAR PageCode:6;
1146         UCHAR Pc:2;
1147         UCHAR Reserved3[4];
1148         UCHAR AllocationLength[2];
1149         UCHAR Control;
1150     } MODE_SENSE10, *PMODE_SENSE10;
1151     struct _MODE_SELECT
1152     {
1153         UCHAR OperationCode;
1154         UCHAR SPBit:1;
1155         UCHAR Reserved1:3;
1156         UCHAR PFBit:1;
1157         UCHAR LogicalUnitNumber:3;
1158         UCHAR Reserved2[2];
1159         UCHAR ParameterListLength;
1160         UCHAR Control;
1161     } MODE_SELECT, *PMODE_SELECT;
1162     struct _MODE_SELECT10
1163     {
1164         UCHAR OperationCode;
1165         UCHAR SPBit:1;
1166         UCHAR Reserved1:3;
1167         UCHAR PFBit:1;
1168         UCHAR LogicalUnitNumber:3;
1169         UCHAR Reserved2[5];
1170         UCHAR ParameterListLength[2];
1171         UCHAR Control;
1172     } MODE_SELECT10, *PMODE_SELECT10;
1173     struct _LOCATE
1174     {
1175         UCHAR OperationCode;
1176         UCHAR Immediate:1;
1177         UCHAR CPBit:1;
1178         UCHAR BTBit:1;
1179         UCHAR Reserved1:2;
1180         UCHAR LogicalUnitNumber:3;
1181         UCHAR Reserved3;
1182         UCHAR LogicalBlockAddress[4];
1183         UCHAR Reserved4;
1184         UCHAR Partition;
1185         UCHAR Control;
1186     } LOCATE, *PLOCATE;
1187     struct _LOGSENSE
1188     {
1189         UCHAR OperationCode;
1190         UCHAR SPBit:1;
1191         UCHAR PPCBit:1;
1192         UCHAR Reserved1:3;
1193         UCHAR LogicalUnitNumber:3;
1194         UCHAR PageCode:6;
1195         UCHAR PCBit:2;
1196         UCHAR Reserved2;
1197         UCHAR Reserved3;
1198         UCHAR ParameterPointer[2];
1199         UCHAR AllocationLength[2];
1200         UCHAR Control;
1201     } LOGSENSE, *PLOGSENSE;
1202     struct _LOGSELECT
1203     {
1204         UCHAR OperationCode;
1205         UCHAR SPBit:1;
1206         UCHAR PCRBit:1;
1207         UCHAR Reserved1:3;
1208         UCHAR LogicalUnitNumber:3;
1209         UCHAR Reserved:6;
1210         UCHAR PCBit:2;
1211         UCHAR Reserved2[4];
1212         UCHAR ParameterListLength[2];
1213         UCHAR Control;
1214     } LOGSELECT, *PLOGSELECT;
1215     struct _PRINT
1216     {
1217         UCHAR OperationCode;
1218         UCHAR Reserved:5;
1219         UCHAR LogicalUnitNumber:3;
1220         UCHAR TransferLength[3];
1221         UCHAR Control;
1222     } PRINT, *PPRINT;
1223     struct _SEEK
1224     {
1225         UCHAR OperationCode;
1226         UCHAR Reserved1:5;
1227         UCHAR LogicalUnitNumber:3;
1228         UCHAR LogicalBlockAddress[4];
1229         UCHAR Reserved2[3];
1230         UCHAR Control;
1231     } SEEK, *PSEEK;
1232     struct _ERASE
1233     {
1234         UCHAR OperationCode;
1235         UCHAR Long:1;
1236         UCHAR Immediate:1;
1237         UCHAR Reserved1:3;
1238         UCHAR LogicalUnitNumber:3;
1239         UCHAR Reserved2[3];
1240         UCHAR Control;
1241     } ERASE, *PERASE;
1242     struct _START_STOP
1243     {
1244         UCHAR OperationCode;
1245         UCHAR Immediate:1;
1246         UCHAR Reserved1:4;
1247         UCHAR LogicalUnitNumber:3;
1248         UCHAR Reserved2[2];
1249         UCHAR Start:1;
1250         UCHAR LoadEject:1;
1251         UCHAR Reserved3:6;
1252         UCHAR Control;
1253     } START_STOP, *PSTART_STOP;
1254     struct _MEDIA_REMOVAL
1255     {
1256         UCHAR OperationCode;
1257         UCHAR Reserved1:5;
1258         UCHAR LogicalUnitNumber:3;
1259         UCHAR Reserved2[2];
1260         UCHAR Prevent:1;
1261         UCHAR Persistant:1;
1262         UCHAR Reserved3:6;
1263         UCHAR Control;
1264     } MEDIA_REMOVAL, *PMEDIA_REMOVAL;
1265     struct _SEEK_BLOCK
1266     {
1267         UCHAR OperationCode;
1268         UCHAR Immediate:1;
1269         UCHAR Reserved1:7;
1270         UCHAR BlockAddress[3];
1271         UCHAR Link:1;
1272         UCHAR Flag:1;
1273         UCHAR Reserved2:4;
1274         UCHAR VendorUnique:2;
1275     } SEEK_BLOCK, *PSEEK_BLOCK;
1276     struct _REQUEST_BLOCK_ADDRESS
1277     {
1278         UCHAR OperationCode;
1279         UCHAR Reserved1[3];
1280         UCHAR AllocationLength;
1281         UCHAR Link:1;
1282         UCHAR Flag:1;
1283         UCHAR Reserved2:4;
1284         UCHAR VendorUnique:2;
1285     } REQUEST_BLOCK_ADDRESS, *PREQUEST_BLOCK_ADDRESS;
1286     struct _PARTITION
1287     {
1288         UCHAR OperationCode;
1289         UCHAR Immediate:1;
1290         UCHAR Sel:1;
1291         UCHAR PartitionSelect:6;
1292         UCHAR Reserved1[3];
1293         UCHAR Control;
1294     } PARTITION, *PPARTITION;
1295     struct _WRITE_TAPE_MARKS
1296     {
1297         UCHAR OperationCode;
1298         UCHAR Immediate:1;
1299         UCHAR WriteSetMarks:1;
1300         UCHAR Reserved:3;
1301         UCHAR LogicalUnitNumber:3;
1302         UCHAR TransferLength[3];
1303         UCHAR Control;
1304     } WRITE_TAPE_MARKS, *PWRITE_TAPE_MARKS;
1305     struct _SPACE_TAPE_MARKS
1306     {
1307         UCHAR OperationCode;
1308         UCHAR Code:3;
1309         UCHAR Reserved:2;
1310         UCHAR LogicalUnitNumber:3;
1311         UCHAR NumMarksMSB;
1312         UCHAR NumMarks;
1313         UCHAR NumMarksLSB;
1314         union
1315         {
1316             UCHAR value;
1317             struct
1318             {
1319                 UCHAR Link:1;
1320                 UCHAR Flag:1;
1321                 UCHAR Reserved:4;
1322                 UCHAR VendorUnique:2;
1323             } Fields;
1324         } Byte6;
1325     } SPACE_TAPE_MARKS, *PSPACE_TAPE_MARKS;
1326     struct _READ_POSITION
1327     {
1328         UCHAR Operation;
1329         UCHAR BlockType:1;
1330         UCHAR Reserved1:4;
1331         UCHAR Lun:3;
1332         UCHAR Reserved2[7];
1333         UCHAR Control;
1334     } READ_POSITION, *PREAD_POSITION;
1335     struct _CDB6READWRITETAPE
1336     {
1337         UCHAR OperationCode;
1338         UCHAR VendorSpecific:5;
1339         UCHAR Reserved:3;
1340         UCHAR TransferLenMSB;
1341         UCHAR TransferLen;
1342         UCHAR TransferLenLSB;
1343         UCHAR Link:1;
1344         UCHAR Flag:1;
1345         UCHAR Reserved1:4;
1346         UCHAR VendorUnique:2;
1347     } CDB6READWRITETAPE, *PCDB6READWRITETAPE;
1348     struct _INIT_ELEMENT_STATUS
1349     {
1350         UCHAR OperationCode;
1351         UCHAR Reserved1:5;
1352         UCHAR LogicalUnitNubmer:3;
1353         UCHAR Reserved2[3];
1354         UCHAR Reserved3:7;
1355         UCHAR NoBarCode:1;
1356     } INIT_ELEMENT_STATUS, *PINIT_ELEMENT_STATUS;
1357     struct _INITIALIZE_ELEMENT_RANGE
1358     {
1359         UCHAR OperationCode;
1360         UCHAR Range:1;
1361         UCHAR Reserved1:4;
1362         UCHAR LogicalUnitNubmer:3;
1363         UCHAR FirstElementAddress[2];
1364         UCHAR Reserved2[2];
1365         UCHAR NumberOfElements[2];
1366         UCHAR Reserved3;
1367         UCHAR Reserved4:7;
1368         UCHAR NoBarCode:1;
1369     } INITIALIZE_ELEMENT_RANGE, *PINITIALIZE_ELEMENT_RANGE;
1370     struct _POSITION_TO_ELEMENT
1371     {
1372         UCHAR OperationCode;
1373         UCHAR Reserved1:5;
1374         UCHAR LogicalUnitNumber:3;
1375         UCHAR TransportElementAddress[2];
1376         UCHAR DestinationElementAddress[2];
1377         UCHAR Reserved2[2];
1378         UCHAR Flip:1;
1379         UCHAR Reserved3:7;
1380         UCHAR Control;
1381     } POSITION_TO_ELEMENT, *PPOSITION_TO_ELEMENT;
1382     struct _MOVE_MEDIUM
1383     {
1384         UCHAR OperationCode;
1385         UCHAR Reserved1:5;
1386         UCHAR LogicalUnitNumber:3;
1387         UCHAR TransportElementAddress[2];
1388         UCHAR SourceElementAddress[2];
1389         UCHAR DestinationElementAddress[2];
1390         UCHAR Reserved2[2];
1391         UCHAR Flip:1;
1392         UCHAR Reserved3:7;
1393         UCHAR Control;
1394     } MOVE_MEDIUM, *PMOVE_MEDIUM;
1395     struct _EXCHANGE_MEDIUM
1396     {
1397         UCHAR OperationCode;
1398         UCHAR Reserved1:5;
1399         UCHAR LogicalUnitNumber:3;
1400         UCHAR TransportElementAddress[2];
1401         UCHAR SourceElementAddress[2];
1402         UCHAR Destination1ElementAddress[2];
1403         UCHAR Destination2ElementAddress[2];
1404         UCHAR Flip1:1;
1405         UCHAR Flip2:1;
1406         UCHAR Reserved3:6;
1407         UCHAR Control;
1408     } EXCHANGE_MEDIUM, *PEXCHANGE_MEDIUM;
1409     struct _READ_ELEMENT_STATUS
1410     {
1411         UCHAR OperationCode;
1412         UCHAR ElementType:4;
1413         UCHAR VolTag:1;
1414         UCHAR LogicalUnitNumber:3;
1415         UCHAR StartingElementAddress[2];
1416         UCHAR NumberOfElements[2];
1417         UCHAR Reserved1;
1418         UCHAR AllocationLength[3];
1419         UCHAR Reserved2;
1420         UCHAR Control;
1421     } READ_ELEMENT_STATUS, *PREAD_ELEMENT_STATUS;
1422     struct _SEND_VOLUME_TAG
1423     {
1424         UCHAR OperationCode;
1425         UCHAR ElementType:4;
1426         UCHAR Reserved1:1;
1427         UCHAR LogicalUnitNumber:3;
1428         UCHAR StartingElementAddress[2];
1429         UCHAR Reserved2;
1430         UCHAR ActionCode:5;
1431         UCHAR Reserved3:3;
1432         UCHAR Reserved4[2];
1433         UCHAR ParameterListLength[2];
1434         UCHAR Reserved5;
1435         UCHAR Control;
1436     } SEND_VOLUME_TAG, *PSEND_VOLUME_TAG;
1437     struct _REQUEST_VOLUME_ELEMENT_ADDRESS
1438     {
1439         UCHAR OperationCode;
1440         UCHAR ElementType:4;
1441         UCHAR VolTag:1;
1442         UCHAR LogicalUnitNumber:3;
1443         UCHAR StartingElementAddress[2];
1444         UCHAR NumberElements[2];
1445         UCHAR Reserved1;
1446         UCHAR AllocationLength[3];
1447         UCHAR Reserved2;
1448         UCHAR Control;
1449     } REQUEST_VOLUME_ELEMENT_ADDRESS, *PREQUEST_VOLUME_ELEMENT_ADDRESS;
1450     struct _LOAD_UNLOAD
1451     {
1452         UCHAR OperationCode;
1453         UCHAR Immediate:1;
1454         UCHAR Reserved1:4;
1455         UCHAR Lun:3;
1456         UCHAR Reserved2[2];
1457         UCHAR Start:1;
1458         UCHAR LoadEject:1;
1459         UCHAR Reserved3:6;
1460         UCHAR Reserved4[3];
1461         UCHAR Slot;
1462         UCHAR Reserved5[3];
1463     } LOAD_UNLOAD, *PLOAD_UNLOAD;
1464     struct _MECH_STATUS
1465     {
1466         UCHAR OperationCode;
1467         UCHAR Reserved:5;
1468         UCHAR Lun:3;
1469         UCHAR Reserved1[6];
1470         UCHAR AllocationLength[2];
1471         UCHAR Reserved2[1];
1472         UCHAR Control;
1473     } MECH_STATUS, *PMECH_STATUS;
1474     struct _SYNCHRONIZE_CACHE10
1475     {
1476         UCHAR OperationCode;
1477         UCHAR RelAddr:1;
1478         UCHAR Immediate:1;
1479         UCHAR Reserved:3;
1480         UCHAR Lun:3;
1481         UCHAR LogicalBlockAddress[4];
1482         UCHAR Reserved2;
1483         UCHAR BlockCount[2];
1484         UCHAR Control;
1485     } SYNCHRONIZE_CACHE10, *PSYNCHRONIZE_CACHE10;
1486     struct _GET_EVENT_STATUS_NOTIFICATION
1487     {
1488         UCHAR OperationCode;
1489         UCHAR Immediate:1;
1490         UCHAR Reserved:4;
1491         UCHAR Lun:3;
1492         UCHAR Reserved2[2];
1493         UCHAR NotificationClassRequest;
1494         UCHAR Reserved3[2];
1495         UCHAR EventListLength[2];
1496         UCHAR Control;
1497     } GET_EVENT_STATUS_NOTIFICATION, *PGET_EVENT_STATUS_NOTIFICATION;
1498     struct _GET_PERFORMANCE
1499     {
1500         UCHAR OperationCode;
1501         UCHAR Except:2;
1502         UCHAR Write:1;
1503         UCHAR Tolerance:2;
1504         UCHAR Reserved0:3;
1505         UCHAR StartingLBA[4];
1506         UCHAR Reserved1[2];
1507         UCHAR MaximumNumberOfDescriptors[2];
1508         UCHAR Type;
1509         UCHAR Control;
1510     } GET_PERFORMANCE;
1511     struct _READ_DVD_STRUCTURE
1512     {
1513         UCHAR OperationCode;
1514         UCHAR Reserved1:5;
1515         UCHAR Lun:3;
1516         UCHAR RMDBlockNumber[4];
1517         UCHAR LayerNumber;
1518         UCHAR Format;
1519         UCHAR AllocationLength[2];
1520         UCHAR Reserved3:6;
1521         UCHAR AGID:2;
1522         UCHAR Control;
1523     } READ_DVD_STRUCTURE, *PREAD_DVD_STRUCTURE;
1524     struct _SET_STREAMING
1525     {
1526         UCHAR OperationCode;
1527         UCHAR Reserved[8];
1528         UCHAR ParameterListLength[2];
1529         UCHAR Control;
1530     } SET_STREAMING;
1531     struct _SEND_DVD_STRUCTURE
1532     {
1533         UCHAR OperationCode;
1534         UCHAR Reserved1:5;
1535         UCHAR Lun:3;
1536         UCHAR Reserved2[5];
1537         UCHAR Format;
1538         UCHAR ParameterListLength[2];
1539         UCHAR Reserved3;
1540         UCHAR Control;
1541     } SEND_DVD_STRUCTURE, *PSEND_DVD_STRUCTURE;
1542     struct _SEND_KEY
1543     {
1544         UCHAR OperationCode;
1545         UCHAR Reserved1:5;
1546         UCHAR Lun:3;
1547         UCHAR Reserved2[6];
1548         UCHAR ParameterListLength[2];
1549         UCHAR KeyFormat:6;
1550         UCHAR AGID:2;
1551         UCHAR Control;
1552     } SEND_KEY, *PSEND_KEY;
1553     struct _REPORT_KEY
1554     {
1555         UCHAR OperationCode;
1556         UCHAR Reserved1:5;
1557         UCHAR Lun:3;
1558         UCHAR LogicalBlockAddress[4];
1559         UCHAR Reserved2[2];
1560         UCHAR AllocationLength[2];
1561         UCHAR KeyFormat:6;
1562         UCHAR AGID:2;
1563         UCHAR Control;
1564     } REPORT_KEY, *PREPORT_KEY;
1565     struct _SET_READ_AHEAD
1566     {
1567         UCHAR OperationCode;
1568         UCHAR Reserved1:5;
1569         UCHAR Lun:3;
1570         UCHAR TriggerLBA[4];
1571         UCHAR ReadAheadLBA[4];
1572         UCHAR Reserved2;
1573         UCHAR Control;
1574     } SET_READ_AHEAD, *PSET_READ_AHEAD;
1575     struct _READ_FORMATTED_CAPACITIES
1576     {
1577         UCHAR OperationCode;
1578         UCHAR Reserved1:5;
1579         UCHAR Lun:3;
1580         UCHAR Reserved2[5];
1581         UCHAR AllocationLength[2];
1582         UCHAR Control;
1583     } READ_FORMATTED_CAPACITIES, *PREAD_FORMATTED_CAPACITIES;
1584     struct _REPORT_LUNS
1585     {
1586         UCHAR OperationCode;
1587         UCHAR Reserved1[5];
1588         UCHAR AllocationLength[4];
1589         UCHAR Reserved2[1];
1590         UCHAR Control;
1591     } REPORT_LUNS, *PREPORT_LUNS;
1592     struct _PERSISTENT_RESERVE_IN
1593     {
1594         UCHAR OperationCode;
1595         UCHAR ServiceAction:5;
1596         UCHAR Reserved1:3;
1597         UCHAR Reserved2[5];
1598         UCHAR AllocationLength[2];
1599         UCHAR Control;
1600     } PERSISTENT_RESERVE_IN, *PPERSISTENT_RESERVE_IN;
1601     struct _PERSISTENT_RESERVE_OUT
1602     {
1603         UCHAR OperationCode;
1604         UCHAR ServiceAction:5;
1605         UCHAR Reserved1:3;
1606         UCHAR Type:4;
1607         UCHAR Scope:4;
1608         UCHAR Reserved2[4];
1609         UCHAR ParameterListLength[2];
1610         UCHAR Control;
1611     } PERSISTENT_RESERVE_OUT, *PPERSISTENT_RESERVE_OUT;
1612     struct _GET_CONFIGURATION
1613     {
1614         UCHAR OperationCode;
1615         UCHAR RequestType:1;
1616         UCHAR Reserved1:7;
1617         UCHAR StartingFeature[2];
1618         UCHAR Reserved2[3];
1619         UCHAR AllocationLength[2];
1620         UCHAR Control;
1621     } GET_CONFIGURATION, *PGET_CONFIGURATION;
1622     struct _SET_CD_SPEED
1623     {
1624         UCHAR OperationCode;
1625         _ANONYMOUS_UNION union
1626         {
1627             UCHAR Reserved1;
1628             _ANONYMOUS_STRUCT struct
1629             {
1630                 UCHAR RotationControl:2;
1631                 UCHAR Reserved3:6;
1632             } DUMMYSTRUCTNAME;
1633         } DUMMYUNIONNAME;
1634         UCHAR ReadSpeed[2];
1635         UCHAR WriteSpeed[2];
1636         UCHAR Reserved2[5];
1637         UCHAR Control;
1638     } SET_CD_SPEED, *PSET_CD_SPEED;
1639     struct _READ12
1640     {
1641         UCHAR OperationCode;
1642         UCHAR RelativeAddress:1;
1643         UCHAR Reserved1:2;
1644         UCHAR ForceUnitAccess:1;
1645         UCHAR DisablePageOut:1;
1646         UCHAR LogicalUnitNumber:3;
1647         UCHAR LogicalBlock[4];
1648         UCHAR TransferLength[4];
1649         UCHAR Reserved2:7;
1650         UCHAR Streaming:1;
1651         UCHAR Control;
1652     } READ12;
1653     struct _WRITE12
1654     {
1655         UCHAR OperationCode;
1656         UCHAR RelativeAddress:1;
1657         UCHAR Reserved1:1;
1658         UCHAR EBP:1;
1659         UCHAR ForceUnitAccess:1;
1660         UCHAR DisablePageOut:1;
1661         UCHAR LogicalUnitNumber:3;
1662         UCHAR LogicalBlock[4];
1663         UCHAR TransferLength[4];
1664         UCHAR Reserved2:7;
1665         UCHAR Streaming:1;
1666         UCHAR Control;
1667     } WRITE12;
1668     struct _READ16
1669     {
1670         UCHAR OperationCode;
1671         UCHAR Reserved1:3;
1672         UCHAR ForceUnitAccess:1;
1673         UCHAR DisablePageOut:1;
1674         UCHAR ReadProtect:3;
1675         UCHAR LogicalBlock[8];
1676         UCHAR TransferLength[4];
1677         UCHAR Reserved2:7;
1678         UCHAR Streaming:1;
1679         UCHAR Control;
1680     } READ16;
1681     struct _WRITE16
1682     {
1683         UCHAR OperationCode;
1684         UCHAR Reserved1:3;
1685         UCHAR ForceUnitAccess:1;
1686         UCHAR DisablePageOut:1;
1687         UCHAR WriteProtect:3;
1688         UCHAR LogicalBlock[8];
1689         UCHAR TransferLength[4];
1690         UCHAR Reserved2:7;
1691         UCHAR Streaming:1;
1692         UCHAR Control;
1693     } WRITE16;
1694     struct _VERIFY16
1695     {
1696         UCHAR OperationCode;
1697         UCHAR Reserved1:1;
1698         UCHAR ByteCheck:1;
1699         UCHAR BlockVerify:1;
1700         UCHAR Reserved2: 1;
1701         UCHAR DisablePageOut:1;
1702         UCHAR VerifyProtect:3;
1703         UCHAR LogicalBlock[8];
1704         UCHAR VerificationLength[4];
1705         UCHAR Reserved3:7;
1706         UCHAR Streaming:1;
1707         UCHAR Control;
1708     } VERIFY16;
1709     struct _SYNCHRONIZE_CACHE16
1710     {
1711         UCHAR OperationCode;
1712         UCHAR Reserved1:1;
1713         UCHAR Immediate:1;
1714         UCHAR Reserved2:6;
1715         UCHAR LogicalBlock[8];
1716         UCHAR BlockCount[4];
1717         UCHAR Reserved3;
1718         UCHAR Control;
1719     } SYNCHRONIZE_CACHE16;
1720     struct _READ_CAPACITY16
1721     {
1722         UCHAR OperationCode;
1723         UCHAR ServiceAction:5;
1724         UCHAR Reserved1:3;
1725         UCHAR LogicalBlock[8];
1726         UCHAR BlockCount[4];
1727         UCHAR PMI:1;
1728         UCHAR Reserved2:7;
1729         UCHAR Control;
1730     } READ_CAPACITY16;
1731     ULONG AsUlong[4];
1732     UCHAR AsByte[16];
1733 } CDB, *PCDB;
1734 
1735 typedef union _EIGHT_BYTE
1736 {
1737     struct
1738     {
1739         UCHAR Byte0;
1740         UCHAR Byte1;
1741         UCHAR Byte2;
1742         UCHAR Byte3;
1743         UCHAR Byte4;
1744         UCHAR Byte5;
1745         UCHAR Byte6;
1746         UCHAR Byte7;
1747     };
1748     ULONGLONG AsULongLong;
1749 } EIGHT_BYTE, *PEIGHT_BYTE;
1750 
1751 typedef union _FOUR_BYTE
1752 {
1753     struct
1754     {
1755         UCHAR Byte0;
1756         UCHAR Byte1;
1757         UCHAR Byte2;
1758         UCHAR Byte3;
1759     };
1760     ULONG AsULong;
1761 } FOUR_BYTE, *PFOUR_BYTE;
1762 
1763 typedef union _TWO_BYTE
1764 {
1765     struct
1766     {
1767         UCHAR Byte0;
1768         UCHAR Byte1;
1769     };
1770     USHORT AsUShort;
1771 } TWO_BYTE, *PTWO_BYTE;
1772 #include <poppack.h>
1773 
1774 #if (NTDDI_VERSION < NTDDI_WINXP)
1775 typedef struct _INQUIRYDATA
1776 {
1777     UCHAR DeviceType:5;
1778     UCHAR DeviceTypeQualifier:3;
1779     UCHAR DeviceTypeModifier:7;
1780     UCHAR RemovableMedia:1;
1781     UCHAR Versions;
1782     UCHAR ResponseDataFormat:4;
1783     UCHAR HiSupport:1;
1784     UCHAR NormACA:1;
1785     UCHAR ReservedBit:1;
1786     UCHAR AERC:1;
1787     UCHAR AdditionalLength;
1788     UCHAR Reserved[2];
1789     UCHAR SoftReset:1;
1790     UCHAR CommandQueue:1;
1791     UCHAR Reserved2:1;
1792     UCHAR LinkedCommands:1;
1793     UCHAR Synchronous:1;
1794     UCHAR Wide16Bit:1;
1795     UCHAR Wide32Bit:1;
1796     UCHAR RelativeAddressing:1;
1797     UCHAR VendorId[8];
1798     UCHAR ProductId[16];
1799     UCHAR ProductRevisionLevel[4];
1800     UCHAR VendorSpecific[20];
1801     UCHAR Reserved3[40];
1802 } INQUIRYDATA, *PINQUIRYDATA;
1803 #else
1804 #include <pshpack1.h>
1805 typedef struct _INQUIRYDATA
1806 {
1807     UCHAR DeviceType:5;
1808     UCHAR DeviceTypeQualifier:3;
1809     UCHAR DeviceTypeModifier:7;
1810     UCHAR RemovableMedia:1;
1811     union
1812     {
1813         UCHAR Versions;
1814         struct
1815         {
1816             UCHAR ANSIVersion:3;
1817             UCHAR ECMAVersion:3;
1818             UCHAR ISOVersion:2;
1819         };
1820     };
1821     UCHAR ResponseDataFormat:4;
1822     UCHAR HiSupport:1;
1823     UCHAR NormACA:1;
1824     UCHAR TerminateTask:1;
1825     UCHAR AERC:1;
1826     UCHAR AdditionalLength;
1827     UCHAR Reserved;
1828     UCHAR Addr16:1;
1829     UCHAR Addr32:1;
1830     UCHAR AckReqQ:1;
1831     UCHAR MediumChanger:1;
1832     UCHAR MultiPort:1;
1833     UCHAR ReservedBit2:1;
1834     UCHAR EnclosureServices:1;
1835     UCHAR ReservedBit3:1;
1836     UCHAR SoftReset:1;
1837     UCHAR CommandQueue:1;
1838     UCHAR TransferDisable:1;
1839     UCHAR LinkedCommands:1;
1840     UCHAR Synchronous:1;
1841     UCHAR Wide16Bit:1;
1842     UCHAR Wide32Bit:1;
1843     UCHAR RelativeAddressing:1;
1844     UCHAR VendorId[8];
1845     UCHAR ProductId[16];
1846     UCHAR ProductRevisionLevel[4];
1847     UCHAR VendorSpecific[20];
1848     UCHAR Reserved3[40];
1849 } INQUIRYDATA, *PINQUIRYDATA;
1850 #include <poppack.h>
1851 #endif
1852 
1853 typedef struct _VPD_MEDIA_SERIAL_NUMBER_PAGE
1854 {
1855     UCHAR DeviceType:5;
1856     UCHAR DeviceTypeQualifier:3;
1857     UCHAR PageCode;
1858     UCHAR Reserved;
1859     UCHAR PageLength;
1860     UCHAR SerialNumber[0];
1861 } VPD_MEDIA_SERIAL_NUMBER_PAGE, *PVPD_MEDIA_SERIAL_NUMBER_PAGE;
1862 
1863 typedef struct _VPD_SERIAL_NUMBER_PAGE
1864 {
1865     UCHAR DeviceType:5;
1866     UCHAR DeviceTypeQualifier:3;
1867     UCHAR PageCode;
1868     UCHAR Reserved;
1869     UCHAR PageLength;
1870     UCHAR SerialNumber[0];
1871 } VPD_SERIAL_NUMBER_PAGE, *PVPD_SERIAL_NUMBER_PAGE;
1872 
1873 typedef struct _VPD_IDENTIFICATION_DESCRIPTOR
1874 {
1875     UCHAR CodeSet:4;
1876     UCHAR Reserved:4;
1877     UCHAR IdentifierType:4;
1878     UCHAR Association:2;
1879     UCHAR Reserved2:2;
1880     UCHAR Reserved3;
1881     UCHAR IdentifierLength;
1882     UCHAR Identifier[0];
1883 } VPD_IDENTIFICATION_DESCRIPTOR, *PVPD_IDENTIFICATION_DESCRIPTOR;
1884 
1885 typedef struct _VPD_IDENTIFICATION_PAGE
1886 {
1887     UCHAR DeviceType:5;
1888     UCHAR DeviceTypeQualifier:3;
1889     UCHAR PageCode;
1890     UCHAR Reserved;
1891     UCHAR PageLength;
1892     UCHAR Descriptors[0];
1893 } VPD_IDENTIFICATION_PAGE, *PVPD_IDENTIFICATION_PAGE;
1894 
1895 typedef struct _VPD_SUPPORTED_PAGES_PAGE
1896 {
1897     UCHAR DeviceType:5;
1898     UCHAR DeviceTypeQualifier:3;
1899     UCHAR PageCode;
1900     UCHAR Reserved;
1901     UCHAR PageLength;
1902     UCHAR SupportedPageList[0];
1903 } VPD_SUPPORTED_PAGES_PAGE, *PVPD_SUPPORTED_PAGES_PAGE;
1904 
1905 #include <pshpack1.h>
1906 typedef struct _READ_CAPACITY_DATA
1907 {
1908     ULONG LogicalBlockAddress;
1909     ULONG BytesPerBlock;
1910 } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
1911 
1912 typedef struct _READ_CAPACITY_DATA_EX
1913 {
1914     LARGE_INTEGER LogicalBlockAddress;
1915     ULONG BytesPerBlock;
1916 } READ_CAPACITY_DATA_EX, *PREAD_CAPACITY_DATA_EX;
1917 
1918 typedef struct _MODE_PARAMETER_HEADER
1919 {
1920     UCHAR ModeDataLength;
1921     UCHAR MediumType;
1922     UCHAR DeviceSpecificParameter;
1923     UCHAR BlockDescriptorLength;
1924 }MODE_PARAMETER_HEADER, *PMODE_PARAMETER_HEADER;
1925 
1926 typedef struct _MODE_PARAMETER_HEADER10
1927 {
1928     UCHAR ModeDataLength[2];
1929     UCHAR MediumType;
1930     UCHAR DeviceSpecificParameter;
1931     UCHAR Reserved[2];
1932     UCHAR BlockDescriptorLength[2];
1933 }MODE_PARAMETER_HEADER10, *PMODE_PARAMETER_HEADER10;
1934 
1935 typedef struct _MODE_PARAMETER_BLOCK
1936 {
1937     UCHAR DensityCode;
1938     UCHAR NumberOfBlocks[3];
1939     UCHAR Reserved;
1940     UCHAR BlockLength[3];
1941 }MODE_PARAMETER_BLOCK, *PMODE_PARAMETER_BLOCK;
1942 
1943 typedef struct _LUN_LIST
1944 {
1945     UCHAR LunListLength[4];
1946     UCHAR Reserved[4];
1947 #if !defined(__midl)
1948     UCHAR Lun[0][8];
1949 #endif
1950 } LUN_LIST, *PLUN_LIST;
1951 
1952 typedef struct _SENSE_DATA
1953 {
1954     UCHAR ErrorCode:7;
1955     UCHAR Valid:1;
1956     UCHAR SegmentNumber;
1957     UCHAR SenseKey:4;
1958     UCHAR Reserved:1;
1959     UCHAR IncorrectLength:1;
1960     UCHAR EndOfMedia:1;
1961     UCHAR FileMark:1;
1962     UCHAR Information[4];
1963     UCHAR AdditionalSenseLength;
1964     UCHAR CommandSpecificInformation[4];
1965     UCHAR AdditionalSenseCode;
1966     UCHAR AdditionalSenseCodeQualifier;
1967     UCHAR FieldReplaceableUnitCode;
1968     UCHAR SenseKeySpecific[3];
1969 } SENSE_DATA, *PSENSE_DATA;
1970 
1971 #include <poppack.h>
1972 
1973 typedef PHYSICAL_ADDRESS STOR_PHYSICAL_ADDRESS;
1974 
1975 typedef struct _ACCESS_RANGE
1976 {
1977     STOR_PHYSICAL_ADDRESS RangeStart;
1978     ULONG RangeLength;
1979     BOOLEAN RangeInMemory;
1980 } ACCESS_RANGE, *PACCESS_RANGE;
1981 
1982 typedef struct _MEMORY_REGION
1983 {
1984     PUCHAR VirtualBase;
1985     PHYSICAL_ADDRESS PhysicalBase;
1986     ULONG Length;
1987 } MEMORY_REGION, *PMEMORY_REGION;
1988 
1989 typedef struct _PORT_CONFIGURATION_INFORMATION
1990 {
1991     ULONG Length;
1992     ULONG SystemIoBusNumber;
1993     INTERFACE_TYPE  AdapterInterfaceType;
1994     ULONG BusInterruptLevel;
1995     ULONG BusInterruptVector;
1996     KINTERRUPT_MODE InterruptMode;
1997     ULONG MaximumTransferLength;
1998     ULONG NumberOfPhysicalBreaks;
1999     ULONG DmaChannel;
2000     ULONG DmaPort;
2001     DMA_WIDTH DmaWidth;
2002     DMA_SPEED DmaSpeed;
2003     ULONG AlignmentMask;
2004     ULONG NumberOfAccessRanges;
2005     ACCESS_RANGE (*AccessRanges)[];
2006     PVOID Reserved;
2007     UCHAR NumberOfBuses;
2008     CCHAR InitiatorBusId[8];
2009     BOOLEAN ScatterGather;
2010     BOOLEAN Master;
2011     BOOLEAN CachesData;
2012     BOOLEAN AdapterScansDown;
2013     BOOLEAN AtdiskPrimaryClaimed;
2014     BOOLEAN AtdiskSecondaryClaimed;
2015     BOOLEAN Dma32BitAddresses;
2016     BOOLEAN DemandMode;
2017     UCHAR MapBuffers;
2018     BOOLEAN NeedPhysicalAddresses;
2019     BOOLEAN TaggedQueuing;
2020     BOOLEAN AutoRequestSense;
2021     BOOLEAN MultipleRequestPerLu;
2022     BOOLEAN ReceiveEvent;
2023     BOOLEAN RealModeInitialized;
2024     BOOLEAN BufferAccessScsiPortControlled;
2025     UCHAR MaximumNumberOfTargets;
2026     UCHAR ReservedUchars[2];
2027     ULONG SlotNumber;
2028     ULONG BusInterruptLevel2;
2029     ULONG BusInterruptVector2;
2030     KINTERRUPT_MODE InterruptMode2;
2031     ULONG DmaChannel2;
2032     ULONG DmaPort2;
2033     DMA_WIDTH DmaWidth2;
2034     DMA_SPEED DmaSpeed2;
2035     ULONG DeviceExtensionSize;
2036     ULONG SpecificLuExtensionSize;
2037     ULONG SrbExtensionSize;
2038     UCHAR  Dma64BitAddresses;
2039     BOOLEAN ResetTargetSupported;
2040     UCHAR MaximumNumberOfLogicalUnits;
2041     BOOLEAN WmiDataProvider;
2042     STOR_SYNCHRONIZATION_MODEL SynchronizationModel;
2043 } PORT_CONFIGURATION_INFORMATION, *PPORT_CONFIGURATION_INFORMATION;
2044 
2045 typedef struct _STOR_SCATTER_GATHER_ELEMENT
2046 {
2047     STOR_PHYSICAL_ADDRESS PhysicalAddress;
2048     ULONG Length;
2049     ULONG_PTR Reserved;
2050 } STOR_SCATTER_GATHER_ELEMENT, *PSTOR_SCATTER_GATHER_ELEMENT;
2051 
2052 typedef struct _STOR_SCATTER_GATHER_LIST
2053 {
2054     ULONG NumberOfElements;
2055     ULONG_PTR Reserved;
2056     STOR_SCATTER_GATHER_ELEMENT List[];
2057 } STOR_SCATTER_GATHER_LIST, *PSTOR_SCATTER_GATHER_LIST;
2058 
2059 typedef struct _DPC_BUFFER
2060 {
2061     CSHORT Type;
2062     UCHAR Number;
2063     UCHAR Importance;
2064     struct
2065     {
2066         PVOID F;
2067         PVOID B;
2068     };
2069     PVOID DeferredRoutine;
2070     PVOID DeferredContext;
2071     PVOID SystemArgument1;
2072     PVOID SystemArgument2;
2073     PVOID DpcData;
2074 } DPC_BUFFER;
2075 
2076 typedef struct _STOR_DPC
2077 {
2078     DPC_BUFFER Dpc;
2079     ULONG_PTR Lock;
2080 } STOR_DPC, *PSTOR_DPC;
2081 
2082 typedef struct _STOR_LOCK_HANDLE
2083 {
2084     STOR_SPINLOCK Lock;
2085     struct
2086     {
2087         struct
2088         {
2089             PVOID Next;
2090             PVOID Lock;
2091         } LockQueue;
2092         KIRQL OldIrql;
2093     } Context;
2094 } STOR_LOCK_HANDLE, *PSTOR_LOCK_HANDLE;
2095 
2096 typedef struct _STOR_LOG_EVENT_DETAILS
2097 {
2098     ULONG InterfaceRevision;
2099     ULONG Size;
2100     ULONG Flags;
2101     STOR_EVENT_ASSOCIATION_ENUM EventAssociation;
2102     ULONG PathId;
2103     ULONG TargetId;
2104     ULONG LunId;
2105     BOOLEAN StorportSpecificErrorCode;
2106     ULONG ErrorCode;
2107     ULONG UniqueId;
2108     ULONG DumpDataSize;
2109     PVOID DumpData;
2110     ULONG StringCount;
2111     PWSTR *StringList;
2112 } STOR_LOG_EVENT_DETAILS, *PSTOR_LOG_EVENT_DETAILS;
2113 
2114 typedef struct _PERF_CONFIGURATION_DATA
2115 {
2116     ULONG Version;
2117     ULONG Size;
2118     ULONG Flags;
2119     ULONG ConcurrentChannels;
2120     ULONG FirstRedirectionMessageNumber, LastRedirectionMessageNumber;
2121     ULONG DeviceNode;
2122     ULONG Reserved;
2123     PGROUP_AFFINITY MessageTargets;
2124 } PERF_CONFIGURATION_DATA, *PPERF_CONFIGURATION_DATA;
2125 
2126 typedef struct _STARTIO_PERFORMANCE_PARAMETERS
2127 {
2128     ULONG Version;
2129     ULONG Size;
2130     ULONG MessageNumber;
2131     ULONG ChannelNumber;
2132 } STARTIO_PERFORMANCE_PARAMETERS, *PSTARTIO_PERFORMANCE_PARAMETERS;
2133 
2134 typedef struct _MESSAGE_INTERRUPT_INFORMATION
2135 {
2136     ULONG MessageId;
2137     ULONG MessageData;
2138     STOR_PHYSICAL_ADDRESS MessageAddress;
2139     ULONG InterruptVector;
2140     ULONG InterruptLevel;
2141     KINTERRUPT_MODE InterruptMode;
2142 } MESSAGE_INTERRUPT_INFORMATION, *PMESSAGE_INTERRUPT_INFORMATION;
2143 
2144 typedef
2145 BOOLEAN
2146 (NTAPI *PHW_INITIALIZE)(
2147     _In_ PVOID DeviceExtension);
2148 
2149 typedef
2150 BOOLEAN
2151 (NTAPI *PHW_BUILDIO)(
2152     _In_ PVOID DeviceExtension,
2153     _In_ PSCSI_REQUEST_BLOCK Srb);
2154 
2155 typedef
2156 BOOLEAN
2157 (NTAPI *PHW_STARTIO)(
2158     _In_ PVOID DeviceExtension,
2159     _In_ PSCSI_REQUEST_BLOCK Srb);
2160 
2161 typedef
2162 BOOLEAN
2163 (NTAPI *PHW_INTERRUPT)(
2164     _In_ PVOID DeviceExtension);
2165 
2166 typedef
2167 VOID
2168 (NTAPI *PHW_TIMER)(
2169     _In_ PVOID DeviceExtension);
2170 
2171 typedef
2172 VOID
2173 (NTAPI *PHW_DMA_STARTED)(
2174     _In_ PVOID DeviceExtension);
2175 
2176 typedef
2177 ULONG
2178 (NTAPI *PHW_FIND_ADAPTER)(
2179     IN PVOID DeviceExtension,
2180     IN PVOID HwContext,
2181     IN PVOID BusInformation,
2182     IN PCHAR ArgumentString,
2183     IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo,
2184     OUT PBOOLEAN Again);
2185 
2186 typedef
2187 BOOLEAN
2188 (NTAPI *PHW_RESET_BUS)(
2189     IN PVOID DeviceExtension,
2190     IN ULONG PathId);
2191 
2192 typedef
2193 BOOLEAN
2194 (NTAPI *PHW_ADAPTER_STATE)(
2195     IN PVOID DeviceExtension,
2196     IN PVOID Context,
2197     IN BOOLEAN SaveState);
2198 
2199 typedef
2200 SCSI_ADAPTER_CONTROL_STATUS
2201 (NTAPI *PHW_ADAPTER_CONTROL)(
2202     IN PVOID DeviceExtension,
2203     IN SCSI_ADAPTER_CONTROL_TYPE ControlType,
2204     IN PVOID Parameters);
2205 
2206 typedef
2207 BOOLEAN
2208 (*PHW_PASSIVE_INITIALIZE_ROUTINE)(
2209     _In_ PVOID DeviceExtension);
2210 
2211 typedef
2212 VOID
2213 (*PHW_DPC_ROUTINE)(
2214     _In_ PSTOR_DPC Dpc,
2215     _In_ PVOID HwDeviceExtension,
2216     _In_ PVOID SystemArgument1,
2217     _In_ PVOID SystemArgument2);
2218 
2219 typedef
2220 BOOLEAN
2221 (NTAPI STOR_SYNCHRONIZED_ACCESS)(
2222     _In_ PVOID HwDeviceExtension,
2223     _In_ PVOID Context);
2224 
2225 typedef STOR_SYNCHRONIZED_ACCESS *PSTOR_SYNCHRONIZED_ACCESS;
2226 
2227 typedef
2228 VOID
2229 (NTAPI *PpostScaterGatherExecute)(
2230     _In_ PVOID *DeviceObject,
2231     _In_ PVOID *Irp,
2232     _In_ PSTOR_SCATTER_GATHER_LIST ScatterGather,
2233     _In_ PVOID Context);
2234 
2235 typedef
2236 BOOLEAN
2237 (NTAPI *PStorPortGetMessageInterruptInformation)(
2238     _In_ PVOID HwDeviceExtension,
2239     _In_ ULONG MessageId,
2240     _Out_ PMESSAGE_INTERRUPT_INFORMATION InterruptInfo);
2241 
2242 typedef
2243 VOID
2244 (NTAPI *PStorPortPutScatterGatherList)(
2245     _In_ PVOID HwDeviceExtension,
2246     _In_ PSTOR_SCATTER_GATHER_LIST ScatterGatherList,
2247     _In_ BOOLEAN WriteToDevice);
2248 
2249 typedef
2250 GETSGSTATUS
2251 (NTAPI *PStorPortBuildScatterGatherList)(
2252     _In_ PVOID HwDeviceExtension,
2253     _In_ PVOID Mdl,
2254     _In_ PVOID CurrentVa,
2255     _In_ ULONG Length,
2256     _In_ PpostScaterGatherExecute ExecutionRoutine,
2257     _In_ PVOID Context,
2258     _In_ BOOLEAN WriteToDevice,
2259     _Inout_ PVOID ScatterGatherBuffer,
2260     _In_ ULONG ScatterGatherBufferLength);
2261 
2262 typedef
2263 VOID
2264 (NTAPI *PStorPortFreePool)(
2265     _In_ PVOID PMemory,
2266     _In_ PVOID HwDeviceExtension,
2267     _In_opt_ PVOID PMdl);
2268 
2269 typedef
2270 PVOID
2271 (NTAPI *PStorPortAllocatePool)(
2272     _In_ ULONG NumberOfBytes,
2273     _In_ ULONG Tag,
2274     _In_ PVOID HwDeviceExtension,
2275     _Out_ PVOID *PMdl);
2276 
2277 typedef
2278 PVOID
2279 (NTAPI *PStorPortGetSystemAddress)(
2280     _In_ PSCSI_REQUEST_BLOCK Srb);
2281 
2282 typedef struct _STORPORT_EXTENDED_FUNCTIONS
2283 {
2284     ULONG Version;
2285     PStorPortGetMessageInterruptInformation GetMessageInterruptInformation;
2286     PStorPortPutScatterGatherList PutScatterGatherList;
2287     PStorPortBuildScatterGatherList BuildScatterGatherList;
2288     PStorPortFreePool FreePool;
2289     PStorPortAllocatePool AllocatePool;
2290     PStorPortGetSystemAddress GetSystemAddress;
2291 } STORPORT_EXTENDED_FUNCTIONS, *PSTORPORT_EXTENDED_FUNCTIONS;
2292 
2293 typedef struct _HW_INITIALIZATION_DATA
2294 {
2295     ULONG HwInitializationDataSize;
2296     INTERFACE_TYPE  AdapterInterfaceType;
2297     PHW_INITIALIZE HwInitialize;
2298     PHW_STARTIO HwStartIo;
2299     PHW_INTERRUPT HwInterrupt;
2300     PHW_FIND_ADAPTER HwFindAdapter;
2301     PHW_RESET_BUS HwResetBus;
2302     PHW_DMA_STARTED HwDmaStarted;
2303     PHW_ADAPTER_STATE HwAdapterState;
2304     ULONG DeviceExtensionSize;
2305     ULONG SpecificLuExtensionSize;
2306     ULONG SrbExtensionSize;
2307     ULONG NumberOfAccessRanges;
2308     PVOID Reserved;
2309     UCHAR MapBuffers;
2310     BOOLEAN NeedPhysicalAddresses;
2311     BOOLEAN TaggedQueuing;
2312     BOOLEAN AutoRequestSense;
2313     BOOLEAN MultipleRequestPerLu;
2314     BOOLEAN ReceiveEvent;
2315     USHORT VendorIdLength;
2316     PVOID VendorId;
2317     USHORT ReservedUshort;
2318     USHORT DeviceIdLength;
2319     PVOID DeviceId;
2320     PHW_ADAPTER_CONTROL HwAdapterControl;
2321     PHW_BUILDIO HwBuildIo;
2322 } HW_INITIALIZATION_DATA, *PHW_INITIALIZATION_DATA;
2323 
2324 
2325 
2326 #define REVERSE_BYTES_QUAD(Destination, Source) { \
2327     PEIGHT_BYTE d = (PEIGHT_BYTE)(Destination); \
2328     PEIGHT_BYTE s = (PEIGHT_BYTE)(Source); \
2329     d->Byte7 = s->Byte0; \
2330     d->Byte6 = s->Byte1; \
2331     d->Byte5 = s->Byte2; \
2332     d->Byte4 = s->Byte3; \
2333     d->Byte3 = s->Byte4; \
2334     d->Byte2 = s->Byte5; \
2335     d->Byte1 = s->Byte6; \
2336     d->Byte0 = s->Byte7; \
2337 }
2338 
2339 #define REVERSE_BYTES(Destination, Source) { \
2340     PFOUR_BYTE d = (PFOUR_BYTE)(Destination); \
2341     PFOUR_BYTE s = (PFOUR_BYTE)(Source); \
2342     d->Byte3 = s->Byte0; \
2343     d->Byte2 = s->Byte1; \
2344     d->Byte1 = s->Byte2; \
2345     d->Byte0 = s->Byte3; \
2346 }
2347 
2348 #define REVERSE_BYTES_SHORT(Destination, Source) { \
2349     PTWO_BYTE d = (PTWO_BYTE)(Destination); \
2350     PTWO_BYTE s = (PTWO_BYTE)(Source); \
2351     d->Byte1 = s->Byte0; \
2352     d->Byte0 = s->Byte1; \
2353 }
2354 
2355 #define StorPortCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
2356 
2357 STORPORT_API
2358 PUCHAR
2359 NTAPI
2360 StorPortAllocateRegistryBuffer(
2361     _In_ PVOID HwDeviceExtension,
2362     _In_ PULONG Length);
2363 
2364 STORPORT_API
2365 BOOLEAN
2366 NTAPI
2367 StorPortBusy(
2368   _In_ PVOID HwDeviceExtension,
2369   _In_ ULONG RequestsToComplete);
2370 
2371 STORPORT_API
2372 VOID
2373 NTAPI
2374 StorPortCompleteRequest(
2375     _In_ PVOID HwDeviceExtension,
2376     _In_ UCHAR PathId,
2377     _In_ UCHAR TargetId,
2378     _In_ UCHAR Lun,
2379     _In_ UCHAR SrbStatus);
2380 
2381 STORPORT_API
2382 ULONG64
2383 NTAPI
2384 StorPortConvertPhysicalAddressToUlong64(
2385     _In_ STOR_PHYSICAL_ADDRESS Address);
2386 
2387 STORPORT_API
2388 STOR_PHYSICAL_ADDRESS
2389 NTAPI
2390 StorPortConvertUlong64ToPhysicalAddress(
2391     _In_ ULONG64 UlongAddress);
2392 
2393 STORPORT_API
2394 VOID
2395 __cdecl
2396 StorPortDebugPrint(
2397     _In_ ULONG DebugPrintLevel,
2398     _In_ PCCHAR DebugMessage,
2399     ...);
2400 
2401 STORPORT_API
2402 BOOLEAN
2403 NTAPI
2404 StorPortDeviceBusy(
2405     _In_ PVOID HwDeviceExtension,
2406     _In_ UCHAR PathId,
2407     _In_ UCHAR TargetId,
2408     _In_ UCHAR Lun,
2409     _In_ ULONG RequestsToComplete);
2410 
2411 STORPORT_API
2412 BOOLEAN
2413 NTAPI
2414 StorPortDeviceReady(
2415     _In_ PVOID HwDeviceExtension,
2416     _In_ UCHAR PathId,
2417     _In_ UCHAR TargetId,
2418     _In_ UCHAR Lun);
2419 
2420 STORPORT_API
2421 VOID
2422 NTAPI
2423 StorPortFreeDeviceBase(
2424     _In_ PVOID HwDeviceExtension,
2425     _In_ PVOID MappedAddress);
2426 
2427 STORPORT_API
2428 VOID
2429 NTAPI
2430 StorPortFreeRegistryBuffer(
2431     _In_ PVOID HwDeviceExtension,
2432     _In_ PUCHAR Buffer);
2433 
2434 STORPORT_API
2435 ULONG
2436 NTAPI
2437 StorPortGetBusData(
2438     _In_ PVOID DeviceExtension,
2439     _In_ ULONG BusDataType,
2440     _In_ ULONG SystemIoBusNumber,
2441     _In_ ULONG SlotNumber,
2442     _Out_ _When_(Length != 0, _Out_writes_bytes_(Length)) PVOID Buffer,
2443     _In_ ULONG Length);
2444 
2445 STORPORT_API
2446 PVOID
2447 NTAPI
2448 StorPortGetDeviceBase(
2449     _In_ PVOID HwDeviceExtension,
2450     _In_ INTERFACE_TYPE BusType,
2451     _In_ ULONG SystemIoBusNumber,
2452     _In_ STOR_PHYSICAL_ADDRESS IoAddress,
2453     _In_ ULONG NumberOfBytes,
2454     _In_ BOOLEAN InIoSpace);
2455 
2456 STORPORT_API
2457 PVOID
2458 NTAPI
2459 StorPortGetLogicalUnit(
2460     _In_ PVOID HwDeviceExtension,
2461     _In_ UCHAR PathId,
2462     _In_ UCHAR TargetId,
2463     _In_ UCHAR Lun);
2464 
2465 STORPORT_API
2466 STOR_PHYSICAL_ADDRESS
2467 NTAPI
2468 StorPortGetPhysicalAddress(
2469     _In_ PVOID HwDeviceExtension,
2470     _In_opt_ PSCSI_REQUEST_BLOCK Srb,
2471     _In_ PVOID VirtualAddress,
2472     _Out_ ULONG *Length);
2473 
2474 STORPORT_API
2475 PSTOR_SCATTER_GATHER_LIST
2476 NTAPI
2477 StorPortGetScatterGatherList(
2478     _In_ PVOID DeviceExtension,
2479     _In_ PSCSI_REQUEST_BLOCK Srb);
2480 
2481 STORPORT_API
2482 PSCSI_REQUEST_BLOCK
2483 NTAPI
2484 StorPortGetSrb(
2485     _In_ PVOID DeviceExtension,
2486     _In_ UCHAR PathId,
2487     _In_ UCHAR TargetId,
2488     _In_ UCHAR Lun,
2489     _In_ LONG QueueTag);
2490 
2491 STORPORT_API
2492 PVOID
2493 NTAPI
2494 StorPortGetUncachedExtension(
2495     _In_ PVOID HwDeviceExtension,
2496     _In_ PPORT_CONFIGURATION_INFORMATION ConfigInfo,
2497     _In_ ULONG NumberOfBytes);
2498 
2499 STORPORT_API
2500 PVOID
2501 NTAPI
2502 StorPortGetVirtualAddress(
2503     _In_ PVOID HwDeviceExtension,
2504     _In_ STOR_PHYSICAL_ADDRESS PhysicalAddress);
2505 
2506 STORPORT_API
2507 ULONG
2508 NTAPI
2509 StorPortInitialize(
2510     _In_ PVOID Argument1,
2511     _In_ PVOID Argument2,
2512     _In_ PHW_INITIALIZATION_DATA HwInitializationData,
2513     _In_opt_ PVOID Unused);
2514 
2515 STORPORT_API
2516 VOID
2517 NTAPI
2518 StorPortLogError(
2519     _In_ PVOID HwDeviceExtension,
2520     _In_opt_ PSCSI_REQUEST_BLOCK Srb,
2521     _In_ UCHAR PathId,
2522     _In_ UCHAR TargetId,
2523     _In_ UCHAR Lun,
2524     _In_ ULONG ErrorCode,
2525     _In_ ULONG UniqueId);
2526 
2527 STORPORT_API
2528 VOID
2529 NTAPI
2530 StorPortMoveMemory(
2531     _Out_writes_bytes_(Length) PVOID WriteBuffer,
2532     _In_reads_bytes_(Length) PVOID ReadBuffer,
2533     _In_ ULONG Length);
2534 
2535 STORPORT_API
2536 VOID
2537 __cdecl
2538 StorPortNotification(
2539     _In_ SCSI_NOTIFICATION_TYPE NotificationType,
2540     _In_ PVOID HwDeviceExtension,
2541     ...);
2542 
2543 STORPORT_API
2544 VOID
2545 NTAPI
2546 StorPortQuerySystemTime(
2547     _Out_ PLARGE_INTEGER CurrentTime);
2548 
2549 STORPORT_API
2550 BOOLEAN
2551 NTAPI
2552 StorPortPause(
2553     _In_ PVOID HwDeviceExtension,
2554     _In_ ULONG TimeOut);
2555 
2556 STORPORT_API
2557 BOOLEAN
2558 NTAPI
2559 StorPortPauseDevice(
2560     _In_ PVOID HwDeviceExtension,
2561     _In_ UCHAR PathId,
2562     _In_ UCHAR TargetId,
2563     _In_ UCHAR Lun,
2564     _In_ ULONG TimeOut);
2565 
2566 STORPORT_API
2567 VOID
2568 NTAPI
2569 StorPortReadPortBufferUchar(
2570     _In_ PVOID HwDeviceExtension,
2571     _In_ PUCHAR Port,
2572     _In_ PUCHAR Buffer,
2573     _In_ ULONG Count);
2574 
2575 STORPORT_API
2576 VOID
2577 NTAPI
2578 StorPortReadPortBufferUlong(
2579     _In_ PVOID HwDeviceExtension,
2580     _In_ PULONG Port,
2581     _In_ PULONG Buffer,
2582     _In_ ULONG Count);
2583 
2584 STORPORT_API
2585 VOID
2586 NTAPI
2587 StorPortReadPortBufferUshort(
2588     _In_ PVOID HwDeviceExtension,
2589     _In_ PUSHORT Port,
2590     _In_ PUSHORT Buffer,
2591     _In_ ULONG Count);
2592 
2593 STORPORT_API
2594 UCHAR
2595 NTAPI
2596 StorPortReadPortUchar(
2597     _In_ PVOID HwDeviceExtension,
2598     _In_ PUCHAR Port);
2599 
2600 STORPORT_API
2601 ULONG
2602 NTAPI
2603 StorPortReadPortUlong(
2604     _In_ PVOID HwDeviceExtension,
2605     _In_ PULONG Port);
2606 
2607 STORPORT_API
2608 USHORT
2609 NTAPI
2610 StorPortReadPortUshort(
2611     _In_ PVOID HwDeviceExtension,
2612     _In_ PUSHORT Port);
2613 
2614 STORPORT_API
2615 VOID
2616 NTAPI
2617 StorPortReadRegisterBufferUchar(
2618     _In_ PVOID HwDeviceExtension,
2619     _In_ PUCHAR Register,
2620     _In_ PUCHAR Buffer,
2621     _In_ ULONG Count);
2622 
2623 STORPORT_API
2624 VOID
2625 NTAPI
2626 StorPortReadRegisterBufferUlong(
2627     _In_ PVOID HwDeviceExtension,
2628     _In_ PULONG Register,
2629     _In_ PULONG Buffer,
2630     _In_ ULONG Count);
2631 
2632 STORPORT_API
2633 VOID
2634 NTAPI
2635 StorPortReadRegisterBufferUshort(
2636     _In_ PVOID HwDeviceExtension,
2637     _In_ PUSHORT Register,
2638     _In_ PUSHORT Buffer,
2639     _In_ ULONG Count);
2640 
2641 STORPORT_API
2642 UCHAR
2643 NTAPI
2644 StorPortReadRegisterUchar(
2645     _In_ PVOID HwDeviceExtension,
2646     _In_ PUCHAR Register);
2647 
2648 STORPORT_API
2649 ULONG
2650 NTAPI
2651 StorPortReadRegisterUlong(
2652     _In_ PVOID HwDeviceExtension,
2653     _In_ PULONG Register);
2654 
2655 STORPORT_API
2656 USHORT
2657 NTAPI
2658 StorPortReadRegisterUshort(
2659     _In_ PVOID HwDeviceExtension,
2660     _In_ PUSHORT Register);
2661 
2662 STORPORT_API
2663 BOOLEAN
2664 NTAPI
2665 StorPortReady(
2666   _In_ PVOID HwDeviceExtension);
2667 
2668 STORPORT_API
2669 BOOLEAN
2670 NTAPI
2671 StorPortRegistryRead(
2672     _In_ PVOID HwDeviceExtension,
2673     _In_ PUCHAR ValueName,
2674     _In_ ULONG Global,
2675     _In_ ULONG Type,
2676     _In_ PUCHAR Buffer,
2677     _In_ PULONG BufferLength);
2678 
2679 STORPORT_API
2680 BOOLEAN
2681 NTAPI
2682 StorPortRegistryWrite(
2683     _In_ PVOID HwDeviceExtension,
2684     _In_ PUCHAR ValueName,
2685     _In_ ULONG Global,
2686     _In_ ULONG Type,
2687     _In_ PUCHAR Buffer,
2688     _In_ ULONG BufferLength);
2689 
2690 STORPORT_API
2691 BOOLEAN
2692 NTAPI
2693 StorPortResume(
2694   _In_ PVOID HwDeviceExtension);
2695 
2696 STORPORT_API
2697 BOOLEAN
2698 NTAPI
2699 StorPortResumeDevice(
2700   _In_ PVOID HwDeviceExtension,
2701   _In_ UCHAR PathId,
2702   _In_ UCHAR TargetId,
2703   _In_ UCHAR Lun);
2704 
2705 STORPORT_API
2706 ULONG
2707 NTAPI
2708 StorPortSetBusDataByOffset(
2709     _In_ PVOID DeviceExtension,
2710     _In_ ULONG BusDataType,
2711     _In_ ULONG SystemIoBusNumber,
2712     _In_ ULONG SlotNumber,
2713     _In_reads_bytes_(Length) PVOID Buffer,
2714     _In_ ULONG Offset,
2715     _In_ ULONG Length);
2716 
2717 STORPORT_API
2718 BOOLEAN
2719 NTAPI
2720 StorPortSetDeviceQueueDepth(
2721   _In_ PVOID HwDeviceExtension,
2722   _In_ UCHAR PathId,
2723   _In_ UCHAR TargetId,
2724   _In_ UCHAR Lun,
2725   _In_ ULONG Depth);
2726 
2727 STORPORT_API
2728 VOID
2729 NTAPI
2730 StorPortStallExecution(
2731     _In_ ULONG Delay);
2732 
2733 STORPORT_API
2734 VOID
2735 NTAPI
2736 StorPortSynchronizeAccess(
2737     _In_ PVOID HwDeviceExtension,
2738     _In_ PSTOR_SYNCHRONIZED_ACCESS SynchronizedAccessRoutine,
2739     _In_opt_ PVOID Context);
2740 
2741 STORPORT_API
2742 BOOLEAN
2743 NTAPI
2744 StorPortValidateRange(
2745     _In_ PVOID HwDeviceExtension,
2746     _In_ INTERFACE_TYPE BusType,
2747     _In_ ULONG SystemIoBusNumber,
2748     _In_ STOR_PHYSICAL_ADDRESS IoAddress,
2749     _In_ ULONG NumberOfBytes,
2750     _In_ BOOLEAN InIoSpace);
2751 
2752 STORPORT_API
2753 VOID
2754 NTAPI
2755 StorPortWritePortBufferUchar(
2756     _In_ PVOID HwDeviceExtension,
2757     _In_ PUCHAR Port,
2758     _In_ PUCHAR Buffer,
2759     _In_ ULONG Count);
2760 
2761 STORPORT_API
2762 VOID
2763 NTAPI
2764 StorPortWritePortBufferUlong(
2765     _In_ PVOID HwDeviceExtension,
2766     _In_ PULONG Port,
2767     _In_ PULONG Buffer,
2768     _In_ ULONG Count);
2769 
2770 STORPORT_API
2771 VOID
2772 NTAPI
2773 StorPortWritePortBufferUshort(
2774     _In_ PVOID HwDeviceExtension,
2775     _In_ PUSHORT Port,
2776     _In_ PUSHORT Buffer,
2777     _In_ ULONG Count);
2778 
2779 STORPORT_API
2780 VOID
2781 NTAPI
2782 StorPortWritePortUchar(
2783     _In_ PVOID HwDeviceExtension,
2784     _In_ PUCHAR Port,
2785     _In_ UCHAR Value);
2786 
2787 STORPORT_API
2788 VOID
2789 NTAPI
2790 StorPortWritePortUlong(
2791     _In_ PVOID HwDeviceExtension,
2792     _In_ PULONG Port,
2793     _In_ ULONG Value);
2794 
2795 STORPORT_API
2796 VOID
2797 NTAPI
2798 StorPortWritePortUshort(
2799     _In_ PVOID HwDeviceExtension,
2800     _In_ PUSHORT Port,
2801     _In_ USHORT Value);
2802 
2803 STORPORT_API
2804 VOID
2805 NTAPI
2806 StorPortWriteRegisterBufferUchar(
2807     _In_ PVOID HwDeviceExtension,
2808     _In_ PUCHAR Register,
2809     _In_ PUCHAR Buffer,
2810     _In_ ULONG Count);
2811 
2812 STORPORT_API
2813 VOID
2814 NTAPI
2815 StorPortWriteRegisterBufferUlong(
2816     _In_ PVOID HwDeviceExtension,
2817     _In_ PULONG Register,
2818     _In_ PULONG Buffer,
2819     _In_ ULONG Count);
2820 
2821 STORPORT_API
2822 VOID
2823 NTAPI
2824 StorPortWriteRegisterBufferUshort(
2825     _In_ PVOID HwDeviceExtension,
2826     _In_ PUSHORT Register,
2827     _In_ PUSHORT Buffer,
2828     _In_ ULONG Count);
2829 
2830 STORPORT_API
2831 VOID
2832 NTAPI
2833 StorPortWriteRegisterUchar(
2834     _In_ PVOID HwDeviceExtension,
2835     _In_ PUCHAR Register,
2836     _In_ UCHAR Value);
2837 
2838 STORPORT_API
2839 VOID
2840 NTAPI
2841 StorPortWriteRegisterUlong(
2842     _In_ PVOID HwDeviceExtension,
2843     _In_ PULONG Register,
2844     _In_ ULONG Value);
2845 
2846 STORPORT_API
2847 VOID
2848 NTAPI
2849 StorPortWriteRegisterUshort(
2850     _In_ PVOID HwDeviceExtension,
2851     _In_ PUSHORT Register,
2852     _In_ USHORT Value);
2853 
2854 
2855 FORCEINLINE
2856 BOOLEAN
2857 StorPortEnablePassiveInitialization(
2858     _In_ PVOID DeviceExtension,
2859     _In_ PHW_PASSIVE_INITIALIZE_ROUTINE HwPassiveInitializeRoutine)
2860 {
2861     LONG Succ;
2862     Succ = FALSE;
2863     StorPortNotification(EnablePassiveInitialization,
2864                          DeviceExtension,
2865                          HwPassiveInitializeRoutine,
2866                          &Succ);
2867     return (BOOLEAN)Succ;
2868 }
2869 
2870 FORCEINLINE
2871 VOID
2872 StorPortInitializeDpc(
2873     _In_ PVOID DeviceExtension,
2874     _Out_ PSTOR_DPC Dpc,
2875     _In_ PHW_DPC_ROUTINE HwDpcRoutine)
2876 {
2877     StorPortNotification(InitializeDpc,
2878                          DeviceExtension,
2879                          Dpc,
2880                          HwDpcRoutine);
2881 }
2882 
2883 FORCEINLINE
2884 BOOLEAN
2885 StorPortIssueDpc(
2886     _In_ PVOID DeviceExtension,
2887     _In_ PSTOR_DPC Dpc,
2888     _In_ PVOID SystemArgument1,
2889     _In_ PVOID SystemArgument2)
2890 {
2891     LONG Succ;
2892     Succ = FALSE;
2893     StorPortNotification(IssueDpc,
2894                          DeviceExtension,
2895                          Dpc,
2896                          SystemArgument1,
2897                          SystemArgument2,
2898                          &Succ);
2899     return (BOOLEAN)Succ;
2900 }
2901 
2902 FORCEINLINE
2903 VOID
2904 StorPortAcquireSpinLock(
2905     _In_ PVOID DeviceExtension,
2906     _In_ STOR_SPINLOCK SpinLock,
2907     _In_ PVOID LockContext,
2908     _Inout_ PSTOR_LOCK_HANDLE LockHandle)
2909 {
2910     StorPortNotification(AcquireSpinLock,
2911                          DeviceExtension,
2912                          SpinLock,
2913                          LockContext,
2914                          LockHandle);
2915 }
2916 
2917 FORCEINLINE
2918 VOID
2919 StorPortReleaseSpinLock(
2920     _In_ PVOID DeviceExtension,
2921     _Inout_ PSTOR_LOCK_HANDLE LockHandle)
2922 {
2923     StorPortNotification(ReleaseSpinLock,
2924                          DeviceExtension,
2925                          LockHandle);
2926 }
2927 
2928 STORPORT_API
2929 ULONG
2930 StorPortExtendedFunction(
2931     _In_ STORPORT_FUNCTION_CODE FunctionCode,
2932     _In_ PVOID HwDeviceExtension,
2933     ...);
2934 
2935 FORCEINLINE
2936 ULONG
2937 StorPortAllocatePool(
2938     _In_ PVOID HwDeviceExtension,
2939     _In_ ULONG NumberOfBytes,
2940     _In_ ULONG Tag,
2941     _Out_ PVOID *BufferPointer
2942     )
2943 {
2944     return StorPortExtendedFunction(ExtFunctionAllocatePool,
2945                                     HwDeviceExtension,
2946                                     NumberOfBytes,
2947                                     Tag,
2948                                     BufferPointer);
2949 }
2950 
2951 FORCEINLINE
2952 ULONG
2953 StorPortFreePool(
2954     _In_ PVOID HwDeviceExtension,
2955     _In_ PVOID BufferPointer)
2956 {
2957     return StorPortExtendedFunction(ExtFunctionFreePool,
2958                                     HwDeviceExtension,
2959                                     BufferPointer);
2960 }
2961 
2962 FORCEINLINE
2963 ULONG
2964 StorPortAllocateMdl(
2965     _In_ PVOID HwDeviceExtension,
2966     _In_ PVOID BufferPointer,
2967     _In_ ULONG NumberOfBytes,
2968     _Out_ PVOID *Mdl)
2969 {
2970     return StorPortExtendedFunction(ExtFunctionAllocateMdl,
2971                                     HwDeviceExtension,
2972                                     BufferPointer,
2973                                     NumberOfBytes,
2974                                     Mdl);
2975 }
2976 
2977 FORCEINLINE
2978 ULONG
2979 StorPortFreeMdl(
2980     _In_ PVOID HwDeviceExtension,
2981     _In_ PVOID Mdl)
2982 {
2983     return StorPortExtendedFunction(ExtFunctionFreeMdl,
2984                                     HwDeviceExtension,
2985                                     Mdl);
2986 }
2987 
2988 FORCEINLINE
2989 ULONG
2990 StorPortBuildMdlForNonPagedPool(
2991     _In_ PVOID HwDeviceExtension,
2992     _Inout_ PVOID Mdl)
2993 {
2994     return StorPortExtendedFunction(ExtFunctionBuildMdlForNonPagedPool,
2995                                     HwDeviceExtension,
2996                                     Mdl);
2997 }
2998 
2999 FORCEINLINE
3000 ULONG
3001 StorPortGetSystemAddress(
3002     _In_ PVOID HwDeviceExtension,
3003     _In_ PSCSI_REQUEST_BLOCK Srb,
3004     _Out_ PVOID *SystemAddress)
3005 {
3006     return StorPortExtendedFunction(ExtFunctionGetSystemAddress,
3007                                     HwDeviceExtension,
3008                                     Srb,
3009                                     SystemAddress);
3010 }
3011 
3012 FORCEINLINE
3013 ULONG
3014 StorPortGetOriginalMdl(
3015     _In_ PVOID HwDeviceExtension,
3016     _In_ PSCSI_REQUEST_BLOCK Srb,
3017     _Out_ PVOID *Mdl)
3018 {
3019     return StorPortExtendedFunction(ExtFunctionGetOriginalMdl,
3020                                     HwDeviceExtension,
3021                                     Srb,
3022                                     Mdl);
3023 }
3024 
3025 FORCEINLINE
3026 ULONG
3027 StorPortCompleteServiceIrp(
3028     _In_ PVOID HwDeviceExtension,
3029     _In_ PVOID Irp)
3030 {
3031     return StorPortExtendedFunction(ExtFunctionCompleteServiceIrp,
3032                                     HwDeviceExtension,
3033                                     Irp);
3034 }
3035 
3036 FORCEINLINE
3037 ULONG
3038 StorPortGetDeviceObjects(
3039     _In_ PVOID HwDeviceExtension,
3040     _Out_ PVOID *AdapterDeviceObject,
3041     _Out_ PVOID *PhysicalDeviceObject,
3042     _Out_ PVOID *LowerDeviceObject)
3043 {
3044     return StorPortExtendedFunction(ExtFunctionGetDeviceObjects,
3045                                     HwDeviceExtension,
3046                                     AdapterDeviceObject,
3047                                     PhysicalDeviceObject,
3048                                     LowerDeviceObject);
3049 }
3050 
3051 FORCEINLINE
3052 ULONG
3053 StorPortBuildScatterGatherList(
3054     _In_ PVOID HwDeviceExtension,
3055     _In_ PVOID Mdl,
3056     _In_ PVOID CurrentVa,
3057     _In_ ULONG Length,
3058     _In_ PpostScaterGatherExecute ExecutionRoutine,
3059     _In_ PVOID Context,
3060     _In_ BOOLEAN WriteToDevice,
3061     _Inout_ PVOID ScatterGatherBuffer,
3062     _In_ ULONG ScatterGatherBufferLength)
3063 {
3064     return StorPortExtendedFunction(ExtFunctionBuildScatterGatherList,
3065                                     HwDeviceExtension,
3066                                     Mdl,
3067                                     CurrentVa,
3068                                     Length,
3069                                     ExecutionRoutine,
3070                                     Context,
3071                                     WriteToDevice,
3072                                     ScatterGatherBuffer,
3073                                     ScatterGatherBufferLength);
3074 }
3075 
3076 FORCEINLINE
3077 ULONG
3078 StorPortPutScatterGatherList(
3079     _In_ PVOID HwDeviceExtension,
3080     _In_ PSTOR_SCATTER_GATHER_LIST ScatterGatherList,
3081     _In_ BOOLEAN WriteToDevice)
3082 {
3083     return StorPortExtendedFunction(ExtFunctionPutScatterGatherList,
3084                                     HwDeviceExtension,
3085                                     ScatterGatherList,
3086                                     WriteToDevice);
3087 }
3088 
3089 FORCEINLINE
3090 ULONG
3091 StorPortAcquireMSISpinLock(
3092     _In_ PVOID HwDeviceExtension,
3093     _In_ ULONG MessageId,
3094     _In_ PULONG OldIrql)
3095 {
3096     return StorPortExtendedFunction(ExtFunctionAcquireMSISpinLock,
3097                                     HwDeviceExtension,
3098                                     MessageId,
3099                                     OldIrql);
3100 }
3101 
3102 FORCEINLINE
3103 ULONG
3104 StorPortReleaseMSISpinLock(
3105     _In_ PVOID HwDeviceExtension,
3106     _In_ ULONG MessageId,
3107     _In_ ULONG OldIrql)
3108 {
3109     return StorPortExtendedFunction(ExtFunctionReleaseMSISpinLock,
3110                                     HwDeviceExtension,
3111                                     MessageId,
3112                                     OldIrql);
3113 }
3114 
3115 FORCEINLINE
3116 ULONG
3117 StorPortGetMSIInfo(
3118     _In_ PVOID HwDeviceExtension,
3119     _In_ ULONG MessageId,
3120     _Out_ PMESSAGE_INTERRUPT_INFORMATION InterruptInfo)
3121 {
3122     return StorPortExtendedFunction(ExtFunctionGetMessageInterruptInformation,
3123                                     HwDeviceExtension,
3124                                     MessageId,
3125                                     InterruptInfo);
3126 }
3127 
3128 FORCEINLINE
3129 ULONG
3130 StorPortInitializePerfOpts(
3131     _In_ PVOID HwDeviceExtension,
3132     _In_ BOOLEAN Query,
3133     _Inout_ PPERF_CONFIGURATION_DATA PerfConfigData)
3134 {
3135     return StorPortExtendedFunction(ExtFunctionInitializePerformanceOptimizations,
3136                                     HwDeviceExtension,
3137                                     Query,
3138                                     PerfConfigData);
3139 }
3140 
3141 FORCEINLINE
3142 ULONG
3143 StorPortGetStartIoPerfParams(
3144     _In_ PVOID HwDeviceExtension,
3145     _In_ PSCSI_REQUEST_BLOCK Srb,
3146     _Inout_ PSTARTIO_PERFORMANCE_PARAMETERS StartIoPerfParams)
3147 {
3148     return StorPortExtendedFunction(ExtFunctionGetStartIoPerformanceParameters,
3149                                     HwDeviceExtension,
3150                                     Srb,
3151                                     StartIoPerfParams);
3152 }
3153 
3154 FORCEINLINE
3155 ULONG
3156 StorPortLogSystemEvent(
3157     _In_ PVOID HwDeviceExtension,
3158     _Inout_ PSTOR_LOG_EVENT_DETAILS LogDetails,
3159     _Inout_ PULONG MaximumSize)
3160 {
3161     return StorPortExtendedFunction(ExtFunctionLogSystemEvent,
3162                                     HwDeviceExtension,
3163                                     LogDetails,
3164                                     MaximumSize);
3165 }
3166 
3167 #if DBG
3168 #define DebugPrint(x) StorPortDebugPrint x
3169 #else
3170 #define DebugPrint(x)
3171 #endif
3172 
3173 #ifdef __cplusplus
3174 }
3175 #endif
3176 
3177 #endif /* _NTSTORPORT_ */
3178