Added scsiport driver skeleton.
[reactos.git] / reactos / drivers / storage / include / srb.h
1 /* $Id: srb.h,v 1.1 2001/07/21 07:29:53 ekohl Exp $
2 *
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: services/storage/include/srb.c
6 * PURPOSE: SCSI port driver definitions
7 * PROGRAMMER: Eric Kohl (ekohl@rz-online.de)
8 */
9
10 #ifndef __STORAGE_INCLUDE_SRB_H
11 #define __STORAGE_INCLUDE_SRB_H
12
13 typedef PHYSICAL_ADDRESS SCSI_PHYSICAL_ADDRESS, *PSCSI_PHYSICAL_ADDRESS;
14
15
16 typedef struct _ACCESS_RANGE
17 {
18 SCSI_PHYSICAL_ADDRESS RangeStart;
19 ULONG RangeLength;
20 BOOLEAN RangeInMemory;
21 }ACCESS_RANGE, *PACCESS_RANGE;
22
23
24 typedef struct _PORT_CONFIGURATION_INFORMATION
25 {
26 ULONG Length;
27 ULONG SystemIoBusNumber;
28 INTERFACE_TYPE AdapterInterfaceType;
29 ULONG BusInterruptLevel;
30 ULONG BusInterruptVector;
31 KINTERRUPT_MODE InterruptMode;
32 ULONG MaximumTransferLength;
33 ULONG NumberOfPhysicalBreaks;
34 ULONG DmaChannel;
35 ULONG DmaPort;
36 DMA_WIDTH DmaWidth;
37 DMA_SPEED DmaSpeed;
38 ULONG AlignmentMask;
39 ULONG NumberOfAccessRanges;
40 ACCESS_RANGE (*AccessRanges)[];
41 PVOID Reserved;
42 UCHAR NumberOfBuses;
43 CCHAR InitiatorBusId[8];
44 BOOLEAN ScatterGather;
45 BOOLEAN Master;
46 BOOLEAN CachesData;
47 BOOLEAN AdapterScansDown;
48 BOOLEAN AtdiskPrimaryClaimed;
49 BOOLEAN AtdiskSecondaryClaimed;
50 BOOLEAN Dma32BitAddresses;
51 BOOLEAN DemandMode;
52 BOOLEAN MapBuffers;
53 BOOLEAN NeedPhysicalAddresses;
54 BOOLEAN TaggedQueuing;
55 BOOLEAN AutoRequestSense;
56 BOOLEAN MultipleRequestPerLu;
57 BOOLEAN ReceiveEvent;
58 BOOLEAN RealModeInitialized;
59 BOOLEAN BufferAccessScsiPortControlled;
60 UCHAR MaximumNumberOfTargets;
61 UCHAR ReservedUchars[2];
62 ULONG SlotNumber;
63 ULONG BusInterruptLevel2;
64 ULONG BusInterruptVector2;
65 KINTERRUPT_MODE InterruptMode2;
66 ULONG DmaChannel2;
67 ULONG DmaPort2;
68 DMA_WIDTH DmaWidth2;
69 DMA_SPEED DmaSpeed2;
70 ULONG DeviceExtensionSize;
71 ULONG SpecificLuExtensionSize;
72 ULONG SrbExtensionSize;
73 } PORT_CONFIGURATION_INFORMATION, *PPORT_CONFIGURATION_INFORMATION;
74
75 #define CONFIG_INFO_VERSION_2 sizeof(PORT_CONFIGURATION_INFORMATION)
76
77
78 typedef struct _SCSI_REQUEST_BLOCK
79 {
80 USHORT Length; // 0x00
81 UCHAR Function; // 0x02
82 UCHAR SrbStatus; // 0x03
83 UCHAR ScsiStatus; // 0x04
84 UCHAR PathId; // 0x05
85 UCHAR TargetId; // 0x06
86 UCHAR Lun; // 0x07
87 UCHAR QueueTag; // 0x08
88 UCHAR QueueAction; // 0x09
89 UCHAR CdbLength; // 0x0A
90 UCHAR SenseInfoBufferLength; // 0x0B
91 ULONG SrbFlags; // 0x0C
92 ULONG DataTransferLength; // 0x10
93 ULONG TimeOutValue; // 0x14
94 PVOID DataBuffer; // 0x18
95 PVOID SenseInfoBuffer; // 0x1C
96 struct _SCSI_REQUEST_BLOCK *NextSrb; // 0x20
97 PVOID OriginalRequest; // 0x24
98 PVOID SrbExtension; // 0x28
99 ULONG QueueSortKey; // 0x2C
100 UCHAR Cdb[16]; // 0x30
101 } SCSI_REQUEST_BLOCK, *PSCSI_REQUEST_BLOCK;
102
103 #define SCSI_REQUEST_BLOCK_SIZE sizeof(SCSI_REQUEST_BLOCK)
104
105
106 typedef enum _SCSI_NOTIFICATION_TYPE
107 {
108 RequestComplete,
109 NextRequest,
110 NextLuRequest,
111 ResetDetected,
112 CallDisableInterrupts,
113 CallEnableInterrupts,
114 RequestTimerCall
115 } SCSI_NOTIFICATION_TYPE, *PSCSI_NOTIFICATION_TYPE;
116
117
118 typedef BOOLEAN STDCALL
119 (*PHW_INITIALIZE)(IN PVOID DeviceExtension);
120
121 typedef BOOLEAN STDCALL
122 (*PHW_STARTIO)(IN PVOID DeviceExtension,
123 IN PSCSI_REQUEST_BLOCK Srb);
124
125 typedef BOOLEAN STDCALL
126 (*PHW_INTERRUPT)(IN PVOID DeviceExtension);
127
128 typedef VOID STDCALL
129 (*PHW_TIMER)(IN PVOID DeviceExtension);
130
131 typedef VOID STDCALL
132 (*PHW_DMA_STARTED)(IN PVOID DeviceExtension);
133
134 typedef ULONG STDCALL
135 (*PHW_FIND_ADAPTER)(IN PVOID DeviceExtension,
136 IN PVOID HwContext,
137 IN PVOID BusInformation,
138 IN PCHAR ArgumentString,
139 IN OUT PPORT_CONFIGURATION_INFORMATION ConfigInfo,
140 OUT PBOOLEAN Again);
141
142 typedef BOOLEAN STDCALL
143 (*PHW_RESET_BUS)(IN PVOID DeviceExtension,
144 IN ULONG PathId);
145
146 typedef BOOLEAN STDCALL
147 (*PHW_ADAPTER_STATE)(IN PVOID DeviceExtension,
148 IN PVOID Context,
149 IN BOOLEAN SaveState);
150
151 typedef struct _HW_INITIALIZATION_DATA
152 {
153 ULONG HwInitializationDataSize;
154 INTERFACE_TYPE AdapterInterfaceType;
155 PHW_INITIALIZE HwInitialize;
156 PHW_STARTIO HwStartIo;
157 PHW_INTERRUPT HwInterrupt;
158 PHW_FIND_ADAPTER HwFindAdapter;
159 PHW_RESET_BUS HwResetBus;
160 PHW_DMA_STARTED HwDmaStarted;
161 PHW_ADAPTER_STATE HwAdapterState;
162 ULONG DeviceExtensionSize;
163 ULONG SpecificLuExtensionSize;
164 ULONG SrbExtensionSize;
165 ULONG NumberOfAccessRanges;
166 PVOID Reserved;
167 BOOLEAN MapBuffers;
168 BOOLEAN NeedPhysicalAddresses;
169 BOOLEAN TaggedQueuing;
170 BOOLEAN AutoRequestSense;
171 BOOLEAN MultipleRequestPerLu;
172 BOOLEAN ReceiveEvent;
173 USHORT VendorIdLength;
174 PVOID VendorId;
175 USHORT ReservedUshort;
176 USHORT DeviceIdLength;
177 PVOID DeviceId;
178 } HW_INITIALIZATION_DATA, *PHW_INITIALIZATION_DATA;
179
180
181 /* FUNCTIONS ****************************************************************/
182
183 VOID
184 ScsiDebugPrint (
185 IN ULONG DebugPrintLevel,
186 IN PCHAR DebugMessage,
187 ...
188 );
189
190 VOID
191 STDCALL
192 ScsiPortCompleteRequest (
193 IN PVOID HwDeviceExtension,
194 IN UCHAR PathId,
195 IN UCHAR TargetId,
196 IN UCHAR Lun,
197 IN UCHAR SrbStatus
198 );
199
200 ULONG
201 STDCALL
202 ScsiPortConvertPhysicalAddressToUlong (
203 IN SCSI_PHYSICAL_ADDRESS Address
204 );
205
206 SCSI_PHYSICAL_ADDRESS
207 STDCALL
208 ScsiPortConvertUlongToPhysicalAddress (
209 IN ULONG UlongAddress
210 );
211
212 VOID
213 STDCALL
214 ScsiPortFlushDma (
215 IN PVOID HwDeviceExtension
216 );
217
218 VOID
219 STDCALL
220 ScsiPortFreeDeviceBase (
221 IN PVOID HwDeviceExtension,
222 IN PVOID MappedAddress
223 );
224
225 ULONG
226 STDCALL
227 ScsiPortGetBusData (
228 IN PVOID DeviceExtension,
229 IN ULONG BusDataType,
230 IN ULONG SystemIoBusNumber,
231 IN ULONG SlotNumber,
232 IN PVOID Buffer,
233 IN ULONG Length
234 );
235
236 PVOID
237 STDCALL
238 ScsiPortGetDeviceBase (
239 IN PVOID HwDeviceExtension,
240 IN INTERFACE_TYPE BusType,
241 IN ULONG SystemIoBusNumber,
242 IN SCSI_PHYSICAL_ADDRESS IoAddress,
243 IN ULONG NumberOfBytes,
244 IN BOOLEAN InIoSpace
245 );
246
247 PVOID
248 STDCALL
249 ScsiPortGetLogicalUnit (
250 IN PVOID HwDeviceExtension,
251 IN UCHAR PathId,
252 IN UCHAR TargetId,
253 IN UCHAR Lun
254 );
255
256 SCSI_PHYSICAL_ADDRESS
257 STDCALL
258 ScsiPortGetPhysicalAddress (
259 IN PVOID HwDeviceExtension,
260 IN PSCSI_REQUEST_BLOCK Srb OPTIONAL,
261 IN PVOID VirtualAddress,
262 OUT PULONG Length
263 );
264
265 PSCSI_REQUEST_BLOCK
266 STDCALL
267 ScsiPortGetSrb (
268 IN PVOID DeviceExtension,
269 IN UCHAR PathId,
270 IN UCHAR TargetId,
271 IN UCHAR Lun,
272 IN LONG QueueTag
273 );
274
275 PVOID
276 STDCALL
277 ScsiPortGetUncachedExtension (
278 IN PVOID HwDeviceExtension,
279 IN PPORT_CONFIGURATION_INFORMATION ConfigInfo,
280 IN ULONG NumberOfBytes
281 );
282
283 PVOID
284 STDCALL
285 ScsiPortGetVirtualAddress (
286 IN PVOID HwDeviceExtension,
287 IN SCSI_PHYSICAL_ADDRESS PhysicalAddress
288 );
289
290 ULONG
291 STDCALL
292 ScsiPortInitialize (
293 IN PVOID Argument1,
294 IN PVOID Argument2,
295 IN struct _HW_INITIALIZATION_DATA *HwInitializationData,
296 IN PVOID HwContext
297 );
298
299 VOID
300 STDCALL
301 ScsiPortIoMapTransfer (
302 IN PVOID HwDeviceExtension,
303 IN PSCSI_REQUEST_BLOCK Srb,
304 IN ULONG LogicalAddress,
305 IN ULONG Length
306 );
307
308 VOID
309 STDCALL
310 ScsiPortLogError (
311 IN PVOID HwDeviceExtension,
312 IN PSCSI_REQUEST_BLOCK Srb OPTIONAL,
313 IN UCHAR PathId,
314 IN UCHAR TargetId,
315 IN UCHAR Lun,
316 IN ULONG ErrorCode,
317 IN ULONG UniqueId
318 );
319
320 VOID
321 STDCALL
322 ScsiPortMoveMemory (
323 OUT PVOID Destination,
324 IN PVOID Source,
325 IN ULONG Length
326 );
327
328 VOID
329 ScsiPortNotification (
330 IN SCSI_NOTIFICATION_TYPE NotificationType,
331 IN PVOID HwDeviceExtension,
332 ...
333 );
334
335 UCHAR
336 STDCALL
337 ScsiPortReadPortUchar (
338 IN PUCHAR Port
339 );
340
341 ULONG
342 STDCALL
343 ScsiPortReadPortUlong (
344 IN PULONG Port
345 );
346
347 USHORT
348 STDCALL
349 ScsiPortReadPortUshort (
350 IN PUSHORT Port
351 );
352
353 #endif /* __STORAGE_INCLUDE_SRB_H */
354
355 /* EOF */