2 Header file for SCSI Disk Driver.
4 Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
22 #include <Protocol/ScsiIo.h>
23 #include <Protocol/ComponentName.h>
24 #include <Protocol/BlockIo.h>
25 #include <Protocol/DriverBinding.h>
26 #include <Protocol/ScsiPassThruExt.h>
27 #include <Protocol/ScsiPassThru.h>
28 #include <Protocol/DiskInfo.h>
31 #include <Library/DebugLib.h>
32 #include <Library/UefiDriverEntryPoint.h>
33 #include <Library/UefiLib.h>
34 #include <Library/BaseMemoryLib.h>
35 #include <Library/MemoryAllocationLib.h>
36 #include <Library/UefiScsiLib.h>
37 #include <Library/UefiBootServicesTableLib.h>
38 #include <Library/DevicePathLib.h>
40 #include <IndustryStandard/Scsi.h>
41 #include <IndustryStandard/Atapi.h>
43 #define IS_DEVICE_FIXED(a) (a)->FixedDevice ? 1 : 0
45 #define SCSI_DISK_DEV_SIGNATURE SIGNATURE_32 ('s', 'c', 'd', 'k')
52 EFI_BLOCK_IO_PROTOCOL BlkIo
;
53 EFI_BLOCK_IO_MEDIA BlkIoMedia
;
54 EFI_SCSI_IO_PROTOCOL
*ScsiIo
;
59 EFI_SCSI_SENSE_DATA
*SenseData
;
60 UINTN SenseDataNumber
;
61 EFI_SCSI_INQUIRY_DATA InquiryData
;
63 EFI_UNICODE_STRING_TABLE
*ControllerNameTable
;
65 EFI_DISK_INFO_PROTOCOL DiskInfo
;
68 // The following fields are only valid for ATAPI/SATA device
72 ATAPI_IDENTIFY_DATA IdentifyData
;
75 // The flag indicates if 16-byte command can be used
80 #define SCSI_DISK_DEV_FROM_THIS(a) CR (a, SCSI_DISK_DEV, BlkIo, SCSI_DISK_DEV_SIGNATURE)
82 #define SCSI_DISK_DEV_FROM_DISKINFO(a) CR (a, SCSI_DISK_DEV, DiskInfo, SCSI_DISK_DEV_SIGNATURE)
87 extern EFI_DRIVER_BINDING_PROTOCOL gScsiDiskDriverBinding
;
88 extern EFI_COMPONENT_NAME_PROTOCOL gScsiDiskComponentName
;
89 extern EFI_COMPONENT_NAME2_PROTOCOL gScsiDiskComponentName2
;
91 // action code used in detect media process
93 #define ACTION_NO_ACTION 0x00
94 #define ACTION_READ_CAPACITY 0x01
95 #define ACTION_RETRY_COMMAND_LATER 0x02
96 #define ACTION_RETRY_WITH_BACKOFF_ALGO 0x03
98 #define SCSI_COMMAND_VERSION_1 0x01
99 #define SCSI_COMMAND_VERSION_2 0x02
100 #define SCSI_COMMAND_VERSION_3 0x03
103 // SCSI Disk Timeout Experience Value
105 #define SCSI_DISK_TIMEOUT EFI_TIMER_PERIOD_SECONDS (3)
108 Test to see if this driver supports ControllerHandle.
110 This service is called by the EFI boot service ConnectController(). In order
111 to make drivers as small as possible, there are a few calling restrictions for
112 this service. ConnectController() must follow these calling restrictions.
113 If any other agent wishes to call Supported() it must also follow these
114 calling restrictions.
116 @param This Protocol instance pointer.
117 @param ControllerHandle Handle of device to test
118 @param RemainingDevicePath Optional parameter use to pick a specific child
121 @retval EFI_SUCCESS This driver supports this device
122 @retval EFI_ALREADY_STARTED This driver is already running on this device
123 @retval other This driver does not support this device
128 ScsiDiskDriverBindingSupported (
129 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
130 IN EFI_HANDLE Controller
,
131 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
135 Start this driver on ControllerHandle.
137 This service is called by the EFI boot service ConnectController(). In order
138 to make drivers as small as possible, there are a few calling restrictions for
139 this service. ConnectController() must follow these calling restrictions. If
140 any other agent wishes to call Start() it must also follow these calling
143 @param This Protocol instance pointer.
144 @param ControllerHandle Handle of device to bind driver to
145 @param RemainingDevicePath Optional parameter use to pick a specific child
148 @retval EFI_SUCCESS This driver is added to ControllerHandle
149 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
150 @retval other This driver does not support this device
155 ScsiDiskDriverBindingStart (
156 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
157 IN EFI_HANDLE Controller
,
158 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
162 Stop this driver on ControllerHandle.
164 This service is called by the EFI boot service DisconnectController().
165 In order to make drivers as small as possible, there are a few calling
166 restrictions for this service. DisconnectController() must follow these
167 calling restrictions. If any other agent wishes to call Stop() it must
168 also follow these calling restrictions.
170 @param This Protocol instance pointer.
171 @param ControllerHandle Handle of device to stop driver on
172 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
173 children is zero stop the entire bus driver.
174 @param ChildHandleBuffer List of Child Handles to Stop.
176 @retval EFI_SUCCESS This driver is removed ControllerHandle
177 @retval other This driver was not removed from this device
182 ScsiDiskDriverBindingStop (
183 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
184 IN EFI_HANDLE Controller
,
185 IN UINTN NumberOfChildren
,
186 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
190 // EFI Component Name Functions
193 Retrieves a Unicode string that is the user readable name of the driver.
195 This function retrieves the user readable name of a driver in the form of a
196 Unicode string. If the driver specified by This has a user readable name in
197 the language specified by Language, then a pointer to the driver name is
198 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
199 by This does not support the language specified by Language,
200 then EFI_UNSUPPORTED is returned.
202 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
203 EFI_COMPONENT_NAME_PROTOCOL instance.
205 @param Language A pointer to a Null-terminated ASCII string
206 array indicating the language. This is the
207 language of the driver name that the caller is
208 requesting, and it must match one of the
209 languages specified in SupportedLanguages. The
210 number of languages supported by a driver is up
211 to the driver writer. Language is specified
212 in RFC 4646 or ISO 639-2 language code format.
214 @param DriverName A pointer to the Unicode string to return.
215 This Unicode string is the name of the
216 driver specified by This in the language
217 specified by Language.
219 @retval EFI_SUCCESS The Unicode string for the Driver specified by
220 This and the language specified by Language was
221 returned in DriverName.
223 @retval EFI_INVALID_PARAMETER Language is NULL.
225 @retval EFI_INVALID_PARAMETER DriverName is NULL.
227 @retval EFI_UNSUPPORTED The driver specified by This does not support
228 the language specified by Language.
233 ScsiDiskComponentNameGetDriverName (
234 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
236 OUT CHAR16
**DriverName
241 Retrieves a Unicode string that is the user readable name of the controller
242 that is being managed by a driver.
244 This function retrieves the user readable name of the controller specified by
245 ControllerHandle and ChildHandle in the form of a Unicode string. If the
246 driver specified by This has a user readable name in the language specified by
247 Language, then a pointer to the controller name is returned in ControllerName,
248 and EFI_SUCCESS is returned. If the driver specified by This is not currently
249 managing the controller specified by ControllerHandle and ChildHandle,
250 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
251 support the language specified by Language, then EFI_UNSUPPORTED is returned.
253 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
254 EFI_COMPONENT_NAME_PROTOCOL instance.
256 @param ControllerHandle The handle of a controller that the driver
257 specified by This is managing. This handle
258 specifies the controller whose name is to be
261 @param ChildHandle The handle of the child controller to retrieve
262 the name of. This is an optional parameter that
263 may be NULL. It will be NULL for device
264 drivers. It will also be NULL for a bus drivers
265 that wish to retrieve the name of the bus
266 controller. It will not be NULL for a bus
267 driver that wishes to retrieve the name of a
270 @param Language A pointer to a Null-terminated ASCII string
271 array indicating the language. This is the
272 language of the driver name that the caller is
273 requesting, and it must match one of the
274 languages specified in SupportedLanguages. The
275 number of languages supported by a driver is up
276 to the driver writer. Language is specified in
277 RFC 4646 or ISO 639-2 language code format.
279 @param ControllerName A pointer to the Unicode string to return.
280 This Unicode string is the name of the
281 controller specified by ControllerHandle and
282 ChildHandle in the language specified by
283 Language from the point of view of the driver
286 @retval EFI_SUCCESS The Unicode string for the user readable name in
287 the language specified by Language for the
288 driver specified by This was returned in
291 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
293 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
296 @retval EFI_INVALID_PARAMETER Language is NULL.
298 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
300 @retval EFI_UNSUPPORTED The driver specified by This is not currently
301 managing the controller specified by
302 ControllerHandle and ChildHandle.
304 @retval EFI_UNSUPPORTED The driver specified by This does not support
305 the language specified by Language.
310 ScsiDiskComponentNameGetControllerName (
311 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
312 IN EFI_HANDLE ControllerHandle
,
313 IN EFI_HANDLE ChildHandle OPTIONAL
,
315 OUT CHAR16
**ControllerName
322 @param This The pointer of EFI_BLOCK_IO_PROTOCOL
323 @param ExtendedVerification The flag about if extend verificate
325 @retval EFI_SUCCESS The device was reset.
326 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
328 @return EFI_STATUS is retured from EFI_SCSI_IO_PROTOCOL.ResetDevice().
334 IN EFI_BLOCK_IO_PROTOCOL
*This
,
335 IN BOOLEAN ExtendedVerification
340 The function is to Read Block from SCSI Disk.
342 @param This The pointer of EFI_BLOCK_IO_PROTOCOL.
343 @param MediaId The Id of Media detected
344 @param Lba The logic block address
345 @param BufferSize The size of Buffer
346 @param Buffer The buffer to fill the read out data
348 @retval EFI_SUCCESS Successfully to read out block.
349 @retval EFI_DEVICE_ERROR Fail to detect media.
350 @retval EFI_NO_MEDIA Media is not present.
351 @retval EFI_MEDIA_CHANGED Media has changed.
352 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
353 @retval EFI_INVALID_PARAMETER Invalid parameter passed in.
359 IN EFI_BLOCK_IO_PROTOCOL
*This
,
368 The function is to Write Block to SCSI Disk.
370 @param This The pointer of EFI_BLOCK_IO_PROTOCOL
371 @param MediaId The Id of Media detected
372 @param Lba The logic block address
373 @param BufferSize The size of Buffer
374 @param Buffer The buffer to fill the read out data
376 @retval EFI_SUCCESS Successfully to read out block.
377 @retval EFI_WRITE_PROTECTED The device can not be written to.
378 @retval EFI_DEVICE_ERROR Fail to detect media.
379 @retval EFI_NO_MEDIA Media is not present.
380 @retval EFI_MEDIA_CHNAGED Media has changed.
381 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
382 @retval EFI_INVALID_PARAMETER Invalid parameter passed in.
387 ScsiDiskWriteBlocks (
388 IN EFI_BLOCK_IO_PROTOCOL
*This
,
399 EFI_SUCCESS is returned directly.
401 @param This The pointer of EFI_BLOCK_IO_PROTOCOL
403 @retval EFI_SUCCESS All outstanding data was written to the device
408 ScsiDiskFlushBlocks (
409 IN EFI_BLOCK_IO_PROTOCOL
*This
414 Provides inquiry information for the controller type.
416 This function is used by the IDE bus driver to get inquiry data. Data format
417 of Identify data is defined by the Interface GUID.
419 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
420 @param[in, out] InquiryData Pointer to a buffer for the inquiry data.
421 @param[in, out] InquiryDataSize Pointer to the value for the inquiry data size.
423 @retval EFI_SUCCESS The command was accepted without any errors.
424 @retval EFI_NOT_FOUND Device does not support this data class
425 @retval EFI_DEVICE_ERROR Error reading InquiryData from device
426 @retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough
431 ScsiDiskInfoInquiry (
432 IN EFI_DISK_INFO_PROTOCOL
*This
,
433 IN OUT VOID
*InquiryData
,
434 IN OUT UINT32
*InquiryDataSize
439 Provides identify information for the controller type.
441 This function is used by the IDE bus driver to get identify data. Data format
442 of Identify data is defined by the Interface GUID.
444 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL
446 @param[in, out] IdentifyData Pointer to a buffer for the identify data.
447 @param[in, out] IdentifyDataSize Pointer to the value for the identify data
450 @retval EFI_SUCCESS The command was accepted without any errors.
451 @retval EFI_NOT_FOUND Device does not support this data class
452 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device
453 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
458 ScsiDiskInfoIdentify (
459 IN EFI_DISK_INFO_PROTOCOL
*This
,
460 IN OUT VOID
*IdentifyData
,
461 IN OUT UINT32
*IdentifyDataSize
466 Provides sense data information for the controller type.
468 This function is used by the IDE bus driver to get sense data.
469 Data format of Sense data is defined by the Interface GUID.
471 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
472 @param[in, out] SenseData Pointer to the SenseData.
473 @param[in, out] SenseDataSize Size of SenseData in bytes.
474 @param[out] SenseDataNumber Pointer to the value for the sense data size.
476 @retval EFI_SUCCESS The command was accepted without any errors.
477 @retval EFI_NOT_FOUND Device does not support this data class.
478 @retval EFI_DEVICE_ERROR Error reading SenseData from device.
479 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough.
484 ScsiDiskInfoSenseData (
485 IN EFI_DISK_INFO_PROTOCOL
*This
,
486 IN OUT VOID
*SenseData
,
487 IN OUT UINT32
*SenseDataSize
,
488 OUT UINT8
*SenseDataNumber
492 This function is used by the IDE bus driver to get controller information.
494 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
495 @param[out] IdeChannel Pointer to the Ide Channel number. Primary or secondary.
496 @param[out] IdeDevice Pointer to the Ide Device number. Master or slave.
498 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid.
499 @retval EFI_UNSUPPORTED This is not an IDE device.
504 ScsiDiskInfoWhichIde (
505 IN EFI_DISK_INFO_PROTOCOL
*This
,
506 OUT UINT32
*IdeChannel
,
507 OUT UINT32
*IdeDevice
512 Detect Device and read out capacity ,if error occurs, parse the sense key.
514 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
515 @param MustReadCapacity The flag about reading device capacity
516 @param MediaChange The pointer of flag indicates if media has changed
518 @retval EFI_DEVICE_ERROR Indicates that error occurs
519 @retval EFI_SUCCESS Successfully to detect media
523 ScsiDiskDetectMedia (
524 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
525 IN BOOLEAN MustReadCapacity
,
526 OUT BOOLEAN
*MediaChange
532 When Test Unit Ready command succeeds, retrieve Sense Keys via Request Sense;
533 When Test Unit Ready command encounters any error caused by host adapter or
534 target, return error without retrieving Sense Keys.
536 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
537 @param NeedRetry The pointer of flag indicates try again
538 @param SenseDataArray The pointer of an array of sense data
539 @param NumberOfSenseKeys The pointer of the number of sense data array
541 @retval EFI_DEVICE_ERROR Indicates that error occurs
542 @retval EFI_SUCCESS Successfully to test unit
546 ScsiDiskTestUnitReady (
547 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
548 OUT BOOLEAN
*NeedRetry
,
549 OUT EFI_SCSI_SENSE_DATA
**SenseDataArray
,
550 OUT UINTN
*NumberOfSenseKeys
555 Parsing Sense Keys which got from request sense command.
557 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
558 @param SenseData The pointer of EFI_SCSI_SENSE_DATA
559 @param NumberOfSenseKeys The number of sense key
560 @param Action The pointer of action which indicates what is need to do next
562 @retval EFI_DEVICE_ERROR Indicates that error occurs
563 @retval EFI_SUCCESS Successfully to complete the parsing
567 DetectMediaParsingSenseKeys (
568 OUT SCSI_DISK_DEV
*ScsiDiskDevice
,
569 IN EFI_SCSI_SENSE_DATA
*SenseData
,
570 IN UINTN NumberOfSenseKeys
,
576 Send read capacity command to device and get the device parameter.
578 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
579 @param NeedRetry The pointer of flag indicates if need a retry
580 @param SenseDataArray The pointer of an array of sense data
581 @param NumberOfSenseKeys The number of sense key
583 @retval EFI_DEVICE_ERROR Indicates that error occurs
584 @retval EFI_SUCCESS Successfully to read capacity
588 ScsiDiskReadCapacity (
589 IN OUT SCSI_DISK_DEV
*ScsiDiskDevice
,
590 OUT BOOLEAN
*NeedRetry
,
591 OUT EFI_SCSI_SENSE_DATA
**SenseDataArray
,
592 OUT UINTN
*NumberOfSenseKeys
596 Check the HostAdapter status and re-interpret it in EFI_STATUS.
598 @param HostAdapterStatus Host Adapter status
600 @retval EFI_SUCCESS Host adapter is OK.
601 @retval EFI_TIMEOUT Timeout.
602 @retval EFI_NOT_READY Adapter NOT ready.
603 @retval EFI_DEVICE_ERROR Adapter device error.
607 CheckHostAdapterStatus (
608 IN UINT8 HostAdapterStatus
613 Check the target status and re-interpret it in EFI_STATUS.
615 @param TargetStatus Target status
617 @retval EFI_NOT_READY Device is NOT ready.
618 @retval EFI_DEVICE_ERROR
624 IN UINT8 TargetStatus
628 Retrieve all sense keys from the device.
630 When encountering error during the process, if retrieve sense keys before
631 error encountered, it returns the sense keys with return status set to EFI_SUCCESS,
632 and NeedRetry set to FALSE; otherwize, return the proper return status.
634 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
635 @param NeedRetry The pointer of flag indicates if need a retry
636 @param SenseDataArray The pointer of an array of sense data
637 @param NumberOfSenseKeys The number of sense key
638 @param AskResetIfError The flag indicates if need reset when error occurs
640 @retval EFI_DEVICE_ERROR Indicates that error occurs
641 @retval EFI_SUCCESS Successfully to request sense key
645 ScsiDiskRequestSenseKeys (
646 IN OUT SCSI_DISK_DEV
*ScsiDiskDevice
,
647 OUT BOOLEAN
*NeedRetry
,
648 OUT EFI_SCSI_SENSE_DATA
**SenseDataArray
,
649 OUT UINTN
*NumberOfSenseKeys
,
650 IN BOOLEAN AskResetIfError
654 Send out Inquiry command to Device.
656 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
657 @param NeedRetry Indicates if needs try again when error happens
659 @retval EFI_DEVICE_ERROR Indicates that error occurs
660 @retval EFI_SUCCESS Successfully to detect media
664 ScsiDiskInquiryDevice (
665 IN OUT SCSI_DISK_DEV
*ScsiDiskDevice
,
666 OUT BOOLEAN
*NeedRetry
672 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
677 IN OUT SCSI_DISK_DEV
*ScsiDiskDevice
681 Read sector from SCSI Disk.
683 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
684 @param Buffer The buffer to fill in the read out data
685 @param Lba Logic block address
686 @param NumberOfBlocks The number of blocks to read
688 @retval EFI_DEVICE_ERROR Indicates a device error.
689 @retval EFI_SUCCESS Operation is successful.
693 ScsiDiskReadSectors (
694 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
697 IN UINTN NumberOfBlocks
701 Write sector to SCSI Disk.
703 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
704 @param Buffer The buffer of data to be written into SCSI Disk
705 @param Lba Logic block address
706 @param NumberOfBlocks The number of blocks to read
708 @retval EFI_DEVICE_ERROR Indicates a device error.
709 @retval EFI_SUCCESS Operation is successful.
713 ScsiDiskWriteSectors (
714 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
717 IN UINTN NumberOfBlocks
721 Submit Read(10) command.
723 @param ScsiDiskDevice The pointer of ScsiDiskDevice
724 @param NeedRetry The pointer of flag indicates if needs retry if error happens
725 @param Timeout The time to complete the command
726 @param DataBuffer The buffer to fill with the read out data
727 @param DataLength The length of buffer
728 @param StartLba The start logic block address
729 @param SectorCount The number of blocks to read
731 @return EFI_STATUS is returned by calling ScsiRead10Command().
735 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
736 OUT BOOLEAN
*NeedRetry
,
738 OUT UINT8
*DataBuffer
,
739 IN OUT UINT32
*DataLength
,
741 IN UINT32 SectorCount
745 Submit Write(10) Command.
747 @param ScsiDiskDevice The pointer of ScsiDiskDevice
748 @param NeedRetry The pointer of flag indicates if needs retry if error happens
749 @param Timeout The time to complete the command
750 @param DataBuffer The buffer to fill with the read out data
751 @param DataLength The length of buffer
752 @param StartLba The start logic block address
753 @param SectorCount The number of blocks to write
755 @return EFI_STATUS is returned by calling ScsiWrite10Command().
760 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
761 OUT BOOLEAN
*NeedRetry
,
763 IN UINT8
*DataBuffer
,
764 IN OUT UINT32
*DataLength
,
766 IN UINT32 SectorCount
770 Submit Read(16) command.
772 @param ScsiDiskDevice The pointer of ScsiDiskDevice
773 @param NeedRetry The pointer of flag indicates if needs retry if error happens
774 @param Timeout The time to complete the command
775 @param DataBuffer The buffer to fill with the read out data
776 @param DataLength The length of buffer
777 @param StartLba The start logic block address
778 @param SectorCount The number of blocks to read
780 @return EFI_STATUS is returned by calling ScsiRead16Command().
784 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
785 OUT BOOLEAN
*NeedRetry
,
787 OUT UINT8
*DataBuffer
,
788 IN OUT UINT32
*DataLength
,
790 IN UINT32 SectorCount
794 Submit Write(16) Command.
796 @param ScsiDiskDevice The pointer of ScsiDiskDevice
797 @param NeedRetry The pointer of flag indicates if needs retry if error happens
798 @param Timeout The time to complete the command
799 @param DataBuffer The buffer to fill with the read out data
800 @param DataLength The length of buffer
801 @param StartLba The start logic block address
802 @param SectorCount The number of blocks to write
804 @return EFI_STATUS is returned by calling ScsiWrite16Command().
809 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
810 OUT BOOLEAN
*NeedRetry
,
812 IN UINT8
*DataBuffer
,
813 IN OUT UINT32
*DataLength
,
815 IN UINT32 SectorCount
819 Get information from media read capacity command.
821 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
822 @param Capacity10 The pointer of EFI_SCSI_DISK_CAPACITY_DATA
823 @param Capacity16 The pointer of EFI_SCSI_DISK_CAPACITY_DATA16
827 IN OUT SCSI_DISK_DEV
*ScsiDiskDevice
,
828 IN EFI_SCSI_DISK_CAPACITY_DATA
*Capacity10
,
829 IN EFI_SCSI_DISK_CAPACITY_DATA16
*Capacity16
833 Check sense key to find if media presents.
835 @param SenseData The pointer of EFI_SCSI_SENSE_DATA
836 @param SenseCounts The number of sense key
838 @retval TRUE NOT any media
839 @retval FALSE Media presents
843 IN EFI_SCSI_SENSE_DATA
*SenseData
,
850 @param SenseData The pointer of EFI_SCSI_SENSE_DATA
851 @param SenseCounts The number of sense key
854 @retval FALSE NOT error
858 ScsiDiskIsMediaError (
859 IN EFI_SCSI_SENSE_DATA
*SenseData
,
864 Check sense key to find if hardware error happens.
866 @param SenseData The pointer of EFI_SCSI_SENSE_DATA
867 @param SenseCounts The number of sense key
869 @retval TRUE Hardware error exits.
870 @retval FALSE NO error.
874 ScsiDiskIsHardwareError (
875 IN EFI_SCSI_SENSE_DATA
*SenseData
,
880 Check sense key to find if media has changed.
882 @param SenseData The pointer of EFI_SCSI_SENSE_DATA
883 @param SenseCounts The number of sense key
885 @retval TRUE Media is changed.
886 @retval FALSE Medit is NOT changed.
889 ScsiDiskIsMediaChange (
890 IN EFI_SCSI_SENSE_DATA
*SenseData
,
895 Check sense key to find if reset happens.
897 @param SenseData The pointer of EFI_SCSI_SENSE_DATA
898 @param SenseCounts The number of sense key
900 @retval TRUE It is reset before.
901 @retval FALSE It is NOT reset before.
905 ScsiDiskIsResetBefore (
906 IN EFI_SCSI_SENSE_DATA
*SenseData
,
911 Check sense key to find if the drive is ready.
913 @param SenseData The pointer of EFI_SCSI_SENSE_DATA
914 @param SenseCounts The number of sense key
915 @param RetryLater The flag means if need a retry
917 @retval TRUE Drive is ready.
918 @retval FALSE Drive is NOT ready.
922 ScsiDiskIsDriveReady (
923 IN EFI_SCSI_SENSE_DATA
*SenseData
,
924 IN UINTN SenseCounts
,
925 OUT BOOLEAN
*RetryLater
929 Check sense key to find if it has sense key.
931 @param SenseData - The pointer of EFI_SCSI_SENSE_DATA
932 @param SenseCounts - The number of sense key
934 @retval TRUE It has sense key.
935 @retval FALSE It has NOT any sense key.
939 ScsiDiskHaveSenseKey (
940 IN EFI_SCSI_SENSE_DATA
*SenseData
,
945 Release resource about disk device.
947 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
951 ReleaseScsiDiskDeviceResources (
952 IN SCSI_DISK_DEV
*ScsiDiskDevice
956 Determine if Block Io should be produced.
959 @param ChildHandle Child Handle to retrieve Parent information.
961 @retval TRUE Should produce Block Io.
962 @retval FALSE Should not produce Block Io.
966 DetermineInstallBlockIo (
967 IN EFI_HANDLE ChildHandle
971 Initialize the installation of DiskInfo protocol.
973 This function prepares for the installation of DiskInfo protocol on the child handle.
974 By default, it installs DiskInfo protocol with SCSI interface GUID. If it further
975 detects that the physical device is an ATAPI/AHCI device, it then updates interface GUID
976 to be IDE/AHCI interface GUID.
978 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV.
979 @param ChildHandle Child handle to install DiskInfo protocol.
983 InitializeInstallDiskInfo (
984 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
985 IN EFI_HANDLE ChildHandle
989 Search protocol database and check to see if the protocol
990 specified by ProtocolGuid is present on a ControllerHandle and opened by
991 ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
992 If the ControllerHandle is found, then the protocol specified by ProtocolGuid
993 will be opened on it.
996 @param ProtocolGuid ProtocolGuid pointer.
997 @param ChildHandle Child Handle to retrieve Parent information.
1003 IN EFI_GUID
*ProtocolGuid
,
1004 IN EFI_HANDLE ChildHandle