[SCSIPORT]
[reactos.git] / reactos / drivers / storage / scsiport / scsiport_int.h
index 5091027..9b6899f 100644 (file)
 #define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
 #endif
 
-#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
+#define TAG_SCSIPORT 'ISCS'
+
+/* Defines how many logical unit arrays will be in a device extension */
+#define LUS_NUMBER 8
+
+#define MAX_SG_LIST 17
+
+/* Flags */
+#define SCSI_PORT_DEVICE_BUSY         0x0001
+#define SCSI_PORT_LU_ACTIVE           0x0002
+#define SCSI_PORT_NOTIFICATION_NEEDED 0x0004
+#define SCSI_PORT_NEXT_REQUEST_READY  0x0008
+#define SCSI_PORT_FLUSH_ADAPTERS      0x0010
+#define SCSI_PORT_MAP_TRANSFER        0x0020
+#define SCSI_PORT_RESET               0x0080
+#define SCSI_PORT_RESET_REQUEST       0x0100
+#define SCSI_PORT_RESET_REPORTED      0x0200
+#define SCSI_PORT_REQUEST_PENDING     0x0800
+#define SCSI_PORT_DISCONNECT_ALLOWED  0x1000
+#define SCSI_PORT_DISABLE_INT_REQUESET 0x2000
+#define SCSI_PORT_DISABLE_INTERRUPTS  0x4000
+#define SCSI_PORT_ENABLE_INT_REQUEST  0x8000
+#define SCSI_PORT_TIMER_NEEDED        0x10000
+
+/* LUN Extension flags*/
+#define LUNEX_FROZEN_QUEUE        0x0001
+#define LUNEX_NEED_REQUEST_SENSE  0x0004
+#define LUNEX_BUSY                0x0008
+#define LUNEX_FULL_QUEUE          0x0010
+#define LUNEX_REQUEST_PENDING     0x0020
+#define SCSI_PORT_SCAN_IN_PROGRESS    0x8000
+
 
 typedef enum _SCSI_PORT_TIMER_STATES
 {
@@ -24,6 +55,26 @@ typedef enum _SCSI_PORT_TIMER_STATES
   IDETimerResetWaitForDrdyAssert
 } SCSI_PORT_TIMER_STATES;
 
+typedef struct _CONFIGURATION_INFO
+{
+    /* Identify info */
+    ULONG AdapterNumber;
+    ULONG LastAdapterNumber;
+    ULONG BusNumber;
+
+    /* Registry related */
+    HANDLE BusKey;
+    HANDLE ServiceKey;
+    HANDLE DeviceKey;
+
+    /* Features */
+    BOOLEAN DisableTaggedQueueing;
+    BOOLEAN DisableMultipleLun;
+
+    /* Parameters */
+    PVOID Parameter;
+    PACCESS_RANGE AccessRanges;
+} CONFIGURATION_INFO, *PCONFIGURATION_INFO;
 
 typedef struct _SCSI_PORT_DEVICE_BASE
 {
@@ -35,31 +86,113 @@ typedef struct _SCSI_PORT_DEVICE_BASE
   ULONG SystemIoBusNumber;
 } SCSI_PORT_DEVICE_BASE, *PSCSI_PORT_DEVICE_BASE;
 
+typedef struct _SCSI_SG_ADDRESS
+{
+    PHYSICAL_ADDRESS PhysicalAddress;
+    ULONG Length;
+} SCSI_SG_ADDRESS, *PSCSI_SG_ADDRESS;
 
-typedef struct _SCSI_PORT_LUN_EXTENSION
+typedef struct _SCSI_REQUEST_BLOCK_INFO
 {
-  LIST_ENTRY List;
+    LIST_ENTRY Requests;
+    PSCSI_REQUEST_BLOCK Srb;
+    PCHAR DataOffset;
+    PVOID SaveSenseRequest;
+
+    ULONG SequenceNumber;
+
+    /* DMA stuff */
+    PVOID BaseOfMapRegister;
+    ULONG NumberOfMapRegisters;
 
+    struct _SCSI_REQUEST_BLOCK_INFO *CompletedRequests;
+
+    /* Scatter-gather list */
+    PSCSI_SG_ADDRESS ScatterGather;
+    SCSI_SG_ADDRESS ScatterGatherList[MAX_SG_LIST];
+} SCSI_REQUEST_BLOCK_INFO, *PSCSI_REQUEST_BLOCK_INFO;
+
+typedef struct _SCSI_PORT_LUN_EXTENSION
+{
   UCHAR PathId;
   UCHAR TargetId;
   UCHAR Lun;
 
+  ULONG Flags;
+
+  struct _SCSI_PORT_LUN_EXTENSION *Next;
+
   BOOLEAN DeviceClaimed;
   PDEVICE_OBJECT DeviceObject;
 
   INQUIRYDATA InquiryData;
 
-  ULONG PendingIrpCount;
-  ULONG ActiveIrpCount;
+  KDEVICE_QUEUE DeviceQueue;
+  ULONG SortKey;
+  ULONG QueueCount;
+  ULONG MaxQueueCount;
 
-  PIRP NextIrp;
-  ULONG Flags;
+  ULONG AttemptCount;
+  LONG RequestTimeout;
+
+  PIRP BusyRequest;
+  PIRP PendingRequest;
+
+  struct _SCSI_PORT_LUN_EXTENSION *ReadyLun;
+  struct _SCSI_PORT_LUN_EXTENSION *CompletedAbortRequests;
+
+  SCSI_REQUEST_BLOCK_INFO SrbInfo;
 
   /* More data? */
 
   UCHAR MiniportLunExtension[1]; /* must be the last entry */
 } SCSI_PORT_LUN_EXTENSION, *PSCSI_PORT_LUN_EXTENSION;
 
+/* Structures for inquiries support */
+
+typedef struct _SCSI_LUN_INFO
+{
+    UCHAR PathId;
+    UCHAR TargetId;
+    UCHAR Lun;
+    BOOLEAN DeviceClaimed;
+    PVOID DeviceObject;
+    struct _SCSI_LUN_INFO *Next;
+    UCHAR InquiryData[INQUIRYDATABUFFERSIZE];
+} SCSI_LUN_INFO, *PSCSI_LUN_INFO;
+
+typedef struct _SCSI_BUS_SCAN_INFO
+{
+    USHORT Length;
+    UCHAR LogicalUnitsCount;
+    UCHAR BusIdentifier;
+    PSCSI_LUN_INFO LunInfo;
+} SCSI_BUS_SCAN_INFO, *PSCSI_BUS_SCAN_INFO;
+
+typedef struct _BUSES_CONFIGURATION_INFORMATION
+{
+    UCHAR NumberOfBuses;
+    PSCSI_BUS_SCAN_INFO BusScanInfo[1];
+} BUSES_CONFIGURATION_INFORMATION, *PBUSES_CONFIGURATION_INFORMATION;
+
+
+typedef struct _SCSI_PORT_INTERRUPT_DATA
+{
+    ULONG Flags; /* Interrupt-time flags */
+    PSCSI_REQUEST_BLOCK_INFO CompletedRequests; /* Linked list of Srb info data */
+    PSCSI_PORT_LUN_EXTENSION CompletedAbort;
+    PSCSI_PORT_LUN_EXTENSION ReadyLun;
+    PHW_TIMER HwScsiTimer;
+    ULONG MiniportTimerValue;
+} SCSI_PORT_INTERRUPT_DATA, *PSCSI_PORT_INTERRUPT_DATA;
+
+
+/* Only for interrupt data saving function */
+typedef struct _SCSI_PORT_SAVE_INTERRUPT
+{
+    PSCSI_PORT_INTERRUPT_DATA InterruptData;
+    struct _SCSI_PORT_DEVICE_EXTENSION *DeviceExtension;
+} SCSI_PORT_SAVE_INTERRUPT, *PSCSI_PORT_SAVE_INTERRUPT;
 
 /*
  * SCSI_PORT_DEVICE_EXTENSION
@@ -74,63 +207,93 @@ typedef struct _SCSI_PORT_DEVICE_EXTENSION
   ULONG Length;
   ULONG MiniPortExtensionSize;
   PPORT_CONFIGURATION_INFORMATION PortConfig;
+  PBUSES_CONFIGURATION_INFORMATION BusesConfig;
+  PVOID NonCachedExtension;
   ULONG PortNumber;
 
-  KSPIN_LOCK Lock;
+  LONG ActiveRequestCounter;
+  ULONG SrbFlags;
   ULONG Flags;
 
+  ULONG BusNum;
+  ULONG MaxTargedIds;
+  ULONG MaxLunCount;
+
+  KSPIN_LOCK IrqLock; /* Used when there are 2 irqs */
+  ULONG SequenceNumber; /* Global sequence number for packets */
+  KSPIN_LOCK SpinLock;
   PKINTERRUPT Interrupt;
