2 Copyright (c) 2006, Intel Corporation
3 All rights reserved. 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 <IndustryStandard/pci22.h>
40 #define bit(a) (1 << (a))
42 #define MAX_TARGET_ID 4
48 UINT16 Command
; /* when write */
49 UINT16 Status
; /* when read */
53 UINT16 Error
; /* when read */
54 UINT16 Feature
; /* when write */
55 } IDE_ERROR_OR_FEATURE
;
58 UINT16 AltStatus
; /* when read */
59 UINT16 DeviceControl
; /* when write */
60 } IDE_AltStatus_OR_DeviceControl
;
73 // Bit definitions in Programming Interface byte of the Class Code field
74 // in PCI IDE controller's Configuration Space
76 #define IDE_PRIMARY_OPERATING_MODE BIT0
77 #define IDE_PRIMARY_PROGRAMMABLE_INDICATOR BIT1
78 #define IDE_SECONDARY_OPERATING_MODE BIT2
79 #define IDE_SECONDARY_PROGRAMMABLE_INDICATOR BIT3
82 #define ATAPI_MAX_CHANNEL 2
89 IDE_ERROR_OR_FEATURE Reg1
;
95 IDE_CMD_OR_STATUS Reg
;
96 IDE_AltStatus_OR_DeviceControl Alt
;
100 #define ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE EFI_SIGNATURE_32 ('a', 's', 'p', 't')
105 EFI_SCSI_PASS_THRU_PROTOCOL ScsiPassThru
;
106 EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru
;
107 EFI_PCI_IO_PROTOCOL
*PciIo
;
108 UINT64 OriginalPciAttributes
;
110 // Local Data goes here
112 IDE_BASE_REGISTERS
*IoPort
;
113 IDE_BASE_REGISTERS AtapiIoPortRegisters
[2];
114 UINT32 LatestTargetId
;
116 } ATAPI_SCSI_PASS_THRU_DEV
;
119 // IDE registers' base addresses
122 UINT16 CommandBlockBaseAddr
;
123 UINT16 ControlBlockBaseAddr
;
124 } IDE_REGISTERS_BASE_ADDR
;
126 #define ATAPI_SCSI_PASS_THRU_DEV_FROM_THIS(a) \
128 ATAPI_SCSI_PASS_THRU_DEV, \
130 ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE \
133 #define ATAPI_EXT_SCSI_PASS_THRU_DEV_FROM_THIS(a) \
135 ATAPI_SCSI_PASS_THRU_DEV, \
137 ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE \
143 extern EFI_DRIVER_BINDING_PROTOCOL gAtapiScsiPassThruDriverBinding
;
144 extern EFI_COMPONENT_NAME_PROTOCOL gAtapiScsiPassThruComponentName
;
145 extern EFI_COMPONENT_NAME2_PROTOCOL gAtapiScsiPassThruComponentName2
;
146 extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gAtapiScsiPassThruDriverSupportedEfiVersion
;
149 // ATAPI Command op code
151 #define OP_INQUIRY 0x12
152 #define OP_LOAD_UNLOAD_CD 0xa6
153 #define OP_MECHANISM_STATUS 0xbd
154 #define OP_MODE_SELECT_10 0x55
155 #define OP_MODE_SENSE_10 0x5a
156 #define OP_PAUSE_RESUME 0x4b
157 #define OP_PLAY_AUDIO_10 0x45
158 #define OP_PLAY_AUDIO_MSF 0x47
159 #define OP_PLAY_CD 0xbc
160 #define OP_PLAY_CD_MSF 0xb4
161 #define OP_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
162 #define OP_READ_10 0x28
163 #define OP_READ_12 0xa8
164 #define OP_READ_CAPACITY 0x25
165 #define OP_READ_CD 0xbe
166 #define OP_READ_CD_MSF 0xb9
167 #define OP_READ_HEADER 0x44
168 #define OP_READ_SUB_CHANNEL 0x42
169 #define OP_READ_TOC 0x43
170 #define OP_REQUEST_SENSE 0x03
172 #define OP_SEEK_10 0x2b
173 #define OP_SET_CD_SPEED 0xbb
174 #define OP_STOPPLAY_SCAN 0x4e
175 #define OP_START_STOP_UNIT 0x1b
176 #define OP_TEST_UNIT_READY 0x00
178 #define OP_FORMAT_UNIT 0x04
179 #define OP_READ_FORMAT_CAPACITIES 0x23
180 #define OP_VERIFY 0x2f
181 #define OP_WRITE_10 0x2a
182 #define OP_WRITE_12 0xaa
183 #define OP_WRITE_AND_VERIFY 0x2e
188 #define ATAPI_SOFT_RESET_CMD 0x08
200 DATA_DIRECTION Direction
;
203 #define MAX_CHANNEL 2
205 #define ValidCdbLength(Len) ((Len) == 6 || (Len) == 10 || (Len) == 12) ? 1 : 0
208 // IDE registers bit definitions
210 // ATA Err Reg bitmap
212 #define BBK_ERR bit (7) ///< Bad block detected
213 #define UNC_ERR bit (6) ///< Uncorrectable Data
214 #define MC_ERR bit (5) ///< Media Change
215 #define IDNF_ERR bit (4) ///< ID Not Found
216 #define MCR_ERR bit (3) ///< Media Change Requested
217 #define ABRT_ERR bit (2) ///< Aborted Command
218 #define TK0NF_ERR bit (1) ///< Track 0 Not Found
219 #define AMNF_ERR bit (0) ///< Address Mark Not Found
222 // ATAPI Err Reg bitmap
224 #define SENSE_KEY_ERR (bit (7) | bit (6) | bit (5) | bit (4))
225 #define EOM_ERR bit (1) ///< End of Media Detected
226 #define ILI_ERR bit (0) ///< Illegal Length Indication
231 #define LBA_MODE bit (6)
246 #define BSY bit (7) ///< Controller Busy
247 #define DRDY bit (6) ///< Drive Ready
248 #define DWF bit (5) ///< Drive Write Fault
249 #define DSC bit (4) ///< Disk Seek Complete
250 #define DRQ bit (3) ///< Data Request
251 #define CORR bit (2) ///< Corrected Data
252 #define IDX bit (1) ///< Index
253 #define ERR bit (0) ///< Error
254 #define CHECK bit (0) ///< Check bit for ATAPI Status Reg
257 // Device Control Reg
259 #define SRST bit (2) ///< Software Reset
260 #define IEN_L bit (1) ///< Interrupt Enable
263 // ATAPI Feature Register
265 #define OVERLAP bit (1)
269 // ATAPI Interrupt Reason Reson Reg (ATA Sector Count Register)
271 #define RELEASE bit (2)
275 #define PACKET_CMD 0xA0
277 #define DEFAULT_CMD (0xa0)
279 // default content of device control register, disable INT
281 #define DEFAULT_CTL (0x0a)
282 #define MAX_ATAPI_BYTE_COUNT (0xfffe)
285 // function prototype
290 AtapiScsiPassThruDriverBindingSupported (
291 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
292 IN EFI_HANDLE Controller
,
293 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
298 AtapiScsiPassThruDriverBindingStart (
299 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
300 IN EFI_HANDLE Controller
,
301 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
306 AtapiScsiPassThruDriverBindingStop (
307 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
308 IN EFI_HANDLE Controller
,
309 IN UINTN NumberOfChildren
,
310 IN EFI_HANDLE
*ChildHandleBuffer
314 // EFI Component Name Functions
317 Retrieves a Unicode string that is the user readable name of the driver.
319 This function retrieves the user readable name of a driver in the form of a
320 Unicode string. If the driver specified by This has a user readable name in
321 the language specified by Language, then a pointer to the driver name is
322 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
323 by This does not support the language specified by Language,
324 then EFI_UNSUPPORTED is returned.
326 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
327 EFI_COMPONENT_NAME_PROTOCOL instance.
329 @param Language[in] A pointer to a Null-terminated ASCII string
330 array indicating the language. This is the
331 language of the driver name that the caller is
332 requesting, and it must match one of the
333 languages specified in SupportedLanguages. The
334 number of languages supported by a driver is up
335 to the driver writer. Language is specified
336 in RFC 3066 or ISO 639-2 language code format.
338 @param DriverName[out] A pointer to the Unicode string to return.
339 This Unicode string is the name of the
340 driver specified by This in the language
341 specified by Language.
343 @retval EFI_SUCCESS The Unicode string for the Driver specified by
344 This and the language specified by Language was
345 returned in DriverName.
347 @retval EFI_INVALID_PARAMETER Language is NULL.
349 @retval EFI_INVALID_PARAMETER DriverName is NULL.
351 @retval EFI_UNSUPPORTED The driver specified by This does not support
352 the language specified by Language.
357 AtapiScsiPassThruComponentNameGetDriverName (
358 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
360 OUT CHAR16
**DriverName
365 Retrieves a Unicode string that is the user readable name of the controller
366 that is being managed by a driver.
368 This function retrieves the user readable name of the controller specified by
369 ControllerHandle and ChildHandle in the form of a Unicode string. If the
370 driver specified by This has a user readable name in the language specified by
371 Language, then a pointer to the controller name is returned in ControllerName,
372 and EFI_SUCCESS is returned. If the driver specified by This is not currently
373 managing the controller specified by ControllerHandle and ChildHandle,
374 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
375 support the language specified by Language, then EFI_UNSUPPORTED is returned.
377 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
378 EFI_COMPONENT_NAME_PROTOCOL instance.
380 @param ControllerHandle[in] The handle of a controller that the driver
381 specified by This is managing. This handle
382 specifies the controller whose name is to be
385 @param ChildHandle[in] The handle of the child controller to retrieve
386 the name of. This is an optional parameter that
387 may be NULL. It will be NULL for device
388 drivers. It will also be NULL for a bus drivers
389 that wish to retrieve the name of the bus
390 controller. It will not be NULL for a bus
391 driver that wishes to retrieve the name of a
394 @param Language[in] A pointer to a Null-terminated ASCII string
395 array indicating the language. This is the
396 language of the driver name that the caller is
397 requesting, and it must match one of the
398 languages specified in SupportedLanguages. The
399 number of languages supported by a driver is up
400 to the driver writer. Language is specified in
401 RFC 3066 or ISO 639-2 language code format.
403 @param ControllerName[out] A pointer to the Unicode string to return.
404 This Unicode string is the name of the
405 controller specified by ControllerHandle and
406 ChildHandle in the language specified by
407 Language from the point of view of the driver
410 @retval EFI_SUCCESS The Unicode string for the user readable name in
411 the language specified by Language for the
412 driver specified by This was returned in
415 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
417 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
420 @retval EFI_INVALID_PARAMETER Language is NULL.
422 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
424 @retval EFI_UNSUPPORTED The driver specified by This is not currently
425 managing the controller specified by
426 ControllerHandle and ChildHandle.
428 @retval EFI_UNSUPPORTED The driver specified by This does not support
429 the language specified by Language.
434 AtapiScsiPassThruComponentNameGetControllerName (
435 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
436 IN EFI_HANDLE ControllerHandle
,
437 IN EFI_HANDLE ChildHandle OPTIONAL
,
439 OUT CHAR16
**ControllerName
445 AtapiScsiPassThruDriverEntryPoint (
446 IN EFI_HANDLE ImageHandle
,
447 IN EFI_SYSTEM_TABLE
*SystemTable
453 Entry point for EFI drivers.
457 ImageHandle - EFI_HANDLE
458 SystemTable - EFI_SYSTEM_TABLE
469 RegisterAtapiScsiPassThru (
470 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
471 IN EFI_HANDLE Controller
,
472 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
473 IN UINT64 OriginalPciAttributes
478 Attaches SCSI Pass Thru Protocol for specified IDE channel.
481 This - Protocol instance pointer.
482 Controller - Parent device handle to the IDE channel.
483 PciIo - PCI I/O protocol attached on the "Controller".
486 Always return EFI_SUCCESS unless installing SCSI Pass Thru Protocol failed.
493 AtapiScsiPassThruFunction (
494 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
497 IN OUT EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
,
498 IN EFI_EVENT Event OPTIONAL
504 Implements EFI_SCSI_PASS_THRU_PROTOCOL.PassThru() function.
508 This: The EFI_SCSI_PASS_THRU_PROTOCOL instance.
509 Target: The Target ID of the ATAPI device to send the SCSI
510 Request Packet. To ATAPI devices attached on an IDE
511 Channel, Target ID 0 indicates Master device;Target
512 ID 1 indicates Slave device.
513 Lun: The LUN of the ATAPI device to send the SCSI Request
514 Packet. To the ATAPI device, Lun is always 0.
515 Packet: The SCSI Request Packet to send to the ATAPI device
516 specified by Target and Lun.
517 Event: If non-blocking I/O is not supported then Event is ignored,
518 and blocking I/O is performed.
519 If Event is NULL, then blocking I/O is performed.
520 If Event is not NULL and non blocking I/O is supported,
521 then non-blocking I/O is performed, and Event will be signaled
522 when the SCSI Request Packet completes.
533 AtapiScsiPassThruGetNextDevice (
534 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
535 IN OUT UINT32
*Target
,
542 Used to retrieve the list of legal Target IDs for SCSI devices
547 This - Protocol instance pointer.
548 Target - On input, a pointer to the Target ID of a SCSI
549 device present on the SCSI channel. On output,
550 a pointer to the Target ID of the next SCSI device
551 present on a SCSI channel. An input value of
552 0xFFFFFFFF retrieves the Target ID of the first
553 SCSI device present on a SCSI channel.
554 Lun - On input, a pointer to the LUN of a SCSI device
555 present on the SCSI channel. On output, a pointer
556 to the LUN of the next SCSI device present on
560 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
561 on the SCSI channel was returned in Target and Lun.
562 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
563 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
564 returned on a previous call to GetNextDevice().
571 AtapiScsiPassThruBuildDevicePath (
572 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
575 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
581 Used to allocate and build a device path node for a SCSI device
582 on a SCSI channel. Would not build device path for a SCSI Host Controller.
586 This - Protocol instance pointer.
587 Target - The Target ID of the SCSI device for which
588 a device path node is to be allocated and built.
589 Lun - The LUN of the SCSI device for which a device
590 path node is to be allocated and built.
591 DevicePath - A pointer to a single device path node that
592 describes the SCSI device specified by
593 Target and Lun. This function is responsible
594 for allocating the buffer DevicePath with the boot
595 service AllocatePool(). It is the caller's
596 responsibility to free DevicePath when the caller
597 is finished with DevicePath.
599 EFI_SUCCESS - The device path node that describes the SCSI device
600 specified by Target and Lun was allocated and
601 returned in DevicePath.
602 EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
603 not exist on the SCSI channel.
604 EFI_INVALID_PARAMETER - DevicePath is NULL.
605 EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
613 AtapiScsiPassThruGetTargetLun (
614 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
615 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
623 Used to translate a device path node to a Target ID and LUN.
627 This - Protocol instance pointer.
628 DevicePath - A pointer to the device path node that
629 describes a SCSI device on the SCSI channel.
630 Target - A pointer to the Target ID of a SCSI device
632 Lun - A pointer to the LUN of a SCSI device on
636 EFI_SUCCESS - DevicePath was successfully translated to a
637 Target ID and LUN, and they were returned
639 EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.
640 EFI_UNSUPPORTED - This driver does not support the device path
641 node type in DevicePath.
642 EFI_NOT_FOUND - A valid translation from DevicePath to a
643 Target ID and LUN does not exist.
650 AtapiScsiPassThruResetChannel (
651 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
657 Resets a SCSI channel.This operation resets all the
658 SCSI devices connected to the SCSI channel.
662 This - Protocol instance pointer.
666 EFI_SUCCESS - The SCSI channel was reset.
667 EFI_UNSUPPORTED - The SCSI channel does not support
668 a channel reset operation.
669 EFI_DEVICE_ERROR - A device error occurred while
670 attempting to reset the SCSI channel.
671 EFI_TIMEOUT - A timeout occurred while attempting
672 to reset the SCSI channel.
679 AtapiScsiPassThruResetTarget (
680 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
688 Resets a SCSI device that is connected to a SCSI channel.
692 This - Protocol instance pointer.
693 Target - The Target ID of the SCSI device to reset.
694 Lun - The LUN of the SCSI device to reset.
698 EFI_SUCCESS - The SCSI device specified by Target and
700 EFI_UNSUPPORTED - The SCSI channel does not support a target
702 EFI_INVALID_PARAMETER - Target or Lun are invalid.
703 EFI_DEVICE_ERROR - A device error occurred while attempting
704 to reset the SCSI device specified by Target
706 EFI_TIMEOUT - A timeout occurred while attempting to reset
707 the SCSI device specified by Target and Lun.
714 AtapiExtScsiPassThruFunction (
715 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
718 IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
,
719 IN EFI_EVENT Event OPTIONAL
725 Implements EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() function.
729 This: The EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
730 Target: The Target ID of the ATAPI device to send the SCSI
731 Request Packet. To ATAPI devices attached on an IDE
732 Channel, Target ID 0 indicates Master device;Target
733 ID 1 indicates Slave device.
734 Lun: The LUN of the ATAPI device to send the SCSI Request
735 Packet. To the ATAPI device, Lun is always 0.
736 Packet: The SCSI Request Packet to send to the ATAPI device
737 specified by Target and Lun.
738 Event: If non-blocking I/O is not supported then Event is ignored,
739 and blocking I/O is performed.
740 If Event is NULL, then blocking I/O is performed.
741 If Event is not NULL and non blocking I/O is supported,
742 then non-blocking I/O is performed, and Event will be signaled
743 when the SCSI Request Packet completes.
754 AtapiExtScsiPassThruGetNextTargetLun (
755 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
756 IN OUT UINT8
**Target
,
763 Used to retrieve the list of legal Target IDs for SCSI devices
768 This - Protocol instance pointer.
769 Target - On input, a pointer to the Target ID of a SCSI
770 device present on the SCSI channel. On output,
771 a pointer to the Target ID of the next SCSI device
772 present on a SCSI channel. An input value of
773 0xFFFFFFFF retrieves the Target ID of the first
774 SCSI device present on a SCSI channel.
775 Lun - On input, a pointer to the LUN of a SCSI device
776 present on the SCSI channel. On output, a pointer
777 to the LUN of the next SCSI device present on
781 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
782 on the SCSI channel was returned in Target and Lun.
783 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
784 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
785 returned on a previous call to GetNextDevice().
792 AtapiExtScsiPassThruBuildDevicePath (
793 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
796 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
802 Used to allocate and build a device path node for a SCSI device
803 on a SCSI channel. Would not build device path for a SCSI Host Controller.
807 This - Protocol instance pointer.
808 Target - The Target ID of the SCSI device for which
809 a device path node is to be allocated and built.
810 Lun - The LUN of the SCSI device for which a device
811 path node is to be allocated and built.
812 DevicePath - A pointer to a single device path node that
813 describes the SCSI device specified by
814 Target and Lun. This function is responsible
815 for allocating the buffer DevicePath with the boot
816 service AllocatePool(). It is the caller's
817 responsibility to free DevicePath when the caller
818 is finished with DevicePath.
820 EFI_SUCCESS - The device path node that describes the SCSI device
821 specified by Target and Lun was allocated and
822 returned in DevicePath.
823 EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
824 not exist on the SCSI channel.
825 EFI_INVALID_PARAMETER - DevicePath is NULL.
826 EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
834 AtapiExtScsiPassThruGetTargetLun (
835 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
836 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
844 Used to translate a device path node to a Target ID and LUN.
848 This - Protocol instance pointer.
849 DevicePath - A pointer to the device path node that
850 describes a SCSI device on the SCSI channel.
851 Target - A pointer to the Target ID of a SCSI device
853 Lun - A pointer to the LUN of a SCSI device on
857 EFI_SUCCESS - DevicePath was successfully translated to a
858 Target ID and LUN, and they were returned
860 EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.
861 EFI_UNSUPPORTED - This driver does not support the device path
862 node type in DevicePath.
863 EFI_NOT_FOUND - A valid translation from DevicePath to a
864 Target ID and LUN does not exist.
871 AtapiExtScsiPassThruResetChannel (
872 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
878 Resets a SCSI channel.This operation resets all the
879 SCSI devices connected to the SCSI channel.
883 This - Protocol instance pointer.
887 EFI_SUCCESS - The SCSI channel was reset.
888 EFI_UNSUPPORTED - The SCSI channel does not support
889 a channel reset operation.
890 EFI_DEVICE_ERROR - A device error occurred while
891 attempting to reset the SCSI channel.
892 EFI_TIMEOUT - A timeout occurred while attempting
893 to reset the SCSI channel.
900 AtapiExtScsiPassThruResetTarget (
901 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
909 Resets a SCSI device that is connected to a SCSI channel.
913 This - Protocol instance pointer.
914 Target - The Target ID of the SCSI device to reset.
915 Lun - The LUN of the SCSI device to reset.
919 EFI_SUCCESS - The SCSI device specified by Target and
921 EFI_UNSUPPORTED - The SCSI channel does not support a target
923 EFI_INVALID_PARAMETER - Target or Lun are invalid.
924 EFI_DEVICE_ERROR - A device error occurred while attempting
925 to reset the SCSI device specified by Target
927 EFI_TIMEOUT - A timeout occurred while attempting to reset
928 the SCSI device specified by Target and Lun.
935 AtapiExtScsiPassThruGetNextTarget (
936 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
937 IN OUT UINT8
**Target
942 Used to retrieve the list of legal Target IDs for SCSI devices
946 This - Protocol instance pointer.
947 Target - On input, a pointer to the Target ID of a SCSI
948 device present on the SCSI channel. On output,
949 a pointer to the Target ID of the next SCSI device
950 present on a SCSI channel. An input value of
951 0xFFFFFFFF retrieves the Target ID of the first
952 SCSI device present on a SCSI channel.
953 Lun - On input, a pointer to the LUN of a SCSI device
954 present on the SCSI channel. On output, a pointer
955 to the LUN of the next SCSI device present on
959 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
960 on the SCSI channel was returned in Target and Lun.
961 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
962 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
963 returned on a previous call to GetNextDevice().
969 CheckSCSIRequestPacket (
970 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
976 Checks the parameters in the SCSI Request Packet to make sure
977 they are valid for a SCSI Pass Thru request.
981 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
991 SubmitBlockingIoCommand (
992 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
994 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1000 Performs blocking I/O request.
1004 AtapiScsiPrivate: Private data structure for the specified channel.
1005 Target: The Target ID of the ATAPI device to send the SCSI
1006 Request Packet. To ATAPI devices attached on an IDE
1007 Channel, Target ID 0 indicates Master device;Target
1008 ID 1 indicates Slave device.
1009 Packet: The SCSI Request Packet to send to the ATAPI device
1010 specified by Target.
1019 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1023 Routine Description:
1025 Checks the requested SCSI command:
1026 Is it supported by this driver?
1027 Is the Data transfer direction reasonable?
1031 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1041 CheckExtSCSIRequestPacket (
1042 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1046 Routine Description:
1048 Checks the parameters in the SCSI Request Packet to make sure
1049 they are valid for a SCSI Pass Thru request.
1053 Packet - The pointer of EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1065 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1069 Routine Description:
1071 Checks the requested SCSI command:
1072 Is it supported by this driver?
1073 Is the Data transfer direction reasonable?
1077 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1087 SubmitExtBlockingIoCommand (
1088 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1090 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1094 Routine Description:
1096 Performs blocking I/O request.
1100 AtapiScsiPrivate: Private data structure for the specified channel.
1101 Target: The Target ID of the ATAPI device to send the SCSI
1102 Request Packet. To ATAPI devices attached on an IDE
1103 Channel, Target ID 0 indicates Master device;Target
1104 ID 1 indicates Slave device.
1105 Packet: The SCSI Request Packet to send to the ATAPI device
1106 specified by Target.
1114 RequestSenseCommand (
1115 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1119 UINT8
*SenseDataLength
1123 Routine Description:
1125 Sumbit request sense command
1129 AtapiScsiPrivate - The pionter of ATAPI_SCSI_PASS_THRU_DEV
1130 Target - The target ID
1131 Timeout - The time to complete the command
1132 SenseData - The buffer to fill in sense data
1133 SenseDataLength - The length of buffer
1143 AtapiPacketCommand (
1144 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1146 UINT8
*PacketCommand
,
1149 DATA_DIRECTION Direction
,
1150 UINT64 TimeOutInMicroSeconds
1154 Routine Description:
1156 Submits ATAPI command packet to the specified ATAPI device.
1160 AtapiScsiPrivate: Private data structure for the specified channel.
1161 Target: The Target ID of the ATAPI device to send the SCSI
1162 Request Packet. To ATAPI devices attached on an IDE
1163 Channel, Target ID 0 indicates Master device;Target
1164 ID 1 indicates Slave device.
1165 PacketCommand: Points to the ATAPI command packet.
1166 Buffer: Points to the transferred data.
1167 ByteCount: When input,indicates the buffer size; when output,
1168 indicates the actually transferred data size.
1169 Direction: Indicates the data transfer direction.
1170 TimeoutInMicroSeconds:
1171 The timeout, in micro second units, to use for the
1172 execution of this ATAPI command.
1173 A TimeoutInMicroSeconds value of 0 means that
1174 this function will wait indefinitely for the ATAPI
1176 If TimeoutInMicroSeconds is greater than zero, then
1177 this function will return EFI_TIMEOUT if the time
1178 required to execute the ATAPI command is greater
1179 than TimeoutInMicroSeconds.
1191 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1196 Routine Description:
1198 Read one byte from a specified I/O port.
1202 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1215 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1220 Routine Description:
1222 Read one word from a specified I/O port.
1226 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1239 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1245 Routine Description:
1247 Write one byte to a specified I/O port.
1251 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1253 Data - The data to write
1265 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1271 Routine Description:
1273 Write one word to a specified I/O port.
1277 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1279 Data - The data to write
1290 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1291 UINT64 TimeOutInMicroSeconds
1295 Routine Description:
1297 Check whether DRQ is clear in the Status Register. (BSY must also be cleared)
1298 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1299 DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1304 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1305 TimeoutInMicroSeconds - The time to wait for
1316 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1317 UINT64 TimeOutInMicroSeconds
1321 Routine Description:
1323 Check whether DRQ is clear in the Alternate Status Register.
1324 (BSY must also be cleared).If TimeoutInMicroSeconds is zero, this routine should
1325 wait infinitely for DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1330 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1331 TimeoutInMicroSeconds - The time to wait for
1342 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1343 UINT64 TimeOutInMicroSeconds
1347 Routine Description:
1349 Check whether DRQ is ready in the Status Register. (BSY must also be cleared)
1350 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1351 DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1356 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1357 TimeoutInMicroSeconds - The time to wait for
1368 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1369 UINT64 TimeOutInMicroSeconds
1373 Routine Description:
1375 Check whether DRQ is ready in the Alternate Status Register.
1376 (BSY must also be cleared)
1377 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1378 DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1383 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1384 TimeoutInMicroSeconds - The time to wait for
1394 StatusWaitForBSYClear (
1395 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1396 UINT64 TimeoutInMicroSeconds
1400 Routine Description:
1402 Check whether BSY is clear in the Status Register.
1403 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1404 BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1409 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1410 TimeoutInMicroSeconds - The time to wait for
1420 AltStatusWaitForBSYClear (
1421 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1422 UINT64 TimeoutInMicroSeconds
1426 Routine Description:
1428 Check whether BSY is clear in the Alternate Status Register.
1429 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1430 BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1435 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1436 TimeoutInMicroSeconds - The time to wait for
1447 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1448 UINT64 TimeoutInMicroSeconds
1452 Routine Description:
1454 Check whether DRDY is ready in the Status Register.
1455 (BSY must also be cleared)
1456 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1457 DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1462 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1463 TimeoutInMicroSeconds - The time to wait for
1473 AltStatusDRDYReady (
1474 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1475 UINT64 TimeoutInMicroSeconds
1479 Routine Description:
1481 Check whether DRDY is ready in the Alternate Status Register.
1482 (BSY must also be cleared)
1483 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1484 DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1489 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1490 TimeoutInMicroSeconds - The time to wait for
1500 AtapiPassThruPioReadWriteData (
1501 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1504 DATA_DIRECTION Direction
,
1505 UINT64 TimeOutInMicroSeconds
1509 Routine Description:
1511 Performs data transfer between ATAPI device and host after the
1512 ATAPI command packet is sent.
1516 AtapiScsiPrivate: Private data structure for the specified channel.
1517 Buffer: Points to the transferred data.
1518 ByteCount: When input,indicates the buffer size; when output,
1519 indicates the actually transferred data size.
1520 Direction: Indicates the data transfer direction.
1521 TimeoutInMicroSeconds:
1522 The timeout, in micro second units, to use for the
1523 execution of this ATAPI command.
1524 A TimeoutInMicroSeconds value of 0 means that
1525 this function will wait indefinitely for the ATAPI
1527 If TimeoutInMicroSeconds is greater than zero, then
1528 this function will return EFI_TIMEOUT if the time
1529 required to execute the ATAPI command is greater
1530 than TimeoutInMicroSeconds.
1539 AtapiPassThruCheckErrorStatus (
1540 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
1544 Routine Description:
1546 Check Error Register for Error Information.
1550 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1561 GetIdeRegistersBaseAddr (
1562 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1563 OUT IDE_REGISTERS_BASE_ADDR
*IdeRegsBaseAddr
1567 Routine Description:
1568 Get IDE IO port registers' base addresses by mode. In 'Compatibility' mode,
1569 use fixed addresses. In Native-PCI mode, get base addresses from BARs in
1570 the PCI IDE controller's Configuration Space.
1573 PciIo - Pointer to the EFI_PCI_IO_PROTOCOL instance
1574 IdeRegsBaseAddr - Pointer to IDE_REGISTERS_BASE_ADDR to
1575 receive IDE IO port registers' base addresses
1586 InitAtapiIoPortRegisters (
1587 IN ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1588 IN IDE_REGISTERS_BASE_ADDR
*IdeRegsBaseAddr
1592 Routine Description:
1594 Initialize each Channel's Base Address of CommandBlock and ControlBlock.
1598 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1599 IdeRegsBaseAddr - The pointer of IDE_REGISTERS_BASE_ADDR
1609 Installs Scsi Pass Thru and/or Ext Scsi Pass Thru
1610 protocols based on feature flags.
1612 @param Controller The controller handle to
1613 install these protocols on.
1614 @param AtapiScsiPrivate A pointer to the protocol private
1617 @retval EFI_SUCCESS The installation succeeds.
1618 @retval other The installation fails.
1622 InstallScsiPassThruProtocols (
1623 IN EFI_HANDLE
*ControllerHandle
,
1624 IN ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate