TianoCore EDK2 master
Loading...
Searching...
No Matches
IdeMode.c File Reference
#include "AtaAtapiPassThru.h"

Go to the source code of this file.

Functions

UINT8 EFIAPI IdeReadPortB (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT16 Port)
 
VOID EFIAPI IdeWritePortB (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT16 Port, IN UINT8 Data)
 
VOID EFIAPI IdeWritePortW (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT16 Port, IN UINT16 Data)
 
VOID EFIAPI IdeWritePortDW (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT16 Port, IN UINT32 Data)
 
VOID EFIAPI IdeWritePortWMultiple (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT16 Port, IN UINTN Count, IN VOID *Buffer)
 
VOID EFIAPI IdeReadPortWMultiple (IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT16 Port, IN UINTN Count, IN VOID *Buffer)
 
VOID EFIAPI DumpAllIdeRegisters (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock)
 
EFI_STATUS EFIAPI CheckStatusRegister (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters)
 
EFI_STATUS EFIAPI DRQClear (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN UINT64 Timeout)
 
EFI_STATUS EFIAPI DRQClear2 (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN UINT64 Timeout)
 
EFI_STATUS EFIAPI DRQReady (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN UINT64 Timeout)
 
EFI_STATUS EFIAPI DRQReady2 (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN UINT64 Timeout)
 
EFI_STATUS EFIAPI WaitForBSYClear (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN UINT64 Timeout)
 
EFI_STATUS EFIAPI GetIdeRegisterIoAddr (IN EFI_PCI_IO_PROTOCOL *PciIo, IN OUT EFI_IDE_REGISTERS *IdeRegisters)
 
EFI_STATUS EFIAPI AtaIssueCommand (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN UINT64 Timeout)
 
EFI_STATUS EFIAPI AtaPioDataInOut (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN OUT VOID *Buffer, IN UINT64 ByteCount, IN BOOLEAN Read, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN UINT64 Timeout, IN ATA_NONBLOCK_TASK *Task)
 
EFI_STATUS EFIAPI AtaNonDataCommandIn (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN UINT64 Timeout, IN ATA_NONBLOCK_TASK *Task)
 
EFI_STATUS AtaUdmStatusWait (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN UINT64 Timeout)
 
EFI_STATUS AtaUdmStatusCheck (IN EFI_PCI_IO_PROTOCOL *PciIo, IN ATA_NONBLOCK_TASK *Task, IN EFI_IDE_REGISTERS *IdeRegisters)
 
EFI_STATUS EFIAPI AtaUdmaInOut (IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN EFI_IDE_REGISTERS *IdeRegisters, IN BOOLEAN Read, IN VOID *DataBuffer, IN UINT64 DataLength, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN UINT64 Timeout, IN ATA_NONBLOCK_TASK *Task)
 
EFI_STATUS EFIAPI AtaPacketReadPendingData (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters)
 
EFI_STATUS EFIAPI AtaPacketReadWrite (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN OUT VOID *Buffer, IN OUT UINT32 *ByteCount, IN BOOLEAN Read, IN UINT64 Timeout)
 
EFI_STATUS EFIAPI AtaPacketCommandExecute (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_IDE_REGISTERS *IdeRegisters, IN UINT8 Channel, IN UINT8 Device, IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet)
 
EFI_STATUS EFIAPI SetDeviceTransferMode (IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT8 Channel, IN UINT8 Device, IN EFI_ATA_TRANSFER_MODE *TransferMode, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock)
 
EFI_STATUS EFIAPI SetDriveParameters (IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT8 Channel, IN UINT8 Device, IN EFI_ATA_DRIVE_PARMS *DriveParameters, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock)
 
EFI_STATUS EFIAPI IdeAtaSmartReturnStatusCheck (IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT8 Channel, IN UINT8 Device, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock)
 