+  PIRP                   CurrentIrp;
+  ULONG IrpFlags;
 
   SCSI_PORT_TIMER_STATES TimerState;
   LONG                   TimerCount;
 
-  LIST_ENTRY DeviceBaseListHead;
+  KTIMER MiniportTimer;
+  KDPC MiniportTimerDpc;
+
+  PMAPPED_ADDRESS MappedAddressList;
 
   ULONG LunExtensionSize;
-  LIST_ENTRY LunExtensionListHead;
+  PSCSI_PORT_LUN_EXTENSION LunExtensionList[LUS_NUMBER];
+
+  SCSI_PORT_INTERRUPT_DATA InterruptData;
 
+  /* SRB extension stuff*/
   ULONG SrbExtensionSize;
+  PVOID SrbExtensionBuffer;
+  PVOID FreeSrbExtensions;
 
-  PIO_SCSI_CAPABILITIES PortCapabilities;
+  /* SRB information */
+  PSCSI_REQUEST_BLOCK_INFO SrbInfo;
+  PSCSI_REQUEST_BLOCK_INFO FreeSrbInfo;
+  ULONG SrbDataCount;
+
+  IO_SCSI_CAPABILITIES PortCapabilities;
 
   PDEVICE_OBJECT DeviceObject;
   PCONTROLLER_OBJECT ControllerObject;
 
+  PHW_INITIALIZE HwInitialize;
   PHW_STARTIO HwStartIo;
   PHW_INTERRUPT HwInterrupt;
+  PHW_RESET_BUS HwResetBus;
+  PHW_DMA_STARTED HwDmaStarted;
+  PHW_TIMER HwScsiTimer;
 
+  PSCSI_REQUEST_BLOCK OriginalSrb;
+  SCSI_REQUEST_BLOCK InternalSrb;
+  SENSE_DATA InternalSenseData;
 
   /* DMA related stuff */
   PADAPTER_OBJECT AdapterObject;
   ULONG MapRegisterCount;
+  BOOLEAN MapBuffers;
+  BOOLEAN MapRegisters;
+  PVOID MapRegisterBase;
+
+  /* Features */
+  BOOLEAN CachesData;
+  BOOLEAN SupportsTaggedQueuing;
+  BOOLEAN SupportsAutoSense;
+  BOOLEAN MultipleReqsPerLun;
+  BOOLEAN ReceiveEvent;
 
   PHYSICAL_ADDRESS PhysicalAddress;
-  PVOID VirtualAddress;
-  RTL_BITMAP SrbExtensionAllocMap;
-  ULONG MaxSrbExtensions;
-  ULONG CurrentSrbExtensions;
   ULONG CommonBufferLength;
+  ULONG InterruptLevel;
+  ULONG IoAddress;
+
+  BOOLEAN NeedSrbExtensionAlloc;
+  BOOLEAN NeedSrbDataAlloc;
 
-  LIST_ENTRY PendingIrpListHead;
-  PIRP NextIrp;
-  ULONG PendingIrpCount;
-  ULONG ActiveIrpCount;
+  ULONG RequestsNumber;
 
   UCHAR MiniPortDeviceExtension[1]; /* must be the last entry */
 } SCSI_PORT_DEVICE_EXTENSION, *PSCSI_PORT_DEVICE_EXTENSION;
 
-typedef struct _SCSI_PORT_SCAN_ADAPTER
+typedef struct _RESETBUS_PARAMS
 {
-  KEVENT Event;
-  IO_STATUS_BLOCK IoStatusBlock;
-  NTSTATUS Status;
-  PSCSI_PORT_LUN_EXTENSION LunExtension;
-  ULONG Lun;
-  ULONG Bus;
-  ULONG Target;
-  SCSI_REQUEST_BLOCK Srb;
-  UCHAR DataBuffer[256];
-  BOOL Active;
-} SCSI_PORT_SCAN_ADAPTER, *PSCSI_PORT_SCAN_ADAPTER;
-
-
+    ULONG PathId;
+    PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
+} RESETBUS_PARAMS, *PRESETBUS_PARAMS;