2 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
3 SPDX-License-Identifier: BSD-2-Clause-Patent
5 Module Name: AtapiPassThru.h
16 #include <Protocol/ScsiPassThru.h>
17 #include <Protocol/ScsiPassThruExt.h>
18 #include <Protocol/PciIo.h>
19 #include <Protocol/DriverSupportedEfiVersion.h>
21 #include <Library/DebugLib.h>
22 #include <Library/UefiDriverEntryPoint.h>
23 #include <Library/BaseLib.h>
24 #include <Library/UefiLib.h>
25 #include <Library/BaseMemoryLib.h>
26 #include <Library/MemoryAllocationLib.h>
27 #include <Library/UefiBootServicesTableLib.h>
28 #include <Library/PcdLib.h>
29 #include <Library/DevicePathLib.h>
31 #include <IndustryStandard/Pci.h>
33 #define MAX_TARGET_ID 4
39 UINT16 Command
; /* when write */
40 UINT16 Status
; /* when read */
44 UINT16 Error
; /* when read */
45 UINT16 Feature
; /* when write */
46 } IDE_ERROR_OR_FEATURE
;
49 UINT16 AltStatus
; /* when read */
50 UINT16 DeviceControl
; /* when write */
51 } IDE_AltStatus_OR_DeviceControl
;
64 // Bit definitions in Programming Interface byte of the Class Code field
65 // in PCI IDE controller's Configuration Space
67 #define IDE_PRIMARY_OPERATING_MODE BIT0
68 #define IDE_PRIMARY_PROGRAMMABLE_INDICATOR BIT1
69 #define IDE_SECONDARY_OPERATING_MODE BIT2
70 #define IDE_SECONDARY_PROGRAMMABLE_INDICATOR BIT3
73 #define ATAPI_MAX_CHANNEL 2
80 IDE_ERROR_OR_FEATURE Reg1
;
86 IDE_CMD_OR_STATUS Reg
;
87 IDE_AltStatus_OR_DeviceControl Alt
;
91 #define ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE SIGNATURE_32 ('a', 's', 'p', 't')
96 EFI_SCSI_PASS_THRU_PROTOCOL ScsiPassThru
;
97 EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru
;
98 EFI_PCI_IO_PROTOCOL
*PciIo
;
99 UINT64 OriginalPciAttributes
;
101 // Local Data goes here
103 IDE_BASE_REGISTERS
*IoPort
;
104 IDE_BASE_REGISTERS AtapiIoPortRegisters
[2];
105 UINT32 LatestTargetId
;
107 } ATAPI_SCSI_PASS_THRU_DEV
;
110 // IDE registers' base addresses
113 UINT16 CommandBlockBaseAddr
;
114 UINT16 ControlBlockBaseAddr
;
115 } IDE_REGISTERS_BASE_ADDR
;
117 #define ATAPI_SCSI_PASS_THRU_DEV_FROM_THIS(a) \
119 ATAPI_SCSI_PASS_THRU_DEV, \
121 ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE \
124 #define ATAPI_EXT_SCSI_PASS_THRU_DEV_FROM_THIS(a) \
126 ATAPI_SCSI_PASS_THRU_DEV, \
128 ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE \
134 extern EFI_DRIVER_BINDING_PROTOCOL gAtapiScsiPassThruDriverBinding
;
135 extern EFI_COMPONENT_NAME_PROTOCOL gAtapiScsiPassThruComponentName
;
136 extern EFI_COMPONENT_NAME2_PROTOCOL gAtapiScsiPassThruComponentName2
;
137 extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gAtapiScsiPassThruDriverSupportedEfiVersion
;
140 // ATAPI Command op code
142 #define OP_INQUIRY 0x12
143 #define OP_LOAD_UNLOAD_CD 0xa6
144 #define OP_MECHANISM_STATUS 0xbd
145 #define OP_MODE_SELECT_10 0x55
146 #define OP_MODE_SENSE_10 0x5a
147 #define OP_PAUSE_RESUME 0x4b
148 #define OP_PLAY_AUDIO_10 0x45
149 #define OP_PLAY_AUDIO_MSF 0x47
150 #define OP_PLAY_CD 0xbc
151 #define OP_PLAY_CD_MSF 0xb4
152 #define OP_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
153 #define OP_READ_10 0x28
154 #define OP_READ_12 0xa8
155 #define OP_READ_CAPACITY 0x25
156 #define OP_READ_CD 0xbe
157 #define OP_READ_CD_MSF 0xb9
158 #define OP_READ_HEADER 0x44
159 #define OP_READ_SUB_CHANNEL 0x42
160 #define OP_READ_TOC 0x43
161 #define OP_REQUEST_SENSE 0x03
163 #define OP_SEEK_10 0x2b
164 #define OP_SET_CD_SPEED 0xbb
165 #define OP_STOPPLAY_SCAN 0x4e
166 #define OP_START_STOP_UNIT 0x1b
167 #define OP_TEST_UNIT_READY 0x00
169 #define OP_FORMAT_UNIT 0x04
170 #define OP_READ_FORMAT_CAPACITIES 0x23
171 #define OP_VERIFY 0x2f
172 #define OP_WRITE_10 0x2a
173 #define OP_WRITE_12 0xaa
174 #define OP_WRITE_AND_VERIFY 0x2e
179 #define ATAPI_SOFT_RESET_CMD 0x08
191 DATA_DIRECTION Direction
;
194 #define MAX_CHANNEL 2
196 #define ValidCdbLength(Len) ((Len) == 6 || (Len) == 10 || (Len) == 12) ? 1 : 0
199 // IDE registers bit definitions
201 // ATA Err Reg bitmap
203 #define BBK_ERR BIT7 ///< Bad block detected
204 #define UNC_ERR BIT6 ///< Uncorrectable Data
205 #define MC_ERR BIT5 ///< Media Change
206 #define IDNF_ERR BIT4 ///< ID Not Found
207 #define MCR_ERR BIT3 ///< Media Change Requested
208 #define ABRT_ERR BIT2 ///< Aborted Command
209 #define TK0NF_ERR BIT1 ///< Track 0 Not Found
210 #define AMNF_ERR BIT0 ///< Address Mark Not Found
213 // ATAPI Err Reg bitmap
215 #define SENSE_KEY_ERR (BIT7 | BIT6 | BIT5 | BIT4)
216 #define EOM_ERR BIT1 ///< End of Media Detected
217 #define ILI_ERR BIT0 ///< Illegal Length Indication
222 #define LBA_MODE BIT6
237 #define BSY BIT7 ///< Controller Busy
238 #define DRDY BIT6 ///< Drive Ready
239 #define DWF BIT5 ///< Drive Write Fault
240 #define DSC BIT4 ///< Disk Seek Complete
241 #define DRQ BIT3 ///< Data Request
242 #define CORR BIT2 ///< Corrected Data
243 #define IDX BIT1 ///< Index
244 #define ERR BIT0 ///< Error
245 #define CHECK BIT0 ///< Check bit for ATAPI Status Reg
248 // Device Control Reg
250 #define SRST BIT2 ///< Software Reset
251 #define IEN_L BIT1 ///< Interrupt Enable
254 // ATAPI Feature Register
260 // ATAPI Interrupt Reason Reson Reg (ATA Sector Count Register)
266 #define PACKET_CMD 0xA0
268 #define DEFAULT_CMD (0xa0)
270 // default content of device control register, disable INT
272 #define DEFAULT_CTL (0x0a)
273 #define MAX_ATAPI_BYTE_COUNT (0xfffe)
276 // function prototype
281 AtapiScsiPassThruDriverBindingSupported (
282 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
283 IN EFI_HANDLE Controller
,
284 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
289 AtapiScsiPassThruDriverBindingStart (
290 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
291 IN EFI_HANDLE Controller
,
292 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
297 AtapiScsiPassThruDriverBindingStop (
298 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
299 IN EFI_HANDLE Controller
,
300 IN UINTN NumberOfChildren
,
301 IN EFI_HANDLE
*ChildHandleBuffer
305 // EFI Component Name Functions
308 Retrieves a Unicode string that is the user readable name of the driver.
310 This function retrieves the user readable name of a driver in the form of a
311 Unicode string. If the driver specified by This has a user readable name in
312 the language specified by Language, then a pointer to the driver name is
313 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
314 by This does not support the language specified by Language,
315 then EFI_UNSUPPORTED is returned.
317 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
318 EFI_COMPONENT_NAME_PROTOCOL instance.
320 @param Language[in] A pointer to a Null-terminated ASCII string
321 array indicating the language. This is the
322 language of the driver name that the caller is
323 requesting, and it must match one of the
324 languages specified in SupportedLanguages. The
325 number of languages supported by a driver is up
326 to the driver writer. Language is specified
327 in RFC 4646 or ISO 639-2 language code format.
329 @param DriverName[out] A pointer to the Unicode string to return.
330 This Unicode string is the name of the
331 driver specified by This in the language
332 specified by Language.
334 @retval EFI_SUCCESS The Unicode string for the Driver specified by
335 This and the language specified by Language was
336 returned in DriverName.
338 @retval EFI_INVALID_PARAMETER Language is NULL.
340 @retval EFI_INVALID_PARAMETER DriverName is NULL.
342 @retval EFI_UNSUPPORTED The driver specified by This does not support
343 the language specified by Language.
348 AtapiScsiPassThruComponentNameGetDriverName (
349 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
351 OUT CHAR16
**DriverName
356 Retrieves a Unicode string that is the user readable name of the controller
357 that is being managed by a driver.
359 This function retrieves the user readable name of the controller specified by
360 ControllerHandle and ChildHandle in the form of a Unicode string. If the
361 driver specified by This has a user readable name in the language specified by
362 Language, then a pointer to the controller name is returned in ControllerName,
363 and EFI_SUCCESS is returned. If the driver specified by This is not currently
364 managing the controller specified by ControllerHandle and ChildHandle,
365 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
366 support the language specified by Language, then EFI_UNSUPPORTED is returned.
368 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
369 EFI_COMPONENT_NAME_PROTOCOL instance.
371 @param ControllerHandle[in] The handle of a controller that the driver
372 specified by This is managing. This handle
373 specifies the controller whose name is to be
376 @param ChildHandle[in] The handle of the child controller to retrieve
377 the name of. This is an optional parameter that
378 may be NULL. It will be NULL for device
379 drivers. It will also be NULL for a bus drivers
380 that wish to retrieve the name of the bus
381 controller. It will not be NULL for a bus
382 driver that wishes to retrieve the name of a
385 @param Language[in] A pointer to a Null-terminated ASCII string
386 array indicating the language. This is the
387 language of the driver name that the caller is
388 requesting, and it must match one of the
389 languages specified in SupportedLanguages. The
390 number of languages supported by a driver is up
391 to the driver writer. Language is specified in
392 RFC 4646 or ISO 639-2 language code format.
394 @param ControllerName[out] A pointer to the Unicode string to return.
395 This Unicode string is the name of the
396 controller specified by ControllerHandle and
397 ChildHandle in the language specified by
398 Language from the point of view of the driver
401 @retval EFI_SUCCESS The Unicode string for the user readable name in
402 the language specified by Language for the
403 driver specified by This was returned in
406 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
408 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
411 @retval EFI_INVALID_PARAMETER Language is NULL.
413 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
415 @retval EFI_UNSUPPORTED The driver specified by This is not currently
416 managing the controller specified by
417 ControllerHandle and ChildHandle.
419 @retval EFI_UNSUPPORTED The driver specified by This does not support
420 the language specified by Language.
425 AtapiScsiPassThruComponentNameGetControllerName (
426 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
427 IN EFI_HANDLE ControllerHandle
,
428 IN EFI_HANDLE ChildHandle OPTIONAL
,
430 OUT CHAR16
**ControllerName
436 AtapiScsiPassThruDriverEntryPoint (
437 IN EFI_HANDLE ImageHandle
,
438 IN EFI_SYSTEM_TABLE
*SystemTable
444 Entry point for EFI drivers.
448 ImageHandle - EFI_HANDLE
449 SystemTable - EFI_SYSTEM_TABLE
460 RegisterAtapiScsiPassThru (
461 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
462 IN EFI_HANDLE Controller
,
463 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
464 IN UINT64 OriginalPciAttributes
469 Attaches SCSI Pass Thru Protocol for specified IDE channel.
472 This - Protocol instance pointer.
473 Controller - Parent device handle to the IDE channel.
474 PciIo - PCI I/O protocol attached on the "Controller".
477 Always return EFI_SUCCESS unless installing SCSI Pass Thru Protocol failed.
484 AtapiScsiPassThruFunction (
485 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
488 IN OUT EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
,
489 IN EFI_EVENT Event OPTIONAL
495 Implements EFI_SCSI_PASS_THRU_PROTOCOL.PassThru() function.
499 This: The EFI_SCSI_PASS_THRU_PROTOCOL instance.
500 Target: The Target ID of the ATAPI device to send the SCSI
501 Request Packet. To ATAPI devices attached on an IDE
502 Channel, Target ID 0 indicates Master device;Target
503 ID 1 indicates Slave device.
504 Lun: The LUN of the ATAPI device to send the SCSI Request
505 Packet. To the ATAPI device, Lun is always 0.
506 Packet: The SCSI Request Packet to send to the ATAPI device
507 specified by Target and Lun.
508 Event: If non-blocking I/O is not supported then Event is ignored,
509 and blocking I/O is performed.
510 If Event is NULL, then blocking I/O is performed.
511 If Event is not NULL and non blocking I/O is supported,
512 then non-blocking I/O is performed, and Event will be signaled
513 when the SCSI Request Packet completes.
524 AtapiScsiPassThruGetNextDevice (
525 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
526 IN OUT UINT32
*Target
,
533 Used to retrieve the list of legal Target IDs for SCSI devices
538 This - Protocol instance pointer.
539 Target - On input, a pointer to the Target ID of a SCSI
540 device present on the SCSI channel. On output,
541 a pointer to the Target ID of the next SCSI device
542 present on a SCSI channel. An input value of
543 0xFFFFFFFF retrieves the Target ID of the first
544 SCSI device present on a SCSI channel.
545 Lun - On input, a pointer to the LUN of a SCSI device
546 present on the SCSI channel. On output, a pointer
547 to the LUN of the next SCSI device present on
551 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
552 on the SCSI channel was returned in Target and Lun.
553 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
554 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
555 returned on a previous call to GetNextDevice().
562 AtapiScsiPassThruBuildDevicePath (
563 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
566 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
572 Used to allocate and build a device path node for a SCSI device
573 on a SCSI channel. Would not build device path for a SCSI Host Controller.
577 This - Protocol instance pointer.
578 Target - The Target ID of the SCSI device for which
579 a device path node is to be allocated and built.
580 Lun - The LUN of the SCSI device for which a device
581 path node is to be allocated and built.
582 DevicePath - A pointer to a single device path node that
583 describes the SCSI device specified by
584 Target and Lun. This function is responsible
585 for allocating the buffer DevicePath with the boot
586 service AllocatePool(). It is the caller's
587 responsibility to free DevicePath when the caller
588 is finished with DevicePath.
590 EFI_SUCCESS - The device path node that describes the SCSI device
591 specified by Target and Lun was allocated and
592 returned in DevicePath.
593 EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
594 not exist on the SCSI channel.
595 EFI_INVALID_PARAMETER - DevicePath is NULL.
596 EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
604 AtapiScsiPassThruGetTargetLun (
605 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
606 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
614 Used to translate a device path node to a Target ID and LUN.
618 This - Protocol instance pointer.
619 DevicePath - A pointer to the device path node that
620 describes a SCSI device on the SCSI channel.
621 Target - A pointer to the Target ID of a SCSI device
623 Lun - A pointer to the LUN of a SCSI device on
627 EFI_SUCCESS - DevicePath was successfully translated to a
628 Target ID and LUN, and they were returned
630 EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.
631 EFI_UNSUPPORTED - This driver does not support the device path
632 node type in DevicePath.
633 EFI_NOT_FOUND - A valid translation from DevicePath to a
634 Target ID and LUN does not exist.
641 AtapiScsiPassThruResetChannel (
642 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
648 Resets a SCSI channel.This operation resets all the
649 SCSI devices connected to the SCSI channel.
653 This - Protocol instance pointer.
657 EFI_SUCCESS - The SCSI channel was reset.
658 EFI_UNSUPPORTED - The SCSI channel does not support
659 a channel reset operation.
660 EFI_DEVICE_ERROR - A device error occurred while
661 attempting to reset the SCSI channel.
662 EFI_TIMEOUT - A timeout occurred while attempting
663 to reset the SCSI channel.
670 AtapiScsiPassThruResetTarget (
671 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
679 Resets a SCSI device that is connected to a SCSI channel.
683 This - Protocol instance pointer.
684 Target - The Target ID of the SCSI device to reset.
685 Lun - The LUN of the SCSI device to reset.
689 EFI_SUCCESS - The SCSI device specified by Target and
691 EFI_UNSUPPORTED - The SCSI channel does not support a target
693 EFI_INVALID_PARAMETER - Target or Lun are invalid.
694 EFI_DEVICE_ERROR - A device error occurred while attempting
695 to reset the SCSI device specified by Target
697 EFI_TIMEOUT - A timeout occurred while attempting to reset
698 the SCSI device specified by Target and Lun.
705 AtapiExtScsiPassThruFunction (
706 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
709 IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
,
710 IN EFI_EVENT Event OPTIONAL
716 Implements EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() function.
720 This: The EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
721 Target: The Target ID of the ATAPI device to send the SCSI
722 Request Packet. To ATAPI devices attached on an IDE
723 Channel, Target ID 0 indicates Master device;Target
724 ID 1 indicates Slave device.
725 Lun: The LUN of the ATAPI device to send the SCSI Request
726 Packet. To the ATAPI device, Lun is always 0.
727 Packet: The SCSI Request Packet to send to the ATAPI device
728 specified by Target and Lun.
729 Event: If non-blocking I/O is not supported then Event is ignored,
730 and blocking I/O is performed.
731 If Event is NULL, then blocking I/O is performed.
732 If Event is not NULL and non blocking I/O is supported,
733 then non-blocking I/O is performed, and Event will be signaled
734 when the SCSI Request Packet completes.
745 AtapiExtScsiPassThruGetNextTargetLun (
746 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
747 IN OUT UINT8
**Target
,
754 Used to retrieve the list of legal Target IDs for SCSI devices
759 This - Protocol instance pointer.
760 Target - On input, a pointer to the Target ID of a SCSI
761 device present on the SCSI channel. On output,
762 a pointer to the Target ID of the next SCSI device
763 present on a SCSI channel. An input value of
764 0xFFFFFFFF retrieves the Target ID of the first
765 SCSI device present on a SCSI channel.
766 Lun - On input, a pointer to the LUN of a SCSI device
767 present on the SCSI channel. On output, a pointer
768 to the LUN of the next SCSI device present on
772 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
773 on the SCSI channel was returned in Target and Lun.
774 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
775 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
776 returned on a previous call to GetNextDevice().
783 AtapiExtScsiPassThruBuildDevicePath (
784 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
787 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
793 Used to allocate and build a device path node for a SCSI device
794 on a SCSI channel. Would not build device path for a SCSI Host Controller.
798 This - Protocol instance pointer.
799 Target - The Target ID of the SCSI device for which
800 a device path node is to be allocated and built.
801 Lun - The LUN of the SCSI device for which a device
802 path node is to be allocated and built.
803 DevicePath - A pointer to a single device path node that
804 describes the SCSI device specified by
805 Target and Lun. This function is responsible
806 for allocating the buffer DevicePath with the boot
807 service AllocatePool(). It is the caller's
808 responsibility to free DevicePath when the caller
809 is finished with DevicePath.
811 EFI_SUCCESS - The device path node that describes the SCSI device
812 specified by Target and Lun was allocated and
813 returned in DevicePath.
814 EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
815 not exist on the SCSI channel.
816 EFI_INVALID_PARAMETER - DevicePath is NULL.
817 EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
825 AtapiExtScsiPassThruGetTargetLun (
826 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
827 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
835 Used to translate a device path node to a Target ID and LUN.
839 This - Protocol instance pointer.
840 DevicePath - A pointer to the device path node that
841 describes a SCSI device on the SCSI channel.
842 Target - A pointer to the Target ID of a SCSI device
844 Lun - A pointer to the LUN of a SCSI device on
848 EFI_SUCCESS - DevicePath was successfully translated to a
849 Target ID and LUN, and they were returned
851 EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.
852 EFI_UNSUPPORTED - This driver does not support the device path
853 node type in DevicePath.
854 EFI_NOT_FOUND - A valid translation from DevicePath to a
855 Target ID and LUN does not exist.
862 AtapiExtScsiPassThruResetChannel (
863 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
869 Resets a SCSI channel.This operation resets all the
870 SCSI devices connected to the SCSI channel.
874 This - Protocol instance pointer.
878 EFI_SUCCESS - The SCSI channel was reset.
879 EFI_UNSUPPORTED - The SCSI channel does not support
880 a channel reset operation.
881 EFI_DEVICE_ERROR - A device error occurred while
882 attempting to reset the SCSI channel.
883 EFI_TIMEOUT - A timeout occurred while attempting
884 to reset the SCSI channel.
891 AtapiExtScsiPassThruResetTarget (
892 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
900 Resets a SCSI device that is connected to a SCSI channel.
904 This - Protocol instance pointer.
905 Target - The Target ID of the SCSI device to reset.
906 Lun - The LUN of the SCSI device to reset.
910 EFI_SUCCESS - The SCSI device specified by Target and
912 EFI_UNSUPPORTED - The SCSI channel does not support a target
914 EFI_INVALID_PARAMETER - Target or Lun are invalid.
915 EFI_DEVICE_ERROR - A device error occurred while attempting
916 to reset the SCSI device specified by Target
918 EFI_TIMEOUT - A timeout occurred while attempting to reset
919 the SCSI device specified by Target and Lun.
926 AtapiExtScsiPassThruGetNextTarget (
927 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
928 IN OUT UINT8
**Target
933 Used to retrieve the list of legal Target IDs for SCSI devices
937 This - Protocol instance pointer.
938 Target - On input, a pointer to the Target ID of a SCSI
939 device present on the SCSI channel. On output,
940 a pointer to the Target ID of the next SCSI device
941 present on a SCSI channel. An input value of
942 0xFFFFFFFF retrieves the Target ID of the first
943 SCSI device present on a SCSI channel.
944 Lun - On input, a pointer to the LUN of a SCSI device
945 present on the SCSI channel. On output, a pointer
946 to the LUN of the next SCSI device present on
950 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
951 on the SCSI channel was returned in Target and Lun.
952 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
953 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
954 returned on a previous call to GetNextDevice().
960 CheckSCSIRequestPacket (
961 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
967 Checks the parameters in the SCSI Request Packet to make sure
968 they are valid for a SCSI Pass Thru request.
972 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
982 SubmitBlockingIoCommand (
983 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
985 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
991 Performs blocking I/O request.
995 AtapiScsiPrivate: Private data structure for the specified channel.
996 Target: The Target ID of the ATAPI device to send the SCSI
997 Request Packet. To ATAPI devices attached on an IDE
998 Channel, Target ID 0 indicates Master device;Target
999 ID 1 indicates Slave device.
1000 Packet: The SCSI Request Packet to send to the ATAPI device
1001 specified by Target.
1010 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1014 Routine Description:
1016 Checks the requested SCSI command:
1017 Is it supported by this driver?
1018 Is the Data transfer direction reasonable?
1022 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1032 CheckExtSCSIRequestPacket (
1033 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1037 Routine Description:
1039 Checks the parameters in the SCSI Request Packet to make sure
1040 they are valid for a SCSI Pass Thru request.
1044 Packet - The pointer of EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1056 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1060 Routine Description:
1062 Checks the requested SCSI command:
1063 Is it supported by this driver?
1064 Is the Data transfer direction reasonable?
1068 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1078 SubmitExtBlockingIoCommand (
1079 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1081 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1085 Routine Description:
1087 Performs blocking I/O request.
1091 AtapiScsiPrivate: Private data structure for the specified channel.
1092 Target: The Target ID of the ATAPI device to send the SCSI
1093 Request Packet. To ATAPI devices attached on an IDE
1094 Channel, Target ID 0 indicates Master device;Target
1095 ID 1 indicates Slave device.
1096 Packet: The SCSI Request Packet to send to the ATAPI device
1097 specified by Target.
1105 RequestSenseCommand (
1106 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1110 UINT8
*SenseDataLength
1114 Routine Description:
1116 Submit request sense command
1120 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1121 Target - The target ID
1122 Timeout - The time to complete the command
1123 SenseData - The buffer to fill in sense data
1124 SenseDataLength - The length of buffer
1134 AtapiPacketCommand (
1135 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1137 UINT8
*PacketCommand
,
1140 DATA_DIRECTION Direction
,
1141 UINT64 TimeOutInMicroSeconds
1145 Routine Description:
1147 Submits ATAPI command packet to the specified ATAPI device.
1151 AtapiScsiPrivate: Private data structure for the specified channel.
1152 Target: The Target ID of the ATAPI device to send the SCSI
1153 Request Packet. To ATAPI devices attached on an IDE
1154 Channel, Target ID 0 indicates Master device;Target
1155 ID 1 indicates Slave device.
1156 PacketCommand: Points to the ATAPI command packet.
1157 Buffer: Points to the transferred data.
1158 ByteCount: When input,indicates the buffer size; when output,
1159 indicates the actually transferred data size.
1160 Direction: Indicates the data transfer direction.
1161 TimeoutInMicroSeconds:
1162 The timeout, in micro second units, to use for the
1163 execution of this ATAPI command.
1164 A TimeoutInMicroSeconds value of 0 means that
1165 this function will wait indefinitely for the ATAPI
1167 If TimeoutInMicroSeconds is greater than zero, then
1168 this function will return EFI_TIMEOUT if the time
1169 required to execute the ATAPI command is greater
1170 than TimeoutInMicroSeconds.
1182 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1187 Routine Description:
1189 Read one byte from a specified I/O port.
1193 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1206 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1211 Routine Description:
1213 Read one word from a specified I/O port.
1217 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1230 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1236 Routine Description:
1238 Write one byte to a specified I/O port.
1242 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1244 Data - The data to write
1256 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1262 Routine Description:
1264 Write one word to a specified I/O port.
1268 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1270 Data - The data to write
1281 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1282 UINT64 TimeOutInMicroSeconds
1286 Routine Description:
1288 Check whether DRQ is clear in the Status Register. (BSY must also be cleared)
1289 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1290 DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1295 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1296 TimeoutInMicroSeconds - The time to wait for
1307 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1308 UINT64 TimeOutInMicroSeconds
1312 Routine Description:
1314 Check whether DRQ is clear in the Alternate Status Register.
1315 (BSY must also be cleared).If TimeoutInMicroSeconds is zero, this routine should
1316 wait infinitely for DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1321 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1322 TimeoutInMicroSeconds - The time to wait for
1333 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1334 UINT64 TimeOutInMicroSeconds
1338 Routine Description:
1340 Check whether DRQ is ready in the Status Register. (BSY must also be cleared)
1341 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1342 DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1347 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1348 TimeoutInMicroSeconds - The time to wait for
1359 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1360 UINT64 TimeOutInMicroSeconds
1364 Routine Description:
1366 Check whether DRQ is ready in the Alternate Status Register.
1367 (BSY must also be cleared)
1368 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1369 DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1374 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1375 TimeoutInMicroSeconds - The time to wait for
1385 StatusWaitForBSYClear (
1386 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1387 UINT64 TimeoutInMicroSeconds
1391 Routine Description:
1393 Check whether BSY is clear in the Status Register.
1394 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1395 BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1400 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1401 TimeoutInMicroSeconds - The time to wait for
1411 AltStatusWaitForBSYClear (
1412 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1413 UINT64 TimeoutInMicroSeconds
1417 Routine Description:
1419 Check whether BSY is clear in the Alternate Status Register.
1420 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1421 BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1426 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1427 TimeoutInMicroSeconds - The time to wait for
1438 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1439 UINT64 TimeoutInMicroSeconds
1443 Routine Description:
1445 Check whether DRDY is ready in the Status Register.
1446 (BSY must also be cleared)
1447 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1448 DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1453 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1454 TimeoutInMicroSeconds - The time to wait for
1464 AltStatusDRDYReady (
1465 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1466 UINT64 TimeoutInMicroSeconds
1470 Routine Description:
1472 Check whether DRDY is ready in the Alternate Status Register.
1473 (BSY must also be cleared)
1474 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1475 DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1480 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1481 TimeoutInMicroSeconds - The time to wait for
1491 AtapiPassThruPioReadWriteData (
1492 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1495 DATA_DIRECTION Direction
,
1496 UINT64 TimeOutInMicroSeconds
1500 Routine Description:
1502 Performs data transfer between ATAPI device and host after the
1503 ATAPI command packet is sent.
1507 AtapiScsiPrivate: Private data structure for the specified channel.
1508 Buffer: Points to the transferred data.
1509 ByteCount: When input,indicates the buffer size; when output,
1510 indicates the actually transferred data size.
1511 Direction: Indicates the data transfer direction.
1512 TimeoutInMicroSeconds:
1513 The timeout, in micro second units, to use for the
1514 execution of this ATAPI command.
1515 A TimeoutInMicroSeconds value of 0 means that
1516 this function will wait indefinitely for the ATAPI
1518 If TimeoutInMicroSeconds is greater than zero, then
1519 this function will return EFI_TIMEOUT if the time
1520 required to execute the ATAPI command is greater
1521 than TimeoutInMicroSeconds.
1530 AtapiPassThruCheckErrorStatus (
1531 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
1535 Routine Description:
1537 Check Error Register for Error Information.
1541 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1552 GetIdeRegistersBaseAddr (
1553 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1554 OUT IDE_REGISTERS_BASE_ADDR
*IdeRegsBaseAddr
1558 Routine Description:
1559 Get IDE IO port registers' base addresses by mode. In 'Compatibility' mode,
1560 use fixed addresses. In Native-PCI mode, get base addresses from BARs in
1561 the PCI IDE controller's Configuration Space.
1564 PciIo - Pointer to the EFI_PCI_IO_PROTOCOL instance
1565 IdeRegsBaseAddr - Pointer to IDE_REGISTERS_BASE_ADDR to
1566 receive IDE IO port registers' base addresses
1577 InitAtapiIoPortRegisters (
1578 IN ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1579 IN IDE_REGISTERS_BASE_ADDR
*IdeRegsBaseAddr
1583 Routine Description:
1585 Initialize each Channel's Base Address of CommandBlock and ControlBlock.
1589 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1590 IdeRegsBaseAddr - The pointer of IDE_REGISTERS_BASE_ADDR
1600 Installs Scsi Pass Thru and/or Ext Scsi Pass Thru
1601 protocols based on feature flags.
1603 @param Controller The controller handle to
1604 install these protocols on.
1605 @param AtapiScsiPrivate A pointer to the protocol private
1608 @retval EFI_SUCCESS The installation succeeds.
1609 @retval other The installation fails.
1613 InstallScsiPassThruProtocols (
1614 IN EFI_HANDLE
*ControllerHandle
,
1615 IN ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate