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