ReactOS 0.4.16-dev-336-gb667d82
scsiport.h
Go to the documentation of this file.
1/*
2 * SCSI_PORT_TIMER_STATES
3 *
4 * DESCRIPTION
5 * An enumeration containing the states in the timer DFA
6 */
7
8#pragma once
9
10#include <ntifs.h>
11#include <stdio.h>
12#include <scsi.h>
13#include <ntddscsi.h>
14#include <ntdddisk.h>
15#include <mountdev.h>
16
17#ifdef DBG
18#include <debug/driverdbg.h>
19#endif
20
21#define TAG_SCSIPORT 'ISCS'
22
23/* Defines how many logical unit arrays will be in a device extension */
24#define LUS_NUMBER 8
25
26#define MAX_SG_LIST 17
27
28/* Flags */
29#define SCSI_PORT_DEVICE_BUSY 0x00001
30#define SCSI_PORT_LU_ACTIVE 0x00002
31#define SCSI_PORT_NOTIFICATION_NEEDED 0x00004
32#define SCSI_PORT_NEXT_REQUEST_READY 0x00008
33#define SCSI_PORT_FLUSH_ADAPTERS 0x00010
34#define SCSI_PORT_MAP_TRANSFER 0x00020
35#define SCSI_PORT_RESET 0x00080
36#define SCSI_PORT_RESET_REQUEST 0x00100
37#define SCSI_PORT_RESET_REPORTED 0x00200
38#define SCSI_PORT_REQUEST_PENDING 0x00800
39#define SCSI_PORT_DISCONNECT_ALLOWED 0x01000
40#define SCSI_PORT_DISABLE_INT_REQUESET 0x02000
41#define SCSI_PORT_DISABLE_INTERRUPTS 0x04000
42#define SCSI_PORT_ENABLE_INT_REQUEST 0x08000
43#define SCSI_PORT_TIMER_NEEDED 0x10000
44
45/* LUN Extension flags*/
46#define LUNEX_FROZEN_QUEUE 0x0001
47#define LUNEX_NEED_REQUEST_SENSE 0x0004
48#define LUNEX_BUSY 0x0008
49#define LUNEX_FULL_QUEUE 0x0010
50#define LUNEX_REQUEST_PENDING 0x0020
51#define SCSI_PORT_SCAN_IN_PROGRESS 0x8000
52
53// we need this to be compatible with ReactOS' classpnp (which is compiled with NTDDI_WIN8)
70
72{
78
79typedef struct _CONFIGURATION_INFO
80{
81 /* Identify info */
85
86 /* Registry related */
90
91 /* Features */
94
95 /* Parameters */
99
101{
103
109
110typedef struct _SCSI_SG_ADDRESS
111{
115
117{
122
124
125 /* DMA stuff */
128
130
131 /* Scatter-gather list */
135
137{
142
143// PDO device
145{
147
151
153
155
157
159
164
167
170
173
175
177
178 /* More data? */
179
180 UCHAR MiniportLunExtension[1]; /* must be the last entry */
182
183/* Structures for inquiries support */
184
185typedef struct _SCSI_BUS_INFO
186{
193
195{
196 ULONG Flags; /* Interrupt-time flags */
197 PSCSI_REQUEST_BLOCK_INFO CompletedRequests; /* Linked list of Srb info data */
203
204
205/* Only for interrupt data saving function */
207{
211
212/*
213 * SCSI_PORT_DEVICE_EXTENSION
214 *
215 * DESCRIPTION
216 * First part of the port objects device extension. The second
217 * part is the miniport-specific device extension.
218 */
219
220#ifdef _WIN64
221#define ALIGNAS_PTR DECLSPEC_ALIGN(8)
222#else
223#define ALIGNAS_PTR DECLSPEC_ALIGN(4)
224#endif
225
226// FDO
228{
230
234 PSCSI_BUS_INFO Buses; // children LUNs are stored here
237
241
245
246 KSPIN_LOCK IrqLock; /* Used when there are 2 irqs */
247 ULONG SequenceNumber; /* Global sequence number for packets */
252
255
258
260
262
264
265 /* SRB extension stuff*/
269
270 /* SRB information */
274
276
278
285
289
290 /* DMA related stuff */
296
297 /* Features */
303
308
311
313
315
320
321 // use the pointer alignment here, some miniport drivers rely on this
322 // moreover, it has to be the last member
325
326typedef struct _RESETBUS_PARAMS
327{
331
333{
338
342 _In_ PIRP Irp,
344{
346 if (ioStack->Parameters.DeviceIoControl.OutputBufferLength < Size)
347 {
348 Irp->IoStatus.Information = Size;
349 return FALSE;
350 }
351 return TRUE;
352}
353
357 _In_ PIRP Irp,
359{
361 if (ioStack->Parameters.DeviceIoControl.InputBufferLength < Size)
362 {
363 Irp->IoStatus.Information = Size;
364 return FALSE;
365 }
366 return TRUE;
367}
368
369// ioctl.c
370
372NTAPI
375 _In_ PIRP Irp);
376
377// fdo.c
378
379VOID
381 _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension);
382
385 _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension);
386
389 _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension);
390
393 _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension);
394
399
400// pdo.c
401
404 _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension);
405
408 _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
411 _In_ UCHAR Lun);
412
415 _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
416 _In_ PSCSI_PORT_LUN_EXTENSION LunExtension,
417 _In_ UCHAR QueueTag);
418
423
424// power.c
425
427
428// registry.c
429
430VOID
432 _Inout_ PCONFIGURATION_INFO ConfigInfo,
434
437 _Inout_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension);
438
441 _Inout_ PSCSI_PORT_LUN_EXTENSION LunExtension);
442
443// scsi.c
444
445VOID
447 _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
450
451IO_DPC_ROUTINE ScsiPortDpcForIsr;
453KSYNCHRONIZE_ROUTINE ScsiPortStartPacket;
454DRIVER_STARTIO ScsiPortStartIo;
455
456
457// scsiport.c
458
459KSERVICE_ROUTINE ScsiPortIsr;
460
462NTAPI
465 _In_ PIRP Irp,
468
470NTAPI
473 _In_ PIRP Irp,
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
unsigned char BOOLEAN
unsigned char UINT8
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR _In_ UCHAR Lun
Definition: classpnp.h:1315
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR PathId
Definition: classpnp.h:1313
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR TargetId
Definition: classpnp.h:1314
_In_ PIRP Irp
Definition: csq.h:116
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
VOID(NTAPI * PHW_DMA_STARTED)(IN PVOID DeviceExtension)
Definition: srb.h:462
BOOLEAN(NTAPI * PHW_INTERRUPT)(IN PVOID DeviceExtension)
Definition: srb.h:450
VOID(NTAPI * PHW_TIMER)(IN PVOID DeviceExtension)
Definition: srb.h:456
BOOLEAN(NTAPI * PHW_STARTIO)(IN PVOID DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb)
Definition: srb.h:443
BOOLEAN(NTAPI * PHW_RESET_BUS)(IN PVOID DeviceExtension, IN ULONG PathId)
Definition: srb.h:479
BOOLEAN(NTAPI * PHW_INITIALIZE)(IN PVOID DeviceExtension)
Definition: srb.h:437
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
DRIVER_DISPATCH(nfs41_FsdDispatch)
#define _Inout_
Definition: no_sal2.h:162
#define _Inout_opt_
Definition: no_sal2.h:216
#define _In_
Definition: no_sal2.h:158
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:31
long LONG
Definition: pedump.c:60
unsigned short USHORT
Definition: pedump.c:61
VOID SpiGetNextRequestFromLun(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, _Inout_ PSCSI_PORT_LUN_EXTENSION LunExtension, _Inout_opt_ PKIRQL OldIrql)
Definition: scsi.c:342
DRIVER_DISPATCH ScsiPortDispatchPower
Definition: scsiport.h:426
DRIVER_DISPATCH ScsiPortDispatchScsi
Definition: scsiport.h:452
struct _SCSI_PORT_COMMON_EXTENSION * PSCSI_PORT_COMMON_EXTENSION
IO_ALLOCATION_ACTION NTAPI SpiAdapterControl(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ PVOID MapRegisterBase, _In_ PVOID Context)
struct _SCSI_PORT_DEVICE_EXTENSION SCSI_PORT_DEVICE_EXTENSION
VOID SpiInitOpenKeys(_Inout_ PCONFIGURATION_INFO ConfigInfo, _In_ PSCSI_PORT_DRIVER_EXTENSION DriverExtension)
Definition: registry.c:18
struct _SCSI_PORT_LUN_EXTENSION * PSCSI_PORT_LUN_EXTENSION
enum _SCSI_PORT_TIMER_STATES SCSI_PORT_TIMER_STATES
struct _STORAGE_ADAPTER_DESCRIPTOR_WIN8 * PSTORAGE_ADAPTER_DESCRIPTOR_WIN8
struct _SCSI_REQUEST_BLOCK_INFO * PSCSI_REQUEST_BLOCK_INFO
struct _SCSI_PORT_SAVE_INTERRUPT SCSI_PORT_SAVE_INTERRUPT
#define ALIGNAS_PTR
Definition: scsiport.h:223
#define MAX_SG_LIST
Definition: scsiport.h:26
KSERVICE_ROUTINE ScsiPortIsr
Definition: scsiport.h:459
DRIVER_STARTIO ScsiPortStartIo
Definition: scsiport.h:454
struct _SCSI_SG_ADDRESS SCSI_SG_ADDRESS
struct _SCSI_PORT_SAVE_INTERRUPT * PSCSI_PORT_SAVE_INTERRUPT
KSYNCHRONIZE_ROUTINE ScsiPortStartPacket
Definition: scsiport.h:453
IO_ALLOCATION_ACTION NTAPI ScsiPortAllocateAdapterChannel(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ PVOID MapRegisterBase, _In_ PVOID Context)
_SCSI_PORT_TIMER_STATES
Definition: scsiport.h:72
@ IDETimerCmdWait
Definition: scsiport.h:74
@ IDETimerResetWaitForDrdyAssert
Definition: scsiport.h:76
@ IDETimerIdle
Definition: scsiport.h:73
@ IDETimerResetWaitForBusyNegate
Definition: scsiport.h:75
NTSTATUS RegistryInitAdapterKey(_Inout_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:127
struct _SCSI_PORT_INTERRUPT_DATA SCSI_PORT_INTERRUPT_DATA
PDEVICE_OBJECT PdoCreateLunDevice(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: pdo.c:18
struct _CONFIGURATION_INFO CONFIGURATION_INFO
NTSTATUS RegistryInitLunKey(_Inout_ PSCSI_PORT_LUN_EXTENSION LunExtension)
Definition: registry.c:359
struct _SCSI_PORT_DEVICE_BASE SCSI_PORT_DEVICE_BASE
struct _SCSI_PORT_DEVICE_BASE * PSCSI_PORT_DEVICE_BASE
struct _SCSIPORT_DRIVER_EXTENSION SCSI_PORT_DRIVER_EXTENSION
FORCEINLINE BOOLEAN VerifyIrpInBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
Definition: scsiport.h:356
struct _SCSI_REQUEST_BLOCK_INFO SCSI_REQUEST_BLOCK_INFO
struct _SCSIPORT_DRIVER_EXTENSION * PSCSI_PORT_DRIVER_EXTENSION
struct _SCSI_BUS_INFO SCSI_BUS_INFO
IO_DPC_ROUTINE ScsiPortDpcForIsr
Definition: scsiport.h:451
PSCSI_REQUEST_BLOCK_INFO SpiGetSrbData(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_PORT_LUN_EXTENSION LunExtension, _In_ UCHAR QueueTag)
Definition: pdo.c:102
struct _SCSI_BUS_INFO * PSCSI_BUS_INFO
FORCEINLINE BOOLEAN VerifyIrpOutBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
Definition: scsiport.h:341
NTSTATUS FdoDispatchPnp(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
Definition: fdo.c:758
NTSTATUS PdoDispatchPnp(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
Definition: pdo.c:554
struct _CONFIGURATION_INFO * PCONFIGURATION_INFO
struct _RESETBUS_PARAMS * PRESETBUS_PARAMS
struct _SCSI_SG_ADDRESS * PSCSI_SG_ADDRESS
NTSTATUS FdoCallHWInitialize(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
Calls HwInitialize routine of the miniport and sets up interrupts Should be called inside ScsiPortIni...
Definition: fdo.c:366
NTSTATUS FdoRemoveAdapter(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:510
NTSTATUS FdoStartAdapter(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:609
NTSTATUS NTAPI ScsiPortDeviceControl(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: ioctl.c:404
struct _SCSI_PORT_DEVICE_EXTENSION * PSCSI_PORT_DEVICE_EXTENSION
PSCSI_PORT_LUN_EXTENSION GetLunByPath(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, _In_ UCHAR PathId, _In_ UCHAR TargetId, _In_ UCHAR Lun)
Definition: pdo.c:68
struct _SCSI_PORT_INTERRUPT_DATA * PSCSI_PORT_INTERRUPT_DATA
struct _STORAGE_ADAPTER_DESCRIPTOR_WIN8 STORAGE_ADAPTER_DESCRIPTOR_WIN8
struct _RESETBUS_PARAMS RESETBUS_PARAMS
VOID FdoScanAdapter(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:222
struct _SCSI_PORT_COMMON_EXTENSION SCSI_PORT_COMMON_EXTENSION
struct _SCSI_PORT_LUN_EXTENSION SCSI_PORT_LUN_EXTENSION
BOOLEAN DisableTaggedQueueing
Definition: scsiport.h:92
ULONG LastAdapterNumber
Definition: scsiport.h:83
PACCESS_RANGE AccessRanges
Definition: scsiport.h:97
BOOLEAN DisableMultipleLun
Definition: scsiport.h:93
union _IO_STACK_LOCATION::@1581 Parameters
struct _IO_STACK_LOCATION::@1581::@1582 DeviceIoControl
Definition: ketypes.h:699
Definition: typedefs.h:120
PSCSI_PORT_DEVICE_EXTENSION DeviceExtension
Definition: scsiport.h:329
PDRIVER_OBJECT DriverObject
Definition: scsiport.h:334
UNICODE_STRING RegistryPath
Definition: scsiport.h:335
HANDLE RegistryMapKey
Definition: scsiport.h:191
UCHAR BusIdentifier
Definition: scsiport.h:190
UCHAR TargetsCount
Definition: scsiport.h:189
UCHAR LogicalUnitsCount
Definition: scsiport.h:188
LIST_ENTRY LunsListHead
Definition: scsiport.h:187
PDEVICE_OBJECT LowerDevice
Definition: scsiport.h:139
PDEVICE_OBJECT DeviceObject
Definition: scsiport.h:138
SCSI_PHYSICAL_ADDRESS IoAddress
Definition: scsiport.h:106
ALIGNAS_PTR UCHAR MiniPortDeviceExtension[]
Definition: scsiport.h:323
SCSI_PORT_TIMER_STATES TimerState
Definition: scsiport.h:253
SENSE_DATA InternalSenseData
Definition: scsiport.h:288
PHW_DMA_STARTED HwDmaStarted
Definition: scsiport.h:283
SCSI_PORT_COMMON_EXTENSION Common
Definition: scsiport.h:229
PPORT_CONFIGURATION_INFORMATION PortConfig
Definition: scsiport.h:233
SCSI_PORT_INTERRUPT_DATA InterruptData
Definition: scsiport.h:263
SCSI_REQUEST_BLOCK InternalSrb
Definition: scsiport.h:287
PSCSI_REQUEST_BLOCK_INFO FreeSrbInfo
Definition: scsiport.h:272
UNICODE_STRING DeviceName
Definition: scsiport.h:316
PHW_RESET_BUS HwResetBus
Definition: scsiport.h:282
UNICODE_STRING InterfaceName
Definition: scsiport.h:317
IO_SCSI_CAPABILITIES PortCapabilities
Definition: scsiport.h:275
PHW_INTERRUPT HwInterrupt
Definition: scsiport.h:281
PHW_INITIALIZE HwInitialize
Definition: scsiport.h:279
PMAPPED_ADDRESS MappedAddressList
Definition: scsiport.h:259
PSCSI_BUS_INFO Buses
Definition: scsiport.h:234
PSCSI_REQUEST_BLOCK OriginalSrb
Definition: scsiport.h:286
PHYSICAL_ADDRESS PhysicalAddress
Definition: scsiport.h:304
PADAPTER_OBJECT AdapterObject
Definition: scsiport.h:291
PCONTROLLER_OBJECT ControllerObject
Definition: scsiport.h:277
PSCSI_REQUEST_BLOCK_INFO SrbInfo
Definition: scsiport.h:271
PSCSI_PORT_LUN_EXTENSION ReadyLun
Definition: scsiport.h:199
PSCSI_PORT_LUN_EXTENSION CompletedAbort
Definition: scsiport.h:198
PSCSI_REQUEST_BLOCK_INFO CompletedRequests
Definition: scsiport.h:197
UCHAR MiniportLunExtension[1]
Definition: scsiport.h:180
KDEVICE_QUEUE DeviceQueue
Definition: scsiport.h:160
SCSI_PORT_COMMON_EXTENSION Common
Definition: scsiport.h:146
SCSI_REQUEST_BLOCK_INFO SrbInfo
Definition: scsiport.h:174
INQUIRYDATA InquiryData
Definition: scsiport.h:158
struct _SCSI_PORT_LUN_EXTENSION * CompletedAbortRequests
Definition: scsiport.h:172
struct _SCSI_PORT_LUN_EXTENSION * ReadyLun
Definition: scsiport.h:171
struct _SCSI_PORT_DEVICE_EXTENSION * DeviceExtension
Definition: scsiport.h:209
PSCSI_PORT_INTERRUPT_DATA InterruptData
Definition: scsiport.h:208
SCSI_SG_ADDRESS ScatterGatherList[MAX_SG_LIST]
Definition: scsiport.h:133
struct _SCSI_REQUEST_BLOCK_INFO * CompletedRequests
Definition: scsiport.h:129
PSCSI_REQUEST_BLOCK Srb
Definition: scsiport.h:119
PSCSI_SG_ADDRESS ScatterGather
Definition: scsiport.h:132
PHYSICAL_ADDRESS PhysicalAddress
Definition: scsiport.h:112
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG
Definition: typedefs.h:59
char * PCHAR
Definition: typedefs.h:51
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:379
#define FORCEINLINE
Definition: wdftypes.h:67
_Inout_ struct _IRP _In_ PVOID MapRegisterBase
Definition: iotypes.h:213
enum _IO_ALLOCATION_ACTION IO_ALLOCATION_ACTION
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:778
unsigned char UCHAR
Definition: xmlstorage.h:181