[SCSIPORT]
[reactos.git] / reactos / drivers / storage / scsiport / scsiport_int.h
1 /*
2 * SCSI_PORT_TIMER_STATES
3 *
4 * DESCRIPTION
5 * An enumeration containing the states in the timer DFA
6 */
7
8 #define VERSION "0.0.3"
9
10 #ifndef PAGE_ROUND_UP
11 #define PAGE_ROUND_UP(x) ( (((ULONG_PTR)x)%PAGE_SIZE) ? ((((ULONG_PTR)x)&(~(PAGE_SIZE-1)))+PAGE_SIZE) : ((ULONG_PTR)x) )
12 #endif
13 #ifndef ROUND_UP
14 #define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
15 #endif
16
17 #define TAG_SCSIPORT 'ISCS'
18
19 /* Defines how many logical unit arrays will be in a device extension */
20 #define LUS_NUMBER 8
21
22 #define MAX_SG_LIST 17
23
24 /* Flags */
25 #define SCSI_PORT_DEVICE_BUSY 0x0001
26 #define SCSI_PORT_LU_ACTIVE 0x0002
27 #define SCSI_PORT_NOTIFICATION_NEEDED 0x0004
28 #define SCSI_PORT_NEXT_REQUEST_READY 0x0008
29 #define SCSI_PORT_FLUSH_ADAPTERS 0x0010
30 #define SCSI_PORT_MAP_TRANSFER 0x0020
31 #define SCSI_PORT_RESET 0x0080
32 #define SCSI_PORT_RESET_REQUEST 0x0100
33 #define SCSI_PORT_RESET_REPORTED 0x0200
34 #define SCSI_PORT_REQUEST_PENDING 0x0800
35 #define SCSI_PORT_DISCONNECT_ALLOWED 0x1000
36 #define SCSI_PORT_DISABLE_INT_REQUESET 0x2000
37 #define SCSI_PORT_DISABLE_INTERRUPTS 0x4000
38 #define SCSI_PORT_ENABLE_INT_REQUEST 0x8000
39 #define SCSI_PORT_TIMER_NEEDED 0x10000
40
41 /* LUN Extension flags*/
42 #define LUNEX_FROZEN_QUEUE 0x0001
43 #define LUNEX_NEED_REQUEST_SENSE 0x0004
44 #define LUNEX_BUSY 0x0008
45 #define LUNEX_FULL_QUEUE 0x0010
46 #define LUNEX_REQUEST_PENDING 0x0020
47 #define SCSI_PORT_SCAN_IN_PROGRESS 0x8000
48
49
50 typedef enum _SCSI_PORT_TIMER_STATES
51 {
52 IDETimerIdle,
53 IDETimerCmdWait,
54 IDETimerResetWaitForBusyNegate,
55 IDETimerResetWaitForDrdyAssert
56 } SCSI_PORT_TIMER_STATES;
57
58 typedef struct _CONFIGURATION_INFO
59 {
60 /* Identify info */
61 ULONG AdapterNumber;
62 ULONG LastAdapterNumber;
63 ULONG BusNumber;
64
65 /* Registry related */
66 HANDLE BusKey;
67 HANDLE ServiceKey;
68 HANDLE DeviceKey;
69
70 /* Features */
71 BOOLEAN DisableTaggedQueueing;
72 BOOLEAN DisableMultipleLun;
73
74 /* Parameters */
75 PVOID Parameter;
76 PACCESS_RANGE AccessRanges;
77 } CONFIGURATION_INFO, *PCONFIGURATION_INFO;
78
79 typedef struct _SCSI_PORT_DEVICE_BASE
80 {
81 LIST_ENTRY List;
82
83 PVOID MappedAddress;
84 ULONG NumberOfBytes;
85 SCSI_PHYSICAL_ADDRESS IoAddress;
86 ULONG SystemIoBusNumber;
87 } SCSI_PORT_DEVICE_BASE, *PSCSI_PORT_DEVICE_BASE;
88
89 typedef struct _SCSI_SG_ADDRESS
90 {
91 PHYSICAL_ADDRESS PhysicalAddress;
92 ULONG Length;
93 } SCSI_SG_ADDRESS, *PSCSI_SG_ADDRESS;
94
95 typedef struct _SCSI_REQUEST_BLOCK_INFO
96 {
97 LIST_ENTRY Requests;
98 PSCSI_REQUEST_BLOCK Srb;
99 PCHAR DataOffset;
100 PVOID SaveSenseRequest;
101
102 ULONG SequenceNumber;
103
104 /* DMA stuff */
105 PVOID BaseOfMapRegister;
106 ULONG NumberOfMapRegisters;
107
108 struct _SCSI_REQUEST_BLOCK_INFO *CompletedRequests;
109
110 /* Scatter-gather list */
111 PSCSI_SG_ADDRESS ScatterGather;
112 SCSI_SG_ADDRESS ScatterGatherList[MAX_SG_LIST];
113 } SCSI_REQUEST_BLOCK_INFO, *PSCSI_REQUEST_BLOCK_INFO;
114
115 typedef struct _SCSI_PORT_LUN_EXTENSION
116 {
117 UCHAR PathId;
118 UCHAR TargetId;
119 UCHAR Lun;
120
121 ULONG Flags;
122
123 struct _SCSI_PORT_LUN_EXTENSION *Next;
124
125 BOOLEAN DeviceClaimed;
126 PDEVICE_OBJECT DeviceObject;
127
128 INQUIRYDATA InquiryData;
129
130 KDEVICE_QUEUE DeviceQueue;
131 ULONG SortKey;
132 ULONG QueueCount;
133 ULONG MaxQueueCount;
134
135 ULONG AttemptCount;
136 LONG RequestTimeout;
137
138 PIRP BusyRequest;
139 PIRP PendingRequest;
140
141 struct _SCSI_PORT_LUN_EXTENSION *ReadyLun;
142 struct _SCSI_PORT_LUN_EXTENSION *CompletedAbortRequests;
143
144 SCSI_REQUEST_BLOCK_INFO SrbInfo;
145
146 /* More data? */
147
148 UCHAR MiniportLunExtension[1]; /* must be the last entry */
149 } SCSI_PORT_LUN_EXTENSION, *PSCSI_PORT_LUN_EXTENSION;
150
151 /* Structures for inquiries support */
152
153 typedef struct _SCSI_LUN_INFO
154 {
155 UCHAR PathId;
156 UCHAR TargetId;
157 UCHAR Lun;
158 BOOLEAN DeviceClaimed;
159 PVOID DeviceObject;
160 struct _SCSI_LUN_INFO *Next;
161 UCHAR InquiryData[INQUIRYDATABUFFERSIZE];
162 } SCSI_LUN_INFO, *PSCSI_LUN_INFO;
163
164 typedef struct _SCSI_BUS_SCAN_INFO
165 {
166 USHORT Length;
167 UCHAR LogicalUnitsCount;
168 UCHAR BusIdentifier;
169 PSCSI_LUN_INFO LunInfo;
170 } SCSI_BUS_SCAN_INFO, *PSCSI_BUS_SCAN_INFO;
171
172 typedef struct _BUSES_CONFIGURATION_INFORMATION
173 {
174 UCHAR NumberOfBuses;
175 PSCSI_BUS_SCAN_INFO BusScanInfo[1];
176 } BUSES_CONFIGURATION_INFORMATION, *PBUSES_CONFIGURATION_INFORMATION;
177
178
179 typedef struct _SCSI_PORT_INTERRUPT_DATA
180 {
181 ULONG Flags; /* Interrupt-time flags */
182 PSCSI_REQUEST_BLOCK_INFO CompletedRequests; /* Linked list of Srb info data */
183 PSCSI_PORT_LUN_EXTENSION CompletedAbort;
184 PSCSI_PORT_LUN_EXTENSION ReadyLun;
185 PHW_TIMER HwScsiTimer;
186 ULONG MiniportTimerValue;
187 } SCSI_PORT_INTERRUPT_DATA, *PSCSI_PORT_INTERRUPT_DATA;
188
189
190 /* Only for interrupt data saving function */
191 typedef struct _SCSI_PORT_SAVE_INTERRUPT
192 {
193 PSCSI_PORT_INTERRUPT_DATA InterruptData;
194 struct _SCSI_PORT_DEVICE_EXTENSION *DeviceExtension;
195 } SCSI_PORT_SAVE_INTERRUPT, *PSCSI_PORT_SAVE_INTERRUPT;
196
197 /*
198 * SCSI_PORT_DEVICE_EXTENSION
199 *
200 * DESCRIPTION
201 * First part of the port objects device extension. The second
202 * part is the miniport-specific device extension.
203 */
204
205 typedef struct _SCSI_PORT_DEVICE_EXTENSION
206 {
207 ULONG Length;
208 ULONG MiniPortExtensionSize;
209 PPORT_CONFIGURATION_INFORMATION PortConfig;
210 PBUSES_CONFIGURATION_INFORMATION BusesConfig;
211 PVOID NonCachedExtension;
212 ULONG PortNumber;
213
214 LONG ActiveRequestCounter;
215 ULONG SrbFlags;
216 ULONG Flags;
217
218 ULONG BusNum;
219 ULONG MaxTargedIds;
220 ULONG MaxLunCount;
221
222 KSPIN_LOCK IrqLock; /* Used when there are 2 irqs */
223 ULONG SequenceNumber; /* Global sequence number for packets */
224 KSPIN_LOCK SpinLock;
225 PKINTERRUPT Interrupt;
226 PIRP CurrentIrp;
227 ULONG IrpFlags;
228
229 SCSI_PORT_TIMER_STATES TimerState;
230 LONG TimerCount;
231
232 KTIMER MiniportTimer;
233 KDPC MiniportTimerDpc;
234
235 PMAPPED_ADDRESS MappedAddressList;
236
237 ULONG LunExtensionSize;
238 PSCSI_PORT_LUN_EXTENSION LunExtensionList[LUS_NUMBER];
239
240 SCSI_PORT_INTERRUPT_DATA InterruptData;
241
242 /* SRB extension stuff*/
243 ULONG SrbExtensionSize;
244 PVOID SrbExtensionBuffer;
245 PVOID FreeSrbExtensions;
246
247 /* SRB information */
248 PSCSI_REQUEST_BLOCK_INFO SrbInfo;
249 PSCSI_REQUEST_BLOCK_INFO FreeSrbInfo;
250 ULONG SrbDataCount;
251
252 IO_SCSI_CAPABILITIES PortCapabilities;
253
254 PDEVICE_OBJECT DeviceObject;
255 PCONTROLLER_OBJECT ControllerObject;
256
257 PHW_INITIALIZE HwInitialize;
258 PHW_STARTIO HwStartIo;
259 PHW_INTERRUPT HwInterrupt;
260 PHW_RESET_BUS HwResetBus;
261 PHW_DMA_STARTED HwDmaStarted;
262 PHW_TIMER HwScsiTimer;
263
264 PSCSI_REQUEST_BLOCK OriginalSrb;
265 SCSI_REQUEST_BLOCK InternalSrb;
266 SENSE_DATA InternalSenseData;
267
268 /* DMA related stuff */
269 PADAPTER_OBJECT AdapterObject;
270 ULONG MapRegisterCount;
271 BOOLEAN MapBuffers;
272 BOOLEAN MapRegisters;
273 PVOID MapRegisterBase;
274
275 /* Features */
276 BOOLEAN CachesData;
277 BOOLEAN SupportsTaggedQueuing;
278 BOOLEAN SupportsAutoSense;
279 BOOLEAN MultipleReqsPerLun;
280 BOOLEAN ReceiveEvent;
281
282 PHYSICAL_ADDRESS PhysicalAddress;
283 ULONG CommonBufferLength;
284 ULONG InterruptLevel;
285 ULONG IoAddress;
286
287 BOOLEAN NeedSrbExtensionAlloc;
288 BOOLEAN NeedSrbDataAlloc;
289
290 ULONG RequestsNumber;
291
292 UCHAR MiniPortDeviceExtension[1]; /* must be the last entry */
293 } SCSI_PORT_DEVICE_EXTENSION, *PSCSI_PORT_DEVICE_EXTENSION;
294
295 typedef struct _RESETBUS_PARAMS
296 {
297 ULONG PathId;
298 PSCSI_PORT_DEVICE_EXTENSION DeviceExtension;
299 } RESETBUS_PARAMS, *PRESETBUS_PARAMS;