xref: /reactos/sdk/include/ddk/storport.h (revision fb5d5ecd)
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 typedef enum _STOR_SYNCHRONIZATION_MODEL
408 {
409     StorSynchronizeHalfDuplex,
410     StorSynchronizeFullDuplex
411 } STOR_SYNCHRONIZATION_MODEL;
412 
413 typedef enum _STOR_DMA_WIDTH
414 {
415     DmaUnknown,
416     Dma32Bit,
417     Dma64BitScatterGather,
418     Dma64Bit
419 } STOR_DMA_WIDTH;
420 
421 typedef enum _STOR_SPINLOCK
422 {
423     DpcLock = 1,
424     StartIoLock,
425     InterruptLock
426 } STOR_SPINLOCK;
427 
428 typedef enum _SCSI_ADAPTER_CONTROL_TYPE
429 {
430     ScsiQuerySupportedControlTypes = 0,
431     ScsiStopAdapter,
432     ScsiRestartAdapter,
433     ScsiSetBootConfig,
434     ScsiSetRunningConfig,
435     ScsiAdapterControlMax,
436     MakeAdapterControlTypeSizeOfUlong = 0xffffffff
437 } SCSI_ADAPTER_CONTROL_TYPE, *PSCSI_ADAPTER_CONTROL_TYPE;
438 
439 typedef enum _SCSI_ADAPTER_CONTROL_STATUS
440 {
441     ScsiAdapterControlSuccess = 0,
442     ScsiAdapterControlUnsuccessful
443 } SCSI_ADAPTER_CONTROL_STATUS, *PSCSI_ADAPTER_CONTROL_STATUS;
444 
445 typedef enum _SCSI_NOTIFICATION_TYPE
446 {
447     RequestComplete,
448     NextRequest,
449     NextLuRequest,
450     ResetDetected,
451     _obsolete1,
452     _obsolete2,
453     RequestTimerCall,
454     BusChangeDetected,
455     WMIEvent,
456     WMIReregister,
457     LinkUp,
458     LinkDown,
459     QueryTickCount,
460     BufferOverrunDetected,
461     TraceNotification,
462     GetExtendedFunctionTable,
463     EnablePassiveInitialization = 0x1000,
464     InitializeDpc,
465     IssueDpc,
466     AcquireSpinLock,
467     ReleaseSpinLock
468 } SCSI_NOTIFICATION_TYPE, *PSCSI_NOTIFICATION_TYPE;
469 
470 typedef enum _STOR_DEVICE_POWER_STATE
471 {
472     StorPowerDeviceUnspecified = 0,
473     StorPowerDeviceD0,
474     StorPowerDeviceD1,
475     StorPowerDeviceD2,
476     StorPowerDeviceD3,
477     StorPowerDeviceMaximum
478 } STOR_DEVICE_POWER_STATE, *PSTOR_DEVICE_POWER_STATE;
479 
480 typedef enum _STOR_POWER_ACTION
481 {
482     StorPowerActionNone = 0,
483     StorPowerActionReserved,
484     StorPowerActionSleep,
485     StorPowerActionHibernate,
486     StorPowerActionShutdown,
487     StorPowerActionShutdownReset,
488     StorPowerActionShutdownOff,
489     StorPowerActionWarmEject
490 } STOR_POWER_ACTION, *PSTOR_POWER_ACTION;
491 
492 typedef enum _STOR_PNP_ACTION
493 {
494     StorStartDevice = 0x0,
495     StorRemoveDevice = 0x2,
496     StorStopDevice = 0x4,
497     StorQueryCapabilities = 0x9,
498     StorQueryResourceRequirements = 0xB,
499     StorFilterResourceRequirements = 0xD,
500     StorSurpriseRemoval = 0x17
501 } STOR_PNP_ACTION, *PSTOR_PNP_ACTION;
502 
503 typedef enum _VPD_CODE_SET
504 {
505     VpdCodeSetReserved = 0,
506     VpdCodeSetBinary = 1,
507     VpdCodeSetAscii = 2,
508     VpdCodeSetUTF8 = 3
509 } VPD_CODE_SET, *PVPD_CODE_SET;
510 
511 typedef enum _VPD_ASSOCIATION
512 {
513     VpdAssocDevice = 0,
514     VpdAssocPort = 1,
515     VpdAssocTarget = 2,
516     VpdAssocReserved1 = 3,
517     VpdAssocReserved2 = 4
518 } VPD_ASSOCIATION, *PVPD_ASSOCIATION;
519 
520 typedef enum _VPD_IDENTIFIER_TYPE
521 {
522     VpdIdentifierTypeVendorSpecific = 0,
523     VpdIdentifierTypeVendorId = 1,
524     VpdIdentifierTypeEUI64 = 2,
525     VpdIdentifierTypeFCPHName = 3,
526     VpdIdentifierTypePortRelative = 4,
527     VpdIdentifierTypeTargetPortGroup = 5,
528     VpdIdentifierTypeLogicalUnitGroup = 6,
529     VpdIdentifierTypeMD5LogicalUnitId = 7,
530     VpdIdentifierTypeSCSINameString = 8
531 } VPD_IDENTIFIER_TYPE, *PVPD_IDENTIFIER_TYPE;
532 
533 typedef enum _STORPORT_FUNCTION_CODE
534 {
535     ExtFunctionAllocatePool,
536     ExtFunctionFreePool,
537     ExtFunctionAllocateMdl,
538     ExtFunctionFreeMdl,
539     ExtFunctionBuildMdlForNonPagedPool,
540     ExtFunctionGetSystemAddress,
541     ExtFunctionGetOriginalMdl,
542     ExtFunctionCompleteServiceIrp,
543     ExtFunctionGetDeviceObjects,
544     ExtFunctionBuildScatterGatherList,
545     ExtFunctionPutScatterGatherList,
546     ExtFunctionAcquireMSISpinLock,
547     ExtFunctionReleaseMSISpinLock,
548     ExtFunctionGetMessageInterruptInformation,
549     ExtFunctionInitializePerformanceOptimizations,
550     ExtFunctionGetStartIoPerformanceParameters,
551     ExtFunctionLogSystemEvent,
552 #if (NTDDI_VERSION >= NTDDI_WIN7)
553     ExtFunctionGetCurrentProcessorNumber,
554     ExtFunctionGetActiveGroupCount,
555     ExtFunctionGetGroupAffinity,
556     ExtFunctionGetActiveNodeCount,
557     ExtFunctionGetNodeAffinity,
558     ExtFunctionGetHighestNodeNumber,
559     ExtFunctionGetLogicalProcessorRelationship,
560     ExtFunctionAllocateContiguousMemorySpecifyCacheNode,
561     ExtFunctionFreeContiguousMemorySpecifyCache
562 #endif
563 } STORPORT_FUNCTION_CODE, *PSTORPORT_FUNCTION_CODE;
564 
565 typedef enum _STOR_EVENT_ASSOCIATION_ENUM
566 {
567     StorEventAdapterAssociation = 0,
568     StorEventLunAssociation,
569     StorEventTargetAssociation,
570     StorEventInvalidAssociation
571 } STOR_EVENT_ASSOCIATION_ENUM;
572 
573 typedef enum _GETSGSTATUS
574 {
575     SG_ALLOCATED = 0,
576     SG_BUFFER_TOO_SMALL
577 } GETSGSTATUS, *PGETSGSTATUS;
578 
579 typedef struct _SCSI_REQUEST_BLOCK
580 {
581     USHORT Length;
582     UCHAR Function;
583     UCHAR SrbStatus;
584     UCHAR ScsiStatus;
585     UCHAR PathId;
586     UCHAR TargetId;
587     UCHAR Lun;
588     UCHAR QueueTag;
589     UCHAR QueueAction;
590     UCHAR CdbLength;
591     UCHAR SenseInfoBufferLength;
592     ULONG SrbFlags;
593     ULONG DataTransferLength;
594     ULONG TimeOutValue;
595     PVOID DataBuffer;
596     PVOID SenseInfoBuffer;
597     struct _SCSI_REQUEST_BLOCK *NextSrb;
598     PVOID OriginalRequest;
599     PVOID SrbExtension;
600     union
601     {
602         ULONG InternalStatus;
603         ULONG QueueSortKey;
604         ULONG LinkTimeoutValue;
605     };
606 #if defined(_WIN64)
607     ULONG Reserved;
608 #endif
609     UCHAR Cdb[16];
610 } SCSI_REQUEST_BLOCK, *PSCSI_REQUEST_BLOCK;
611 
612 typedef struct _SCSI_WMI_REQUEST_BLOCK
613 {
614     USHORT Length;
615     UCHAR Function;
616     UCHAR SrbStatus;
617     UCHAR WMISubFunction;
618     UCHAR PathId;
619     UCHAR TargetId;
620     UCHAR Lun;
621     UCHAR Reserved1;
622     UCHAR WMIFlags;
623     UCHAR Reserved2[2];
624     ULONG SrbFlags;
625     ULONG DataTransferLength;
626     ULONG TimeOutValue;
627     PVOID DataBuffer;
628     PVOID DataPath;
629     PVOID Reserved3;
630     PVOID OriginalRequest;
631     PVOID SrbExtension;
632     ULONG Reserved4;
633 #if (NTDDI_VERSION >= NTDDI_WS03SP1) && defined(_WIN64)
634     ULONG Reserved6;
635 #endif
636     UCHAR Reserved5[16];
637 } SCSI_WMI_REQUEST_BLOCK, *PSCSI_WMI_REQUEST_BLOCK;
638 
639 typedef struct _SCSI_POWER_REQUEST_BLOCK
640 {
641     USHORT Length;
642     UCHAR Function;
643     UCHAR SrbStatus;
644     UCHAR SrbPowerFlags;
645     UCHAR PathId;
646     UCHAR TargetId;
647     UCHAR Lun;
648     STOR_DEVICE_POWER_STATE DevicePowerState;
649     ULONG SrbFlags;
650     ULONG DataTransferLength;
651     ULONG TimeOutValue;
652     PVOID DataBuffer;
653     PVOID SenseInfoBuffer;
654     struct _SCSI_REQUEST_BLOCK *NextSrb;
655     PVOID OriginalRequest;
656     PVOID SrbExtension;
657     STOR_POWER_ACTION PowerAction;
658 #if defined(_WIN64)
659     ULONG Reserved;
660 #endif
661     UCHAR Reserved5[16];
662 } SCSI_POWER_REQUEST_BLOCK, *PSCSI_POWER_REQUEST_BLOCK;
663 
664 typedef struct _STOR_DEVICE_CAPABILITIES
665 {
666     USHORT Version;
667     ULONG DeviceD1:1;
668     ULONG DeviceD2:1;
669     ULONG LockSupported:1;
670     ULONG EjectSupported:1;
671     ULONG Removable:1;
672     ULONG DockDevice:1;
673     ULONG UniqueID:1;
674     ULONG SilentInstall:1;
675     ULONG SurpriseRemovalOK:1;
676     ULONG NoDisplayInUI:1;
677 } STOR_DEVICE_CAPABILITIES, *PSTOR_DEVICE_CAPABILITIES;
678 
679 typedef struct _SCSI_PNP_REQUEST_BLOCK
680 {
681     USHORT Length;
682     UCHAR Function;
683     UCHAR SrbStatus;
684     UCHAR PnPSubFunction;
685     UCHAR PathId;
686     UCHAR TargetId;
687     UCHAR Lun;
688     STOR_PNP_ACTION PnPAction;
689     ULONG SrbFlags;
690     ULONG DataTransferLength;
691     ULONG TimeOutValue;
692     PVOID DataBuffer;
693     PVOID SenseInfoBuffer;
694     struct _SCSI_REQUEST_BLOCK *NextSrb;
695     PVOID OriginalRequest;
696     PVOID SrbExtension;
697     ULONG SrbPnPFlags;
698 #if defined(_WIN64)
699     ULONG Reserved;
700 #endif
701     UCHAR Reserved4[16];
702 } SCSI_PNP_REQUEST_BLOCK, *PSCSI_PNP_REQUEST_BLOCK;
703 
704 #include <pshpack1.h>
705 typedef union _CDB
706 {
707     struct _CDB6GENERIC
708     {
709         UCHAR OperationCode;
710         UCHAR Immediate:1;
711         UCHAR CommandUniqueBits:4;
712         UCHAR LogicalUnitNumber:3;
713         UCHAR CommandUniqueBytes[3];
714         UCHAR Link:1;
715         UCHAR Flag:1;
716         UCHAR Reserved:4;
717         UCHAR VendorUnique:2;
718     } CDB6GENERIC, *PCDB6GENERIC;
719     struct _CDB6READWRITE
720     {
721         UCHAR OperationCode;
722         UCHAR LogicalBlockMsb1:5;
723         UCHAR LogicalUnitNumber:3;
724         UCHAR LogicalBlockMsb0;
725         UCHAR LogicalBlockLsb;
726         UCHAR TransferBlocks;
727         UCHAR Control;
728     } CDB6READWRITE, *PCDB6READWRITE;
729     struct _CDB6INQUIRY
730     {
731         UCHAR OperationCode;
732         UCHAR Reserved1:5;
733         UCHAR LogicalUnitNumber:3;
734         UCHAR PageCode;
735         UCHAR IReserved;
736         UCHAR AllocationLength;
737         UCHAR Control;
738     } CDB6INQUIRY, *PCDB6INQUIRY;
739     struct _CDB6INQUIRY3
740     {
741         UCHAR OperationCode;
742         UCHAR EnableVitalProductData:1;
743         UCHAR CommandSupportData:1;
744         UCHAR Reserved1:6;
745         UCHAR PageCode;
746         UCHAR Reserved2;
747         UCHAR AllocationLength;
748         UCHAR Control;
749     } CDB6INQUIRY3, *PCDB6INQUIRY3;
750     struct _CDB6VERIFY
751     {
752         UCHAR OperationCode;
753         UCHAR Fixed:1;
754         UCHAR ByteCompare:1;
755         UCHAR Immediate:1;
756         UCHAR Reserved:2;
757         UCHAR LogicalUnitNumber:3;
758         UCHAR VerificationLength[3];
759         UCHAR Control;
760     } CDB6VERIFY, *PCDB6VERIFY;
761     struct _CDB6FORMAT
762     {
763         UCHAR OperationCode;
764         UCHAR FormatControl:5;
765         UCHAR LogicalUnitNumber:3;
766         UCHAR FReserved1;
767         UCHAR InterleaveMsb;
768         UCHAR InterleaveLsb;
769         UCHAR FReserved2;
770     } CDB6FORMAT, *PCDB6FORMAT;
771     struct _CDB10
772     {
773         UCHAR OperationCode;
774         UCHAR RelativeAddress:1;
775         UCHAR Reserved1:2;
776         UCHAR ForceUnitAccess:1;
777         UCHAR DisablePageOut:1;
778         UCHAR LogicalUnitNumber:3;
779         UCHAR LogicalBlockByte0;
780         UCHAR LogicalBlockByte1;
781         UCHAR LogicalBlockByte2;
782         UCHAR LogicalBlockByte3;
783         UCHAR Reserved2;
784         UCHAR TransferBlocksMsb;
785         UCHAR TransferBlocksLsb;
786         UCHAR Control;
787     } CDB10, *PCDB10;
788     struct _CDB12
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 LogicalBlock[4];
797         UCHAR TransferLength[4];
798         UCHAR Reserved2;
799         UCHAR Control;
800     } CDB12, *PCDB12;
801     struct _CDB16
802     {
803         UCHAR OperationCode;
804         UCHAR Reserved1:3;
805         UCHAR ForceUnitAccess:1;
806         UCHAR DisablePageOut:1;
807         UCHAR Protection:3;
808         UCHAR LogicalBlock[8];
809         UCHAR TransferLength[4];
810         UCHAR Reserved2;
811         UCHAR Control;
812     } CDB16, *PCDB16;
813     struct _PAUSE_RESUME
814     {
815         UCHAR OperationCode;
816         UCHAR Reserved1:5;
817         UCHAR LogicalUnitNumber:3;
818         UCHAR Reserved2[6];
819         UCHAR Action;
820         UCHAR Control;
821     } PAUSE_RESUME, *PPAUSE_RESUME;
822     struct _READ_TOC
823     {
824         UCHAR OperationCode;
825         UCHAR Reserved0:1;
826         UCHAR Msf:1;
827         UCHAR Reserved1:3;
828         UCHAR LogicalUnitNumber:3;
829         UCHAR Format2:4;
830         UCHAR Reserved2:4;
831         UCHAR Reserved3[3];
832         UCHAR StartingTrack;
833         UCHAR AllocationLength[2];
834         UCHAR Control:6;
835         UCHAR Format:2;
836     } READ_TOC, *PREAD_TOC;
837     struct _READ_DISK_INFORMATION
838     {
839         UCHAR OperationCode;
840         UCHAR Reserved1:5;
841         UCHAR Lun:3;
842         UCHAR Reserved2[5];
843         UCHAR AllocationLength[2];
844         UCHAR Control;
845     } READ_DISK_INFORMATION, *PREAD_DISK_INFORMATION;
846     struct _READ_TRACK_INFORMATION
847     {
848         UCHAR OperationCode;
849         UCHAR Track:1;
850         UCHAR Reserved1:3;
851         UCHAR Reserved2:1;
852         UCHAR Lun:3;
853         UCHAR BlockAddress[4];
854         UCHAR Reserved3;
855         UCHAR AllocationLength[2];
856         UCHAR Control;
857     } READ_TRACK_INFORMATION, *PREAD_TRACK_INFORMATION;
858     struct _RESERVE_TRACK_RZONE
859     {
860         UCHAR OperationCode;
861         UCHAR Reserved1[4];
862         UCHAR ReservationSize[4];
863         UCHAR Control;
864     } RESERVE_TRACK_RZONE, *PRESERVE_TRACK_RZONE;
865     struct _SEND_OPC_INFORMATION
866     {
867         UCHAR OperationCode;
868         UCHAR DoOpc:1;
869         UCHAR Reserved1:7;
870         UCHAR Exclude0:1;
871         UCHAR Exclude1:1;
872         UCHAR Reserved2:6;
873         UCHAR Reserved3[4];
874         UCHAR ParameterListLength[2];
875         UCHAR Reserved4;
876     } SEND_OPC_INFORMATION, *PSEND_OPC_INFORMATION;
877     struct _REPAIR_TRACK
878     {
879         UCHAR OperationCode;
880         UCHAR Immediate:1;
881         UCHAR Reserved1:7;
882         UCHAR Reserved2[2];
883         UCHAR TrackNumber[2];
884         UCHAR Reserved3[3];
885         UCHAR Control;
886     } REPAIR_TRACK, *PREPAIR_TRACK;
887     struct _CLOSE_TRACK
888     {
889         UCHAR OperationCode;
890         UCHAR Immediate:1;
891         UCHAR Reserved1:7;
892         UCHAR Track:1;
893         UCHAR Session:1;
894         UCHAR Reserved2:6;
895         UCHAR Reserved3;
896         UCHAR TrackNumber[2];
897         UCHAR Reserved4[3];
898         UCHAR Control;
899     } CLOSE_TRACK, *PCLOSE_TRACK;
900     struct _READ_BUFFER_CAPACITY
901     {
902         UCHAR OperationCode;
903         UCHAR BlockInfo:1;
904         UCHAR Reserved1:7;
905         UCHAR Reserved2[5];
906         UCHAR AllocationLength[2];
907         UCHAR Control;
908     } READ_BUFFER_CAPACITY, *PREAD_BUFFER_CAPACITY;
909     struct _SEND_CUE_SHEET
910     {
911         UCHAR OperationCode;
912         UCHAR Reserved[5];
913         UCHAR CueSheetSize[3];
914         UCHAR Control;
915     } SEND_CUE_SHEET, *PSEND_CUE_SHEET;
916     struct _READ_HEADER
917     {
918         UCHAR OperationCode;
919         UCHAR Reserved1:1;
920         UCHAR Msf:1;
921         UCHAR Reserved2:3;
922         UCHAR Lun:3;
923         UCHAR LogicalBlockAddress[4];
924         UCHAR Reserved3;
925         UCHAR AllocationLength[2];
926         UCHAR Control;
927     } READ_HEADER, *PREAD_HEADER;
928     struct _PLAY_AUDIO
929     {
930         UCHAR OperationCode;
931         UCHAR Reserved1:5;
932         UCHAR LogicalUnitNumber:3;
933         UCHAR StartingBlockAddress[4];
934         UCHAR Reserved2;
935         UCHAR PlayLength[2];
936         UCHAR Control;
937     } PLAY_AUDIO, *PPLAY_AUDIO;
938     struct _PLAY_AUDIO_MSF
939     {
940         UCHAR OperationCode;
941         UCHAR Reserved1:5;
942         UCHAR LogicalUnitNumber:3;
943         UCHAR Reserved2;
944         UCHAR StartingM;
945         UCHAR StartingS;
946         UCHAR StartingF;
947         UCHAR EndingM;
948         UCHAR EndingS;
949         UCHAR EndingF;
950         UCHAR Control;
951     } PLAY_AUDIO_MSF, *PPLAY_AUDIO_MSF;
952     struct _BLANK_MEDIA
953     {
954         UCHAR OperationCode;
955         UCHAR BlankType:3;
956         UCHAR Reserved1:1;
957         UCHAR Immediate:1;
958         UCHAR Reserved2:3;
959         UCHAR AddressOrTrack[4];
960         UCHAR Reserved3[5];
961         UCHAR Control;
962     } BLANK_MEDIA, *PBLANK_MEDIA;
963     struct _PLAY_CD
964     {
965         UCHAR OperationCode;
966         UCHAR Reserved1:1;
967         UCHAR CMSF:1;
968         UCHAR ExpectedSectorType:3;
969         UCHAR Lun:3;
970         _ANONYMOUS_UNION union
971         {
972             struct _LBA
973             {
974                 UCHAR StartingBlockAddress[4];
975                 UCHAR PlayLength[4];
976             } LBA;
977             struct _MSF
978             {
979                 UCHAR Reserved1;
980                 UCHAR StartingM;
981                 UCHAR StartingS;
982                 UCHAR StartingF;
983                 UCHAR EndingM;
984                 UCHAR EndingS;
985                 UCHAR EndingF;
986                 UCHAR Reserved2;
987             } MSF;
988         } DUMMYUNIONNAME;
989         UCHAR Audio:1;
990         UCHAR Composite:1;
991         UCHAR Port1:1;
992         UCHAR Port2:1;
993         UCHAR Reserved2:3;
994         UCHAR Speed:1;
995         UCHAR Control;
996     } PLAY_CD, *PPLAY_CD;
997     struct _SCAN_CD
998     {
999         UCHAR OperationCode;
1000         UCHAR RelativeAddress:1;
1001         UCHAR Reserved1:3;
1002         UCHAR Direct:1;
1003         UCHAR Lun:3;
1004         UCHAR StartingAddress[4];
1005         UCHAR Reserved2[3];
1006         UCHAR Reserved3:6;
1007         UCHAR Type:2;
1008         UCHAR Reserved4;
1009         UCHAR Control;
1010     } SCAN_CD, *PSCAN_CD;
1011     struct _STOP_PLAY_SCAN
1012     {
1013         UCHAR OperationCode;
1014         UCHAR Reserved1:5;
1015         UCHAR Lun:3;
1016         UCHAR Reserved2[7];
1017         UCHAR Control;
1018     } STOP_PLAY_SCAN, *PSTOP_PLAY_SCAN;
1019     struct _SUBCHANNEL
1020     {
1021         UCHAR OperationCode;
1022         UCHAR Reserved0:1;
1023         UCHAR Msf:1;
1024         UCHAR Reserved1:3;
1025         UCHAR LogicalUnitNumber:3;
1026         UCHAR Reserved2:6;
1027         UCHAR SubQ:1;
1028         UCHAR Reserved3:1;
1029         UCHAR Format;
1030         UCHAR Reserved4[2];
1031         UCHAR TrackNumber;
1032         UCHAR AllocationLength[2];
1033         UCHAR Control;
1034     } SUBCHANNEL, *PSUBCHANNEL;
1035     struct _READ_CD
1036     {
1037         UCHAR OperationCode;
1038         UCHAR RelativeAddress:1;
1039         UCHAR Reserved0:1;
1040         UCHAR ExpectedSectorType:3;
1041         UCHAR Lun:3;
1042         UCHAR StartingLBA[4];
1043         UCHAR TransferBlocks[3];
1044         UCHAR Reserved2:1;
1045         UCHAR ErrorFlags:2;
1046         UCHAR IncludeEDC:1;
1047         UCHAR IncludeUserData:1;
1048         UCHAR HeaderCode:2;
1049         UCHAR IncludeSyncData:1;
1050         UCHAR SubChannelSelection:3;
1051         UCHAR Reserved3:5;
1052         UCHAR Control;
1053     } READ_CD, *PREAD_CD;
1054     struct _READ_CD_MSF
1055     {
1056         UCHAR OperationCode;
1057         UCHAR RelativeAddress:1;
1058         UCHAR Reserved1:1;
1059         UCHAR ExpectedSectorType:3;
1060         UCHAR Lun:3;
1061         UCHAR Reserved2;
1062         UCHAR StartingM;
1063         UCHAR StartingS;
1064         UCHAR StartingF;
1065         UCHAR EndingM;
1066         UCHAR EndingS;
1067         UCHAR EndingF;
1068         UCHAR Reserved3;
1069         UCHAR Reserved4:1;
1070         UCHAR ErrorFlags:2;
1071         UCHAR IncludeEDC:1;
1072         UCHAR IncludeUserData:1;
1073         UCHAR HeaderCode:2;
1074         UCHAR IncludeSyncData:1;
1075         UCHAR SubChannelSelection:3;
1076         UCHAR Reserved5:5;
1077         UCHAR Control;
1078     } READ_CD_MSF, *PREAD_CD_MSF;
1079     struct _PLXTR_READ_CDDA
1080     {
1081         UCHAR OperationCode;
1082         UCHAR Reserved0:5;
1083         UCHAR LogicalUnitNumber:3;
1084         UCHAR LogicalBlockByte0;
1085         UCHAR LogicalBlockByte1;
1086         UCHAR LogicalBlockByte2;
1087         UCHAR LogicalBlockByte3;
1088         UCHAR TransferBlockByte0;
1089         UCHAR TransferBlockByte1;
1090         UCHAR TransferBlockByte2;
1091         UCHAR TransferBlockByte3;
1092         UCHAR SubCode;
1093         UCHAR Control;
1094     } PLXTR_READ_CDDA, *PPLXTR_READ_CDDA;
1095     struct _NEC_READ_CDDA
1096     {
1097         UCHAR OperationCode;
1098         UCHAR Reserved0;
1099         UCHAR LogicalBlockByte0;
1100         UCHAR LogicalBlockByte1;
1101         UCHAR LogicalBlockByte2;
1102         UCHAR LogicalBlockByte3;
1103         UCHAR Reserved1;
1104         UCHAR TransferBlockByte0;
1105         UCHAR TransferBlockByte1;
1106         UCHAR Control;
1107     } NEC_READ_CDDA, *PNEC_READ_CDDA;
1108     struct _MODE_SENSE
1109     {
1110         UCHAR OperationCode;
1111         UCHAR Reserved1:3;
1112         UCHAR Dbd:1;
1113         UCHAR Reserved2:1;
1114         UCHAR LogicalUnitNumber:3;
1115         UCHAR PageCode:6;
1116         UCHAR Pc:2;
1117         UCHAR Reserved3;
1118         UCHAR AllocationLength;
1119         UCHAR Control;
1120     } MODE_SENSE, *PMODE_SENSE;
1121     struct _MODE_SENSE10
1122     {
1123         UCHAR OperationCode;
1124         UCHAR Reserved1:3;
1125         UCHAR Dbd:1;
1126         UCHAR Reserved2:1;
1127         UCHAR LogicalUnitNumber:3;
1128         UCHAR PageCode:6;
1129         UCHAR Pc:2;
1130         UCHAR Reserved3[4];
1131         UCHAR AllocationLength[2];
1132         UCHAR Control;
1133     } MODE_SENSE10, *PMODE_SENSE10;
1134     struct _MODE_SELECT
1135     {
1136         UCHAR OperationCode;
1137         UCHAR SPBit:1;
1138         UCHAR Reserved1:3;
1139         UCHAR PFBit:1;
1140         UCHAR LogicalUnitNumber:3;
1141         UCHAR Reserved2[2];
1142         UCHAR ParameterListLength;
1143         UCHAR Control;
1144     } MODE_SELECT, *PMODE_SELECT;
1145     struct _MODE_SELECT10
1146     {
1147         UCHAR OperationCode;
1148         UCHAR SPBit:1;
1149         UCHAR Reserved1:3;
1150         UCHAR PFBit:1;
1151         UCHAR LogicalUnitNumber:3;
1152         UCHAR Reserved2[5];
1153         UCHAR ParameterListLength[2];
1154         UCHAR Control;
1155     } MODE_SELECT10, *PMODE_SELECT10;
1156     struct _LOCATE
1157     {
1158         UCHAR OperationCode;
1159         UCHAR Immediate:1;
1160         UCHAR CPBit:1;
1161         UCHAR BTBit:1;
1162         UCHAR Reserved1:2;
1163         UCHAR LogicalUnitNumber:3;
1164         UCHAR Reserved3;
1165         UCHAR LogicalBlockAddress[4];
1166         UCHAR Reserved4;
1167         UCHAR Partition;
1168         UCHAR Control;
1169     } LOCATE, *PLOCATE;
1170     struct _LOGSENSE
1171     {
1172         UCHAR OperationCode;
1173         UCHAR SPBit:1;
1174         UCHAR PPCBit:1;
1175         UCHAR Reserved1:3;
1176         UCHAR LogicalUnitNumber:3;
1177         UCHAR PageCode:6;
1178         UCHAR PCBit:2;
1179         UCHAR Reserved2;
1180         UCHAR Reserved3;
1181         UCHAR ParameterPointer[2];
1182         UCHAR AllocationLength[2];
1183         UCHAR Control;
1184     } LOGSENSE, *PLOGSENSE;
1185     struct _LOGSELECT
1186     {
1187         UCHAR OperationCode;
1188         UCHAR SPBit:1;
1189         UCHAR PCRBit:1;
1190         UCHAR Reserved1:3;
1191         UCHAR LogicalUnitNumber:3;
1192         UCHAR Reserved:6;
1193         UCHAR PCBit:2;
1194         UCHAR Reserved2[4];
1195         UCHAR ParameterListLength[2];
1196         UCHAR Control;
1197     } LOGSELECT, *PLOGSELECT;
1198     struct _PRINT
1199     {
1200         UCHAR OperationCode;
1201         UCHAR Reserved:5;
1202         UCHAR LogicalUnitNumber:3;
1203         UCHAR TransferLength[3];
1204         UCHAR Control;
1205     } PRINT, *PPRINT;
1206     struct _SEEK
1207     {
1208         UCHAR OperationCode;
1209         UCHAR Reserved1:5;
1210         UCHAR LogicalUnitNumber:3;
1211         UCHAR LogicalBlockAddress[4];
1212         UCHAR Reserved2[3];
1213         UCHAR Control;
1214     } SEEK, *PSEEK;
1215     struct _ERASE
1216     {
1217         UCHAR OperationCode;
1218         UCHAR Long:1;
1219         UCHAR Immediate:1;
1220         UCHAR Reserved1:3;
1221         UCHAR LogicalUnitNumber:3;
1222         UCHAR Reserved2[3];
1223         UCHAR Control;
1224     } ERASE, *PERASE;
1225     struct _START_STOP
1226     {
1227         UCHAR OperationCode;
1228         UCHAR Immediate:1;
1229         UCHAR Reserved1:4;
1230         UCHAR LogicalUnitNumber:3;
1231         UCHAR Reserved2[2];
1232         UCHAR Start:1;
1233         UCHAR LoadEject:1;
1234         UCHAR Reserved3:6;
1235         UCHAR Control;
1236     } START_STOP, *PSTART_STOP;
1237     struct _MEDIA_REMOVAL
1238     {
1239         UCHAR OperationCode;
1240         UCHAR Reserved1:5;
1241         UCHAR LogicalUnitNumber:3;
1242         UCHAR Reserved2[2];
1243         UCHAR Prevent:1;
1244         UCHAR Persistant:1;
1245         UCHAR Reserved3:6;
1246         UCHAR Control;
1247     } MEDIA_REMOVAL, *PMEDIA_REMOVAL;
1248     struct _SEEK_BLOCK
1249     {
1250         UCHAR OperationCode;
1251         UCHAR Immediate:1;
1252         UCHAR Reserved1:7;
1253         UCHAR BlockAddress[3];
1254         UCHAR Link:1;
1255         UCHAR Flag:1;
1256         UCHAR Reserved2:4;
1257         UCHAR VendorUnique:2;
1258     } SEEK_BLOCK, *PSEEK_BLOCK;
1259     struct _REQUEST_BLOCK_ADDRESS
1260     {
1261         UCHAR OperationCode;
1262         UCHAR Reserved1[3];
1263         UCHAR AllocationLength;
1264         UCHAR Link:1;
1265         UCHAR Flag:1;
1266         UCHAR Reserved2:4;
1267         UCHAR VendorUnique:2;
1268     } REQUEST_BLOCK_ADDRESS, *PREQUEST_BLOCK_ADDRESS;
1269     struct _PARTITION
1270     {
1271         UCHAR OperationCode;
1272         UCHAR Immediate:1;
1273         UCHAR Sel:1;
1274         UCHAR PartitionSelect:6;
1275         UCHAR Reserved1[3];
1276         UCHAR Control;
1277     } PARTITION, *PPARTITION;
1278     struct _WRITE_TAPE_MARKS
1279     {
1280         UCHAR OperationCode;
1281         UCHAR Immediate:1;
1282         UCHAR WriteSetMarks:1;
1283         UCHAR Reserved:3;
1284         UCHAR LogicalUnitNumber:3;
1285         UCHAR TransferLength[3];
1286         UCHAR Control;
1287     } WRITE_TAPE_MARKS, *PWRITE_TAPE_MARKS;
1288     struct _SPACE_TAPE_MARKS
1289     {
1290         UCHAR OperationCode;
1291         UCHAR Code:3;
1292         UCHAR Reserved:2;
1293         UCHAR LogicalUnitNumber:3;
1294         UCHAR NumMarksMSB;
1295         UCHAR NumMarks;
1296         UCHAR NumMarksLSB;
1297         union
1298         {
1299             UCHAR value;
1300             struct
1301             {
1302                 UCHAR Link:1;
1303                 UCHAR Flag:1;
1304                 UCHAR Reserved:4;
1305                 UCHAR VendorUnique:2;
1306             } Fields;
1307         } Byte6;
1308     } SPACE_TAPE_MARKS, *PSPACE_TAPE_MARKS;
1309     struct _READ_POSITION
1310     {
1311         UCHAR Operation;
1312         UCHAR BlockType:1;
1313         UCHAR Reserved1:4;
1314         UCHAR Lun:3;
1315         UCHAR Reserved2[7];
1316         UCHAR Control;
1317     } READ_POSITION, *PREAD_POSITION;
1318     struct _CDB6READWRITETAPE
1319     {
1320         UCHAR OperationCode;
1321         UCHAR VendorSpecific:5;
1322         UCHAR Reserved:3;
1323         UCHAR TransferLenMSB;
1324         UCHAR TransferLen;
1325         UCHAR TransferLenLSB;
1326         UCHAR Link:1;
1327         UCHAR Flag:1;
1328         UCHAR Reserved1:4;
1329         UCHAR VendorUnique:2;
1330     } CDB6READWRITETAPE, *PCDB6READWRITETAPE;
1331     struct _INIT_ELEMENT_STATUS
1332     {
1333         UCHAR OperationCode;
1334         UCHAR Reserved1:5;
1335         UCHAR LogicalUnitNubmer:3;
1336         UCHAR Reserved2[3];
1337         UCHAR Reserved3:7;
1338         UCHAR NoBarCode:1;
1339     } INIT_ELEMENT_STATUS, *PINIT_ELEMENT_STATUS;
1340     struct _INITIALIZE_ELEMENT_RANGE
1341     {
1342         UCHAR OperationCode;
1343         UCHAR Range:1;
1344         UCHAR Reserved1:4;
1345         UCHAR LogicalUnitNubmer:3;
1346         UCHAR FirstElementAddress[2];
1347         UCHAR Reserved2[2];
1348         UCHAR NumberOfElements[2];
1349         UCHAR Reserved3;
1350         UCHAR Reserved4:7;
1351         UCHAR NoBarCode:1;
1352     } INITIALIZE_ELEMENT_RANGE, *PINITIALIZE_ELEMENT_RANGE;
1353     struct _POSITION_TO_ELEMENT
1354     {
1355         UCHAR OperationCode;
1356         UCHAR Reserved1:5;
1357         UCHAR LogicalUnitNumber:3;
1358         UCHAR TransportElementAddress[2];
1359         UCHAR DestinationElementAddress[2];
1360         UCHAR Reserved2[2];
1361         UCHAR Flip:1;
1362         UCHAR Reserved3:7;
1363         UCHAR Control;
1364     } POSITION_TO_ELEMENT, *PPOSITION_TO_ELEMENT;
1365     struct _MOVE_MEDIUM
1366     {
1367         UCHAR OperationCode;
1368         UCHAR Reserved1:5;
1369         UCHAR LogicalUnitNumber:3;
1370         UCHAR TransportElementAddress[2];
1371         UCHAR SourceElementAddress[2];
1372         UCHAR DestinationElementAddress[2];
1373         UCHAR Reserved2[2];
1374         UCHAR Flip:1;
1375         UCHAR Reserved3:7;
1376         UCHAR Control;
1377     } MOVE_MEDIUM, *PMOVE_MEDIUM;
1378     struct _EXCHANGE_MEDIUM
1379     {
1380         UCHAR OperationCode;
1381         UCHAR Reserved1:5;
1382         UCHAR LogicalUnitNumber:3;
1383         UCHAR TransportElementAddress[2];
1384         UCHAR SourceElementAddress[2];
1385         UCHAR Destination1ElementAddress[2];
1386         UCHAR Destination2ElementAddress[2];
1387         UCHAR Flip1:1;
1388         UCHAR Flip2:1;
1389         UCHAR Reserved3:6;
1390         UCHAR Control;
1391     } EXCHANGE_MEDIUM, *PEXCHANGE_MEDIUM;
1392     struct _READ_ELEMENT_STATUS
1393     {
1394         UCHAR OperationCode;
1395         UCHAR ElementType:4;
1396         UCHAR VolTag:1;
1397         UCHAR LogicalUnitNumber:3;
1398         UCHAR StartingElementAddress[2];
1399         UCHAR NumberOfElements[2];
1400         UCHAR Reserved1;
1401         UCHAR AllocationLength[3];
1402         UCHAR Reserved2;
1403         UCHAR Control;
1404     } READ_ELEMENT_STATUS, *PREAD_ELEMENT_STATUS;
1405     struct _SEND_VOLUME_TAG
1406     {
1407         UCHAR OperationCode;
1408         UCHAR ElementType:4;
1409         UCHAR Reserved1:1;
1410         UCHAR LogicalUnitNumber:3;
1411         UCHAR StartingElementAddress[2];
1412         UCHAR Reserved2;
1413         UCHAR ActionCode:5;
1414         UCHAR Reserved3:3;
1415         UCHAR Reserved4[2];
1416         UCHAR ParameterListLength[2];
1417         UCHAR Reserved5;
1418         UCHAR Control;
1419     } SEND_VOLUME_TAG, *PSEND_VOLUME_TAG;
1420     struct _REQUEST_VOLUME_ELEMENT_ADDRESS
1421     {
1422         UCHAR OperationCode;
1423         UCHAR ElementType:4;
1424         UCHAR VolTag:1;
1425         UCHAR LogicalUnitNumber:3;
1426         UCHAR StartingElementAddress[2];
1427         UCHAR NumberElements[2];
1428         UCHAR Reserved1;
1429         UCHAR AllocationLength[3];
1430         UCHAR Reserved2;
1431         UCHAR Control;
1432     } REQUEST_VOLUME_ELEMENT_ADDRESS, *PREQUEST_VOLUME_ELEMENT_ADDRESS;
1433     struct _LOAD_UNLOAD
1434     {
1435         UCHAR OperationCode;
1436         UCHAR Immediate:1;
1437         UCHAR Reserved1:4;
1438         UCHAR Lun:3;
1439         UCHAR Reserved2[2];
1440         UCHAR Start:1;
1441         UCHAR LoadEject:1;
1442         UCHAR Reserved3:6;
1443         UCHAR Reserved4[3];
1444         UCHAR Slot;
1445         UCHAR Reserved5[3];
1446     } LOAD_UNLOAD, *PLOAD_UNLOAD;
1447     struct _MECH_STATUS
1448     {
1449         UCHAR OperationCode;
1450         UCHAR Reserved:5;
1451         UCHAR Lun:3;
1452         UCHAR Reserved1[6];
1453         UCHAR AllocationLength[2];
1454         UCHAR Reserved2[1];
1455         UCHAR Control;
1456     } MECH_STATUS, *PMECH_STATUS;
1457     struct _SYNCHRONIZE_CACHE10
1458     {
1459         UCHAR OperationCode;
1460         UCHAR RelAddr:1;
1461         UCHAR Immediate:1;
1462         UCHAR Reserved:3;
1463         UCHAR Lun:3;
1464         UCHAR LogicalBlockAddress[4];
1465         UCHAR Reserved2;
1466         UCHAR BlockCount[2];
1467         UCHAR Control;
1468     } SYNCHRONIZE_CACHE10, *PSYNCHRONIZE_CACHE10;
1469     struct _GET_EVENT_STATUS_NOTIFICATION
1470     {
1471         UCHAR OperationCode;
1472         UCHAR Immediate:1;
1473         UCHAR Reserved:4;
1474         UCHAR Lun:3;
1475         UCHAR Reserved2[2];
1476         UCHAR NotificationClassRequest;
1477         UCHAR Reserved3[2];
1478         UCHAR EventListLength[2];
1479         UCHAR Control;
1480     } GET_EVENT_STATUS_NOTIFICATION, *PGET_EVENT_STATUS_NOTIFICATION;
1481     struct _GET_PERFORMANCE
1482     {
1483         UCHAR OperationCode;
1484         UCHAR Except:2;
1485         UCHAR Write:1;
1486         UCHAR Tolerance:2;
1487         UCHAR Reserved0:3;
1488         UCHAR StartingLBA[4];
1489         UCHAR Reserved1[2];
1490         UCHAR MaximumNumberOfDescriptors[2];
1491         UCHAR Type;
1492         UCHAR Control;
1493     } GET_PERFORMANCE;
1494     struct _READ_DVD_STRUCTURE
1495     {
1496         UCHAR OperationCode;
1497         UCHAR Reserved1:5;
1498         UCHAR Lun:3;
1499         UCHAR RMDBlockNumber[4];
1500         UCHAR LayerNumber;
1501         UCHAR Format;
1502         UCHAR AllocationLength[2];
1503         UCHAR Reserved3:6;
1504         UCHAR AGID:2;
1505         UCHAR Control;
1506     } READ_DVD_STRUCTURE, *PREAD_DVD_STRUCTURE;
1507     struct _SET_STREAMING
1508     {
1509         UCHAR OperationCode;
1510         UCHAR Reserved[8];
1511         UCHAR ParameterListLength[2];
1512         UCHAR Control;
1513     } SET_STREAMING;
1514     struct _SEND_DVD_STRUCTURE
1515     {
1516         UCHAR OperationCode;
1517         UCHAR Reserved1:5;
1518         UCHAR Lun:3;
1519         UCHAR Reserved2[5];
1520         UCHAR Format;
1521         UCHAR ParameterListLength[2];
1522         UCHAR Reserved3;
1523         UCHAR Control;
1524     } SEND_DVD_STRUCTURE, *PSEND_DVD_STRUCTURE;
1525     struct _SEND_KEY
1526     {
1527         UCHAR OperationCode;
1528         UCHAR Reserved1:5;
1529         UCHAR Lun:3;
1530         UCHAR Reserved2[6];
1531         UCHAR ParameterListLength[2];
1532         UCHAR KeyFormat:6;
1533         UCHAR AGID:2;
1534         UCHAR Control;
1535     } SEND_KEY, *PSEND_KEY;
1536     struct _REPORT_KEY
1537     {
1538         UCHAR OperationCode;
1539         UCHAR Reserved1:5;
1540         UCHAR Lun:3;
1541         UCHAR LogicalBlockAddress[4];
1542         UCHAR Reserved2[2];
1543         UCHAR AllocationLength[2];
1544         UCHAR KeyFormat:6;
1545         UCHAR AGID:2;
1546         UCHAR Control;
1547     } REPORT_KEY, *PREPORT_KEY;
1548     struct _SET_READ_AHEAD
1549     {
1550         UCHAR OperationCode;
1551         UCHAR Reserved1:5;
1552         UCHAR Lun:3;
1553         UCHAR TriggerLBA[4];
1554         UCHAR ReadAheadLBA[4];
1555         UCHAR Reserved2;
1556         UCHAR Control;
1557     } SET_READ_AHEAD, *PSET_READ_AHEAD;
1558     struct _READ_FORMATTED_CAPACITIES
1559     {
1560         UCHAR OperationCode;
1561         UCHAR Reserved1:5;
1562         UCHAR Lun:3;
1563         UCHAR Reserved2[5];
1564         UCHAR AllocationLength[2];
1565         UCHAR Control;
1566     } READ_FORMATTED_CAPACITIES, *PREAD_FORMATTED_CAPACITIES;
1567     struct _REPORT_LUNS
1568     {
1569         UCHAR OperationCode;
1570         UCHAR Reserved1[5];
1571         UCHAR AllocationLength[4];
1572         UCHAR Reserved2[1];
1573         UCHAR Control;
1574     } REPORT_LUNS, *PREPORT_LUNS;
1575     struct _PERSISTENT_RESERVE_IN
1576     {
1577         UCHAR OperationCode;
1578         UCHAR ServiceAction:5;
1579         UCHAR Reserved1:3;
1580         UCHAR Reserved2[5];
1581         UCHAR AllocationLength[2];
1582         UCHAR Control;
1583     } PERSISTENT_RESERVE_IN, *PPERSISTENT_RESERVE_IN;
1584     struct _PERSISTENT_RESERVE_OUT
1585     {
1586         UCHAR OperationCode;
1587         UCHAR ServiceAction:5;
1588         UCHAR Reserved1:3;
1589         UCHAR Type:4;
1590         UCHAR Scope:4;
1591         UCHAR Reserved2[4];
1592         UCHAR ParameterListLength[2];
1593         UCHAR Control;
1594     } PERSISTENT_RESERVE_OUT, *PPERSISTENT_RESERVE_OUT;
1595     struct _GET_CONFIGURATION
1596     {
1597         UCHAR OperationCode;
1598         UCHAR RequestType:1;
1599         UCHAR Reserved1:7;
1600         UCHAR StartingFeature[2];
1601         UCHAR Reserved2[3];
1602         UCHAR AllocationLength[2];
1603         UCHAR Control;
1604     } GET_CONFIGURATION, *PGET_CONFIGURATION;
1605     struct _SET_CD_SPEED
1606     {
1607         UCHAR OperationCode;
1608         _ANONYMOUS_UNION union
1609         {
1610             UCHAR Reserved1;
1611             _ANONYMOUS_STRUCT struct
1612             {
1613                 UCHAR RotationControl:2;
1614                 UCHAR Reserved3:6;
1615             } DUMMYSTRUCTNAME;
1616         } DUMMYUNIONNAME;
1617         UCHAR ReadSpeed[2];
1618         UCHAR WriteSpeed[2];
1619         UCHAR Reserved2[5];
1620         UCHAR Control;
1621     } SET_CD_SPEED, *PSET_CD_SPEED;
1622     struct _READ12
1623     {
1624         UCHAR OperationCode;
1625         UCHAR RelativeAddress:1;
1626         UCHAR Reserved1:2;
1627         UCHAR ForceUnitAccess:1;
1628         UCHAR DisablePageOut:1;
1629         UCHAR LogicalUnitNumber:3;
1630         UCHAR LogicalBlock[4];
1631         UCHAR TransferLength[4];
1632         UCHAR Reserved2:7;
1633         UCHAR Streaming:1;
1634         UCHAR Control;
1635     } READ12;
1636     struct _WRITE12
1637     {
1638         UCHAR OperationCode;
1639         UCHAR RelativeAddress:1;
1640         UCHAR Reserved1:1;
1641         UCHAR EBP:1;
1642         UCHAR ForceUnitAccess:1;
1643         UCHAR DisablePageOut:1;
1644         UCHAR LogicalUnitNumber:3;
1645         UCHAR LogicalBlock[4];
1646         UCHAR TransferLength[4];
1647         UCHAR Reserved2:7;
1648         UCHAR Streaming:1;
1649         UCHAR Control;
1650     } WRITE12;
1651     struct _READ16
1652     {
1653         UCHAR OperationCode;
1654         UCHAR Reserved1:3;
1655         UCHAR ForceUnitAccess:1;
1656         UCHAR DisablePageOut:1;
1657         UCHAR ReadProtect:3;
1658         UCHAR LogicalBlock[8];
1659         UCHAR TransferLength[4];
1660         UCHAR Reserved2:7;
1661         UCHAR Streaming:1;
1662         UCHAR Control;
1663     } READ16;
1664     struct _WRITE16
1665     {
1666         UCHAR OperationCode;
1667         UCHAR Reserved1:3;
1668         UCHAR ForceUnitAccess:1;
1669         UCHAR DisablePageOut:1;
1670         UCHAR WriteProtect:3;
1671         UCHAR LogicalBlock[8];
1672         UCHAR TransferLength[4];
1673         UCHAR Reserved2:7;
1674         UCHAR Streaming:1;
1675         UCHAR Control;
1676     } WRITE16;
1677     struct _VERIFY16
1678     {
1679         UCHAR OperationCode;
1680         UCHAR Reserved1:1;
1681         UCHAR ByteCheck:1;
1682         UCHAR BlockVerify:1;
1683         UCHAR Reserved2: 1;
1684         UCHAR DisablePageOut:1;
1685         UCHAR VerifyProtect:3;
1686         UCHAR LogicalBlock[8];
1687         UCHAR VerificationLength[4];
1688         UCHAR Reserved3:7;
1689         UCHAR Streaming:1;
1690         UCHAR Control;
1691     } VERIFY16;
1692     struct _SYNCHRONIZE_CACHE16
1693     {
1694         UCHAR OperationCode;
1695         UCHAR Reserved1:1;
1696         UCHAR Immediate:1;
1697         UCHAR Reserved2:6;
1698         UCHAR LogicalBlock[8];
1699         UCHAR BlockCount[4];
1700         UCHAR Reserved3;
1701         UCHAR Control;
1702     } SYNCHRONIZE_CACHE16;
1703     struct _READ_CAPACITY16
1704     {
1705         UCHAR OperationCode;
1706         UCHAR ServiceAction:5;
1707         UCHAR Reserved1:3;
1708         UCHAR LogicalBlock[8];
1709         UCHAR BlockCount[4];
1710         UCHAR PMI:1;
1711         UCHAR Reserved2:7;
1712         UCHAR Control;
1713     } READ_CAPACITY16;
1714     ULONG AsUlong[4];
1715     UCHAR AsByte[16];
1716 } CDB, *PCDB;
1717 
1718 typedef union _EIGHT_BYTE
1719 {
1720     struct
1721     {
1722         UCHAR Byte0;
1723         UCHAR Byte1;
1724         UCHAR Byte2;
1725         UCHAR Byte3;
1726         UCHAR Byte4;
1727         UCHAR Byte5;
1728         UCHAR Byte6;
1729         UCHAR Byte7;
1730     };
1731     ULONGLONG AsULongLong;
1732 } EIGHT_BYTE, *PEIGHT_BYTE;
1733 
1734 typedef union _FOUR_BYTE
1735 {
1736     struct
1737     {
1738         UCHAR Byte0;
1739         UCHAR Byte1;
1740         UCHAR Byte2;
1741         UCHAR Byte3;
1742     };
1743     ULONG AsULong;
1744 } FOUR_BYTE, *PFOUR_BYTE;
1745 
1746 typedef union _TWO_BYTE
1747 {
1748     struct
1749     {
1750         UCHAR Byte0;
1751         UCHAR Byte1;
1752     };
1753     USHORT AsUShort;
1754 } TWO_BYTE, *PTWO_BYTE;
1755 #include <poppack.h>
1756 
1757 #if (NTDDI_VERSION < NTDDI_WINXP)
1758 typedef struct _INQUIRYDATA
1759 {
1760     UCHAR DeviceType:5;
1761     UCHAR DeviceTypeQualifier:3;
1762     UCHAR DeviceTypeModifier:7;
1763     UCHAR RemovableMedia:1;
1764     UCHAR Versions;
1765     UCHAR ResponseDataFormat:4;
1766     UCHAR HiSupport:1;
1767     UCHAR NormACA:1;
1768     UCHAR ReservedBit:1;
1769     UCHAR AERC:1;
1770     UCHAR AdditionalLength;
1771     UCHAR Reserved[2];
1772     UCHAR SoftReset:1;
1773     UCHAR CommandQueue:1;
1774     UCHAR Reserved2:1;
1775     UCHAR LinkedCommands:1;
1776     UCHAR Synchronous:1;
1777     UCHAR Wide16Bit:1;
1778     UCHAR Wide32Bit:1;
1779     UCHAR RelativeAddressing:1;
1780     UCHAR VendorId[8];
1781     UCHAR ProductId[16];
1782     UCHAR ProductRevisionLevel[4];
1783     UCHAR VendorSpecific[20];
1784     UCHAR Reserved3[40];
1785 } INQUIRYDATA, *PINQUIRYDATA;
1786 #else
1787 #include <pshpack1.h>
1788 typedef struct _INQUIRYDATA
1789 {
1790     UCHAR DeviceType:5;
1791     UCHAR DeviceTypeQualifier:3;
1792     UCHAR DeviceTypeModifier:7;
1793     UCHAR RemovableMedia:1;
1794     union
1795     {
1796         UCHAR Versions;
1797         struct
1798         {
1799             UCHAR ANSIVersion:3;
1800             UCHAR ECMAVersion:3;
1801             UCHAR ISOVersion:2;
1802         };
1803     };
1804     UCHAR ResponseDataFormat:4;
1805     UCHAR HiSupport:1;
1806     UCHAR NormACA:1;
1807     UCHAR TerminateTask:1;
1808     UCHAR AERC:1;
1809     UCHAR AdditionalLength;
1810     UCHAR Reserved;
1811     UCHAR Addr16:1;
1812     UCHAR Addr32:1;
1813     UCHAR AckReqQ:1;
1814     UCHAR MediumChanger:1;
1815     UCHAR MultiPort:1;
1816     UCHAR ReservedBit2:1;
1817     UCHAR EnclosureServices:1;
1818     UCHAR ReservedBit3:1;
1819     UCHAR SoftReset:1;
1820     UCHAR CommandQueue:1;
1821     UCHAR TransferDisable:1;
1822     UCHAR LinkedCommands:1;
1823     UCHAR Synchronous:1;
1824     UCHAR Wide16Bit:1;
1825     UCHAR Wide32Bit:1;
1826     UCHAR RelativeAddressing:1;
1827     UCHAR VendorId[8];
1828     UCHAR ProductId[16];
1829     UCHAR ProductRevisionLevel[4];
1830     UCHAR VendorSpecific[20];
1831     UCHAR Reserved3[40];
1832 } INQUIRYDATA, *PINQUIRYDATA;
1833 #include <poppack.h>
1834 #endif
1835 
1836 typedef struct _VPD_MEDIA_SERIAL_NUMBER_PAGE
1837 {
1838     UCHAR DeviceType:5;
1839     UCHAR DeviceTypeQualifier:3;
1840     UCHAR PageCode;
1841     UCHAR Reserved;
1842     UCHAR PageLength;
1843     UCHAR SerialNumber[0];
1844 } VPD_MEDIA_SERIAL_NUMBER_PAGE, *PVPD_MEDIA_SERIAL_NUMBER_PAGE;
1845 
1846 typedef struct _VPD_SERIAL_NUMBER_PAGE
1847 {
1848     UCHAR DeviceType:5;
1849     UCHAR DeviceTypeQualifier:3;
1850     UCHAR PageCode;
1851     UCHAR Reserved;
1852     UCHAR PageLength;
1853     UCHAR SerialNumber[0];
1854 } VPD_SERIAL_NUMBER_PAGE, *PVPD_SERIAL_NUMBER_PAGE;
1855 
1856 typedef struct _VPD_IDENTIFICATION_DESCRIPTOR
1857 {
1858     UCHAR CodeSet:4;
1859     UCHAR Reserved:4;
1860     UCHAR IdentifierType:4;
1861     UCHAR Association:2;
1862     UCHAR Reserved2:2;
1863     UCHAR Reserved3;
1864     UCHAR IdentifierLength;
1865     UCHAR Identifier[0];
1866 } VPD_IDENTIFICATION_DESCRIPTOR, *PVPD_IDENTIFICATION_DESCRIPTOR;
1867 
1868 typedef struct _VPD_IDENTIFICATION_PAGE
1869 {
1870     UCHAR DeviceType:5;
1871     UCHAR DeviceTypeQualifier:3;
1872     UCHAR PageCode;
1873     UCHAR Reserved;
1874     UCHAR PageLength;
1875     UCHAR Descriptors[0];
1876 } VPD_IDENTIFICATION_PAGE, *PVPD_IDENTIFICATION_PAGE;
1877 
1878 typedef struct _VPD_SUPPORTED_PAGES_PAGE
1879 {
1880     UCHAR DeviceType:5;
1881     UCHAR DeviceTypeQualifier:3;
1882     UCHAR PageCode;
1883     UCHAR Reserved;
1884     UCHAR PageLength;
1885     UCHAR SupportedPageList[0];
1886 } VPD_SUPPORTED_PAGES_PAGE, *PVPD_SUPPORTED_PAGES_PAGE;
1887 
1888 #include <pshpack1.h>
1889 typedef struct _READ_CAPACITY_DATA
1890 {
1891     ULONG LogicalBlockAddress;
1892     ULONG BytesPerBlock;
1893 } READ_CAPACITY_DATA, *PREAD_CAPACITY_DATA;
1894 
1895 typedef struct _READ_CAPACITY_DATA_EX
1896 {
1897     LARGE_INTEGER LogicalBlockAddress;
1898     ULONG BytesPerBlock;
1899 } READ_CAPACITY_DATA_EX, *PREAD_CAPACITY_DATA_EX;
1900 
1901 typedef struct _MODE_PARAMETER_HEADER
1902 {
1903     UCHAR ModeDataLength;
1904     UCHAR MediumType;
1905     UCHAR DeviceSpecificParameter;
1906     UCHAR BlockDescriptorLength;
1907 }MODE_PARAMETER_HEADER, *PMODE_PARAMETER_HEADER;
1908 
1909 typedef struct _MODE_PARAMETER_HEADER10
1910 {
1911     UCHAR ModeDataLength[2];
1912     UCHAR MediumType;
1913     UCHAR DeviceSpecificParameter;
1914     UCHAR Reserved[2];
1915     UCHAR BlockDescriptorLength[2];
1916 }MODE_PARAMETER_HEADER10, *PMODE_PARAMETER_HEADER10;
1917 
1918 typedef struct _MODE_PARAMETER_BLOCK
1919 {
1920     UCHAR DensityCode;
1921     UCHAR NumberOfBlocks[3];
1922     UCHAR Reserved;
1923     UCHAR BlockLength[3];
1924 }MODE_PARAMETER_BLOCK, *PMODE_PARAMETER_BLOCK;
1925 
1926 typedef struct _LUN_LIST
1927 {
1928     UCHAR LunListLength[4];
1929     UCHAR Reserved[4];
1930 #if !defined(__midl)
1931     UCHAR Lun[0][8];
1932 #endif
1933 } LUN_LIST, *PLUN_LIST;
1934 #include <poppack.h>
1935 
1936 typedef PHYSICAL_ADDRESS STOR_PHYSICAL_ADDRESS;
1937 
1938 typedef struct _ACCESS_RANGE
1939 {
1940     STOR_PHYSICAL_ADDRESS RangeStart;
1941     ULONG RangeLength;
1942     BOOLEAN RangeInMemory;
1943 } ACCESS_RANGE, *PACCESS_RANGE;
1944 
1945 typedef struct _MEMORY_REGION
1946 {
1947     PUCHAR VirtualBase;
1948     PHYSICAL_ADDRESS PhysicalBase;
1949     ULONG Length;
1950 } MEMORY_REGION, *PMEMORY_REGION;
1951 
1952 typedef struct _PORT_CONFIGURATION_INFORMATION
1953 {
1954     ULONG Length;
1955     ULONG SystemIoBusNumber;
1956     INTERFACE_TYPE  AdapterInterfaceType;
1957     ULONG BusInterruptLevel;
1958     ULONG BusInterruptVector;
1959     KINTERRUPT_MODE InterruptMode;
1960     ULONG MaximumTransferLength;
1961     ULONG NumberOfPhysicalBreaks;
1962     ULONG DmaChannel;
1963     ULONG DmaPort;
1964     DMA_WIDTH DmaWidth;
1965     DMA_SPEED DmaSpeed;
1966     ULONG AlignmentMask;
1967     ULONG NumberOfAccessRanges;
1968     ACCESS_RANGE (*AccessRanges)[];
1969     PVOID Reserved;
1970     UCHAR NumberOfBuses;
1971     CCHAR InitiatorBusId[8];
1972     BOOLEAN ScatterGather;
1973     BOOLEAN Master;
1974     BOOLEAN CachesData;
1975     BOOLEAN AdapterScansDown;
1976     BOOLEAN AtdiskPrimaryClaimed;
1977     BOOLEAN AtdiskSecondaryClaimed;
1978     BOOLEAN Dma32BitAddresses;
1979     BOOLEAN DemandMode;
1980     UCHAR MapBuffers;
1981     BOOLEAN NeedPhysicalAddresses;
1982     BOOLEAN TaggedQueuing;
1983     BOOLEAN AutoRequestSense;
1984     BOOLEAN MultipleRequestPerLu;
1985     BOOLEAN ReceiveEvent;
1986     BOOLEAN RealModeInitialized;
1987     BOOLEAN BufferAccessScsiPortControlled;
1988     UCHAR MaximumNumberOfTargets;
1989     UCHAR ReservedUchars[2];
1990     ULONG SlotNumber;
1991     ULONG BusInterruptLevel2;
1992     ULONG BusInterruptVector2;
1993     KINTERRUPT_MODE InterruptMode2;
1994     ULONG DmaChannel2;
1995     ULONG DmaPort2;
1996     DMA_WIDTH DmaWidth2;
1997     DMA_SPEED DmaSpeed2;
1998     ULONG DeviceExtensionSize;
1999     ULONG SpecificLuExtensionSize;
2000     ULONG SrbExtensionSize;
2001     UCHAR  Dma64BitAddresses;
2002     BOOLEAN ResetTargetSupported;
2003     UCHAR MaximumNumberOfLogicalUnits;
2004     BOOLEAN WmiDataProvider;
2005     STOR_SYNCHRONIZATION_MODEL SynchronizationModel;
2006 } PORT_CONFIGURATION_INFORMATION, *PPORT_CONFIGURATION_INFORMATION;
2007 
2008 typedef struct _STOR_SCATTER_GATHER_ELEMENT
2009 {
2010     STOR_PHYSICAL_ADDRESS PhysicalAddress;
2011     ULONG Length;
2012     ULONG_PTR Reserved;
2013 } STOR_SCATTER_GATHER_ELEMENT, *PSTOR_SCATTER_GATHER_ELEMENT;
2014 
2015 typedef struct _STOR_SCATTER_GATHER_LIST
2016 {
2017     ULONG NumberOfElements;
2018     ULONG_PTR Reserved;
2019     STOR_SCATTER_GATHER_ELEMENT List[];
2020 } STOR_SCATTER_GATHER_LIST, *PSTOR_SCATTER_GATHER_LIST;
2021 
2022 typedef struct _DPC_BUFFER
2023 {
2024     CSHORT Type;
2025     UCHAR Number;
2026     UCHAR Importance;
2027     struct
2028     {
2029         PVOID F;
2030         PVOID B;
2031     };
2032     PVOID DeferredRoutine;
2033     PVOID DeferredContext;
2034     PVOID SystemArgument1;
2035     PVOID SystemArgument2;
2036     PVOID DpcData;
2037 } DPC_BUFFER;
2038 
2039 typedef struct _STOR_DPC
2040 {
2041     DPC_BUFFER Dpc;
2042     ULONG_PTR Lock;
2043 } STOR_DPC, *PSTOR_DPC;
2044 
2045 typedef struct _STOR_LOCK_HANDLE
2046 {
2047     STOR_SPINLOCK Lock;
2048     struct
2049     {
2050         struct
2051         {
2052             PVOID Next;
2053             PVOID Lock;
2054         } LockQueue;
2055         KIRQL OldIrql;
2056     } Context;
2057 } STOR_LOCK_HANDLE, *PSTOR_LOCK_HANDLE;
2058 
2059 typedef struct _STOR_LOG_EVENT_DETAILS
2060 {
2061     ULONG InterfaceRevision;
2062     ULONG Size;
2063     ULONG Flags;
2064     STOR_EVENT_ASSOCIATION_ENUM EventAssociation;
2065     ULONG PathId;
2066     ULONG TargetId;
2067     ULONG LunId;
2068     BOOLEAN StorportSpecificErrorCode;
2069     ULONG ErrorCode;
2070     ULONG UniqueId;
2071     ULONG DumpDataSize;
2072     PVOID DumpData;
2073     ULONG StringCount;
2074     PWSTR *StringList;
2075 } STOR_LOG_EVENT_DETAILS, *PSTOR_LOG_EVENT_DETAILS;
2076 
2077 typedef struct _PERF_CONFIGURATION_DATA
2078 {
2079     ULONG Version;
2080     ULONG Size;
2081     ULONG Flags;
2082     ULONG ConcurrentChannels;
2083     ULONG FirstRedirectionMessageNumber, LastRedirectionMessageNumber;
2084     ULONG DeviceNode;
2085     ULONG Reserved;
2086     PGROUP_AFFINITY MessageTargets;
2087 } PERF_CONFIGURATION_DATA, *PPERF_CONFIGURATION_DATA;
2088 
2089 typedef struct _STARTIO_PERFORMANCE_PARAMETERS
2090 {
2091     ULONG Version;
2092     ULONG Size;
2093     ULONG MessageNumber;
2094     ULONG ChannelNumber;
2095 } STARTIO_PERFORMANCE_PARAMETERS, *PSTARTIO_PERFORMANCE_PARAMETERS;
2096 
2097 typedef struct _MESSAGE_INTERRUPT_INFORMATION
2098 {
2099     ULONG MessageId;
2100     ULONG MessageData;
2101     STOR_PHYSICAL_ADDRESS MessageAddress;
2102     ULONG InterruptVector;
2103     ULONG InterruptLevel;
2104     KINTERRUPT_MODE InterruptMode;
2105 } MESSAGE_INTERRUPT_INFORMATION, *PMESSAGE_INTERRUPT_INFORMATION;
2106 
2107 typedef
2108 BOOLEAN
2109 (NTAPI *PHW_INITIALIZE)(
2110     _In_ PVOID DeviceExtension);
2111 
2112 typedef
2113 BOOLEAN
2114 (NTAPI *PHW_BUILDIO)(
2115     _In_ PVOID DeviceExtension,
2116     _In_ PSCSI_REQUEST_BLOCK Srb);
2117 
2118 typedef
2119 BOOLEAN
2120 (NTAPI *PHW_STARTIO)(
2121     _In_ PVOID DeviceExtension,
2122     _In_ PSCSI_REQUEST_BLOCK Srb);
2123 
2124 typedef
2125 BOOLEAN
2126 (NTAPI *PHW_INTERRUPT)(
2127     _In_ PVOID DeviceExtension);
2128 
2129 typedef
2130 VOID
2131 (NTAPI *PHW_TIMER)(
2132     _In_ PVOID DeviceExtension);
2133 
2134 typedef
2135 VOID
2136 (NTAPI *PHW_DMA_STARTED)(
2137     _In_ PVOID DeviceExtension);
2138 
2139 typedef
2140 ULONG
2141 (NTAPI *PHW_FIND_ADAPTER)(
2142     IN PVOID DeviceExtension,
2143     IN PVOID HwContext,
2144     IN PVOID BusInformation,
2145     IN PCHAR ArgumentString,
2146     IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo,
2147     OUT PBOOLEAN Again);
2148 
2149 typedef
2150 BOOLEAN
2151 (NTAPI *PHW_RESET_BUS)(
2152     IN PVOID DeviceExtension,
2153     IN ULONG PathId);
2154 
2155 typedef
2156 BOOLEAN
2157 (NTAPI *PHW_ADAPTER_STATE)(
2158     IN PVOID DeviceExtension,
2159     IN PVOID Context,
2160     IN BOOLEAN SaveState);
2161 
2162 typedef
2163 SCSI_ADAPTER_CONTROL_STATUS
2164 (NTAPI *PHW_ADAPTER_CONTROL)(
2165     IN PVOID DeviceExtension,
2166     IN SCSI_ADAPTER_CONTROL_TYPE ControlType,
2167     IN PVOID Parameters);
2168 
2169 typedef
2170 BOOLEAN
2171 (*PHW_PASSIVE_INITIALIZE_ROUTINE)(
2172     _In_ PVOID DeviceExtension);
2173 
2174 typedef
2175 VOID
2176 (*PHW_DPC_ROUTINE)(
2177     _In_ PSTOR_DPC Dpc,
2178     _In_ PVOID HwDeviceExtension,
2179     _In_ PVOID SystemArgument1,
2180     _In_ PVOID SystemArgument2);
2181 
2182 typedef
2183 BOOLEAN
2184 (NTAPI STOR_SYNCHRONIZED_ACCESS)(
2185     _In_ PVOID HwDeviceExtension,
2186     _In_ PVOID Context);
2187 
2188 typedef STOR_SYNCHRONIZED_ACCESS *PSTOR_SYNCHRONIZED_ACCESS;
2189 
2190 typedef
2191 VOID
2192 (NTAPI *PpostScaterGatherExecute)(
2193     _In_ PVOID *DeviceObject,
2194     _In_ PVOID *Irp,
2195     _In_ PSTOR_SCATTER_GATHER_LIST ScatterGather,
2196     _In_ PVOID Context);
2197 
2198 typedef
2199 BOOLEAN
2200 (NTAPI *PStorPortGetMessageInterruptInformation)(
2201     _In_ PVOID HwDeviceExtension,
2202     _In_ ULONG MessageId,
2203     _Out_ PMESSAGE_INTERRUPT_INFORMATION InterruptInfo);
2204 
2205 typedef
2206 VOID
2207 (NTAPI *PStorPortPutScatterGatherList)(
2208     _In_ PVOID HwDeviceExtension,
2209     _In_ PSTOR_SCATTER_GATHER_LIST ScatterGatherList,
2210     _In_ BOOLEAN WriteToDevice);
2211 
2212 typedef
2213 GETSGSTATUS
2214 (NTAPI *PStorPortBuildScatterGatherList)(
2215     _In_ PVOID HwDeviceExtension,
2216     _In_ PVOID Mdl,
2217     _In_ PVOID CurrentVa,
2218     _In_ ULONG Length,
2219     _In_ PpostScaterGatherExecute ExecutionRoutine,
2220     _In_ PVOID Context,
2221     _In_ BOOLEAN WriteToDevice,
2222     _Inout_ PVOID ScatterGatherBuffer,
2223     _In_ ULONG ScatterGatherBufferLength);
2224 
2225 typedef
2226 VOID
2227 (NTAPI *PStorPortFreePool)(
2228     _In_ PVOID PMemory,
2229     _In_ PVOID HwDeviceExtension,
2230     _In_opt_ PVOID PMdl);
2231 
2232 typedef
2233 PVOID
2234 (NTAPI *PStorPortAllocatePool)(
2235     _In_ ULONG NumberOfBytes,
2236     _In_ ULONG Tag,
2237     _In_ PVOID HwDeviceExtension,
2238     _Out_ PVOID *PMdl);
2239 
2240 typedef
2241 PVOID
2242 (NTAPI *PStorPortGetSystemAddress)(
2243     _In_ PSCSI_REQUEST_BLOCK Srb);
2244 
2245 typedef struct _STORPORT_EXTENDED_FUNCTIONS
2246 {
2247     ULONG Version;
2248     PStorPortGetMessageInterruptInformation GetMessageInterruptInformation;
2249     PStorPortPutScatterGatherList PutScatterGatherList;
2250     PStorPortBuildScatterGatherList BuildScatterGatherList;
2251     PStorPortFreePool FreePool;
2252     PStorPortAllocatePool AllocatePool;
2253     PStorPortGetSystemAddress GetSystemAddress;
2254 } STORPORT_EXTENDED_FUNCTIONS, *PSTORPORT_EXTENDED_FUNCTIONS;
2255 
2256 typedef struct _HW_INITIALIZATION_DATA
2257 {
2258     ULONG HwInitializationDataSize;
2259     INTERFACE_TYPE  AdapterInterfaceType;
2260     PHW_INITIALIZE HwInitialize;
2261     PHW_STARTIO HwStartIo;
2262     PHW_INTERRUPT HwInterrupt;
2263     PHW_FIND_ADAPTER HwFindAdapter;
2264     PHW_RESET_BUS HwResetBus;
2265     PHW_DMA_STARTED HwDmaStarted;
2266     PHW_ADAPTER_STATE HwAdapterState;
2267     ULONG DeviceExtensionSize;
2268     ULONG SpecificLuExtensionSize;
2269     ULONG SrbExtensionSize;
2270     ULONG NumberOfAccessRanges;
2271     PVOID Reserved;
2272     UCHAR MapBuffers;
2273     BOOLEAN NeedPhysicalAddresses;
2274     BOOLEAN TaggedQueuing;
2275     BOOLEAN AutoRequestSense;
2276     BOOLEAN MultipleRequestPerLu;
2277     BOOLEAN ReceiveEvent;
2278     USHORT VendorIdLength;
2279     PVOID VendorId;
2280     USHORT ReservedUshort;
2281     USHORT DeviceIdLength;
2282     PVOID DeviceId;
2283     PHW_ADAPTER_CONTROL HwAdapterControl;
2284     PHW_BUILDIO HwBuildIo;
2285 } HW_INITIALIZATION_DATA, *PHW_INITIALIZATION_DATA;
2286 
2287 
2288 
2289 #define REVERSE_BYTES_QUAD(Destination, Source) { \
2290     PEIGHT_BYTE d = (PEIGHT_BYTE)(Destination); \
2291     PEIGHT_BYTE s = (PEIGHT_BYTE)(Source); \
2292     d->Byte7 = s->Byte0; \
2293     d->Byte6 = s->Byte1; \
2294     d->Byte5 = s->Byte2; \
2295     d->Byte4 = s->Byte3; \
2296     d->Byte3 = s->Byte4; \
2297     d->Byte2 = s->Byte5; \
2298     d->Byte1 = s->Byte6; \
2299     d->Byte0 = s->Byte7; \
2300 }
2301 
2302 #define REVERSE_BYTES(Destination, Source) { \
2303     PFOUR_BYTE d = (PFOUR_BYTE)(Destination); \
2304     PFOUR_BYTE s = (PFOUR_BYTE)(Source); \
2305     d->Byte3 = s->Byte0; \
2306     d->Byte2 = s->Byte1; \
2307     d->Byte1 = s->Byte2; \
2308     d->Byte0 = s->Byte3; \
2309 }
2310 
2311 #define REVERSE_BYTES_SHORT(Destination, Source) { \
2312     PTWO_BYTE d = (PTWO_BYTE)(Destination); \
2313     PTWO_BYTE s = (PTWO_BYTE)(Source); \
2314     d->Byte1 = s->Byte0; \
2315     d->Byte0 = s->Byte1; \
2316 }
2317 
2318 #define StorPortCopyMemory(Destination,Source,Length) memcpy((Destination),(Source),(Length))
2319 
2320 STORPORT_API
2321 PUCHAR
2322 NTAPI
2323 StorPortAllocateRegistryBuffer(
2324     _In_ PVOID HwDeviceExtension,
2325     _In_ PULONG Length);
2326 
2327 STORPORT_API
2328 BOOLEAN
2329 NTAPI
2330 StorPortBusy(
2331   _In_ PVOID HwDeviceExtension,
2332   _In_ ULONG RequestsToComplete);
2333 
2334 STORPORT_API
2335 VOID
2336 NTAPI
2337 StorPortCompleteRequest(
2338     _In_ PVOID HwDeviceExtension,
2339     _In_ UCHAR PathId,
2340     _In_ UCHAR TargetId,
2341     _In_ UCHAR Lun,
2342     _In_ UCHAR SrbStatus);
2343 
2344 STORPORT_API
2345 ULONG64
2346 NTAPI
2347 StorPortConvertPhysicalAddressToUlong64(
2348     _In_ STOR_PHYSICAL_ADDRESS Address);
2349 
2350 STORPORT_API
2351 STOR_PHYSICAL_ADDRESS
2352 NTAPI
2353 StorPortConvertUlong64ToPhysicalAddress(
2354     _In_ ULONG64 UlongAddress);
2355 
2356 STORPORT_API
2357 VOID
2358 __cdecl
2359 StorPortDebugPrint(
2360     _In_ ULONG DebugPrintLevel,
2361     _In_ PCCHAR DebugMessage,
2362     ...);
2363 
2364 STORPORT_API
2365 BOOLEAN
2366 NTAPI
2367 StorPortDeviceBusy(
2368     _In_ PVOID HwDeviceExtension,
2369     _In_ UCHAR PathId,
2370     _In_ UCHAR TargetId,
2371     _In_ UCHAR Lun,
2372     _In_ ULONG RequestsToComplete);
2373 
2374 STORPORT_API
2375 BOOLEAN
2376 NTAPI
2377 StorPortDeviceReady(
2378     _In_ PVOID HwDeviceExtension,
2379     _In_ UCHAR PathId,
2380     _In_ UCHAR TargetId,
2381     _In_ UCHAR Lun);
2382 
2383 STORPORT_API
2384 VOID
2385 NTAPI
2386 StorPortFreeDeviceBase(
2387     _In_ PVOID HwDeviceExtension,
2388     _In_ PVOID MappedAddress);
2389 
2390 STORPORT_API
2391 VOID
2392 NTAPI
2393 StorPortFreeRegistryBuffer(
2394     _In_ PVOID HwDeviceExtension,
2395     _In_ PUCHAR Buffer);
2396 
2397 STORPORT_API
2398 ULONG
2399 NTAPI
2400 StorPortGetBusData(
2401     _In_ PVOID DeviceExtension,
2402     _In_ ULONG BusDataType,
2403     _In_ ULONG SystemIoBusNumber,
2404     _In_ ULONG SlotNumber,
2405     _Out_ _When_(Length != 0, _Out_writes_bytes_(Length)) PVOID Buffer,
2406     _In_ ULONG Length);
2407 
2408 STORPORT_API
2409 PVOID
2410 NTAPI
2411 StorPortGetDeviceBase(
2412     _In_ PVOID HwDeviceExtension,
2413     _In_ INTERFACE_TYPE BusType,
2414     _In_ ULONG SystemIoBusNumber,
2415     _In_ STOR_PHYSICAL_ADDRESS IoAddress,
2416     _In_ ULONG NumberOfBytes,
2417     _In_ BOOLEAN InIoSpace);
2418 
2419 STORPORT_API
2420 PVOID
2421 NTAPI
2422 StorPortGetLogicalUnit(
2423     _In_ PVOID HwDeviceExtension,
2424     _In_ UCHAR PathId,
2425     _In_ UCHAR TargetId,
2426     _In_ UCHAR Lun);
2427 
2428 STORPORT_API
2429 STOR_PHYSICAL_ADDRESS
2430 NTAPI
2431 StorPortGetPhysicalAddress(
2432     _In_ PVOID HwDeviceExtension,
2433     _In_opt_ PSCSI_REQUEST_BLOCK Srb,
2434     _In_ PVOID VirtualAddress,
2435     _Out_ ULONG *Length);
2436 
2437 STORPORT_API
2438 PSTOR_SCATTER_GATHER_LIST
2439 NTAPI
2440 StorPortGetScatterGatherList(
2441     _In_ PVOID DeviceExtension,
2442     _In_ PSCSI_REQUEST_BLOCK Srb);
2443 
2444 STORPORT_API
2445 PSCSI_REQUEST_BLOCK
2446 NTAPI
2447 StorPortGetSrb(
2448     _In_ PVOID DeviceExtension,
2449     _In_ UCHAR PathId,
2450     _In_ UCHAR TargetId,
2451     _In_ UCHAR Lun,
2452     _In_ LONG QueueTag);
2453 
2454 STORPORT_API
2455 PVOID
2456 NTAPI
2457 StorPortGetUncachedExtension(
2458     _In_ PVOID HwDeviceExtension,
2459     _In_ PPORT_CONFIGURATION_INFORMATION ConfigInfo,
2460     _In_ ULONG NumberOfBytes);
2461 
2462 STORPORT_API
2463 PVOID
2464 NTAPI
2465 StorPortGetVirtualAddress(
2466     _In_ PVOID HwDeviceExtension,
2467     _In_ STOR_PHYSICAL_ADDRESS PhysicalAddress);
2468 
2469 STORPORT_API
2470 ULONG
2471 NTAPI
2472 StorPortInitialize(
2473     _In_ PVOID Argument1,
2474     _In_ PVOID Argument2,
2475     _In_ PHW_INITIALIZATION_DATA HwInitializationData,
2476     _In_opt_ PVOID Unused);
2477 
2478 STORPORT_API
2479 VOID
2480 NTAPI
2481 StorPortLogError(
2482     _In_ PVOID HwDeviceExtension,
2483     _In_opt_ PSCSI_REQUEST_BLOCK Srb,
2484     _In_ UCHAR PathId,
2485     _In_ UCHAR TargetId,
2486     _In_ UCHAR Lun,
2487     _In_ ULONG ErrorCode,
2488     _In_ ULONG UniqueId);
2489 
2490 STORPORT_API
2491 VOID
2492 NTAPI
2493 StorPortMoveMemory(
2494     _Out_writes_bytes_(Length) PVOID WriteBuffer,
2495     _In_reads_bytes_(Length) PVOID ReadBuffer,
2496     _In_ ULONG Length);
2497 
2498 STORPORT_API
2499 VOID
2500 __cdecl
2501 StorPortNotification(
2502     _In_ SCSI_NOTIFICATION_TYPE NotificationType,
2503     _In_ PVOID HwDeviceExtension,
2504     ...);
2505 
2506 STORPORT_API
2507 VOID
2508 NTAPI
2509 StorPortQuerySystemTime(
2510     _Out_ PLARGE_INTEGER CurrentTime);
2511 
2512 STORPORT_API
2513 BOOLEAN
2514 NTAPI
2515 StorPortPause(
2516     _In_ PVOID HwDeviceExtension,
2517     _In_ ULONG TimeOut);
2518 
2519 STORPORT_API
2520 BOOLEAN
2521 NTAPI
2522 StorPortPauseDevice(
2523     _In_ PVOID HwDeviceExtension,
2524     _In_ UCHAR PathId,
2525     _In_ UCHAR TargetId,
2526     _In_ UCHAR Lun,
2527     _In_ ULONG TimeOut);
2528 
2529 STORPORT_API
2530 VOID
2531 NTAPI
2532 StorPortReadPortBufferUchar(
2533     _In_ PVOID HwDeviceExtension,
2534     _In_ PUCHAR Port,
2535     _In_ PUCHAR Buffer,
2536     _In_ ULONG Count);
2537 
2538 STORPORT_API
2539 VOID
2540 NTAPI
2541 StorPortReadPortBufferUlong(
2542     _In_ PVOID HwDeviceExtension,
2543     _In_ PULONG Port,
2544     _In_ PULONG Buffer,
2545     _In_ ULONG Count);
2546 
2547 STORPORT_API
2548 VOID
2549 NTAPI
2550 StorPortReadPortBufferUshort(
2551     _In_ PVOID HwDeviceExtension,
2552     _In_ PUSHORT Port,
2553     _In_ PUSHORT Buffer,
2554     _In_ ULONG Count);
2555 
2556 STORPORT_API
2557 UCHAR
2558 NTAPI
2559 StorPortReadPortUchar(
2560     _In_ PVOID HwDeviceExtension,
2561     _In_ PUCHAR Port);
2562 
2563 STORPORT_API
2564 ULONG
2565 NTAPI
2566 StorPortReadPortUlong(
2567     _In_ PVOID HwDeviceExtension,
2568     _In_ PULONG Port);
2569 
2570 STORPORT_API
2571 USHORT
2572 NTAPI
2573 StorPortReadPortUshort(
2574     _In_ PVOID HwDeviceExtension,
2575     _In_ PUSHORT Port);
2576 
2577 STORPORT_API
2578 VOID
2579 NTAPI
2580 StorPortReadRegisterBufferUchar(
2581     _In_ PVOID HwDeviceExtension,
2582     _In_ PUCHAR Register,
2583     _In_ PUCHAR Buffer,
2584     _In_ ULONG Count);
2585 
2586 STORPORT_API
2587 VOID
2588 NTAPI
2589 StorPortReadRegisterBufferUlong(
2590     _In_ PVOID HwDeviceExtension,
2591     _In_ PULONG Register,
2592     _In_ PULONG Buffer,
2593     _In_ ULONG Count);
2594 
2595 STORPORT_API
2596 VOID
2597 NTAPI
2598 StorPortReadRegisterBufferUshort(
2599     _In_ PVOID HwDeviceExtension,
2600     _In_ PUSHORT Register,
2601     _In_ PUSHORT Buffer,
2602     _In_ ULONG Count);
2603 
2604 STORPORT_API
2605 UCHAR
2606 NTAPI
2607 StorPortReadRegisterUchar(
2608     _In_ PVOID HwDeviceExtension,
2609     _In_ PUCHAR Register);
2610 
2611 STORPORT_API
2612 ULONG
2613 NTAPI
2614 StorPortReadRegisterUlong(
2615     _In_ PVOID HwDeviceExtension,
2616     _In_ PULONG Register);
2617 
2618 STORPORT_API
2619 USHORT
2620 NTAPI
2621 StorPortReadRegisterUshort(
2622     _In_ PVOID HwDeviceExtension,
2623     _In_ PUSHORT Register);
2624 
2625 STORPORT_API
2626 BOOLEAN
2627 NTAPI
2628 StorPortReady(
2629   _In_ PVOID HwDeviceExtension);
2630 
2631 STORPORT_API
2632 BOOLEAN
2633 NTAPI
2634 StorPortRegistryRead(
2635     _In_ PVOID HwDeviceExtension,
2636     _In_ PUCHAR ValueName,
2637     _In_ ULONG Global,
2638     _In_ ULONG Type,
2639     _In_ PUCHAR Buffer,
2640     _In_ PULONG BufferLength);
2641 
2642 STORPORT_API
2643 BOOLEAN
2644 NTAPI
2645 StorPortRegistryWrite(
2646     _In_ PVOID HwDeviceExtension,
2647     _In_ PUCHAR ValueName,
2648     _In_ ULONG Global,
2649     _In_ ULONG Type,
2650     _In_ PUCHAR Buffer,
2651     _In_ ULONG BufferLength);
2652 
2653 STORPORT_API
2654 BOOLEAN
2655 NTAPI
2656 StorPortResume(
2657   _In_ PVOID HwDeviceExtension);
2658 
2659 STORPORT_API
2660 BOOLEAN
2661 NTAPI
2662 StorPortResumeDevice(
2663   _In_ PVOID HwDeviceExtension,
2664   _In_ UCHAR PathId,
2665   _In_ UCHAR TargetId,
2666   _In_ UCHAR Lun);
2667 
2668 STORPORT_API
2669 ULONG
2670 NTAPI
2671 StorPortSetBusDataByOffset(
2672     _In_ PVOID DeviceExtension,
2673     _In_ ULONG BusDataType,
2674     _In_ ULONG SystemIoBusNumber,
2675     _In_ ULONG SlotNumber,
2676     _In_reads_bytes_(Length) PVOID Buffer,
2677     _In_ ULONG Offset,
2678     _In_ ULONG Length);
2679 
2680 STORPORT_API
2681 BOOLEAN
2682 NTAPI
2683 StorPortSetDeviceQueueDepth(
2684   _In_ PVOID HwDeviceExtension,
2685   _In_ UCHAR PathId,
2686   _In_ UCHAR TargetId,
2687   _In_ UCHAR Lun,
2688   _In_ ULONG Depth);
2689 
2690 STORPORT_API
2691 VOID
2692 NTAPI
2693 StorPortStallExecution(
2694     _In_ ULONG Delay);
2695 
2696 STORPORT_API
2697 VOID
2698 NTAPI
2699 StorPortSynchronizeAccess(
2700     _In_ PVOID HwDeviceExtension,
2701     _In_ PSTOR_SYNCHRONIZED_ACCESS SynchronizedAccessRoutine,
2702     _In_opt_ PVOID Context);
2703 
2704 STORPORT_API
2705 BOOLEAN
2706 NTAPI
2707 StorPortValidateRange(
2708     _In_ PVOID HwDeviceExtension,
2709     _In_ INTERFACE_TYPE BusType,
2710     _In_ ULONG SystemIoBusNumber,
2711     _In_ STOR_PHYSICAL_ADDRESS IoAddress,
2712     _In_ ULONG NumberOfBytes,
2713     _In_ BOOLEAN InIoSpace);
2714 
2715 STORPORT_API
2716 VOID
2717 NTAPI
2718 StorPortWritePortBufferUchar(
2719     _In_ PVOID HwDeviceExtension,
2720     _In_ PUCHAR Port,
2721     _In_ PUCHAR Buffer,
2722     _In_ ULONG Count);
2723 
2724 STORPORT_API
2725 VOID
2726 NTAPI
2727 StorPortWritePortBufferUlong(
2728     _In_ PVOID HwDeviceExtension,
2729     _In_ PULONG Port,
2730     _In_ PULONG Buffer,
2731     _In_ ULONG Count);
2732 
2733 STORPORT_API
2734 VOID
2735 NTAPI
2736 StorPortWritePortBufferUshort(
2737     _In_ PVOID HwDeviceExtension,
2738     _In_ PUSHORT Port,
2739     _In_ PUSHORT Buffer,
2740     _In_ ULONG Count);
2741 
2742 STORPORT_API
2743 VOID
2744 NTAPI
2745 StorPortWritePortUchar(
2746     _In_ PVOID HwDeviceExtension,
2747     _In_ PUCHAR Port,
2748     _In_ UCHAR Value);
2749 
2750 STORPORT_API
2751 VOID
2752 NTAPI
2753 StorPortWritePortUlong(
2754     _In_ PVOID HwDeviceExtension,
2755     _In_ PULONG Port,
2756     _In_ ULONG Value);
2757 
2758 STORPORT_API
2759 VOID
2760 NTAPI
2761 StorPortWritePortUshort(
2762     _In_ PVOID HwDeviceExtension,
2763     _In_ PUSHORT Port,
2764     _In_ USHORT Value);
2765 
2766 STORPORT_API
2767 VOID
2768 NTAPI
2769 StorPortWriteRegisterBufferUchar(
2770     _In_ PVOID HwDeviceExtension,
2771     _In_ PUCHAR Register,
2772     _In_ PUCHAR Buffer,
2773     _In_ ULONG Count);
2774 
2775 STORPORT_API
2776 VOID
2777 NTAPI
2778 StorPortWriteRegisterBufferUlong(
2779     _In_ PVOID HwDeviceExtension,
2780     _In_ PULONG Register,
2781     _In_ PULONG Buffer,
2782     _In_ ULONG Count);
2783 
2784 STORPORT_API
2785 VOID
2786 NTAPI
2787 StorPortWriteRegisterBufferUshort(
2788     _In_ PVOID HwDeviceExtension,
2789     _In_ PUSHORT Register,
2790     _In_ PUSHORT Buffer,
2791     _In_ ULONG Count);
2792 
2793 STORPORT_API
2794 VOID
2795 NTAPI
2796 StorPortWriteRegisterUchar(
2797     _In_ PVOID HwDeviceExtension,
2798     _In_ PUCHAR Register,
2799     _In_ UCHAR Value);
2800 
2801 STORPORT_API
2802 VOID
2803 NTAPI
2804 StorPortWriteRegisterUlong(
2805     _In_ PVOID HwDeviceExtension,
2806     _In_ PULONG Register,
2807     _In_ ULONG Value);
2808 
2809 STORPORT_API
2810 VOID
2811 NTAPI
2812 StorPortWriteRegisterUshort(
2813     _In_ PVOID HwDeviceExtension,
2814     _In_ PUSHORT Register,
2815     _In_ USHORT Value);
2816 
2817 
2818 FORCEINLINE
2819 BOOLEAN
2820 StorPortEnablePassiveInitialization(
2821     _In_ PVOID DeviceExtension,
2822     _In_ PHW_PASSIVE_INITIALIZE_ROUTINE HwPassiveInitializeRoutine)
2823 {
2824     LONG Succ;
2825     Succ = FALSE;
2826     StorPortNotification(EnablePassiveInitialization,
2827                          DeviceExtension,
2828                          HwPassiveInitializeRoutine,
2829                          &Succ);
2830     return (BOOLEAN)Succ;
2831 }
2832 
2833 FORCEINLINE
2834 VOID
2835 StorPortInitializeDpc(
2836     _In_ PVOID DeviceExtension,
2837     _Out_ PSTOR_DPC Dpc,
2838     _In_ PHW_DPC_ROUTINE HwDpcRoutine)
2839 {
2840     StorPortNotification(InitializeDpc,
2841                          DeviceExtension,
2842                          Dpc,
2843                          HwDpcRoutine);
2844 }
2845 
2846 FORCEINLINE
2847 BOOLEAN
2848 StorPortIssueDpc(
2849     _In_ PVOID DeviceExtension,
2850     _In_ PSTOR_DPC Dpc,
2851     _In_ PVOID SystemArgument1,
2852     _In_ PVOID SystemArgument2)
2853 {
2854     LONG Succ;
2855     Succ = FALSE;
2856     StorPortNotification(IssueDpc,
2857                          DeviceExtension,
2858                          Dpc,
2859                          SystemArgument1,
2860                          SystemArgument2,
2861                          &Succ);
2862     return (BOOLEAN)Succ;
2863 }
2864 
2865 FORCEINLINE
2866 VOID
2867 StorPortAcquireSpinLock(
2868     _In_ PVOID DeviceExtension,
2869     _In_ STOR_SPINLOCK SpinLock,
2870     _In_ PVOID LockContext,
2871     _Inout_ PSTOR_LOCK_HANDLE LockHandle)
2872 {
2873     StorPortNotification(AcquireSpinLock,
2874                          DeviceExtension,
2875                          SpinLock,
2876                          LockContext,
2877                          LockHandle);
2878 }
2879 
2880 FORCEINLINE
2881 VOID
2882 StorPortReleaseSpinLock(
2883     _In_ PVOID DeviceExtension,
2884     _Inout_ PSTOR_LOCK_HANDLE LockHandle)
2885 {
2886     StorPortNotification(ReleaseSpinLock,
2887                          DeviceExtension,
2888                          LockHandle);
2889 }
2890 
2891 STORPORT_API
2892 ULONG
2893 StorPortExtendedFunction(
2894     _In_ STORPORT_FUNCTION_CODE FunctionCode,
2895     _In_ PVOID HwDeviceExtension,
2896     ...);
2897 
2898 FORCEINLINE
2899 ULONG
2900 StorPortAllocatePool(
2901     _In_ PVOID HwDeviceExtension,
2902     _In_ ULONG NumberOfBytes,
2903     _In_ ULONG Tag,
2904     _Out_ PVOID *BufferPointer
2905     )
2906 {
2907     return StorPortExtendedFunction(ExtFunctionAllocatePool,
2908                                     HwDeviceExtension,
2909                                     NumberOfBytes,
2910                                     Tag,
2911                                     BufferPointer);
2912 }
2913 
2914 FORCEINLINE
2915 ULONG
2916 StorPortFreePool(
2917     _In_ PVOID HwDeviceExtension,
2918     _In_ PVOID BufferPointer)
2919 {
2920     return StorPortExtendedFunction(ExtFunctionFreePool,
2921                                     HwDeviceExtension,
2922                                     BufferPointer);
2923 }
2924 
2925 FORCEINLINE
2926 ULONG
2927 StorPortAllocateMdl(
2928     _In_ PVOID HwDeviceExtension,
2929     _In_ PVOID BufferPointer,
2930     _In_ ULONG NumberOfBytes,
2931     _Out_ PVOID *Mdl)
2932 {
2933     return StorPortExtendedFunction(ExtFunctionAllocateMdl,
2934                                     HwDeviceExtension,
2935                                     BufferPointer,
2936                                     NumberOfBytes,
2937                                     Mdl);
2938 }
2939 
2940 FORCEINLINE
2941 ULONG
2942 StorPortFreeMdl(
2943     _In_ PVOID HwDeviceExtension,
2944     _In_ PVOID Mdl)
2945 {
2946     return StorPortExtendedFunction(ExtFunctionFreeMdl,
2947                                     HwDeviceExtension,
2948                                     Mdl);
2949 }
2950 
2951 FORCEINLINE
2952 ULONG
2953 StorPortBuildMdlForNonPagedPool(
2954     _In_ PVOID HwDeviceExtension,
2955     _Inout_ PVOID Mdl)
2956 {
2957     return StorPortExtendedFunction(ExtFunctionBuildMdlForNonPagedPool,
2958                                     HwDeviceExtension,
2959                                     Mdl);
2960 }
2961 
2962 FORCEINLINE
2963 ULONG
2964 StorPortGetSystemAddress(
2965     _In_ PVOID HwDeviceExtension,
2966     _In_ PSCSI_REQUEST_BLOCK Srb,
2967     _Out_ PVOID *SystemAddress)
2968 {
2969     return StorPortExtendedFunction(ExtFunctionGetSystemAddress,
2970                                     HwDeviceExtension,
2971                                     Srb,
2972                                     SystemAddress);
2973 }
2974 
2975 FORCEINLINE
2976 ULONG
2977 StorPortGetOriginalMdl(
2978     _In_ PVOID HwDeviceExtension,
2979     _In_ PSCSI_REQUEST_BLOCK Srb,
2980     _Out_ PVOID *Mdl)
2981 {
2982     return StorPortExtendedFunction(ExtFunctionGetOriginalMdl,
2983                                     HwDeviceExtension,
2984                                     Srb,
2985                                     Mdl);
2986 }
2987 
2988 FORCEINLINE
2989 ULONG
2990 StorPortCompleteServiceIrp(
2991     _In_ PVOID HwDeviceExtension,
2992     _In_ PVOID Irp)
2993 {
2994     return StorPortExtendedFunction(ExtFunctionCompleteServiceIrp,
2995                                     HwDeviceExtension,
2996                                     Irp);
2997 }
2998 
2999 FORCEINLINE
3000 ULONG
3001 StorPortGetDeviceObjects(
3002     _In_ PVOID HwDeviceExtension,
3003     _Out_ PVOID *AdapterDeviceObject,
3004     _Out_ PVOID *PhysicalDeviceObject,
3005     _Out_ PVOID *LowerDeviceObject)
3006 {
3007     return StorPortExtendedFunction(ExtFunctionGetDeviceObjects,
3008                                     HwDeviceExtension,
3009                                     AdapterDeviceObject,
3010                                     PhysicalDeviceObject,
3011                                     LowerDeviceObject);
3012 }
3013 
3014 FORCEINLINE
3015 ULONG
3016 StorPortBuildScatterGatherList(
3017     _In_ PVOID HwDeviceExtension,
3018     _In_ PVOID Mdl,
3019     _In_ PVOID CurrentVa,
3020     _In_ ULONG Length,
3021     _In_ PpostScaterGatherExecute ExecutionRoutine,
3022     _In_ PVOID Context,
3023     _In_ BOOLEAN WriteToDevice,
3024     _Inout_ PVOID ScatterGatherBuffer,
3025     _In_ ULONG ScatterGatherBufferLength)
3026 {
3027     return StorPortExtendedFunction(ExtFunctionBuildScatterGatherList,
3028                                     HwDeviceExtension,
3029                                     Mdl,
3030                                     CurrentVa,
3031                                     Length,
3032                                     ExecutionRoutine,
3033                                     Context,
3034                                     WriteToDevice,
3035                                     ScatterGatherBuffer,
3036                                     ScatterGatherBufferLength);
3037 }
3038 
3039 FORCEINLINE
3040 ULONG
3041 StorPortPutScatterGatherList(
3042     _In_ PVOID HwDeviceExtension,
3043     _In_ PSTOR_SCATTER_GATHER_LIST ScatterGatherList,
3044     _In_ BOOLEAN WriteToDevice)
3045 {
3046     return StorPortExtendedFunction(ExtFunctionPutScatterGatherList,
3047                                     HwDeviceExtension,
3048                                     ScatterGatherList,
3049                                     WriteToDevice);
3050 }
3051 
3052 FORCEINLINE
3053 ULONG
3054 StorPortAcquireMSISpinLock(
3055     _In_ PVOID HwDeviceExtension,
3056     _In_ ULONG MessageId,
3057     _In_ PULONG OldIrql)
3058 {
3059     return StorPortExtendedFunction(ExtFunctionAcquireMSISpinLock,
3060                                     HwDeviceExtension,
3061                                     MessageId,
3062                                     OldIrql);
3063 }
3064 
3065 FORCEINLINE
3066 ULONG
3067 StorPortReleaseMSISpinLock(
3068     _In_ PVOID HwDeviceExtension,
3069     _In_ ULONG MessageId,
3070     _In_ ULONG OldIrql)
3071 {
3072     return StorPortExtendedFunction(ExtFunctionReleaseMSISpinLock,
3073                                     HwDeviceExtension,
3074                                     MessageId,
3075                                     OldIrql);
3076 }
3077 
3078 FORCEINLINE
3079 ULONG
3080 StorPortGetMSIInfo(
3081     _In_ PVOID HwDeviceExtension,
3082     _In_ ULONG MessageId,
3083     _Out_ PMESSAGE_INTERRUPT_INFORMATION InterruptInfo)
3084 {
3085     return StorPortExtendedFunction(ExtFunctionGetMessageInterruptInformation,
3086                                     HwDeviceExtension,
3087                                     MessageId,
3088                                     InterruptInfo);
3089 }
3090 
3091 FORCEINLINE
3092 ULONG
3093 StorPortInitializePerfOpts(
3094     _In_ PVOID HwDeviceExtension,
3095     _In_ BOOLEAN Query,
3096     _Inout_ PPERF_CONFIGURATION_DATA PerfConfigData)
3097 {
3098     return StorPortExtendedFunction(ExtFunctionInitializePerformanceOptimizations,
3099                                     HwDeviceExtension,
3100                                     Query,
3101                                     PerfConfigData);
3102 }
3103 
3104 FORCEINLINE
3105 ULONG
3106 StorPortGetStartIoPerfParams(
3107     _In_ PVOID HwDeviceExtension,
3108     _In_ PSCSI_REQUEST_BLOCK Srb,
3109     _Inout_ PSTARTIO_PERFORMANCE_PARAMETERS StartIoPerfParams)
3110 {
3111     return StorPortExtendedFunction(ExtFunctionGetStartIoPerformanceParameters,
3112                                     HwDeviceExtension,
3113                                     Srb,
3114                                     StartIoPerfParams);
3115 }
3116 
3117 FORCEINLINE
3118 ULONG
3119 StorPortLogSystemEvent(
3120     _In_ PVOID HwDeviceExtension,
3121     _Inout_ PSTOR_LOG_EVENT_DETAILS LogDetails,
3122     _Inout_ PULONG MaximumSize)
3123 {
3124     return StorPortExtendedFunction(ExtFunctionLogSystemEvent,
3125                                     HwDeviceExtension,
3126                                     LogDetails,
3127                                     MaximumSize);
3128 }
3129 
3130 #if DBG
3131 #define DebugPrint(x) StorPortDebugPrint x
3132 #else
3133 #define DebugPrint(x)
3134 #endif
3135 
3136 #ifdef __cplusplus
3137 }
3138 #endif
3139 
3140 #endif /* _NTSTORPORT_ */
3141