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