ReactOS  0.4.14-dev-606-g14ebc0b
class2.h
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS kernel
4  * FILE: services/storage/include/class2.h
5  * PURPOSE: SCSI class driver definitions
6  * PROGRAMMER: Eric Kohl
7  */
8 
9 #pragma once
10 
11 #include <ntddscsi.h>
12 #include <srb.h>
13 
14 #define MAXIMUM_RETRIES 15
15 #define RETRY_WAIT 2000000 /* 200 ms in units of 100 ns */
16 
17 //
18 // Indicates that the device has write caching enabled.
19 //
20 
21 #define DEV_WRITE_CACHE 0x00000001
22 
23 
24 //
25 // Build SCSI 1 or SCSI 2 CDBs
26 //
27 
28 #define DEV_USE_SCSI1 0x00000002
29 
30 //
31 // Indicates whether is is safe to send StartUnit commands
32 // to this device. It will only be off for some removeable devices.
33 //
34 
35 #define DEV_SAFE_START_UNIT 0x00000004
36 
37 //
38 // Indicates whether it is unsafe to send SCSIOP_MECHANISM_STATUS commands to
39 // this device. Some devices don't like these 12 byte commands
40 //
41 
42 #define DEV_NO_12BYTE_CDB 0x00000008
43 
44 
45 struct _CLASS_INIT_DATA;
46 
47 typedef VOID
51  IN OUT BOOLEAN *Retry);
52 
53 typedef BOOLEAN
55 
56 typedef NTSTATUS
58  IN PIRP Irp);
59 
60 typedef BOOLEAN
64  IN PDEVICE_OBJECT PortDeviceObject,
66 
67 typedef NTSTATUS
69  IN PIRP Irp);
70 
71 typedef NTSTATUS
73  IN PIRP Irp);
74 
75 typedef NTSTATUS
77  IN PIRP Irp);
78 
79 
80 typedef struct _CLASS_INIT_DATA
81 {
95 
96 
97 typedef struct _DEVICE_EXTENSION
98 {
137 
138 
139 typedef struct _COMPLETION_CONTEXT
140 {
144 
145 
146 /* FUNCTIONS ****************************************************************/
147 
148 IO_COMPLETION_ROUTINE ScsiClassAsynchronousCompletion;
151  IN PIRP Irp,
152  IN PVOID Context);
153 
154 VOID NTAPI
156  IN PIRP Irp);
157 
159 ScsiClassClaimDevice(IN PDEVICE_OBJECT PortDeviceObject,
160  IN PSCSI_INQUIRY_DATA LunInfo,
162  OUT PDEVICE_OBJECT *NewPortDeviceObject OPTIONAL);
163 
166  IN PCCHAR ObjectNameBuffer,
170 
173  IN PIRP Irp);
174 
175 PVOID NTAPI
176 ScsiClassFindModePage(IN PCHAR ModeSenseBuffer,
177  IN ULONG Length,
178  IN UCHAR PageMode,
179  IN BOOLEAN Use6Byte);
180 
181 ULONG NTAPI
183  OUT PSCSI_ADAPTER_BUS_INFO AdapterInformation);
184 
187  OUT PIO_SCSI_CAPABILITIES *PortCapabilities);
188 
190 ScsiClassGetInquiryData(IN PDEVICE_OBJECT PortDeviceObject,
191  OUT PSCSI_ADAPTER_BUS_INFO *ConfigInfo);
192 
193 ULONG NTAPI
197 
198 VOID NTAPI
201 
204  IN PIRP Irp);
205 
211  IN ULONG RetryCount,
212  OUT NTSTATUS *Status);
213 
216  IN PIRP Irp,
217  IN PVOID Context);
218 
221  IN PIRP Irp,
222  IN PVOID Context);
223 
224 ULONG NTAPI
226  IN PCHAR ModeSenseBuffer,
227  IN ULONG Length,
228  IN UCHAR PageMode);
229 
230 ULONG NTAPI
232 
235 
236 VOID NTAPI
238 
242  PIRP Irp,
243  PVOID BufferAddress,
245  BOOLEAN WriteToDevice);
246 
250  PVOID BufferAddress,
252  BOOLEAN WriteToDevice);
253 
254 VOID NTAPI
256  IN PIRP Irp,
257  IN ULONG MaximumBytes);
258 
259 NTSTATUS
260 NTAPI
263  IN PIRP Irp,
265  );
266 
267 /* EOF */
PCLASS_CREATE_CLOSE ClassCreateClose
Definition: class2.h:111
signed char * PCHAR
Definition: retypes.h:7
#define IN
Definition: typedefs.h:38
DEVICE_TYPE DeviceType
Definition: class2.h:84
NTSTATUS(NTAPI * PCLASS_READ_WRITE)(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class2.h:57
struct LOOKASIDE_ALIGN _NPAGED_LOOKASIDE_LIST NPAGED_LOOKASIDE_LIST
BOOLEAN(NTAPI * PCLASS_FIND_DEVICES)(IN PDRIVER_OBJECT DriverObject, IN PUNICODE_STRING RegistryPath, IN struct _CLASS_INIT_DATA *InitializationData, IN PDEVICE_OBJECT PortDeviceObject, IN ULONG PortNumber)
Definition: class2.h:61
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:694
USHORT DeviceFlags
Definition: class2.h:130
ULONG ErrorCount
Definition: class2.h:120
_In_ BOOLEAN Release
Definition: classpnp.h:929
PDRIVER_STARTIO ClassStartIo
Definition: class2.h:93
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS NTAPI ScsiClassCreateDeviceObject(IN PDRIVER_OBJECT DriverObject, IN PCCHAR ObjectNameBuffer, IN PDEVICE_OBJECT PhysicalDeviceObject OPTIONAL, IN OUT PDEVICE_OBJECT *DeviceObject, IN PCLASS_INIT_DATA InitializationData)
NTSTATUS NTAPI ScsiClassGetCapabilities(IN PDEVICE_OBJECT PortDeviceObject, OUT PIO_SCSI_CAPABILITIES *PortCapabilities)
Definition: class2.c:531
struct _COMPLETION_CONTEXT * PCOMPLETION_CONTEXT
NTSTATUS NTAPI ScsiClassSendSrbAsynchronous(PDEVICE_OBJECT DeviceObject, PSCSI_REQUEST_BLOCK Srb, PIRP Irp, PVOID BufferAddress, ULONG BufferLength, BOOLEAN WriteToDevice)
Definition: class2.c:3369
PCLASS_FIND_DEVICES ClassFindDevices
Definition: class2.h:89
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS(NTAPI * PCLASS_SHUTDOWN_FLUSH)(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class2.h:72
ULONG DMByteSkew
Definition: class2.h:103
struct _INQUIRYDATA * PINQUIRYDATA
BOOLEAN DMActive
Definition: class2.h:105
PVOID NTAPI ScsiClassFindModePage(IN PCHAR ModeSenseBuffer, IN ULONG Length, IN UCHAR PageMode, IN BOOLEAN Use6Byte)
Definition: class2.c:3295
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1122
PCLASS_DEVICE_CONTROL ClassDeviceControl
Definition: class2.h:109
UNICODE_STRING DeviceName
Definition: class2.h:135
PCLASS_READ_WRITE ClassReadWriteVerification
Definition: class2.h:87
PDEVICE_OBJECT DeviceObject
Definition: class2.h:141
BOOLEAN NTAPI ScsiClassInterpretSenseInfo(IN PDEVICE_OBJECT DeviceObject, IN PSCSI_REQUEST_BLOCK Srb, IN UCHAR MajorFunctionCode, IN ULONG IoDeviceCode, IN ULONG RetryCount, OUT NTSTATUS *Status)
Definition: class2.c:2147
NTSTATUS NTAPI ScsiClassIoCompleteAssociated(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: class2.c:1640
struct _COMPLETION_CONTEXT COMPLETION_CONTEXT
ULONG NTAPI ScsiClassInitialize(IN PVOID Argument1, IN PVOID Argument2, IN PCLASS_INIT_DATA InitializationData)
Definition: class2.c:160
SCSI_REQUEST_BLOCK Srb
Definition: class2.h:142
ULONG SrbFlags
Definition: class2.h:119
PCLASS_FIND_DEVICES ClassFindDevices
Definition: class2.h:108
NTSTATUS NTAPI ScsiClassInternalIoControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class2.c:4655
NTSTATUS NTAPI ScsiClassGetInquiryData(IN PDEVICE_OBJECT PortDeviceObject, OUT PSCSI_ADAPTER_BUS_INFO *ConfigInfo)
Definition: class2.c:612
ULONG TimeOutValue
Definition: class2.h:117
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
long LONG
Definition: pedump.c:60
_In_ ULONG BufferLength
Definition: usbdlib.h:225
NTSTATUS NTAPI ScsiClassDeviceControl(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
ULONG NTAPI ScsiClassModeSense(IN PDEVICE_OBJECT DeviceObject, IN PCHAR ModeSenseBuffer, IN ULONG Length, IN UCHAR PageMode)
Definition: class2.c:3198
NTSTATUS NTAPI ScsiClassCheckVerifyComplete(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: class2.c:4909
DRIVER_STARTIO * PDRIVER_STARTIO
Definition: iotypes.h:2137
VOID(* PCLASS_ERROR)(IN PDEVICE_OBJECT DeviceObject, IN PSCSI_REQUEST_BLOCK Srb, IN OUT NTSTATUS *Status, IN OUT BOOLEAN *Retry)
Definition: class.h:58
NTSTATUS NTAPI ScsiClassClaimDevice(IN PDEVICE_OBJECT PortDeviceObject, IN PSCSI_INQUIRY_DATA LunInfo, IN BOOLEAN Release, OUT PDEVICE_OBJECT *NewPortDeviceObject OPTIONAL)
Definition: class2.c:4488
ULONG PortNumber
Definition: storport.c:18
unsigned char BOOLEAN
_In_z_ PCCHAR ObjectNameBuffer
Definition: classpnp.h:789
ULONG DeviceExtensionSize
Definition: class2.h:83
VOID NTAPI ScsiClassBuildRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
UCHAR PortNumber
Definition: class2.h:124
static PDRIVER_OBJECT DriverObject
Definition: template.c:42
PDISK_GEOMETRY_EX DiskGeometry
Definition: class2.h:114
IN PSCSI_REQUEST_BLOCK IN OUT NTSTATUS IN OUT BOOLEAN * Retry
Definition: class2.h:49
UCHAR TargetId
Definition: class2.h:126
VOID NTAPI ScsiClassSplitRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG MaximumBytes)
Definition: class2.c:1297
PSENSE_DATA SenseData
Definition: class2.h:116
_In_ PVOID Argument2
Definition: classpnp.h:680
NTSTATUS NTAPI ScsiClassIoComplete(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
Definition: class2.c:1491
ULONG MediaChangeCount
Definition: class2.h:134
NTSTATUS NTAPI ScsiClassReadDriveCapacity(IN PDEVICE_OBJECT DeviceObject)
Definition: class2.c:714
NPAGED_LOOKASIDE_LIST SrbLookasideListHead
Definition: class2.h:122
HANDLE MediaChangeEventHandle
Definition: class2.h:132
NTSTATUS NTAPI ScsiClassSendSrbSynchronous(PDEVICE_OBJECT DeviceObject, PSCSI_REQUEST_BLOCK Srb, PVOID BufferAddress, ULONG BufferLength, BOOLEAN WriteToDevice)
Definition: class2.c:1855
BOOLEAN MediaChangeNoMedia
Definition: class2.h:133
ULONG NTAPI ScsiClassFindUnclaimedDevices(IN PCLASS_INIT_DATA InitializationData, OUT PSCSI_ADAPTER_BUS_INFO AdapterInformation)
PCLASS_CREATE_CLOSE ClassCreateClose
Definition: class2.h:92
_In_opt_ PIRP _In_ PSCSI_REQUEST_BLOCK _In_ UCHAR MajorFunctionCode
Definition: classpnp.h:465
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
LARGE_INTEGER StartingOffset
Definition: class2.h:102
unsigned char UCHAR
Definition: xmlstorage.h:181
#define NTSTATUS
Definition: precomp.h:20
_In_ PVOID _In_ PCLASS_INIT_DATA InitializationData
Definition: classpnp.h:680
PDRIVER_STARTIO ClassStartIo
Definition: class2.h:112
ULONG DeviceCharacteristics
Definition: class2.h:85
PCLASS_ERROR ClassError
Definition: class2.h:106
ULONG InitializationDataSize
Definition: class2.h:82
PCLASS_DEVICE_CONTROL ClassDeviceControl
Definition: class2.h:90
Status
Definition: gdiplustypes.h:24
BOOLEAN(NTAPI * PCLASS_DEVICE_CALLBACK)(IN PINQUIRYDATA)
Definition: class2.h:54
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
PCLASS_SHUTDOWN_FLUSH ClassShutdownFlush
Definition: class2.h:110
UCHAR ReservedByte
Definition: class2.h:129
PCLASS_READ_WRITE ClassReadWriteVerification
Definition: class2.h:107
unsigned short USHORT
Definition: pedump.c:61
typedef VOID(NTAPI *PCLASS_ERROR)(IN PDEVICE_OBJECT DeviceObject
VOID NTAPI ScsiClassReleaseQueue(IN PDEVICE_OBJECT DeviceObject)
Definition: class2.c:938
PDEVICE_OBJECT DeviceObject
Definition: mntmgr.h:15
PCLASS_DEVICE_CALLBACK ClassFindDeviceCallBack
Definition: class2.h:88
ULONG KSPIN_LOCK
Definition: env_spec_w32.h:72
#define DEVICE_TYPE
Definition: guid.c:10
UCHAR SectorShift
Definition: class2.h:128
struct _CLASS_INIT_DATA CLASS_INIT_DATA
NTSTATUS(NTAPI * PCLASS_CREATE_CLOSE)(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class2.h:76
PCLASS_SHUTDOWN_FLUSH ClassShutdownFlush
Definition: class2.h:91
ULONG NTAPI ScsiClassQueryTimeOutRegistryValue(IN PUNICODE_STRING RegistryPath)
Definition: class2.c:4816
_In_ ULONG NumberElements
Definition: classpnp.h:944
IN PSCSI_REQUEST_BLOCK IN OUT NTSTATUS * Status
Definition: class2.h:49
#define BOOLEAN
Definition: pedump.c:73
#define OUT
Definition: typedefs.h:39
unsigned int ULONG
Definition: retypes.h:1
PIO_SCSI_CAPABILITIES PortCapabilities
Definition: class2.h:113
KSPIN_LOCK SplitRequestSpinLock
Definition: class2.h:121
_In_ PUNICODE_STRING RegistryPath
Definition: wmip.h:27
LARGE_INTEGER PartitionLength
Definition: class2.h:101
NTSTATUS(NTAPI * PCLASS_DEVICE_CONTROL)(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: class2.h:68
PDEVICE_OBJECT PortDeviceObject
Definition: class2.h:100
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
struct _DEVICE_EXTENSION * PDEVICE_EXTENSION
PDEVICE_OBJECT PhysicalDevice
Definition: class2.h:115
VOID NTAPI ScsiClassInitializeSrbLookasideList(IN PDEVICE_EXTENSION DeviceExtension, IN ULONG NumberElements)
Definition: class2.c:4778
struct _CLASS_INIT_DATA * PCLASS_INIT_DATA
PCLASS_ERROR ClassError
Definition: class2.h:86
ULONG DeviceNumber
Definition: class2.h:118
IO_COMPLETION_ROUTINE ScsiClassAsynchronousCompletion
Definition: class2.h:148
_In_opt_ PIRP _In_ PSCSI_REQUEST_BLOCK _In_ UCHAR _In_ ULONG IoDeviceCode
Definition: classpnp.h:465
struct _DEVICE_EXTENSION DEVICE_EXTENSION
PKEVENT MediaChangeEvent
Definition: class2.h:131
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68