]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.h
Porting R8's PI-enabled ScsiBus driver
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiBusDxe / ScsiBus.h
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 ScsiBus.h
15
16 Abstract:
17
18 Header file for SCSI Bus Driver.
19
20 Revision History
21 ++*/
22
23 // TODO: fix comment to end with --*/
24 #ifndef _SCSI_BUS_H
25 #define _SCSI_BUS_H
26
27
28 #include <IndustryStandard/scsi.h>
29 //
30 // 1000 * 1000 * 10
31 //
32 #define ONE_SECOND_TIMER 10000000
33
34 #define SCSI_IO_DEV_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 'i', 'o')
35
36 typedef struct _SCSI_TARGET_ID {
37 union {
38 UINT32 Scsi;
39 UINT8 ExtScsi[4];
40 } ScsiId;
41 UINT8 ExtScsiId[12];
42 }SCSI_TARGET_ID;
43
44
45 typedef struct {
46 VOID *Data1;
47 VOID *Data2;
48 } SCSI_EVENT_DATA;
49
50
51 typedef struct {
52 UINT32 Signature;
53 EFI_HANDLE Handle;
54 EFI_SCSI_IO_PROTOCOL ScsiIo;
55 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
56 BOOLEAN ExtScsiSupport;
57 EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru;
58 EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiPassThru;
59 SCSI_TARGET_ID Pun;
60 UINT64 Lun;
61 UINT8 ScsiDeviceType;
62 UINT8 ScsiVersion;
63 BOOLEAN RemovableDevice;
64 } SCSI_IO_DEV;
65
66 #define SCSI_IO_DEV_FROM_THIS(a) CR (a, SCSI_IO_DEV, ScsiIo, SCSI_IO_DEV_SIGNATURE)
67
68 //
69 // SCSI Bus Controller device strcuture
70 //
71 #define EFI_SCSI_BUS_PROTOCOL_GUID \
72 { \
73 0x5261213D, 0x3A3D, 0x441E, 0xB3, 0xAF, 0x21, 0xD3, 0xF7, 0xA4, 0xCA, 0x17 \
74 }
75
76 typedef struct _EFI_SCSI_BUS_PROTOCOL {
77 UINT64 Reserved;
78 } EFI_SCSI_BUS_PROTOCOL;
79
80 #define SCSI_BUS_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 's', 'i')
81
82
83 typedef struct _SCSI_BUS_DEVICE {
84 UINTN Signature;
85 EFI_SCSI_BUS_PROTOCOL BusIdentify;
86 BOOLEAN ExtScsiSupport;
87 EFI_SCSI_PASS_THRU_PROTOCOL *ScsiInterface;
88 EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiInterface;
89 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
90 } SCSI_BUS_DEVICE;
91
92 #define SCSI_BUS_CONTROLLER_DEVICE_FROM_THIS(a) CR (a, SCSI_BUS_DEVICE, BusIdentify, SCSI_BUS_DEVICE_SIGNATURE)
93
94 //
95 // Global Variables
96 //
97 extern EFI_DRIVER_BINDING_PROTOCOL gScsiBusDriverBinding;
98 extern EFI_COMPONENT_NAME_PROTOCOL gScsiBusComponentName;
99
100 EFI_STATUS
101 EFIAPI
102 SCSIBusDriverBindingSupported (
103 IN EFI_DRIVER_BINDING_PROTOCOL *This,
104 IN EFI_HANDLE Controller,
105 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
106 );
107
108 EFI_STATUS
109 EFIAPI
110 SCSIBusDriverBindingStart (
111 IN EFI_DRIVER_BINDING_PROTOCOL *This,
112 IN EFI_HANDLE Controller,
113 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
114 );
115
116 EFI_STATUS
117 EFIAPI
118 SCSIBusDriverBindingStop (
119 IN EFI_DRIVER_BINDING_PROTOCOL *This,
120 IN EFI_HANDLE Controller,
121 IN UINTN NumberOfChildren,
122 IN EFI_HANDLE *ChildHandleBuffer
123 );
124
125 //
126 // EFI Component Name Functions
127 //
128 EFI_STATUS
129 EFIAPI
130 ScsiBusComponentNameGetDriverName (
131 IN EFI_COMPONENT_NAME_PROTOCOL *This,
132 IN CHAR8 *Language,
133 OUT CHAR16 **DriverName
134 );
135
136 EFI_STATUS
137 EFIAPI
138 ScsiBusComponentNameGetControllerName (
139 IN EFI_COMPONENT_NAME_PROTOCOL *This,
140 IN EFI_HANDLE ControllerHandle,
141 IN EFI_HANDLE ChildHandle OPTIONAL,
142 IN CHAR8 *Language,
143 OUT CHAR16 **ControllerName
144 );
145
146 EFI_STATUS
147 EFIAPI
148 ScsiGetDeviceType (
149 IN EFI_SCSI_IO_PROTOCOL *This,
150 OUT UINT8 *DeviceType
151 )
152 /*++
153
154 Routine Description:
155
156 Retrieves the device type information of the SCSI Controller.
157
158 Arguments:
159
160 This - Protocol instance pointer.
161 DeviceType - A pointer to the device type information
162 retrieved from the SCSI Controller.
163
164 Returns:
165
166 EFI_SUCCESS - Retrieves the device type information successfully.
167 EFI_INVALID_PARAMETER - The DeviceType is NULL.
168
169 --*/
170 ;
171
172 EFI_STATUS
173 EFIAPI
174 ScsiResetBus (
175 IN EFI_SCSI_IO_PROTOCOL *This
176 )
177 /*++
178
179 Routine Description:
180
181 Resets the SCSI Bus that the SCSI Controller is attached to.
182
183 Arguments:
184
185 This - Protocol instance pointer.
186
187 Returns:
188
189 EFI_SUCCESS - The SCSI bus is reset successfully.
190 EFI_DEVICE_ERROR - Errors encountered when resetting the SCSI bus.
191 EFI_UNSUPPORTED - The bus reset operation is not supported by the
192 SCSI Host Controller.
193 EFI_TIMEOUT - A timeout occurred while attempting to reset
194 the SCSI bus.
195
196 --*/
197 ;
198
199 EFI_STATUS
200 EFIAPI
201 ScsiResetDevice (
202 IN EFI_SCSI_IO_PROTOCOL *This
203 )
204 /*++
205
206 Routine Description:
207
208 Resets the SCSI Controller that the device handle specifies.
209
210 Arguments:
211
212 This - Protocol instance pointer.
213
214 Returns:
215
216 EFI_SUCCESS - Reset the SCSI controller successfully.
217 EFI_DEVICE_ERROR - Errors are encountered when resetting the
218 SCSI Controller.
219 EFI_UNSUPPORTED - The SCSI bus does not support a device
220 reset operation.
221 EFI_TIMEOUT - A timeout occurred while attempting to
222 reset the SCSI Controller.
223
224 --*/
225 ;
226
227 EFI_STATUS
228 EFIAPI
229 ScsiExecuteSCSICommand (
230 IN EFI_SCSI_IO_PROTOCOL *This,
231 IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *CommandPacket,
232 IN EFI_EVENT Event
233 )
234 /*++
235
236 Routine Description:
237
238 Sends a SCSI Request Packet to the SCSI Controller for execution.
239
240 Arguments:
241
242 This - Protocol instance pointer.
243 Packet - The SCSI request packet to send to the SCSI
244 Controller specified by the device handle.
245 Event - If the SCSI bus where the SCSI device is attached
246 does not support non-blocking I/O, then Event is
247 ignored, and blocking I/O is performed.
248 If Event is NULL, then blocking I/O is performed.
249 If Event is not NULL and non-blocking I/O is
250 supported, then non-blocking I/O is performed,
251 and Event will be signaled when the SCSI Request
252 Packet completes.
253 Returns:
254
255 EFI_SUCCESS - The SCSI Request Packet was sent by the host
256 successfully, and TransferLength bytes were
257 transferred to/from DataBuffer.See
258 HostAdapterStatus, TargetStatus,
259 SenseDataLength, and SenseData in that order
260 for additional status information.
261 EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was executed,
262 but the entire DataBuffer could not be transferred.
263 The actual number of bytes transferred is returned
264 in TransferLength. See HostAdapterStatus,
265 TargetStatus, SenseDataLength, and SenseData in
266 that order for additional status information.
267 EFI_NOT_READY - The SCSI Request Packet could not be sent because
268 there are too many SCSI Command Packets already
269 queued.The caller may retry again later.
270 EFI_DEVICE_ERROR - A device error occurred while attempting to send
271 the SCSI Request Packet. See HostAdapterStatus,
272 TargetStatus, SenseDataLength, and SenseData in
273 that order for additional status information.
274 EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
275 The SCSI Request Packet was not sent, so no
276 additional status information is available.
277 EFI_UNSUPPORTED - The command described by the SCSI Request Packet
278 is not supported by the SCSI initiator(i.e., SCSI
279 Host Controller). The SCSI Request Packet was not
280 sent, so no additional status information is
281 available.
282 EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
283 Request Packet to execute. See HostAdapterStatus,
284 TargetStatus, SenseDataLength, and SenseData in
285 that order for additional status information.
286
287 --*/
288 ;
289
290 EFI_STATUS
291 ScsiScanCreateDevice (
292 EFI_DRIVER_BINDING_PROTOCOL *This,
293 EFI_HANDLE Controller,
294 SCSI_TARGET_ID *TargetId,
295 UINT64 Lun,
296 SCSI_BUS_DEVICE *ScsiBusDev
297 )
298 /*++
299
300 Routine Description:
301
302 Scan SCSI Bus to discover the device, and attach ScsiIoProtocol to it.
303
304 Arguments:
305
306 This - Protocol instance pointer
307 Controller - Controller handle
308 Pun - The Pun of the SCSI device on the SCSI channel.
309 Lun - The Lun of the SCSI device on the SCSI channel.
310 ScsiBusDev - The pointer of SCSI_BUS_DEVICE
311
312 Returns:
313
314 EFI_SUCCESS - Successfully to discover the device and attach ScsiIoProtocol to it.
315 EFI_OUT_OF_RESOURCES - Fail to discover the device.
316
317 --*/
318 ;
319
320 BOOLEAN
321 DiscoverScsiDevice (
322 SCSI_IO_DEV *ScsiIoDevice
323 )
324 /*++
325
326 Routine Description:
327
328 TODO: Add function description
329
330 Arguments:
331
332 ScsiIoDevice - TODO: add argument description
333
334 Returns:
335
336 TODO: add return values
337
338 --*/
339 ;
340
341 EFI_STATUS
342 GetLunList (
343 EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru,
344 UINT32 Target,
345 UINT64 **LunArray,
346 UINTN *NumberOfLuns
347 )
348 /*++
349
350 Routine Description:
351
352 TODO: Add function description
353
354 Arguments:
355
356 ScsiPassThru - TODO: add argument description
357 Target - TODO: add argument description
358 LunArray - TODO: add argument description
359 NumberOfLuns - TODO: add argument description
360
361 Returns:
362
363 TODO: add return values
364
365 --*/
366 ;
367
368 EFI_STATUS
369 ScsiBusSubmitReportLunCommand (
370 EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru,
371 UINT32 Target,
372 UINTN AllocationLength,
373 VOID *Buffer,
374 EFI_SCSI_SENSE_DATA *SenseData,
375 UINT8 *SenseDataLength,
376 UINT8 *HostAdapterStatus,
377 UINT8 *TargetStatus
378 )
379 /*++
380
381 Routine Description:
382
383 TODO: Add function description
384
385 Arguments:
386
387 ScsiPassThru - TODO: add argument description
388 Target - TODO: add argument description
389 AllocationLength - TODO: add argument description
390 Buffer - TODO: add argument description
391 SenseData - TODO: add argument description
392 SenseDataLength - TODO: add argument description
393 HostAdapterStatus - TODO: add argument description
394 TargetStatus - TODO: add argument description
395
396 Returns:
397
398 TODO: add return values
399
400 --*/
401 ;
402 #endif