xref: /reactos/drivers/storage/ide/uniata/srb.h (revision 84ccccab)
1 /*
2 	Module Name:
3 
4     srb.h
5 
6 	Abstract:
7 
8     This file defines the interface between SCSI mini-port drivers and the
9     SCSI port driver.  It is also used by SCSI class drivers to talk to the
10     SCSI port driver.
11     w2k-related definitions are added by Alter from w2k/xp DDK
12  */
13 
14 #ifndef _NTSRB_
15 #define _NTSRB_
16 
17 #pragma pack(push, 8)
18 
19 // Define SCSI maximum configuration parameters.
20 
21 #define SCSI_MAXIMUM_LOGICAL_UNITS 8
22 #define SCSI_MAXIMUM_TARGETS_PER_BUS 128
23 #define SCSI_MAXIMUM_LUNS_PER_TARGET 255
24 #define SCSI_MAXIMUM_BUSES 8
25 #define SCSI_MINIMUM_PHYSICAL_BREAKS  16
26 #define SCSI_MAXIMUM_PHYSICAL_BREAKS 255
27 
28 // This constant is for backward compatibility.
29 // This use to be the maximum number of targets supported.
30 
31 #define SCSI_MAXIMUM_TARGETS 8
32 // begin_ntminitape
33 #define MAXIMUM_CDB_SIZE 12
34 // end_ntminitape
35 
36 #ifndef USER_MODE
37 
38 typedef PHYSICAL_ADDRESS SCSI_PHYSICAL_ADDRESS, *PSCSI_PHYSICAL_ADDRESS;
39 
40 typedef struct _ACCESS_RANGE {
41     SCSI_PHYSICAL_ADDRESS RangeStart;
42     ULONG RangeLength;
43     BOOLEAN RangeInMemory;
44 }ACCESS_RANGE, *PACCESS_RANGE;
45 
46 //
47 // Configuration information structure.  Contains the information necessary
48 // to initialize the adapter. NOTE: This structure's must be a multiple of
49 // quadwords.
50 //
51 
52 typedef struct _PORT_CONFIGURATION_INFORMATION {
53     ULONG Length;				// Length of port configuation information strucuture.
54     ULONG SystemIoBusNumber;	// IO bus number (0 for machines that have only 1 IO bus
55     INTERFACE_TYPE  AdapterInterfaceType;	// EISA, MCA or ISA
56     ULONG BusInterruptLevel;	// Interrupt request level for device
57     // Bus interrupt vector used with hardware buses which use as vector as
58     // well as level, such as internal buses.
59     ULONG BusInterruptVector;
60     KINTERRUPT_MODE InterruptMode;	// Interrupt mode (level-sensitive or edge-triggered)
61 
62     ULONG MaximumTransferLength;	// Max bytes that can be transferred in a single SRB
63     ULONG NumberOfPhysicalBreaks;	// Number of contiguous blocks of physical memory
64     ULONG DmaChannel;				// DMA channel for devices using system DMA
65     ULONG DmaPort;
66     DMA_WIDTH DmaWidth;
67     DMA_SPEED DmaSpeed;
68     ULONG AlignmentMask;			// Alignment masked for the adapter for data transfers.
69     ULONG NumberOfAccessRanges;		// Number of allocated access range elements.
70     ACCESS_RANGE (*AccessRanges)[];	// Pointer to array of access range elements.
71     PVOID Reserved;
72     UCHAR NumberOfBuses;			// Number of SCSI buses attached to the adapter.
73     CCHAR InitiatorBusId[8];		// SCSI bus ID for adapter
74     BOOLEAN ScatterGather;			// Indicates that the adapter does scatter/gather
75     BOOLEAN Master;					// Indicates that the adapter is a bus master
76     BOOLEAN CachesData;				// Host caches data or state.
77     BOOLEAN AdapterScansDown;		// Host adapter scans down for bios devices.
78     BOOLEAN AtdiskPrimaryClaimed;	// Primary at disk address (0x1F0) claimed.
79     BOOLEAN AtdiskSecondaryClaimed;	// Secondary at disk address (0x170) claimed.
80     BOOLEAN Dma32BitAddresses;		// The master uses 32-bit DMA addresses.
81     BOOLEAN DemandMode;				// Use Demand Mode DMA rather than Single Request.
82     BOOLEAN MapBuffers;				// Data buffers must be mapped into virtual address space.
83     BOOLEAN NeedPhysicalAddresses;	// We need to tranlate virtual to physical addresses.
84     BOOLEAN TaggedQueuing;			// Supports tagged queuing
85     BOOLEAN AutoRequestSense;		// Supports auto request sense.
86     BOOLEAN MultipleRequestPerLu;	// Supports multiple requests per logical unit.
87     BOOLEAN ReceiveEvent;			// Support receive event function.
88     BOOLEAN RealModeInitialized;	// Indicates the real-mode driver has initialized the card.
89 
90     BOOLEAN BufferAccessScsiPortControlled; // Indicate that the miniport will not touch
91 									// the data buffers directly.
92     UCHAR   MaximumNumberOfTargets;	// Indicator for wide scsi.
93     UCHAR   ReservedUchars[2];		// Ensure quadword alignment.
94     ULONG SlotNumber;				// Adapter slot number
95     ULONG BusInterruptLevel2;		// Interrupt information for a second IRQ.
96     ULONG BusInterruptVector2;
97     KINTERRUPT_MODE InterruptMode2;
98     ULONG DmaChannel2;				// DMA information for a second channel.
99     ULONG DmaPort2;
100     DMA_WIDTH DmaWidth2;
101     DMA_SPEED DmaSpeed2;
102 
103 } PORT_CONFIGURATION_INFORMATION, *PPORT_CONFIGURATION_INFORMATION;
104 
105 typedef struct _PORT_CONFIGURATION_INFORMATION_NT {
106     // Fields added to allow for the miniport
107     // to update these sizes based on requirements
108     // for large transfers ( > 64K);
109     ULONG DeviceExtensionSize;
110     ULONG SpecificLuExtensionSize;
111     ULONG SrbExtensionSize;
112 } PORT_CONFIGURATION_INFORMATION_NT, *PPORT_CONFIGURATION_INFORMATION_NT;
113 
114 typedef struct _PORT_CONFIGURATION_INFORMATION_2K {
115     // Used to determine whether the system and/or the miniport support
116     // 64-bit physical addresses.  See SCSI_DMA64_* flags below.
117     UCHAR  Dma64BitAddresses;
118     // Indicates that the miniport can accept a SRB_FUNCTION_RESET_DEVICE
119     // to clear all requests to a particular LUN.
120     BOOLEAN ResetTargetSupported;
121     // Indicates that the miniport can support more than 8 logical units per
122     // target (maximum LUN number is one less than this field).
123     UCHAR MaximumNumberOfLogicalUnits;
124     // Supports WMI?
125     BOOLEAN WmiDataProvider;
126 } PORT_CONFIGURATION_INFORMATION_2K, *PPORT_CONFIGURATION_INFORMATION_2K;
127 
128 typedef struct _PORT_CONFIGURATION_INFORMATION_COMMON {
129     PORT_CONFIGURATION_INFORMATION     comm;
130     PORT_CONFIGURATION_INFORMATION_NT  nt4;
131     PORT_CONFIGURATION_INFORMATION_2K  w2k;
132 } PORT_CONFIGURATION_INFORMATION_COMMON, *PPORT_CONFIGURATION_INFORMATION_COMMON;
133 
134 //
135 // Version control for ConfigInfo structure.
136 //
137 
138 #define CONFIG_INFO_VERSION_2 sizeof(PORT_CONFIGURATION_INFORMATION)
139 
140 //
141 // Flags for controlling 64-bit DMA use (PORT_CONFIGURATION_INFORMATION field
142 // Dma64BitAddresses)
143 //
144 
145 //
146 // Set by scsiport on entering HwFindAdapter if the system can support 64-bit
147 // physical addresses.  The miniport can use this information before calling
148 // ScsiPortGetUncachedExtension to modify the DeviceExtensionSize,
149 // SpecificLuExtensionSize & SrbExtensionSize fields to account for the extra
150 // size of the scatter gather list.
151 //
152 
153 #define SCSI_DMA64_SYSTEM_SUPPORTED     0x80
154 
155 //
156 // Set by the miniport before calling ScsiPortGetUncachedExtension to indicate
157 // that scsiport should provide it with 64-bit physical addresses.  If the
158 // system does not support 64-bit PA's then this bit will be ignored.
159 //
160 
161 #define SCSI_DMA64_MINIPORT_SUPPORTED   0x01
162 
163 
164 //
165 // Command type (and parameter) definition(s) for AdapterControl requests.
166 //
167 
168 typedef enum _SCSI_ADAPTER_CONTROL_TYPE {
169     ScsiQuerySupportedControlTypes = 0,
170     ScsiStopAdapter,
171     ScsiRestartAdapter,
172     ScsiSetBootConfig,
173     ScsiSetRunningConfig,
174     ScsiAdapterControlMax,
175     MakeAdapterControlTypeSizeOfUlong = 0xffffffff
176 } SCSI_ADAPTER_CONTROL_TYPE, *PSCSI_ADAPTER_CONTROL_TYPE;
177 
178 //
179 // Adapter control status values
180 //
181 
182 typedef enum _SCSI_ADAPTER_CONTROL_STATUS {
183     ScsiAdapterControlSuccess = 0,
184     ScsiAdapterControlUnsuccessful
185 } SCSI_ADAPTER_CONTROL_STATUS, *PSCSI_ADAPTER_CONTROL_STATUS;
186 
187 //
188 // Parameters for Adapter Control Functions:
189 //
190 
191 //
192 // ScsiQuerySupportedControlTypes:
193 //
194 
195 #ifdef _MSC_VER
196 #pragma warning(disable:4200)
197 #endif
198 typedef struct _SCSI_SUPPORTED_CONTROL_TYPE_LIST {
199 
200     //
201     // Specifies the number of entries in the adapter control type list.
202     //
203 
204     IN ULONG MaxControlType;
205 
206     //
207     // The miniport will set TRUE for each control type it supports.
208     // The number of entries in this array is defined by MaxAdapterControlType
209     // - the miniport must not attempt to set any AC types beyond the maximum
210     // value specified.
211     //
212 
213     OUT BOOLEAN SupportedTypeList[0];
214 
215 } SCSI_SUPPORTED_CONTROL_TYPE_LIST, *PSCSI_SUPPORTED_CONTROL_TYPE_LIST;
216 #ifdef _MSC_VER
217 #pragma warning(disable:4200)
218 #endif
219 
220 //
221 // Uninitialized flag value.
222 //
223 
224 #define SP_UNINITIALIZED_VALUE ((ULONG) ~0)
225 #define SP_UNTAGGED ((UCHAR) ~0)
226 
227 //
228 // Set asynchronous events.
229 //
230 
231 #define SRBEV_BUS_RESET               0x0001
232 #define SRBEV_SCSI_ASYNC_NOTIFICATION 0x0002
233 
234 // begin_ntminitape
235 
236 //
237 // SCSI I/O Request Block
238 //
239 
240 typedef struct _SCSI_REQUEST_BLOCK {
241     USHORT Length;                  // offset 0
242     UCHAR Function;                 // offset 2
243     UCHAR SrbStatus;                // offset 3
244     UCHAR ScsiStatus;               // offset 4
245     UCHAR PathId;                   // offset 5
246     UCHAR TargetId;                 // offset 6
247     UCHAR Lun;                      // offset 7
248     UCHAR QueueTag;                 // offset 8
249     UCHAR QueueAction;              // offset 9
250     UCHAR CdbLength;                // offset a
251     UCHAR SenseInfoBufferLength;    // offset b
252     ULONG SrbFlags;                 // offset c
253     ULONG DataTransferLength;       // offset 10
254     ULONG TimeOutValue;             // offset 14
255     PVOID DataBuffer;               // offset 18
256     PVOID SenseInfoBuffer;          // offset 1c
257     struct _SCSI_REQUEST_BLOCK *NextSrb; // offset 20
258     PVOID OriginalRequest;          // offset 24
259     PVOID SrbExtension;             // offset 28
260     union {
261         ULONG InternalStatus;       // offset 2c
262         ULONG QueueSortKey;         // offset 2c
263     };
264 
265 #if defined(_WIN64)
266     // Force PVOID alignment of Cdb
267     ULONG Reserved;
268 
269 #endif
270 
271     UCHAR Cdb[16];                  // offset 30
272 } SCSI_REQUEST_BLOCK, *PSCSI_REQUEST_BLOCK;
273 
274 #define SCSI_REQUEST_BLOCK_SIZE sizeof(SCSI_REQUEST_BLOCK)
275 
276 //
277 // SCSI I/O Request Block for WMI Requests
278 //
279 
280 typedef struct _SCSI_WMI_REQUEST_BLOCK {
281     USHORT Length;
282     UCHAR Function;        // SRB_FUNCTION_WMI
283     UCHAR SrbStatus;
284     UCHAR WMISubFunction;
285     UCHAR PathId;          // If SRB_WMI_FLAGS_ADAPTER_REQUEST is set in
286     UCHAR TargetId;        // WMIFlags then PathId, TargetId and Lun are
287     UCHAR Lun;             // reserved fields.
288     UCHAR Reserved1;
289     UCHAR WMIFlags;
290     UCHAR Reserved2[2];
291     ULONG SrbFlags;
292     ULONG DataTransferLength;
293     ULONG TimeOutValue;
294     PVOID DataBuffer;
295     PVOID DataPath;
296     PVOID Reserved3;
297     PVOID OriginalRequest;
298     PVOID SrbExtension;
299     ULONG Reserved4;
300     UCHAR Reserved5[16];
301 } SCSI_WMI_REQUEST_BLOCK, *PSCSI_WMI_REQUEST_BLOCK;
302 
303 //
304 // SRB Functions
305 //
306 
307 #define SRB_FUNCTION_EXECUTE_SCSI           0x00
308 #define SRB_FUNCTION_CLAIM_DEVICE           0x01
309 #define SRB_FUNCTION_IO_CONTROL             0x02
310 #define SRB_FUNCTION_RECEIVE_EVENT          0x03
311 #define SRB_FUNCTION_RELEASE_QUEUE          0x04
312 #define SRB_FUNCTION_ATTACH_DEVICE          0x05
313 #define SRB_FUNCTION_RELEASE_DEVICE         0x06
314 #define SRB_FUNCTION_SHUTDOWN               0x07
315 #define SRB_FUNCTION_FLUSH                  0x08
316 #define SRB_FUNCTION_ABORT_COMMAND          0x10
317 #define SRB_FUNCTION_RELEASE_RECOVERY       0x11
318 #define SRB_FUNCTION_RESET_BUS              0x12
319 #define SRB_FUNCTION_RESET_DEVICE           0x13
320 #define SRB_FUNCTION_TERMINATE_IO           0x14
321 #define SRB_FUNCTION_FLUSH_QUEUE            0x15
322 #define SRB_FUNCTION_REMOVE_DEVICE          0x16
323 #define SRB_FUNCTION_WMI                    0x17
324 #define SRB_FUNCTION_LOCK_QUEUE             0x18
325 #define SRB_FUNCTION_UNLOCK_QUEUE           0x19
326 #define SRB_FUNCTION_RESET_LOGICAL_UNIT     0x20
327 
328 //
329 // SRB Status
330 //
331 
332 #define SRB_STATUS_PENDING                  0x00
333 #define SRB_STATUS_SUCCESS                  0x01
334 #define SRB_STATUS_ABORTED                  0x02
335 #define SRB_STATUS_ABORT_FAILED             0x03
336 #define SRB_STATUS_ERROR                    0x04
337 #define SRB_STATUS_BUSY                     0x05
338 #define SRB_STATUS_INVALID_REQUEST          0x06
339 #define SRB_STATUS_INVALID_PATH_ID          0x07
340 #define SRB_STATUS_NO_DEVICE                0x08
341 #define SRB_STATUS_TIMEOUT                  0x09
342 #define SRB_STATUS_SELECTION_TIMEOUT        0x0A
343 #define SRB_STATUS_COMMAND_TIMEOUT          0x0B
344 #define SRB_STATUS_MESSAGE_REJECTED         0x0D
345 #define SRB_STATUS_BUS_RESET                0x0E
346 #define SRB_STATUS_PARITY_ERROR             0x0F
347 #define SRB_STATUS_REQUEST_SENSE_FAILED     0x10
348 #define SRB_STATUS_NO_HBA                   0x11
349 #define SRB_STATUS_DATA_OVERRUN             0x12
350 #define SRB_STATUS_UNEXPECTED_BUS_FREE      0x13
351 #define SRB_STATUS_PHASE_SEQUENCE_FAILURE   0x14
352 #define SRB_STATUS_BAD_SRB_BLOCK_LENGTH     0x15
353 #define SRB_STATUS_REQUEST_FLUSHED          0x16
354 #define SRB_STATUS_INVALID_LUN              0x20
355 #define SRB_STATUS_INVALID_TARGET_ID        0x21
356 #define SRB_STATUS_BAD_FUNCTION             0x22
357 #define SRB_STATUS_ERROR_RECOVERY           0x23
358 #define SRB_STATUS_NOT_POWERED              0x24
359 
360 //
361 // This value is used by the port driver to indicate that a non-scsi-related
362 // error occured.  Miniports must never return this status.
363 //
364 
365 #define SRB_STATUS_INTERNAL_ERROR           0x30
366 
367 //
368 // Srb status values 0x38 through 0x3f are reserved for internal port driver
369 // use.
370 //
371 
372 
373 
374 //
375 // SRB Status Masks
376 //
377 
378 #define SRB_STATUS_QUEUE_FROZEN             0x40
379 #define SRB_STATUS_AUTOSENSE_VALID          0x80
380 
381 #define SRB_STATUS(Status) (Status & ~(SRB_STATUS_AUTOSENSE_VALID | SRB_STATUS_QUEUE_FROZEN))
382 
383 //
384 // SRB Flag Bits
385 //
386 
387 #define SRB_FLAGS_QUEUE_ACTION_ENABLE       0x00000002
388 #define SRB_FLAGS_DISABLE_DISCONNECT        0x00000004
389 #define SRB_FLAGS_DISABLE_SYNCH_TRANSFER    0x00000008
390 #define SRB_FLAGS_BYPASS_FROZEN_QUEUE       0x00000010
391 #define SRB_FLAGS_DISABLE_AUTOSENSE         0x00000020
392 #define SRB_FLAGS_DATA_IN                   0x00000040
393 #define SRB_FLAGS_DATA_OUT                  0x00000080
394 #define SRB_FLAGS_NO_DATA_TRANSFER          0x00000000
395 #define SRB_FLAGS_UNSPECIFIED_DIRECTION      (SRB_FLAGS_DATA_IN | SRB_FLAGS_DATA_OUT)
396 #define SRB_FLAGS_NO_QUEUE_FREEZE           0x00000100
397 #define SRB_FLAGS_ADAPTER_CACHE_ENABLE      0x00000200
398 #define SRB_FLAGS_FREE_SENSE_BUFFER         0x00000400
399 #define SRB_FLAGS_IS_ACTIVE                 0x00010000
400 #define SRB_FLAGS_ALLOCATED_FROM_ZONE       0x00020000
401 #define SRB_FLAGS_SGLIST_FROM_POOL          0x00040000
402 #define SRB_FLAGS_BYPASS_LOCKED_QUEUE       0x00080000
403 
404 #define SRB_FLAGS_NO_KEEP_AWAKE             0x00100000
405 #define SRB_FLAGS_PORT_DRIVER_ALLOCSENSE    0x00200000
406 #define SRB_FLAGS_PORT_DRIVER_SENSEHASPORT  0x00400000
407 #define SRB_FLAGS_DONT_START_NEXT_PACKET    0x00800000
408 
409 #define SRB_FLAGS_PORT_DRIVER_RESERVED      0x0F000000
410 #define SRB_FLAGS_CLASS_DRIVER_RESERVED     0xF0000000
411 //
412 // Queue Action
413 //
414 
415 #define SRB_SIMPLE_TAG_REQUEST              0x20
416 #define SRB_HEAD_OF_QUEUE_TAG_REQUEST       0x21
417 #define SRB_ORDERED_QUEUE_TAG_REQUEST       0x22
418 
419 #define SRB_WMI_FLAGS_ADAPTER_REQUEST       0x01
420 
421 // end_ntminitape
422 
423 //
424 // SCSI Adapter Dependent Routines
425 //
426 
427 typedef
428 BOOLEAN
429 (NTAPI *PHW_INITIALIZE) (
430     IN PVOID DeviceExtension
431     );
432 
433 typedef
434 BOOLEAN
435 (NTAPI *PHW_STARTIO) (
436     IN PVOID DeviceExtension,
437     IN PSCSI_REQUEST_BLOCK Srb
438     );
439 
440 typedef
441 BOOLEAN
442 (NTAPI *PHW_INTERRUPT) (
443     IN PVOID DeviceExtension
444     );
445 
446 typedef
447 VOID
448 (NTAPI *PHW_TIMER) (
449     IN PVOID DeviceExtension
450     );
451 
452 typedef
453 VOID
454 (NTAPI *PHW_DMA_STARTED) (
455     IN PVOID DeviceExtension
456     );
457 
458 typedef
459 ULONG
460 (NTAPI *PHW_FIND_ADAPTER) (
461     IN PVOID DeviceExtension,
462     IN PVOID HwContext,
463     IN PVOID BusInformation,
464     IN PCHAR ArgumentString,
465     IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo,
466     OUT PBOOLEAN Again
467     );
468 
469 typedef
470 BOOLEAN
471 (NTAPI *PHW_RESET_BUS) (
472     IN PVOID DeviceExtension,
473     IN ULONG PathId
474     );
475 
476 typedef
477 BOOLEAN
478 (NTAPI *PHW_ADAPTER_STATE) (
479     IN PVOID DeviceExtension,
480     IN PVOID Context,
481     IN BOOLEAN SaveState
482     );
483 
484 typedef
485 SCSI_ADAPTER_CONTROL_STATUS
486 (NTAPI *PHW_ADAPTER_CONTROL) (
487     IN PVOID DeviceExtension,
488     IN SCSI_ADAPTER_CONTROL_TYPE ControlType,
489     IN PVOID Parameters
490     );
491 
492 //
493 // Port driver error codes
494 //
495 
496 #define SP_BUS_PARITY_ERROR         0x0001
497 #define SP_UNEXPECTED_DISCONNECT    0x0002
498 #define SP_INVALID_RESELECTION      0x0003
499 #define SP_BUS_TIME_OUT             0x0004
500 #define SP_PROTOCOL_ERROR           0x0005
501 #define SP_INTERNAL_ADAPTER_ERROR   0x0006
502 #define SP_REQUEST_TIMEOUT          0x0007
503 #define SP_IRQ_NOT_RESPONDING       0x0008
504 #define SP_BAD_FW_WARNING           0x0009
505 #define SP_BAD_FW_ERROR             0x000a
506 #define SP_LOST_WMI_MINIPORT_REQUEST 0x000b
507 
508 
509 //
510 // Return values for SCSI_HW_FIND_ADAPTER.
511 //
512 
513 #define SP_RETURN_NOT_FOUND     0
514 #define SP_RETURN_FOUND         1
515 #define SP_RETURN_ERROR         2
516 #define SP_RETURN_BAD_CONFIG    3
517 
518 //
519 // Notification Event Types
520 //
521 
522 typedef enum _SCSI_NOTIFICATION_TYPE {
523     RequestComplete,
524     NextRequest,
525     NextLuRequest,
526     ResetDetected,
527     CallDisableInterrupts,
528     CallEnableInterrupts,
529     RequestTimerCall,
530     BusChangeDetected,     /* New */
531     WMIEvent,
532     WMIReregister
533 } SCSI_NOTIFICATION_TYPE, *PSCSI_NOTIFICATION_TYPE;
534 
535 //
536 // Structure passed between miniport initialization
537 // and SCSI port initialization
538 //
539 
540 typedef struct _HW_INITIALIZATION_DATA {
541 
542     ULONG HwInitializationDataSize;
543     // Adapter interface type:
544     //
545     // Internal
546     // Isa
547     // Eisa
548     // MicroChannel
549     // TurboChannel
550     // PCIBus
551     // VMEBus
552     // NuBus
553     // PCMCIABus
554     // CBus
555     // MPIBus
556     // MPSABus
557     INTERFACE_TYPE  AdapterInterfaceType;
558 	// Miniport driver routines
559     PHW_INITIALIZE HwInitialize;
560     PHW_STARTIO HwStartIo;
561     PHW_INTERRUPT HwInterrupt;
562     PHW_FIND_ADAPTER HwFindAdapter;
563     PHW_RESET_BUS HwResetBus;
564     PHW_DMA_STARTED HwDmaStarted;
565     PHW_ADAPTER_STATE HwAdapterState;
566     ULONG DeviceExtensionSize;
567     ULONG SpecificLuExtensionSize;
568     ULONG SrbExtensionSize;
569     ULONG NumberOfAccessRanges;
570     PVOID Reserved;
571 
572     BOOLEAN MapBuffers;				// Data buffers must be mapped into virtual address space.
573     BOOLEAN NeedPhysicalAddresses;	// We need to tranlate virtual to physical addresses.
574     BOOLEAN TaggedQueuing;			// Supports tagged queuing
575     BOOLEAN AutoRequestSense;		// Supports auto request sense.
576     BOOLEAN MultipleRequestPerLu;	// Supports multiple requests per logical unit.
577     BOOLEAN ReceiveEvent;			// Support receive event function.
578     USHORT VendorIdLength;			// Vendor identification length
579     PVOID VendorId;					// Vendor identification
580     USHORT ReservedUshort;			// Pad for alignment and future use.
581     USHORT DeviceIdLength;			// Device identification length
582     PVOID DeviceId;					// Device identification
583 
584 } HW_INITIALIZATION_DATA, *PHW_INITIALIZATION_DATA;
585 
586 typedef struct _HW_INITIALIZATION_DATA_2K {
587     // Stop adapter routine.
588     PHW_ADAPTER_CONTROL HwAdapterControl;
589 
590 } HW_INITIALIZATION_DATA_2K, *PHW_INITIALIZATION_DATA_2K;
591 
592 typedef struct _HW_INITIALIZATION_DATA_COMMON {
593   HW_INITIALIZATION_DATA      comm;
594   HW_INITIALIZATION_DATA_2K   w2k;
595 }HW_INITIALIZATION_DATA_COMMON, *PHW_INITIALIZATION_DATA_COMMON;
596 
597 // begin_ntminitape
598 
599 #ifndef _NTDDK_
600 #define SCSIPORT_API DECLSPEC_IMPORT
601 #else
602 #define SCSIPORT_API
603 #endif
604 
605 // end_ntminitape
606 
607 //
608 // Port driver routines called by miniport driver
609 //
610 
611 SCSIPORT_API
612 ULONG NTAPI
613 ScsiPortInitialize(
614     IN PVOID Argument1,
615     IN PVOID Argument2,
616     IN struct _HW_INITIALIZATION_DATA *HwInitializationData,
617     IN PVOID HwContext
618     );
619 
620 SCSIPORT_API
621 VOID NTAPI
622 ScsiPortFreeDeviceBase(
623     IN PVOID HwDeviceExtension,
624     IN PVOID MappedAddress
625     );
626 
627 SCSIPORT_API
628 ULONG NTAPI
629 ScsiPortGetBusData(
630     IN PVOID DeviceExtension,
631     IN ULONG BusDataType,
632     IN ULONG SystemIoBusNumber,
633     IN ULONG SlotNumber,
634     IN PVOID Buffer,
635     IN ULONG Length
636     );
637 
638 SCSIPORT_API
639 ULONG NTAPI
640 ScsiPortSetBusDataByOffset(
641     IN PVOID DeviceExtension,
642     IN ULONG BusDataType,
643     IN ULONG SystemIoBusNumber,
644     IN ULONG SlotNumber,
645     IN PVOID Buffer,
646     IN ULONG Offset,
647     IN ULONG Length
648     );
649 
650 SCSIPORT_API
651 PVOID NTAPI
652 ScsiPortGetDeviceBase(
653     IN PVOID HwDeviceExtension,
654     IN INTERFACE_TYPE BusType,
655     IN ULONG SystemIoBusNumber,
656     IN SCSI_PHYSICAL_ADDRESS IoAddress,
657     IN ULONG NumberOfBytes,
658     IN BOOLEAN InIoSpace
659     );
660 
661 SCSIPORT_API
662 PVOID NTAPI
663 ScsiPortGetLogicalUnit(
664     IN PVOID HwDeviceExtension,
665     IN UCHAR PathId,
666     IN UCHAR TargetId,
667     IN UCHAR Lun
668     );
669 
670 SCSIPORT_API
671 PSCSI_REQUEST_BLOCK NTAPI
672 ScsiPortGetSrb(
673     IN PVOID DeviceExtension,
674     IN UCHAR PathId,
675     IN UCHAR TargetId,
676     IN UCHAR Lun,
677     IN LONG QueueTag
678     );
679 
680 SCSIPORT_API
681 SCSI_PHYSICAL_ADDRESS NTAPI
682 ScsiPortGetPhysicalAddress(
683     IN PVOID HwDeviceExtension,
684     IN PSCSI_REQUEST_BLOCK Srb,
685     IN PVOID VirtualAddress,
686     OUT ULONG *Length
687     );
688 
689 SCSIPORT_API
690 PVOID NTAPI
691 ScsiPortGetVirtualAddress(
692     IN PVOID HwDeviceExtension,
693     IN SCSI_PHYSICAL_ADDRESS PhysicalAddress
694     );
695 
696 SCSIPORT_API
697 PVOID NTAPI
698 ScsiPortGetUncachedExtension(
699     IN PVOID HwDeviceExtension,
700     IN PPORT_CONFIGURATION_INFORMATION ConfigInfo,
701     IN ULONG NumberOfBytes
702     );
703 
704 SCSIPORT_API
705 VOID NTAPI
706 ScsiPortFlushDma(
707     IN PVOID DeviceExtension
708     );
709 
710 SCSIPORT_API
711 VOID NTAPI
712 ScsiPortIoMapTransfer(
713     IN PVOID HwDeviceExtension,
714     IN PSCSI_REQUEST_BLOCK Srb,
715     IN PVOID LogicalAddress,
716     IN ULONG Length
717     );
718 
719 SCSIPORT_API
720 VOID __cdecl
721 ScsiPortNotification(
722     IN SCSI_NOTIFICATION_TYPE NotificationType,
723     IN PVOID HwDeviceExtension,
724     ...
725     );
726 
727 SCSIPORT_API
728 VOID NTAPI
729 ScsiPortLogError(
730     IN PVOID HwDeviceExtension,
731     IN PSCSI_REQUEST_BLOCK Srb OPTIONAL,
732     IN UCHAR PathId,
733     IN UCHAR TargetId,
734     IN UCHAR Lun,
735     IN ULONG ErrorCode,
736     IN ULONG UniqueId
737     );
738 
739 SCSIPORT_API
740 VOID NTAPI
741 ScsiPortCompleteRequest(
742     IN PVOID HwDeviceExtension,
743     IN UCHAR PathId,
744     IN UCHAR TargetId,
745     IN UCHAR Lun,
746     IN UCHAR SrbStatus
747     );
748 
749 SCSIPORT_API
750 VOID NTAPI
751 ScsiPortMoveMemory(
752     IN PVOID WriteBuffer,
753     IN PVOID ReadBuffer,
754     IN ULONG Length
755     );
756 
757 SCSIPORT_API
758 UCHAR NTAPI
759 ScsiPortReadPortUchar(
760     IN PUCHAR Port
761     );
762 
763 SCSIPORT_API
764 USHORT NTAPI
765 ScsiPortReadPortUshort(
766     IN PUSHORT Port
767     );
768 
769 SCSIPORT_API
770 ULONG NTAPI
771 ScsiPortReadPortUlong(
772     IN PULONG Port
773     );
774 
775 SCSIPORT_API
776 VOID NTAPI
777 ScsiPortReadPortBufferUchar(
778     IN PUCHAR Port,
779     IN PUCHAR Buffer,
780     IN ULONG  Count
781     );
782 
783 SCSIPORT_API
784 VOID NTAPI
785 ScsiPortReadPortBufferUshort(
786     IN PUSHORT Port,
787     IN PUSHORT Buffer,
788     IN ULONG Count
789     );
790 
791 SCSIPORT_API
792 VOID NTAPI
793 ScsiPortReadPortBufferUlong(
794     IN PULONG Port,
795     IN PULONG Buffer,
796     IN ULONG Count
797     );
798 
799 SCSIPORT_API
800 UCHAR NTAPI
801 ScsiPortReadRegisterUchar(
802     IN PUCHAR Register
803     );
804 
805 SCSIPORT_API
806 USHORT NTAPI
807 ScsiPortReadRegisterUshort(
808     IN PUSHORT Register
809     );
810 
811 SCSIPORT_API
812 ULONG NTAPI
813 ScsiPortReadRegisterUlong(
814     IN PULONG Register
815     );
816 
817 SCSIPORT_API
818 VOID NTAPI
819 ScsiPortReadRegisterBufferUchar(
820     IN PUCHAR Register,
821     IN PUCHAR Buffer,
822     IN ULONG  Count
823     );
824 
825 SCSIPORT_API
826 VOID NTAPI
827 ScsiPortReadRegisterBufferUshort(
828     IN PUSHORT Register,
829     IN PUSHORT Buffer,
830     IN ULONG Count
831     );
832 
833 SCSIPORT_API
834 VOID NTAPI
835 ScsiPortReadRegisterBufferUlong(
836     IN PULONG Register,
837     IN PULONG Buffer,
838     IN ULONG Count
839     );
840 
841 SCSIPORT_API
842 VOID NTAPI
843 ScsiPortStallExecution(
844     IN ULONG Delay
845     );
846 
847 SCSIPORT_API
848 VOID NTAPI
849 ScsiPortWritePortUchar(
850     IN PUCHAR Port,
851     IN UCHAR Value
852     );
853 
854 SCSIPORT_API
855 VOID NTAPI
856 ScsiPortWritePortUshort(
857     IN PUSHORT Port,
858     IN USHORT Value
859     );
860 
861 SCSIPORT_API
862 VOID NTAPI
863 ScsiPortWritePortUlong(
864     IN PULONG Port,
865     IN ULONG Value
866     );
867 
868 SCSIPORT_API
869 VOID NTAPI
870 ScsiPortWritePortBufferUchar(
871     IN PUCHAR Port,
872     IN PUCHAR Buffer,
873     IN ULONG  Count
874     );
875 
876 SCSIPORT_API
877 VOID NTAPI
878 ScsiPortWritePortBufferUshort(
879     IN PUSHORT Port,
880     IN PUSHORT Buffer,
881     IN ULONG Count
882     );
883 
884 SCSIPORT_API
885 VOID NTAPI
886 ScsiPortWritePortBufferUlong(
887     IN PULONG Port,
888     IN PULONG Buffer,
889     IN ULONG Count
890     );
891 
892 SCSIPORT_API
893 VOID NTAPI
894 ScsiPortWriteRegisterUchar(
895     IN PUCHAR Register,
896     IN UCHAR Value
897     );
898 
899 SCSIPORT_API
900 VOID NTAPI
901 ScsiPortWriteRegisterUshort(
902     IN PUSHORT Register,
903     IN USHORT Value
904     );
905 
906 SCSIPORT_API
907 VOID NTAPI
908 ScsiPortWriteRegisterUlong(
909     IN PULONG Register,
910     IN ULONG Value
911     );
912 
913 SCSIPORT_API
914 VOID NTAPI
915 ScsiPortWriteRegisterBufferUchar(
916     IN PUCHAR Register,
917     IN PUCHAR Buffer,
918     IN ULONG  Count
919     );
920 
921 SCSIPORT_API
922 VOID NTAPI
923 ScsiPortWriteRegisterBufferUshort(
924     IN PUSHORT Register,
925     IN PUSHORT Buffer,
926     IN ULONG Count
927     );
928 
929 SCSIPORT_API
930 VOID NTAPI
931 ScsiPortWriteRegisterBufferUlong(
932     IN PULONG Register,
933     IN PULONG Buffer,
934     IN ULONG Count
935     );
936 
937 SCSIPORT_API
938 SCSI_PHYSICAL_ADDRESS NTAPI
939 ScsiPortConvertUlongToPhysicalAddress(
940     ULONG UlongAddress
941     );
942 
943 SCSIPORT_API
944 ULONG NTAPI
945 ScsiPortConvertPhysicalAddressToUlong(
946     SCSI_PHYSICAL_ADDRESS Address
947     );
948 
949 #define ScsiPortConvertPhysicalAddressToUlong(Address) ((Address).LowPart)
950 
951 SCSIPORT_API
952 BOOLEAN NTAPI
953 ScsiPortValidateRange(
954     IN PVOID HwDeviceExtension,
955     IN INTERFACE_TYPE BusType,
956     IN ULONG SystemIoBusNumber,
957     IN SCSI_PHYSICAL_ADDRESS IoAddress,
958     IN ULONG NumberOfBytes,
959     IN BOOLEAN InIoSpace
960     );
961 
962 // begin_ntminitape
963 
964 SCSIPORT_API
965 VOID __cdecl
966 ScsiDebugPrint(
967     ULONG DebugPrintLevel,
968     PCCHAR DebugMessage,
969     ...
970     );
971 
972 // end_ntminitape
973 
974 #endif //USER_MODE
975 
976 #pragma pack(pop)
977 
978 #endif //
979