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