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 <Library/DevicePathLib.h>
37 #include <IndustryStandard/Pci22.h>
43 #define bit(a) (1 << (a))
45 #define MAX_TARGET_ID 4
51 UINT16 Command
; /* when write */
52 UINT16 Status
; /* when read */
56 UINT16 Error
; /* when read */
57 UINT16 Feature
; /* when write */
58 } IDE_ERROR_OR_FEATURE
;
61 UINT16 AltStatus
; /* when read */
62 UINT16 DeviceControl
; /* when write */
63 } IDE_AltStatus_OR_DeviceControl
;
76 // Bit definitions in Programming Interface byte of the Class Code field
77 // in PCI IDE controller's Configuration Space
79 #define IDE_PRIMARY_OPERATING_MODE BIT0
80 #define IDE_PRIMARY_PROGRAMMABLE_INDICATOR BIT1
81 #define IDE_SECONDARY_OPERATING_MODE BIT2
82 #define IDE_SECONDARY_PROGRAMMABLE_INDICATOR BIT3
85 #define ATAPI_MAX_CHANNEL 2
92 IDE_ERROR_OR_FEATURE Reg1
;
98 IDE_CMD_OR_STATUS Reg
;
99 IDE_AltStatus_OR_DeviceControl Alt
;
101 } IDE_BASE_REGISTERS
;
103 #define ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE SIGNATURE_32 ('a', 's', 'p', 't')
108 EFI_SCSI_PASS_THRU_PROTOCOL ScsiPassThru
;
109 EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru
;
110 EFI_PCI_IO_PROTOCOL
*PciIo
;
111 UINT64 OriginalPciAttributes
;
113 // Local Data goes here
115 IDE_BASE_REGISTERS
*IoPort
;
116 IDE_BASE_REGISTERS AtapiIoPortRegisters
[2];
117 UINT32 LatestTargetId
;
119 } ATAPI_SCSI_PASS_THRU_DEV
;
122 // IDE registers' base addresses
125 UINT16 CommandBlockBaseAddr
;
126 UINT16 ControlBlockBaseAddr
;
127 } IDE_REGISTERS_BASE_ADDR
;
129 #define ATAPI_SCSI_PASS_THRU_DEV_FROM_THIS(a) \
131 ATAPI_SCSI_PASS_THRU_DEV, \
133 ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE \
136 #define ATAPI_EXT_SCSI_PASS_THRU_DEV_FROM_THIS(a) \
138 ATAPI_SCSI_PASS_THRU_DEV, \
140 ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE \
146 extern EFI_DRIVER_BINDING_PROTOCOL gAtapiScsiPassThruDriverBinding
;
147 extern EFI_COMPONENT_NAME_PROTOCOL gAtapiScsiPassThruComponentName
;
148 extern EFI_COMPONENT_NAME2_PROTOCOL gAtapiScsiPassThruComponentName2
;
149 extern EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gAtapiScsiPassThruDriverSupportedEfiVersion
;
152 // ATAPI Command op code
154 #define OP_INQUIRY 0x12
155 #define OP_LOAD_UNLOAD_CD 0xa6
156 #define OP_MECHANISM_STATUS 0xbd
157 #define OP_MODE_SELECT_10 0x55
158 #define OP_MODE_SENSE_10 0x5a
159 #define OP_PAUSE_RESUME 0x4b
160 #define OP_PLAY_AUDIO_10 0x45
161 #define OP_PLAY_AUDIO_MSF 0x47
162 #define OP_PLAY_CD 0xbc
163 #define OP_PLAY_CD_MSF 0xb4
164 #define OP_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
165 #define OP_READ_10 0x28
166 #define OP_READ_12 0xa8
167 #define OP_READ_CAPACITY 0x25
168 #define OP_READ_CD 0xbe
169 #define OP_READ_CD_MSF 0xb9
170 #define OP_READ_HEADER 0x44
171 #define OP_READ_SUB_CHANNEL 0x42
172 #define OP_READ_TOC 0x43
173 #define OP_REQUEST_SENSE 0x03
175 #define OP_SEEK_10 0x2b
176 #define OP_SET_CD_SPEED 0xbb
177 #define OP_STOPPLAY_SCAN 0x4e
178 #define OP_START_STOP_UNIT 0x1b
179 #define OP_TEST_UNIT_READY 0x00
181 #define OP_FORMAT_UNIT 0x04
182 #define OP_READ_FORMAT_CAPACITIES 0x23
183 #define OP_VERIFY 0x2f
184 #define OP_WRITE_10 0x2a
185 #define OP_WRITE_12 0xaa
186 #define OP_WRITE_AND_VERIFY 0x2e
191 #define ATAPI_SOFT_RESET_CMD 0x08
203 DATA_DIRECTION Direction
;
206 #define MAX_CHANNEL 2
208 #define ValidCdbLength(Len) ((Len) == 6 || (Len) == 10 || (Len) == 12) ? 1 : 0
211 // IDE registers bit definitions
213 // ATA Err Reg bitmap
215 #define BBK_ERR bit (7) ///< Bad block detected
216 #define UNC_ERR bit (6) ///< Uncorrectable Data
217 #define MC_ERR bit (5) ///< Media Change
218 #define IDNF_ERR bit (4) ///< ID Not Found
219 #define MCR_ERR bit (3) ///< Media Change Requested
220 #define ABRT_ERR bit (2) ///< Aborted Command
221 #define TK0NF_ERR bit (1) ///< Track 0 Not Found
222 #define AMNF_ERR bit (0) ///< Address Mark Not Found
225 // ATAPI Err Reg bitmap
227 #define SENSE_KEY_ERR (bit (7) | bit (6) | bit (5) | bit (4))
228 #define EOM_ERR bit (1) ///< End of Media Detected
229 #define ILI_ERR bit (0) ///< Illegal Length Indication
234 #define LBA_MODE bit (6)
249 #define BSY bit (7) ///< Controller Busy
250 #define DRDY bit (6) ///< Drive Ready
251 #define DWF bit (5) ///< Drive Write Fault
252 #define DSC bit (4) ///< Disk Seek Complete
253 #define DRQ bit (3) ///< Data Request
254 #define CORR bit (2) ///< Corrected Data
255 #define IDX bit (1) ///< Index
256 #define ERR bit (0) ///< Error
257 #define CHECK bit (0) ///< Check bit for ATAPI Status Reg
260 // Device Control Reg
262 #define SRST bit (2) ///< Software Reset
263 #define IEN_L bit (1) ///< Interrupt Enable
266 // ATAPI Feature Register
268 #define OVERLAP bit (1)
272 // ATAPI Interrupt Reason Reson Reg (ATA Sector Count Register)
274 #define RELEASE bit (2)
278 #define PACKET_CMD 0xA0
280 #define DEFAULT_CMD (0xa0)
282 // default content of device control register, disable INT
284 #define DEFAULT_CTL (0x0a)
285 #define MAX_ATAPI_BYTE_COUNT (0xfffe)
288 // function prototype
293 AtapiScsiPassThruDriverBindingSupported (
294 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
295 IN EFI_HANDLE Controller
,
296 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
301 AtapiScsiPassThruDriverBindingStart (
302 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
303 IN EFI_HANDLE Controller
,
304 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
309 AtapiScsiPassThruDriverBindingStop (
310 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
311 IN EFI_HANDLE Controller
,
312 IN UINTN NumberOfChildren
,
313 IN EFI_HANDLE
*ChildHandleBuffer
317 // EFI Component Name Functions
320 Retrieves a Unicode string that is the user readable name of the driver.
322 This function retrieves the user readable name of a driver in the form of a
323 Unicode string. If the driver specified by This has a user readable name in
324 the language specified by Language, then a pointer to the driver name is
325 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
326 by This does not support the language specified by Language,
327 then EFI_UNSUPPORTED is returned.
329 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
330 EFI_COMPONENT_NAME_PROTOCOL instance.
332 @param Language[in] A pointer to a Null-terminated ASCII string
333 array indicating the language. This is the
334 language of the driver name that the caller is
335 requesting, and it must match one of the
336 languages specified in SupportedLanguages. The
337 number of languages supported by a driver is up
338 to the driver writer. Language is specified
339 in RFC 4646 or ISO 639-2 language code format.
341 @param DriverName[out] A pointer to the Unicode string to return.
342 This Unicode string is the name of the
343 driver specified by This in the language
344 specified by Language.
346 @retval EFI_SUCCESS The Unicode string for the Driver specified by
347 This and the language specified by Language was
348 returned in DriverName.
350 @retval EFI_INVALID_PARAMETER Language is NULL.
352 @retval EFI_INVALID_PARAMETER DriverName is NULL.
354 @retval EFI_UNSUPPORTED The driver specified by This does not support
355 the language specified by Language.
360 AtapiScsiPassThruComponentNameGetDriverName (
361 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
363 OUT CHAR16
**DriverName
368 Retrieves a Unicode string that is the user readable name of the controller
369 that is being managed by a driver.
371 This function retrieves the user readable name of the controller specified by
372 ControllerHandle and ChildHandle in the form of a Unicode string. If the
373 driver specified by This has a user readable name in the language specified by
374 Language, then a pointer to the controller name is returned in ControllerName,
375 and EFI_SUCCESS is returned. If the driver specified by This is not currently
376 managing the controller specified by ControllerHandle and ChildHandle,
377 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
378 support the language specified by Language, then EFI_UNSUPPORTED is returned.
380 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
381 EFI_COMPONENT_NAME_PROTOCOL instance.
383 @param ControllerHandle[in] The handle of a controller that the driver
384 specified by This is managing. This handle
385 specifies the controller whose name is to be
388 @param ChildHandle[in] The handle of the child controller to retrieve
389 the name of. This is an optional parameter that
390 may be NULL. It will be NULL for device
391 drivers. It will also be NULL for a bus drivers
392 that wish to retrieve the name of the bus
393 controller. It will not be NULL for a bus
394 driver that wishes to retrieve the name of a
397 @param Language[in] A pointer to a Null-terminated ASCII string
398 array indicating the language. This is the
399 language of the driver name that the caller is
400 requesting, and it must match one of the
401 languages specified in SupportedLanguages. The
402 number of languages supported by a driver is up
403 to the driver writer. Language is specified in
404 RFC 4646 or ISO 639-2 language code format.
406 @param ControllerName[out] A pointer to the Unicode string to return.
407 This Unicode string is the name of the
408 controller specified by ControllerHandle and
409 ChildHandle in the language specified by
410 Language from the point of view of the driver
413 @retval EFI_SUCCESS The Unicode string for the user readable name in
414 the language specified by Language for the
415 driver specified by This was returned in
418 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
420 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
423 @retval EFI_INVALID_PARAMETER Language is NULL.
425 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
427 @retval EFI_UNSUPPORTED The driver specified by This is not currently
428 managing the controller specified by
429 ControllerHandle and ChildHandle.
431 @retval EFI_UNSUPPORTED The driver specified by This does not support
432 the language specified by Language.
437 AtapiScsiPassThruComponentNameGetControllerName (
438 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
439 IN EFI_HANDLE ControllerHandle
,
440 IN EFI_HANDLE ChildHandle OPTIONAL
,
442 OUT CHAR16
**ControllerName
448 AtapiScsiPassThruDriverEntryPoint (
449 IN EFI_HANDLE ImageHandle
,
450 IN EFI_SYSTEM_TABLE
*SystemTable
456 Entry point for EFI drivers.
460 ImageHandle - EFI_HANDLE
461 SystemTable - EFI_SYSTEM_TABLE
472 RegisterAtapiScsiPassThru (
473 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
474 IN EFI_HANDLE Controller
,
475 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
476 IN UINT64 OriginalPciAttributes
481 Attaches SCSI Pass Thru Protocol for specified IDE channel.
484 This - Protocol instance pointer.
485 Controller - Parent device handle to the IDE channel.
486 PciIo - PCI I/O protocol attached on the "Controller".
489 Always return EFI_SUCCESS unless installing SCSI Pass Thru Protocol failed.
496 AtapiScsiPassThruFunction (
497 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
500 IN OUT EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
,
501 IN EFI_EVENT Event OPTIONAL
507 Implements EFI_SCSI_PASS_THRU_PROTOCOL.PassThru() function.
511 This: The EFI_SCSI_PASS_THRU_PROTOCOL instance.
512 Target: The Target ID of the ATAPI device to send the SCSI
513 Request Packet. To ATAPI devices attached on an IDE
514 Channel, Target ID 0 indicates Master device;Target
515 ID 1 indicates Slave device.
516 Lun: The LUN of the ATAPI device to send the SCSI Request
517 Packet. To the ATAPI device, Lun is always 0.
518 Packet: The SCSI Request Packet to send to the ATAPI device
519 specified by Target and Lun.
520 Event: If non-blocking I/O is not supported then Event is ignored,
521 and blocking I/O is performed.
522 If Event is NULL, then blocking I/O is performed.
523 If Event is not NULL and non blocking I/O is supported,
524 then non-blocking I/O is performed, and Event will be signaled
525 when the SCSI Request Packet completes.
536 AtapiScsiPassThruGetNextDevice (
537 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
538 IN OUT UINT32
*Target
,
545 Used to retrieve the list of legal Target IDs for SCSI devices
550 This - Protocol instance pointer.
551 Target - On input, a pointer to the Target ID of a SCSI
552 device present on the SCSI channel. On output,
553 a pointer to the Target ID of the next SCSI device
554 present on a SCSI channel. An input value of
555 0xFFFFFFFF retrieves the Target ID of the first
556 SCSI device present on a SCSI channel.
557 Lun - On input, a pointer to the LUN of a SCSI device
558 present on the SCSI channel. On output, a pointer
559 to the LUN of the next SCSI device present on
563 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
564 on the SCSI channel was returned in Target and Lun.
565 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
566 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
567 returned on a previous call to GetNextDevice().
574 AtapiScsiPassThruBuildDevicePath (
575 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
578 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
584 Used to allocate and build a device path node for a SCSI device
585 on a SCSI channel. Would not build device path for a SCSI Host Controller.
589 This - Protocol instance pointer.
590 Target - The Target ID of the SCSI device for which
591 a device path node is to be allocated and built.
592 Lun - The LUN of the SCSI device for which a device
593 path node is to be allocated and built.
594 DevicePath - A pointer to a single device path node that
595 describes the SCSI device specified by
596 Target and Lun. This function is responsible
597 for allocating the buffer DevicePath with the boot
598 service AllocatePool(). It is the caller's
599 responsibility to free DevicePath when the caller
600 is finished with DevicePath.
602 EFI_SUCCESS - The device path node that describes the SCSI device
603 specified by Target and Lun was allocated and
604 returned in DevicePath.
605 EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
606 not exist on the SCSI channel.
607 EFI_INVALID_PARAMETER - DevicePath is NULL.
608 EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
616 AtapiScsiPassThruGetTargetLun (
617 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
618 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
626 Used to translate a device path node to a Target ID and LUN.
630 This - Protocol instance pointer.
631 DevicePath - A pointer to the device path node that
632 describes a SCSI device on the SCSI channel.
633 Target - A pointer to the Target ID of a SCSI device
635 Lun - A pointer to the LUN of a SCSI device on
639 EFI_SUCCESS - DevicePath was successfully translated to a
640 Target ID and LUN, and they were returned
642 EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.
643 EFI_UNSUPPORTED - This driver does not support the device path
644 node type in DevicePath.
645 EFI_NOT_FOUND - A valid translation from DevicePath to a
646 Target ID and LUN does not exist.
653 AtapiScsiPassThruResetChannel (
654 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
660 Resets a SCSI channel.This operation resets all the
661 SCSI devices connected to the SCSI channel.
665 This - Protocol instance pointer.
669 EFI_SUCCESS - The SCSI channel was reset.
670 EFI_UNSUPPORTED - The SCSI channel does not support
671 a channel reset operation.
672 EFI_DEVICE_ERROR - A device error occurred while
673 attempting to reset the SCSI channel.
674 EFI_TIMEOUT - A timeout occurred while attempting
675 to reset the SCSI channel.
682 AtapiScsiPassThruResetTarget (
683 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
691 Resets a SCSI device that is connected to a SCSI channel.
695 This - Protocol instance pointer.
696 Target - The Target ID of the SCSI device to reset.
697 Lun - The LUN of the SCSI device to reset.
701 EFI_SUCCESS - The SCSI device specified by Target and
703 EFI_UNSUPPORTED - The SCSI channel does not support a target
705 EFI_INVALID_PARAMETER - Target or Lun are invalid.
706 EFI_DEVICE_ERROR - A device error occurred while attempting
707 to reset the SCSI device specified by Target
709 EFI_TIMEOUT - A timeout occurred while attempting to reset
710 the SCSI device specified by Target and Lun.
717 AtapiExtScsiPassThruFunction (
718 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
721 IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
,
722 IN EFI_EVENT Event OPTIONAL
728 Implements EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() function.
732 This: The EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
733 Target: The Target ID of the ATAPI device to send the SCSI
734 Request Packet. To ATAPI devices attached on an IDE
735 Channel, Target ID 0 indicates Master device;Target
736 ID 1 indicates Slave device.
737 Lun: The LUN of the ATAPI device to send the SCSI Request
738 Packet. To the ATAPI device, Lun is always 0.
739 Packet: The SCSI Request Packet to send to the ATAPI device
740 specified by Target and Lun.
741 Event: If non-blocking I/O is not supported then Event is ignored,
742 and blocking I/O is performed.
743 If Event is NULL, then blocking I/O is performed.
744 If Event is not NULL and non blocking I/O is supported,
745 then non-blocking I/O is performed, and Event will be signaled
746 when the SCSI Request Packet completes.
757 AtapiExtScsiPassThruGetNextTargetLun (
758 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
759 IN OUT UINT8
**Target
,
766 Used to retrieve the list of legal Target IDs for SCSI devices
771 This - Protocol instance pointer.
772 Target - On input, a pointer to the Target ID of a SCSI
773 device present on the SCSI channel. On output,
774 a pointer to the Target ID of the next SCSI device
775 present on a SCSI channel. An input value of
776 0xFFFFFFFF retrieves the Target ID of the first
777 SCSI device present on a SCSI channel.
778 Lun - On input, a pointer to the LUN of a SCSI device
779 present on the SCSI channel. On output, a pointer
780 to the LUN of the next SCSI device present on
784 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
785 on the SCSI channel was returned in Target and Lun.
786 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
787 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
788 returned on a previous call to GetNextDevice().
795 AtapiExtScsiPassThruBuildDevicePath (
796 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
799 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
805 Used to allocate and build a device path node for a SCSI device
806 on a SCSI channel. Would not build device path for a SCSI Host Controller.
810 This - Protocol instance pointer.
811 Target - The Target ID of the SCSI device for which
812 a device path node is to be allocated and built.
813 Lun - The LUN of the SCSI device for which a device
814 path node is to be allocated and built.
815 DevicePath - A pointer to a single device path node that
816 describes the SCSI device specified by
817 Target and Lun. This function is responsible
818 for allocating the buffer DevicePath with the boot
819 service AllocatePool(). It is the caller's
820 responsibility to free DevicePath when the caller
821 is finished with DevicePath.
823 EFI_SUCCESS - The device path node that describes the SCSI device
824 specified by Target and Lun was allocated and
825 returned in DevicePath.
826 EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
827 not exist on the SCSI channel.
828 EFI_INVALID_PARAMETER - DevicePath is NULL.
829 EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
837 AtapiExtScsiPassThruGetTargetLun (
838 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
839 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
847 Used to translate a device path node to a Target ID and LUN.
851 This - Protocol instance pointer.
852 DevicePath - A pointer to the device path node that
853 describes a SCSI device on the SCSI channel.
854 Target - A pointer to the Target ID of a SCSI device
856 Lun - A pointer to the LUN of a SCSI device on
860 EFI_SUCCESS - DevicePath was successfully translated to a
861 Target ID and LUN, and they were returned
863 EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.
864 EFI_UNSUPPORTED - This driver does not support the device path
865 node type in DevicePath.
866 EFI_NOT_FOUND - A valid translation from DevicePath to a
867 Target ID and LUN does not exist.
874 AtapiExtScsiPassThruResetChannel (
875 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
881 Resets a SCSI channel.This operation resets all the
882 SCSI devices connected to the SCSI channel.
886 This - Protocol instance pointer.
890 EFI_SUCCESS - The SCSI channel was reset.
891 EFI_UNSUPPORTED - The SCSI channel does not support
892 a channel reset operation.
893 EFI_DEVICE_ERROR - A device error occurred while
894 attempting to reset the SCSI channel.
895 EFI_TIMEOUT - A timeout occurred while attempting
896 to reset the SCSI channel.
903 AtapiExtScsiPassThruResetTarget (
904 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
912 Resets a SCSI device that is connected to a SCSI channel.
916 This - Protocol instance pointer.
917 Target - The Target ID of the SCSI device to reset.
918 Lun - The LUN of the SCSI device to reset.
922 EFI_SUCCESS - The SCSI device specified by Target and
924 EFI_UNSUPPORTED - The SCSI channel does not support a target
926 EFI_INVALID_PARAMETER - Target or Lun are invalid.
927 EFI_DEVICE_ERROR - A device error occurred while attempting
928 to reset the SCSI device specified by Target
930 EFI_TIMEOUT - A timeout occurred while attempting to reset
931 the SCSI device specified by Target and Lun.
938 AtapiExtScsiPassThruGetNextTarget (
939 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
940 IN OUT UINT8
**Target
945 Used to retrieve the list of legal Target IDs for SCSI devices
949 This - Protocol instance pointer.
950 Target - On input, a pointer to the Target ID of a SCSI
951 device present on the SCSI channel. On output,
952 a pointer to the Target ID of the next SCSI device
953 present on a SCSI channel. An input value of
954 0xFFFFFFFF retrieves the Target ID of the first
955 SCSI device present on a SCSI channel.
956 Lun - On input, a pointer to the LUN of a SCSI device
957 present on the SCSI channel. On output, a pointer
958 to the LUN of the next SCSI device present on
962 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
963 on the SCSI channel was returned in Target and Lun.
964 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
965 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
966 returned on a previous call to GetNextDevice().
972 CheckSCSIRequestPacket (
973 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
979 Checks the parameters in the SCSI Request Packet to make sure
980 they are valid for a SCSI Pass Thru request.
984 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
994 SubmitBlockingIoCommand (
995 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
997 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1001 Routine Description:
1003 Performs blocking I/O request.
1007 AtapiScsiPrivate: Private data structure for the specified channel.
1008 Target: The Target ID of the ATAPI device to send the SCSI
1009 Request Packet. To ATAPI devices attached on an IDE
1010 Channel, Target ID 0 indicates Master device;Target
1011 ID 1 indicates Slave device.
1012 Packet: The SCSI Request Packet to send to the ATAPI device
1013 specified by Target.
1022 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1026 Routine Description:
1028 Checks the requested SCSI command:
1029 Is it supported by this driver?
1030 Is the Data transfer direction reasonable?
1034 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1044 CheckExtSCSIRequestPacket (
1045 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1049 Routine Description:
1051 Checks the parameters in the SCSI Request Packet to make sure
1052 they are valid for a SCSI Pass Thru request.
1056 Packet - The pointer of EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1068 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1072 Routine Description:
1074 Checks the requested SCSI command:
1075 Is it supported by this driver?
1076 Is the Data transfer direction reasonable?
1080 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1090 SubmitExtBlockingIoCommand (
1091 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1093 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1097 Routine Description:
1099 Performs blocking I/O request.
1103 AtapiScsiPrivate: Private data structure for the specified channel.
1104 Target: The Target ID of the ATAPI device to send the SCSI
1105 Request Packet. To ATAPI devices attached on an IDE
1106 Channel, Target ID 0 indicates Master device;Target
1107 ID 1 indicates Slave device.
1108 Packet: The SCSI Request Packet to send to the ATAPI device
1109 specified by Target.
1117 RequestSenseCommand (
1118 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1122 UINT8
*SenseDataLength
1126 Routine Description:
1128 Sumbit request sense command
1132 AtapiScsiPrivate - The pionter of ATAPI_SCSI_PASS_THRU_DEV
1133 Target - The target ID
1134 Timeout - The time to complete the command
1135 SenseData - The buffer to fill in sense data
1136 SenseDataLength - The length of buffer
1146 AtapiPacketCommand (
1147 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1149 UINT8
*PacketCommand
,
1152 DATA_DIRECTION Direction
,
1153 UINT64 TimeOutInMicroSeconds
1157 Routine Description:
1159 Submits ATAPI command packet to the specified ATAPI device.
1163 AtapiScsiPrivate: Private data structure for the specified channel.
1164 Target: The Target ID of the ATAPI device to send the SCSI
1165 Request Packet. To ATAPI devices attached on an IDE
1166 Channel, Target ID 0 indicates Master device;Target
1167 ID 1 indicates Slave device.
1168 PacketCommand: Points to the ATAPI command packet.
1169 Buffer: Points to the transferred data.
1170 ByteCount: When input,indicates the buffer size; when output,
1171 indicates the actually transferred data size.
1172 Direction: Indicates the data transfer direction.
1173 TimeoutInMicroSeconds:
1174 The timeout, in micro second units, to use for the
1175 execution of this ATAPI command.
1176 A TimeoutInMicroSeconds value of 0 means that
1177 this function will wait indefinitely for the ATAPI
1179 If TimeoutInMicroSeconds is greater than zero, then
1180 this function will return EFI_TIMEOUT if the time
1181 required to execute the ATAPI command is greater
1182 than TimeoutInMicroSeconds.
1194 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1199 Routine Description:
1201 Read one byte from a specified I/O port.
1205 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1218 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1223 Routine Description:
1225 Read one word from a specified I/O port.
1229 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1242 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1248 Routine Description:
1250 Write one byte to a specified I/O port.
1254 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1256 Data - The data to write
1268 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1274 Routine Description:
1276 Write one word to a specified I/O port.
1280 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1282 Data - The data to write
1293 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1294 UINT64 TimeOutInMicroSeconds
1298 Routine Description:
1300 Check whether DRQ is clear in the Status Register. (BSY must also be cleared)
1301 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1302 DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1307 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1308 TimeoutInMicroSeconds - The time to wait for
1319 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1320 UINT64 TimeOutInMicroSeconds
1324 Routine Description:
1326 Check whether DRQ is clear in the Alternate Status Register.
1327 (BSY must also be cleared).If TimeoutInMicroSeconds is zero, this routine should
1328 wait infinitely for DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1333 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1334 TimeoutInMicroSeconds - The time to wait for
1345 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1346 UINT64 TimeOutInMicroSeconds
1350 Routine Description:
1352 Check whether DRQ is ready in the Status Register. (BSY must also be cleared)
1353 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1354 DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1359 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1360 TimeoutInMicroSeconds - The time to wait for
1371 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1372 UINT64 TimeOutInMicroSeconds
1376 Routine Description:
1378 Check whether DRQ is ready in the Alternate Status Register.
1379 (BSY must also be cleared)
1380 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1381 DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1386 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1387 TimeoutInMicroSeconds - The time to wait for
1397 StatusWaitForBSYClear (
1398 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1399 UINT64 TimeoutInMicroSeconds
1403 Routine Description:
1405 Check whether BSY is clear in the Status Register.
1406 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1407 BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1412 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1413 TimeoutInMicroSeconds - The time to wait for
1423 AltStatusWaitForBSYClear (
1424 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1425 UINT64 TimeoutInMicroSeconds
1429 Routine Description:
1431 Check whether BSY is clear in the Alternate Status Register.
1432 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1433 BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1438 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1439 TimeoutInMicroSeconds - The time to wait for
1450 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1451 UINT64 TimeoutInMicroSeconds
1455 Routine Description:
1457 Check whether DRDY is ready in the Status Register.
1458 (BSY must also be cleared)
1459 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1460 DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1465 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1466 TimeoutInMicroSeconds - The time to wait for
1476 AltStatusDRDYReady (
1477 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1478 UINT64 TimeoutInMicroSeconds
1482 Routine Description:
1484 Check whether DRDY is ready in the Alternate Status Register.
1485 (BSY must also be cleared)
1486 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1487 DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1492 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1493 TimeoutInMicroSeconds - The time to wait for
1503 AtapiPassThruPioReadWriteData (
1504 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1507 DATA_DIRECTION Direction
,
1508 UINT64 TimeOutInMicroSeconds
1512 Routine Description:
1514 Performs data transfer between ATAPI device and host after the
1515 ATAPI command packet is sent.
1519 AtapiScsiPrivate: Private data structure for the specified channel.
1520 Buffer: Points to the transferred data.
1521 ByteCount: When input,indicates the buffer size; when output,
1522 indicates the actually transferred data size.
1523 Direction: Indicates the data transfer direction.
1524 TimeoutInMicroSeconds:
1525 The timeout, in micro second units, to use for the
1526 execution of this ATAPI command.
1527 A TimeoutInMicroSeconds value of 0 means that
1528 this function will wait indefinitely for the ATAPI
1530 If TimeoutInMicroSeconds is greater than zero, then
1531 this function will return EFI_TIMEOUT if the time
1532 required to execute the ATAPI command is greater
1533 than TimeoutInMicroSeconds.
1542 AtapiPassThruCheckErrorStatus (
1543 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
1547 Routine Description:
1549 Check Error Register for Error Information.
1553 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1564 GetIdeRegistersBaseAddr (
1565 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1566 OUT IDE_REGISTERS_BASE_ADDR
*IdeRegsBaseAddr
1570 Routine Description:
1571 Get IDE IO port registers' base addresses by mode. In 'Compatibility' mode,
1572 use fixed addresses. In Native-PCI mode, get base addresses from BARs in
1573 the PCI IDE controller's Configuration Space.
1576 PciIo - Pointer to the EFI_PCI_IO_PROTOCOL instance
1577 IdeRegsBaseAddr - Pointer to IDE_REGISTERS_BASE_ADDR to
1578 receive IDE IO port registers' base addresses
1589 InitAtapiIoPortRegisters (
1590 IN ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1591 IN IDE_REGISTERS_BASE_ADDR
*IdeRegsBaseAddr
1595 Routine Description:
1597 Initialize each Channel's Base Address of CommandBlock and ControlBlock.
1601 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1602 IdeRegsBaseAddr - The pointer of IDE_REGISTERS_BASE_ADDR
1612 Installs Scsi Pass Thru and/or Ext Scsi Pass Thru
1613 protocols based on feature flags.
1615 @param Controller The controller handle to
1616 install these protocols on.
1617 @param AtapiScsiPrivate A pointer to the protocol private
1620 @retval EFI_SUCCESS The installation succeeds.
1621 @retval other The installation fails.
1625 InstallScsiPassThruProtocols (
1626 IN EFI_HANDLE
*ControllerHandle
,
1627 IN ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate