2007-03-27 10:07:57 +00:00
|
|
|
/*
|
|
|
|
* SCSI_PORT_TIMER_STATES
|
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* An enumeration containing the states in the timer DFA
|
|
|
|
*/
|
2007-03-27 11:07:12 +00:00
|
|
|
|
2014-02-03 10:49:41 +00:00
|
|
|
#pragma once
|
|
|
|
|
2007-03-27 11:07:12 +00:00
|
|
|
#define VERSION "0.0.3"
|
|
|
|
|
|
|
|
#ifndef PAGE_ROUND_UP
|
|
|
|
#define PAGE_ROUND_UP(x) ( (((ULONG_PTR)x)%PAGE_SIZE) ? ((((ULONG_PTR)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : ((ULONG_PTR)x) )
|
|
|
|
#endif
|
|
|
|
#ifndef ROUND_UP
|
|
|
|
#define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
|
|
|
|
#endif
|
|
|
|
|
2009-08-24 17:12:25 +00:00
|
|
|
#define TAG_SCSIPORT 'ISCS'
|
2007-03-27 11:07:12 +00:00
|
|
|
|
2007-03-27 21:15:09 +00:00
|
|
|
/* Defines how many logical unit arrays will be in a device extension */
|
|
|
|
#define LUS_NUMBER 8
|
|
|
|
|
2007-07-08 12:21:18 +00:00
|
|
|
#define MAX_SG_LIST 17
|
|
|
|
|
2007-03-27 21:15:09 +00:00
|
|
|
/* Flags */
|
2007-03-28 18:29:15 +00:00
|
|
|
#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
|
2007-03-29 21:05:41 +00:00
|
|
|
#define SCSI_PORT_FLUSH_ADAPTERS 0x0010
|
|
|
|
#define SCSI_PORT_MAP_TRANSFER 0x0020
|
2007-03-28 18:29:15 +00:00
|
|
|
#define SCSI_PORT_RESET 0x0080
|
|
|
|
#define SCSI_PORT_RESET_REQUEST 0x0100
|
2007-03-29 21:05:41 +00:00
|
|
|
#define SCSI_PORT_RESET_REPORTED 0x0200
|
|
|
|
#define SCSI_PORT_REQUEST_PENDING 0x0800
|
2007-03-28 19:26:41 +00:00
|
|
|
#define SCSI_PORT_DISCONNECT_ALLOWED 0x1000
|
2007-03-29 21:05:41 +00:00
|
|
|
#define SCSI_PORT_DISABLE_INT_REQUESET 0x2000
|
2007-03-28 18:29:15 +00:00
|
|
|
#define SCSI_PORT_DISABLE_INTERRUPTS 0x4000
|
2007-03-29 21:05:41 +00:00
|
|
|
#define SCSI_PORT_ENABLE_INT_REQUEST 0x8000
|
2010-09-08 10:39:37 +00:00
|
|
|
#define SCSI_PORT_TIMER_NEEDED 0x10000
|
2007-03-29 21:05:41 +00:00
|
|
|
|
|
|
|
/* 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
|
2007-03-28 18:29:15 +00:00
|
|
|
#define SCSI_PORT_SCAN_IN_PROGRESS 0x8000
|
|
|
|
|
|
|
|
|
2007-03-27 10:07:57 +00:00
|
|
|
typedef enum _SCSI_PORT_TIMER_STATES
|
|
|
|
{
|
2016-01-10 22:39:25 +00:00
|
|
|
IDETimerIdle,
|
|
|
|
IDETimerCmdWait,
|
|
|
|
IDETimerResetWaitForBusyNegate,
|
|
|
|
IDETimerResetWaitForDrdyAssert
|
2007-03-27 10:07:57 +00:00
|
|
|
} SCSI_PORT_TIMER_STATES;
|
|
|
|
|
2007-03-30 13:17:06 +00:00
|
|
|
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;
|
2007-03-27 10:07:57 +00:00
|
|
|
|
|
|
|
typedef struct _SCSI_PORT_DEVICE_BASE
|
|
|
|
{
|
2016-01-10 22:39:25 +00:00
|
|
|
LIST_ENTRY List;
|
2007-03-27 10:07:57 +00:00
|
|
|
|
2016-01-10 22:39:25 +00:00
|
|
|
PVOID MappedAddress;
|
|
|
|
ULONG NumberOfBytes;
|
|
|
|
SCSI_PHYSICAL_ADDRESS IoAddress;
|
|
|
|
ULONG SystemIoBusNumber;
|
2007-03-27 10:07:57 +00:00
|
|
|
} SCSI_PORT_DEVICE_BASE, *PSCSI_PORT_DEVICE_BASE;
|
|
|
|
|
2007-07-08 12:21:18 +00:00
|
|
|
typedef struct _SCSI_SG_ADDRESS
|
|
|
|
{
|
|
|
|
PHYSICAL_ADDRESS PhysicalAddress;
|
|
|
|
ULONG Length;
|
|
|
|
} SCSI_SG_ADDRESS, *PSCSI_SG_ADDRESS;
|
|
|
|
|
2007-03-27 21:15:09 +00:00
|
|
|
typedef struct _SCSI_REQUEST_BLOCK_INFO
|
|
|
|
{
|
|
|
|
LIST_ENTRY Requests;
|
2007-03-28 10:41:03 +00:00
|
|
|
PSCSI_REQUEST_BLOCK Srb;
|
2007-03-28 18:29:15 +00:00
|
|
|
PCHAR DataOffset;
|
2007-03-29 21:05:41 +00:00
|
|
|
PVOID SaveSenseRequest;
|
|
|
|
|
|
|
|
ULONG SequenceNumber;
|
|
|
|
|
|
|
|
/* DMA stuff */
|
|
|
|
PVOID BaseOfMapRegister;
|
|
|
|
ULONG NumberOfMapRegisters;
|
|
|
|
|
2007-03-28 10:41:03 +00:00
|
|
|
struct _SCSI_REQUEST_BLOCK_INFO *CompletedRequests;
|
2007-07-08 12:21:18 +00:00
|
|
|
|
|
|
|
/* Scatter-gather list */
|
|
|
|
PSCSI_SG_ADDRESS ScatterGather;
|
|
|
|
SCSI_SG_ADDRESS ScatterGatherList[MAX_SG_LIST];
|
2007-03-27 21:15:09 +00:00
|
|
|
} SCSI_REQUEST_BLOCK_INFO, *PSCSI_REQUEST_BLOCK_INFO;
|
2007-03-27 10:07:57 +00:00
|
|
|
|
|
|
|
typedef struct _SCSI_PORT_LUN_EXTENSION
|
|
|
|
{
|
2016-01-10 22:39:25 +00:00
|
|
|
UCHAR PathId;
|
|
|
|
UCHAR TargetId;
|
|
|
|
UCHAR Lun;
|
2007-03-27 10:07:57 +00:00
|
|
|
|
2016-01-10 22:39:25 +00:00
|
|
|
ULONG Flags;
|
2007-03-27 21:15:09 +00:00
|
|
|
|
2016-01-10 22:39:25 +00:00
|
|
|
struct _SCSI_PORT_LUN_EXTENSION *Next;
|
2007-03-27 21:15:09 +00:00
|
|
|
|
2016-01-10 22:39:25 +00:00
|
|
|
BOOLEAN DeviceClaimed;
|
|
|
|
PDEVICE_OBJECT DeviceObject;
|
2007-03-27 10:07:57 +00:00
|
|
|
|
2016-01-10 22:39:25 +00:00
|
|
|
INQUIRYDATA InquiryData;
|
2007-03-27 10:07:57 +00:00
|
|
|
|
2016-01-10 22:39:25 +00:00
|
|
|
KDEVICE_QUEUE DeviceQueue;
|
|
|
|
ULONG SortKey;
|
|
|
|
ULONG QueueCount;
|
|
|
|
ULONG MaxQueueCount;
|
2007-03-28 18:29:15 +00:00
|
|
|
|
2016-01-10 22:39:25 +00:00
|
|
|
ULONG AttemptCount;
|
|
|
|
LONG RequestTimeout;
|
2007-03-27 10:07:57 +00:00
|
|
|
|
2016-01-10 22:39:25 +00:00
|
|
|
PIRP BusyRequest;
|
|
|
|
PIRP PendingRequest;
|
2007-03-29 21:05:41 +00:00
|
|
|
|
2016-01-10 22:39:25 +00:00
|
|
|
struct _SCSI_PORT_LUN_EXTENSION *ReadyLun;
|
|
|
|
struct _SCSI_PORT_LUN_EXTENSION *CompletedAbortRequests;
|
2007-03-29 21:05:41 +00:00
|
|
|
|
2016-01-10 22:39:25 +00:00
|
|
|
SCSI_REQUEST_BLOCK_INFO SrbInfo;
|
2007-03-27 21:15:09 +00:00
|
|
|
|
2016-01-10 22:39:25 +00:00
|
|
|
/* More data? */
|
2007-03-27 10:07:57 +00:00
|
|
|
|
2016-01-10 22:39:25 +00:00
|
|
|
UCHAR MiniportLunExtension[1]; /* must be the last entry */
|
2007-03-27 10:07:57 +00:00
|
|
|
} SCSI_PORT_LUN_EXTENSION, *PSCSI_PORT_LUN_EXTENSION;
|
|
|
|
|
2007-03-27 21:15:09 +00:00
|
|
|
/* 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;
|
2007-03-27 10:07:57 +00:00
|
|
|
|
2007-03-28 10:41:03 +00:00
|
|
|
|
|
|
|
typedef struct _SCSI_PORT_INTERRUPT_DATA
|
|
|
|
{
|
|
|
|
ULONG Flags; /* Interrupt-time flags */
|
|
|
|
PSCSI_REQUEST_BLOCK_INFO CompletedRequests; /* Linked list of Srb info data */
|
2007-03-29 21:05:41 +00:00
|
|
|
PSCSI_PORT_LUN_EXTENSION CompletedAbort;
|
|
|
|
PSCSI_PORT_LUN_EXTENSION ReadyLun;
|
2010-09-08 10:39:37 +00:00
|
|
|
PHW_TIMER HwScsiTimer;
|
|
|
|
ULONG MiniportTimerValue;
|
2007-03-28 10:41:03 +00:00
|
|
|
} SCSI_PORT_INTERRUPT_DATA, *PSCSI_PORT_INTERRUPT_DATA;
|
|
|
|
|
|
|
|
|
2007-03-29 21:05:41 +00:00
|
|
|
/* 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;
|
|
|
|
|
2007-03-27 10:07:57 +00:00
|
|
|
/*
|
|
|
|
* SCSI_PORT_DEVICE_EXTENSION
|
|
|
|
*
|
|
|
|
* DESCRIPTION
|
|
|
|
* First part of the port objects device extension. The second
|
|
|
|
* part is the miniport-specific device extension.
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct _SCSI_PORT_DEVICE_EXTENSION
|
|
|
|
{
|
2016-01-10 22:39:25 +00:00
|
|
|
ULONG Length;
|
|
|
|
ULONG MiniPortExtensionSize;
|
|
|
|
PPORT_CONFIGURATION_INFORMATION PortConfig;
|
|
|
|
PBUSES_CONFIGURATION_INFORMATION BusesConfig;
|
|
|
|
PVOID NonCachedExtension;
|
|
|
|
ULONG PortNumber;
|
|
|
|
|
|
|
|
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[2];
|
|
|
|
PIRP CurrentIrp;
|
|
|
|
ULONG IrpFlags;
|
|
|
|
|
|
|
|
SCSI_PORT_TIMER_STATES TimerState;
|
|
|
|
LONG TimerCount;
|
|
|
|
|
|
|
|
KTIMER MiniportTimer;
|
|
|
|
KDPC MiniportTimerDpc;
|
|
|
|
|
|
|
|
PMAPPED_ADDRESS MappedAddressList;
|
|
|
|
|
|
|
|
ULONG LunExtensionSize;
|
|
|
|
PSCSI_PORT_LUN_EXTENSION LunExtensionList[LUS_NUMBER];
|
|
|
|
|
|
|
|
SCSI_PORT_INTERRUPT_DATA InterruptData;
|
|
|
|
|
|
|
|
/* SRB extension stuff*/
|
|
|
|
ULONG SrbExtensionSize;
|
|
|
|
PVOID SrbExtensionBuffer;
|
|
|
|
PVOID FreeSrbExtensions;
|
|
|
|
|
|
|
|
/* 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;
|
|
|
|
ULONG CommonBufferLength;
|
|
|
|
ULONG InterruptLevel[2];
|
|
|
|
ULONG IoAddress;
|
|
|
|
|
|
|
|
BOOLEAN NeedSrbExtensionAlloc;
|
|
|
|
BOOLEAN NeedSrbDataAlloc;
|
|
|
|
|
|
|
|
ULONG RequestsNumber;
|
|
|
|
|
|
|
|
ULONG InterruptCount;
|
|
|
|
|
|
|
|
UCHAR MiniPortDeviceExtension[1]; /* must be the last entry */
|
2007-03-27 10:07:57 +00:00
|
|
|
} SCSI_PORT_DEVICE_EXTENSION, *PSCSI_PORT_DEVICE_EXTENSION;
|
2007-03-31 20:03:07 +00:00
|
|
|
|
|
|
|
typedef struct _RESETBUS_PARAMS
|
|
|
|
{
|
|
|
|
ULONG PathId;
|
|
|
|
PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
|
|
|
|
} RESETBUS_PARAMS, *PRESETBUS_PARAMS;
|