]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
Update the SCSI Disk Driver to not mount drives on physical only SCSI channels
[mirror_edk2.git] / MdeModulePkg / Bus / Scsi / ScsiDiskDxe / ScsiDisk.h
CommitLineData
3b2dbece 1/** @file\r
2 Header file for SCSI Disk Driver.\r
6ad55b15 3\r
3b2dbece 4Copyright (c) 2004 - 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
6ad55b15 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
6ad55b15 12\r
3b2dbece 13**/\r
6ad55b15 14\r
9beb888e 15#ifndef _SCSI_DISK_H_\r
16#define _SCSI_DISK_H_\r
6ad55b15 17\r
18\r
9beb888e 19#include <Uefi.h>\r
20\r
21\r
22#include <Protocol/ScsiIo.h>\r
23#include <Protocol/ComponentName.h>\r
24#include <Protocol/BlockIo.h>\r
25#include <Protocol/DriverBinding.h>\r
26#include <Protocol/ScsiPassThruExt.h>\r
d14faa52 27#include <Protocol/ScsiPassThru.h>\r
9beb888e 28\r
29#include <Library/DebugLib.h>\r
30#include <Library/UefiDriverEntryPoint.h>\r
31#include <Library/UefiLib.h>\r
32#include <Library/BaseMemoryLib.h>\r
94e0fd07 33#include <Library/MemoryAllocationLib.h>\r
ae50ee26 34#include <Library/UefiScsiLib.h>\r
9beb888e 35#include <Library/UefiBootServicesTableLib.h>\r
36\r
9cb8724d 37#include <IndustryStandard/Scsi.h>\r
6ad55b15 38\r
9beb888e 39#define IS_DEVICE_FIXED(a) (a)->FixedDevice ? 1 : 0\r
6ad55b15 40\r
f3f2e05d 41#define SCSI_DISK_DEV_SIGNATURE SIGNATURE_32 ('s', 'c', 'd', 'k')\r
6ad55b15 42\r
43typedef struct {\r
44 UINT32 Signature;\r
45\r
46 EFI_HANDLE Handle;\r
47\r
48 EFI_BLOCK_IO_PROTOCOL BlkIo;\r
49 EFI_BLOCK_IO_MEDIA BlkIoMedia;\r
50 EFI_SCSI_IO_PROTOCOL *ScsiIo;\r
51 UINT8 DeviceType;\r
52 BOOLEAN FixedDevice;\r
53 UINT16 Reserved;\r
54\r
55 EFI_SCSI_SENSE_DATA *SenseData;\r
56 UINTN SenseDataNumber;\r
57 EFI_SCSI_INQUIRY_DATA InquiryData;\r
58\r
59 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
60\r
61} SCSI_DISK_DEV;\r
62\r
63#define SCSI_DISK_DEV_FROM_THIS(a) CR (a, SCSI_DISK_DEV, BlkIo, SCSI_DISK_DEV_SIGNATURE)\r
64\r
65//\r
66// Global Variables\r
67//\r
70da5bc2 68extern EFI_DRIVER_BINDING_PROTOCOL gScsiDiskDriverBinding;\r
69extern EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName;\r
70extern EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2;\r
6ad55b15 71//\r
72// action code used in detect media process\r
73//\r
74#define ACTION_NO_ACTION 0x00\r
75#define ACTION_READ_CAPACITY 0x01\r
76#define ACTION_RETRY_COMMAND_LATER 0x02\r
77\r
b96cd313 78#define SCSI_COMMAND_VERSION_1 0x01\r
79#define SCSI_COMMAND_VERSION_2 0x02\r
80#define SCSI_COMMAND_VERSION_3 0x03\r
81\r
82\r
9beb888e 83/**\r
84 Test to see if this driver supports ControllerHandle.\r
85\r
86 This service is called by the EFI boot service ConnectController(). In order\r
87 to make drivers as small as possible, there are a few calling restrictions for\r
88 this service. ConnectController() must follow these calling restrictions.\r
89 If any other agent wishes to call Supported() it must also follow these\r
90 calling restrictions.\r
91\r
92 @param This Protocol instance pointer.\r
93 @param ControllerHandle Handle of device to test\r
94 @param RemainingDevicePath Optional parameter use to pick a specific child\r
95 device to start.\r
96\r
97 @retval EFI_SUCCESS This driver supports this device\r
98 @retval EFI_ALREADY_STARTED This driver is already running on this device\r
99 @retval other This driver does not support this device\r
100\r
101**/\r
6ad55b15 102EFI_STATUS\r
103EFIAPI\r
104ScsiDiskDriverBindingSupported (\r
105 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
106 IN EFI_HANDLE Controller,\r
9beb888e 107 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
6ad55b15 108 );\r
109\r
9beb888e 110/**\r
111 Start this driver on 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 Start() 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 bind driver to\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 is added to ControllerHandle\r
125 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
126 @retval other This driver does not support this device\r
127\r
128**/\r
6ad55b15 129EFI_STATUS\r
130EFIAPI\r
131ScsiDiskDriverBindingStart (\r
132 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
133 IN EFI_HANDLE Controller,\r
9beb888e 134 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
6ad55b15 135 );\r
136\r
9beb888e 137/**\r
138 Stop this driver on ControllerHandle.\r
139\r
140 This service is called by the EFI boot service DisconnectController().\r
141 In order to make drivers as small as possible, there are a few calling\r
142 restrictions for this service. DisconnectController() must follow these\r
143 calling restrictions. If any other agent wishes to call Stop() it must\r
144 also follow these calling restrictions.\r
145 \r
146 @param This Protocol instance pointer.\r
147 @param ControllerHandle Handle of device to stop driver on\r
148 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
149 children is zero stop the entire bus driver.\r
150 @param ChildHandleBuffer List of Child Handles to Stop.\r
151\r
152 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
153 @retval other This driver was not removed from this device\r
154\r
155**/\r
6ad55b15 156EFI_STATUS\r
157EFIAPI\r
158ScsiDiskDriverBindingStop (\r
159 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
160 IN EFI_HANDLE Controller,\r
161 IN UINTN NumberOfChildren,\r
9beb888e 162 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
6ad55b15 163 );\r
164\r
165//\r
166// EFI Component Name Functions\r
167//\r
70da5bc2 168/**\r
169 Retrieves a Unicode string that is the user readable name of the driver.\r
170\r
171 This function retrieves the user readable name of a driver in the form of a\r
172 Unicode string. If the driver specified by This has a user readable name in\r
173 the language specified by Language, then a pointer to the driver name is\r
174 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
175 by This does not support the language specified by Language,\r
176 then EFI_UNSUPPORTED is returned.\r
177\r
9beb888e 178 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
70da5bc2 179 EFI_COMPONENT_NAME_PROTOCOL instance.\r
180\r
9beb888e 181 @param Language A pointer to a Null-terminated ASCII string\r
70da5bc2 182 array indicating the language. This is the\r
183 language of the driver name that the caller is\r
184 requesting, and it must match one of the\r
185 languages specified in SupportedLanguages. The\r
186 number of languages supported by a driver is up\r
187 to the driver writer. Language is specified\r
0254efc0 188 in RFC 4646 or ISO 639-2 language code format.\r
70da5bc2 189\r
9beb888e 190 @param DriverName A pointer to the Unicode string to return.\r
70da5bc2 191 This Unicode string is the name of the\r
192 driver specified by This in the language\r
193 specified by Language.\r
194\r
195 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
196 This and the language specified by Language was\r
197 returned in DriverName.\r
198\r
199 @retval EFI_INVALID_PARAMETER Language is NULL.\r
200\r
201 @retval EFI_INVALID_PARAMETER DriverName is NULL.\r
202\r
203 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
204 the language specified by Language.\r
205\r
206**/\r
6ad55b15 207EFI_STATUS\r
208EFIAPI\r
209ScsiDiskComponentNameGetDriverName (\r
210 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
211 IN CHAR8 *Language,\r
212 OUT CHAR16 **DriverName\r
213 );\r
214\r
70da5bc2 215\r
216/**\r
217 Retrieves a Unicode string that is the user readable name of the controller\r
218 that is being managed by a driver.\r
219\r
220 This function retrieves the user readable name of the controller specified by\r
221 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
222 driver specified by This has a user readable name in the language specified by\r
223 Language, then a pointer to the controller name is returned in ControllerName,\r
224 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
225 managing the controller specified by ControllerHandle and ChildHandle,\r
226 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
227 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
228\r
9beb888e 229 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
70da5bc2 230 EFI_COMPONENT_NAME_PROTOCOL instance.\r
231\r
9beb888e 232 @param ControllerHandle The handle of a controller that the driver\r
70da5bc2 233 specified by This is managing. This handle\r
234 specifies the controller whose name is to be\r
235 returned.\r
236\r
9beb888e 237 @param ChildHandle The handle of the child controller to retrieve\r
70da5bc2 238 the name of. This is an optional parameter that\r
239 may be NULL. It will be NULL for device\r
240 drivers. It will also be NULL for a bus drivers\r
241 that wish to retrieve the name of the bus\r
242 controller. It will not be NULL for a bus\r
243 driver that wishes to retrieve the name of a\r
244 child controller.\r
245\r
9beb888e 246 @param Language A pointer to a Null-terminated ASCII string\r
70da5bc2 247 array indicating the language. This is the\r
248 language of the driver name that the caller is\r
249 requesting, and it must match one of the\r
250 languages specified in SupportedLanguages. The\r
251 number of languages supported by a driver is up\r
252 to the driver writer. Language is specified in\r
0254efc0 253 RFC 4646 or ISO 639-2 language code format.\r
70da5bc2 254\r
9beb888e 255 @param ControllerName A pointer to the Unicode string to return.\r
70da5bc2 256 This Unicode string is the name of the\r
257 controller specified by ControllerHandle and\r
258 ChildHandle in the language specified by\r
259 Language from the point of view of the driver\r
260 specified by This.\r
261\r
262 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
263 the language specified by Language for the\r
264 driver specified by This was returned in\r
265 DriverName.\r
266\r
267 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.\r
268\r
269 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
270 EFI_HANDLE.\r
271\r
272 @retval EFI_INVALID_PARAMETER Language is NULL.\r
273\r
274 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
275\r
276 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
277 managing the controller specified by\r
278 ControllerHandle and ChildHandle.\r
279\r
280 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
281 the language specified by Language.\r
282\r
283**/\r
6ad55b15 284EFI_STATUS\r
285EFIAPI\r
286ScsiDiskComponentNameGetControllerName (\r
287 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
288 IN EFI_HANDLE ControllerHandle,\r
289 IN EFI_HANDLE ChildHandle OPTIONAL,\r
290 IN CHAR8 *Language,\r
291 OUT CHAR16 **ControllerName\r
292 );\r
293\r
9beb888e 294/**\r
295 Reset SCSI Disk.\r
296\r
297\r
298 @param This The pointer of EFI_BLOCK_IO_PROTOCOL\r
299 @param ExtendedVerification The flag about if extend verificate\r
70da5bc2 300\r
9beb888e 301 @retval EFI_SUCCESS The device was reset.\r
302 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
303 not be reset.\r
304 @return EFI_STATUS is retured from EFI_SCSI_IO_PROTOCOL.ResetDevice().\r
305\r
306**/\r
6ad55b15 307EFI_STATUS\r
308EFIAPI\r
309ScsiDiskReset (\r
310 IN EFI_BLOCK_IO_PROTOCOL *This,\r
311 IN BOOLEAN ExtendedVerification\r
9beb888e 312 );\r
6ad55b15 313\r
6ad55b15 314\r
9beb888e 315/**\r
316 The function is to Read Block from SCSI Disk.\r
6ad55b15 317\r
9beb888e 318 @param This The pointer of EFI_BLOCK_IO_PROTOCOL.\r
319 @param MediaId The Id of Media detected\r
320 @param Lba The logic block address\r
321 @param BufferSize The size of Buffer\r
322 @param Buffer The buffer to fill the read out data\r
6ad55b15 323\r
9beb888e 324 @retval EFI_SUCCESS Successfully to read out block.\r
325 @retval EFI_DEVICE_ERROR Fail to detect media.\r
326 @retval EFI_NO_MEDIA Media is not present.\r
327 @retval EFI_MEDIA_CHANGED Media has changed.\r
328 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
329 @retval EFI_INVALID_PARAMETER Invalid parameter passed in.\r
6ad55b15 330\r
9beb888e 331**/\r
6ad55b15 332EFI_STATUS\r
333EFIAPI\r
334ScsiDiskReadBlocks (\r
335 IN EFI_BLOCK_IO_PROTOCOL *This,\r
336 IN UINT32 MediaId,\r
9beb888e 337 IN EFI_LBA Lba,\r
6ad55b15 338 IN UINTN BufferSize,\r
339 OUT VOID *Buffer\r
9beb888e 340 );\r
6ad55b15 341\r
6ad55b15 342\r
9beb888e 343/**\r
344 The function is to Write Block to SCSI Disk.\r
345\r
346 @param This The pointer of EFI_BLOCK_IO_PROTOCOL\r
347 @param MediaId The Id of Media detected\r
348 @param Lba The logic block address\r
349 @param BufferSize The size of Buffer\r
350 @param Buffer The buffer to fill the read out data\r
351\r
352 @retval EFI_SUCCESS Successfully to read out block.\r
353 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
354 @retval EFI_DEVICE_ERROR Fail to detect media.\r
355 @retval EFI_NO_MEDIA Media is not present.\r
356 @retval EFI_MEDIA_CHNAGED Media has changed.\r
357 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
358 @retval EFI_INVALID_PARAMETER Invalid parameter passed in.\r
6ad55b15 359\r
9beb888e 360**/\r
6ad55b15 361EFI_STATUS\r
362EFIAPI\r
363ScsiDiskWriteBlocks (\r
364 IN EFI_BLOCK_IO_PROTOCOL *This,\r
365 IN UINT32 MediaId,\r
9beb888e 366 IN EFI_LBA Lba,\r
6ad55b15 367 IN UINTN BufferSize,\r
368 IN VOID *Buffer\r
9beb888e 369 );\r
6ad55b15 370\r
6ad55b15 371\r
9beb888e 372/**\r
373 Flush Block to Disk.\r
6ad55b15 374\r
9beb888e 375 EFI_SUCCESS is returned directly.\r
6ad55b15 376\r
9beb888e 377 @param This The pointer of EFI_BLOCK_IO_PROTOCOL\r
6ad55b15 378\r
9beb888e 379 @retval EFI_SUCCESS All outstanding data was written to the device\r
6ad55b15 380\r
9beb888e 381**/\r
6ad55b15 382EFI_STATUS\r
383EFIAPI\r
384ScsiDiskFlushBlocks (\r
385 IN EFI_BLOCK_IO_PROTOCOL *This\r
9beb888e 386 );\r
6ad55b15 387\r
9beb888e 388/**\r
389 Dectect Device and read out capacity ,if error occurs, parse the sense key.\r
6ad55b15 390\r
9beb888e 391 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
392 @param MustReadCapacity The flag about reading device capacity\r
393 @param MediaChange The pointer of flag indicates if media has changed \r
6ad55b15 394\r
9beb888e 395 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
396 @retval EFI_SUCCESS Successfully to detect media\r
6ad55b15 397\r
9beb888e 398**/\r
6ad55b15 399EFI_STATUS\r
400ScsiDiskDetectMedia (\r
9beb888e 401 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
402 IN BOOLEAN MustReadCapacity,\r
403 OUT BOOLEAN *MediaChange\r
404 );\r
6ad55b15 405\r
9beb888e 406/**\r
407 To test deivice.\r
6ad55b15 408\r
9beb888e 409 When Test Unit Ready command succeeds, retrieve Sense Keys via Request Sense;\r
410 When Test Unit Ready command encounters any error caused by host adapter or\r
411 target, return error without retrieving Sense Keys.\r
6ad55b15 412\r
9beb888e 413 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
414 @param NeedRetry The pointer of flag indicates try again\r
415 @param SenseDataArray The pointer of an array of sense data\r
416 @param NumberOfSenseKeys The pointer of the number of sense data array\r
6ad55b15 417\r
9beb888e 418 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
419 @retval EFI_SUCCESS Successfully to test unit\r
f36d6e66 420\r
9beb888e 421**/\r
6ad55b15 422EFI_STATUS\r
423ScsiDiskTestUnitReady (\r
9beb888e 424 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
425 OUT BOOLEAN *NeedRetry,\r
426 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
427 OUT UINTN *NumberOfSenseKeys\r
428 );\r
6ad55b15 429\r
6ad55b15 430\r
9beb888e 431/**\r
432 Parsing Sense Keys which got from request sense command.\r
6ad55b15 433\r
9beb888e 434 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
435 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
436 @param NumberOfSenseKeys The number of sense key \r
437 @param Action The pointer of action which indicates what is need to do next\r
6ad55b15 438\r
9beb888e 439 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
440 @retval EFI_SUCCESS Successfully to complete the parsing\r
6ad55b15 441\r
9beb888e 442**/\r
6ad55b15 443EFI_STATUS\r
444DetectMediaParsingSenseKeys (\r
9beb888e 445 OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
446 IN EFI_SCSI_SENSE_DATA *SenseData,\r
447 IN UINTN NumberOfSenseKeys,\r
448 OUT UINTN *Action\r
449 );\r
6ad55b15 450\r
6ad55b15 451\r
9beb888e 452/**\r
453 Send read capacity command to device and get the device parameter.\r
6ad55b15 454\r
9beb888e 455 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
456 @param NeedRetry The pointer of flag indicates if need a retry\r
457 @param SenseDataArray The pointer of an array of sense data\r
458 @param NumberOfSenseKeys The number of sense key\r
6ad55b15 459\r
9beb888e 460 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
461 @retval EFI_SUCCESS Successfully to read capacity\r
6ad55b15 462\r
9beb888e 463**/\r
6ad55b15 464EFI_STATUS\r
465ScsiDiskReadCapacity (\r
9beb888e 466 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
467 OUT BOOLEAN *NeedRetry,\r
468 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
469 OUT UINTN *NumberOfSenseKeys\r
470 );\r
6ad55b15 471\r
9beb888e 472/**\r
473 Check the HostAdapter status and re-interpret it in EFI_STATUS.\r
6ad55b15 474\r
9beb888e 475 @param HostAdapterStatus Host Adapter status\r
6ad55b15 476\r
9beb888e 477 @retval EFI_SUCCESS Host adapter is OK.\r
478 @retval EFI_TIMEOUT Timeout.\r
479 @retval EFI_NOT_READY Adapter NOT ready.\r
480 @retval EFI_DEVICE_ERROR Adapter device error.\r
6ad55b15 481\r
9beb888e 482**/\r
6ad55b15 483EFI_STATUS\r
484CheckHostAdapterStatus (\r
9beb888e 485 IN UINT8 HostAdapterStatus\r
486 );\r
6ad55b15 487\r
6ad55b15 488\r
9beb888e 489/**\r
490 Check the target status and re-interpret it in EFI_STATUS.\r
6ad55b15 491\r
9beb888e 492 @param TargetStatus Target status\r
6ad55b15 493\r
9beb888e 494 @retval EFI_NOT_READY Device is NOT ready.\r
495 @retval EFI_DEVICE_ERROR \r
496 @retval EFI_SUCCESS\r
6ad55b15 497\r
9beb888e 498**/\r
6ad55b15 499EFI_STATUS\r
500CheckTargetStatus (\r
9beb888e 501 IN UINT8 TargetStatus\r
502 );\r
6ad55b15 503\r
9beb888e 504/**\r
505 Retrieve all sense keys from the device.\r
6ad55b15 506\r
9beb888e 507 When encountering error during the process, if retrieve sense keys before\r
508 error encounterred, it returns the sense keys with return status set to EFI_SUCCESS,\r
509 and NeedRetry set to FALSE; otherwize, return the proper return status.\r
6ad55b15 510\r
9beb888e 511 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
512 @param NeedRetry The pointer of flag indicates if need a retry\r
513 @param SenseDataArray The pointer of an array of sense data\r
514 @param NumberOfSenseKeys The number of sense key\r
515 @param AskResetIfError The flag indicates if need reset when error occurs\r
6ad55b15 516\r
9beb888e 517 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
518 @retval EFI_SUCCESS Successfully to request sense key\r
6ad55b15 519\r
9beb888e 520**/\r
6ad55b15 521EFI_STATUS\r
522ScsiDiskRequestSenseKeys (\r
9beb888e 523 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
524 OUT BOOLEAN *NeedRetry,\r
525 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
526 OUT UINTN *NumberOfSenseKeys,\r
527 IN BOOLEAN AskResetIfError\r
528 );\r
6ad55b15 529\r
9beb888e 530/**\r
531 Send out Inquiry command to Device.\r
6ad55b15 532\r
9beb888e 533 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
534 @param NeedRetry Indicates if needs try again when error happens\r
6ad55b15 535\r
9beb888e 536 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
537 @retval EFI_SUCCESS Successfully to detect media\r
6ad55b15 538\r
9beb888e 539**/\r
6ad55b15 540EFI_STATUS\r
541ScsiDiskInquiryDevice (\r
9beb888e 542 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
543 OUT BOOLEAN *NeedRetry\r
544 );\r
6ad55b15 545\r
9beb888e 546/**\r
547 Parse Inquiry data.\r
6ad55b15 548\r
9beb888e 549 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
6ad55b15 550\r
9beb888e 551**/\r
6ad55b15 552VOID\r
553ParseInquiryData (\r
9beb888e 554 IN OUT SCSI_DISK_DEV *ScsiDiskDevice\r
555 );\r
6ad55b15 556\r
9beb888e 557/**\r
558 Read sector from SCSI Disk.\r
6ad55b15 559\r
9beb888e 560 @param ScsiDiskDevice The poiniter of SCSI_DISK_DEV\r
561 @param Buffer The buffer to fill in the read out data\r
562 @param Lba Logic block address\r
563 @param NumberOfBlocks The number of blocks to read\r
6ad55b15 564\r
9beb888e 565 @retval EFI_DEVICE_ERROR Indicates a device error.\r
566 @retval EFI_SUCCESS Operation is successful.\r
6ad55b15 567\r
9beb888e 568**/\r
6ad55b15 569EFI_STATUS\r
570ScsiDiskReadSectors (\r
9beb888e 571 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
572 OUT VOID *Buffer,\r
573 IN EFI_LBA Lba,\r
574 IN UINTN NumberOfBlocks\r
575 );\r
6ad55b15 576\r
9beb888e 577/**\r
578 Write sector to SCSI Disk.\r
6ad55b15 579\r
9beb888e 580 @param ScsiDiskDevice The poiniter of SCSI_DISK_DEV\r
581 @param Buffer The buffer of data to be written into SCSI Disk\r
582 @param Lba Logic block address\r
583 @param NumberOfBlocks The number of blocks to read\r
6ad55b15 584\r
9beb888e 585 @retval EFI_DEVICE_ERROR Indicates a device error.\r
586 @retval EFI_SUCCESS Operation is successful.\r
6ad55b15 587\r
9beb888e 588**/\r
6ad55b15 589EFI_STATUS\r
590ScsiDiskWriteSectors (\r
9beb888e 591 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
592 IN VOID *Buffer,\r
593 IN EFI_LBA Lba,\r
594 IN UINTN NumberOfBlocks\r
595 );\r
6ad55b15 596\r
9beb888e 597/**\r
598 Sumbmit Read command.\r
599\r
600 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
601 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
602 @param SenseDataArray NOT used yet in this function\r
603 @param NumberOfSenseKeys The number of sense key\r
604 @param Timeout The time to complete the command\r
605 @param DataBuffer The buffer to fill with the read out data\r
606 @param DataLength The length of buffer\r
607 @param StartLba The start logic block address\r
608 @param SectorSize The size of sector\r
609\r
610 @return EFI_STATUS is returned by calling ScsiRead10Command().\r
611**/\r
6ad55b15 612EFI_STATUS\r
613ScsiDiskRead10 (\r
9beb888e 614 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
615 OUT BOOLEAN *NeedRetry,\r
616 OUT EFI_SCSI_SENSE_DATA **SenseDataArray, OPTIONAL\r
617 OUT UINTN *NumberOfSenseKeys,\r
618 IN UINT64 Timeout,\r
619 OUT UINT8 *DataBuffer,\r
620 IN OUT UINT32 *DataLength,\r
621 IN UINT32 StartLba,\r
622 IN UINT32 SectorSize\r
623 );\r
6ad55b15 624\r
9beb888e 625/**\r
626 Submit Write Command.\r
6ad55b15 627\r
9beb888e 628 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
629 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
630 @param SenseDataArray NOT used yet in this function\r
631 @param NumberOfSenseKeys The number of sense key\r
632 @param Timeout The time to complete the command\r
633 @param DataBuffer The buffer to fill with the read out data\r
634 @param DataLength The length of buffer\r
635 @param StartLba The start logic block address\r
636 @param SectorSize The size of sector\r
6ad55b15 637\r
9beb888e 638 @return EFI_STATUS is returned by calling ScsiWrite10Command().\r
6ad55b15 639\r
9beb888e 640**/\r
6ad55b15 641EFI_STATUS\r
642ScsiDiskWrite10 (\r
9beb888e 643 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
644 OUT BOOLEAN *NeedRetry,\r
645 OUT EFI_SCSI_SENSE_DATA **SenseDataArray, OPTIONAL\r
646 OUT UINTN *NumberOfSenseKeys,\r
647 IN UINT64 Timeout,\r
648 IN UINT8 *DataBuffer,\r
649 IN OUT UINT32 *DataLength,\r
650 IN UINT32 StartLba,\r
651 IN UINT32 SectorSize\r
652 );\r
6ad55b15 653\r
9beb888e 654/**\r
655 Get information from media read capacity command.\r
6ad55b15 656\r
9beb888e 657 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
b96cd313 658 @param Capacity10 The pointer of EFI_SCSI_DISK_CAPACITY_DATA\r
659 @param Capacity16 The pointer of EFI_SCSI_DISK_CAPACITY_DATA16\r
9beb888e 660**/\r
6ad55b15 661VOID\r
662GetMediaInfo (\r
b96cd313 663 SCSI_DISK_DEV *ScsiDiskDevice,\r
664 EFI_SCSI_DISK_CAPACITY_DATA *Capacity10,\r
665 EFI_SCSI_DISK_CAPACITY_DATA16 *Capacity16\r
9beb888e 666 );\r
6ad55b15 667\r
9beb888e 668/**\r
669 Check sense key to find if media presents.\r
6ad55b15 670\r
9beb888e 671 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
672 @param SenseCounts The number of sense key\r
6ad55b15 673\r
9beb888e 674 @retval TRUE NOT any media\r
675 @retval FALSE Media presents\r
676**/\r
6ad55b15 677BOOLEAN\r
678ScsiDiskIsNoMedia (\r
679 IN EFI_SCSI_SENSE_DATA *SenseData,\r
680 IN UINTN SenseCounts\r
9beb888e 681 );\r
6ad55b15 682\r
9beb888e 683/**\r
684 Parse sense key.\r
6ad55b15 685\r
9beb888e 686 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
687 @param SenseCounts The number of sense key\r
6ad55b15 688\r
9beb888e 689 @retval TRUE Error\r
690 @retval FALSE NOT error\r
6ad55b15 691\r
9beb888e 692**/\r
6ad55b15 693BOOLEAN\r
694ScsiDiskIsMediaError (\r
695 IN EFI_SCSI_SENSE_DATA *SenseData,\r
696 IN UINTN SenseCounts\r
9beb888e 697 );\r
6ad55b15 698\r
9beb888e 699/**\r
700 Check sense key to find if hardware error happens.\r
6ad55b15 701\r
9beb888e 702 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
703 @param SenseCounts The number of sense key\r
6ad55b15 704\r
9beb888e 705 @retval TRUE Hardware error exits.\r
706 @retval FALSE NO error.\r
6ad55b15 707\r
9beb888e 708**/\r
6ad55b15 709BOOLEAN\r
710ScsiDiskIsHardwareError (\r
711 IN EFI_SCSI_SENSE_DATA *SenseData,\r
712 IN UINTN SenseCounts\r
9beb888e 713 );\r
6ad55b15 714\r
9beb888e 715/**\r
716 Check sense key to find if media has changed.\r
6ad55b15 717\r
9beb888e 718 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
719 @param SenseCounts The number of sense key\r
6ad55b15 720\r
9beb888e 721 @retval TRUE Media is changed.\r
722 @retval FALSE Medit is NOT changed.\r
723**/\r
6ad55b15 724BOOLEAN\r
725ScsiDiskIsMediaChange (\r
726 IN EFI_SCSI_SENSE_DATA *SenseData,\r
727 IN UINTN SenseCounts\r
9beb888e 728 );\r
6ad55b15 729\r
9beb888e 730/**\r
731 Check sense key to find if reset happens.\r
6ad55b15 732\r
9beb888e 733 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
734 @param SenseCounts The number of sense key\r
6ad55b15 735\r
9beb888e 736 @retval TRUE It is reset before.\r
737 @retval FALSE It is NOT reset before.\r
6ad55b15 738\r
9beb888e 739**/\r
6ad55b15 740BOOLEAN\r
741ScsiDiskIsResetBefore (\r
742 IN EFI_SCSI_SENSE_DATA *SenseData,\r
743 IN UINTN SenseCounts\r
9beb888e 744 );\r
6ad55b15 745\r
9beb888e 746/**\r
747 Check sense key to find if the drive is ready.\r
6ad55b15 748\r
9beb888e 749 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
750 @param SenseCounts The number of sense key\r
751 @param RetryLater The flag means if need a retry \r
6ad55b15 752\r
9beb888e 753 @retval TRUE Drive is ready.\r
754 @retval FALSE Drive is NOT ready.\r
6ad55b15 755\r
9beb888e 756**/\r
6ad55b15 757BOOLEAN\r
758ScsiDiskIsDriveReady (\r
759 IN EFI_SCSI_SENSE_DATA *SenseData,\r
760 IN UINTN SenseCounts,\r
9beb888e 761 OUT BOOLEAN *RetryLater\r
762 );\r
6ad55b15 763\r
9beb888e 764/**\r
765 Check sense key to find if it has sense key.\r
6ad55b15 766\r
9beb888e 767 @param SenseData - The pointer of EFI_SCSI_SENSE_DATA\r
768 @param SenseCounts - The number of sense key\r
6ad55b15 769\r
9beb888e 770 @retval TRUE It has sense key.\r
771 @retval FALSE It has NOT any sense key.\r
6ad55b15 772\r
9beb888e 773**/\r
6ad55b15 774BOOLEAN\r
775ScsiDiskHaveSenseKey (\r
776 IN EFI_SCSI_SENSE_DATA *SenseData,\r
777 IN UINTN SenseCounts\r
9beb888e 778 );\r
6ad55b15 779\r
9beb888e 780/**\r
781 Release resource about disk device.\r
6ad55b15 782\r
9beb888e 783 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
6ad55b15 784\r
9beb888e 785**/\r
6ad55b15 786VOID\r
787ReleaseScsiDiskDeviceResources (\r
788 IN SCSI_DISK_DEV *ScsiDiskDevice\r
9beb888e 789 );\r
6ad55b15 790\r
d14faa52 791/**\r
792 Determine if Block Io should be produced.\r
793 \r
794\r
795 @param ChildHandle Child Handle to retrive Parent information.\r
796 \r
797 @retval TRUE Should produce Block Io.\r
798 @retval FALSE Should not produce Block Io.\r
799\r
800**/ \r
801BOOLEAN\r
802DetermineInstallBlockIo (\r
803 IN EFI_HANDLE ChildHandle\r
804 );\r
805\r
806/**\r
807 Search protocol database and check to see if the protocol\r
808 specified by ProtocolGuid is present on a ControllerHandle and opened by\r
809 ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
810 If the ControllerHandle is found, then the protocol specified by ProtocolGuid\r
811 will be opened on it. \r
812 \r
813\r
814 @param ProtocolGuid ProtocolGuid pointer.\r
815 @param ChildHandle Child Handle to retrieve Parent information.\r
816 \r
817**/ \r
818VOID *\r
819EFIAPI\r
820GetParentProtocol (\r
821 IN EFI_GUID *ProtocolGuid,\r
822 IN EFI_HANDLE ChildHandle\r
823 );\r
824\r
6ad55b15 825#endif\r