xref: /reactos/sdk/include/ddk/srb.h (revision b12069d6)
1 /*
2  * scsi.h
3  *
4  * Interface between SCSI miniport drivers and the SCSI port driver.
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 _NTSRB_
24 #define _NTSRB_
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 /* NOTE: the current SCSI_MAXIMUM_TARGETS_PER_BUS is applicable
31  * only on scsiport miniports. For storport miniports, the max
32  * target supported is 255. */
33 #if (NTDDI_VERSION >= NTDDI_WIN8)
34 #define SCSI_MAXIMUM_BUSES_PER_ADAPTER    255
35 #endif
36 #define SCSI_MAXIMUM_TARGETS_PER_BUS      128
37 #define SCSI_MAXIMUM_LUNS_PER_TARGET      255
38 #define SCSI_MINIMUM_PHYSICAL_BREAKS      16
39 #define SCSI_MAXIMUM_PHYSICAL_BREAKS      255
40 
41 /* These constants are for backward compatibility.
42  * They used to be the maximum supported. */
43 #define SCSI_MAXIMUM_BUSES                8
44 #define SCSI_MAXIMUM_TARGETS              8
45 #define SCSI_MAXIMUM_LOGICAL_UNITS        8
46 
47 /* PORT_CONFIGURATION_INFORMATION.Dma64BitAddresses constants */
48 #define SCSI_DMA64_MINIPORT_SUPPORTED            0x01
49 #define SCSI_DMA64_SYSTEM_SUPPORTED              0x80
50 #if (NTDDI_VERSION > NTDDI_WS03SP1)
51 #define SCSI_DMA64_MINIPORT_FULL64BIT_SUPPORTED  0x02
52 #endif
53 
54 #define SP_UNINITIALIZED_VALUE            ((ULONG) ~0)
55 #define SP_UNTAGGED                       ((UCHAR) ~0)
56 
57 /* Asynchronous events */
58 #define SRBEV_BUS_RESET                   0x0001
59 #define SRBEV_SCSI_ASYNC_NOTIFICATION     0x0002
60 
61 #define MAXIMUM_CDB_SIZE                  12
62 
63 #if DBG
64 #define DebugPrint(x) ScsiDebugPrint x
65 #else
66 #define DebugPrint(x)
67 #endif
68 
69 #define SCSI_COMBINE_BUS_TARGET(Bus, Target)(  \
70   ((((UCHAR) (Target)) & ~(0x20 - 1)) << 8) |  \
71   (((UCHAR) (Bus)) << 5) |                     \
72   (((UCHAR) (Target)) & (0x20 - 1)))
73 
74 #define SCSI_DECODE_BUS_TARGET(Value, Bus, Target)( \
75   Bus = (UCHAR) ((Value) >> 5),                     \
76   Target = (UCHAR) ((((Value) >> 8) & ~(0x20 - 1)) | ((Value) & (0x20 - 1))))
77 
78 /* SCSI_REQUEST_BLOCK.Function constants */
79 #define SRB_FUNCTION_EXECUTE_SCSI           0x00
80 #define SRB_FUNCTION_CLAIM_DEVICE           0x01
81 #define SRB_FUNCTION_IO_CONTROL             0x02
82 #define SRB_FUNCTION_RECEIVE_EVENT          0x03
83 #define SRB_FUNCTION_RELEASE_QUEUE          0x04
84 #define SRB_FUNCTION_ATTACH_DEVICE          0x05
85 #define SRB_FUNCTION_RELEASE_DEVICE         0x06
86 #define SRB_FUNCTION_SHUTDOWN               0x07
87 #define SRB_FUNCTION_FLUSH                  0x08
88 #define SRB_FUNCTION_PROTOCOL_COMMAND       0x09
89 #define SRB_FUNCTION_ABORT_COMMAND          0x10
90 #define SRB_FUNCTION_RELEASE_RECOVERY       0x11
91 #define SRB_FUNCTION_RESET_BUS              0x12
92 #define SRB_FUNCTION_RESET_DEVICE           0x13
93 #define SRB_FUNCTION_TERMINATE_IO           0x14
94 #define SRB_FUNCTION_FLUSH_QUEUE            0x15
95 #define SRB_FUNCTION_REMOVE_DEVICE          0x16
96 #define SRB_FUNCTION_WMI                    0x17
97 #define SRB_FUNCTION_LOCK_QUEUE             0x18
98 #define SRB_FUNCTION_UNLOCK_QUEUE           0x19
99 #define SRB_FUNCTION_QUIESCE_DEVICE         0x1a
100 #define SRB_FUNCTION_RESET_LOGICAL_UNIT     0x20
101 #define SRB_FUNCTION_SET_LINK_TIMEOUT       0x21
102 #define SRB_FUNCTION_LINK_TIMEOUT_OCCURRED  0x22
103 #define SRB_FUNCTION_LINK_TIMEOUT_COMPLETE  0x23
104 #define SRB_FUNCTION_POWER                  0x24
105 #define SRB_FUNCTION_PNP                    0x25
106 #define SRB_FUNCTION_DUMP_POINTERS          0x26
107 #define SRB_FUNCTION_FREE_DUMP_POINTERS     0x27
108 #define SRB_FUNCTION_STORAGE_REQUEST_BLOCK  0x28 // special value
109 #define SRB_FUNCTION_CRYPTO_OPERATION       0x29
110 #define SRB_FUNCTION_GET_DUMP_INFO          0x2a
111 #define SRB_FUNCTION_FREE_DUMP_INFO         0x2b
112 
113 /* SCSI_REQUEST_BLOCK.SrbStatus constants */
114 #define SRB_STATUS_PENDING                0x00
115 #define SRB_STATUS_SUCCESS                0x01
116 #define SRB_STATUS_ABORTED                0x02
117 #define SRB_STATUS_ABORT_FAILED           0x03
118 #define SRB_STATUS_ERROR                  0x04
119 #define SRB_STATUS_BUSY                   0x05
120 #define SRB_STATUS_INVALID_REQUEST        0x06
121 #define SRB_STATUS_INVALID_PATH_ID        0x07
122 #define SRB_STATUS_NO_DEVICE              0x08
123 #define SRB_STATUS_TIMEOUT                0x09
124 #define SRB_STATUS_SELECTION_TIMEOUT      0x0A
125 #define SRB_STATUS_COMMAND_TIMEOUT        0x0B
126 #define SRB_STATUS_MESSAGE_REJECTED       0x0D
127 #define SRB_STATUS_BUS_RESET              0x0E
128 #define SRB_STATUS_PARITY_ERROR           0x0F
129 #define SRB_STATUS_REQUEST_SENSE_FAILED   0x10
130 #define SRB_STATUS_NO_HBA                 0x11
131 #define SRB_STATUS_DATA_OVERRUN           0x12
132 #define SRB_STATUS_UNEXPECTED_BUS_FREE    0x13
133 #define SRB_STATUS_PHASE_SEQUENCE_FAILURE 0x14
134 #define SRB_STATUS_BAD_SRB_BLOCK_LENGTH   0x15
135 #define SRB_STATUS_REQUEST_FLUSHED        0x16
136 #define SRB_STATUS_INVALID_LUN            0x20
137 #define SRB_STATUS_INVALID_TARGET_ID      0x21
138 #define SRB_STATUS_BAD_FUNCTION           0x22
139 #define SRB_STATUS_ERROR_RECOVERY         0x23
140 #define SRB_STATUS_NOT_POWERED            0x24
141 #define SRB_STATUS_LINK_DOWN              0x25
142 #define SRB_STATUS_INSUFFICIENT_RESOURCES 0x26
143 #define SRB_STATUS_THROTTLED_REQUEST      0x27
144 #define SRB_STATUS_INTERNAL_ERROR         0x30
145 
146 #define SRB_STATUS_QUEUE_FROZEN           0x40
147 #define SRB_STATUS_AUTOSENSE_VALID        0x80
148 
149 #define SRB_STATUS(Status) \
150   (Status & ~(SRB_STATUS_AUTOSENSE_VALID | SRB_STATUS_QUEUE_FROZEN))
151 
152 /* SCSI_REQUEST_BLOCK.SrbFlags constants */
153 #define SRB_FLAGS_QUEUE_ACTION_ENABLE       0x00000002
154 #define SRB_FLAGS_DISABLE_DISCONNECT        0x00000004
155 #define SRB_FLAGS_DISABLE_SYNCH_TRANSFER    0x00000008
156 #define SRB_FLAGS_BYPASS_FROZEN_QUEUE       0x00000010
157 #define SRB_FLAGS_DISABLE_AUTOSENSE         0x00000020
158 #define SRB_FLAGS_DATA_IN                   0x00000040
159 #define SRB_FLAGS_DATA_OUT                  0x00000080
160 #define SRB_FLAGS_NO_DATA_TRANSFER          0x00000000
161 #define SRB_FLAGS_UNSPECIFIED_DIRECTION     (SRB_FLAGS_DATA_IN | SRB_FLAGS_DATA_OUT)
162 #define SRB_FLAGS_NO_QUEUE_FREEZE           0x00000100
163 #define SRB_FLAGS_ADAPTER_CACHE_ENABLE      0x00000200
164 #define SRB_FLAGS_FREE_SENSE_BUFFER         0x00000400
165 #define SRB_FLAGS_D3_PROCESSING             0x00000800
166 #define SRB_FLAGS_SEQUENTIAL_REQUIRED       0x00001000
167 #define SRB_FLAGS_IS_ACTIVE                 0x00010000
168 #define SRB_FLAGS_ALLOCATED_FROM_ZONE       0x00020000
169 #define SRB_FLAGS_SGLIST_FROM_POOL          0x00040000
170 #define SRB_FLAGS_BYPASS_LOCKED_QUEUE       0x00080000
171 #define SRB_FLAGS_NO_KEEP_AWAKE             0x00100000
172 #define SRB_FLAGS_PORT_DRIVER_ALLOCSENSE    0x00200000
173 #define SRB_FLAGS_PORT_DRIVER_SENSEHASPORT  0x00400000
174 #define SRB_FLAGS_DONT_START_NEXT_PACKET    0x00800000
175 #define SRB_FLAGS_PORT_DRIVER_RESERVED      0x0F000000
176 #define SRB_FLAGS_CLASS_DRIVER_RESERVED     0xF0000000
177 
178 #if DBG
179 #define SCSI_PORT_SIGNATURE                 0x54524f50
180 #endif
181 
182 #define SRB_SIMPLE_TAG_REQUEST              0x20
183 #define SRB_HEAD_OF_QUEUE_TAG_REQUEST       0x21
184 #define SRB_ORDERED_QUEUE_TAG_REQUEST       0x22
185 
186 #define SRB_WMI_FLAGS_ADAPTER_REQUEST       0x0001
187 #define SRB_POWER_FLAGS_ADAPTER_REQUEST     0x0001
188 #define SRB_PNP_FLAGS_ADAPTER_REQUEST       0x0001
189 
190 #define SP_BUS_PARITY_ERROR                 0x0001
191 #define SP_UNEXPECTED_DISCONNECT            0x0002
192 #define SP_INVALID_RESELECTION              0x0003
193 #define SP_BUS_TIME_OUT                     0x0004
194 #define SP_PROTOCOL_ERROR                   0x0005
195 #define SP_INTERNAL_ADAPTER_ERROR           0x0006
196 #define SP_REQUEST_TIMEOUT                  0x0007
197 #define SP_IRQ_NOT_RESPONDING               0x0008
198 #define SP_BAD_FW_WARNING                   0x0009
199 #define SP_BAD_FW_ERROR                     0x000a
200 #define SP_LOST_WMI_MINIPORT_REQUEST        0x000b
201 
202 #define SP_VER_TRACE_SUPPORT                0x0010
203 
204 #define SP_RETURN_NOT_FOUND                 0
205 #define SP_RETURN_FOUND                     1
206 #define SP_RETURN_ERROR                     2
207 #define SP_RETURN_BAD_CONFIG                3
208 
209 typedef PHYSICAL_ADDRESS SCSI_PHYSICAL_ADDRESS, *PSCSI_PHYSICAL_ADDRESS;
210 
211 typedef struct _ACCESS_RANGE {
212   SCSI_PHYSICAL_ADDRESS RangeStart;
213   ULONG RangeLength;
214   BOOLEAN RangeInMemory;
215 } ACCESS_RANGE, *PACCESS_RANGE;
216 
217 typedef struct _PORT_CONFIGURATION_INFORMATION {
218   ULONG Length;
219   ULONG SystemIoBusNumber;
220   INTERFACE_TYPE AdapterInterfaceType;
221   ULONG BusInterruptLevel;
222   ULONG BusInterruptVector;
223   KINTERRUPT_MODE InterruptMode;
224   ULONG MaximumTransferLength;
225   ULONG NumberOfPhysicalBreaks;
226   ULONG DmaChannel;
227   ULONG DmaPort;
228   DMA_WIDTH DmaWidth;
229   DMA_SPEED DmaSpeed;
230   ULONG AlignmentMask;
231   ULONG NumberOfAccessRanges;
232   ACCESS_RANGE (*AccessRanges)[];
233   PVOID Reserved;
234   UCHAR NumberOfBuses;
235   UCHAR InitiatorBusId[8];
236   BOOLEAN ScatterGather;
237   BOOLEAN Master;
238   BOOLEAN CachesData;
239   BOOLEAN AdapterScansDown;
240   BOOLEAN AtdiskPrimaryClaimed;
241   BOOLEAN AtdiskSecondaryClaimed;
242   BOOLEAN Dma32BitAddresses;
243   BOOLEAN DemandMode;
244   BOOLEAN MapBuffers;
245   BOOLEAN NeedPhysicalAddresses;
246   BOOLEAN TaggedQueuing;
247   BOOLEAN AutoRequestSense;
248   BOOLEAN MultipleRequestPerLu;
249   BOOLEAN ReceiveEvent;
250   BOOLEAN RealModeInitialized;
251   BOOLEAN BufferAccessScsiPortControlled;
252   UCHAR MaximumNumberOfTargets;
253   UCHAR ReservedUchars[2];
254   ULONG SlotNumber;
255   ULONG BusInterruptLevel2;
256   ULONG BusInterruptVector2;
257   KINTERRUPT_MODE InterruptMode2;
258   ULONG DmaChannel2;
259   ULONG DmaPort2;
260   DMA_WIDTH DmaWidth2;
261   DMA_SPEED DmaSpeed2;
262   ULONG DeviceExtensionSize;
263   ULONG SpecificLuExtensionSize;
264   ULONG SrbExtensionSize;
265   UCHAR Dma64BitAddresses;
266   BOOLEAN ResetTargetSupported;
267   UCHAR MaximumNumberOfLogicalUnits;
268   BOOLEAN WmiDataProvider;
269 } PORT_CONFIGURATION_INFORMATION, *PPORT_CONFIGURATION_INFORMATION;
270 
271 #define CONFIG_INFO_VERSION_2 sizeof(PORT_CONFIGURATION_INFORMATION)
272 
273 #ifdef __GNUC__
274 __extension__ /* enums limited to range of integer */
275 #endif
276 typedef enum _SCSI_ADAPTER_CONTROL_TYPE {
277   ScsiQuerySupportedControlTypes = 0,
278   ScsiStopAdapter,
279   ScsiRestartAdapter,
280   ScsiSetBootConfig,
281   ScsiSetRunningConfig,
282   ScsiAdapterControlMax,
283   MakeAdapterControlTypeSizeOfUlong = 0xffffffff
284 } SCSI_ADAPTER_CONTROL_TYPE, *PSCSI_ADAPTER_CONTROL_TYPE;
285 
286 typedef enum _SCSI_ADAPTER_CONTROL_STATUS {
287   ScsiAdapterControlSuccess = 0,
288   ScsiAdapterControlUnsuccessful
289 } SCSI_ADAPTER_CONTROL_STATUS, *PSCSI_ADAPTER_CONTROL_STATUS;
290 
291 typedef struct _SCSI_SUPPORTED_CONTROL_TYPE_LIST {
292   ULONG MaxControlType;
293   BOOLEAN SupportedTypeList[0];
294 } SCSI_SUPPORTED_CONTROL_TYPE_LIST, *PSCSI_SUPPORTED_CONTROL_TYPE_LIST;
295 
296 typedef struct _SCSI_REQUEST_BLOCK {
297   USHORT Length;
298   UCHAR Function;
299   UCHAR SrbStatus;
300   UCHAR ScsiStatus;
301   UCHAR PathId;
302   UCHAR TargetId;
303   UCHAR Lun;
304   UCHAR QueueTag;
305   UCHAR QueueAction;
306   UCHAR CdbLength;
307   UCHAR SenseInfoBufferLength;
308   ULONG SrbFlags;
309   ULONG DataTransferLength;
310   ULONG TimeOutValue;
311   _Field_size_bytes_(DataTransferLength) PVOID DataBuffer;
312   PVOID SenseInfoBuffer;
313   struct _SCSI_REQUEST_BLOCK *NextSrb;
314   PVOID OriginalRequest;
315   PVOID SrbExtension;
316   _ANONYMOUS_UNION union {
317     ULONG InternalStatus;
318     ULONG QueueSortKey;
319     ULONG LinkTimeoutValue;
320   } DUMMYUNIONNAME;
321 #if defined(_WIN64)
322   ULONG Reserved;
323 #endif
324   UCHAR Cdb[16];
325 } SCSI_REQUEST_BLOCK, *PSCSI_REQUEST_BLOCK;
326 
327 #define SCSI_REQUEST_BLOCK_SIZE           sizeof(SCSI_REQUEST_BLOCK)
328 
329 typedef struct _SCSI_WMI_REQUEST_BLOCK {
330   USHORT Length;
331   UCHAR Function;
332   UCHAR SrbStatus;
333   UCHAR WMISubFunction;
334   UCHAR PathId;
335   UCHAR TargetId;
336   UCHAR Lun;
337   UCHAR Reserved1;
338   UCHAR WMIFlags;
339   UCHAR Reserved2[2];
340   ULONG SrbFlags;
341   ULONG DataTransferLength;
342   ULONG TimeOutValue;
343   PVOID DataBuffer;
344   PVOID DataPath;
345   PVOID Reserved3;
346   PVOID OriginalRequest;
347   PVOID SrbExtension;
348   ULONG Reserved4;
349 #if (NTDDI_VERSION >= NTDDI_WS03SP1) && defined(_WIN64)
350   ULONG Reserved6;
351 #endif
352   UCHAR Reserved5[16];
353 } SCSI_WMI_REQUEST_BLOCK, *PSCSI_WMI_REQUEST_BLOCK;
354 
355 typedef enum _STOR_DEVICE_POWER_STATE {
356   StorPowerDeviceUnspecified = 0,
357   StorPowerDeviceD0,
358   StorPowerDeviceD1,
359   StorPowerDeviceD2,
360   StorPowerDeviceD3,
361   StorPowerDeviceMaximum
362 } STOR_DEVICE_POWER_STATE, *PSTOR_DEVICE_POWER_STATE;
363 
364 typedef enum _STOR_POWER_ACTION {
365   StorPowerActionNone = 0,
366   StorPowerActionReserved,
367   StorPowerActionSleep,
368   StorPowerActionHibernate,
369   StorPowerActionShutdown,
370   StorPowerActionShutdownReset,
371   StorPowerActionShutdownOff,
372   StorPowerActionWarmEject
373 } STOR_POWER_ACTION, *PSTOR_POWER_ACTION;
374 
375 typedef struct _SCSI_POWER_REQUEST_BLOCK {
376   USHORT Length;
377   UCHAR Function;
378   UCHAR SrbStatus;
379   UCHAR SrbPowerFlags;
380   UCHAR PathId;
381   UCHAR TargetId;
382   UCHAR Lun;
383   STOR_DEVICE_POWER_STATE DevicePowerState;
384   ULONG SrbFlags;
385   ULONG DataTransferLength;
386   ULONG TimeOutValue;
387   PVOID DataBuffer;
388   PVOID SenseInfoBuffer;
389   struct _SCSI_REQUEST_BLOCK *NextSrb;
390   PVOID OriginalRequest;
391   PVOID SrbExtension;
392   STOR_POWER_ACTION PowerAction;
393 #if defined(_WIN64)
394   ULONG Reserved;
395 #endif
396   UCHAR Reserved5[16];
397 } SCSI_POWER_REQUEST_BLOCK, *PSCSI_POWER_REQUEST_BLOCK;
398 
399 typedef enum _STOR_PNP_ACTION {
400   StorStartDevice = 0x0,
401   StorRemoveDevice = 0x2,
402   StorStopDevice  = 0x4,
403   StorQueryCapabilities = 0x9,
404   StorQueryResourceRequirements = 0xB,
405   StorFilterResourceRequirements = 0xD,
406   StorSurpriseRemoval = 0x17
407 } STOR_PNP_ACTION, *PSTOR_PNP_ACTION;
408 
409 typedef struct _STOR_DEVICE_CAPABILITIES {
410   USHORT Version;
411   ULONG DeviceD1:1;
412   ULONG DeviceD2:1;
413   ULONG LockSupported:1;
414   ULONG EjectSupported:1;
415   ULONG Removable:1;
416   ULONG DockDevice:1;
417   ULONG UniqueID:1;
418   ULONG SilentInstall:1;
419   ULONG SurpriseRemovalOK:1;
420   ULONG NoDisplayInUI:1;
421 } STOR_DEVICE_CAPABILITIES, *PSTOR_DEVICE_CAPABILITIES;
422 
423 typedef struct _SCSI_PNP_REQUEST_BLOCK {
424   USHORT Length;
425   UCHAR Function;
426   UCHAR SrbStatus;
427   UCHAR PnPSubFunction;
428   UCHAR PathId;
429   UCHAR TargetId;
430   UCHAR Lun;
431   STOR_PNP_ACTION PnPAction;
432   ULONG SrbFlags;
433   ULONG DataTransferLength;
434   ULONG TimeOutValue;
435   PVOID DataBuffer;
436   PVOID SenseInfoBuffer;
437   struct _SCSI_REQUEST_BLOCK *NextSrb;
438   PVOID OriginalRequest;
439   PVOID SrbExtension;
440   ULONG SrbPnPFlags;
441 #if defined(_WIN64)
442   ULONG Reserved;
443 #endif
444   UCHAR Reserved4[16];
445 } SCSI_PNP_REQUEST_BLOCK, *PSCSI_PNP_REQUEST_BLOCK;
446 
447 #if (NTDDI_VERSION >= NTDDI_WIN8)
448 #if defined(_WIN64)
449 #define SRB_ALIGN           DECLSPEC_ALIGN(8)
450 #define POINTER_ALIGN       DECLSPEC_ALIGN(8)
451 #else
452 #define SRB_ALIGN
453 #define POINTER_ALIGN
454 #endif
455 
456 typedef enum _SRBEXDATATYPE {
457   SrbExDataTypeUnknown = 0,
458   SrbExDataTypeBidirectional,
459   SrbExDataTypeScsiCdb16 = 0x40,
460   SrbExDataTypeScsiCdb32,
461   SrbExDataTypeScsiCdbVar,
462   SrbExDataTypeWmi = 0x60,
463   SrbExDataTypePower,
464   SrbExDataTypePnP,
465   SrbExDataTypeIoInfo = 0x80,
466   SrbExDataTypeMSReservedStart = 0xf0000000,
467   SrbExDataTypeReserved = 0xffffffff
468 } SRBEXDATATYPE, *PSRBEXDATATYPE;
469 
470 typedef struct SRB_ALIGN _SRBEX_DATA {
471   SRBEXDATATYPE Type;
472   ULONG Length;
473   _Field_size_bytes_(Length) UCHAR Data[ANYSIZE_ARRAY];
474 } SRBEX_DATA, *PSRBEX_DATA;
475 
476 #define SRBEX_DATA_BIDIRECTIONAL_LENGTH ((2 * sizeof(ULONG)) + sizeof(PVOID))
477 
478 typedef struct SRB_ALIGN _SRBEX_DATA_BIDIRECTIONAL {
479   _Field_range_(SrbExDataTypeBidirectional, SrbExDataTypeBidirectional)
480   SRBEXDATATYPE Type;
481   _Field_range_(SRBEX_DATA_BIDIRECTIONAL_LENGTH, SRBEX_DATA_BIDIRECTIONAL_LENGTH)
482   ULONG Length;
483   ULONG DataInTransferLength;
484   ULONG Reserved1;
485   _Field_size_bytes_full_(DataInTransferLength)
486   PVOID POINTER_ALIGN DataInBuffer;
487 } SRBEX_DATA_BIDIRECTIONAL, *PSRBEX_DATA_BIDIRECTIONAL;
488 
489 #define SRBEX_DATA_SCSI_CDB16_LENGTH ((20 * sizeof(UCHAR)) + sizeof(ULONG) + sizeof(PVOID))
490 
491 typedef struct SRB_ALIGN _SRBEX_DATA_SCSI_CDB16 {
492   _Field_range_(SrbExDataTypeScsiCdb16, SrbExDataTypeScsiCdb16)
493   SRBEXDATATYPE Type;
494   _Field_range_(SRBEX_DATA_SCSI_CDB16_LENGTH, SRBEX_DATA_SCSI_CDB16_LENGTH)
495   ULONG Length;
496   UCHAR ScsiStatus;
497   UCHAR SenseInfoBufferLength;
498   UCHAR CdbLength;
499   UCHAR Reserved;
500   ULONG Reserved1;
501   _Field_size_bytes_full_(SenseInfoBufferLength)
502   PVOID POINTER_ALIGN SenseInfoBuffer;
503   UCHAR POINTER_ALIGN Cdb[16];
504 } SRBEX_DATA_SCSI_CDB16, *PSRBEX_DATA_SCSI_CDB16;
505 
506 #define SRBEX_DATA_SCSI_CDB32_LENGTH ((36 * sizeof(UCHAR)) + sizeof(ULONG) + sizeof(PVOID))
507 
508 typedef struct SRB_ALIGN _SRBEX_DATA_SCSI_CDB32 {
509   _Field_range_(SrbExDataTypeScsiCdb32, SrbExDataTypeScsiCdb32)
510   SRBEXDATATYPE Type;
511   _Field_range_(SRBEX_DATA_SCSI_CDB32_LENGTH, SRBEX_DATA_SCSI_CDB32_LENGTH)
512   ULONG Length;
513   UCHAR ScsiStatus;
514   UCHAR SenseInfoBufferLength;
515   UCHAR CdbLength;
516   UCHAR Reserved;
517   ULONG Reserved1;
518   _Field_size_bytes_full_(SenseInfoBufferLength)
519   PVOID POINTER_ALIGN SenseInfoBuffer;
520   UCHAR POINTER_ALIGN Cdb[32];
521 } SRBEX_DATA_SCSI_CDB32, *PSRBEX_DATA_SCSI_CDB32;
522 
523 #define SRBEX_DATA_SCSI_CDB_VAR_LENGTH_MIN ((4 * sizeof(UCHAR)) + (3 * sizeof(ULONG)) + sizeof(PVOID))
524 #define SRBEX_DATA_SCSI_CDB_VAR_LENGTH_MAX 0xffffffffUL
525 
526 typedef struct SRB_ALIGN _SRBEX_DATA_SCSI_CDB_VAR {
527   _Field_range_(SrbExDataTypeScsiCdbVar, SrbExDataTypeScsiCdbVar)
528   SRBEXDATATYPE Type;
529   _Field_range_(SRBEX_DATA_SCSI_CDB_VAR_LENGTH_MIN, SRBEX_DATA_SCSI_CDB_VAR_LENGTH_MAX)
530   ULONG Length;
531   UCHAR ScsiStatus;
532   UCHAR SenseInfoBufferLength;
533   UCHAR Reserved[2];
534   ULONG CdbLength;
535   ULONG Reserved1[2];
536   _Field_size_bytes_full_(SenseInfoBufferLength)
537   PVOID POINTER_ALIGN SenseInfoBuffer;
538   _Field_size_bytes_full_(CdbLength)
539   UCHAR POINTER_ALIGN Cdb[ANYSIZE_ARRAY];
540 } SRBEX_DATA_SCSI_CDB_VAR, *PSRBEX_DATA_SCSI_CDB_VAR;
541 
542 #define SRBEX_DATA_WMI_LENGTH ((4 * sizeof(UCHAR)) + sizeof(ULONG) + sizeof(PVOID))
543 
544 typedef struct SRB_ALIGN _SRBEX_DATA_WMI {
545   _Field_range_(SrbExDataTypeWmi, SrbExDataTypeWmi)
546   SRBEXDATATYPE Type;
547   _Field_range_(SRBEX_DATA_WMI_LENGTH, SRBEX_DATA_WMI_LENGTH)
548   ULONG Length;
549   UCHAR WMISubFunction;
550   UCHAR WMIFlags;
551   UCHAR Reserved[2];
552   ULONG Reserved1;
553   PVOID POINTER_ALIGN DataPath;
554 } SRBEX_DATA_WMI, *PSRBEX_DATA_WMI;
555 
556 #define SRBEX_DATA_POWER_LENGTH ((4 * sizeof(UCHAR)) + sizeof(STOR_DEVICE_POWER_STATE) + sizeof(STOR_POWER_ACTION))
557 
558 typedef struct SRB_ALIGN _SRBEX_DATA_POWER {
559   _Field_range_(SrbExDataTypePower, SrbExDataTypePower)
560   SRBEXDATATYPE Type;
561   _Field_range_(SRBEX_DATA_POWER_LENGTH, SRBEX_DATA_POWER_LENGTH)
562   ULONG Length;
563   UCHAR SrbPowerFlags;
564   UCHAR Reserved[3];
565   STOR_DEVICE_POWER_STATE DevicePowerState;
566   STOR_POWER_ACTION PowerAction;
567 } SRBEX_DATA_POWER, *PSRBEX_DATA_POWER;
568 
569 #define SRBEX_DATA_PNP_LENGTH ((4 * sizeof(UCHAR)) + sizeof(STOR_PNP_ACTION) + (2 * sizeof(ULONG)))
570 
571 typedef struct SRB_ALIGN _SRBEX_DATA_PNP {
572   _Field_range_(SrbExDataTypePnP, SrbExDataTypePnP)
573   SRBEXDATATYPE Type;
574   _Field_range_(SRBEX_DATA_PNP_LENGTH, SRBEX_DATA_PNP_LENGTH)
575   ULONG Length;
576   UCHAR PnPSubFunction;
577   UCHAR Reserved[3];
578   STOR_PNP_ACTION PnPAction;
579   ULONG SrbPnPFlags;
580   ULONG Reserved1;
581 } SRBEX_DATA_PNP, *PSRBEX_DATA_PNP;
582 
583 #define SRBEX_DATA_IO_INFO_LENGTH ((5 * sizeof(ULONG)) + (4 * sizeof(UCHAR)))
584 
585 #define REQUEST_INFO_NO_CACHE_FLAG                  0x00000001
586 #define REQUEST_INFO_PAGING_IO_FLAG                 0x00000002
587 #define REQUEST_INFO_SEQUENTIAL_IO_FLAG             0x00000004
588 #define REQUEST_INFO_TEMPORARY_FLAG                 0x00000008
589 #define REQUEST_INFO_WRITE_THROUGH_FLAG             0x00000010
590 #define REQUEST_INFO_HYBRID_WRITE_THROUGH_FLAG      0x00000020
591 
592 #if (NTDDI_VERSION >= NTDDI_WINTHRESHOLD)
593 
594 #define REQUEST_INFO_NO_FILE_OBJECT_FLAG            0x00000040
595 #define REQUEST_INFO_VOLSNAP_IO_FLAG                0x00000080
596 #define REQUEST_INFO_STREAM_FLAG                    0x00000100
597 
598 #endif /* (NTDDI_VERSION >= NTDDI_WINTHRESHOLD) */
599 
600 #define REQUEST_INFO_VALID_CACHEPRIORITY_FLAG       0x80000000
601 
602 typedef struct SRB_ALIGN _SRBEX_DATA_IO_INFO {
603   _Field_range_(SrbExDataTypeIoInfo, SrbExDataTypeIoInfo)
604   SRBEXDATATYPE Type;
605   _Field_range_(SRBEX_DATA_IO_INFO_LENGTH, SRBEX_DATA_IO_INFO_LENGTH)
606   ULONG Length;
607   ULONG Flags;
608   ULONG Key;
609   ULONG RWLength;
610   BOOLEAN IsWriteRequest;
611   UCHAR CachePriority;
612   UCHAR Reserved[2];
613   ULONG Reserved1[2];
614 } SRBEX_DATA_IO_INFO, *PSRBEX_DATA_IO_INFO;
615 
616 #define SRB_SIGNATURE 0x53524258
617 #define STORAGE_REQUEST_BLOCK_VERSION_1    0x1
618 
619 typedef struct SRB_ALIGN _STORAGE_REQUEST_BLOCK_HEADER {
620   USHORT Length;
621   _Field_range_(SRB_FUNCTION_STORAGE_REQUEST_BLOCK, SRB_FUNCTION_STORAGE_REQUEST_BLOCK)
622   UCHAR Function;
623   UCHAR SrbStatus;
624 } STORAGE_REQUEST_BLOCK_HEADER, *PSTORAGE_REQUEST_BLOCK_HEADER;
625 
626 typedef _Struct_size_bytes_(SrbLength) struct SRB_ALIGN _STORAGE_REQUEST_BLOCK {
627   USHORT Length;
628   _Field_range_(SRB_FUNCTION_STORAGE_REQUEST_BLOCK, SRB_FUNCTION_STORAGE_REQUEST_BLOCK)
629   UCHAR Function;
630   UCHAR SrbStatus;
631   UCHAR ReservedUchar[4];
632   _Field_range_(SRB_SIGNATURE, SRB_SIGNATURE)
633   ULONG Signature;
634   _Field_range_(STORAGE_REQUEST_BLOCK_VERSION_1, STORAGE_REQUEST_BLOCK_VERSION_1)
635   ULONG Version;
636   ULONG SrbLength;
637   ULONG SrbFunction;
638   ULONG SrbFlags;
639   ULONG ReservedUlong;
640   ULONG RequestTag;
641   USHORT RequestPriority;
642   USHORT RequestAttribute;
643   ULONG TimeOutValue;
644   ULONG SystemStatus;
645   ULONG ZeroGuard1;
646   _Field_range_(sizeof(STORAGE_REQUEST_BLOCK), SrbLength - sizeof(STOR_ADDRESS))
647   ULONG AddressOffset;
648   ULONG NumSrbExData;
649   ULONG DataTransferLength;
650   _Field_size_bytes_full_(DataTransferLength)
651   PVOID POINTER_ALIGN DataBuffer;
652   PVOID POINTER_ALIGN ZeroGuard2;
653   PVOID POINTER_ALIGN OriginalRequest;
654   PVOID POINTER_ALIGN ClassContext;
655   PVOID POINTER_ALIGN PortContext;
656   PVOID POINTER_ALIGN MiniportContext;
657   struct _STORAGE_REQUEST_BLOCK POINTER_ALIGN *NextSrb;
658   _At_buffer_(SrbExDataOffset, _Iter_, NumSrbExData, _Field_range_(0, SrbLength - sizeof(SRBEX_DATA)))
659   _Field_size_(NumSrbExData)
660   ULONG SrbExDataOffset[ANYSIZE_ARRAY];
661 } STORAGE_REQUEST_BLOCK, *PSTORAGE_REQUEST_BLOCK;
662 
663 #define SRB_TYPE_SCSI_REQUEST_BLOCK         0
664 #define SRB_TYPE_STORAGE_REQUEST_BLOCK      1
665 
666 #define STORAGE_ADDRESS_TYPE_BTL8        0
667 #endif /* (NTDDI_VERSION >= NTDDI_WIN8) */
668 
669 typedef
670 _Must_inspect_result_
671 BOOLEAN
672 (NTAPI *PHW_INITIALIZE)(
673   _In_ PVOID DeviceExtension);
674 
675 typedef
676 _Must_inspect_result_
677 BOOLEAN
678 (NTAPI *PHW_STARTIO)(
679   _In_ PVOID DeviceExtension,
680   _In_ PSCSI_REQUEST_BLOCK Srb);
681 
682 typedef
683 _Must_inspect_result_
684 BOOLEAN
685 (NTAPI *PHW_INTERRUPT)(
686   _In_ PVOID DeviceExtension);
687 
688 typedef VOID
689 (NTAPI *PHW_TIMER)(
690   _In_ PVOID DeviceExtension);
691 
692 typedef VOID
693 (NTAPI *PHW_DMA_STARTED)(
694   _In_ PVOID DeviceExtension);
695 
696 typedef
697 _Must_inspect_result_
698 ULONG
699 (NTAPI *PHW_FIND_ADAPTER)(
700   _In_ PVOID DeviceExtension,
701   _In_ PVOID HwContext,
702   _In_ PVOID BusInformation,
703   _In_ PCHAR ArgumentString,
704   _Inout_ PPORT_CONFIGURATION_INFORMATION ConfigInfo,
705   _Out_ PBOOLEAN Again);
706 
707 typedef
708 _Must_inspect_result_
709 BOOLEAN
710 (NTAPI *PHW_RESET_BUS)(
711   _In_ PVOID DeviceExtension,
712   _In_ ULONG PathId);
713 
714 typedef
715 _Must_inspect_result_
716 BOOLEAN
717 (NTAPI *PHW_ADAPTER_STATE)(
718   _In_ PVOID DeviceExtension,
719   _In_ PVOID Context,
720   _In_ BOOLEAN SaveState);
721 
722 typedef
723 _Must_inspect_result_
724 SCSI_ADAPTER_CONTROL_STATUS
725 (NTAPI *PHW_ADAPTER_CONTROL)(
726   _In_ PVOID DeviceExtension,
727   _In_ SCSI_ADAPTER_CONTROL_TYPE ControlType,
728   _In_ PVOID Parameters);
729 
730 typedef enum _SCSI_NOTIFICATION_TYPE {
731   RequestComplete,
732   NextRequest,
733   NextLuRequest,
734   ResetDetected,
735   CallDisableInterrupts,
736   CallEnableInterrupts,
737   RequestTimerCall,
738   BusChangeDetected,
739   WMIEvent,
740   WMIReregister,
741   LinkUp,
742   LinkDown,
743   QueryTickCount,
744   BufferOverrunDetected,
745   TraceNotification
746 } SCSI_NOTIFICATION_TYPE, *PSCSI_NOTIFICATION_TYPE;
747 
748 typedef struct _HW_INITIALIZATION_DATA {
749   ULONG HwInitializationDataSize;
750   INTERFACE_TYPE  AdapterInterfaceType;
751   PHW_INITIALIZE HwInitialize;
752   PHW_STARTIO HwStartIo;
753   PHW_INTERRUPT HwInterrupt;
754   PHW_FIND_ADAPTER HwFindAdapter;
755   PHW_RESET_BUS HwResetBus;
756   PHW_DMA_STARTED HwDmaStarted;
757   PHW_ADAPTER_STATE HwAdapterState;
758   ULONG DeviceExtensionSize;
759   ULONG SpecificLuExtensionSize;
760   ULONG SrbExtensionSize;
761   ULONG NumberOfAccessRanges;
762   PVOID Reserved;
763   BOOLEAN MapBuffers;
764   BOOLEAN NeedPhysicalAddresses;
765   BOOLEAN TaggedQueuing;
766   BOOLEAN AutoRequestSense;
767   BOOLEAN MultipleRequestPerLu;
768   BOOLEAN ReceiveEvent;
769   USHORT VendorIdLength;
770   PVOID VendorId;
771   _ANONYMOUS_UNION union {
772     USHORT ReservedUshort;
773     USHORT PortVersionFlags;
774   } DUMMYUNIONNAME;
775   USHORT DeviceIdLength;
776   PVOID DeviceId;
777   PHW_ADAPTER_CONTROL HwAdapterControl;
778 } HW_INITIALIZATION_DATA, *PHW_INITIALIZATION_DATA;
779 
780 #if defined(_NTDDK_)
781 #define SCSIPORT_API
782 #else
783 #define SCSIPORT_API DECLSPEC_IMPORT
784 #endif
785 
786 SCSIPORT_API
787 VOID
788 NTAPI
789 ScsiPortCompleteRequest(
790   _In_ PVOID HwDeviceExtension,
791   _In_ UCHAR PathId,
792   _In_ UCHAR TargetId,
793   _In_ UCHAR Lun,
794   _In_ UCHAR SrbStatus);
795 
796 _Must_inspect_result_
797 SCSIPORT_API
798 ULONG
799 NTAPI
800 ScsiPortConvertPhysicalAddressToUlong(
801   _In_ SCSI_PHYSICAL_ADDRESS Address);
802 
803 #define ScsiPortConvertPhysicalAddressToUlong(Address) ((Address).LowPart)
804 #define ScsiPortConvertPhysicalAddressToULongPtr(Address) ((ULONG_PTR)((Address).QuadPart))
805 
806 _Must_inspect_result_
807 SCSIPORT_API
808 SCSI_PHYSICAL_ADDRESS
809 NTAPI
810 ScsiPortConvertUlongToPhysicalAddress(
811   _In_ ULONG_PTR UlongAddress);
812 
813 SCSIPORT_API
814 VOID
815 NTAPI
816 ScsiPortFlushDma(
817   _In_ PVOID DeviceExtension);
818 
819 SCSIPORT_API
820 VOID
821 NTAPI
822 ScsiPortFreeDeviceBase(
823   _In_ PVOID HwDeviceExtension,
824   _In_ PVOID MappedAddress);
825 
826 _Must_inspect_result_
827 SCSIPORT_API
828 ULONG
829 NTAPI
830 ScsiPortGetBusData(
831   _In_ PVOID DeviceExtension,
832   _In_ ULONG BusDataType,
833   _In_ ULONG SystemIoBusNumber,
834   _In_ ULONG SlotNumber,
835   _In_reads_bytes_(Length) PVOID Buffer,
836   _In_ ULONG Length);
837 
838 _Must_inspect_result_
839 SCSIPORT_API
840 PVOID
841 NTAPI
842 ScsiPortGetDeviceBase(
843   _In_ PVOID HwDeviceExtension,
844   _In_ INTERFACE_TYPE BusType,
845   _In_ ULONG SystemIoBusNumber,
846   _In_ SCSI_PHYSICAL_ADDRESS IoAddress,
847   _In_ ULONG NumberOfBytes,
848   _In_ BOOLEAN InIoSpace);
849 
850 _Must_inspect_result_
851 SCSIPORT_API
852 PVOID
853 NTAPI
854 ScsiPortGetLogicalUnit(
855   _In_ PVOID HwDeviceExtension,
856   _In_ UCHAR PathId,
857   _In_ UCHAR TargetId,
858   _In_ UCHAR Lun);
859 
860 _Must_inspect_result_
861 SCSIPORT_API
862 SCSI_PHYSICAL_ADDRESS
863 NTAPI
864 ScsiPortGetPhysicalAddress(
865   _In_ PVOID HwDeviceExtension,
866   _In_ PSCSI_REQUEST_BLOCK Srb,
867   _In_ PVOID VirtualAddress,
868   _Out_ ULONG *Length);
869 
870 _Must_inspect_result_
871 SCSIPORT_API
872 PSCSI_REQUEST_BLOCK
873 NTAPI
874 ScsiPortGetSrb(
875   _In_ PVOID DeviceExtension,
876   _In_ UCHAR PathId,
877   _In_ UCHAR TargetId,
878   _In_ UCHAR Lun,
879   _In_ LONG QueueTag);
880 
881 _Must_inspect_result_
882 SCSIPORT_API
883 PVOID
884 NTAPI
885 ScsiPortGetUncachedExtension(
886   _In_ PVOID HwDeviceExtension,
887   _In_ PPORT_CONFIGURATION_INFORMATION ConfigInfo,
888   _In_ ULONG NumberOfBytes);
889 
890 _Must_inspect_result_
891 SCSIPORT_API
892 PVOID
893 NTAPI
894 ScsiPortGetVirtualAddress(
895   _In_ PVOID HwDeviceExtension,
896   _In_ SCSI_PHYSICAL_ADDRESS PhysicalAddress);
897 
898 _Must_inspect_result_
899 _IRQL_requires_max_(PASSIVE_LEVEL)
900 SCSIPORT_API
901 ULONG
902 NTAPI
903 ScsiPortInitialize(
904   _In_ PVOID Argument1,
905   _In_ PVOID Argument2,
906   _In_ struct _HW_INITIALIZATION_DATA *HwInitializationData,
907   _In_ PVOID HwContext);
908 
909 SCSIPORT_API
910 VOID
911 NTAPI
912 ScsiPortIoMapTransfer(
913   _In_ PVOID HwDeviceExtension,
914   _In_ PSCSI_REQUEST_BLOCK Srb,
915   _In_ PVOID LogicalAddress,
916   _In_ ULONG Length);
917 
918 SCSIPORT_API
919 VOID
920 NTAPI
921 ScsiPortLogError(
922   _In_ PVOID HwDeviceExtension,
923   _In_opt_ PSCSI_REQUEST_BLOCK Srb,
924   _In_ UCHAR PathId,
925   _In_ UCHAR TargetId,
926   _In_ UCHAR Lun,
927   _In_ ULONG ErrorCode,
928   _In_ ULONG UniqueId);
929 
930 SCSIPORT_API
931 VOID
932 __cdecl
933 ScsiPortNotification(
934   _In_ SCSI_NOTIFICATION_TYPE NotificationType,
935   _In_ PVOID HwDeviceExtension,
936   ...);
937 
938 SCSIPORT_API
939 VOID
940 NTAPI
941 ScsiPortQuerySystemTime(
942   _Out_ PLARGE_INTEGER CurrentTime);
943 
944 _Must_inspect_result_
945 SCSIPORT_API
946 ULONG
947 NTAPI
948 ScsiPortSetBusDataByOffset(
949   _In_ PVOID DeviceExtension,
950   _In_ ULONG BusDataType,
951   _In_ ULONG SystemIoBusNumber,
952   _In_ ULONG SlotNumber,
953   _In_reads_bytes_(Length) PVOID Buffer,
954   _In_ ULONG Offset,
955   _In_ ULONG Length);
956 
957 SCSIPORT_API
958 VOID
959 NTAPI
960 ScsiPortStallExecution(
961   _In_ ULONG Delay);
962 
963 _Must_inspect_result_
964 SCSIPORT_API
965 BOOLEAN
966 NTAPI
967 ScsiPortValidateRange(
968   _In_ PVOID HwDeviceExtension,
969   _In_ INTERFACE_TYPE BusType,
970   _In_ ULONG SystemIoBusNumber,
971   _In_ SCSI_PHYSICAL_ADDRESS IoAddress,
972   _In_ ULONG NumberOfBytes,
973   _In_ BOOLEAN InIoSpace);
974 
975 SCSIPORT_API
976 VOID
977 __cdecl
978 ScsiDebugPrint(
979   ULONG DebugPrintLevel,
980   PCCHAR DebugMessage,
981   ...);
982 
983 #if defined(_M_AMD64)
984 
985 #define ScsiPortReadPortUchar READ_PORT_UCHAR
986 #define ScsiPortReadPortUshort READ_PORT_USHORT
987 #define ScsiPortReadPortUlong READ_PORT_ULONG
988 
989 #define ScsiPortReadPortBufferUchar READ_PORT_BUFFER_UCHAR
990 #define ScsiPortReadPortBufferUshort READ_PORT_BUFFER_USHORT
991 #define ScsiPortReadPortBufferUlong READ_PORT_BUFFER_ULONG
992 
993 #define ScsiPortReadRegisterUchar READ_REGISTER_UCHAR
994 #define ScsiPortReadRegisterUshort READ_REGISTER_USHORT
995 #define ScsiPortReadRegisterUlong READ_REGISTER_ULONG
996 
997 #define ScsiPortReadRegisterBufferUchar READ_REGISTER_BUFFER_UCHAR
998 #define ScsiPortReadRegisterBufferUshort READ_REGISTER_BUFFER_USHORT
999 #define ScsiPortReadRegisterBufferUlong READ_REGISTER_BUFFER_ULONG
1000 
1001 #define ScsiPortWritePortUchar WRITE_PORT_UCHAR
1002 #define ScsiPortWritePortUshort WRITE_PORT_USHORT
1003 #define ScsiPortWritePortUlong WRITE_PORT_ULONG
1004 
1005 #define ScsiPortWritePortBufferUchar WRITE_PORT_BUFFER_UCHAR
1006 #define ScsiPortWritePortBufferUshort WRITE_PORT_BUFFER_USHORT
1007 #define ScsiPortWritePortBufferUlong WRITE_PORT_BUFFER_ULONG
1008 
1009 #define ScsiPortWriteRegisterUchar WRITE_REGISTER_UCHAR
1010 #define ScsiPortWriteRegisterUshort WRITE_REGISTER_USHORT
1011 #define ScsiPortWriteRegisterUlong WRITE_REGISTER_ULONG
1012 
1013 #define ScsiPortWriteRegisterBufferUchar WRITE_REGISTER_BUFFER_UCHAR
1014 #define ScsiPortWriteRegisterBufferUshort WRITE_REGISTER_BUFFER_USHORT
1015 #define ScsiPortWriteRegisterBufferUlong WRITE_REGISTER_BUFFER_ULONG
1016 
1017 #define ScsiPortMoveMemory memmove
1018 
1019 #else
1020 
1021 _Must_inspect_result_
1022 SCSIPORT_API
1023 UCHAR
1024 NTAPI
1025 ScsiPortReadPortUchar(
1026   _In_ PUCHAR Port);
1027 
1028 _Must_inspect_result_
1029 SCSIPORT_API
1030 ULONG
1031 NTAPI
1032 ScsiPortReadPortUlong(
1033   _In_ PULONG Port);
1034 
1035 _Must_inspect_result_
1036 SCSIPORT_API
1037 USHORT
1038 NTAPI
1039 ScsiPortReadPortUshort(
1040   _In_ PUSHORT Port);
1041 
1042 SCSIPORT_API
1043 VOID
1044 NTAPI
1045 ScsiPortReadPortBufferUchar(
1046   _In_ PUCHAR Port,
1047   _In_ PUCHAR Buffer,
1048   _In_ ULONG Count);
1049 
1050 SCSIPORT_API
1051 VOID
1052 NTAPI
1053 ScsiPortReadPortBufferUlong(
1054   _In_ PULONG Port,
1055   _In_ PULONG Buffer,
1056   _In_ ULONG Count);
1057 
1058 SCSIPORT_API
1059 VOID
1060 NTAPI
1061 ScsiPortReadPortBufferUshort(
1062   _In_ PUSHORT Port,
1063   _In_ PUSHORT Buffer,
1064   _In_ ULONG Count);
1065 
1066 _Must_inspect_result_
1067 SCSIPORT_API
1068 UCHAR
1069 NTAPI
1070 ScsiPortReadRegisterUchar(
1071   _In_ PUCHAR Register);
1072 
1073 _Must_inspect_result_
1074 SCSIPORT_API
1075 ULONG
1076 NTAPI
1077 ScsiPortReadRegisterUlong(
1078   _In_ PULONG Register);
1079 
1080 _Must_inspect_result_
1081 SCSIPORT_API
1082 USHORT
1083 NTAPI
1084 ScsiPortReadRegisterUshort(
1085   _In_ PUSHORT Register);
1086 
1087 SCSIPORT_API
1088 VOID
1089 NTAPI
1090 ScsiPortReadRegisterBufferUchar(
1091   _In_ PUCHAR Register,
1092   _In_ PUCHAR Buffer,
1093   _In_ ULONG Count);
1094 
1095 SCSIPORT_API
1096 VOID
1097 NTAPI
1098 ScsiPortReadRegisterBufferUlong(
1099   _In_ PULONG Register,
1100   _In_ PULONG Buffer,
1101   _In_ ULONG Count);
1102 
1103 SCSIPORT_API
1104 VOID
1105 NTAPI
1106 ScsiPortReadRegisterBufferUshort(
1107   _In_ PUSHORT Register,
1108   _In_ PUSHORT Buffer,
1109   _In_ ULONG Count);
1110 
1111 SCSIPORT_API
1112 VOID
1113 NTAPI
1114 ScsiPortWritePortUchar(
1115   _In_ PUCHAR Port,
1116   _In_ UCHAR Value);
1117 
1118 SCSIPORT_API
1119 VOID
1120 NTAPI
1121 ScsiPortWritePortUlong(
1122   _In_ PULONG Port,
1123   _In_ ULONG Value);
1124 
1125 SCSIPORT_API
1126 VOID
1127 NTAPI
1128 ScsiPortWritePortUshort(
1129   _In_ PUSHORT Port,
1130   _In_ USHORT Value);
1131 
1132 SCSIPORT_API
1133 VOID
1134 NTAPI
1135 ScsiPortWritePortBufferUchar(
1136   _In_ PUCHAR Port,
1137   _In_ PUCHAR Buffer,
1138   _In_ ULONG Count);
1139 
1140 SCSIPORT_API
1141 VOID
1142 NTAPI
1143 ScsiPortWritePortBufferUlong(
1144   _In_ PULONG Port,
1145   _In_ PULONG Buffer,
1146   _In_ ULONG Count);
1147 
1148 SCSIPORT_API
1149 VOID
1150 NTAPI
1151 ScsiPortWritePortBufferUshort(
1152   _In_ PUSHORT Port,
1153   _In_ PUSHORT Buffer,
1154   _In_ ULONG Count);
1155 
1156 SCSIPORT_API
1157 VOID
1158 NTAPI
1159 ScsiPortWriteRegisterUchar(
1160   _In_ PUCHAR Register,
1161   _In_ UCHAR Value);
1162 
1163 SCSIPORT_API
1164 VOID
1165 NTAPI
1166 ScsiPortWriteRegisterUlong(
1167   _In_ PULONG Register,
1168   _In_ ULONG Value);
1169 
1170 SCSIPORT_API
1171 VOID
1172 NTAPI
1173 ScsiPortWriteRegisterUshort(
1174   _In_ PUSHORT Register,
1175   _In_ USHORT Value);
1176 
1177 SCSIPORT_API
1178 VOID
1179 NTAPI
1180 ScsiPortWriteRegisterBufferUchar(
1181   _In_ PUCHAR Register,
1182   _In_ PUCHAR Buffer,
1183   _In_ ULONG Count);
1184 
1185 SCSIPORT_API
1186 VOID
1187 NTAPI
1188 ScsiPortWriteRegisterBufferUlong(
1189   _In_ PULONG Register,
1190   _In_ PULONG Buffer,
1191   _In_ ULONG Count);
1192 
1193 SCSIPORT_API
1194 VOID
1195 NTAPI
1196 ScsiPortWriteRegisterBufferUshort(
1197   _In_ PUSHORT Register,
1198   _In_ PUSHORT Buffer,
1199   _In_ ULONG Count);
1200 
1201 SCSIPORT_API
1202 VOID
1203 NTAPI
1204 ScsiPortMoveMemory(
1205   _In_ PVOID WriteBuffer,
1206   _In_ PVOID ReadBuffer,
1207   _In_ ULONG Length);
1208 
1209 #endif /* defined(_M_AMD64) */
1210 
1211 #ifdef __cplusplus
1212 }
1213 #endif
1214 
1215 #endif /* _NTSRB_ */
1216