]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[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
d1102dba 4Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
9d510e61 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
6ad55b15 6\r
3b2dbece 7**/\r
6ad55b15 8\r
9beb888e 9#ifndef _SCSI_DISK_H_\r
10#define _SCSI_DISK_H_\r
6ad55b15 11\r
12\r
9beb888e 13#include <Uefi.h>\r
14\r
15\r
16#include <Protocol/ScsiIo.h>\r
17#include <Protocol/ComponentName.h>\r
18#include <Protocol/BlockIo.h>\r
d670bf53 19#include <Protocol/BlockIo2.h>\r
b6e5da19 20#include <Protocol/EraseBlock.h>\r
9beb888e 21#include <Protocol/DriverBinding.h>\r
22#include <Protocol/ScsiPassThruExt.h>\r
d14faa52 23#include <Protocol/ScsiPassThru.h>\r
d716651f 24#include <Protocol/DiskInfo.h>\r
25\r
9beb888e 26\r
27#include <Library/DebugLib.h>\r
28#include <Library/UefiDriverEntryPoint.h>\r
29#include <Library/UefiLib.h>\r
30#include <Library/BaseMemoryLib.h>\r
94e0fd07 31#include <Library/MemoryAllocationLib.h>\r
ae50ee26 32#include <Library/UefiScsiLib.h>\r
9beb888e 33#include <Library/UefiBootServicesTableLib.h>\r
d716651f 34#include <Library/DevicePathLib.h>\r
9beb888e 35\r
9cb8724d 36#include <IndustryStandard/Scsi.h>\r
d716651f 37#include <IndustryStandard/Atapi.h>\r
6ad55b15 38\r
9beb888e 39#define IS_DEVICE_FIXED(a) (a)->FixedDevice ? 1 : 0\r
6ad55b15 40\r
b6e5da19
HW
41typedef struct {\r
42 UINT32 MaxLbaCnt;\r
43 UINT32 MaxBlkDespCnt;\r
44 UINT32 GranularityAlignment;\r
45} SCSI_UNMAP_PARAM_INFO;\r
46\r
f3f2e05d 47#define SCSI_DISK_DEV_SIGNATURE SIGNATURE_32 ('s', 'c', 'd', 'k')\r
6ad55b15 48\r
49typedef struct {\r
50 UINT32 Signature;\r
51\r
52 EFI_HANDLE Handle;\r
53\r
54 EFI_BLOCK_IO_PROTOCOL BlkIo;\r
d670bf53 55 EFI_BLOCK_IO2_PROTOCOL BlkIo2;\r
6ad55b15 56 EFI_BLOCK_IO_MEDIA BlkIoMedia;\r
b6e5da19 57 EFI_ERASE_BLOCK_PROTOCOL EraseBlock;\r
6ad55b15 58 EFI_SCSI_IO_PROTOCOL *ScsiIo;\r
59 UINT8 DeviceType;\r
60 BOOLEAN FixedDevice;\r
61 UINT16 Reserved;\r
62\r
63 EFI_SCSI_SENSE_DATA *SenseData;\r
64 UINTN SenseDataNumber;\r
65 EFI_SCSI_INQUIRY_DATA InquiryData;\r
66\r
67 EFI_UNICODE_STRING_TABLE *ControllerNameTable;\r
68\r
d716651f 69 EFI_DISK_INFO_PROTOCOL DiskInfo;\r
70\r
71 //\r
72 // The following fields are only valid for ATAPI/SATA device\r
73 //\r
74 UINT32 Channel;\r
75 UINT32 Device;\r
76 ATAPI_IDENTIFY_DATA IdentifyData;\r
b6e5da19
HW
77\r
78 //\r
79 // Scsi UNMAP command parameters information\r
80 //\r
81 SCSI_UNMAP_PARAM_INFO UnmapInfo;\r
82 BOOLEAN BlockLimitsVpdSupported;\r
d1102dba 83\r
f95bc048 84 //\r
85 // The flag indicates if 16-byte command can be used\r
86 //\r
87 BOOLEAN Cdb16Byte;\r
d670bf53
HW
88\r
89 //\r
b6e5da19 90 // The queue for asynchronous task requests\r
d670bf53 91 //\r
b6e5da19 92 LIST_ENTRY AsyncTaskQueue;\r
6ad55b15 93} SCSI_DISK_DEV;\r
94\r
d670bf53
HW
95#define SCSI_DISK_DEV_FROM_BLKIO(a) CR (a, SCSI_DISK_DEV, BlkIo, SCSI_DISK_DEV_SIGNATURE)\r
96#define SCSI_DISK_DEV_FROM_BLKIO2(a) CR (a, SCSI_DISK_DEV, BlkIo2, SCSI_DISK_DEV_SIGNATURE)\r
b6e5da19 97#define SCSI_DISK_DEV_FROM_ERASEBLK(a) CR (a, SCSI_DISK_DEV, EraseBlock, SCSI_DISK_DEV_SIGNATURE)\r
6ad55b15 98\r
d716651f 99#define SCSI_DISK_DEV_FROM_DISKINFO(a) CR (a, SCSI_DISK_DEV, DiskInfo, SCSI_DISK_DEV_SIGNATURE)\r
100\r
d670bf53
HW
101//\r
102// Asynchronous I/O request\r
103//\r
104//\r
105// Private data structure for a BlockIo2 request\r
106//\r
107typedef struct {\r
108 EFI_BLOCK_IO2_TOKEN *Token;\r
109 //\r
a717086c
HW
110 // The flag indicates if the last Scsi Read/Write sub-task for a BlockIo2\r
111 // request is sent to device\r
112 //\r
113 BOOLEAN LastScsiRW;\r
114\r
115 //\r
116 // The queue for Scsi Read/Write sub-tasks of a BlockIo2 request\r
d670bf53
HW
117 //\r
118 LIST_ENTRY ScsiRWQueue;\r
119\r
120 LIST_ENTRY Link;\r
121} SCSI_BLKIO2_REQUEST;\r
122\r
123//\r
124// Private data structure for a SCSI Read/Write request\r
125//\r
126typedef struct {\r
127 SCSI_DISK_DEV *ScsiDiskDevice;\r
128 UINT64 Timeout;\r
129 EFI_SCSI_SENSE_DATA *SenseData;\r
130 UINT8 SenseDataLength;\r
131 UINT8 HostAdapterStatus;\r
132 UINT8 TargetStatus;\r
133 UINT8 *InBuffer;\r
134 UINT8 *OutBuffer;\r
135 UINT32 DataLength;\r
136 UINT64 StartLba;\r
137 UINT32 SectorCount;\r
138 UINT8 TimesRetry;\r
139\r
140 //\r
141 // The BlockIo2 request this SCSI command belongs to\r
142 //\r
143 SCSI_BLKIO2_REQUEST *BlkIo2Req;\r
144\r
145 LIST_ENTRY Link;\r
146} SCSI_ASYNC_RW_REQUEST;\r
147\r
b6e5da19
HW
148//\r
149// Private data structure for an EraseBlock request\r
150//\r
151typedef struct {\r
152 EFI_ERASE_BLOCK_TOKEN *Token;\r
153\r
154 EFI_SCSI_IO_SCSI_REQUEST_PACKET CommandPacket;\r
155\r
156 LIST_ENTRY Link;\r
157} SCSI_ERASEBLK_REQUEST;\r
158\r
6ad55b15 159//\r
160// Global Variables\r
161//\r
70da5bc2 162extern EFI_DRIVER_BINDING_PROTOCOL gScsiDiskDriverBinding;\r
163extern EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName;\r
164extern EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2;\r
6ad55b15 165//\r
166// action code used in detect media process\r
167//\r
73a9e822
TF
168#define ACTION_NO_ACTION 0x00\r
169#define ACTION_READ_CAPACITY 0x01\r
170#define ACTION_RETRY_COMMAND_LATER 0x02\r
171#define ACTION_RETRY_WITH_BACKOFF_ALGO 0x03\r
6ad55b15 172\r
b96cd313 173#define SCSI_COMMAND_VERSION_1 0x01\r
174#define SCSI_COMMAND_VERSION_2 0x02\r
175#define SCSI_COMMAND_VERSION_3 0x03\r
176\r
3cc033c5
FT
177//\r
178// SCSI Disk Timeout Experience Value\r
179//\r
1d3fa1bd
FT
180// As ScsiDisk and ScsiBus driver are used to manage SCSI or ATAPI devices, the timout\r
181// value is updated to 30s to follow ATA/ATAPI spec in which the device may take up to 30s\r
182// to respond command.\r
183//\r
184#define SCSI_DISK_TIMEOUT EFI_TIMER_PERIOD_SECONDS (30)\r
b96cd313 185\r
9beb888e 186/**\r
187 Test to see if this driver supports ControllerHandle.\r
188\r
189 This service is called by the EFI boot service ConnectController(). In order\r
190 to make drivers as small as possible, there are a few calling restrictions for\r
191 this service. ConnectController() must follow these calling restrictions.\r
192 If any other agent wishes to call Supported() it must also follow these\r
193 calling restrictions.\r
194\r
195 @param This Protocol instance pointer.\r
196 @param ControllerHandle Handle of device to test\r
197 @param RemainingDevicePath Optional parameter use to pick a specific child\r
198 device to start.\r
199\r
200 @retval EFI_SUCCESS This driver supports this device\r
201 @retval EFI_ALREADY_STARTED This driver is already running on this device\r
202 @retval other This driver does not support this device\r
203\r
204**/\r
6ad55b15 205EFI_STATUS\r
206EFIAPI\r
207ScsiDiskDriverBindingSupported (\r
208 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
209 IN EFI_HANDLE Controller,\r
9beb888e 210 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
6ad55b15 211 );\r
212\r
9beb888e 213/**\r
214 Start this driver on ControllerHandle.\r
215\r
216 This service is called by the EFI boot service ConnectController(). In order\r
217 to make drivers as small as possible, there are a few calling restrictions for\r
218 this service. ConnectController() must follow these calling restrictions. If\r
219 any other agent wishes to call Start() it must also follow these calling\r
220 restrictions.\r
221\r
222 @param This Protocol instance pointer.\r
223 @param ControllerHandle Handle of device to bind driver to\r
224 @param RemainingDevicePath Optional parameter use to pick a specific child\r
225 device to start.\r
226\r
227 @retval EFI_SUCCESS This driver is added to ControllerHandle\r
228 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle\r
229 @retval other This driver does not support this device\r
230\r
231**/\r
6ad55b15 232EFI_STATUS\r
233EFIAPI\r
234ScsiDiskDriverBindingStart (\r
235 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
236 IN EFI_HANDLE Controller,\r
9beb888e 237 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL\r
6ad55b15 238 );\r
239\r
9beb888e 240/**\r
241 Stop this driver on ControllerHandle.\r
242\r
243 This service is called by the EFI boot service DisconnectController().\r
244 In order to make drivers as small as possible, there are a few calling\r
245 restrictions for this service. DisconnectController() must follow these\r
246 calling restrictions. If any other agent wishes to call Stop() it must\r
247 also follow these calling restrictions.\r
d1102dba 248\r
9beb888e 249 @param This Protocol instance pointer.\r
250 @param ControllerHandle Handle of device to stop driver on\r
251 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of\r
252 children is zero stop the entire bus driver.\r
253 @param ChildHandleBuffer List of Child Handles to Stop.\r
254\r
255 @retval EFI_SUCCESS This driver is removed ControllerHandle\r
256 @retval other This driver was not removed from this device\r
257\r
258**/\r
6ad55b15 259EFI_STATUS\r
260EFIAPI\r
261ScsiDiskDriverBindingStop (\r
262 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
263 IN EFI_HANDLE Controller,\r
264 IN UINTN NumberOfChildren,\r
9beb888e 265 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL\r
6ad55b15 266 );\r
267\r
268//\r
269// EFI Component Name Functions\r
270//\r
70da5bc2 271/**\r
272 Retrieves a Unicode string that is the user readable name of the driver.\r
273\r
274 This function retrieves the user readable name of a driver in the form of a\r
275 Unicode string. If the driver specified by This has a user readable name in\r
276 the language specified by Language, then a pointer to the driver name is\r
277 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified\r
278 by This does not support the language specified by Language,\r
279 then EFI_UNSUPPORTED is returned.\r
280\r
9beb888e 281 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
70da5bc2 282 EFI_COMPONENT_NAME_PROTOCOL instance.\r
283\r
9beb888e 284 @param Language A pointer to a Null-terminated ASCII string\r
70da5bc2 285 array indicating the language. This is the\r
286 language of the driver name that the caller is\r
287 requesting, and it must match one of the\r
288 languages specified in SupportedLanguages. The\r
289 number of languages supported by a driver is up\r
290 to the driver writer. Language is specified\r
0254efc0 291 in RFC 4646 or ISO 639-2 language code format.\r
70da5bc2 292\r
9beb888e 293 @param DriverName A pointer to the Unicode string to return.\r
70da5bc2 294 This Unicode string is the name of the\r
295 driver specified by This in the language\r
296 specified by Language.\r
297\r
298 @retval EFI_SUCCESS The Unicode string for the Driver specified by\r
299 This and the language specified by Language was\r
300 returned in DriverName.\r
301\r
302 @retval EFI_INVALID_PARAMETER Language is NULL.\r
303\r
304 @retval EFI_INVALID_PARAMETER DriverName is NULL.\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
6ad55b15 310EFI_STATUS\r
311EFIAPI\r
312ScsiDiskComponentNameGetDriverName (\r
313 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
314 IN CHAR8 *Language,\r
315 OUT CHAR16 **DriverName\r
316 );\r
317\r
70da5bc2 318\r
319/**\r
320 Retrieves a Unicode string that is the user readable name of the controller\r
321 that is being managed by a driver.\r
322\r
323 This function retrieves the user readable name of the controller specified by\r
324 ControllerHandle and ChildHandle in the form of a Unicode string. If the\r
325 driver specified by This has a user readable name in the language specified by\r
326 Language, then a pointer to the controller name is returned in ControllerName,\r
327 and EFI_SUCCESS is returned. If the driver specified by This is not currently\r
328 managing the controller specified by ControllerHandle and ChildHandle,\r
329 then EFI_UNSUPPORTED is returned. If the driver specified by This does not\r
330 support the language specified by Language, then EFI_UNSUPPORTED is returned.\r
331\r
9beb888e 332 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or\r
70da5bc2 333 EFI_COMPONENT_NAME_PROTOCOL instance.\r
334\r
9beb888e 335 @param ControllerHandle The handle of a controller that the driver\r
70da5bc2 336 specified by This is managing. This handle\r
337 specifies the controller whose name is to be\r
338 returned.\r
339\r
9beb888e 340 @param ChildHandle The handle of the child controller to retrieve\r
70da5bc2 341 the name of. This is an optional parameter that\r
342 may be NULL. It will be NULL for device\r
343 drivers. It will also be NULL for a bus drivers\r
344 that wish to retrieve the name of the bus\r
345 controller. It will not be NULL for a bus\r
346 driver that wishes to retrieve the name of a\r
347 child controller.\r
348\r
9beb888e 349 @param Language A pointer to a Null-terminated ASCII string\r
70da5bc2 350 array indicating the language. This is the\r
351 language of the driver name that the caller is\r
352 requesting, and it must match one of the\r
353 languages specified in SupportedLanguages. The\r
354 number of languages supported by a driver is up\r
355 to the driver writer. Language is specified in\r
0254efc0 356 RFC 4646 or ISO 639-2 language code format.\r
70da5bc2 357\r
9beb888e 358 @param ControllerName A pointer to the Unicode string to return.\r
70da5bc2 359 This Unicode string is the name of the\r
360 controller specified by ControllerHandle and\r
361 ChildHandle in the language specified by\r
362 Language from the point of view of the driver\r
363 specified by This.\r
364\r
365 @retval EFI_SUCCESS The Unicode string for the user readable name in\r
366 the language specified by Language for the\r
367 driver specified by This was returned in\r
368 DriverName.\r
369\r
284ee2e8 370 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.\r
70da5bc2 371\r
372 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid\r
373 EFI_HANDLE.\r
374\r
375 @retval EFI_INVALID_PARAMETER Language is NULL.\r
376\r
377 @retval EFI_INVALID_PARAMETER ControllerName is NULL.\r
378\r
379 @retval EFI_UNSUPPORTED The driver specified by This is not currently\r
380 managing the controller specified by\r
381 ControllerHandle and ChildHandle.\r
382\r
383 @retval EFI_UNSUPPORTED The driver specified by This does not support\r
384 the language specified by Language.\r
385\r
386**/\r
6ad55b15 387EFI_STATUS\r
388EFIAPI\r
389ScsiDiskComponentNameGetControllerName (\r
390 IN EFI_COMPONENT_NAME_PROTOCOL *This,\r
391 IN EFI_HANDLE ControllerHandle,\r
392 IN EFI_HANDLE ChildHandle OPTIONAL,\r
393 IN CHAR8 *Language,\r
394 OUT CHAR16 **ControllerName\r
395 );\r
396\r
9beb888e 397/**\r
398 Reset SCSI Disk.\r
399\r
400\r
401 @param This The pointer of EFI_BLOCK_IO_PROTOCOL\r
402 @param ExtendedVerification The flag about if extend verificate\r
70da5bc2 403\r
9beb888e 404 @retval EFI_SUCCESS The device was reset.\r
405 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
406 not be reset.\r
407 @return EFI_STATUS is retured from EFI_SCSI_IO_PROTOCOL.ResetDevice().\r
408\r
409**/\r
6ad55b15 410EFI_STATUS\r
411EFIAPI\r
412ScsiDiskReset (\r
413 IN EFI_BLOCK_IO_PROTOCOL *This,\r
414 IN BOOLEAN ExtendedVerification\r
9beb888e 415 );\r
6ad55b15 416\r
6ad55b15 417\r
9beb888e 418/**\r
419 The function is to Read Block from SCSI Disk.\r
6ad55b15 420\r
9beb888e 421 @param This The pointer of EFI_BLOCK_IO_PROTOCOL.\r
422 @param MediaId The Id of Media detected\r
423 @param Lba The logic block address\r
424 @param BufferSize The size of Buffer\r
425 @param Buffer The buffer to fill the read out data\r
6ad55b15 426\r
9beb888e 427 @retval EFI_SUCCESS Successfully to read out block.\r
428 @retval EFI_DEVICE_ERROR Fail to detect media.\r
429 @retval EFI_NO_MEDIA Media is not present.\r
430 @retval EFI_MEDIA_CHANGED Media has changed.\r
431 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
432 @retval EFI_INVALID_PARAMETER Invalid parameter passed in.\r
6ad55b15 433\r
9beb888e 434**/\r
6ad55b15 435EFI_STATUS\r
436EFIAPI\r
437ScsiDiskReadBlocks (\r
438 IN EFI_BLOCK_IO_PROTOCOL *This,\r
439 IN UINT32 MediaId,\r
9beb888e 440 IN EFI_LBA Lba,\r
6ad55b15 441 IN UINTN BufferSize,\r
442 OUT VOID *Buffer\r
9beb888e 443 );\r
6ad55b15 444\r
6ad55b15 445\r
9beb888e 446/**\r
447 The function is to Write Block to SCSI Disk.\r
448\r
449 @param This The pointer of EFI_BLOCK_IO_PROTOCOL\r
450 @param MediaId The Id of Media detected\r
451 @param Lba The logic block address\r
452 @param BufferSize The size of Buffer\r
453 @param Buffer The buffer to fill the read out data\r
454\r
455 @retval EFI_SUCCESS Successfully to read out block.\r
456 @retval EFI_WRITE_PROTECTED The device can not be written to.\r
457 @retval EFI_DEVICE_ERROR Fail to detect media.\r
458 @retval EFI_NO_MEDIA Media is not present.\r
459 @retval EFI_MEDIA_CHNAGED Media has changed.\r
460 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.\r
461 @retval EFI_INVALID_PARAMETER Invalid parameter passed in.\r
6ad55b15 462\r
9beb888e 463**/\r
6ad55b15 464EFI_STATUS\r
465EFIAPI\r
466ScsiDiskWriteBlocks (\r
467 IN EFI_BLOCK_IO_PROTOCOL *This,\r
468 IN UINT32 MediaId,\r
9beb888e 469 IN EFI_LBA Lba,\r
6ad55b15 470 IN UINTN BufferSize,\r
471 IN VOID *Buffer\r
9beb888e 472 );\r
6ad55b15 473\r
6ad55b15 474\r
9beb888e 475/**\r
476 Flush Block to Disk.\r
6ad55b15 477\r
9beb888e 478 EFI_SUCCESS is returned directly.\r
6ad55b15 479\r
9beb888e 480 @param This The pointer of EFI_BLOCK_IO_PROTOCOL\r
6ad55b15 481\r
9beb888e 482 @retval EFI_SUCCESS All outstanding data was written to the device\r
6ad55b15 483\r
9beb888e 484**/\r
6ad55b15 485EFI_STATUS\r
486EFIAPI\r
487ScsiDiskFlushBlocks (\r
488 IN EFI_BLOCK_IO_PROTOCOL *This\r
9beb888e 489 );\r
6ad55b15 490\r
d716651f 491\r
d670bf53
HW
492/**\r
493 Reset SCSI Disk.\r
494\r
495 @param This The pointer of EFI_BLOCK_IO2_PROTOCOL.\r
496 @param ExtendedVerification The flag about if extend verificate.\r
497\r
498 @retval EFI_SUCCESS The device was reset.\r
499 @retval EFI_DEVICE_ERROR The device is not functioning properly and could\r
500 not be reset.\r
501 @return EFI_STATUS is returned from EFI_SCSI_IO_PROTOCOL.ResetDevice().\r
502\r
503**/\r
504EFI_STATUS\r
505EFIAPI\r
506ScsiDiskResetEx (\r
507 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
508 IN BOOLEAN ExtendedVerification\r
509 );\r
510\r
511/**\r
512 The function is to Read Block from SCSI Disk.\r
513\r
514 @param This The pointer of EFI_BLOCK_IO_PROTOCOL.\r
515 @param MediaId The Id of Media detected.\r
516 @param Lba The logic block address.\r
517 @param Token A pointer to the token associated with the transaction.\r
518 @param BufferSize The size of Buffer.\r
519 @param Buffer The buffer to fill the read out data.\r
520\r
521 @retval EFI_SUCCESS The read request was queued if Token-> Event is\r
522 not NULL. The data was read correctly from the\r
523 device if theToken-> Event is NULL.\r
524 @retval EFI_DEVICE_ERROR The device reported an error while attempting\r
525 to perform the read operation.\r
526 @retval EFI_NO_MEDIA There is no media in the device.\r
527 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
528 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of\r
529 the intrinsic block size of the device.\r
530 @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not\r
531 valid, or the buffer is not on proper\r
532 alignment.\r
533 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a\r
534 lack of resources.\r
535\r
536**/\r
537EFI_STATUS\r
538EFIAPI\r
539ScsiDiskReadBlocksEx (\r
540 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
541 IN UINT32 MediaId,\r
542 IN EFI_LBA Lba,\r
543 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
544 IN UINTN BufferSize,\r
545 OUT VOID *Buffer\r
546 );\r
547\r
548/**\r
549 The function is to Write Block to SCSI Disk.\r
550\r
551 @param This The pointer of EFI_BLOCK_IO_PROTOCOL.\r
552 @param MediaId The Id of Media detected.\r
553 @param Lba The logic block address.\r
554 @param Token A pointer to the token associated with the transaction.\r
555 @param BufferSize The size of Buffer.\r
556 @param Buffer The buffer to fill the read out data.\r
557\r
558 @retval EFI_SUCCESS The data were written correctly to the device.\r
559 @retval EFI_WRITE_PROTECTED The device cannot be written to.\r
560 @retval EFI_NO_MEDIA There is no media in the device.\r
561 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
562 @retval EFI_DEVICE_ERROR The device reported an error while attempting\r
563 to perform the write operation.\r
564 @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of\r
565 the intrinsic block size of the device.\r
566 @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not\r
567 valid, or the buffer is not on proper\r
568 alignment.\r
569\r
570**/\r
571EFI_STATUS\r
572EFIAPI\r
573ScsiDiskWriteBlocksEx (\r
574 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
575 IN UINT32 MediaId,\r
576 IN EFI_LBA Lba,\r
577 IN OUT EFI_BLOCK_IO2_TOKEN *Token,\r
578 IN UINTN BufferSize,\r
579 IN VOID *Buffer\r
580 );\r
581\r
582/**\r
583 Flush the Block Device.\r
584\r
585 @param This Indicates a pointer to the calling context.\r
586 @param Token A pointer to the token associated with the transaction.\r
587\r
7013e088
HW
588 @retval EFI_SUCCESS All outstanding data was written to the device.\r
589 @retval EFI_DEVICE_ERROR The device reported an error while attempting to\r
590 write data.\r
591 @retval EFI_WRITE_PROTECTED The device cannot be written to.\r
592 @retval EFI_NO_MEDIA There is no media in the device.\r
593 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
d670bf53
HW
594\r
595**/\r
596EFI_STATUS\r
597EFIAPI\r
598ScsiDiskFlushBlocksEx (\r
599 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
600 IN OUT EFI_BLOCK_IO2_TOKEN *Token\r
601 );\r
602\r
b6e5da19
HW
603/**\r
604 Erase a specified number of device blocks.\r
605\r
606 @param[in] This Indicates a pointer to the calling context.\r
607 @param[in] MediaId The media ID that the erase request is for.\r
608 @param[in] Lba The starting logical block address to be\r
609 erased. The caller is responsible for erasing\r
610 only legitimate locations.\r
611 @param[in, out] Token A pointer to the token associated with the\r
612 transaction.\r
613 @param[in] Size The size in bytes to be erased. This must be\r
614 a multiple of the physical block size of the\r
615 device.\r
616\r
617 @retval EFI_SUCCESS The erase request was queued if Event is not\r
618 NULL. The data was erased correctly to the\r
619 device if the Event is NULL.to the device.\r
620 @retval EFI_WRITE_PROTECTED The device cannot be erased due to write\r
621 protection.\r
622 @retval EFI_DEVICE_ERROR The device reported an error while attempting\r
623 to perform the erase operation.\r
624 @retval EFI_INVALID_PARAMETER The erase request contains LBAs that are not\r
625 valid.\r
626 @retval EFI_NO_MEDIA There is no media in the device.\r
627 @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.\r
628\r
629**/\r
630EFI_STATUS\r
631EFIAPI\r
632ScsiDiskEraseBlocks (\r
633 IN EFI_ERASE_BLOCK_PROTOCOL *This,\r
634 IN UINT32 MediaId,\r
635 IN EFI_LBA Lba,\r
636 IN OUT EFI_ERASE_BLOCK_TOKEN *Token,\r
637 IN UINTN Size\r
638 );\r
639\r
d670bf53 640\r
d716651f 641/**\r
642 Provides inquiry information for the controller type.\r
d1102dba 643\r
d716651f 644 This function is used by the IDE bus driver to get inquiry data. Data format\r
645 of Identify data is defined by the Interface GUID.\r
646\r
4140a663 647 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
648 @param[in, out] InquiryData Pointer to a buffer for the inquiry data.\r
649 @param[in, out] InquiryDataSize Pointer to the value for the inquiry data size.\r
d716651f 650\r
651 @retval EFI_SUCCESS The command was accepted without any errors.\r
d1102dba
LG
652 @retval EFI_NOT_FOUND Device does not support this data class\r
653 @retval EFI_DEVICE_ERROR Error reading InquiryData from device\r
654 @retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough\r
d716651f 655\r
656**/\r
657EFI_STATUS\r
658EFIAPI\r
659ScsiDiskInfoInquiry (\r
660 IN EFI_DISK_INFO_PROTOCOL *This,\r
661 IN OUT VOID *InquiryData,\r
662 IN OUT UINT32 *InquiryDataSize\r
663 );\r
664\r
665\r
666/**\r
667 Provides identify information for the controller type.\r
668\r
669 This function is used by the IDE bus driver to get identify data. Data format\r
670 of Identify data is defined by the Interface GUID.\r
671\r
d1102dba 672 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL\r
d716651f 673 instance.\r
4140a663 674 @param[in, out] IdentifyData Pointer to a buffer for the identify data.\r
675 @param[in, out] IdentifyDataSize Pointer to the value for the identify data\r
d716651f 676 size.\r
677\r
678 @retval EFI_SUCCESS The command was accepted without any errors.\r
d1102dba
LG
679 @retval EFI_NOT_FOUND Device does not support this data class\r
680 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device\r
681 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough\r
d716651f 682\r
683**/\r
684EFI_STATUS\r
685EFIAPI\r
686ScsiDiskInfoIdentify (\r
687 IN EFI_DISK_INFO_PROTOCOL *This,\r
688 IN OUT VOID *IdentifyData,\r
689 IN OUT UINT32 *IdentifyDataSize\r
690 );\r
691\r
692\r
693/**\r
694 Provides sense data information for the controller type.\r
d1102dba
LG
695\r
696 This function is used by the IDE bus driver to get sense data.\r
d716651f 697 Data format of Sense data is defined by the Interface GUID.\r
698\r
4140a663 699 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
700 @param[in, out] SenseData Pointer to the SenseData.\r
701 @param[in, out] SenseDataSize Size of SenseData in bytes.\r
702 @param[out] SenseDataNumber Pointer to the value for the sense data size.\r
d716651f 703\r
704 @retval EFI_SUCCESS The command was accepted without any errors.\r
705 @retval EFI_NOT_FOUND Device does not support this data class.\r
706 @retval EFI_DEVICE_ERROR Error reading SenseData from device.\r
707 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough.\r
708\r
709**/\r
710EFI_STATUS\r
711EFIAPI\r
712ScsiDiskInfoSenseData (\r
713 IN EFI_DISK_INFO_PROTOCOL *This,\r
714 IN OUT VOID *SenseData,\r
715 IN OUT UINT32 *SenseDataSize,\r
716 OUT UINT8 *SenseDataNumber\r
717 );\r
718\r
719/**\r
720 This function is used by the IDE bus driver to get controller information.\r
721\r
d1102dba 722 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
d716651f 723 @param[out] IdeChannel Pointer to the Ide Channel number. Primary or secondary.\r
724 @param[out] IdeDevice Pointer to the Ide Device number. Master or slave.\r
725\r
726 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid.\r
727 @retval EFI_UNSUPPORTED This is not an IDE device.\r
728\r
729**/\r
730EFI_STATUS\r
731EFIAPI\r
732ScsiDiskInfoWhichIde (\r
733 IN EFI_DISK_INFO_PROTOCOL *This,\r
734 OUT UINT32 *IdeChannel,\r
735 OUT UINT32 *IdeDevice\r
736 );\r
737\r
738\r
9beb888e 739/**\r
d716651f 740 Detect Device and read out capacity ,if error occurs, parse the sense key.\r
6ad55b15 741\r
9beb888e 742 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
743 @param MustReadCapacity The flag about reading device capacity\r
d1102dba 744 @param MediaChange The pointer of flag indicates if media has changed\r
6ad55b15 745\r
9beb888e 746 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
747 @retval EFI_SUCCESS Successfully to detect media\r
6ad55b15 748\r
9beb888e 749**/\r
6ad55b15 750EFI_STATUS\r
751ScsiDiskDetectMedia (\r
9beb888e 752 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
753 IN BOOLEAN MustReadCapacity,\r
754 OUT BOOLEAN *MediaChange\r
755 );\r
6ad55b15 756\r
9beb888e 757/**\r
d716651f 758 To test device.\r
6ad55b15 759\r
9beb888e 760 When Test Unit Ready command succeeds, retrieve Sense Keys via Request Sense;\r
761 When Test Unit Ready command encounters any error caused by host adapter or\r
762 target, return error without retrieving Sense Keys.\r
6ad55b15 763\r
9beb888e 764 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
765 @param NeedRetry The pointer of flag indicates try again\r
766 @param SenseDataArray The pointer of an array of sense data\r
767 @param NumberOfSenseKeys The pointer of the number of sense data array\r
6ad55b15 768\r
9beb888e 769 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
770 @retval EFI_SUCCESS Successfully to test unit\r
f36d6e66 771\r
9beb888e 772**/\r
6ad55b15 773EFI_STATUS\r
774ScsiDiskTestUnitReady (\r
9beb888e 775 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
776 OUT BOOLEAN *NeedRetry,\r
777 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
778 OUT UINTN *NumberOfSenseKeys\r
779 );\r
6ad55b15 780\r
6ad55b15 781\r
9beb888e 782/**\r
783 Parsing Sense Keys which got from request sense command.\r
6ad55b15 784\r
9beb888e 785 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
786 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
d1102dba 787 @param NumberOfSenseKeys The number of sense key\r
9beb888e 788 @param Action The pointer of action which indicates what is need to do next\r
6ad55b15 789\r
9beb888e 790 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
791 @retval EFI_SUCCESS Successfully to complete the parsing\r
6ad55b15 792\r
9beb888e 793**/\r
6ad55b15 794EFI_STATUS\r
795DetectMediaParsingSenseKeys (\r
9beb888e 796 OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
797 IN EFI_SCSI_SENSE_DATA *SenseData,\r
798 IN UINTN NumberOfSenseKeys,\r
799 OUT UINTN *Action\r
800 );\r
6ad55b15 801\r
6ad55b15 802\r
9beb888e 803/**\r
804 Send read capacity command to device and get the device parameter.\r
6ad55b15 805\r
9beb888e 806 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
807 @param NeedRetry The pointer of flag indicates if need a retry\r
808 @param SenseDataArray The pointer of an array of sense data\r
809 @param NumberOfSenseKeys The number of sense key\r
6ad55b15 810\r
9beb888e 811 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
812 @retval EFI_SUCCESS Successfully to read capacity\r
6ad55b15 813\r
9beb888e 814**/\r
6ad55b15 815EFI_STATUS\r
816ScsiDiskReadCapacity (\r
9beb888e 817 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
818 OUT BOOLEAN *NeedRetry,\r
819 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
820 OUT UINTN *NumberOfSenseKeys\r
821 );\r
6ad55b15 822\r
9beb888e 823/**\r
824 Check the HostAdapter status and re-interpret it in EFI_STATUS.\r
6ad55b15 825\r
9beb888e 826 @param HostAdapterStatus Host Adapter status\r
6ad55b15 827\r
9beb888e 828 @retval EFI_SUCCESS Host adapter is OK.\r
829 @retval EFI_TIMEOUT Timeout.\r
830 @retval EFI_NOT_READY Adapter NOT ready.\r
831 @retval EFI_DEVICE_ERROR Adapter device error.\r
6ad55b15 832\r
9beb888e 833**/\r
6ad55b15 834EFI_STATUS\r
835CheckHostAdapterStatus (\r
9beb888e 836 IN UINT8 HostAdapterStatus\r
837 );\r
6ad55b15 838\r
6ad55b15 839\r
9beb888e 840/**\r
841 Check the target status and re-interpret it in EFI_STATUS.\r
6ad55b15 842\r
9beb888e 843 @param TargetStatus Target status\r
6ad55b15 844\r
9beb888e 845 @retval EFI_NOT_READY Device is NOT ready.\r
d1102dba 846 @retval EFI_DEVICE_ERROR\r
9beb888e 847 @retval EFI_SUCCESS\r
6ad55b15 848\r
9beb888e 849**/\r
6ad55b15 850EFI_STATUS\r
851CheckTargetStatus (\r
9beb888e 852 IN UINT8 TargetStatus\r
853 );\r
6ad55b15 854\r
9beb888e 855/**\r
856 Retrieve all sense keys from the device.\r
6ad55b15 857\r
9beb888e 858 When encountering error during the process, if retrieve sense keys before\r
d716651f 859 error encountered, it returns the sense keys with return status set to EFI_SUCCESS,\r
9beb888e 860 and NeedRetry set to FALSE; otherwize, return the proper return status.\r
6ad55b15 861\r
9beb888e 862 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
863 @param NeedRetry The pointer of flag indicates if need a retry\r
864 @param SenseDataArray The pointer of an array of sense data\r
865 @param NumberOfSenseKeys The number of sense key\r
866 @param AskResetIfError The flag indicates if need reset when error occurs\r
6ad55b15 867\r
9beb888e 868 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
869 @retval EFI_SUCCESS Successfully to request sense key\r
6ad55b15 870\r
9beb888e 871**/\r
6ad55b15 872EFI_STATUS\r
873ScsiDiskRequestSenseKeys (\r
9beb888e 874 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
875 OUT BOOLEAN *NeedRetry,\r
876 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
877 OUT UINTN *NumberOfSenseKeys,\r
878 IN BOOLEAN AskResetIfError\r
879 );\r
6ad55b15 880\r
9beb888e 881/**\r
882 Send out Inquiry command to Device.\r
6ad55b15 883\r
9beb888e 884 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
885 @param NeedRetry Indicates if needs try again when error happens\r
6ad55b15 886\r
9beb888e 887 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
888 @retval EFI_SUCCESS Successfully to detect media\r
6ad55b15 889\r
9beb888e 890**/\r
6ad55b15 891EFI_STATUS\r
892ScsiDiskInquiryDevice (\r
9beb888e 893 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
894 OUT BOOLEAN *NeedRetry\r
895 );\r
6ad55b15 896\r
9beb888e 897/**\r
898 Parse Inquiry data.\r
6ad55b15 899\r
9beb888e 900 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
6ad55b15 901\r
9beb888e 902**/\r
6ad55b15 903VOID\r
904ParseInquiryData (\r
9beb888e 905 IN OUT SCSI_DISK_DEV *ScsiDiskDevice\r
906 );\r
6ad55b15 907\r
9beb888e 908/**\r
909 Read sector from SCSI Disk.\r
6ad55b15 910\r
d716651f 911 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
9beb888e 912 @param Buffer The buffer to fill in the read out data\r
913 @param Lba Logic block address\r
914 @param NumberOfBlocks The number of blocks to read\r
6ad55b15 915\r
9beb888e 916 @retval EFI_DEVICE_ERROR Indicates a device error.\r
917 @retval EFI_SUCCESS Operation is successful.\r
6ad55b15 918\r
9beb888e 919**/\r
6ad55b15 920EFI_STATUS\r
921ScsiDiskReadSectors (\r
9beb888e 922 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
923 OUT VOID *Buffer,\r
924 IN EFI_LBA Lba,\r
925 IN UINTN NumberOfBlocks\r
926 );\r
6ad55b15 927\r
9beb888e 928/**\r
929 Write sector to SCSI Disk.\r
6ad55b15 930\r
d716651f 931 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
9beb888e 932 @param Buffer The buffer of data to be written into SCSI Disk\r
933 @param Lba Logic block address\r
934 @param NumberOfBlocks The number of blocks to read\r
6ad55b15 935\r
9beb888e 936 @retval EFI_DEVICE_ERROR Indicates a device error.\r
937 @retval EFI_SUCCESS Operation is successful.\r
6ad55b15 938\r
9beb888e 939**/\r
6ad55b15 940EFI_STATUS\r
941ScsiDiskWriteSectors (\r
9beb888e 942 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
943 IN VOID *Buffer,\r
944 IN EFI_LBA Lba,\r
945 IN UINTN NumberOfBlocks\r
946 );\r
6ad55b15 947\r
d670bf53
HW
948/**\r
949 Asynchronously read sector from SCSI Disk.\r
950\r
951 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV.\r
952 @param Buffer The buffer to fill in the read out data.\r
953 @param Lba Logic block address.\r
954 @param NumberOfBlocks The number of blocks to read.\r
955 @param Token A pointer to the token associated with the\r
956 non-blocking read request.\r
957\r
958 @retval EFI_INVALID_PARAMETER Token is NULL or Token->Event is NULL.\r
959 @retval EFI_DEVICE_ERROR Indicates a device error.\r
960 @retval EFI_SUCCESS Operation is successful.\r
961\r
962**/\r
963EFI_STATUS\r
964ScsiDiskAsyncReadSectors (\r
965 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
966 OUT VOID *Buffer,\r
967 IN EFI_LBA Lba,\r
968 IN UINTN NumberOfBlocks,\r
969 IN EFI_BLOCK_IO2_TOKEN *Token\r
970 );\r
971\r
972/**\r
973 Asynchronously write sector to SCSI Disk.\r
974\r
975 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV.\r
976 @param Buffer The buffer of data to be written into SCSI Disk.\r
977 @param Lba Logic block address.\r
978 @param NumberOfBlocks The number of blocks to read.\r
979 @param Token A pointer to the token associated with the\r
980 non-blocking read request.\r
981\r
982 @retval EFI_INVALID_PARAMETER Token is NULL or Token->Event is NULL\r
983 @retval EFI_DEVICE_ERROR Indicates a device error.\r
984 @retval EFI_SUCCESS Operation is successful.\r
985\r
986**/\r
987EFI_STATUS\r
988ScsiDiskAsyncWriteSectors (\r
989 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
990 IN VOID *Buffer,\r
991 IN EFI_LBA Lba,\r
992 IN UINTN NumberOfBlocks,\r
993 IN EFI_BLOCK_IO2_TOKEN *Token\r
994 );\r
995\r
9beb888e 996/**\r
73a9e822 997 Submit Read(10) command.\r
9beb888e 998\r
999 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
1000 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
9beb888e 1001 @param Timeout The time to complete the command\r
1002 @param DataBuffer The buffer to fill with the read out data\r
1003 @param DataLength The length of buffer\r
1004 @param StartLba The start logic block address\r
73a9e822 1005 @param SectorCount The number of blocks to read\r
9beb888e 1006\r
1007 @return EFI_STATUS is returned by calling ScsiRead10Command().\r
1008**/\r
6ad55b15 1009EFI_STATUS\r
1010ScsiDiskRead10 (\r
9beb888e 1011 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1012 OUT BOOLEAN *NeedRetry,\r
9beb888e 1013 IN UINT64 Timeout,\r
1014 OUT UINT8 *DataBuffer,\r
1015 IN OUT UINT32 *DataLength,\r
1016 IN UINT32 StartLba,\r
73a9e822 1017 IN UINT32 SectorCount\r
9beb888e 1018 );\r
6ad55b15 1019\r
9beb888e 1020/**\r
73a9e822 1021 Submit Write(10) Command.\r
6ad55b15 1022\r
9beb888e 1023 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
1024 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
9beb888e 1025 @param Timeout The time to complete the command\r
1026 @param DataBuffer The buffer to fill with the read out data\r
1027 @param DataLength The length of buffer\r
1028 @param StartLba The start logic block address\r
73a9e822 1029 @param SectorCount The number of blocks to write\r
6ad55b15 1030\r
9beb888e 1031 @return EFI_STATUS is returned by calling ScsiWrite10Command().\r
6ad55b15 1032\r
9beb888e 1033**/\r
6ad55b15 1034EFI_STATUS\r
1035ScsiDiskWrite10 (\r
9beb888e 1036 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1037 OUT BOOLEAN *NeedRetry,\r
9beb888e 1038 IN UINT64 Timeout,\r
1039 IN UINT8 *DataBuffer,\r
1040 IN OUT UINT32 *DataLength,\r
1041 IN UINT32 StartLba,\r
73a9e822 1042 IN UINT32 SectorCount\r
9beb888e 1043 );\r
6ad55b15 1044\r
a108933e 1045/**\r
1046 Submit Read(16) command.\r
1047\r
1048 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
1049 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
a108933e 1050 @param Timeout The time to complete the command\r
1051 @param DataBuffer The buffer to fill with the read out data\r
1052 @param DataLength The length of buffer\r
1053 @param StartLba The start logic block address\r
73a9e822 1054 @param SectorCount The number of blocks to read\r
a108933e 1055\r
73a9e822 1056 @return EFI_STATUS is returned by calling ScsiRead16Command().\r
a108933e 1057**/\r
1058EFI_STATUS\r
1059ScsiDiskRead16 (\r
1060 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1061 OUT BOOLEAN *NeedRetry,\r
a108933e 1062 IN UINT64 Timeout,\r
1063 OUT UINT8 *DataBuffer,\r
1064 IN OUT UINT32 *DataLength,\r
1065 IN UINT64 StartLba,\r
73a9e822 1066 IN UINT32 SectorCount\r
a108933e 1067 );\r
d1102dba 1068\r
a108933e 1069/**\r
1070 Submit Write(16) Command.\r
1071\r
1072 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
1073 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
a108933e 1074 @param Timeout The time to complete the command\r
1075 @param DataBuffer The buffer to fill with the read out data\r
1076 @param DataLength The length of buffer\r
1077 @param StartLba The start logic block address\r
73a9e822 1078 @param SectorCount The number of blocks to write\r
a108933e 1079\r
73a9e822 1080 @return EFI_STATUS is returned by calling ScsiWrite16Command().\r
a108933e 1081\r
1082**/\r
1083EFI_STATUS\r
1084ScsiDiskWrite16 (\r
1085 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1086 OUT BOOLEAN *NeedRetry,\r
a108933e 1087 IN UINT64 Timeout,\r
1088 IN UINT8 *DataBuffer,\r
1089 IN OUT UINT32 *DataLength,\r
1090 IN UINT64 StartLba,\r
73a9e822 1091 IN UINT32 SectorCount\r
d1102dba 1092 );\r
a108933e 1093\r
d670bf53
HW
1094/**\r
1095 Submit Async Read(10) command.\r
1096\r
1097 @param ScsiDiskDevice The pointer of ScsiDiskDevice.\r
1098 @param Timeout The time to complete the command.\r
032800ec 1099 @param TimesRetry The number of times the command has been retried.\r
d670bf53
HW
1100 @param DataBuffer The buffer to fill with the read out data.\r
1101 @param DataLength The length of buffer.\r
1102 @param StartLba The start logic block address.\r
1103 @param SectorCount The number of blocks to read.\r
1104 @param BlkIo2Req The upstream BlockIo2 request.\r
1105 @param Token The pointer to the token associated with the\r
1106 non-blocking read request.\r
1107\r
1108 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a\r
1109 lack of resources.\r
1110 @return others Status returned by calling\r
1111 ScsiRead10CommandEx().\r
1112\r
1113**/\r
1114EFI_STATUS\r
1115ScsiDiskAsyncRead10 (\r
1116 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1117 IN UINT64 Timeout,\r
032800ec 1118 IN UINT8 TimesRetry,\r
d670bf53
HW
1119 OUT UINT8 *DataBuffer,\r
1120 IN UINT32 DataLength,\r
1121 IN UINT32 StartLba,\r
1122 IN UINT32 SectorCount,\r
1123 IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req,\r
1124 IN EFI_BLOCK_IO2_TOKEN *Token\r
1125 );\r
1126\r
1127/**\r
1128 Submit Async Write(10) command.\r
1129\r
1130 @param ScsiDiskDevice The pointer of ScsiDiskDevice.\r
1131 @param Timeout The time to complete the command.\r
032800ec 1132 @param TimesRetry The number of times the command has been retried.\r
d670bf53
HW
1133 @param DataBuffer The buffer contains the data to write.\r
1134 @param DataLength The length of buffer.\r
1135 @param StartLba The start logic block address.\r
1136 @param SectorCount The number of blocks to write.\r
1137 @param BlkIo2Req The upstream BlockIo2 request.\r
1138 @param Token The pointer to the token associated with the\r
1139 non-blocking read request.\r
1140\r
1141 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a\r
1142 lack of resources.\r
1143 @return others Status returned by calling\r
1144 ScsiWrite10CommandEx().\r
1145\r
1146**/\r
1147EFI_STATUS\r
1148ScsiDiskAsyncWrite10 (\r
1149 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1150 IN UINT64 Timeout,\r
032800ec 1151 IN UINT8 TimesRetry,\r
d670bf53
HW
1152 IN UINT8 *DataBuffer,\r
1153 IN UINT32 DataLength,\r
1154 IN UINT32 StartLba,\r
1155 IN UINT32 SectorCount,\r
1156 IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req,\r
1157 IN EFI_BLOCK_IO2_TOKEN *Token\r
1158 );\r
1159\r
1160/**\r
1161 Submit Async Read(16) command.\r
1162\r
1163 @param ScsiDiskDevice The pointer of ScsiDiskDevice.\r
1164 @param Timeout The time to complete the command.\r
032800ec 1165 @param TimesRetry The number of times the command has been retried.\r
d670bf53
HW
1166 @param DataBuffer The buffer to fill with the read out data.\r
1167 @param DataLength The length of buffer.\r
1168 @param StartLba The start logic block address.\r
1169 @param SectorCount The number of blocks to read.\r
1170 @param BlkIo2Req The upstream BlockIo2 request.\r
1171 @param Token The pointer to the token associated with the\r
1172 non-blocking read request.\r
1173\r
1174 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a\r
1175 lack of resources.\r
1176 @return others Status returned by calling\r
1177 ScsiRead16CommandEx().\r
1178\r
1179**/\r
1180EFI_STATUS\r
1181ScsiDiskAsyncRead16 (\r
1182 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1183 IN UINT64 Timeout,\r
032800ec 1184 IN UINT8 TimesRetry,\r
d670bf53
HW
1185 OUT UINT8 *DataBuffer,\r
1186 IN UINT32 DataLength,\r
1187 IN UINT64 StartLba,\r
1188 IN UINT32 SectorCount,\r
1189 IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req,\r
1190 IN EFI_BLOCK_IO2_TOKEN *Token\r
1191 );\r
1192\r
1193/**\r
1194 Submit Async Write(16) command.\r
1195\r
1196 @param ScsiDiskDevice The pointer of ScsiDiskDevice.\r
1197 @param Timeout The time to complete the command.\r
032800ec 1198 @param TimesRetry The number of times the command has been retried.\r
d670bf53
HW
1199 @param DataBuffer The buffer contains the data to write.\r
1200 @param DataLength The length of buffer.\r
1201 @param StartLba The start logic block address.\r
1202 @param SectorCount The number of blocks to write.\r
1203 @param BlkIo2Req The upstream BlockIo2 request.\r
1204 @param Token The pointer to the token associated with the\r
1205 non-blocking read request.\r
1206\r
1207 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a\r
1208 lack of resources.\r
1209 @return others Status returned by calling\r
1210 ScsiWrite16CommandEx().\r
1211\r
1212**/\r
1213EFI_STATUS\r
1214ScsiDiskAsyncWrite16 (\r
1215 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1216 IN UINT64 Timeout,\r
032800ec 1217 IN UINT8 TimesRetry,\r
d670bf53
HW
1218 IN UINT8 *DataBuffer,\r
1219 IN UINT32 DataLength,\r
1220 IN UINT64 StartLba,\r
1221 IN UINT32 SectorCount,\r
1222 IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req,\r
1223 IN EFI_BLOCK_IO2_TOKEN *Token\r
1224 );\r
1225\r
9beb888e 1226/**\r
1227 Get information from media read capacity command.\r
6ad55b15 1228\r
9beb888e 1229 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
b96cd313 1230 @param Capacity10 The pointer of EFI_SCSI_DISK_CAPACITY_DATA\r
1231 @param Capacity16 The pointer of EFI_SCSI_DISK_CAPACITY_DATA16\r
9beb888e 1232**/\r
6ad55b15 1233VOID\r
1234GetMediaInfo (\r
aa75dfec 1235 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
1236 IN EFI_SCSI_DISK_CAPACITY_DATA *Capacity10,\r
1237 IN EFI_SCSI_DISK_CAPACITY_DATA16 *Capacity16\r
9beb888e 1238 );\r
6ad55b15 1239\r
9beb888e 1240/**\r
1241 Check sense key to find if media presents.\r
6ad55b15 1242\r
9beb888e 1243 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
1244 @param SenseCounts The number of sense key\r
6ad55b15 1245\r
9beb888e 1246 @retval TRUE NOT any media\r
1247 @retval FALSE Media presents\r
1248**/\r
6ad55b15 1249BOOLEAN\r
1250ScsiDiskIsNoMedia (\r
1251 IN EFI_SCSI_SENSE_DATA *SenseData,\r
1252 IN UINTN SenseCounts\r
9beb888e 1253 );\r
6ad55b15 1254\r
9beb888e 1255/**\r
1256 Parse sense key.\r
6ad55b15 1257\r
9beb888e 1258 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
1259 @param SenseCounts The number of sense key\r
6ad55b15 1260\r
9beb888e 1261 @retval TRUE Error\r
1262 @retval FALSE NOT error\r
6ad55b15 1263\r
9beb888e 1264**/\r
6ad55b15 1265BOOLEAN\r
1266ScsiDiskIsMediaError (\r
1267 IN EFI_SCSI_SENSE_DATA *SenseData,\r
1268 IN UINTN SenseCounts\r
9beb888e 1269 );\r
6ad55b15 1270\r
9beb888e 1271/**\r
1272 Check sense key to find if hardware error happens.\r
6ad55b15 1273\r
9beb888e 1274 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
1275 @param SenseCounts The number of sense key\r
6ad55b15 1276\r
9beb888e 1277 @retval TRUE Hardware error exits.\r
1278 @retval FALSE NO error.\r
6ad55b15 1279\r
9beb888e 1280**/\r
6ad55b15 1281BOOLEAN\r
1282ScsiDiskIsHardwareError (\r
1283 IN EFI_SCSI_SENSE_DATA *SenseData,\r
1284 IN UINTN SenseCounts\r
9beb888e 1285 );\r
6ad55b15 1286\r
9beb888e 1287/**\r
1288 Check sense key to find if media has changed.\r
6ad55b15 1289\r
9beb888e 1290 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
1291 @param SenseCounts The number of sense key\r
6ad55b15 1292\r
9beb888e 1293 @retval TRUE Media is changed.\r
1294 @retval FALSE Medit is NOT changed.\r
1295**/\r
6ad55b15 1296BOOLEAN\r
1297ScsiDiskIsMediaChange (\r
1298 IN EFI_SCSI_SENSE_DATA *SenseData,\r
1299 IN UINTN SenseCounts\r
9beb888e 1300 );\r
6ad55b15 1301\r
9beb888e 1302/**\r
1303 Check sense key to find if reset happens.\r
6ad55b15 1304\r
9beb888e 1305 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
1306 @param SenseCounts The number of sense key\r
6ad55b15 1307\r
9beb888e 1308 @retval TRUE It is reset before.\r
1309 @retval FALSE It is NOT reset before.\r
6ad55b15 1310\r
9beb888e 1311**/\r
6ad55b15 1312BOOLEAN\r
1313ScsiDiskIsResetBefore (\r
1314 IN EFI_SCSI_SENSE_DATA *SenseData,\r
1315 IN UINTN SenseCounts\r
9beb888e 1316 );\r
6ad55b15 1317\r
9beb888e 1318/**\r
1319 Check sense key to find if the drive is ready.\r
6ad55b15 1320\r
9beb888e 1321 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
1322 @param SenseCounts The number of sense key\r
d1102dba 1323 @param RetryLater The flag means if need a retry\r
6ad55b15 1324\r
9beb888e 1325 @retval TRUE Drive is ready.\r
1326 @retval FALSE Drive is NOT ready.\r
6ad55b15 1327\r
9beb888e 1328**/\r
6ad55b15 1329BOOLEAN\r
1330ScsiDiskIsDriveReady (\r
1331 IN EFI_SCSI_SENSE_DATA *SenseData,\r
1332 IN UINTN SenseCounts,\r
9beb888e 1333 OUT BOOLEAN *RetryLater\r
1334 );\r
6ad55b15 1335\r
9beb888e 1336/**\r
1337 Check sense key to find if it has sense key.\r
6ad55b15 1338\r
9beb888e 1339 @param SenseData - The pointer of EFI_SCSI_SENSE_DATA\r
1340 @param SenseCounts - The number of sense key\r
6ad55b15 1341\r
9beb888e 1342 @retval TRUE It has sense key.\r
1343 @retval FALSE It has NOT any sense key.\r
6ad55b15 1344\r
9beb888e 1345**/\r
6ad55b15 1346BOOLEAN\r
1347ScsiDiskHaveSenseKey (\r
1348 IN EFI_SCSI_SENSE_DATA *SenseData,\r
1349 IN UINTN SenseCounts\r
9beb888e 1350 );\r
6ad55b15 1351\r
9beb888e 1352/**\r
1353 Release resource about disk device.\r
6ad55b15 1354\r
9beb888e 1355 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
6ad55b15 1356\r
9beb888e 1357**/\r
6ad55b15 1358VOID\r
1359ReleaseScsiDiskDeviceResources (\r
1360 IN SCSI_DISK_DEV *ScsiDiskDevice\r
9beb888e 1361 );\r
6ad55b15 1362\r
d14faa52 1363/**\r
1364 Determine if Block Io should be produced.\r
d1102dba 1365\r
d14faa52 1366\r
d716651f 1367 @param ChildHandle Child Handle to retrieve Parent information.\r
d1102dba 1368\r
d14faa52 1369 @retval TRUE Should produce Block Io.\r
1370 @retval FALSE Should not produce Block Io.\r
1371\r
d1102dba 1372**/\r
d14faa52 1373BOOLEAN\r
1374DetermineInstallBlockIo (\r
1375 IN EFI_HANDLE ChildHandle\r
1376 );\r
1377\r
d716651f 1378/**\r
1379 Initialize the installation of DiskInfo protocol.\r
1380\r
1381 This function prepares for the installation of DiskInfo protocol on the child handle.\r
1382 By default, it installs DiskInfo protocol with SCSI interface GUID. If it further\r
1383 detects that the physical device is an ATAPI/AHCI device, it then updates interface GUID\r
1384 to be IDE/AHCI interface GUID.\r
1385\r
1386 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV.\r
1387 @param ChildHandle Child handle to install DiskInfo protocol.\r
d1102dba
LG
1388\r
1389**/\r
d716651f 1390VOID\r
1391InitializeInstallDiskInfo (\r
1392 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1393 IN EFI_HANDLE ChildHandle\r
d1102dba 1394 );\r
d716651f 1395\r
d14faa52 1396/**\r
1397 Search protocol database and check to see if the protocol\r
1398 specified by ProtocolGuid is present on a ControllerHandle and opened by\r
1399 ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
1400 If the ControllerHandle is found, then the protocol specified by ProtocolGuid\r
d1102dba
LG
1401 will be opened on it.\r
1402\r
d14faa52 1403\r
1404 @param ProtocolGuid ProtocolGuid pointer.\r
1405 @param ChildHandle Child Handle to retrieve Parent information.\r
d1102dba
LG
1406\r
1407**/\r
d14faa52 1408VOID *\r
1409EFIAPI\r
1410GetParentProtocol (\r
1411 IN EFI_GUID *ProtocolGuid,\r
1412 IN EFI_HANDLE ChildHandle\r
1413 );\r
1414\r
b6e5da19
HW
1415/**\r
1416 Determine if EFI Erase Block Protocol should be produced.\r
1417\r
1418 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV.\r
1419 @param ChildHandle Handle of device.\r
1420\r
1421 @retval TRUE Should produce EFI Erase Block Protocol.\r
1422 @retval FALSE Should not produce EFI Erase Block Protocol.\r
1423\r
1424**/\r
1425BOOLEAN\r
1426DetermineInstallEraseBlock (\r
1427 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1428 IN EFI_HANDLE ChildHandle\r
1429 );\r
1430\r
6ad55b15 1431#endif\r