2 Header file for SCSI Disk Driver.
4 Copyright (c) 2004 - 2010, 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
97 #define SCSI_COMMAND_VERSION_1 0x01
98 #define SCSI_COMMAND_VERSION_2 0x02
99 #define SCSI_COMMAND_VERSION_3 0x03
103 Test to see if this driver supports ControllerHandle.
105 This service is called by the EFI boot service ConnectController(). In order
106 to make drivers as small as possible, there are a few calling restrictions for
107 this service. ConnectController() must follow these calling restrictions.
108 If any other agent wishes to call Supported() it must also follow these
109 calling restrictions.
111 @param This Protocol instance pointer.
112 @param ControllerHandle Handle of device to test
113 @param RemainingDevicePath Optional parameter use to pick a specific child
116 @retval EFI_SUCCESS This driver supports this device
117 @retval EFI_ALREADY_STARTED This driver is already running on this device
118 @retval other This driver does not support this device
123 ScsiDiskDriverBindingSupported (
124 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
125 IN EFI_HANDLE Controller
,
126 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
130 Start this driver on ControllerHandle.
132 This service is called by the EFI boot service ConnectController(). In order
133 to make drivers as small as possible, there are a few calling restrictions for
134 this service. ConnectController() must follow these calling restrictions. If
135 any other agent wishes to call Start() it must also follow these calling
138 @param This Protocol instance pointer.
139 @param ControllerHandle Handle of device to bind driver to
140 @param RemainingDevicePath Optional parameter use to pick a specific child
143 @retval EFI_SUCCESS This driver is added to ControllerHandle
144 @retval EFI_ALREADY_STARTED This driver is already running on ControllerHandle
145 @retval other This driver does not support this device
150 ScsiDiskDriverBindingStart (
151 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
152 IN EFI_HANDLE Controller
,
153 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
157 Stop this driver on ControllerHandle.
159 This service is called by the EFI boot service DisconnectController().
160 In order to make drivers as small as possible, there are a few calling
161 restrictions for this service. DisconnectController() must follow these
162 calling restrictions. If any other agent wishes to call Stop() it must
163 also follow these calling restrictions.
165 @param This Protocol instance pointer.
166 @param ControllerHandle Handle of device to stop driver on
167 @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
168 children is zero stop the entire bus driver.
169 @param ChildHandleBuffer List of Child Handles to Stop.
171 @retval EFI_SUCCESS This driver is removed ControllerHandle
172 @retval other This driver was not removed from this device
177 ScsiDiskDriverBindingStop (
178 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
179 IN EFI_HANDLE Controller
,
180 IN UINTN NumberOfChildren
,
181 IN EFI_HANDLE
*ChildHandleBuffer OPTIONAL
185 // EFI Component Name Functions
188 Retrieves a Unicode string that is the user readable name of the driver.
190 This function retrieves the user readable name of a driver in the form of a
191 Unicode string. If the driver specified by This has a user readable name in
192 the language specified by Language, then a pointer to the driver name is
193 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
194 by This does not support the language specified by Language,
195 then EFI_UNSUPPORTED is returned.
197 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
198 EFI_COMPONENT_NAME_PROTOCOL instance.
200 @param Language A pointer to a Null-terminated ASCII string
201 array indicating the language. This is the
202 language of the driver name that the caller is
203 requesting, and it must match one of the
204 languages specified in SupportedLanguages. The
205 number of languages supported by a driver is up
206 to the driver writer. Language is specified
207 in RFC 4646 or ISO 639-2 language code format.
209 @param DriverName A pointer to the Unicode string to return.
210 This Unicode string is the name of the
211 driver specified by This in the language
212 specified by Language.
214 @retval EFI_SUCCESS The Unicode string for the Driver specified by
215 This and the language specified by Language was
216 returned in DriverName.
218 @retval EFI_INVALID_PARAMETER Language is NULL.
220 @retval EFI_INVALID_PARAMETER DriverName is NULL.
222 @retval EFI_UNSUPPORTED The driver specified by This does not support
223 the language specified by Language.
228 ScsiDiskComponentNameGetDriverName (
229 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
231 OUT CHAR16
**DriverName
236 Retrieves a Unicode string that is the user readable name of the controller
237 that is being managed by a driver.
239 This function retrieves the user readable name of the controller specified by
240 ControllerHandle and ChildHandle in the form of a Unicode string. If the
241 driver specified by This has a user readable name in the language specified by
242 Language, then a pointer to the controller name is returned in ControllerName,
243 and EFI_SUCCESS is returned. If the driver specified by This is not currently
244 managing the controller specified by ControllerHandle and ChildHandle,
245 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
246 support the language specified by Language, then EFI_UNSUPPORTED is returned.
248 @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
249 EFI_COMPONENT_NAME_PROTOCOL instance.
251 @param ControllerHandle The handle of a controller that the driver
252 specified by This is managing. This handle
253 specifies the controller whose name is to be
256 @param ChildHandle The handle of the child controller to retrieve
257 the name of. This is an optional parameter that
258 may be NULL. It will be NULL for device
259 drivers. It will also be NULL for a bus drivers
260 that wish to retrieve the name of the bus
261 controller. It will not be NULL for a bus
262 driver that wishes to retrieve the name of a
265 @param Language A pointer to a Null-terminated ASCII string
266 array indicating the language. This is the
267 language of the driver name that the caller is
268 requesting, and it must match one of the
269 languages specified in SupportedLanguages. The
270 number of languages supported by a driver is up
271 to the driver writer. Language is specified in
272 RFC 4646 or ISO 639-2 language code format.
274 @param ControllerName A pointer to the Unicode string to return.
275 This Unicode string is the name of the
276 controller specified by ControllerHandle and
277 ChildHandle in the language specified by
278 Language from the point of view of the driver
281 @retval EFI_SUCCESS The Unicode string for the user readable name in
282 the language specified by Language for the
283 driver specified by This was returned in
286 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
288 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
291 @retval EFI_INVALID_PARAMETER Language is NULL.
293 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
295 @retval EFI_UNSUPPORTED The driver specified by This is not currently
296 managing the controller specified by
297 ControllerHandle and ChildHandle.
299 @retval EFI_UNSUPPORTED The driver specified by This does not support
300 the language specified by Language.
305 ScsiDiskComponentNameGetControllerName (
306 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
307 IN EFI_HANDLE ControllerHandle
,
308 IN EFI_HANDLE ChildHandle OPTIONAL
,
310 OUT CHAR16
**ControllerName
317 @param This The pointer of EFI_BLOCK_IO_PROTOCOL
318 @param ExtendedVerification The flag about if extend verificate
320 @retval EFI_SUCCESS The device was reset.
321 @retval EFI_DEVICE_ERROR The device is not functioning properly and could
323 @return EFI_STATUS is retured from EFI_SCSI_IO_PROTOCOL.ResetDevice().
329 IN EFI_BLOCK_IO_PROTOCOL
*This
,
330 IN BOOLEAN ExtendedVerification
335 The function is to Read Block from SCSI Disk.
337 @param This The pointer of EFI_BLOCK_IO_PROTOCOL.
338 @param MediaId The Id of Media detected
339 @param Lba The logic block address
340 @param BufferSize The size of Buffer
341 @param Buffer The buffer to fill the read out data
343 @retval EFI_SUCCESS Successfully to read out block.
344 @retval EFI_DEVICE_ERROR Fail to detect media.
345 @retval EFI_NO_MEDIA Media is not present.
346 @retval EFI_MEDIA_CHANGED Media has changed.
347 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
348 @retval EFI_INVALID_PARAMETER Invalid parameter passed in.
354 IN EFI_BLOCK_IO_PROTOCOL
*This
,
363 The function is to Write Block to SCSI Disk.
365 @param This The pointer of EFI_BLOCK_IO_PROTOCOL
366 @param MediaId The Id of Media detected
367 @param Lba The logic block address
368 @param BufferSize The size of Buffer
369 @param Buffer The buffer to fill the read out data
371 @retval EFI_SUCCESS Successfully to read out block.
372 @retval EFI_WRITE_PROTECTED The device can not be written to.
373 @retval EFI_DEVICE_ERROR Fail to detect media.
374 @retval EFI_NO_MEDIA Media is not present.
375 @retval EFI_MEDIA_CHNAGED Media has changed.
376 @retval EFI_BAD_BUFFER_SIZE The Buffer was not a multiple of the block size of the device.
377 @retval EFI_INVALID_PARAMETER Invalid parameter passed in.
382 ScsiDiskWriteBlocks (
383 IN EFI_BLOCK_IO_PROTOCOL
*This
,
394 EFI_SUCCESS is returned directly.
396 @param This The pointer of EFI_BLOCK_IO_PROTOCOL
398 @retval EFI_SUCCESS All outstanding data was written to the device
403 ScsiDiskFlushBlocks (
404 IN EFI_BLOCK_IO_PROTOCOL
*This
409 Provides inquiry information for the controller type.
411 This function is used by the IDE bus driver to get inquiry data. Data format
412 of Identify data is defined by the Interface GUID.
414 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
415 @param[in, out] InquiryData Pointer to a buffer for the inquiry data.
416 @param[in, out] InquiryDataSize Pointer to the value for the inquiry data size.
418 @retval EFI_SUCCESS The command was accepted without any errors.
419 @retval EFI_NOT_FOUND Device does not support this data class
420 @retval EFI_DEVICE_ERROR Error reading InquiryData from device
421 @retval EFI_BUFFER_TOO_SMALL InquiryDataSize not big enough
426 ScsiDiskInfoInquiry (
427 IN EFI_DISK_INFO_PROTOCOL
*This
,
428 IN OUT VOID
*InquiryData
,
429 IN OUT UINT32
*InquiryDataSize
434 Provides identify information for the controller type.
436 This function is used by the IDE bus driver to get identify data. Data format
437 of Identify data is defined by the Interface GUID.
439 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL
441 @param[in, out] IdentifyData Pointer to a buffer for the identify data.
442 @param[in, out] IdentifyDataSize Pointer to the value for the identify data
445 @retval EFI_SUCCESS The command was accepted without any errors.
446 @retval EFI_NOT_FOUND Device does not support this data class
447 @retval EFI_DEVICE_ERROR Error reading IdentifyData from device
448 @retval EFI_BUFFER_TOO_SMALL IdentifyDataSize not big enough
453 ScsiDiskInfoIdentify (
454 IN EFI_DISK_INFO_PROTOCOL
*This
,
455 IN OUT VOID
*IdentifyData
,
456 IN OUT UINT32
*IdentifyDataSize
461 Provides sense data information for the controller type.
463 This function is used by the IDE bus driver to get sense data.
464 Data format of Sense data is defined by the Interface GUID.
466 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
467 @param[in, out] SenseData Pointer to the SenseData.
468 @param[in, out] SenseDataSize Size of SenseData in bytes.
469 @param[out] SenseDataNumber Pointer to the value for the sense data size.
471 @retval EFI_SUCCESS The command was accepted without any errors.
472 @retval EFI_NOT_FOUND Device does not support this data class.
473 @retval EFI_DEVICE_ERROR Error reading SenseData from device.
474 @retval EFI_BUFFER_TOO_SMALL SenseDataSize not big enough.
479 ScsiDiskInfoSenseData (
480 IN EFI_DISK_INFO_PROTOCOL
*This
,
481 IN OUT VOID
*SenseData
,
482 IN OUT UINT32
*SenseDataSize
,
483 OUT UINT8
*SenseDataNumber
487 This function is used by the IDE bus driver to get controller information.
489 @param[in] This Pointer to the EFI_DISK_INFO_PROTOCOL instance.
490 @param[out] IdeChannel Pointer to the Ide Channel number. Primary or secondary.
491 @param[out] IdeDevice Pointer to the Ide Device number. Master or slave.
493 @retval EFI_SUCCESS IdeChannel and IdeDevice are valid.
494 @retval EFI_UNSUPPORTED This is not an IDE device.
499 ScsiDiskInfoWhichIde (
500 IN EFI_DISK_INFO_PROTOCOL
*This
,
501 OUT UINT32
*IdeChannel
,
502 OUT UINT32
*IdeDevice
507 Detect Device and read out capacity ,if error occurs, parse the sense key.
509 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
510 @param MustReadCapacity The flag about reading device capacity
511 @param MediaChange The pointer of flag indicates if media has changed
513 @retval EFI_DEVICE_ERROR Indicates that error occurs
514 @retval EFI_SUCCESS Successfully to detect media
518 ScsiDiskDetectMedia (
519 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
520 IN BOOLEAN MustReadCapacity
,
521 OUT BOOLEAN
*MediaChange
527 When Test Unit Ready command succeeds, retrieve Sense Keys via Request Sense;
528 When Test Unit Ready command encounters any error caused by host adapter or
529 target, return error without retrieving Sense Keys.
531 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
532 @param NeedRetry The pointer of flag indicates try again
533 @param SenseDataArray The pointer of an array of sense data
534 @param NumberOfSenseKeys The pointer of the number of sense data array
536 @retval EFI_DEVICE_ERROR Indicates that error occurs
537 @retval EFI_SUCCESS Successfully to test unit
541 ScsiDiskTestUnitReady (
542 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
543 OUT BOOLEAN
*NeedRetry
,
544 OUT EFI_SCSI_SENSE_DATA
**SenseDataArray
,
545 OUT UINTN
*NumberOfSenseKeys
550 Parsing Sense Keys which got from request sense command.
552 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
553 @param SenseData The pointer of EFI_SCSI_SENSE_DATA
554 @param NumberOfSenseKeys The number of sense key
555 @param Action The pointer of action which indicates what is need to do next
557 @retval EFI_DEVICE_ERROR Indicates that error occurs
558 @retval EFI_SUCCESS Successfully to complete the parsing
562 DetectMediaParsingSenseKeys (
563 OUT SCSI_DISK_DEV
*ScsiDiskDevice
,
564 IN EFI_SCSI_SENSE_DATA
*SenseData
,
565 IN UINTN NumberOfSenseKeys
,
571 Send read capacity command to device and get the device parameter.
573 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
574 @param NeedRetry The pointer of flag indicates if need a retry
575 @param SenseDataArray The pointer of an array of sense data
576 @param NumberOfSenseKeys The number of sense key
578 @retval EFI_DEVICE_ERROR Indicates that error occurs
579 @retval EFI_SUCCESS Successfully to read capacity
583 ScsiDiskReadCapacity (
584 IN OUT SCSI_DISK_DEV
*ScsiDiskDevice
,
585 OUT BOOLEAN
*NeedRetry
,
586 OUT EFI_SCSI_SENSE_DATA
**SenseDataArray
,
587 OUT UINTN
*NumberOfSenseKeys
591 Check the HostAdapter status and re-interpret it in EFI_STATUS.
593 @param HostAdapterStatus Host Adapter status
595 @retval EFI_SUCCESS Host adapter is OK.
596 @retval EFI_TIMEOUT Timeout.
597 @retval EFI_NOT_READY Adapter NOT ready.
598 @retval EFI_DEVICE_ERROR Adapter device error.
602 CheckHostAdapterStatus (
603 IN UINT8 HostAdapterStatus
608 Check the target status and re-interpret it in EFI_STATUS.
610 @param TargetStatus Target status
612 @retval EFI_NOT_READY Device is NOT ready.
613 @retval EFI_DEVICE_ERROR
619 IN UINT8 TargetStatus
623 Retrieve all sense keys from the device.
625 When encountering error during the process, if retrieve sense keys before
626 error encountered, it returns the sense keys with return status set to EFI_SUCCESS,
627 and NeedRetry set to FALSE; otherwize, return the proper return status.
629 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
630 @param NeedRetry The pointer of flag indicates if need a retry
631 @param SenseDataArray The pointer of an array of sense data
632 @param NumberOfSenseKeys The number of sense key
633 @param AskResetIfError The flag indicates if need reset when error occurs
635 @retval EFI_DEVICE_ERROR Indicates that error occurs
636 @retval EFI_SUCCESS Successfully to request sense key
640 ScsiDiskRequestSenseKeys (
641 IN OUT SCSI_DISK_DEV
*ScsiDiskDevice
,
642 OUT BOOLEAN
*NeedRetry
,
643 OUT EFI_SCSI_SENSE_DATA
**SenseDataArray
,
644 OUT UINTN
*NumberOfSenseKeys
,
645 IN BOOLEAN AskResetIfError
649 Send out Inquiry command to Device.
651 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
652 @param NeedRetry Indicates if needs try again when error happens
654 @retval EFI_DEVICE_ERROR Indicates that error occurs
655 @retval EFI_SUCCESS Successfully to detect media
659 ScsiDiskInquiryDevice (
660 IN OUT SCSI_DISK_DEV
*ScsiDiskDevice
,
661 OUT BOOLEAN
*NeedRetry
667 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
672 IN OUT SCSI_DISK_DEV
*ScsiDiskDevice
676 Read sector from SCSI Disk.
678 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
679 @param Buffer The buffer to fill in the read out data
680 @param Lba Logic block address
681 @param NumberOfBlocks The number of blocks to read
683 @retval EFI_DEVICE_ERROR Indicates a device error.
684 @retval EFI_SUCCESS Operation is successful.
688 ScsiDiskReadSectors (
689 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
692 IN UINTN NumberOfBlocks
696 Write sector to SCSI Disk.
698 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
699 @param Buffer The buffer of data to be written into SCSI Disk
700 @param Lba Logic block address
701 @param NumberOfBlocks The number of blocks to read
703 @retval EFI_DEVICE_ERROR Indicates a device error.
704 @retval EFI_SUCCESS Operation is successful.
708 ScsiDiskWriteSectors (
709 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
712 IN UINTN NumberOfBlocks
718 @param ScsiDiskDevice The pointer of ScsiDiskDevice
719 @param NeedRetry The pointer of flag indicates if needs retry if error happens
720 @param SenseDataArray NOT used yet in this function
721 @param NumberOfSenseKeys The number of sense key
722 @param Timeout The time to complete the command
723 @param DataBuffer The buffer to fill with the read out data
724 @param DataLength The length of buffer
725 @param StartLba The start logic block address
726 @param SectorSize The size of sector
728 @return EFI_STATUS is returned by calling ScsiRead10Command().
732 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
733 OUT BOOLEAN
*NeedRetry
,
734 OUT EFI_SCSI_SENSE_DATA
**SenseDataArray
, OPTIONAL
735 OUT UINTN
*NumberOfSenseKeys
,
737 OUT UINT8
*DataBuffer
,
738 IN OUT UINT32
*DataLength
,
744 Submit Write Command.
746 @param ScsiDiskDevice The pointer of ScsiDiskDevice
747 @param NeedRetry The pointer of flag indicates if needs retry if error happens
748 @param SenseDataArray NOT used yet in this function
749 @param NumberOfSenseKeys The number of sense key
750 @param Timeout The time to complete the command
751 @param DataBuffer The buffer to fill with the read out data
752 @param DataLength The length of buffer
753 @param StartLba The start logic block address
754 @param SectorSize The size of sector
756 @return EFI_STATUS is returned by calling ScsiWrite10Command().
761 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
762 OUT BOOLEAN
*NeedRetry
,
763 OUT EFI_SCSI_SENSE_DATA
**SenseDataArray
, OPTIONAL
764 OUT UINTN
*NumberOfSenseKeys
,
766 IN UINT8
*DataBuffer
,
767 IN OUT UINT32
*DataLength
,
773 Submit Read(16) command.
775 @param ScsiDiskDevice The pointer of ScsiDiskDevice
776 @param NeedRetry The pointer of flag indicates if needs retry if error happens
777 @param SenseDataArray NOT used yet in this function
778 @param NumberOfSenseKeys The number of sense key
779 @param Timeout The time to complete the command
780 @param DataBuffer The buffer to fill with the read out data
781 @param DataLength The length of buffer
782 @param StartLba The start logic block address
783 @param SectorSize The size of sector
785 @return EFI_STATUS is returned by calling ScsiRead10Command().
789 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
790 OUT BOOLEAN
*NeedRetry
,
791 OUT EFI_SCSI_SENSE_DATA
**SenseDataArray
, OPTIONAL
792 OUT UINTN
*NumberOfSenseKeys
,
794 OUT UINT8
*DataBuffer
,
795 IN OUT UINT32
*DataLength
,
801 Submit Write(16) Command.
803 @param ScsiDiskDevice The pointer of ScsiDiskDevice
804 @param NeedRetry The pointer of flag indicates if needs retry if error happens
805 @param SenseDataArray NOT used yet in this function
806 @param NumberOfSenseKeys The number of sense key
807 @param Timeout The time to complete the command
808 @param DataBuffer The buffer to fill with the read out data
809 @param DataLength The length of buffer
810 @param StartLba The start logic block address
811 @param SectorSize The size of sector
813 @return EFI_STATUS is returned by calling ScsiWrite10Command().
818 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
819 OUT BOOLEAN
*NeedRetry
,
820 OUT EFI_SCSI_SENSE_DATA
**SenseDataArray
, OPTIONAL
821 OUT UINTN
*NumberOfSenseKeys
,
823 IN UINT8
*DataBuffer
,
824 IN OUT UINT32
*DataLength
,
830 Get information from media read capacity command.
832 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
833 @param Capacity10 The pointer of EFI_SCSI_DISK_CAPACITY_DATA
834 @param Capacity16 The pointer of EFI_SCSI_DISK_CAPACITY_DATA16
838 IN OUT SCSI_DISK_DEV
*ScsiDiskDevice
,
839 IN EFI_SCSI_DISK_CAPACITY_DATA
*Capacity10
,
840 IN EFI_SCSI_DISK_CAPACITY_DATA16
*Capacity16
844 Check sense key to find if media presents.
846 @param SenseData The pointer of EFI_SCSI_SENSE_DATA
847 @param SenseCounts The number of sense key
849 @retval TRUE NOT any media
850 @retval FALSE Media presents
854 IN EFI_SCSI_SENSE_DATA
*SenseData
,
861 @param SenseData The pointer of EFI_SCSI_SENSE_DATA
862 @param SenseCounts The number of sense key
865 @retval FALSE NOT error
869 ScsiDiskIsMediaError (
870 IN EFI_SCSI_SENSE_DATA
*SenseData
,
875 Check sense key to find if hardware error happens.
877 @param SenseData The pointer of EFI_SCSI_SENSE_DATA
878 @param SenseCounts The number of sense key
880 @retval TRUE Hardware error exits.
881 @retval FALSE NO error.
885 ScsiDiskIsHardwareError (
886 IN EFI_SCSI_SENSE_DATA
*SenseData
,
891 Check sense key to find if media has changed.
893 @param SenseData The pointer of EFI_SCSI_SENSE_DATA
894 @param SenseCounts The number of sense key
896 @retval TRUE Media is changed.
897 @retval FALSE Medit is NOT changed.
900 ScsiDiskIsMediaChange (
901 IN EFI_SCSI_SENSE_DATA
*SenseData
,
906 Check sense key to find if reset happens.
908 @param SenseData The pointer of EFI_SCSI_SENSE_DATA
909 @param SenseCounts The number of sense key
911 @retval TRUE It is reset before.
912 @retval FALSE It is NOT reset before.
916 ScsiDiskIsResetBefore (
917 IN EFI_SCSI_SENSE_DATA
*SenseData
,
922 Check sense key to find if the drive is ready.
924 @param SenseData The pointer of EFI_SCSI_SENSE_DATA
925 @param SenseCounts The number of sense key
926 @param RetryLater The flag means if need a retry
928 @retval TRUE Drive is ready.
929 @retval FALSE Drive is NOT ready.
933 ScsiDiskIsDriveReady (
934 IN EFI_SCSI_SENSE_DATA
*SenseData
,
935 IN UINTN SenseCounts
,
936 OUT BOOLEAN
*RetryLater
940 Check sense key to find if it has sense key.
942 @param SenseData - The pointer of EFI_SCSI_SENSE_DATA
943 @param SenseCounts - The number of sense key
945 @retval TRUE It has sense key.
946 @retval FALSE It has NOT any sense key.
950 ScsiDiskHaveSenseKey (
951 IN EFI_SCSI_SENSE_DATA
*SenseData
,
956 Release resource about disk device.
958 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV
962 ReleaseScsiDiskDeviceResources (
963 IN SCSI_DISK_DEV
*ScsiDiskDevice
967 Determine if Block Io should be produced.
970 @param ChildHandle Child Handle to retrieve Parent information.
972 @retval TRUE Should produce Block Io.
973 @retval FALSE Should not produce Block Io.
977 DetermineInstallBlockIo (
978 IN EFI_HANDLE ChildHandle
982 Initialize the installation of DiskInfo protocol.
984 This function prepares for the installation of DiskInfo protocol on the child handle.
985 By default, it installs DiskInfo protocol with SCSI interface GUID. If it further
986 detects that the physical device is an ATAPI/AHCI device, it then updates interface GUID
987 to be IDE/AHCI interface GUID.
989 @param ScsiDiskDevice The pointer of SCSI_DISK_DEV.
990 @param ChildHandle Child handle to install DiskInfo protocol.
994 InitializeInstallDiskInfo (
995 IN SCSI_DISK_DEV
*ScsiDiskDevice
,
996 IN EFI_HANDLE ChildHandle
1000 Search protocol database and check to see if the protocol
1001 specified by ProtocolGuid is present on a ControllerHandle and opened by
1002 ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
1003 If the ControllerHandle is found, then the protocol specified by ProtocolGuid
1004 will be opened on it.
1007 @param ProtocolGuid ProtocolGuid pointer.
1008 @param ChildHandle Child Handle to retrieve Parent information.
1014 IN EFI_GUID
*ProtocolGuid
,
1015 IN EFI_HANDLE ChildHandle