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