2 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
3 This program and the accompanying materials
4 are licensed and made available under the terms and conditions of the BSD License
5 which accompanies this distribution. The full text of the license may be found at
6 http://opensource.org/licenses/bsd-license.php
8 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
9 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 Module Name: AtapiPassThru.h
22 #include <Protocol/ScsiPassThru.h>
23 #include <Protocol/ScsiPassThruExt.h>
24 #include <Protocol/PciIo.h>
25 #include <Protocol/DriverSupportedEfiVersion.h>
27 #include <Library/DebugLib.h>
28 #include <Library/UefiDriverEntryPoint.h>
29 #include <Library/BaseLib.h>
30 #include <Library/UefiLib.h>
31 #include <Library/BaseMemoryLib.h>
32 #include <Library/MemoryAllocationLib.h>
33 #include <Library/UefiBootServicesTableLib.h>
34 #include <Library/PcdLib.h>
35 #include <Library/DevicePathLib.h>
37 #include <IndustryStandard/Pci.h>
39 #define MAX_TARGET_ID 4
45 UINT16 Command
; /* when write */
46 UINT16 Status
; /* when read */
50 UINT16 Error
; /* when read */
51 UINT16 Feature
; /* when write */
52 } IDE_ERROR_OR_FEATURE
;
55 UINT16 AltStatus
; /* when read */
56 UINT16 DeviceControl
; /* when write */
57 } IDE_AltStatus_OR_DeviceControl
;
70 // Bit definitions in Programming Interface byte of the Class Code field
71 // in PCI IDE controller's Configuration Space
73 #define IDE_PRIMARY_OPERATING_MODE BIT0
74 #define IDE_PRIMARY_PROGRAMMABLE_INDICATOR BIT1
75 #define IDE_SECONDARY_OPERATING_MODE BIT2
76 #define IDE_SECONDARY_PROGRAMMABLE_INDICATOR BIT3
79 #define ATAPI_MAX_CHANNEL 2
86 IDE_ERROR_OR_FEATURE Reg1
;
92 IDE_CMD_OR_STATUS Reg
;
93 IDE_AltStatus_OR_DeviceControl Alt
;
97 #define ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE SIGNATURE_32 ('a', 's', 'p', 't')
102 EFI_SCSI_PASS_THRU_PROTOCOL ScsiPassThru
;
103 EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru
;
104 EFI_PCI_IO_PROTOCOL
*PciIo
;
105 UINT64 OriginalPciAttributes
;
107 // Local Data goes here
109 IDE_BASE_REGISTERS
*IoPort
;
110 IDE_BASE_REGISTERS AtapiIoPortRegisters
[2];
111 UINT32 LatestTargetId
;
113 } ATAPI_SCSI_PASS_THRU_DEV
;
116 // IDE registers' base addresses
119 UINT16 CommandBlockBaseAddr
;
120 UINT16 ControlBlockBaseAddr
;
121 } IDE_REGISTERS_BASE_ADDR
;
123 #define ATAPI_SCSI_PASS_THRU_DEV_FROM_THIS(a) \
125 ATAPI_SCSI_PASS_THRU_DEV, \
127 ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE \
130 #define ATAPI_EXT_SCSI_PASS_THRU_DEV_FROM_THIS(a) \
132 ATAPI_SCSI_PASS_THRU_DEV, \
134 ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE \
140 extern EFI_DRIVER_BINDING_PROTOCOL gAtapiScsiPassThruDriverBinding
;
141 extern EFI_COMPONENT_NAME_PROTOCOL gAtapiScsiPassThruComponentName
;
142 extern EFI_COMPONENT_NAME2_PROTOCOL gAtapiScsiPassThruComponentName2
;
143 extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gAtapiScsiPassThruDriverSupportedEfiVersion
;
146 // ATAPI Command op code
148 #define OP_INQUIRY 0x12
149 #define OP_LOAD_UNLOAD_CD 0xa6
150 #define OP_MECHANISM_STATUS 0xbd
151 #define OP_MODE_SELECT_10 0x55
152 #define OP_MODE_SENSE_10 0x5a
153 #define OP_PAUSE_RESUME 0x4b
154 #define OP_PLAY_AUDIO_10 0x45
155 #define OP_PLAY_AUDIO_MSF 0x47
156 #define OP_PLAY_CD 0xbc
157 #define OP_PLAY_CD_MSF 0xb4
158 #define OP_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
159 #define OP_READ_10 0x28
160 #define OP_READ_12 0xa8
161 #define OP_READ_CAPACITY 0x25
162 #define OP_READ_CD 0xbe
163 #define OP_READ_CD_MSF 0xb9
164 #define OP_READ_HEADER 0x44
165 #define OP_READ_SUB_CHANNEL 0x42
166 #define OP_READ_TOC 0x43
167 #define OP_REQUEST_SENSE 0x03
169 #define OP_SEEK_10 0x2b
170 #define OP_SET_CD_SPEED 0xbb
171 #define OP_STOPPLAY_SCAN 0x4e
172 #define OP_START_STOP_UNIT 0x1b
173 #define OP_TEST_UNIT_READY 0x00
175 #define OP_FORMAT_UNIT 0x04
176 #define OP_READ_FORMAT_CAPACITIES 0x23
177 #define OP_VERIFY 0x2f
178 #define OP_WRITE_10 0x2a
179 #define OP_WRITE_12 0xaa
180 #define OP_WRITE_AND_VERIFY 0x2e
185 #define ATAPI_SOFT_RESET_CMD 0x08
197 DATA_DIRECTION Direction
;
200 #define MAX_CHANNEL 2
202 #define ValidCdbLength(Len) ((Len) == 6 || (Len) == 10 || (Len) == 12) ? 1 : 0
205 // IDE registers bit definitions
207 // ATA Err Reg bitmap
209 #define BBK_ERR BIT7 ///< Bad block detected
210 #define UNC_ERR BIT6 ///< Uncorrectable Data
211 #define MC_ERR BIT5 ///< Media Change
212 #define IDNF_ERR BIT4 ///< ID Not Found
213 #define MCR_ERR BIT3 ///< Media Change Requested
214 #define ABRT_ERR BIT2 ///< Aborted Command
215 #define TK0NF_ERR BIT1 ///< Track 0 Not Found
216 #define AMNF_ERR BIT0 ///< Address Mark Not Found
219 // ATAPI Err Reg bitmap
221 #define SENSE_KEY_ERR (BIT7 | BIT6 | BIT5 | BIT4)
222 #define EOM_ERR BIT1 ///< End of Media Detected
223 #define ILI_ERR BIT0 ///< Illegal Length Indication
228 #define LBA_MODE BIT6
243 #define BSY BIT7 ///< Controller Busy
244 #define DRDY BIT6 ///< Drive Ready
245 #define DWF BIT5 ///< Drive Write Fault
246 #define DSC BIT4 ///< Disk Seek Complete
247 #define DRQ BIT3 ///< Data Request
248 #define CORR BIT2 ///< Corrected Data
249 #define IDX BIT1 ///< Index
250 #define ERR BIT0 ///< Error
251 #define CHECK BIT0 ///< Check bit for ATAPI Status Reg
254 // Device Control Reg
256 #define SRST BIT2 ///< Software Reset
257 #define IEN_L BIT1 ///< Interrupt Enable
260 // ATAPI Feature Register
266 // ATAPI Interrupt Reason Reson Reg (ATA Sector Count Register)
272 #define PACKET_CMD 0xA0
274 #define DEFAULT_CMD (0xa0)
276 // default content of device control register, disable INT
278 #define DEFAULT_CTL (0x0a)
279 #define MAX_ATAPI_BYTE_COUNT (0xfffe)
282 // function prototype
287 AtapiScsiPassThruDriverBindingSupported (
288 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
289 IN EFI_HANDLE Controller
,
290 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
295 AtapiScsiPassThruDriverBindingStart (
296 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
297 IN EFI_HANDLE Controller
,
298 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
303 AtapiScsiPassThruDriverBindingStop (
304 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
305 IN EFI_HANDLE Controller
,
306 IN UINTN NumberOfChildren
,
307 IN EFI_HANDLE
*ChildHandleBuffer
311 // EFI Component Name Functions
314 Retrieves a Unicode string that is the user readable name of the driver.
316 This function retrieves the user readable name of a driver in the form of a
317 Unicode string. If the driver specified by This has a user readable name in
318 the language specified by Language, then a pointer to the driver name is
319 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
320 by This does not support the language specified by Language,
321 then EFI_UNSUPPORTED is returned.
323 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
324 EFI_COMPONENT_NAME_PROTOCOL instance.
326 @param Language[in] A pointer to a Null-terminated ASCII string
327 array indicating the language. This is the
328 language of the driver name that the caller is
329 requesting, and it must match one of the
330 languages specified in SupportedLanguages. The
331 number of languages supported by a driver is up
332 to the driver writer. Language is specified
333 in RFC 4646 or ISO 639-2 language code format.
335 @param DriverName[out] A pointer to the Unicode string to return.
336 This Unicode string is the name of the
337 driver specified by This in the language
338 specified by Language.
340 @retval EFI_SUCCESS The Unicode string for the Driver specified by
341 This and the language specified by Language was
342 returned in DriverName.
344 @retval EFI_INVALID_PARAMETER Language is NULL.
346 @retval EFI_INVALID_PARAMETER DriverName is NULL.
348 @retval EFI_UNSUPPORTED The driver specified by This does not support
349 the language specified by Language.
354 AtapiScsiPassThruComponentNameGetDriverName (
355 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
357 OUT CHAR16
**DriverName
362 Retrieves a Unicode string that is the user readable name of the controller
363 that is being managed by a driver.
365 This function retrieves the user readable name of the controller specified by
366 ControllerHandle and ChildHandle in the form of a Unicode string. If the
367 driver specified by This has a user readable name in the language specified by
368 Language, then a pointer to the controller name is returned in ControllerName,
369 and EFI_SUCCESS is returned. If the driver specified by This is not currently
370 managing the controller specified by ControllerHandle and ChildHandle,
371 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
372 support the language specified by Language, then EFI_UNSUPPORTED is returned.
374 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
375 EFI_COMPONENT_NAME_PROTOCOL instance.
377 @param ControllerHandle[in] The handle of a controller that the driver
378 specified by This is managing. This handle
379 specifies the controller whose name is to be
382 @param ChildHandle[in] The handle of the child controller to retrieve
383 the name of. This is an optional parameter that
384 may be NULL. It will be NULL for device
385 drivers. It will also be NULL for a bus drivers
386 that wish to retrieve the name of the bus
387 controller. It will not be NULL for a bus
388 driver that wishes to retrieve the name of a
391 @param Language[in] A pointer to a Null-terminated ASCII string
392 array indicating the language. This is the
393 language of the driver name that the caller is
394 requesting, and it must match one of the
395 languages specified in SupportedLanguages. The
396 number of languages supported by a driver is up
397 to the driver writer. Language is specified in
398 RFC 4646 or ISO 639-2 language code format.
400 @param ControllerName[out] A pointer to the Unicode string to return.
401 This Unicode string is the name of the
402 controller specified by ControllerHandle and
403 ChildHandle in the language specified by
404 Language from the point of view of the driver
407 @retval EFI_SUCCESS The Unicode string for the user readable name in
408 the language specified by Language for the
409 driver specified by This was returned in
412 @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
414 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
417 @retval EFI_INVALID_PARAMETER Language is NULL.
419 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
421 @retval EFI_UNSUPPORTED The driver specified by This is not currently
422 managing the controller specified by
423 ControllerHandle and ChildHandle.
425 @retval EFI_UNSUPPORTED The driver specified by This does not support
426 the language specified by Language.
431 AtapiScsiPassThruComponentNameGetControllerName (
432 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
433 IN EFI_HANDLE ControllerHandle
,
434 IN EFI_HANDLE ChildHandle OPTIONAL
,
436 OUT CHAR16
**ControllerName
442 AtapiScsiPassThruDriverEntryPoint (
443 IN EFI_HANDLE ImageHandle
,
444 IN EFI_SYSTEM_TABLE
*SystemTable
450 Entry point for EFI drivers.
454 ImageHandle - EFI_HANDLE
455 SystemTable - EFI_SYSTEM_TABLE
466 RegisterAtapiScsiPassThru (
467 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
468 IN EFI_HANDLE Controller
,
469 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
470 IN UINT64 OriginalPciAttributes
475 Attaches SCSI Pass Thru Protocol for specified IDE channel.
478 This - Protocol instance pointer.
479 Controller - Parent device handle to the IDE channel.
480 PciIo - PCI I/O protocol attached on the "Controller".
483 Always return EFI_SUCCESS unless installing SCSI Pass Thru Protocol failed.
490 AtapiScsiPassThruFunction (
491 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
494 IN OUT EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
,
495 IN EFI_EVENT Event OPTIONAL
501 Implements EFI_SCSI_PASS_THRU_PROTOCOL.PassThru() function.
505 This: The EFI_SCSI_PASS_THRU_PROTOCOL instance.
506 Target: The Target ID of the ATAPI device to send the SCSI
507 Request Packet. To ATAPI devices attached on an IDE
508 Channel, Target ID 0 indicates Master device;Target
509 ID 1 indicates Slave device.
510 Lun: The LUN of the ATAPI device to send the SCSI Request
511 Packet. To the ATAPI device, Lun is always 0.
512 Packet: The SCSI Request Packet to send to the ATAPI device
513 specified by Target and Lun.
514 Event: If non-blocking I/O is not supported then Event is ignored,
515 and blocking I/O is performed.
516 If Event is NULL, then blocking I/O is performed.
517 If Event is not NULL and non blocking I/O is supported,
518 then non-blocking I/O is performed, and Event will be signaled
519 when the SCSI Request Packet completes.
530 AtapiScsiPassThruGetNextDevice (
531 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
532 IN OUT UINT32
*Target
,
539 Used to retrieve the list of legal Target IDs for SCSI devices
544 This - Protocol instance pointer.
545 Target - On input, a pointer to the Target ID of a SCSI
546 device present on the SCSI channel. On output,
547 a pointer to the Target ID of the next SCSI device
548 present on a SCSI channel. An input value of
549 0xFFFFFFFF retrieves the Target ID of the first
550 SCSI device present on a SCSI channel.
551 Lun - On input, a pointer to the LUN of a SCSI device
552 present on the SCSI channel. On output, a pointer
553 to the LUN of the next SCSI device present on
557 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
558 on the SCSI channel was returned in Target and Lun.
559 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
560 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
561 returned on a previous call to GetNextDevice().
568 AtapiScsiPassThruBuildDevicePath (
569 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
572 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
578 Used to allocate and build a device path node for a SCSI device
579 on a SCSI channel. Would not build device path for a SCSI Host Controller.
583 This - Protocol instance pointer.
584 Target - The Target ID of the SCSI device for which
585 a device path node is to be allocated and built.
586 Lun - The LUN of the SCSI device for which a device
587 path node is to be allocated and built.
588 DevicePath - A pointer to a single device path node that
589 describes the SCSI device specified by
590 Target and Lun. This function is responsible
591 for allocating the buffer DevicePath with the boot
592 service AllocatePool(). It is the caller's
593 responsibility to free DevicePath when the caller
594 is finished with DevicePath.
596 EFI_SUCCESS - The device path node that describes the SCSI device
597 specified by Target and Lun was allocated and
598 returned in DevicePath.
599 EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
600 not exist on the SCSI channel.
601 EFI_INVALID_PARAMETER - DevicePath is NULL.
602 EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
610 AtapiScsiPassThruGetTargetLun (
611 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
612 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
620 Used to translate a device path node to a Target ID and LUN.
624 This - Protocol instance pointer.
625 DevicePath - A pointer to the device path node that
626 describes a SCSI device on the SCSI channel.
627 Target - A pointer to the Target ID of a SCSI device
629 Lun - A pointer to the LUN of a SCSI device on
633 EFI_SUCCESS - DevicePath was successfully translated to a
634 Target ID and LUN, and they were returned
636 EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.
637 EFI_UNSUPPORTED - This driver does not support the device path
638 node type in DevicePath.
639 EFI_NOT_FOUND - A valid translation from DevicePath to a
640 Target ID and LUN does not exist.
647 AtapiScsiPassThruResetChannel (
648 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
654 Resets a SCSI channel.This operation resets all the
655 SCSI devices connected to the SCSI channel.
659 This - Protocol instance pointer.
663 EFI_SUCCESS - The SCSI channel was reset.
664 EFI_UNSUPPORTED - The SCSI channel does not support
665 a channel reset operation.
666 EFI_DEVICE_ERROR - A device error occurred while
667 attempting to reset the SCSI channel.
668 EFI_TIMEOUT - A timeout occurred while attempting
669 to reset the SCSI channel.
676 AtapiScsiPassThruResetTarget (
677 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
685 Resets a SCSI device that is connected to a SCSI channel.
689 This - Protocol instance pointer.
690 Target - The Target ID of the SCSI device to reset.
691 Lun - The LUN of the SCSI device to reset.
695 EFI_SUCCESS - The SCSI device specified by Target and
697 EFI_UNSUPPORTED - The SCSI channel does not support a target
699 EFI_INVALID_PARAMETER - Target or Lun are invalid.
700 EFI_DEVICE_ERROR - A device error occurred while attempting
701 to reset the SCSI device specified by Target
703 EFI_TIMEOUT - A timeout occurred while attempting to reset
704 the SCSI device specified by Target and Lun.
711 AtapiExtScsiPassThruFunction (
712 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
715 IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
,
716 IN EFI_EVENT Event OPTIONAL
722 Implements EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() function.
726 This: The EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
727 Target: The Target ID of the ATAPI device to send the SCSI
728 Request Packet. To ATAPI devices attached on an IDE
729 Channel, Target ID 0 indicates Master device;Target
730 ID 1 indicates Slave device.
731 Lun: The LUN of the ATAPI device to send the SCSI Request
732 Packet. To the ATAPI device, Lun is always 0.
733 Packet: The SCSI Request Packet to send to the ATAPI device
734 specified by Target and Lun.
735 Event: If non-blocking I/O is not supported then Event is ignored,
736 and blocking I/O is performed.
737 If Event is NULL, then blocking I/O is performed.
738 If Event is not NULL and non blocking I/O is supported,
739 then non-blocking I/O is performed, and Event will be signaled
740 when the SCSI Request Packet completes.
751 AtapiExtScsiPassThruGetNextTargetLun (
752 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
753 IN OUT UINT8
**Target
,
760 Used to retrieve the list of legal Target IDs for SCSI devices
765 This - Protocol instance pointer.
766 Target - On input, a pointer to the Target ID of a SCSI
767 device present on the SCSI channel. On output,
768 a pointer to the Target ID of the next SCSI device
769 present on a SCSI channel. An input value of
770 0xFFFFFFFF retrieves the Target ID of the first
771 SCSI device present on a SCSI channel.
772 Lun - On input, a pointer to the LUN of a SCSI device
773 present on the SCSI channel. On output, a pointer
774 to the LUN of the next SCSI device present on
778 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
779 on the SCSI channel was returned in Target and Lun.
780 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
781 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
782 returned on a previous call to GetNextDevice().
789 AtapiExtScsiPassThruBuildDevicePath (
790 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
793 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
799 Used to allocate and build a device path node for a SCSI device
800 on a SCSI channel. Would not build device path for a SCSI Host Controller.
804 This - Protocol instance pointer.
805 Target - The Target ID of the SCSI device for which
806 a device path node is to be allocated and built.
807 Lun - The LUN of the SCSI device for which a device
808 path node is to be allocated and built.
809 DevicePath - A pointer to a single device path node that
810 describes the SCSI device specified by
811 Target and Lun. This function is responsible
812 for allocating the buffer DevicePath with the boot
813 service AllocatePool(). It is the caller's
814 responsibility to free DevicePath when the caller
815 is finished with DevicePath.
817 EFI_SUCCESS - The device path node that describes the SCSI device
818 specified by Target and Lun was allocated and
819 returned in DevicePath.
820 EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
821 not exist on the SCSI channel.
822 EFI_INVALID_PARAMETER - DevicePath is NULL.
823 EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
831 AtapiExtScsiPassThruGetTargetLun (
832 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
833 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
841 Used to translate a device path node to a Target ID and LUN.
845 This - Protocol instance pointer.
846 DevicePath - A pointer to the device path node that
847 describes a SCSI device on the SCSI channel.
848 Target - A pointer to the Target ID of a SCSI device
850 Lun - A pointer to the LUN of a SCSI device on
854 EFI_SUCCESS - DevicePath was successfully translated to a
855 Target ID and LUN, and they were returned
857 EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.
858 EFI_UNSUPPORTED - This driver does not support the device path
859 node type in DevicePath.
860 EFI_NOT_FOUND - A valid translation from DevicePath to a
861 Target ID and LUN does not exist.
868 AtapiExtScsiPassThruResetChannel (
869 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
875 Resets a SCSI channel.This operation resets all the
876 SCSI devices connected to the SCSI channel.
880 This - Protocol instance pointer.
884 EFI_SUCCESS - The SCSI channel was reset.
885 EFI_UNSUPPORTED - The SCSI channel does not support
886 a channel reset operation.
887 EFI_DEVICE_ERROR - A device error occurred while
888 attempting to reset the SCSI channel.
889 EFI_TIMEOUT - A timeout occurred while attempting
890 to reset the SCSI channel.
897 AtapiExtScsiPassThruResetTarget (
898 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
906 Resets a SCSI device that is connected to a SCSI channel.
910 This - Protocol instance pointer.
911 Target - The Target ID of the SCSI device to reset.
912 Lun - The LUN of the SCSI device to reset.
916 EFI_SUCCESS - The SCSI device specified by Target and
918 EFI_UNSUPPORTED - The SCSI channel does not support a target
920 EFI_INVALID_PARAMETER - Target or Lun are invalid.
921 EFI_DEVICE_ERROR - A device error occurred while attempting
922 to reset the SCSI device specified by Target
924 EFI_TIMEOUT - A timeout occurred while attempting to reset
925 the SCSI device specified by Target and Lun.
932 AtapiExtScsiPassThruGetNextTarget (
933 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
934 IN OUT UINT8
**Target
939 Used to retrieve the list of legal Target IDs for SCSI devices
943 This - Protocol instance pointer.
944 Target - On input, a pointer to the Target ID of a SCSI
945 device present on the SCSI channel. On output,
946 a pointer to the Target ID of the next SCSI device
947 present on a SCSI channel. An input value of
948 0xFFFFFFFF retrieves the Target ID of the first
949 SCSI device present on a SCSI channel.
950 Lun - On input, a pointer to the LUN of a SCSI device
951 present on the SCSI channel. On output, a pointer
952 to the LUN of the next SCSI device present on
956 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
957 on the SCSI channel was returned in Target and Lun.
958 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
959 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
960 returned on a previous call to GetNextDevice().
966 CheckSCSIRequestPacket (
967 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
973 Checks the parameters in the SCSI Request Packet to make sure
974 they are valid for a SCSI Pass Thru request.
978 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
988 SubmitBlockingIoCommand (
989 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
991 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
997 Performs blocking I/O request.
1001 AtapiScsiPrivate: Private data structure for the specified channel.
1002 Target: The Target ID of the ATAPI device to send the SCSI
1003 Request Packet. To ATAPI devices attached on an IDE
1004 Channel, Target ID 0 indicates Master device;Target
1005 ID 1 indicates Slave device.
1006 Packet: The SCSI Request Packet to send to the ATAPI device
1007 specified by Target.
1016 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1020 Routine Description:
1022 Checks the requested SCSI command:
1023 Is it supported by this driver?
1024 Is the Data transfer direction reasonable?
1028 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1038 CheckExtSCSIRequestPacket (
1039 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1043 Routine Description:
1045 Checks the parameters in the SCSI Request Packet to make sure
1046 they are valid for a SCSI Pass Thru request.
1050 Packet - The pointer of EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1062 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1066 Routine Description:
1068 Checks the requested SCSI command:
1069 Is it supported by this driver?
1070 Is the Data transfer direction reasonable?
1074 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1084 SubmitExtBlockingIoCommand (
1085 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1087 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1091 Routine Description:
1093 Performs blocking I/O request.
1097 AtapiScsiPrivate: Private data structure for the specified channel.
1098 Target: The Target ID of the ATAPI device to send the SCSI
1099 Request Packet. To ATAPI devices attached on an IDE
1100 Channel, Target ID 0 indicates Master device;Target
1101 ID 1 indicates Slave device.
1102 Packet: The SCSI Request Packet to send to the ATAPI device
1103 specified by Target.
1111 RequestSenseCommand (
1112 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1116 UINT8
*SenseDataLength
1120 Routine Description:
1122 Sumbit request sense command
1126 AtapiScsiPrivate - The pionter of ATAPI_SCSI_PASS_THRU_DEV
1127 Target - The target ID
1128 Timeout - The time to complete the command
1129 SenseData - The buffer to fill in sense data
1130 SenseDataLength - The length of buffer
1140 AtapiPacketCommand (
1141 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1143 UINT8
*PacketCommand
,
1146 DATA_DIRECTION Direction
,
1147 UINT64 TimeOutInMicroSeconds
1151 Routine Description:
1153 Submits ATAPI command packet to the specified ATAPI device.
1157 AtapiScsiPrivate: Private data structure for the specified channel.
1158 Target: The Target ID of the ATAPI device to send the SCSI
1159 Request Packet. To ATAPI devices attached on an IDE
1160 Channel, Target ID 0 indicates Master device;Target
1161 ID 1 indicates Slave device.
1162 PacketCommand: Points to the ATAPI command packet.
1163 Buffer: Points to the transferred data.
1164 ByteCount: When input,indicates the buffer size; when output,
1165 indicates the actually transferred data size.
1166 Direction: Indicates the data transfer direction.
1167 TimeoutInMicroSeconds:
1168 The timeout, in micro second units, to use for the
1169 execution of this ATAPI command.
1170 A TimeoutInMicroSeconds value of 0 means that
1171 this function will wait indefinitely for the ATAPI
1173 If TimeoutInMicroSeconds is greater than zero, then
1174 this function will return EFI_TIMEOUT if the time
1175 required to execute the ATAPI command is greater
1176 than TimeoutInMicroSeconds.
1188 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1193 Routine Description:
1195 Read one byte from a specified I/O port.
1199 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1212 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1217 Routine Description:
1219 Read one word from a specified I/O port.
1223 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1236 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1242 Routine Description:
1244 Write one byte to a specified I/O port.
1248 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1250 Data - The data to write
1262 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1268 Routine Description:
1270 Write one word to a specified I/O port.
1274 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1276 Data - The data to write
1287 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1288 UINT64 TimeOutInMicroSeconds
1292 Routine Description:
1294 Check whether DRQ is clear in the Status Register. (BSY must also be cleared)
1295 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1296 DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1301 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1302 TimeoutInMicroSeconds - The time to wait for
1313 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1314 UINT64 TimeOutInMicroSeconds
1318 Routine Description:
1320 Check whether DRQ is clear in the Alternate Status Register.
1321 (BSY must also be cleared).If TimeoutInMicroSeconds is zero, this routine should
1322 wait infinitely for DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1327 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1328 TimeoutInMicroSeconds - The time to wait for
1339 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1340 UINT64 TimeOutInMicroSeconds
1344 Routine Description:
1346 Check whether DRQ is ready in the Status Register. (BSY must also be cleared)
1347 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1348 DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1353 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1354 TimeoutInMicroSeconds - The time to wait for
1365 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1366 UINT64 TimeOutInMicroSeconds
1370 Routine Description:
1372 Check whether DRQ is ready in the Alternate Status Register.
1373 (BSY must also be cleared)
1374 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1375 DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1380 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1381 TimeoutInMicroSeconds - The time to wait for
1391 StatusWaitForBSYClear (
1392 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1393 UINT64 TimeoutInMicroSeconds
1397 Routine Description:
1399 Check whether BSY is clear in the Status Register.
1400 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1401 BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1406 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1407 TimeoutInMicroSeconds - The time to wait for
1417 AltStatusWaitForBSYClear (
1418 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1419 UINT64 TimeoutInMicroSeconds
1423 Routine Description:
1425 Check whether BSY is clear in the Alternate Status Register.
1426 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1427 BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1432 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1433 TimeoutInMicroSeconds - The time to wait for
1444 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1445 UINT64 TimeoutInMicroSeconds
1449 Routine Description:
1451 Check whether DRDY is ready in the Status Register.
1452 (BSY must also be cleared)
1453 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1454 DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1459 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1460 TimeoutInMicroSeconds - The time to wait for
1470 AltStatusDRDYReady (
1471 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1472 UINT64 TimeoutInMicroSeconds
1476 Routine Description:
1478 Check whether DRDY is ready in the Alternate Status Register.
1479 (BSY must also be cleared)
1480 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1481 DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1486 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1487 TimeoutInMicroSeconds - The time to wait for
1497 AtapiPassThruPioReadWriteData (
1498 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1501 DATA_DIRECTION Direction
,
1502 UINT64 TimeOutInMicroSeconds
1506 Routine Description:
1508 Performs data transfer between ATAPI device and host after the
1509 ATAPI command packet is sent.
1513 AtapiScsiPrivate: Private data structure for the specified channel.
1514 Buffer: Points to the transferred data.
1515 ByteCount: When input,indicates the buffer size; when output,
1516 indicates the actually transferred data size.
1517 Direction: Indicates the data transfer direction.
1518 TimeoutInMicroSeconds:
1519 The timeout, in micro second units, to use for the
1520 execution of this ATAPI command.
1521 A TimeoutInMicroSeconds value of 0 means that
1522 this function will wait indefinitely for the ATAPI
1524 If TimeoutInMicroSeconds is greater than zero, then
1525 this function will return EFI_TIMEOUT if the time
1526 required to execute the ATAPI command is greater
1527 than TimeoutInMicroSeconds.
1536 AtapiPassThruCheckErrorStatus (
1537 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
1541 Routine Description:
1543 Check Error Register for Error Information.
1547 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1558 GetIdeRegistersBaseAddr (
1559 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1560 OUT IDE_REGISTERS_BASE_ADDR
*IdeRegsBaseAddr
1564 Routine Description:
1565 Get IDE IO port registers' base addresses by mode. In 'Compatibility' mode,
1566 use fixed addresses. In Native-PCI mode, get base addresses from BARs in
1567 the PCI IDE controller's Configuration Space.
1570 PciIo - Pointer to the EFI_PCI_IO_PROTOCOL instance
1571 IdeRegsBaseAddr - Pointer to IDE_REGISTERS_BASE_ADDR to
1572 receive IDE IO port registers' base addresses
1583 InitAtapiIoPortRegisters (
1584 IN ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1585 IN IDE_REGISTERS_BASE_ADDR
*IdeRegsBaseAddr
1589 Routine Description:
1591 Initialize each Channel's Base Address of CommandBlock and ControlBlock.
1595 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1596 IdeRegsBaseAddr - The pointer of IDE_REGISTERS_BASE_ADDR
1606 Installs Scsi Pass Thru and/or Ext Scsi Pass Thru
1607 protocols based on feature flags.
1609 @param Controller The controller handle to
1610 install these protocols on.
1611 @param AtapiScsiPrivate A pointer to the protocol private
1614 @retval EFI_SUCCESS The installation succeeds.
1615 @retval other The installation fails.
1619 InstallScsiPassThruProtocols (
1620 IN EFI_HANDLE
*ControllerHandle
,
1621 IN ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate