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