]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Scsi/ScsiBusDxe/ScsiBus.h
MdeModulePkg/Bus/Scsi: Fix various typos
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiBusDxe / ScsiBus.h
CommitLineData
3b2dbece 1/** @file\r
2 Header file for SCSI Bus Driver.\r
3a10d471 3\r
d1102dba 4Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
3a10d471 6\r
3b2dbece 7**/\r
3a10d471 8\r
9beb888e 9#ifndef _SCSI_BUS_H_\r
10#define _SCSI_BUS_H_\r
3a10d471 11\r
12\r
9beb888e 13#include <Uefi.h>\r
14\r
15#include <Protocol/ScsiPassThru.h>\r
16#include <Protocol/ScsiPassThruExt.h>\r
17#include <Protocol/ScsiIo.h>\r
18#include <Protocol/ComponentName.h>\r
19#include <Protocol/DriverBinding.h>\r
20#include <Protocol/DevicePath.h>\r
21\r
22#include <Library/DebugLib.h>\r
23#include <Library/UefiDriverEntryPoint.h>\r
24#include <Library/UefiLib.h>\r
25#include <Library/BaseMemoryLib.h>\r
26#include <Library/MemoryAllocationLib.h>\r
ae50ee26 27#include <Library/UefiScsiLib.h>\r
9beb888e 28#include <Library/UefiBootServicesTableLib.h>\r
29#include <Library/DevicePathLib.h>\r
37623a5c 30#include <Library/ReportStatusCodeLib.h>\r
9beb888e 31\r
9cb8724d 32#include <IndustryStandard/Scsi.h>\r
3a10d471 33\r
f3f2e05d 34#define SCSI_IO_DEV_SIGNATURE SIGNATURE_32 ('s', 'c', 'i', 'o')\r
3a10d471 35\r
1ccdbf2a 36typedef union {\r
37 UINT32 Scsi;\r
d1102dba 38 UINT8 ExtScsi[4];\r
1ccdbf2a 39} SCSI_ID;\r
40\r
70c94b3b 41typedef struct _SCSI_TARGET_ID {\r
1ccdbf2a 42 SCSI_ID ScsiId;\r
70c94b3b 43 UINT8 ExtScsiId[12];\r
44}SCSI_TARGET_ID;\r
45\r
46\r
47typedef struct {\r
48 VOID *Data1;\r
49 VOID *Data2;\r
50} SCSI_EVENT_DATA;\r
51\r
70c94b3b 52//\r
cc530cd1 53// SCSI Bus Controller device structure\r
70c94b3b 54//\r
37623a5c 55#define SCSI_BUS_DEVICE_SIGNATURE SIGNATURE_32 ('s', 'c', 's', 'i')\r
70c94b3b 56\r
3cc033c5
FT
57//\r
58// SCSI Bus Timeout Experience Value\r
59//\r
60#define SCSI_BUS_TIMEOUT EFI_TIMER_PERIOD_SECONDS (3)\r
61\r
c8ad2d7a
LG
62//\r
63// The ScsiBusProtocol is just used to locate ScsiBusDev\r
64// structure in the SCSIBusDriverBindingStop(). Then we can\r
65// Close all opened protocols and release this structure.\r
66// ScsiBusProtocol is the private protocol.\r
67// gEfiCallerIdGuid will be used as its protocol guid.\r
68//\r
70c94b3b 69typedef struct _EFI_SCSI_BUS_PROTOCOL {\r
70 UINT64 Reserved;\r
71} EFI_SCSI_BUS_PROTOCOL;\r
72\r
70c94b3b 73typedef struct _SCSI_BUS_DEVICE {\r
74 UINTN Signature;\r
75 EFI_SCSI_BUS_PROTOCOL BusIdentify;\r
d1102dba 76 BOOLEAN ExtScsiSupport;\r
70c94b3b 77 EFI_SCSI_PASS_THRU_PROTOCOL *ScsiInterface;\r
78 EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiInterface;\r
79 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
80} SCSI_BUS_DEVICE;\r
81\r
82#define SCSI_BUS_CONTROLLER_DEVICE_FROM_THIS(a) CR (a, SCSI_BUS_DEVICE, BusIdentify, SCSI_BUS_DEVICE_SIGNATURE)\r
83\r
37623a5c 84typedef struct {\r
85 UINT32 Signature;\r
86 EFI_HANDLE Handle;\r
87 EFI_SCSI_IO_PROTOCOL ScsiIo;\r
88 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
d1102dba 89 BOOLEAN ExtScsiSupport;\r
37623a5c 90 EFI_SCSI_PASS_THRU_PROTOCOL *ScsiPassThru;\r
91 EFI_EXT_SCSI_PASS_THRU_PROTOCOL *ExtScsiPassThru;\r
92 SCSI_BUS_DEVICE *ScsiBusDeviceData;\r
93 SCSI_TARGET_ID Pun;\r
94 UINT64 Lun;\r
95 UINT8 ScsiDeviceType;\r
96 UINT8 ScsiVersion;\r
97 BOOLEAN RemovableDevice;\r
98} SCSI_IO_DEV;\r
99\r
100#define SCSI_IO_DEV_FROM_THIS(a) CR (a, SCSI_IO_DEV, ScsiIo, SCSI_IO_DEV_SIGNATURE)\r
101\r
3a10d471 102//\r
103// Global Variables\r
104//\r
70da5bc2 105extern EFI_DRIVER_BINDING_PROTOCOL gScsiBusDriverBinding;\r
106extern EFI_COMPONENT_NAME_PROTOCOL gScsiBusComponentName;\r
107extern EFI_COMPONENT_NAME2_PROTOCOL gScsiBusComponentName2;\r
3a10d471 108\r
9beb888e 109/**\r
110 Test to see if this driver supports ControllerHandle.\r
111\r
112 This service is called by the EFI boot service ConnectController(). In order\r
113 to make drivers as small as possible, there are a few calling restrictions for\r
114 this service. ConnectController() must follow these calling restrictions. If\r
115 any other agent wishes to call Supported() it must also follow these calling\r
116 restrictions.\r
117\r
118 @param This Protocol instance pointer.\r
119 @param ControllerHandle Handle of device to test\r
120 @param RemainingDevicePath Optional parameter use to pick a specific child\r
121 device to start.\r
122\r
123 @retval EFI_SUCCESS This driver supports this device\r
124 @retval EFI_ALREADY_STARTED This driver is already running on this device\r
125 @retval other This driver does not support this device\r
126\r
127**/\r
3a10d471 128EFI_STATUS\r
129EFIAPI\r
130SCSIBusDriverBindingSupported (\r
131 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
132 IN EFI_HANDLE Controller,\r
133 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
134 );\r
135\r
9beb888e 136/**\r
137 Start this driver on ControllerHandle.\r
138\r
139 This service is called by the EFI boot service ConnectController(). In order\r
140 to make drivers as small as possible, there are a few calling restrictions for\r
141 this service. ConnectController() must follow these calling restrictions. If\r
142 any other agent wishes to call Start() it must also follow these calling\r
143 restrictions.\r
144\r
145 @param This Protocol instance pointer.\r
146 @param ControllerHandle Handle of device to bind driver to\r
147 @param RemainingDevicePath Optional parameter use to pick a specific child\r
148 device to start.\r
149\r
150 @retval EFI_SUCCESS This driver is added to ControllerHandle\r
151 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
152 @retval other This driver does not support this device\r
153\r
154**/\r
3a10d471 155EFI_STATUS\r
156EFIAPI\r
157SCSIBusDriverBindingStart (\r
158 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
159 IN EFI_HANDLE Controller,\r
160 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath\r
161 );\r
162\r
9beb888e 163/**\r
164 Stop this driver on ControllerHandle.\r
165\r
166 This service is called by the EFI boot service DisconnectController().\r
167 In order to make drivers as small as possible, there are a few calling\r
168 restrictions for this service. DisconnectController() must follow these\r
169 calling restrictions. If any other agent wishes to call Stop() it must also\r
170 follow these calling restrictions.\r
d1102dba 171\r
9beb888e 172 @param This Protocol instance pointer.\r
173 @param ControllerHandle Handle of device to stop driver on\r
174 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
175 children is zero stop the entire bus driver.\r
176 @param ChildHandleBuffer List of Child Handles to Stop.\r
177\r
178 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
179 @retval other This driver was not removed from this device\r
180\r
181**/\r
3a10d471 182EFI_STATUS\r
183EFIAPI\r
184SCSIBusDriverBindingStop (\r
185 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
186 IN EFI_HANDLE Controller,\r
187 IN UINTN NumberOfChildren,\r
188 IN EFI_HANDLE *ChildHandleBuffer\r
189 );\r
190\r
191//\r
192// EFI Component Name Functions\r
193//\r
70da5bc2 194/**\r
195 Retrieves a Unicode string that is the user readable name of the driver.\r
196\r
197 This function retrieves the user readable name of a driver in the form of a\r
198 Unicode string. If the driver specified by This has a user readable name in\r
199 the language specified by Language, then a pointer to the driver name is\r
200 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
201 by This does not support the language specified by Language,\r
202 then EFI_UNSUPPORTED is returned.\r
203\r
9beb888e 204 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
70da5bc2 205 EFI_COMPONENT_NAME_PROTOCOL instance.\r
206\r
9beb888e 207 @param Language A pointer to a Null-terminated ASCII string\r
70da5bc2 208 array indicating the language. This is the\r
209 language of the driver name that the caller is\r
210 requesting, and it must match one of the\r
211 languages specified in SupportedLanguages. The\r
212 number of languages supported by a driver is up\r
213 to the driver writer. Language is specified\r
0254efc0 214 in RFC 4646 or ISO 639-2 language code format.\r
70da5bc2 215\r
9beb888e 216 @param DriverName A pointer to the Unicode string to return.\r
70da5bc2 217 This Unicode string is the name of the\r
218 driver specified by This in the language\r
219 specified by Language.\r
220\r
221 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
222 This and the language specified by Language was\r
223 returned in DriverName.\r
224\r
225 @retval EFI_INVALID_PARAMETER Language is NULL.\r
226\r
227 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
228\r
229 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
230 the language specified by Language.\r
231\r
232**/\r
3a10d471 233EFI_STATUS\r
234EFIAPI\r
235ScsiBusComponentNameGetDriverName (\r
236 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
237 IN CHAR8 *Language,\r
238 OUT CHAR16 **DriverName\r
239 );\r
240\r
70da5bc2 241/**\r
242 Retrieves a Unicode string that is the user readable name of the controller\r
243 that is being managed by a driver.\r
244\r
245 This function retrieves the user readable name of the controller specified by\r
246 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
247 driver specified by This has a user readable name in the language specified by\r
248 Language, then a pointer to the controller name is returned in ControllerName,\r
249 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
250 managing the controller specified by ControllerHandle and ChildHandle,\r
251 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
252 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
253\r
9beb888e 254 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
70da5bc2 255 EFI_COMPONENT_NAME_PROTOCOL instance.\r
256\r
9beb888e 257 @param ControllerHandle The handle of a controller that the driver\r
70da5bc2 258 specified by This is managing. This handle\r
259 specifies the controller whose name is to be\r
260 returned.\r
261\r
9beb888e 262 @param ChildHandle The handle of the child controller to retrieve\r
70da5bc2 263 the name of. This is an optional parameter that\r
264 may be NULL. It will be NULL for device\r
265 drivers. It will also be NULL for a bus drivers\r
266 that wish to retrieve the name of the bus\r
267 controller. It will not be NULL for a bus\r
268 driver that wishes to retrieve the name of a\r
269 child controller.\r
270\r
9beb888e 271 @param Language A pointer to a Null-terminated ASCII string\r
70da5bc2 272 array indicating the language. This is the\r
273 language of the driver name that the caller is\r
274 requesting, and it must match one of the\r
275 languages specified in SupportedLanguages. The\r
276 number of languages supported by a driver is up\r
277 to the driver writer. Language is specified in\r
0254efc0 278 RFC 4646 or ISO 639-2 language code format.\r
70da5bc2 279\r
9beb888e 280 @param ControllerName A pointer to the Unicode string to return.\r
70da5bc2 281 This Unicode string is the name of the\r
282 controller specified by ControllerHandle and\r
283 ChildHandle in the language specified by\r
284 Language from the point of view of the driver\r
285 specified by This.\r
286\r
287 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
288 the language specified by Language for the\r
289 driver specified by This was returned in\r
290 DriverName.\r
291\r
284ee2e8 292 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
70da5bc2 293\r
294 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
295 EFI_HANDLE.\r
296\r
297 @retval EFI_INVALID_PARAMETER Language is NULL.\r
298\r
299 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
300\r
301 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
302 managing the controller specified by\r
303 ControllerHandle and ChildHandle.\r
304\r
305 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
306 the language specified by Language.\r
307\r
308**/\r
3a10d471 309EFI_STATUS\r
310EFIAPI\r
311ScsiBusComponentNameGetControllerName (\r
312 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
313 IN EFI_HANDLE ControllerHandle,\r
314 IN EFI_HANDLE ChildHandle OPTIONAL,\r
315 IN CHAR8 *Language,\r
316 OUT CHAR16 **ControllerName\r
317 );\r
318\r
9beb888e 319/**\r
320 Retrieves the device type information of the SCSI Controller.\r
70da5bc2 321\r
9beb888e 322 @param This Protocol instance pointer.\r
323 @param DeviceType A pointer to the device type information retrieved from\r
d1102dba 324 the SCSI Controller.\r
9beb888e 325\r
326 @retval EFI_SUCCESS Retrieves the device type information successfully.\r
327 @retval EFI_INVALID_PARAMETER The DeviceType is NULL.\r
d1102dba 328\r
9beb888e 329**/\r
3a10d471 330EFI_STATUS\r
331EFIAPI\r
332ScsiGetDeviceType (\r
333 IN EFI_SCSI_IO_PROTOCOL *This,\r
334 OUT UINT8 *DeviceType\r
9beb888e 335 );\r
3a10d471 336\r
9beb888e 337/**\r
338 Retrieves the device location in the SCSI channel.\r
3a10d471 339\r
9beb888e 340 @param This Protocol instance pointer.\r
341 @param Target A pointer to the Target ID of a SCSI device\r
342 on the SCSI channel.\r
343 @param Lun A pointer to the LUN of the SCSI device on\r
344 the SCSI channel.\r
3a10d471 345\r
9beb888e 346 @retval EFI_SUCCESS Retrieves the device location successfully.\r
347 @retval EFI_INVALID_PARAMETER The Target or Lun is NULL.\r
3a10d471 348\r
9beb888e 349**/\r
3a10d471 350EFI_STATUS\r
351EFIAPI\r
9beb888e 352ScsiGetDeviceLocation (\r
353 IN EFI_SCSI_IO_PROTOCOL *This,\r
354 IN OUT UINT8 **Target,\r
355 OUT UINT64 *Lun\r
356 );\r
3a10d471 357\r
9beb888e 358/**\r
70c94b3b 359 Resets the SCSI Bus that the SCSI Controller is attached to.\r
3a10d471 360\r
9beb888e 361 @param This Protocol instance pointer.\r
3a10d471 362\r
9beb888e 363 @retval EFI_SUCCESS The SCSI bus is reset successfully.\r
364 @retval EFI_DEVICE_ERROR Errors encountered when resetting the SCSI bus.\r
365 @retval EFI_UNSUPPORTED The bus reset operation is not supported by the\r
366 SCSI Host Controller.\r
d1102dba 367 @retval EFI_TIMEOUT A timeout occurred while attempting to reset\r
9beb888e 368 the SCSI bus.\r
369**/\r
3a10d471 370EFI_STATUS\r
371EFIAPI\r
9beb888e 372ScsiResetBus (\r
3a10d471 373 IN EFI_SCSI_IO_PROTOCOL *This\r
9beb888e 374 );\r
3a10d471 375\r
9beb888e 376/**\r
70c94b3b 377 Resets the SCSI Controller that the device handle specifies.\r
3a10d471 378\r
9beb888e 379 @param This Protocol instance pointer.\r
3a10d471 380\r
9beb888e 381 @retval EFI_SUCCESS Reset the SCSI controller successfully.\r
382 @retval EFI_DEVICE_ERROR Errors are encountered when resetting the SCSI Controller.\r
383 @retval EFI_UNSUPPORTED The SCSI bus does not support a device reset operation.\r
384 @retval EFI_TIMEOUT A timeout occurred while attempting to reset the\r
385 SCSI Controller.\r
386**/\r
3a10d471 387EFI_STATUS\r
388EFIAPI\r
9beb888e 389ScsiResetDevice (\r
390 IN EFI_SCSI_IO_PROTOCOL *This\r
391 );\r
3a10d471 392\r
9beb888e 393/**\r
70c94b3b 394 Sends a SCSI Request Packet to the SCSI Controller for execution.\r
3a10d471 395\r
9beb888e 396 @param This Protocol instance pointer.\r
d1102dba 397 @param CommandPacket The SCSI request packet to send to the SCSI\r
70c94b3b 398 Controller specified by the device handle.\r
9beb888e 399 @param Event If the SCSI bus where the SCSI device is attached\r
d1102dba
LG
400 does not support non-blocking I/O, then Event is\r
401 ignored, and blocking I/O is performed.\r
70c94b3b 402 If Event is NULL, then blocking I/O is performed.\r
d1102dba 403 If Event is not NULL and non-blocking I/O is\r
70c94b3b 404 supported, then non-blocking I/O is performed,\r
405 and Event will be signaled when the SCSI Request\r
406 Packet completes.\r
3a10d471 407\r
d1102dba
LG
408 @retval EFI_SUCCESS The SCSI Request Packet was sent by the host\r
409 successfully, and TransferLength bytes were\r
410 transferred to/from DataBuffer.See\r
411 HostAdapterStatus, TargetStatus,\r
9beb888e 412 SenseDataLength, and SenseData in that order\r
413 for additional status information.\r
d1102dba 414 @retval EFI_BAD_BUFFER_SIZE The SCSI Request Packet was executed,\r
9beb888e 415 but the entire DataBuffer could not be transferred.\r
416 The actual number of bytes transferred is returned\r
d1102dba
LG
417 in TransferLength. See HostAdapterStatus,\r
418 TargetStatus, SenseDataLength, and SenseData in\r
9beb888e 419 that order for additional status information.\r
d1102dba
LG
420 @retval EFI_NOT_READY The SCSI Request Packet could not be sent because\r
421 there are too many SCSI Command Packets already\r
9beb888e 422 queued.The caller may retry again later.\r
d1102dba
LG
423 @retval EFI_DEVICE_ERROR A device error occurred while attempting to send\r
424 the SCSI Request Packet. See HostAdapterStatus,\r
425 TargetStatus, SenseDataLength, and SenseData in\r
9beb888e 426 that order for additional status information.\r
d1102dba
LG
427 @retval EFI_INVALID_PARAMETER The contents of CommandPacket are invalid.\r
428 The SCSI Request Packet was not sent, so no\r
9beb888e 429 additional status information is available.\r
430 @retval EFI_UNSUPPORTED The command described by the SCSI Request Packet\r
d1102dba 431 is not supported by the SCSI initiator(i.e., SCSI\r
9beb888e 432 Host Controller). The SCSI Request Packet was not\r
d1102dba 433 sent, so no additional status information is\r
9beb888e 434 available.\r
d1102dba 435 @retval EFI_TIMEOUT A timeout occurred while waiting for the SCSI\r
9beb888e 436 Request Packet to execute. See HostAdapterStatus,\r
d1102dba 437 TargetStatus, SenseDataLength, and SenseData in\r
9beb888e 438 that order for additional status information.\r
439**/\r
3a10d471 440EFI_STATUS\r
9beb888e 441EFIAPI\r
442ScsiExecuteSCSICommand (\r
443 IN EFI_SCSI_IO_PROTOCOL *This,\r
444 IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *CommandPacket,\r
445 IN EFI_EVENT Event OPTIONAL\r
446 );\r
3a10d471 447\r
9beb888e 448/**\r
70c94b3b 449 Scan SCSI Bus to discover the device, and attach ScsiIoProtocol to it.\r
3a10d471 450\r
9beb888e 451 @param This Protocol instance pointer\r
452 @param Controller Controller handle\r
cc530cd1 453 @param TargetId Target to be scanned\r
9beb888e 454 @param Lun The Lun of the SCSI device on the SCSI channel.\r
455 @param ScsiBusDev The pointer of SCSI_BUS_DEVICE\r
3a10d471 456\r
9beb888e 457 @retval EFI_SUCCESS Successfully to discover the device and attach\r
458 ScsiIoProtocol to it.\r
459 @retval EFI_OUT_OF_RESOURCES Fail to discover the device.\r
3a10d471 460\r
9beb888e 461**/\r
462EFI_STATUS\r
463EFIAPI\r
464ScsiScanCreateDevice (\r
465 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
466 IN EFI_HANDLE Controller,\r
467 IN SCSI_TARGET_ID *TargetId,\r
468 IN UINT64 Lun,\r
469 IN OUT SCSI_BUS_DEVICE *ScsiBusDev\r
470 );\r
3a10d471 471\r
9beb888e 472/**\r
f36d6e66 473 Discovery SCSI Device\r
3a10d471 474\r
9beb888e 475 @param ScsiIoDevice The pointer of SCSI_IO_DEV\r
3a10d471 476\r
9beb888e 477 @retval TRUE Find SCSI Device and verify it.\r
478 @retval FALSE Unable to find SCSI Device.\r
3a10d471 479\r
9beb888e 480**/\r
481BOOLEAN\r
482DiscoverScsiDevice (\r
483 IN OUT SCSI_IO_DEV *ScsiIoDevice\r
484 );\r
3a10d471 485\r
3a10d471 486#endif\r