ReactOS  0.4.15-dev-1623-g66cf1d2
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 
79 typedef struct _CONFIGURATION_INFO
80 {
81  /* Identify info */
85 
86  /* Registry related */
90 
91  /* Features */
94 
95  /* Parameters */
99 
101 {
103 
109 
110 typedef 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 
185 typedef 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 
326 typedef struct _RESETBUS_PARAMS
327 {
331 
333 {
338 
340 BOOLEAN
342  _In_ PIRP Irp,
343  _In_ SIZE_T Size)
344 {
346  if (ioStack->Parameters.DeviceIoControl.OutputBufferLength < Size)
347  {
348  Irp->IoStatus.Information = Size;
349  return FALSE;
350  }
351  return TRUE;
352 }
353 
355 BOOLEAN
357  _In_ PIRP Irp,
358  _In_ SIZE_T Size)
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 
371 NTSTATUS
372 NTAPI
375  _In_ PIRP Irp);
376 
377 // fdo.c
378 
379 VOID
381  _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension);
382 
383 NTSTATUS
385  _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension);
386 
387 NTSTATUS
389  _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension);
390 
391 NTSTATUS
393  _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension);
394 
395 NTSTATUS
398  _Inout_ PIRP Irp);
399 
400 // pdo.c
401 
404  _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension);
405 
408  _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
409  _In_ UCHAR PathId,
411  _In_ UCHAR Lun);
412 
415  _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
416  _In_ PSCSI_PORT_LUN_EXTENSION LunExtension,
417  _In_ UCHAR QueueTag);
418 
419 NTSTATUS
422  _Inout_ PIRP Irp);
423 
424 // power.c
425 
427 
428 // registry.c
429 
430 VOID
432  _Inout_ PCONFIGURATION_INFO ConfigInfo,
434 
435 NTSTATUS
437  _Inout_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension);
438 
439 NTSTATUS
441  _Inout_ PSCSI_PORT_LUN_EXTENSION LunExtension);
442 
443 // scsi.c
444 
445 VOID
447  _In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension,
448  _Inout_ PSCSI_PORT_LUN_EXTENSION LunExtension,
450 
451 IO_DPC_ROUTINE ScsiPortDpcForIsr;
453 KSYNCHRONIZE_ROUTINE ScsiPortStartPacket;
454 DRIVER_STARTIO ScsiPortStartIo;
455 
456 
457 // scsiport.c
458 
459 KSERVICE_ROUTINE ScsiPortIsr;
460 
462 NTAPI
465  _In_ PIRP Irp,
467  _In_ PVOID Context);
468 
470 NTAPI
473  _In_ PIRP Irp,
475  _In_ PVOID Context);
PCONTROLLER_OBJECT ControllerObject
Definition: scsiport.h:277
struct _SCSI_REQUEST_BLOCK_INFO * CompletedRequests
Definition: scsiport.h:129
struct _RESETBUS_PARAMS * PRESETBUS_PARAMS
signed char * PCHAR
Definition: retypes.h:7
VOID SpiInitOpenKeys(_Inout_ PCONFIGURATION_INFO ConfigInfo, _In_ PSCSI_PORT_DRIVER_EXTENSION DriverExtension)
Definition: registry.c:18
enum _IO_ALLOCATION_ACTION IO_ALLOCATION_ACTION
SCSI_PORT_COMMON_EXTENSION Common
Definition: scsiport.h:229
struct _SCSI_BUS_INFO * PSCSI_BUS_INFO
KDEVICE_QUEUE DeviceQueue
Definition: scsiport.h:160
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR _In_ UCHAR Lun
Definition: classpnp.h:1310
PSCSI_PORT_DEVICE_EXTENSION DeviceExtension
Definition: scsiport.h:329
BOOLEAN DisableMultipleLun
Definition: scsiport.h:93
PDEVICE_OBJECT DeviceObject
Definition: scsiport.h:138
KSERVICE_ROUTINE ScsiPortIsr
Definition: scsiport.h:459
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR PathId
Definition: classpnp.h:1310
BOOLEAN(NTAPI * PHW_RESET_BUS)(IN PVOID DeviceExtension, IN ULONG PathId)
Definition: srb.h:471
#define TRUE
Definition: types.h:120
SCSI_PHYSICAL_ADDRESS IoAddress
Definition: scsiport.h:106
UCHAR MiniportLunExtension[1]
Definition: scsiport.h:180
_In_ ULONG _In_ BOOLEAN _In_ ULONG _In_ UCHAR _In_ UCHAR TargetId
Definition: classpnp.h:1310
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFINTERRUPT * Interrupt
Definition: wdfinterrupt.h:372
struct _SCSI_SG_ADDRESS SCSI_SG_ADDRESS
KSYNCHRONIZE_ROUTINE ScsiPortStartPacket
Definition: scsiport.h:453
PSCSI_REQUEST_BLOCK_INFO SpiGetSrbData(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, _In_ PSCSI_PORT_LUN_EXTENSION LunExtension, _In_ UCHAR QueueTag)
Definition: pdo.c:102
PDEVICE_OBJECT LowerDevice
Definition: scsiport.h:139
UNICODE_STRING DeviceName
Definition: scsiport.h:316
#define MAX_SG_LIST
Definition: scsiport.h:26
LONG NTSTATUS
Definition: precomp.h:26
PHW_INITIALIZE HwInitialize
Definition: scsiport.h:279
struct _SCSI_PORT_DEVICE_BASE * PSCSI_PORT_DEVICE_BASE
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
PSCSI_REQUEST_BLOCK_INFO CompletedRequests
Definition: scsiport.h:197
struct _SCSIPORT_DRIVER_EXTENSION SCSI_PORT_DRIVER_EXTENSION
struct _SCSI_PORT_LUN_EXTENSION * PSCSI_PORT_LUN_EXTENSION
_SCSI_PORT_TIMER_STATES
Definition: scsiport.h:71
IO_DPC_ROUTINE ScsiPortDpcForIsr
Definition: scsiport.h:451
IO_ALLOCATION_ACTION NTAPI SpiAdapterControl(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ PVOID MapRegisterBase, _In_ PVOID Context)
PADAPTER_OBJECT AdapterObject
Definition: scsiport.h:291
struct _SCSIPORT_DRIVER_EXTENSION * PSCSI_PORT_DRIVER_EXTENSION
DRIVER_DISPATCH ScsiPortDispatchScsi
Definition: scsiport.h:452
ALIGNAS_PTR UCHAR MiniPortDeviceExtension[]
Definition: scsiport.h:323
struct _SCSI_PORT_LUN_EXTENSION SCSI_PORT_LUN_EXTENSION
VOID SpiGetNextRequestFromLun(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension, _Inout_ PSCSI_PORT_LUN_EXTENSION LunExtension, _Inout_opt_ PKIRQL OldIrql)
Definition: scsi.c:342
NTSTATUS RegistryInitLunKey(_Inout_ PSCSI_PORT_LUN_EXTENSION LunExtension)
Definition: registry.c:359
struct _SCSI_PORT_DEVICE_BASE SCSI_PORT_DEVICE_BASE
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
struct _RESETBUS_PARAMS RESETBUS_PARAMS
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
BOOLEAN(NTAPI * PHW_INITIALIZE)(IN PVOID DeviceExtension)
Definition: srb.h:429
long LONG
Definition: pedump.c:60
PSCSI_BUS_INFO Buses
Definition: scsiport.h:234
struct _STORAGE_ADAPTER_DESCRIPTOR_WIN8 STORAGE_ADAPTER_DESCRIPTOR_WIN8
PSCSI_REQUEST_BLOCK_INFO SrbInfo
Definition: scsiport.h:271
unsigned char BOOLEAN
struct _SCSI_REQUEST_BLOCK_INFO * PSCSI_REQUEST_BLOCK_INFO
PACCESS_RANGE AccessRanges
Definition: scsiport.h:97
PSCSI_SG_ADDRESS ScatterGather
Definition: scsiport.h:132
struct _CONFIGURATION_INFO CONFIGURATION_INFO
PMAPPED_ADDRESS MappedAddressList
Definition: scsiport.h:259
NTSTATUS FdoStartAdapter(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:605
NTSTATUS PdoDispatchPnp(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
Definition: pdo.c:554
PSCSI_REQUEST_BLOCK_INFO FreeSrbInfo
Definition: scsiport.h:272
UCHAR LogicalUnitsCount
Definition: scsiport.h:188
PPORT_CONFIGURATION_INFORMATION PortConfig
Definition: scsiport.h:233
struct _SCSI_PORT_DEVICE_EXTENSION * PSCSI_PORT_DEVICE_EXTENSION
SCSI_REQUEST_BLOCK_INFO SrbInfo
Definition: scsiport.h:174
NTSTATUS FdoRemoveAdapter(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:506
struct _SCSI_PORT_INTERRUPT_DATA SCSI_PORT_INTERRUPT_DATA
BOOLEAN(NTAPI * PHW_STARTIO)(IN PVOID DeviceExtension, IN PSCSI_REQUEST_BLOCK Srb)
Definition: srb.h:435
IO_ALLOCATION_ACTION NTAPI ScsiPortAllocateAdapterChannel(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ PVOID MapRegisterBase, _In_ PVOID Context)
IO_SCSI_CAPABILITIES PortCapabilities
Definition: scsiport.h:275
PSCSI_PORT_INTERRUPT_DATA InterruptData
Definition: scsiport.h:208
struct _SCSI_PORT_COMMON_EXTENSION SCSI_PORT_COMMON_EXTENSION
#define _Inout_
Definition: no_sal2.h:162
struct _SCSI_PORT_SAVE_INTERRUPT SCSI_PORT_SAVE_INTERRUPT
unsigned char UCHAR
Definition: xmlstorage.h:181
PSCSI_PORT_LUN_EXTENSION CompletedAbort
Definition: scsiport.h:198
_Requires_lock_held_ Interrupt _Releases_lock_ Interrupt _In_ _IRQL_restores_ KIRQL OldIrql
Definition: kefuncs.h:790
Definition: ketypes.h:687
PHYSICAL_ADDRESS PhysicalAddress
Definition: scsiport.h:304
NTSTATUS FdoDispatchPnp(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp)
Definition: fdo.c:709
struct _CONFIGURATION_INFO * PCONFIGURATION_INFO
VOID FdoScanAdapter(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: fdo.c:222
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
struct _SCSI_PORT_LUN_EXTENSION * CompletedAbortRequests
Definition: scsiport.h:172
Definition: typedefs.h:119
struct _SCSI_PORT_DEVICE_EXTENSION SCSI_PORT_DEVICE_EXTENSION
struct _SCSI_REQUEST_BLOCK_INFO SCSI_REQUEST_BLOCK_INFO
SCSI_PORT_TIMER_STATES TimerState
Definition: scsiport.h:253
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:362
HANDLE RegistryMapKey
Definition: scsiport.h:191
PPCI_DRIVER_EXTENSION DriverExtension
Definition: pci.c:41
DRIVER_DISPATCH(nfs41_FsdDispatch)
PSCSI_REQUEST_BLOCK Srb
Definition: scsiport.h:119
struct _SCSI_PORT_INTERRUPT_DATA * PSCSI_PORT_INTERRUPT_DATA
PDRIVER_OBJECT DriverObject
Definition: scsiport.h:334
PHYSICAL_ADDRESS PhysicalAddress
Definition: scsiport.h:112
SCSI_SG_ADDRESS ScatterGatherList[MAX_SG_LIST]
Definition: scsiport.h:133
enum _SCSI_PORT_TIMER_STATES SCSI_PORT_TIMER_STATES
#define _In_
Definition: no_sal2.h:158
struct _SCSI_SG_ADDRESS * PSCSI_SG_ADDRESS
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2789
ULONG_PTR SIZE_T
Definition: typedefs.h:80
ULONG LastAdapterNumber
Definition: scsiport.h:83
INQUIRYDATA InquiryData
Definition: scsiport.h:158
_Inout_ struct _IRP _In_ PVOID MapRegisterBase
Definition: iotypes.h:212
unsigned short USHORT
Definition: pedump.c:61
UNICODE_STRING InterfaceName
Definition: scsiport.h:317
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define FORCEINLINE
Definition: wdftypes.h:67
NTSTATUS RegistryInitAdapterKey(_Inout_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: registry.c:127
BOOLEAN(NTAPI * PHW_INTERRUPT)(IN PVOID DeviceExtension)
Definition: srb.h:442
UCHAR TargetsCount
Definition: scsiport.h:189
struct _SCSI_PORT_LUN_EXTENSION * ReadyLun
Definition: scsiport.h:171
FORCEINLINE BOOLEAN VerifyIrpOutBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
Definition: scsiport.h:341
SCSI_PORT_COMMON_EXTENSION Common
Definition: scsiport.h:146
PHW_DMA_STARTED HwDmaStarted
Definition: scsiport.h:283
DRIVER_STARTIO ScsiPortStartIo
Definition: scsiport.h:454
SCSI_REQUEST_BLOCK InternalSrb
Definition: scsiport.h:287
NTSTATUS NTAPI ScsiPortDeviceControl(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp)
Definition: ioctl.c:404
LIST_ENTRY LunsListHead
Definition: scsiport.h:187
struct _SCSI_PORT_SAVE_INTERRUPT * PSCSI_PORT_SAVE_INTERRUPT
PDEVICE_OBJECT PdoCreateLunDevice(_In_ PSCSI_PORT_DEVICE_EXTENSION DeviceExtension)
Definition: pdo.c:18
struct _SCSI_BUS_INFO SCSI_BUS_INFO
struct _STORAGE_ADAPTER_DESCRIPTOR_WIN8 * PSTORAGE_ADAPTER_DESCRIPTOR_WIN8
VOID(NTAPI * PHW_TIMER)(IN PVOID DeviceExtension)
Definition: srb.h:448
PSCSI_PORT_LUN_EXTENSION ReadyLun
Definition: scsiport.h:199
unsigned int ULONG
Definition: retypes.h:1
PHW_INTERRUPT HwInterrupt
Definition: scsiport.h:281
FORCEINLINE BOOLEAN VerifyIrpInBufferSize(_In_ PIRP Irp, _In_ SIZE_T Size)
Definition: scsiport.h:356
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 _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3124
DRIVER_DISPATCH ScsiPortDispatchPower
Definition: scsiport.h:426
PSCSI_REQUEST_BLOCK OriginalSrb
Definition: scsiport.h:286
#define ALIGNAS_PTR
Definition: scsiport.h:223
unsigned char UINT8
BOOLEAN DisableTaggedQueueing
Definition: scsiport.h:92
SCSI_PORT_INTERRUPT_DATA InterruptData
Definition: scsiport.h:263
UCHAR BusIdentifier
Definition: scsiport.h:190
struct _SCSI_PORT_DEVICE_EXTENSION * DeviceExtension
Definition: scsiport.h:209
PHW_RESET_BUS HwResetBus
Definition: scsiport.h:282
UNICODE_STRING RegistryPath
Definition: scsiport.h:335
struct _SCSI_PORT_COMMON_EXTENSION * PSCSI_PORT_COMMON_EXTENSION
VOID(NTAPI * PHW_DMA_STARTED)(IN PVOID DeviceExtension)
Definition: srb.h:454
#define _Inout_opt_
Definition: no_sal2.h:216
SENSE_DATA InternalSenseData
Definition: scsiport.h:288