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