00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
#ifndef _CLASS_
00024
00025
#include <ntdddisk.h>
00026
#include <ntddcdrm.h>
00027
#include <ntddtape.h>
00028
#include <ntddchgr.h>
00029
#include <ntddstor.h>
00030
#include "ntddscsi.h"
00031
#include <stdio.h>
00032
00033
00034
00035
#if DBG
00036
00037
#define DebugPrint(x) ScsiDebugPrint x
00038
00039
#else
00040
00041 #define DebugPrint(x)
00042
00043
#endif // DBG
00044
00045
00046
00047
#ifdef POOL_TAGGING
00048
#undef ExAllocatePool
00049
#undef ExAllocatePoolWithQuota
00050
#define ExAllocatePool(a,b) ExAllocatePoolWithTag(a,b,'HscS')
00051
#define ExAllocatePoolWithQuota(a,b) ExAllocatePoolWithQuotaTag(a,b,'HscS')
00052
#endif
00053
00054 #define MAXIMUM_RETRIES 4
00055
00056
typedef
00057
VOID
00058 (*PCLASS_ERROR) (
00059 IN
PDEVICE_OBJECT DeviceObject,
00060 IN PSCSI_REQUEST_BLOCK Srb,
00061 IN OUT
NTSTATUS *
Status,
00062 IN OUT BOOLEAN *Retry
00063 );
00064
00065
typedef struct _DEVICE_EXTENSION {
00066
00067
00068
00069
00070
00071
PDEVICE_OBJECT DeviceObject;
00072
00073
00074
00075
00076
00077
PDEVICE_OBJECT PortDeviceObject;
00078
00079
00080
00081
00082
00083 LARGE_INTEGER PartitionLength;
00084
00085
00086
00087
00088
00089 LARGE_INTEGER StartingOffset;
00090
00091
00092
00093
00094
00095 ULONG DMByteSkew;
00096
00097
00098
00099
00100
00101 ULONG DMSkew;
00102
00103
00104
00105
00106
00107 BOOLEAN DMActive;
00108
00109
00110
00111
00112
00113
PCLASS_ERROR ClassError;
00114
00115
00116
00117
00118
00119 PIO_SCSI_CAPABILITIES PortCapabilities;
00120
00121
00122
00123
00124
00125 PDISK_GEOMETRY DiskGeometry;
00126
00127
00128
00129
00130
00131
PDEVICE_OBJECT PhysicalDevice;
00132
00133
00134
00135
00136
00137 PSENSE_DATA SenseData;
00138
00139
00140
00141
00142
00143 ULONG TimeOutValue;
00144
00145
00146
00147
00148
00149 ULONG DeviceNumber;
00150
00151
00152
00153
00154
00155 ULONG SrbFlags;
00156
00157
00158
00159
00160
00161 ULONG ErrorCount;
00162
00163
00164
00165
00166
00167 KSPIN_LOCK SplitRequestSpinLock;
00168
00169
00170
00171
00172
00173 PZONE_HEADER SrbZone;
00174
00175 PKSPIN_LOCK
SrbZoneSpinLock;
00176
00177
00178
00179
00180
00181 LONG
LockCount;
00182
00183
00184
00185
00186
00187 UCHAR
PortNumber;
00188
00189
00190
00191
00192
00193 UCHAR
PathId;
00194
00195
00196
00197
00198
00199 UCHAR
TargetId;
00200
00201
00202
00203
00204
00205 UCHAR
Lun;
00206
00207
00208
00209
00210
00211 UCHAR
SectorShift;
00212
00213
00214
00215
00216
00217 BOOLEAN
WriteCache;
00218
00219
00220
00221
00222
00223 BOOLEAN
UseScsi1;
00224
00225 }
DEVICE_EXTENSION, *
PDEVICE_EXTENSION;
00226
00227
00228
00229
00230
00231 typedef struct _COMPLETION_CONTEXT {
00232
PDEVICE_OBJECT DeviceObject;
00233 SCSI_REQUEST_BLOCK Srb;
00234 }
COMPLETION_CONTEXT, *
PCOMPLETION_CONTEXT;
00235
00236
00237
NTSTATUS
00238
ScsiClassGetCapabilities(
00239 IN
PDEVICE_OBJECT PortDeviceObject,
00240 OUT PIO_SCSI_CAPABILITIES *PortCapabilities
00241 );
00242
00243
NTSTATUS
00244
ScsiClassGetInquiryData(
00245 IN
PDEVICE_OBJECT PortDeviceObject,
00246 IN PSCSI_ADAPTER_BUS_INFO *ConfigInfo
00247 );
00248
00249
NTSTATUS
00250
ScsiClassReadDriveCapacity(
00251 IN
PDEVICE_OBJECT DeviceObject
00252 );
00253
00254
VOID
00255
ScsiClassReleaseQueue(
00256 IN
PDEVICE_OBJECT DeviceObject
00257 );
00258
00259
NTSTATUS
00260
ScsiClassRemoveDevice(
00261 IN
PDEVICE_OBJECT PortDeviceObject,
00262 IN UCHAR PathId,
00263 IN UCHAR TargetId,
00264 IN UCHAR Lun
00265 );
00266
00267
NTSTATUS
00268
ScsiClassAsynchronousCompletion(
00269
PDEVICE_OBJECT DeviceObject,
00270
PIRP Irp,
00271 PVOID Context
00272 );
00273
00274
VOID
00275
ScsiClassSplitRequest(
00276 IN
PDEVICE_OBJECT DeviceObject,
00277 IN
PIRP Irp,
00278 IN ULONG MaximumBytes
00279 );
00280
00281
NTSTATUS
00282
ScsiClassDeviceControl(
00283
PDEVICE_OBJECT DeviceObject,
00284
PIRP Irp
00285 );
00286
00287
NTSTATUS
00288
ScsiClassIoComplete(
00289 IN
PDEVICE_OBJECT DeviceObject,
00290 IN
PIRP Irp,
00291 IN PVOID Context
00292 );
00293
00294
NTSTATUS
00295
ScsiClassIoCompleteAssociated(
00296 IN
PDEVICE_OBJECT DeviceObject,
00297 IN
PIRP Irp,
00298 IN PVOID Context
00299 );
00300
00301 BOOLEAN
00302
ScsiClassInterpretSenseInfo(
00303 IN
PDEVICE_OBJECT DeviceObject,
00304 IN PSCSI_REQUEST_BLOCK Srb,
00305 IN UCHAR MajorFunctionCode,
00306 IN ULONG IoDeviceCode,
00307 IN ULONG RetryCount,
00308 OUT NTSTATUS *Status
00309 );
00310
00311
NTSTATUS
00312
ScsiClassSendSrbSynchronous(
00313
PDEVICE_OBJECT DeviceObject,
00314 PSCSI_REQUEST_BLOCK Srb,
00315 PVOID BufferAddress,
00316 ULONG BufferLength,
00317 BOOLEAN WriteToDevice
00318 );
00319
00320
NTSTATUS
00321
ScsiClassSendSrbAsynchronous(
00322
PDEVICE_OBJECT DeviceObject,
00323 PSCSI_REQUEST_BLOCK Srb,
00324
PIRP Irp,
00325 PVOID BufferAddress,
00326 ULONG BufferLength,
00327 BOOLEAN WriteToDevice
00328 );
00329
00330
VOID
00331
ScsiClassBuildRequest(
00332
PDEVICE_OBJECT DeviceObject,
00333
PIRP Irp
00334 );
00335
00336 ULONG
00337
ScsiClassModeSense(
00338 IN
PDEVICE_OBJECT DeviceObject,
00339 IN PCHAR ModeSenseBuffer,
00340 IN ULONG Length,
00341 IN UCHAR PageMode
00342 );
00343
00344 BOOLEAN
00345
ScsiClassModeSelect(
00346 IN
PDEVICE_OBJECT DeviceObject,
00347 IN PCHAR ModeSelectBuffer,
00348 IN ULONG Length,
00349 IN BOOLEAN SavePage
00350 );
00351
00352 PVOID
00353
ScsiClassFindModePage(
00354 IN PCHAR ModeSenseBuffer,
00355 IN ULONG Length,
00356 IN UCHAR PageMode
00357 );
00358
00359
NTSTATUS
00360
ScsiClassClaimDevice(
00361 IN
PDEVICE_OBJECT PortDeviceObject,
00362 IN PSCSI_INQUIRY_DATA LunInfo,
00363 IN BOOLEAN Release,
00364 OUT
PDEVICE_OBJECT *NewPortDeviceObject OPTIONAL
00365 );
00366
00367
NTSTATUS
00368
ScsiClassInternalIoControl (
00369 IN
PDEVICE_OBJECT DeviceObject,
00370 IN
PIRP Irp
00371 );
00372
00373
#endif