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