VOID EFIAPI IdeAtaSmartSupport (IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT8 Channel, IN UINT8 Device, IN EFI_IDENTIFY_DATA *IdentifyData, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock)
 
EFI_STATUS EFIAPI AtaIdentify (IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT8 Channel, IN UINT8 Device, IN OUT EFI_IDENTIFY_DATA *Buffer, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock)
 
EFI_STATUS EFIAPI AtaIdentifyPacket (IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT8 Channel, IN UINT8 Device, IN OUT EFI_IDENTIFY_DATA *Buffer, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock)
 
EFI_STATUS EFIAPI DetectAndConfigIdeDevice (IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance, IN UINT8 IdeChannel)
 
EFI_STATUS EFIAPI IdeModeInitialization (IN ATA_ATAPI_PASS_THRU_INSTANCE *Instance)
 

Detailed Description

Header file for AHCI mode of ATA host controller.

Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file IdeMode.c.

Function Documentation

◆ AtaIdentify()

EFI_STATUS EFIAPI AtaIdentify ( IN ATA_ATAPI_PASS_THRU_INSTANCE Instance,
IN UINT8  Channel,
IN UINT8  Device,
IN OUT EFI_IDENTIFY_DATA Buffer,
IN OUT EFI_ATA_STATUS_BLOCK AtaStatusBlock 
)

Sends out an ATA Identify Command to the specified device.

This function is called by DiscoverIdeDevice() during its device identification. It sends out the ATA Identify Command to the specified device. Only ATA device responses to this command. If the command succeeds, it returns the Identify data structure which contains information about the device. This function extracts the information it needs to fill the IDE_BLK_IO_DEV data structure, including device type, media block size, media capacity, and etc.

Parameters
InstanceA pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
ChannelThe channel number of device.
DeviceThe device number of device.
BufferA pointer to data buffer which is used to contain IDENTIFY data.
AtaStatusBlockA pointer to EFI_ATA_STATUS_BLOCK data structure.
Return values
EFI_SUCCESSIdentify ATA device successfully.
EFI_DEVICE_ERRORATA Identify Device Command failed or device is not ATA device.
EFI_OUT_OF_RESOURCESAllocate memory failed.

Definition at line 2244 of file IdeMode.c.

◆ AtaIdentifyPacket()

EFI_STATUS EFIAPI AtaIdentifyPacket ( IN ATA_ATAPI_PASS_THRU_INSTANCE Instance,
IN UINT8  Channel,
IN UINT8  Device,
IN OUT EFI_IDENTIFY_DATA Buffer,
IN OUT EFI_ATA_STATUS_BLOCK AtaStatusBlock 
)

This function is called by DiscoverIdeDevice() during its device identification. Its main purpose is to get enough information for the device media to fill in the Media data structure of the Block I/O Protocol interface.

There are 5 steps to reach such objective:

  1. Sends out the ATAPI Identify Command to the specified device. Only ATAPI device responses to this command. If the command succeeds, it returns the Identify data structure which filled with information about the device. Since the ATAPI device contains removable media, the only meaningful information is the device module name.
  2. Sends out ATAPI Inquiry Packet Command to the specified device. This command will return inquiry data of the device, which contains the device type information.
  3. Allocate sense data space for future use. We don't detect the media presence here to improvement boot performance, especially when CD media is present. The media detection will be performed just before each BLK_IO read/write
Parameters
InstanceA pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
ChannelThe channel number of device.
DeviceThe device number of device.
BufferA pointer to data buffer which is used to contain IDENTIFY data.
AtaStatusBlockA pointer to EFI_ATA_STATUS_BLOCK data structure.
Return values
EFI_SUCCESSIdentify ATAPI device successfully.
EFI_DEVICE_ERRORATA Identify Packet Device Command failed or device type is not supported by this IDE driver.
EFI_OUT_OF_RESOURCESAllocate memory failed.

Definition at line 2309 of file IdeMode.c.

◆ AtaIssueCommand()

EFI_STATUS EFIAPI AtaIssueCommand ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_IDE_REGISTERS IdeRegisters,
IN EFI_ATA_COMMAND_BLOCK AtaCommandBlock,
IN UINT64  Timeout 
)

Send ATA Ext command into device with NON_DATA protocol.

Parameters
PciIoA pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
AtaCommandBlockA pointer to EFI_ATA_COMMAND_BLOCK data structure.
TimeoutThe time to complete the command, uses 100ns as a unit.
Return values
EFI_SUCCESSReading succeed
EFI_DEVICE_ERRORError executing commands on this device.

Definition at line 836 of file IdeMode.c.

◆ AtaNonDataCommandIn()

EFI_STATUS EFIAPI AtaNonDataCommandIn ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_IDE_REGISTERS IdeRegisters,
IN EFI_ATA_COMMAND_BLOCK AtaCommandBlock,
IN OUT EFI_ATA_STATUS_BLOCK AtaStatusBlock,
IN UINT64  Timeout,
IN ATA_NONBLOCK_TASK Task 
)

Send ATA command into device with NON_DATA protocol

Parameters
[in]PciIoA pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
[in]IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
[in]AtaCommandBlockA pointer to EFI_ATA_COMMAND_BLOCK data structure.
[in,out]AtaStatusBlockA pointer to EFI_ATA_STATUS_BLOCK data structure.
[in]TimeoutThe time to complete the command, uses 100ns as a unit.
[in]TaskOptional. Pointer to the ATA_NONBLOCK_TASK used by non-blocking mode.
Return values
EFI_SUCCESSReading succeed
EFI_ABORTEDCommand failed
EFI_DEVICE_ERRORDevice status error.

Definition at line 1069 of file IdeMode.c.

◆ AtaPacketCommandExecute()

EFI_STATUS EFIAPI AtaPacketCommandExecute ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_IDE_REGISTERS IdeRegisters,
IN UINT8  Channel,
IN UINT8  Device,
IN EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET Packet 
)

This function is used to send out ATAPI commands conforms to the Packet Command with PIO Data In Protocol.

Parameters
[in]PciIoPointer to the EFI_PCI_IO_PROTOCOL instance
[in]IdeRegistersPointer to EFI_IDE_REGISTERS which is used to store the IDE i/o port registers' base addresses
[in]ChannelThe channel number of device.
[in]DeviceThe device number of device.
[in]PacketA pointer to EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET data structure.
Return values
EFI_SUCCESSsend out the ATAPI packet command successfully and device sends data successfully.
EFI_DEVICE_ERRORthe device failed to send data.

Definition at line 1806 of file IdeMode.c.

◆ AtaPacketReadPendingData()

EFI_STATUS EFIAPI AtaPacketReadPendingData ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_IDE_REGISTERS IdeRegisters 
)

This function reads the pending data in the device.

Parameters
PciIoA pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
Return values
EFI_SUCCESSSuccessfully read.
EFI_NOT_READYThe BSY is set avoiding reading.

Definition at line 1624 of file IdeMode.c.

◆ AtaPacketReadWrite()

EFI_STATUS EFIAPI AtaPacketReadWrite ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_IDE_REGISTERS IdeRegisters,
IN OUT VOID *  Buffer,
IN OUT UINT32 *  ByteCount,
IN BOOLEAN  Read,
IN UINT64  Timeout 
)

This function is called by AtaPacketCommandExecute(). It is used to transfer data between host and device. The data direction is specified by the fourth parameter.

Parameters
PciIoA pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
BufferBuffer contained data transferred between host and device.
ByteCountData size in byte unit of the buffer.
ReadFlag used to determine the data transfer direction. Read equals 1, means data transferred from device to host; Read equals 0, means data transferred from host to device.
TimeoutTimeout value for wait DRQ ready before each data stream's transfer , uses 100ns as a unit.
Return values
EFI_SUCCESSdata is transferred successfully.
EFI_DEVICE_ERRORthe device failed to transfer data.

