[UDFS] Svn add some missing files. CORE-9774
[reactos.git] / reactos / drivers / filesystems / udfs / CDRW / scsi_port.h
1 ////////////////////////////////////////////////////////////////////
2 // Copyright (C) Alexander Telyatnikov, Ivan Keliukh, Yegor Anchishkin, SKIF Software, 1999-2013. Kiev, Ukraine
3 // All rights reserved
4 ////////////////////////////////////////////////////////////////////
5 /*
6
7 Module Name:
8
9 scsi_port.h
10
11 Abstract:
12
13 This is the include file that defines all constants and types for
14 accessing the SCSI port adapters.
15
16 Environment:
17
18 kernel mode only
19 */
20
21 #ifndef __SCSI_PORT_H__
22 #define __SCSI_PORT_H__
23
24 #ifndef WIN64
25
26 #include "srb.h"
27
28 #ifdef SCSIPORT_API
29 #undef SCSIPORT_API
30 #endif
31
32 // Device Name - this string is the name of the device. It is the name
33 // that should be passed to NtOpenFile when accessing the device.
34 //
35 // Note: For devices that support multiple units, it should be suffixed
36 // with the Ascii representation of the unit number.
37
38 #define IOCTL_SCSI_BASE FILE_DEVICE_CONTROLLER
39
40 #define DD_SCSI_DEVICE_NAME "\\Device\\ScsiPort"
41
42
43 // NtDeviceIoControlFile IoControlCode values for this device.
44 //
45 // Warning: Remember that the low two bits of the code specify how the
46 // buffers are passed to the driver!
47
48 #define IOCTL_SCSI_PASS_THROUGH CTL_CODE(IOCTL_SCSI_BASE, 0x0401, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
49 #define IOCTL_SCSI_MINIPORT CTL_CODE(IOCTL_SCSI_BASE, 0x0402, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
50 #define IOCTL_SCSI_GET_INQUIRY_DATA CTL_CODE(IOCTL_SCSI_BASE, 0x0403, METHOD_BUFFERED, FILE_ANY_ACCESS)
51 #define IOCTL_SCSI_GET_CAPABILITIES CTL_CODE(IOCTL_SCSI_BASE, 0x0404, METHOD_BUFFERED, FILE_ANY_ACCESS)
52 #define IOCTL_SCSI_PASS_THROUGH_DIRECT CTL_CODE(IOCTL_SCSI_BASE, 0x0405, METHOD_BUFFERED, FILE_READ_ACCESS | FILE_WRITE_ACCESS)
53 #define IOCTL_SCSI_GET_ADDRESS CTL_CODE(IOCTL_SCSI_BASE, 0x0406, METHOD_BUFFERED, FILE_ANY_ACCESS)
54 #define IOCTL_SCSI_RESCAN_BUS CTL_CODE(IOCTL_SCSI_BASE, 0x0407, METHOD_BUFFERED, FILE_ANY_ACCESS)
55 #define IOCTL_SCSI_GET_DUMP_POINTERS CTL_CODE(IOCTL_SCSI_BASE, 0x0408, METHOD_BUFFERED, FILE_ANY_ACCESS)
56
57 // Define the SCSI pass through structure.
58
59 typedef struct _SCSI_PASS_THROUGH {
60 USHORT Length;
61 UCHAR ScsiStatus;
62 UCHAR PathId;
63 UCHAR TargetId;
64 UCHAR Lun;
65 UCHAR CdbLength;
66 UCHAR SenseInfoLength;
67 UCHAR DataIn;
68 ULONG DataTransferLength;
69 ULONG TimeOutValue;
70 ULONG DataBufferOffset;
71 ULONG SenseInfoOffset;
72 UCHAR Cdb[16];
73 }SCSI_PASS_THROUGH, *PSCSI_PASS_THROUGH;
74
75 // Define the SCSI pass through direct structure.
76
77 typedef struct _SCSI_PASS_THROUGH_DIRECT {
78 USHORT Length;
79 UCHAR ScsiStatus;
80 UCHAR PathId;
81 UCHAR TargetId;
82 UCHAR Lun;
83 UCHAR CdbLength;
84 UCHAR SenseInfoLength;
85 UCHAR DataIn;
86 ULONG DataTransferLength;
87 ULONG TimeOutValue;
88 PVOID DataBuffer;
89 ULONG SenseInfoOffset;
90 UCHAR Cdb[16];
91 }SCSI_PASS_THROUGH_DIRECT, *PSCSI_PASS_THROUGH_DIRECT;
92
93 // Define SCSI information.
94 // Used with the IOCTL_SCSI_GET_INQUIRY_DATA IOCTL.
95
96 typedef struct _SCSI_BUS_DATA {
97 UCHAR NumberOfLogicalUnits;
98 UCHAR InitiatorBusId;
99 ULONG InquiryDataOffset;
100 }SCSI_BUS_DATA, *PSCSI_BUS_DATA;
101
102 // Define SCSI adapter bus information structure..
103 // Used with the IOCTL_SCSI_GET_INQUIRY_DATA IOCTL.
104
105 typedef struct _SCSI_ADAPTER_BUS_INFO {
106 UCHAR NumberOfBuses;
107 SCSI_BUS_DATA BusData[1];
108 } SCSI_ADAPTER_BUS_INFO, *PSCSI_ADAPTER_BUS_INFO;
109
110 // Define SCSI adapter bus information.
111 // Used with the IOCTL_SCSI_GET_INQUIRY_DATA IOCTL.
112
113 typedef struct _SCSI_INQUIRY_DATA {
114 UCHAR PathId;
115 UCHAR TargetId;
116 UCHAR Lun;
117 BOOLEAN DeviceClaimed;
118 ULONG InquiryDataLength;
119 ULONG NextInquiryDataOffset;
120 UCHAR InquiryData[1];
121 }SCSI_INQUIRY_DATA, *PSCSI_INQUIRY_DATA;
122
123 // Define header for I/O control SRB.
124
125 typedef struct _SRB_IO_CONTROL {
126 ULONG HeaderLength;
127 UCHAR Signature[8];
128 ULONG Timeout;
129 ULONG ControlCode;
130 ULONG ReturnCode;
131 ULONG Length;
132 } SRB_IO_CONTROL, *PSRB_IO_CONTROL;
133
134 // SCSI port driver capabilities structure.
135
136 typedef struct _IO_SCSI_CAPABILITIES {
137 ULONG Length; // Length of this structure
138 ULONG MaximumTransferLength; // Maximum transfer size in single SRB (obsolete)
139 ULONG MaximumPhysicalPages; // Maximum number of physical pages per data buffer
140 ULONG SupportedAsynchronousEvents; // Async calls from port to class
141 ULONG AlignmentMask; // Alignment mask for data transfers.
142 BOOLEAN TaggedQueuing; // Supports tagged queuing
143 BOOLEAN AdapterScansDown; // Host adapter scans down for bios devices.
144 BOOLEAN AdapterUsesPio; // The host adapter uses programmed I/O.
145 } IO_SCSI_CAPABILITIES, *PIO_SCSI_CAPABILITIES;
146
147 typedef struct _SCSI_ADDRESS {
148 ULONG Length;
149 UCHAR PortNumber;
150 UCHAR PathId;
151 UCHAR TargetId;
152 UCHAR Lun;
153 }SCSI_ADDRESS, *PSCSI_ADDRESS;
154
155 // Define structure for returning crash dump pointers.
156
157 struct _ADAPTER_OBJECT;
158
159 typedef struct _DUMP_POINTERS {
160 struct _ADAPTER_OBJECT *AdapterObject;
161 PVOID MappedRegisterBase;
162 PVOID PortConfiguration;
163 PVOID CommonBufferVa;
164 LARGE_INTEGER CommonBufferPa;
165 ULONG CommonBufferSize;
166 } DUMP_POINTERS, *PDUMP_POINTERS;
167
168 #endif //WIN64
169
170
171 // Define values for pass-through DataIn field.
172
173 #define SCSI_IOCTL_DATA_OUT 0
174 #define SCSI_IOCTL_DATA_IN 1
175 #define SCSI_IOCTL_DATA_UNSPECIFIED 2
176
177 #define CLASS_SPECIAL_CAUSE_NOT_REPORTABLE_HACK 0x00000020
178
179 #define SCSIPORT_API
180
181 #ifndef USER_MODE
182 extern NTSTATUS ScsiClassGetInquiryData(IN PDEVICE_OBJECT PortDeviceObject,
183 IN PSCSI_ADAPTER_BUS_INFO *ConfigInfo);
184 extern NTSTATUS ScsiClassReadDeviceInquiryData(IN PDEVICE_OBJECT DeviceObject,
185 IN BOOLEAN DirectAccess);
186 extern NTSTATUS ScsiClassReadDriveCapacity(IN PDEVICE_OBJECT DeviceObject);
187
188 #ifndef CDRW_W32
189
190 // Class dll routines called by class drivers
191
192 extern NTSTATUS ScsiClassGetCapabilities(IN PDEVICE_OBJECT PortDeviceObject,
193 OUT PIO_SCSI_CAPABILITIES *PortCapabilities);
194 extern NTSTATUS ScsiClassGetAddress(IN PDEVICE_OBJECT ClassDeviceObject,
195 OUT PSCSI_ADDRESS Address);
196 extern VOID ScsiClassReleaseQueue(IN PDEVICE_OBJECT DeviceObject);
197 extern NTSTATUS ScsiClassRemoveDevice(IN PDEVICE_OBJECT PortDeviceObject, IN UCHAR PathId,
198 IN UCHAR TargetId, IN UCHAR Lun);
199 extern NTSTATUS ScsiClassClaimDevice(IN PDEVICE_OBJECT PortDeviceObject,
200 IN PSCSI_INQUIRY_DATA LunInfo, IN BOOLEAN Release,
201 OUT PDEVICE_OBJECT *NewPortDeviceObject OPTIONAL);
202 extern NTSTATUS ScsiClassInternalIoControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp);
203 extern NTSTATUS ScsiClassIoCompletion(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp,
204 IN PVOID Context);
205 extern NTSTATUS ScsiClassSendSrbSynchronous(IN PDEVICE_OBJECT TargetDeviceObject,
206 IN PSCSI_REQUEST_BLOCK _srb,
207 IN PKEVENT event);
208
209 #endif //CDRW_W32
210
211 extern VOID ScsiClassInitSrbBusAddr(PSCSI_REQUEST_BLOCK Srb,
212 PVOID DeviceExtension);
213
214 extern NTSTATUS
215 DbgWaitForSingleObject_(
216 IN PVOID Object,
217 IN PLARGE_INTEGER Timeout OPTIONAL
218 );
219 #endif //USER_MODE
220
221 #endif //__SCSI_PORT_H__