]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Bus/Scsi/ScsiDiskDxe/ScsiDisk.h
MdeModulePkg ScsiDiskDxe: Add BlockIO2 Support
[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
558 @retval EFI_SUCCESS All outstanding data was written to the device.\r
559 @retval EFI_DEVICE_ERROR The device reported an error while writing back the\r
560 data.\r
561 @retval EFI_NO_MEDIA There is no media in the device.\r
562\r
563**/\r
564EFI_STATUS\r
565EFIAPI\r
566ScsiDiskFlushBlocksEx (\r
567 IN EFI_BLOCK_IO2_PROTOCOL *This,\r
568 IN OUT EFI_BLOCK_IO2_TOKEN *Token\r
569 );\r
570\r
571\r
d716651f 572/**\r
573 Provides inquiry information for the controller type.\r
574 \r
575 This function is used by the IDE bus driver to get inquiry data. Data format\r
576 of Identify data is defined by the Interface GUID.\r
577\r
4140a663 578 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
579 @param[in, out] InquiryData Pointer to a buffer for the inquiry data.\r
580 @param[in, out] InquiryDataSize Pointer to the value for the inquiry data size.\r
d716651f 581\r
582 @retval EFI_SUCCESS The command was accepted without any errors.\r
583 @retval EFI_NOT_FOUND Device does not support this data class \r
584 @retval EFI_DEVICE_ERROR Error reading InquiryData from device \r
585 @retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough \r
586\r
587**/\r
588EFI_STATUS\r
589EFIAPI\r
590ScsiDiskInfoInquiry (\r
591 IN EFI_DISK_INFO_PROTOCOL *This,\r
592 IN OUT VOID *InquiryData,\r
593 IN OUT UINT32 *InquiryDataSize\r
594 );\r
595\r
596\r
597/**\r
598 Provides identify information for the controller type.\r
599\r
600 This function is used by the IDE bus driver to get identify data. Data format\r
601 of Identify data is defined by the Interface GUID.\r
602\r
603 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL \r
604 instance.\r
4140a663 605 @param[in, out] IdentifyData Pointer to a buffer for the identify data.\r
606 @param[in, out] IdentifyDataSize Pointer to the value for the identify data\r
d716651f 607 size.\r
608\r
609 @retval EFI_SUCCESS The command was accepted without any errors.\r
610 @retval EFI_NOT_FOUND Device does not support this data class \r
611 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device \r
612 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough \r
613\r
614**/\r
615EFI_STATUS\r
616EFIAPI\r
617ScsiDiskInfoIdentify (\r
618 IN EFI_DISK_INFO_PROTOCOL *This,\r
619 IN OUT VOID *IdentifyData,\r
620 IN OUT UINT32 *IdentifyDataSize\r
621 );\r
622\r
623\r
624/**\r
625 Provides sense data information for the controller type.\r
626 \r
627 This function is used by the IDE bus driver to get sense data. \r
628 Data format of Sense data is defined by the Interface GUID.\r
629\r
4140a663 630 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.\r
631 @param[in, out] SenseData Pointer to the SenseData.\r
632 @param[in, out] SenseDataSize Size of SenseData in bytes.\r
633 @param[out] SenseDataNumber Pointer to the value for the sense data size.\r
d716651f 634\r
635 @retval EFI_SUCCESS The command was accepted without any errors.\r
636 @retval EFI_NOT_FOUND Device does not support this data class.\r
637 @retval EFI_DEVICE_ERROR Error reading SenseData from device.\r
638 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough.\r
639\r
640**/\r
641EFI_STATUS\r
642EFIAPI\r
643ScsiDiskInfoSenseData (\r
644 IN EFI_DISK_INFO_PROTOCOL *This,\r
645 IN OUT VOID *SenseData,\r
646 IN OUT UINT32 *SenseDataSize,\r
647 OUT UINT8 *SenseDataNumber\r
648 );\r
649\r
650/**\r
651 This function is used by the IDE bus driver to get controller information.\r
652\r
653 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance. \r
654 @param[out] IdeChannel Pointer to the Ide Channel number. Primary or secondary.\r
655 @param[out] IdeDevice Pointer to the Ide Device number. Master or slave.\r
656\r
657 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid.\r
658 @retval EFI_UNSUPPORTED This is not an IDE device.\r
659\r
660**/\r
661EFI_STATUS\r
662EFIAPI\r
663ScsiDiskInfoWhichIde (\r
664 IN EFI_DISK_INFO_PROTOCOL *This,\r
665 OUT UINT32 *IdeChannel,\r
666 OUT UINT32 *IdeDevice\r
667 );\r
668\r
669\r
9beb888e 670/**\r
d716651f 671 Detect Device and read out capacity ,if error occurs, parse the sense key.\r
6ad55b15 672\r
9beb888e 673 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
674 @param MustReadCapacity The flag about reading device capacity\r
675 @param MediaChange The pointer of flag indicates if media has changed \r
6ad55b15 676\r
9beb888e 677 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
678 @retval EFI_SUCCESS Successfully to detect media\r
6ad55b15 679\r
9beb888e 680**/\r
6ad55b15 681EFI_STATUS\r
682ScsiDiskDetectMedia (\r
9beb888e 683 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
684 IN BOOLEAN MustReadCapacity,\r
685 OUT BOOLEAN *MediaChange\r
686 );\r
6ad55b15 687\r
9beb888e 688/**\r
d716651f 689 To test device.\r
6ad55b15 690\r
9beb888e 691 When Test Unit Ready command succeeds, retrieve Sense Keys via Request Sense;\r
692 When Test Unit Ready command encounters any error caused by host adapter or\r
693 target, return error without retrieving Sense Keys.\r
6ad55b15 694\r
9beb888e 695 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
696 @param NeedRetry The pointer of flag indicates try again\r
697 @param SenseDataArray The pointer of an array of sense data\r
698 @param NumberOfSenseKeys The pointer of the number of sense data array\r
6ad55b15 699\r
9beb888e 700 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
701 @retval EFI_SUCCESS Successfully to test unit\r
f36d6e66 702\r
9beb888e 703**/\r
6ad55b15 704EFI_STATUS\r
705ScsiDiskTestUnitReady (\r
9beb888e 706 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
707 OUT BOOLEAN *NeedRetry,\r
708 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
709 OUT UINTN *NumberOfSenseKeys\r
710 );\r
6ad55b15 711\r
6ad55b15 712\r
9beb888e 713/**\r
714 Parsing Sense Keys which got from request sense command.\r
6ad55b15 715\r
9beb888e 716 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
717 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
718 @param NumberOfSenseKeys The number of sense key \r
719 @param Action The pointer of action which indicates what is need to do next\r
6ad55b15 720\r
9beb888e 721 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
722 @retval EFI_SUCCESS Successfully to complete the parsing\r
6ad55b15 723\r
9beb888e 724**/\r
6ad55b15 725EFI_STATUS\r
726DetectMediaParsingSenseKeys (\r
9beb888e 727 OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
728 IN EFI_SCSI_SENSE_DATA *SenseData,\r
729 IN UINTN NumberOfSenseKeys,\r
730 OUT UINTN *Action\r
731 );\r
6ad55b15 732\r
6ad55b15 733\r
9beb888e 734/**\r
735 Send read capacity command to device and get the device parameter.\r
6ad55b15 736\r
9beb888e 737 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
738 @param NeedRetry The pointer of flag indicates if need a retry\r
739 @param SenseDataArray The pointer of an array of sense data\r
740 @param NumberOfSenseKeys The number of sense key\r
6ad55b15 741\r
9beb888e 742 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
743 @retval EFI_SUCCESS Successfully to read capacity\r
6ad55b15 744\r
9beb888e 745**/\r
6ad55b15 746EFI_STATUS\r
747ScsiDiskReadCapacity (\r
9beb888e 748 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
749 OUT BOOLEAN *NeedRetry,\r
750 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
751 OUT UINTN *NumberOfSenseKeys\r
752 );\r
6ad55b15 753\r
9beb888e 754/**\r
755 Check the HostAdapter status and re-interpret it in EFI_STATUS.\r
6ad55b15 756\r
9beb888e 757 @param HostAdapterStatus Host Adapter status\r
6ad55b15 758\r
9beb888e 759 @retval EFI_SUCCESS Host adapter is OK.\r
760 @retval EFI_TIMEOUT Timeout.\r
761 @retval EFI_NOT_READY Adapter NOT ready.\r
762 @retval EFI_DEVICE_ERROR Adapter device error.\r
6ad55b15 763\r
9beb888e 764**/\r
6ad55b15 765EFI_STATUS\r
766CheckHostAdapterStatus (\r
9beb888e 767 IN UINT8 HostAdapterStatus\r
768 );\r
6ad55b15 769\r
6ad55b15 770\r
9beb888e 771/**\r
772 Check the target status and re-interpret it in EFI_STATUS.\r
6ad55b15 773\r
9beb888e 774 @param TargetStatus Target status\r
6ad55b15 775\r
9beb888e 776 @retval EFI_NOT_READY Device is NOT ready.\r
777 @retval EFI_DEVICE_ERROR \r
778 @retval EFI_SUCCESS\r
6ad55b15 779\r
9beb888e 780**/\r
6ad55b15 781EFI_STATUS\r
782CheckTargetStatus (\r
9beb888e 783 IN UINT8 TargetStatus\r
784 );\r
6ad55b15 785\r
9beb888e 786/**\r
787 Retrieve all sense keys from the device.\r
6ad55b15 788\r
9beb888e 789 When encountering error during the process, if retrieve sense keys before\r
d716651f 790 error encountered, it returns the sense keys with return status set to EFI_SUCCESS,\r
9beb888e 791 and NeedRetry set to FALSE; otherwize, return the proper return status.\r
6ad55b15 792\r
9beb888e 793 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
794 @param NeedRetry The pointer of flag indicates if need a retry\r
795 @param SenseDataArray The pointer of an array of sense data\r
796 @param NumberOfSenseKeys The number of sense key\r
797 @param AskResetIfError The flag indicates if need reset when error occurs\r
6ad55b15 798\r
9beb888e 799 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
800 @retval EFI_SUCCESS Successfully to request sense key\r
6ad55b15 801\r
9beb888e 802**/\r
6ad55b15 803EFI_STATUS\r
804ScsiDiskRequestSenseKeys (\r
9beb888e 805 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
806 OUT BOOLEAN *NeedRetry,\r
807 OUT EFI_SCSI_SENSE_DATA **SenseDataArray,\r
808 OUT UINTN *NumberOfSenseKeys,\r
809 IN BOOLEAN AskResetIfError\r
810 );\r
6ad55b15 811\r
9beb888e 812/**\r
813 Send out Inquiry command to Device.\r
6ad55b15 814\r
9beb888e 815 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
816 @param NeedRetry Indicates if needs try again when error happens\r
6ad55b15 817\r
9beb888e 818 @retval EFI_DEVICE_ERROR Indicates that error occurs\r
819 @retval EFI_SUCCESS Successfully to detect media\r
6ad55b15 820\r
9beb888e 821**/\r
6ad55b15 822EFI_STATUS\r
823ScsiDiskInquiryDevice (\r
9beb888e 824 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
825 OUT BOOLEAN *NeedRetry\r
826 );\r
6ad55b15 827\r
9beb888e 828/**\r
829 Parse Inquiry data.\r
6ad55b15 830\r
9beb888e 831 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
6ad55b15 832\r
9beb888e 833**/\r
6ad55b15 834VOID\r
835ParseInquiryData (\r
9beb888e 836 IN OUT SCSI_DISK_DEV *ScsiDiskDevice\r
837 );\r
6ad55b15 838\r
9beb888e 839/**\r
840 Read sector from SCSI Disk.\r
6ad55b15 841\r
d716651f 842 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
9beb888e 843 @param Buffer The buffer to fill in the read out data\r
844 @param Lba Logic block address\r
845 @param NumberOfBlocks The number of blocks to read\r
6ad55b15 846\r
9beb888e 847 @retval EFI_DEVICE_ERROR Indicates a device error.\r
848 @retval EFI_SUCCESS Operation is successful.\r
6ad55b15 849\r
9beb888e 850**/\r
6ad55b15 851EFI_STATUS\r
852ScsiDiskReadSectors (\r
9beb888e 853 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
854 OUT VOID *Buffer,\r
855 IN EFI_LBA Lba,\r
856 IN UINTN NumberOfBlocks\r
857 );\r
6ad55b15 858\r
9beb888e 859/**\r
860 Write sector to SCSI Disk.\r
6ad55b15 861\r
d716651f 862 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
9beb888e 863 @param Buffer The buffer of data to be written into SCSI Disk\r
864 @param Lba Logic block address\r
865 @param NumberOfBlocks The number of blocks to read\r
6ad55b15 866\r
9beb888e 867 @retval EFI_DEVICE_ERROR Indicates a device error.\r
868 @retval EFI_SUCCESS Operation is successful.\r
6ad55b15 869\r
9beb888e 870**/\r
6ad55b15 871EFI_STATUS\r
872ScsiDiskWriteSectors (\r
9beb888e 873 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
874 IN VOID *Buffer,\r
875 IN EFI_LBA Lba,\r
876 IN UINTN NumberOfBlocks\r
877 );\r
6ad55b15 878\r
d670bf53
HW
879/**\r
880 Asynchronously read sector from SCSI Disk.\r
881\r
882 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV.\r
883 @param Buffer The buffer to fill in the read out data.\r
884 @param Lba Logic block address.\r
885 @param NumberOfBlocks The number of blocks to read.\r
886 @param Token A pointer to the token associated with the\r
887 non-blocking read request.\r
888\r
889 @retval EFI_INVALID_PARAMETER Token is NULL or Token->Event is NULL.\r
890 @retval EFI_DEVICE_ERROR Indicates a device error.\r
891 @retval EFI_SUCCESS Operation is successful.\r
892\r
893**/\r
894EFI_STATUS\r
895ScsiDiskAsyncReadSectors (\r
896 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
897 OUT VOID *Buffer,\r
898 IN EFI_LBA Lba,\r
899 IN UINTN NumberOfBlocks,\r
900 IN EFI_BLOCK_IO2_TOKEN *Token\r
901 );\r
902\r
903/**\r
904 Asynchronously write sector to SCSI Disk.\r
905\r
906 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV.\r
907 @param Buffer The buffer of data to be written into SCSI Disk.\r
908 @param Lba Logic block address.\r
909 @param NumberOfBlocks The number of blocks to read.\r
910 @param Token A pointer to the token associated with the\r
911 non-blocking read request.\r
912\r
913 @retval EFI_INVALID_PARAMETER Token is NULL or Token->Event is NULL\r
914 @retval EFI_DEVICE_ERROR Indicates a device error.\r
915 @retval EFI_SUCCESS Operation is successful.\r
916\r
917**/\r
918EFI_STATUS\r
919ScsiDiskAsyncWriteSectors (\r
920 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
921 IN VOID *Buffer,\r
922 IN EFI_LBA Lba,\r
923 IN UINTN NumberOfBlocks,\r
924 IN EFI_BLOCK_IO2_TOKEN *Token\r
925 );\r
926\r
9beb888e 927/**\r
73a9e822 928 Submit Read(10) command.\r
9beb888e 929\r
930 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
931 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
9beb888e 932 @param Timeout The time to complete the command\r
933 @param DataBuffer The buffer to fill with the read out data\r
934 @param DataLength The length of buffer\r
935 @param StartLba The start logic block address\r
73a9e822 936 @param SectorCount The number of blocks to read\r
9beb888e 937\r
938 @return EFI_STATUS is returned by calling ScsiRead10Command().\r
939**/\r
6ad55b15 940EFI_STATUS\r
941ScsiDiskRead10 (\r
9beb888e 942 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
943 OUT BOOLEAN *NeedRetry,\r
9beb888e 944 IN UINT64 Timeout,\r
945 OUT UINT8 *DataBuffer,\r
946 IN OUT UINT32 *DataLength,\r
947 IN UINT32 StartLba,\r
73a9e822 948 IN UINT32 SectorCount\r
9beb888e 949 );\r
6ad55b15 950\r
9beb888e 951/**\r
73a9e822 952 Submit Write(10) Command.\r
6ad55b15 953\r
9beb888e 954 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
955 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
9beb888e 956 @param Timeout The time to complete the command\r
957 @param DataBuffer The buffer to fill with the read out data\r
958 @param DataLength The length of buffer\r
959 @param StartLba The start logic block address\r
73a9e822 960 @param SectorCount The number of blocks to write\r
6ad55b15 961\r
9beb888e 962 @return EFI_STATUS is returned by calling ScsiWrite10Command().\r
6ad55b15 963\r
9beb888e 964**/\r
6ad55b15 965EFI_STATUS\r
966ScsiDiskWrite10 (\r
9beb888e 967 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
968 OUT BOOLEAN *NeedRetry,\r
9beb888e 969 IN UINT64 Timeout,\r
970 IN UINT8 *DataBuffer,\r
971 IN OUT UINT32 *DataLength,\r
972 IN UINT32 StartLba,\r
73a9e822 973 IN UINT32 SectorCount\r
9beb888e 974 );\r
6ad55b15 975\r
a108933e 976/**\r
977 Submit Read(16) command.\r
978\r
979 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
980 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
a108933e 981 @param Timeout The time to complete the command\r
982 @param DataBuffer The buffer to fill with the read out data\r
983 @param DataLength The length of buffer\r
984 @param StartLba The start logic block address\r
73a9e822 985 @param SectorCount The number of blocks to read\r
a108933e 986\r
73a9e822 987 @return EFI_STATUS is returned by calling ScsiRead16Command().\r
a108933e 988**/\r
989EFI_STATUS\r
990ScsiDiskRead16 (\r
991 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
992 OUT BOOLEAN *NeedRetry,\r
a108933e 993 IN UINT64 Timeout,\r
994 OUT UINT8 *DataBuffer,\r
995 IN OUT UINT32 *DataLength,\r
996 IN UINT64 StartLba,\r
73a9e822 997 IN UINT32 SectorCount\r
a108933e 998 );\r
999 \r
1000/**\r
1001 Submit Write(16) Command.\r
1002\r
1003 @param ScsiDiskDevice The pointer of ScsiDiskDevice\r
1004 @param NeedRetry The pointer of flag indicates if needs retry if error happens\r
a108933e 1005 @param Timeout The time to complete the command\r
1006 @param DataBuffer The buffer to fill with the read out data\r
1007 @param DataLength The length of buffer\r
1008 @param StartLba The start logic block address\r
73a9e822 1009 @param SectorCount The number of blocks to write\r
a108933e 1010\r
73a9e822 1011 @return EFI_STATUS is returned by calling ScsiWrite16Command().\r
a108933e 1012\r
1013**/\r
1014EFI_STATUS\r
1015ScsiDiskWrite16 (\r
1016 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1017 OUT BOOLEAN *NeedRetry,\r
a108933e 1018 IN UINT64 Timeout,\r
1019 IN UINT8 *DataBuffer,\r
1020 IN OUT UINT32 *DataLength,\r
1021 IN UINT64 StartLba,\r
73a9e822 1022 IN UINT32 SectorCount\r
a108933e 1023 ); \r
1024\r
d670bf53
HW
1025/**\r
1026 Submit Async Read(10) command.\r
1027\r
1028 @param ScsiDiskDevice The pointer of ScsiDiskDevice.\r
1029 @param Timeout The time to complete the command.\r
1030 @param DataBuffer The buffer to fill with the read out data.\r
1031 @param DataLength The length of buffer.\r
1032 @param StartLba The start logic block address.\r
1033 @param SectorCount The number of blocks to read.\r
1034 @param BlkIo2Req The upstream BlockIo2 request.\r
1035 @param Token The pointer to the token associated with the\r
1036 non-blocking read request.\r
1037\r
1038 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a\r
1039 lack of resources.\r
1040 @return others Status returned by calling\r
1041 ScsiRead10CommandEx().\r
1042\r
1043**/\r
1044EFI_STATUS\r
1045ScsiDiskAsyncRead10 (\r
1046 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1047 IN UINT64 Timeout,\r
1048 OUT UINT8 *DataBuffer,\r
1049 IN UINT32 DataLength,\r
1050 IN UINT32 StartLba,\r
1051 IN UINT32 SectorCount,\r
1052 IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req,\r
1053 IN EFI_BLOCK_IO2_TOKEN *Token\r
1054 );\r
1055\r
1056/**\r
1057 Submit Async Write(10) command.\r
1058\r
1059 @param ScsiDiskDevice The pointer of ScsiDiskDevice.\r
1060 @param Timeout The time to complete the command.\r
1061 @param DataBuffer The buffer contains the data to write.\r
1062 @param DataLength The length of buffer.\r
1063 @param StartLba The start logic block address.\r
1064 @param SectorCount The number of blocks to write.\r
1065 @param BlkIo2Req The upstream BlockIo2 request.\r
1066 @param Token The pointer to the token associated with the\r
1067 non-blocking read request.\r
1068\r
1069 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a\r
1070 lack of resources.\r
1071 @return others Status returned by calling\r
1072 ScsiWrite10CommandEx().\r
1073\r
1074**/\r
1075EFI_STATUS\r
1076ScsiDiskAsyncWrite10 (\r
1077 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1078 IN UINT64 Timeout,\r
1079 IN UINT8 *DataBuffer,\r
1080 IN UINT32 DataLength,\r
1081 IN UINT32 StartLba,\r
1082 IN UINT32 SectorCount,\r
1083 IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req,\r
1084 IN EFI_BLOCK_IO2_TOKEN *Token\r
1085 );\r
1086\r
1087/**\r
1088 Submit Async Read(16) command.\r
1089\r
1090 @param ScsiDiskDevice The pointer of ScsiDiskDevice.\r
1091 @param Timeout The time to complete the command.\r
1092 @param DataBuffer The buffer to fill with the read out data.\r
1093 @param DataLength The length of buffer.\r
1094 @param StartLba The start logic block address.\r
1095 @param SectorCount The number of blocks to read.\r
1096 @param BlkIo2Req The upstream BlockIo2 request.\r
1097 @param Token The pointer to the token associated with the\r
1098 non-blocking read request.\r
1099\r
1100 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a\r
1101 lack of resources.\r
1102 @return others Status returned by calling\r
1103 ScsiRead16CommandEx().\r
1104\r
1105**/\r
1106EFI_STATUS\r
1107ScsiDiskAsyncRead16 (\r
1108 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1109 IN UINT64 Timeout,\r
1110 OUT UINT8 *DataBuffer,\r
1111 IN UINT32 DataLength,\r
1112 IN UINT64 StartLba,\r
1113 IN UINT32 SectorCount,\r
1114 IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req,\r
1115 IN EFI_BLOCK_IO2_TOKEN *Token\r
1116 );\r
1117\r
1118/**\r
1119 Submit Async Write(16) command.\r
1120\r
1121 @param ScsiDiskDevice The pointer of ScsiDiskDevice.\r
1122 @param Timeout The time to complete the command.\r
1123 @param DataBuffer The buffer contains the data to write.\r
1124 @param DataLength The length of buffer.\r
1125 @param StartLba The start logic block address.\r
1126 @param SectorCount The number of blocks to write.\r
1127 @param BlkIo2Req The upstream BlockIo2 request.\r
1128 @param Token The pointer to the token associated with the\r
1129 non-blocking read request.\r
1130\r
1131 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a\r
1132 lack of resources.\r
1133 @return others Status returned by calling\r
1134 ScsiWrite16CommandEx().\r
1135\r
1136**/\r
1137EFI_STATUS\r
1138ScsiDiskAsyncWrite16 (\r
1139 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1140 IN UINT64 Timeout,\r
1141 IN UINT8 *DataBuffer,\r
1142 IN UINT32 DataLength,\r
1143 IN UINT64 StartLba,\r
1144 IN UINT32 SectorCount,\r
1145 IN OUT SCSI_BLKIO2_REQUEST *BlkIo2Req,\r
1146 IN EFI_BLOCK_IO2_TOKEN *Token\r
1147 );\r
1148\r
9beb888e 1149/**\r
1150 Get information from media read capacity command.\r
6ad55b15 1151\r
9beb888e 1152 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
b96cd313 1153 @param Capacity10 The pointer of EFI_SCSI_DISK_CAPACITY_DATA\r
1154 @param Capacity16 The pointer of EFI_SCSI_DISK_CAPACITY_DATA16\r
9beb888e 1155**/\r
6ad55b15 1156VOID\r
1157GetMediaInfo (\r
aa75dfec 1158 IN OUT SCSI_DISK_DEV *ScsiDiskDevice,\r
1159 IN EFI_SCSI_DISK_CAPACITY_DATA *Capacity10,\r
1160 IN EFI_SCSI_DISK_CAPACITY_DATA16 *Capacity16\r
9beb888e 1161 );\r
6ad55b15 1162\r
9beb888e 1163/**\r
1164 Check sense key to find if media presents.\r
6ad55b15 1165\r
9beb888e 1166 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
1167 @param SenseCounts The number of sense key\r
6ad55b15 1168\r
9beb888e 1169 @retval TRUE NOT any media\r
1170 @retval FALSE Media presents\r
1171**/\r
6ad55b15 1172BOOLEAN\r
1173ScsiDiskIsNoMedia (\r
1174 IN EFI_SCSI_SENSE_DATA *SenseData,\r
1175 IN UINTN SenseCounts\r
9beb888e 1176 );\r
6ad55b15 1177\r
9beb888e 1178/**\r
1179 Parse sense key.\r
6ad55b15 1180\r
9beb888e 1181 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
1182 @param SenseCounts The number of sense key\r
6ad55b15 1183\r
9beb888e 1184 @retval TRUE Error\r
1185 @retval FALSE NOT error\r
6ad55b15 1186\r
9beb888e 1187**/\r
6ad55b15 1188BOOLEAN\r
1189ScsiDiskIsMediaError (\r
1190 IN EFI_SCSI_SENSE_DATA *SenseData,\r
1191 IN UINTN SenseCounts\r
9beb888e 1192 );\r
6ad55b15 1193\r
9beb888e 1194/**\r
1195 Check sense key to find if hardware error happens.\r
6ad55b15 1196\r
9beb888e 1197 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
1198 @param SenseCounts The number of sense key\r
6ad55b15 1199\r
9beb888e 1200 @retval TRUE Hardware error exits.\r
1201 @retval FALSE NO error.\r
6ad55b15 1202\r
9beb888e 1203**/\r
6ad55b15 1204BOOLEAN\r
1205ScsiDiskIsHardwareError (\r
1206 IN EFI_SCSI_SENSE_DATA *SenseData,\r
1207 IN UINTN SenseCounts\r
9beb888e 1208 );\r
6ad55b15 1209\r
9beb888e 1210/**\r
1211 Check sense key to find if media has changed.\r
6ad55b15 1212\r
9beb888e 1213 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
1214 @param SenseCounts The number of sense key\r
6ad55b15 1215\r
9beb888e 1216 @retval TRUE Media is changed.\r
1217 @retval FALSE Medit is NOT changed.\r
1218**/\r
6ad55b15 1219BOOLEAN\r
1220ScsiDiskIsMediaChange (\r
1221 IN EFI_SCSI_SENSE_DATA *SenseData,\r
1222 IN UINTN SenseCounts\r
9beb888e 1223 );\r
6ad55b15 1224\r
9beb888e 1225/**\r
1226 Check sense key to find if reset happens.\r
6ad55b15 1227\r
9beb888e 1228 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
1229 @param SenseCounts The number of sense key\r
6ad55b15 1230\r
9beb888e 1231 @retval TRUE It is reset before.\r
1232 @retval FALSE It is NOT reset before.\r
6ad55b15 1233\r
9beb888e 1234**/\r
6ad55b15 1235BOOLEAN\r
1236ScsiDiskIsResetBefore (\r
1237 IN EFI_SCSI_SENSE_DATA *SenseData,\r
1238 IN UINTN SenseCounts\r
9beb888e 1239 );\r
6ad55b15 1240\r
9beb888e 1241/**\r
1242 Check sense key to find if the drive is ready.\r
6ad55b15 1243\r
9beb888e 1244 @param SenseData The pointer of EFI_SCSI_SENSE_DATA\r
1245 @param SenseCounts The number of sense key\r
1246 @param RetryLater The flag means if need a retry \r
6ad55b15 1247\r
9beb888e 1248 @retval TRUE Drive is ready.\r
1249 @retval FALSE Drive is NOT ready.\r
6ad55b15 1250\r
9beb888e 1251**/\r
6ad55b15 1252BOOLEAN\r
1253ScsiDiskIsDriveReady (\r
1254 IN EFI_SCSI_SENSE_DATA *SenseData,\r
1255 IN UINTN SenseCounts,\r
9beb888e 1256 OUT BOOLEAN *RetryLater\r
1257 );\r
6ad55b15 1258\r
9beb888e 1259/**\r
1260 Check sense key to find if it has sense key.\r
6ad55b15 1261\r
9beb888e 1262 @param SenseData - The pointer of EFI_SCSI_SENSE_DATA\r
1263 @param SenseCounts - The number of sense key\r
6ad55b15 1264\r
9beb888e 1265 @retval TRUE It has sense key.\r
1266 @retval FALSE It has NOT any sense key.\r
6ad55b15 1267\r
9beb888e 1268**/\r
6ad55b15 1269BOOLEAN\r
1270ScsiDiskHaveSenseKey (\r
1271 IN EFI_SCSI_SENSE_DATA *SenseData,\r
1272 IN UINTN SenseCounts\r
9beb888e 1273 );\r
6ad55b15 1274\r
9beb888e 1275/**\r
1276 Release resource about disk device.\r
6ad55b15 1277\r
9beb888e 1278 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV\r
6ad55b15 1279\r
9beb888e 1280**/\r
6ad55b15 1281VOID\r
1282ReleaseScsiDiskDeviceResources (\r
1283 IN SCSI_DISK_DEV *ScsiDiskDevice\r
9beb888e 1284 );\r
6ad55b15 1285\r
d14faa52 1286/**\r
1287 Determine if Block Io should be produced.\r
1288 \r
1289\r
d716651f 1290 @param ChildHandle Child Handle to retrieve Parent information.\r
d14faa52 1291 \r
1292 @retval TRUE Should produce Block Io.\r
1293 @retval FALSE Should not produce Block Io.\r
1294\r
1295**/ \r
1296BOOLEAN\r
1297DetermineInstallBlockIo (\r
1298 IN EFI_HANDLE ChildHandle\r
1299 );\r
1300\r
d716651f 1301/**\r
1302 Initialize the installation of DiskInfo protocol.\r
1303\r
1304 This function prepares for the installation of DiskInfo protocol on the child handle.\r
1305 By default, it installs DiskInfo protocol with SCSI interface GUID. If it further\r
1306 detects that the physical device is an ATAPI/AHCI device, it then updates interface GUID\r
1307 to be IDE/AHCI interface GUID.\r
1308\r
1309 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV.\r
1310 @param ChildHandle Child handle to install DiskInfo protocol.\r
1311 \r
1312**/ \r
1313VOID\r
1314InitializeInstallDiskInfo (\r
1315 IN SCSI_DISK_DEV *ScsiDiskDevice,\r
1316 IN EFI_HANDLE ChildHandle\r
1317 ); \r
1318\r
d14faa52 1319/**\r
1320 Search protocol database and check to see if the protocol\r
1321 specified by ProtocolGuid is present on a ControllerHandle and opened by\r
1322 ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
1323 If the ControllerHandle is found, then the protocol specified by ProtocolGuid\r
1324 will be opened on it. \r
1325 \r
1326\r
1327 @param ProtocolGuid ProtocolGuid pointer.\r
1328 @param ChildHandle Child Handle to retrieve Parent information.\r
1329 \r
1330**/ \r
1331VOID *\r
1332EFIAPI\r
1333GetParentProtocol (\r
1334 IN EFI_GUID *ProtocolGuid,\r
1335 IN EFI_HANDLE ChildHandle\r
1336 );\r
1337\r
6ad55b15 1338#endif\r