Definition at line 1673 of file IdeMode.c.

◆ AtaPioDataInOut()

EFI_STATUS EFIAPI AtaPioDataInOut ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_IDE_REGISTERS IdeRegisters,
IN OUT VOID *  Buffer,
IN UINT64  ByteCount,
IN BOOLEAN  Read,
IN EFI_ATA_COMMAND_BLOCK AtaCommandBlock,
IN OUT EFI_ATA_STATUS_BLOCK AtaStatusBlock,
IN UINT64  Timeout,
IN ATA_NONBLOCK_TASK Task 
)

This function is used to send out ATA commands conforms to the PIO Data In Protocol.

Parameters
[in]PciIoA pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
[in]IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
[in,out]BufferA pointer to the source buffer for the data.
[in]ByteCountThe length of the data.
[in]ReadFlag used to determine the data transfer direction. Read equals 1, means data transferred from device to host;Read equals 0, means data transferred from host to device.
[in]AtaCommandBlockA pointer to EFI_ATA_COMMAND_BLOCK data structure.
[in,out]AtaStatusBlockA pointer to EFI_ATA_STATUS_BLOCK data structure.
[in]TimeoutThe time to complete the command, uses 100ns as a unit.
[in]TaskOptional. Pointer to the ATA_NONBLOCK_TASK used by non-blocking mode.
Return values
EFI_SUCCESSsend out the ATA command and device send required data successfully.
EFI_DEVICE_ERRORcommand sent failed.

Definition at line 934 of file IdeMode.c.

◆ AtaUdmaInOut()

EFI_STATUS EFIAPI AtaUdmaInOut ( IN ATA_ATAPI_PASS_THRU_INSTANCE Instance,
IN EFI_IDE_REGISTERS IdeRegisters,
IN BOOLEAN  Read,
IN VOID *  DataBuffer,
IN UINT64  DataLength,
IN EFI_ATA_COMMAND_BLOCK AtaCommandBlock,
IN OUT EFI_ATA_STATUS_BLOCK AtaStatusBlock,
IN UINT64  Timeout,
IN ATA_NONBLOCK_TASK Task 
)

Perform an ATA Udma operation (Read, ReadExt, Write, WriteExt).

Parameters
[in]InstanceA pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
[in]IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
[in]ReadFlag used to determine the data transfer direction. Read equals 1, means data transferred from device to host;Read equals 0, means data transferred from host to device.
[in]DataBufferA pointer to the source buffer for the data.
[in]DataLengthThe length of the data.
[in]AtaCommandBlockA pointer to EFI_ATA_COMMAND_BLOCK data structure.
[in,out]AtaStatusBlockA pointer to EFI_ATA_STATUS_BLOCK data structure.
[in]TimeoutThe time to complete the command, uses 100ns as a unit.
[in]TaskOptional. Pointer to the ATA_NONBLOCK_TASK used by non-blocking mode.
Return values
EFI_SUCCESSthe operation is successful.
EFI_OUT_OF_RESOURCESBuild PRD table failed
EFI_UNSUPPORTEDUnknown channel or operations command
EFI_DEVICE_ERRORAta command execute failed

Definition at line 1263 of file IdeMode.c.

◆ AtaUdmStatusCheck()

EFI_STATUS AtaUdmStatusCheck ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN ATA_NONBLOCK_TASK Task,
IN EFI_IDE_REGISTERS IdeRegisters 
)

Check if the memory to be set.

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]TaskOptional. Pointer to the ATA_NONBLOCK_TASK used by non-blocking mode.
[in]IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
Return values
EFI_DEVICE_ERRORThe memory setting met a issue.
EFI_NOT_READYThe memory is not set.
EFI_TIMEOUTThe memory setting is time out.
EFI_SUCCESSThe memory is correct set.

