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>
26 #include <Library/DebugLib.h>
27 #include <Library/UefiDriverEntryPoint.h>
28 #include <Library/BaseLib.h>
29 #include <Library/UefiLib.h>
30 #include <Library/BaseMemoryLib.h>
31 #include <Library/MemoryAllocationLib.h>
32 #include <Library/UefiBootServicesTableLib.h>
33 #include <Library/PcdLib.h>
34 #include <IndustryStandard/pci22.h>
39 #define bit(a) (1 << (a))
41 #define MAX_TARGET_ID 4
47 UINT16 Command
; /* when write */
48 UINT16 Status
; /* when read */
52 UINT16 Error
; /* when read */
53 UINT16 Feature
; /* when write */
54 } IDE_ERROR_OR_FEATURE
;
57 UINT16 AltStatus
; /* when read */
58 UINT16 DeviceControl
; /* when write */
59 } IDE_AltStatus_OR_DeviceControl
;
72 // Bit definitions in Programming Interface byte of the Class Code field
73 // in PCI IDE controller's Configuration Space
75 #define IDE_PRIMARY_OPERATING_MODE BIT0
76 #define IDE_PRIMARY_PROGRAMMABLE_INDICATOR BIT1
77 #define IDE_SECONDARY_OPERATING_MODE BIT2
78 #define IDE_SECONDARY_PROGRAMMABLE_INDICATOR BIT3
81 #define ATAPI_MAX_CHANNEL 2
88 IDE_ERROR_OR_FEATURE Reg1
;
94 IDE_CMD_OR_STATUS Reg
;
95 IDE_AltStatus_OR_DeviceControl Alt
;
99 #define ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE EFI_SIGNATURE_32 ('a', 's', 'p', 't')
104 EFI_SCSI_PASS_THRU_PROTOCOL ScsiPassThru
;
105 EFI_EXT_SCSI_PASS_THRU_PROTOCOL ExtScsiPassThru
;
106 EFI_PCI_IO_PROTOCOL
*PciIo
;
107 UINT64 OriginalPciAttributes
;
109 // Local Data goes here
111 IDE_BASE_REGISTERS
*IoPort
;
112 IDE_BASE_REGISTERS AtapiIoPortRegisters
[2];
113 UINT32 LatestTargetId
;
115 } ATAPI_SCSI_PASS_THRU_DEV
;
118 // IDE registers' base addresses
121 UINT16 CommandBlockBaseAddr
;
122 UINT16 ControlBlockBaseAddr
;
123 } IDE_REGISTERS_BASE_ADDR
;
125 #define ATAPI_SCSI_PASS_THRU_DEV_FROM_THIS(a) \
127 ATAPI_SCSI_PASS_THRU_DEV, \
129 ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE \
132 #define ATAPI_EXT_SCSI_PASS_THRU_DEV_FROM_THIS(a) \
134 ATAPI_SCSI_PASS_THRU_DEV, \
136 ATAPI_SCSI_PASS_THRU_DEV_SIGNATURE \
142 extern EFI_DRIVER_BINDING_PROTOCOL gAtapiScsiPassThruDriverBinding
;
143 extern EFI_COMPONENT_NAME_PROTOCOL gAtapiScsiPassThruComponentName
;
144 extern EFI_COMPONENT_NAME2_PROTOCOL gAtapiScsiPassThruComponentName2
;
147 // ATAPI Command op code
149 #define OP_INQUIRY 0x12
150 #define OP_LOAD_UNLOAD_CD 0xa6
151 #define OP_MECHANISM_STATUS 0xbd
152 #define OP_MODE_SELECT_10 0x55
153 #define OP_MODE_SENSE_10 0x5a
154 #define OP_PAUSE_RESUME 0x4b
155 #define OP_PLAY_AUDIO_10 0x45
156 #define OP_PLAY_AUDIO_MSF 0x47
157 #define OP_PLAY_CD 0xbc
158 #define OP_PLAY_CD_MSF 0xb4
159 #define OP_PREVENT_ALLOW_MEDIUM_REMOVAL 0x1e
160 #define OP_READ_10 0x28
161 #define OP_READ_12 0xa8
162 #define OP_READ_CAPACITY 0x25
163 #define OP_READ_CD 0xbe
164 #define OP_READ_CD_MSF 0xb9
165 #define OP_READ_HEADER 0x44
166 #define OP_READ_SUB_CHANNEL 0x42
167 #define OP_READ_TOC 0x43
168 #define OP_REQUEST_SENSE 0x03
170 #define OP_SEEK_10 0x2b
171 #define OP_SET_CD_SPEED 0xbb
172 #define OP_STOPPLAY_SCAN 0x4e
173 #define OP_START_STOP_UNIT 0x1b
174 #define OP_TEST_UNIT_READY 0x00
176 #define OP_FORMAT_UNIT 0x04
177 #define OP_READ_FORMAT_CAPACITIES 0x23
178 #define OP_VERIFY 0x2f
179 #define OP_WRITE_10 0x2a
180 #define OP_WRITE_12 0xaa
181 #define OP_WRITE_AND_VERIFY 0x2e
186 #define ATAPI_SOFT_RESET_CMD 0x08
198 DATA_DIRECTION Direction
;
201 #define MAX_CHANNEL 2
203 #define ValidCdbLength(Len) ((Len) == 6 || (Len) == 10 || (Len) == 12) ? 1 : 0
206 // IDE registers bit definitions
208 // ATA Err Reg bitmap
210 #define BBK_ERR bit (7) ///< Bad block detected
211 #define UNC_ERR bit (6) ///< Uncorrectable Data
212 #define MC_ERR bit (5) ///< Media Change
213 #define IDNF_ERR bit (4) ///< ID Not Found
214 #define MCR_ERR bit (3) ///< Media Change Requested
215 #define ABRT_ERR bit (2) ///< Aborted Command
216 #define TK0NF_ERR bit (1) ///< Track 0 Not Found
217 #define AMNF_ERR bit (0) ///< Address Mark Not Found
220 // ATAPI Err Reg bitmap
222 #define SENSE_KEY_ERR (bit (7) | bit (6) | bit (5) | bit (4))
223 #define EOM_ERR bit (1) ///< End of Media Detected
224 #define ILI_ERR bit (0) ///< Illegal Length Indication
229 #define LBA_MODE bit (6)
244 #define BSY bit (7) ///< Controller Busy
245 #define DRDY bit (6) ///< Drive Ready
246 #define DWF bit (5) ///< Drive Write Fault
247 #define DSC bit (4) ///< Disk Seek Complete
248 #define DRQ bit (3) ///< Data Request
249 #define CORR bit (2) ///< Corrected Data
250 #define IDX bit (1) ///< Index
251 #define ERR bit (0) ///< Error
252 #define CHECK bit (0) ///< Check bit for ATAPI Status Reg
255 // Device Control Reg
257 #define SRST bit (2) ///< Software Reset
258 #define IEN_L bit (1) ///< Interrupt Enable
261 // ATAPI Feature Register
263 #define OVERLAP bit (1)
267 // ATAPI Interrupt Reason Reson Reg (ATA Sector Count Register)
269 #define RELEASE bit (2)
273 #define PACKET_CMD 0xA0
275 #define DEFAULT_CMD (0xa0)
277 // default content of device control register, disable INT
279 #define DEFAULT_CTL (0x0a)
280 #define MAX_ATAPI_BYTE_COUNT (0xfffe)
283 // function prototype
288 AtapiScsiPassThruDriverBindingSupported (
289 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
290 IN EFI_HANDLE Controller
,
291 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
296 AtapiScsiPassThruDriverBindingStart (
297 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
298 IN EFI_HANDLE Controller
,
299 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
304 AtapiScsiPassThruDriverBindingStop (
305 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
306 IN EFI_HANDLE Controller
,
307 IN UINTN NumberOfChildren
,
308 IN EFI_HANDLE
*ChildHandleBuffer
312 // EFI Component Name Functions
315 Retrieves a Unicode string that is the user readable name of the driver.
317 This function retrieves the user readable name of a driver in the form of a
318 Unicode string. If the driver specified by This has a user readable name in
319 the language specified by Language, then a pointer to the driver name is
320 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
321 by This does not support the language specified by Language,
322 then EFI_UNSUPPORTED is returned.
324 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
325 EFI_COMPONENT_NAME_PROTOCOL instance.
327 @param Language[in] A pointer to a Null-terminated ASCII string
328 array indicating the language. This is the
329 language of the driver name that the caller is
330 requesting, and it must match one of the
331 languages specified in SupportedLanguages. The
332 number of languages supported by a driver is up
333 to the driver writer. Language is specified
334 in RFC 3066 or ISO 639-2 language code format.
336 @param DriverName[out] A pointer to the Unicode string to return.
337 This Unicode string is the name of the
338 driver specified by This in the language
339 specified by Language.
341 @retval EFI_SUCCESS The Unicode string for the Driver specified by
342 This and the language specified by Language was
343 returned in DriverName.
345 @retval EFI_INVALID_PARAMETER Language is NULL.
347 @retval EFI_INVALID_PARAMETER DriverName is NULL.
349 @retval EFI_UNSUPPORTED The driver specified by This does not support
350 the language specified by Language.
355 AtapiScsiPassThruComponentNameGetDriverName (
356 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
358 OUT CHAR16
**DriverName
363 Retrieves a Unicode string that is the user readable name of the controller
364 that is being managed by a driver.
366 This function retrieves the user readable name of the controller specified by
367 ControllerHandle and ChildHandle in the form of a Unicode string. If the
368 driver specified by This has a user readable name in the language specified by
369 Language, then a pointer to the controller name is returned in ControllerName,
370 and EFI_SUCCESS is returned. If the driver specified by This is not currently
371 managing the controller specified by ControllerHandle and ChildHandle,
372 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
373 support the language specified by Language, then EFI_UNSUPPORTED is returned.
375 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
376 EFI_COMPONENT_NAME_PROTOCOL instance.
378 @param ControllerHandle[in] The handle of a controller that the driver
379 specified by This is managing. This handle
380 specifies the controller whose name is to be
383 @param ChildHandle[in] The handle of the child controller to retrieve
384 the name of. This is an optional parameter that
385 may be NULL. It will be NULL for device
386 drivers. It will also be NULL for a bus drivers
387 that wish to retrieve the name of the bus
388 controller. It will not be NULL for a bus
389 driver that wishes to retrieve the name of a
392 @param Language[in] A pointer to a Null-terminated ASCII string
393 array indicating the language. This is the
394 language of the driver name that the caller is
395 requesting, and it must match one of the
396 languages specified in SupportedLanguages. The
397 number of languages supported by a driver is up
398 to the driver writer. Language is specified in
399 RFC 3066 or ISO 639-2 language code format.
401 @param ControllerName[out] A pointer to the Unicode string to return.
402 This Unicode string is the name of the
403 controller specified by ControllerHandle and
404 ChildHandle in the language specified by
405 Language from the point of view of the driver
408 @retval EFI_SUCCESS The Unicode string for the user readable name in
409 the language specified by Language for the
410 driver specified by This was returned in
413 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
415 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
418 @retval EFI_INVALID_PARAMETER Language is NULL.
420 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
422 @retval EFI_UNSUPPORTED The driver specified by This is not currently
423 managing the controller specified by
424 ControllerHandle and ChildHandle.
426 @retval EFI_UNSUPPORTED The driver specified by This does not support
427 the language specified by Language.
432 AtapiScsiPassThruComponentNameGetControllerName (
433 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
434 IN EFI_HANDLE ControllerHandle
,
435 IN EFI_HANDLE ChildHandle OPTIONAL
,
437 OUT CHAR16
**ControllerName
443 AtapiScsiPassThruDriverEntryPoint (
444 IN EFI_HANDLE ImageHandle
,
445 IN EFI_SYSTEM_TABLE
*SystemTable
451 Entry point for EFI drivers.
455 ImageHandle - EFI_HANDLE
456 SystemTable - EFI_SYSTEM_TABLE
467 RegisterAtapiScsiPassThru (
468 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
469 IN EFI_HANDLE Controller
,
470 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
471 IN UINT64 OriginalPciAttributes
476 Attaches SCSI Pass Thru Protocol for specified IDE channel.
479 This - Protocol instance pointer.
480 Controller - Parent device handle to the IDE channel.
481 PciIo - PCI I/O protocol attached on the "Controller".
484 Always return EFI_SUCCESS unless installing SCSI Pass Thru Protocol failed.
491 AtapiScsiPassThruFunction (
492 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
495 IN OUT EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
,
496 IN EFI_EVENT Event OPTIONAL
502 Implements EFI_SCSI_PASS_THRU_PROTOCOL.PassThru() function.
506 This: The EFI_SCSI_PASS_THRU_PROTOCOL instance.
507 Target: The Target ID of the ATAPI device to send the SCSI
508 Request Packet. To ATAPI devices attached on an IDE
509 Channel, Target ID 0 indicates Master device;Target
510 ID 1 indicates Slave device.
511 Lun: The LUN of the ATAPI device to send the SCSI Request
512 Packet. To the ATAPI device, Lun is always 0.
513 Packet: The SCSI Request Packet to send to the ATAPI device
514 specified by Target and Lun.
515 Event: If non-blocking I/O is not supported then Event is ignored,
516 and blocking I/O is performed.
517 If Event is NULL, then blocking I/O is performed.
518 If Event is not NULL and non blocking I/O is supported,
519 then non-blocking I/O is performed, and Event will be signaled
520 when the SCSI Request Packet completes.
531 AtapiScsiPassThruGetNextDevice (
532 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
533 IN OUT UINT32
*Target
,
540 Used to retrieve the list of legal Target IDs for SCSI devices
545 This - Protocol instance pointer.
546 Target - On input, a pointer to the Target ID of a SCSI
547 device present on the SCSI channel. On output,
548 a pointer to the Target ID of the next SCSI device
549 present on a SCSI channel. An input value of
550 0xFFFFFFFF retrieves the Target ID of the first
551 SCSI device present on a SCSI channel.
552 Lun - On input, a pointer to the LUN of a SCSI device
553 present on the SCSI channel. On output, a pointer
554 to the LUN of the next SCSI device present on
558 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
559 on the SCSI channel was returned in Target and Lun.
560 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
561 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
562 returned on a previous call to GetNextDevice().
569 AtapiScsiPassThruBuildDevicePath (
570 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
573 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
579 Used to allocate and build a device path node for a SCSI device
580 on a SCSI channel. Would not build device path for a SCSI Host Controller.
584 This - Protocol instance pointer.
585 Target - The Target ID of the SCSI device for which
586 a device path node is to be allocated and built.
587 Lun - The LUN of the SCSI device for which a device
588 path node is to be allocated and built.
589 DevicePath - A pointer to a single device path node that
590 describes the SCSI device specified by
591 Target and Lun. This function is responsible
592 for allocating the buffer DevicePath with the boot
593 service AllocatePool(). It is the caller's
594 responsibility to free DevicePath when the caller
595 is finished with DevicePath.
597 EFI_SUCCESS - The device path node that describes the SCSI device
598 specified by Target and Lun was allocated and
599 returned in DevicePath.
600 EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
601 not exist on the SCSI channel.
602 EFI_INVALID_PARAMETER - DevicePath is NULL.
603 EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
611 AtapiScsiPassThruGetTargetLun (
612 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
613 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
621 Used to translate a device path node to a Target ID and LUN.
625 This - Protocol instance pointer.
626 DevicePath - A pointer to the device path node that
627 describes a SCSI device on the SCSI channel.
628 Target - A pointer to the Target ID of a SCSI device
630 Lun - A pointer to the LUN of a SCSI device on
634 EFI_SUCCESS - DevicePath was successfully translated to a
635 Target ID and LUN, and they were returned
637 EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.
638 EFI_UNSUPPORTED - This driver does not support the device path
639 node type in DevicePath.
640 EFI_NOT_FOUND - A valid translation from DevicePath to a
641 Target ID and LUN does not exist.
648 AtapiScsiPassThruResetChannel (
649 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
655 Resets a SCSI channel.This operation resets all the
656 SCSI devices connected to the SCSI channel.
660 This - Protocol instance pointer.
664 EFI_SUCCESS - The SCSI channel was reset.
665 EFI_UNSUPPORTED - The SCSI channel does not support
666 a channel reset operation.
667 EFI_DEVICE_ERROR - A device error occurred while
668 attempting to reset the SCSI channel.
669 EFI_TIMEOUT - A timeout occurred while attempting
670 to reset the SCSI channel.
677 AtapiScsiPassThruResetTarget (
678 IN EFI_SCSI_PASS_THRU_PROTOCOL
*This
,
686 Resets a SCSI device that is connected to a SCSI channel.
690 This - Protocol instance pointer.
691 Target - The Target ID of the SCSI device to reset.
692 Lun - The LUN of the SCSI device to reset.
696 EFI_SUCCESS - The SCSI device specified by Target and
698 EFI_UNSUPPORTED - The SCSI channel does not support a target
700 EFI_INVALID_PARAMETER - Target or Lun are invalid.
701 EFI_DEVICE_ERROR - A device error occurred while attempting
702 to reset the SCSI device specified by Target
704 EFI_TIMEOUT - A timeout occurred while attempting to reset
705 the SCSI device specified by Target and Lun.
712 AtapiExtScsiPassThruFunction (
713 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
716 IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
,
717 IN EFI_EVENT Event OPTIONAL
723 Implements EFI_EXT_SCSI_PASS_THRU_PROTOCOL.PassThru() function.
727 This: The EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
728 Target: The Target ID of the ATAPI device to send the SCSI
729 Request Packet. To ATAPI devices attached on an IDE
730 Channel, Target ID 0 indicates Master device;Target
731 ID 1 indicates Slave device.
732 Lun: The LUN of the ATAPI device to send the SCSI Request
733 Packet. To the ATAPI device, Lun is always 0.
734 Packet: The SCSI Request Packet to send to the ATAPI device
735 specified by Target and Lun.
736 Event: If non-blocking I/O is not supported then Event is ignored,
737 and blocking I/O is performed.
738 If Event is NULL, then blocking I/O is performed.
739 If Event is not NULL and non blocking I/O is supported,
740 then non-blocking I/O is performed, and Event will be signaled
741 when the SCSI Request Packet completes.
752 AtapiExtScsiPassThruGetNextTargetLun (
753 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
754 IN OUT UINT8
**Target
,
761 Used to retrieve the list of legal Target IDs for SCSI devices
766 This - Protocol instance pointer.
767 Target - On input, a pointer to the Target ID of a SCSI
768 device present on the SCSI channel. On output,
769 a pointer to the Target ID of the next SCSI device
770 present on a SCSI channel. An input value of
771 0xFFFFFFFF retrieves the Target ID of the first
772 SCSI device present on a SCSI channel.
773 Lun - On input, a pointer to the LUN of a SCSI device
774 present on the SCSI channel. On output, a pointer
775 to the LUN of the next SCSI device present on
779 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
780 on the SCSI channel was returned in Target and Lun.
781 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
782 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
783 returned on a previous call to GetNextDevice().
790 AtapiExtScsiPassThruBuildDevicePath (
791 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
794 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
800 Used to allocate and build a device path node for a SCSI device
801 on a SCSI channel. Would not build device path for a SCSI Host Controller.
805 This - Protocol instance pointer.
806 Target - The Target ID of the SCSI device for which
807 a device path node is to be allocated and built.
808 Lun - The LUN of the SCSI device for which a device
809 path node is to be allocated and built.
810 DevicePath - A pointer to a single device path node that
811 describes the SCSI device specified by
812 Target and Lun. This function is responsible
813 for allocating the buffer DevicePath with the boot
814 service AllocatePool(). It is the caller's
815 responsibility to free DevicePath when the caller
816 is finished with DevicePath.
818 EFI_SUCCESS - The device path node that describes the SCSI device
819 specified by Target and Lun was allocated and
820 returned in DevicePath.
821 EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
822 not exist on the SCSI channel.
823 EFI_INVALID_PARAMETER - DevicePath is NULL.
824 EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
832 AtapiExtScsiPassThruGetTargetLun (
833 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
834 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
842 Used to translate a device path node to a Target ID and LUN.
846 This - Protocol instance pointer.
847 DevicePath - A pointer to the device path node that
848 describes a SCSI device on the SCSI channel.
849 Target - A pointer to the Target ID of a SCSI device
851 Lun - A pointer to the LUN of a SCSI device on
855 EFI_SUCCESS - DevicePath was successfully translated to a
856 Target ID and LUN, and they were returned
858 EFI_INVALID_PARAMETER - DevicePath/Target/Lun is NULL.
859 EFI_UNSUPPORTED - This driver does not support the device path
860 node type in DevicePath.
861 EFI_NOT_FOUND - A valid translation from DevicePath to a
862 Target ID and LUN does not exist.
869 AtapiExtScsiPassThruResetChannel (
870 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
876 Resets a SCSI channel.This operation resets all the
877 SCSI devices connected to the SCSI channel.
881 This - Protocol instance pointer.
885 EFI_SUCCESS - The SCSI channel was reset.
886 EFI_UNSUPPORTED - The SCSI channel does not support
887 a channel reset operation.
888 EFI_DEVICE_ERROR - A device error occurred while
889 attempting to reset the SCSI channel.
890 EFI_TIMEOUT - A timeout occurred while attempting
891 to reset the SCSI channel.
898 AtapiExtScsiPassThruResetTarget (
899 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
907 Resets a SCSI device that is connected to a SCSI channel.
911 This - Protocol instance pointer.
912 Target - The Target ID of the SCSI device to reset.
913 Lun - The LUN of the SCSI device to reset.
917 EFI_SUCCESS - The SCSI device specified by Target and
919 EFI_UNSUPPORTED - The SCSI channel does not support a target
921 EFI_INVALID_PARAMETER - Target or Lun are invalid.
922 EFI_DEVICE_ERROR - A device error occurred while attempting
923 to reset the SCSI device specified by Target
925 EFI_TIMEOUT - A timeout occurred while attempting to reset
926 the SCSI device specified by Target and Lun.
933 AtapiExtScsiPassThruGetNextTarget (
934 IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*This
,
935 IN OUT UINT8
**Target
940 Used to retrieve the list of legal Target IDs for SCSI devices
944 This - Protocol instance pointer.
945 Target - On input, a pointer to the Target ID of a SCSI
946 device present on the SCSI channel. On output,
947 a pointer to the Target ID of the next SCSI device
948 present on a SCSI channel. An input value of
949 0xFFFFFFFF retrieves the Target ID of the first
950 SCSI device present on a SCSI channel.
951 Lun - On input, a pointer to the LUN of a SCSI device
952 present on the SCSI channel. On output, a pointer
953 to the LUN of the next SCSI device present on
957 EFI_SUCCESS - The Target ID and Lun of the next SCSI device
958 on the SCSI channel was returned in Target and Lun.
959 EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
960 EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF,and Target and Lun were not
961 returned on a previous call to GetNextDevice().
967 CheckSCSIRequestPacket (
968 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
974 Checks the parameters in the SCSI Request Packet to make sure
975 they are valid for a SCSI Pass Thru request.
979 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
989 SubmitBlockingIoCommand (
990 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
992 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
998 Performs blocking I/O request.
1002 AtapiScsiPrivate: Private data structure for the specified channel.
1003 Target: The Target ID of the ATAPI device to send the SCSI
1004 Request Packet. To ATAPI devices attached on an IDE
1005 Channel, Target ID 0 indicates Master device;Target
1006 ID 1 indicates Slave device.
1007 Packet: The SCSI Request Packet to send to the ATAPI device
1008 specified by Target.
1017 EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1021 Routine Description:
1023 Checks the requested SCSI command:
1024 Is it supported by this driver?
1025 Is the Data transfer direction reasonable?
1029 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1039 CheckExtSCSIRequestPacket (
1040 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1044 Routine Description:
1046 Checks the parameters in the SCSI Request Packet to make sure
1047 they are valid for a SCSI Pass Thru request.
1051 Packet - The pointer of EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1063 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1067 Routine Description:
1069 Checks the requested SCSI command:
1070 Is it supported by this driver?
1071 Is the Data transfer direction reasonable?
1075 Packet - The pointer of EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
1085 SubmitExtBlockingIoCommand (
1086 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1088 EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET
*Packet
1092 Routine Description:
1094 Performs blocking I/O request.
1098 AtapiScsiPrivate: Private data structure for the specified channel.
1099 Target: The Target ID of the ATAPI device to send the SCSI
1100 Request Packet. To ATAPI devices attached on an IDE
1101 Channel, Target ID 0 indicates Master device;Target
1102 ID 1 indicates Slave device.
1103 Packet: The SCSI Request Packet to send to the ATAPI device
1104 specified by Target.
1112 RequestSenseCommand (
1113 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1117 UINT8
*SenseDataLength
1121 Routine Description:
1123 Sumbit request sense command
1127 AtapiScsiPrivate - The pionter of ATAPI_SCSI_PASS_THRU_DEV
1128 Target - The target ID
1129 Timeout - The time to complete the command
1130 SenseData - The buffer to fill in sense data
1131 SenseDataLength - The length of buffer
1141 AtapiPacketCommand (
1142 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1144 UINT8
*PacketCommand
,
1147 DATA_DIRECTION Direction
,
1148 UINT64 TimeOutInMicroSeconds
1152 Routine Description:
1154 Submits ATAPI command packet to the specified ATAPI device.
1158 AtapiScsiPrivate: Private data structure for the specified channel.
1159 Target: The Target ID of the ATAPI device to send the SCSI
1160 Request Packet. To ATAPI devices attached on an IDE
1161 Channel, Target ID 0 indicates Master device;Target
1162 ID 1 indicates Slave device.
1163 PacketCommand: Points to the ATAPI command packet.
1164 Buffer: Points to the transferred data.
1165 ByteCount: When input,indicates the buffer size; when output,
1166 indicates the actually transferred data size.
1167 Direction: Indicates the data transfer direction.
1168 TimeoutInMicroSeconds:
1169 The timeout, in micro second units, to use for the
1170 execution of this ATAPI command.
1171 A TimeoutInMicroSeconds value of 0 means that
1172 this function will wait indefinitely for the ATAPI
1174 If TimeoutInMicroSeconds is greater than zero, then
1175 this function will return EFI_TIMEOUT if the time
1176 required to execute the ATAPI command is greater
1177 than TimeoutInMicroSeconds.
1189 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1194 Routine Description:
1196 Read one byte from a specified I/O port.
1200 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1213 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1218 Routine Description:
1220 Read one word from a specified I/O port.
1224 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1237 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1243 Routine Description:
1245 Write one byte to a specified I/O port.
1249 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1251 Data - The data to write
1263 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1269 Routine Description:
1271 Write one word to a specified I/O port.
1275 PciIo - The pointer of EFI_PCI_IO_PROTOCOL
1277 Data - The data to write
1288 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1289 UINT64 TimeOutInMicroSeconds
1293 Routine Description:
1295 Check whether DRQ is clear in the Status Register. (BSY must also be cleared)
1296 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1297 DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1302 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1303 TimeoutInMicroSeconds - The time to wait for
1314 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1315 UINT64 TimeOutInMicroSeconds
1319 Routine Description:
1321 Check whether DRQ is clear in the Alternate Status Register.
1322 (BSY must also be cleared).If TimeoutInMicroSeconds is zero, this routine should
1323 wait infinitely for DRQ clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1328 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1329 TimeoutInMicroSeconds - The time to wait for
1340 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1341 UINT64 TimeOutInMicroSeconds
1345 Routine Description:
1347 Check whether DRQ is ready in the Status Register. (BSY must also be cleared)
1348 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1349 DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1354 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1355 TimeoutInMicroSeconds - The time to wait for
1366 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1367 UINT64 TimeOutInMicroSeconds
1371 Routine Description:
1373 Check whether DRQ is ready in the Alternate Status Register.
1374 (BSY must also be cleared)
1375 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1376 DRQ ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1381 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1382 TimeoutInMicroSeconds - The time to wait for
1392 StatusWaitForBSYClear (
1393 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1394 UINT64 TimeoutInMicroSeconds
1398 Routine Description:
1400 Check whether BSY is clear in the Status Register.
1401 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1402 BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1407 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1408 TimeoutInMicroSeconds - The time to wait for
1418 AltStatusWaitForBSYClear (
1419 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1420 UINT64 TimeoutInMicroSeconds
1424 Routine Description:
1426 Check whether BSY is clear in the Alternate Status Register.
1427 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1428 BSY clear. Otherwise, it will return EFI_TIMEOUT when specified time is
1433 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1434 TimeoutInMicroSeconds - The time to wait for
1445 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1446 UINT64 TimeoutInMicroSeconds
1450 Routine Description:
1452 Check whether DRDY is ready in the Status Register.
1453 (BSY must also be cleared)
1454 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1455 DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1460 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1461 TimeoutInMicroSeconds - The time to wait for
1471 AltStatusDRDYReady (
1472 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1473 UINT64 TimeoutInMicroSeconds
1477 Routine Description:
1479 Check whether DRDY is ready in the Alternate Status Register.
1480 (BSY must also be cleared)
1481 If TimeoutInMicroSeconds is zero, this routine should wait infinitely for
1482 DRDY ready. Otherwise, it will return EFI_TIMEOUT when specified time is
1487 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1488 TimeoutInMicroSeconds - The time to wait for
1498 AtapiPassThruPioReadWriteData (
1499 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1502 DATA_DIRECTION Direction
,
1503 UINT64 TimeOutInMicroSeconds
1507 Routine Description:
1509 Performs data transfer between ATAPI device and host after the
1510 ATAPI command packet is sent.
1514 AtapiScsiPrivate: Private data structure for the specified channel.
1515 Buffer: Points to the transferred data.
1516 ByteCount: When input,indicates the buffer size; when output,
1517 indicates the actually transferred data size.
1518 Direction: Indicates the data transfer direction.
1519 TimeoutInMicroSeconds:
1520 The timeout, in micro second units, to use for the
1521 execution of this ATAPI command.
1522 A TimeoutInMicroSeconds value of 0 means that
1523 this function will wait indefinitely for the ATAPI
1525 If TimeoutInMicroSeconds is greater than zero, then
1526 this function will return EFI_TIMEOUT if the time
1527 required to execute the ATAPI command is greater
1528 than TimeoutInMicroSeconds.
1537 AtapiPassThruCheckErrorStatus (
1538 ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
1542 Routine Description:
1544 Check Error Register for Error Information.
1548 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1559 GetIdeRegistersBaseAddr (
1560 IN EFI_PCI_IO_PROTOCOL
*PciIo
,
1561 OUT IDE_REGISTERS_BASE_ADDR
*IdeRegsBaseAddr
1565 Routine Description:
1566 Get IDE IO port registers' base addresses by mode. In 'Compatibility' mode,
1567 use fixed addresses. In Native-PCI mode, get base addresses from BARs in
1568 the PCI IDE controller's Configuration Space.
1571 PciIo - Pointer to the EFI_PCI_IO_PROTOCOL instance
1572 IdeRegsBaseAddr - Pointer to IDE_REGISTERS_BASE_ADDR to
1573 receive IDE IO port registers' base addresses
1584 InitAtapiIoPortRegisters (
1585 IN ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate
,
1586 IN IDE_REGISTERS_BASE_ADDR
*IdeRegsBaseAddr
1590 Routine Description:
1592 Initialize each Channel's Base Address of CommandBlock and ControlBlock.
1596 AtapiScsiPrivate - The pointer of ATAPI_SCSI_PASS_THRU_DEV
1597 IdeRegsBaseAddr - The pointer of IDE_REGISTERS_BASE_ADDR
1607 Installs Scsi Pass Thru and/or Ext Scsi Pass Thru
1608 protocols based on feature flags.
1610 @param Controller The controller handle to
1611 install these protocols on.
1612 @param AtapiScsiPrivate A pointer to the protocol private
1615 @retval EFI_SUCCESS The installation succeeds.
1616 @retval other The installation fails.
1620 InstallScsiPassThruProtocols (
1621 IN EFI_HANDLE
*ControllerHandle
,
1622 IN ATAPI_SCSI_PASS_THRU_DEV
*AtapiScsiPrivate