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