Definition at line 1198 of file IdeMode.c.

◆ AtaUdmStatusWait()

EFI_STATUS AtaUdmStatusWait ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_IDE_REGISTERS IdeRegisters,
IN UINT64  Timeout 
)

Wait for memory to be set.

Parameters
[in]PciIoThe PCI IO protocol instance.
[in]IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
[in]TimeoutThe time to complete the command, uses 100ns as a unit.
Return values
EFI_DEVICE_ERRORThe memory is not set.
EFI_TIMEOUTThe memory setting is time out.
EFI_SUCCESSThe memory is correct set.

Definition at line 1133 of file IdeMode.c.

◆ CheckStatusRegister()

EFI_STATUS EFIAPI CheckStatusRegister ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_IDE_REGISTERS IdeRegisters 
)

This function is used to analyze the Status Register at the condition that BSY is zero. if there is ERR bit set in the Status Register, then return error.

Parameters
PciIoA pointer to EFI_PCI_IO_PROTOCOL data structure.
IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
Return values
EFI_SUCCESSNo err information in the Status Register.
EFI_DEVICE_ERRORAny err information in the Status Register.

Definition at line 302 of file IdeMode.c.

◆ DetectAndConfigIdeDevice()

EFI_STATUS EFIAPI DetectAndConfigIdeDevice ( IN ATA_ATAPI_PASS_THRU_INSTANCE Instance,
IN UINT8  IdeChannel 
)

This function is used for detect whether the IDE device exists in the specified Channel as the specified Device Number.

There is two IDE channels: one is Primary Channel, the other is Secondary Channel.(Channel is the logical name for the physical "Cable".) Different channel has different register group.

On each IDE channel, at most two IDE devices attach, one is called Device 0 (Master device), the other is called Device 1 (Slave device). The devices on the same channel co-use the same register group, so before sending out a command for a specified device via command register, it is a must to select the current device to accept the command by set the device number in the Head/Device Register.

Parameters
InstanceA pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
IdeChannelThe channel number of device.
Return values
EFI_SUCCESSsuccessfully detects device.
otherany failure during detection process will return this value.

Definition at line 2367 of file IdeMode.c.

◆ DRQClear()

EFI_STATUS EFIAPI DRQClear ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_IDE_REGISTERS IdeRegisters,
IN UINT64  Timeout 
)

This function is used to poll for the DRQ bit clear in the Status Register. DRQ is cleared when the device is finished transferring data. So this function is called after data transfer is finished.

Parameters
PciIoA pointer to EFI_PCI_IO_PROTOCOL data structure.
IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
TimeoutThe time to complete the command, uses 100ns as a unit.
Return values
EFI_SUCCESSDRQ bit clear within the time out.
EFI_TIMEOUTDRQ bit not clear within the time out.
Note
Read Status Register will clear interrupt status.

Definition at line 344 of file IdeMode.c.

◆ DRQClear2()

EFI_STATUS EFIAPI DRQClear2 ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_IDE_REGISTERS IdeRegisters,
IN UINT64  Timeout 
)

This function is used to poll for the DRQ bit clear in the Alternate Status Register. DRQ is cleared when the device is finished transferring data. So this function is called after data transfer is finished.

Parameters
PciIoA pointer to EFI_PCI_IO_PROTOCOL data structure.
IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
TimeoutThe time to complete the command, uses 100ns as a unit.
Return values
EFI_SUCCESSDRQ bit clear within the time out.
EFI_TIMEOUTDRQ bit not clear within the time out.
Note
Read Alternate Status Register will not clear interrupt status.

Definition at line 407 of file IdeMode.c.

◆ DRQReady()

EFI_STATUS EFIAPI DRQReady ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_IDE_REGISTERS IdeRegisters,
IN UINT64  Timeout 
)

This function is used to poll for the DRQ bit set in the Status Register. DRQ is set when the device is ready to transfer data. So this function is called after the command is sent to the device and before required data is transferred.

Parameters
PciIoA pointer to EFI_PCI_IO_PROTOCOL data structure.
IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
TimeoutThe time to complete the command, uses 100ns as a unit.
Return values
EFI_SUCCESSBSY bit cleared and DRQ bit set within the timeout.
EFI_TIMEOUTBSY bit not cleared within the timeout.
EFI_ABORTEDPolling abandoned due to command abort.
EFI_DEVICE_ERRORPolling abandoned due to a non-abort error.
EFI_NOT_READYBSY bit cleared within timeout, and device reported "command complete" by clearing DRQ bit.
Note
Read Status Register will clear interrupt status.

Definition at line 481 of file IdeMode.c.

◆ DRQReady2()

EFI_STATUS EFIAPI DRQReady2 ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_IDE_REGISTERS IdeRegisters,
IN UINT64  Timeout 
)

This function is used to poll for the DRQ bit set in the Alternate Status Register. DRQ is set when the device is ready to transfer data. So this function is called after the command is sent to the device and before required data is transferred.

Parameters
PciIoA pointer to EFI_PCI_IO_PROTOCOL data structure.
IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
TimeoutThe time to complete the command, uses 100ns as a unit.
Return values
EFI_SUCCESSBSY bit cleared and DRQ bit set within the timeout.
EFI_TIMEOUTBSY bit not cleared within the timeout.
EFI_ABORTEDPolling abandoned due to command abort.
EFI_DEVICE_ERRORPolling abandoned due to a non-abort error.
EFI_NOT_READYBSY bit cleared within timeout, and device reported "command complete" by clearing DRQ bit.
Note
Read Alternate Status Register will not clear interrupt status.

Definition at line 567 of file IdeMode.c.

◆ DumpAllIdeRegisters()

VOID EFIAPI DumpAllIdeRegisters ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_IDE_REGISTERS IdeRegisters,
IN OUT EFI_ATA_STATUS_BLOCK AtaStatusBlock 
)

This function is used to analyze the Status Register and print out some debug information and if there is ERR bit set in the Status Register, the Error Register's value is also be parsed and print out.

Parameters
PciIoA pointer to EFI_PCI_IO_PROTOCOL data structure.
IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
AtaStatusBlockA pointer to EFI_ATA_STATUS_BLOCK data structure.

Definition at line 219 of file IdeMode.c.

◆ GetIdeRegisterIoAddr()

EFI_STATUS EFIAPI GetIdeRegisterIoAddr ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN OUT EFI_IDE_REGISTERS IdeRegisters 
)

Get IDE i/o port registers' base addresses by mode.

In 'Compatibility' mode, use fixed addresses. In Native-PCI mode, get base addresses from BARs in the PCI IDE controller's Configuration Space.

The steps to get IDE i/o port registers' base addresses for each channel as follows:

  1. Examine the Programming Interface byte of the Class Code fields in PCI IDE controller's Configuration Space to determine the operating mode.
  2. a) In 'Compatibility' mode, use fixed addresses shown in the Table 1 below.
    | | Command Block | Control Block | | Channel | Registers | Registers | |___________|_______________|_______________| | Primary | 1F0h - 1F7h | 3F6h - 3F7h | |___________|_______________|_______________| | Secondary | 170h - 177h | 376h - 377h | |___________|_______________|_______________|

Table 1. Compatibility resource mappings

b) In Native-PCI mode, IDE registers are mapped into IO space using the BARs in IDE controller's PCI Configuration Space, shown in the Table 2 below.


| | Command Block | Control Block | | Channel | Registers | Registers | |___________|___________________|___________________| | Primary | BAR at offset 0x10| BAR at offset 0x14| |___________|___________________|___________________| | Secondary | BAR at offset 0x18| BAR at offset 0x1C| |___________|___________________|___________________|

Table 2. BARs for Register Mapping

Parameters
[in]PciIoPointer to the EFI_PCI_IO_PROTOCOL instance
[in,out]IdeRegistersPointer to EFI_IDE_REGISTERS which is used to store the IDE i/o port registers' base addresses
Return values
EFI_UNSUPPORTEDReturn this value when the BARs is not IO type
EFI_SUCCESSGet the Base address successfully
OtherRead the pci configuration data error

Definition at line 728 of file IdeMode.c.

◆ IdeAtaSmartReturnStatusCheck()

EFI_STATUS EFIAPI IdeAtaSmartReturnStatusCheck ( IN ATA_ATAPI_PASS_THRU_INSTANCE Instance,
IN UINT8  Channel,
IN UINT8  Device,
IN OUT EFI_ATA_STATUS_BLOCK AtaStatusBlock 
)

Send SMART Return Status command to check if the execution of SMART cmd is successful or not.

Parameters
InstanceA pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
ChannelThe channel number of device.
DeviceThe device number of device.
AtaStatusBlockA pointer to EFI_ATA_STATUS_BLOCK data structure.
Return values
EFI_SUCCESSSuccessfully get the return status of S.M.A.R.T command execution.
OthersFail to get return status data.

Definition at line 2036 of file IdeMode.c.

◆ IdeAtaSmartSupport()

VOID EFIAPI IdeAtaSmartSupport ( IN ATA_ATAPI_PASS_THRU_INSTANCE Instance,
IN UINT8  Channel,
IN UINT8  Device,
IN EFI_IDENTIFY_DATA IdentifyData,
IN OUT EFI_ATA_STATUS_BLOCK AtaStatusBlock 
)

Enable SMART command of the disk if supported.

Parameters
InstanceA pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
ChannelThe channel number of device.
DeviceThe device number of device.
IdentifyDataA pointer to data buffer which is used to contain IDENTIFY data.
AtaStatusBlockA pointer to EFI_ATA_STATUS_BLOCK data structure.

Definition at line 2119 of file IdeMode.c.

◆ IdeModeInitialization()

EFI_STATUS EFIAPI IdeModeInitialization ( IN ATA_ATAPI_PASS_THRU_INSTANCE Instance)

Initialize ATA host controller at IDE mode.

The function is designed to initialize ATA host controller.

Parameters
[in]InstanceA pointer to the ATA_ATAPI_PASS_THRU_INSTANCE instance.

Definition at line 2601 of file IdeMode.c.

◆ IdeReadPortB()

UINT8 EFIAPI IdeReadPortB ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT16  Port 
)

read a one-byte data from a IDE port.

Parameters
PciIoA pointer to EFI_PCI_IO_PROTOCOL data structure
PortThe IDE Port number
Returns
the one-byte data read from IDE port

Definition at line 21 of file IdeMode.c.

◆ IdeReadPortWMultiple()

VOID EFIAPI IdeReadPortWMultiple ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT16  Port,
IN UINTN  Count,
IN VOID *  Buffer 
)

Reads multiple words of data from the IDE data port. Call the IO abstraction once to do the complete read, not one word at a time

Parameters
PciIoA pointer to EFI_PCI_IO_PROTOCOL data structure
PortIO port to read
CountNumber of UINT16's to read
BufferPointer to the data buffer for read

Definition at line 184 of file IdeMode.c.

◆ IdeWritePortB()

VOID EFIAPI IdeWritePortB ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT16  Port,
IN UINT8  Data 
)

write a 1-byte data to a specific IDE port.

Parameters
PciIoA pointer to EFI_PCI_IO_PROTOCOL data structure
PortThe IDE port to be written
DataThe data to write to the port

Definition at line 54 of file IdeMode.c.

◆ IdeWritePortDW()

VOID EFIAPI IdeWritePortDW ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT16  Port,
IN UINT32  Data 
)

write a 2-word data to a specific IDE port.

Parameters
PciIoA pointer to EFI_PCI_IO_PROTOCOL data structure
PortThe IDE port to be written
DataThe data to write to the port

Definition at line 114 of file IdeMode.c.

◆ IdeWritePortW()

VOID EFIAPI IdeWritePortW ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT16  Port,
IN UINT16  Data 
)

write a 1-word data to a specific IDE port.

Parameters
PciIoA pointer to EFI_PCI_IO_PROTOCOL data structure
PortThe IDE port to be written
DataThe data to write to the port

Definition at line 84 of file IdeMode.c.

◆ IdeWritePortWMultiple()

VOID EFIAPI IdeWritePortWMultiple ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN UINT16  Port,
IN UINTN  Count,
IN VOID *  Buffer 
)

Write multiple words of data to the IDE data port. Call the IO abstraction once to do the complete read, not one word at a time

Parameters
PciIoA pointer to EFI_PCI_IO_PROTOCOL data structure
PortIO port to read
CountNo. of UINT16's to read
BufferPointer to the data buffer for read

Definition at line 148 of file IdeMode.c.

◆ SetDeviceTransferMode()

EFI_STATUS EFIAPI SetDeviceTransferMode ( IN ATA_ATAPI_PASS_THRU_INSTANCE Instance,
IN UINT8  Channel,
IN UINT8  Device,
IN EFI_ATA_TRANSFER_MODE TransferMode,
IN OUT EFI_ATA_STATUS_BLOCK AtaStatusBlock 
)

Set the calculated Best transfer mode to a detected device.

Parameters
InstanceA pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
ChannelThe channel number of device.
DeviceThe device number of device.
TransferModeA pointer to EFI_ATA_TRANSFER_MODE data structure.
AtaStatusBlockA pointer to EFI_ATA_STATUS_BLOCK data structure.
Return values
EFI_SUCCESSSet transfer mode successfully.
EFI_DEVICE_ERRORSet transfer mode failed.
EFI_OUT_OF_RESOURCESAllocate memory failed.

Definition at line 1917 of file IdeMode.c.

◆ SetDriveParameters()

EFI_STATUS EFIAPI SetDriveParameters ( IN ATA_ATAPI_PASS_THRU_INSTANCE Instance,
IN UINT8  Channel,
IN UINT8  Device,
IN EFI_ATA_DRIVE_PARMS DriveParameters,
IN OUT EFI_ATA_STATUS_BLOCK AtaStatusBlock 
)

Set drive parameters for devices not support PACKETS command.

Parameters
InstanceA pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
ChannelThe channel number of device.
DeviceThe device number of device.
DriveParametersA pointer to EFI_ATA_DRIVE_PARMS data structure.
AtaStatusBlockA pointer to EFI_ATA_STATUS_BLOCK data structure.
Return values
EFI_SUCCESSSet drive parameter successfully.
EFI_DEVICE_ERRORSet drive parameter failed.
EFI_OUT_OF_RESOURCESAllocate memory failed.

Definition at line 1966 of file IdeMode.c.

◆ WaitForBSYClear()

EFI_STATUS EFIAPI WaitForBSYClear ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_IDE_REGISTERS IdeRegisters,
IN UINT64  Timeout 
)

This function is used to poll for the BSY bit clear in the Status Register. BSY is clear when the device is not busy. Every command must be sent after device is not busy.

Parameters
PciIoA pointer to ATA_ATAPI_PASS_THRU_INSTANCE data structure.
IdeRegistersA pointer to EFI_IDE_REGISTERS data structure.
TimeoutThe time to complete the command, uses 100ns as a unit.
Return values
EFI_SUCCESSBSY bit clear within the time out.
EFI_TIMEOUTBSY bit not clear within the time out.
Note
Read Status Register will clear interrupt status.

Definition at line 641 of file IdeMode.c.