TianoCore EDK2 master
Loading...
Searching...
No Matches
AtaPassThruExecute.c File Reference
#include "AtaBus.h"

Go to the source code of this file.

Macros

#define ATA_CMD_TRUST_NON_DATA   0x5B
 
#define ATA_CMD_TRUST_RECEIVE   0x5C
 
#define ATA_CMD_TRUST_RECEIVE_DMA   0x5D
 
#define ATA_CMD_TRUST_SEND   0x5E
 
#define ATA_CMD_TRUST_SEND_DMA   0x5F
 

Functions

EFI_STATUS AtaDevicePassThru (IN OUT ATA_DEVICE *AtaDevice, IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *TaskPacket OPTIONAL, IN OUT EFI_EVENT Event OPTIONAL)
 
EFI_STATUS ResetAtaDevice (IN ATA_DEVICE *AtaDevice)
 
VOID PrintAtaModelName (IN OUT ATA_DEVICE *AtaDevice)
 
EFI_LBA GetAtapi6Capacity (IN ATA_DEVICE *AtaDevice)
 
EFI_STATUS IdentifyAtaDevice (IN OUT ATA_DEVICE *AtaDevice)
 
EFI_STATUS DiscoverAtaDevice (IN OUT ATA_DEVICE *AtaDevice)
 
EFI_STATUS TransferAtaDevice (IN OUT ATA_DEVICE *AtaDevice, IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *TaskPacket OPTIONAL, IN OUT VOID *Buffer, IN EFI_LBA StartLba, IN UINT32 TransferLength, IN BOOLEAN IsWrite, IN EFI_EVENT Event OPTIONAL)
 
VOID EFIAPI FreeAtaSubTask (IN OUT ATA_BUS_ASYN_SUB_TASK *Task)
 
VOID EFIAPI AtaTerminateNonBlockingTask (IN ATA_DEVICE *AtaDevice)
 
VOID EFIAPI AtaNonBlockingCallBack (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_STATUS AccessAtaDevice (IN OUT ATA_DEVICE *AtaDevice, IN OUT UINT8 *Buffer, IN EFI_LBA StartLba, IN UINTN NumberOfBlocks, IN BOOLEAN IsWrite, IN OUT EFI_BLOCK_IO2_TOKEN *Token)
 
EFI_STATUS EFIAPI TrustTransferAtaDevice (IN OUT ATA_DEVICE *AtaDevice, IN OUT VOID *Buffer, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN TransferLength, IN BOOLEAN IsTrustSend, IN UINT64 Timeout, OUT UINTN *TransferLengthOut)
 

Variables

EFI_ATA_PASS_THRU_CMD_PROTOCOL mAtaPassThruCmdProtocols [][2]
 
UINT8 mAtaCommands [][2][2]
 
UINT8 mAtaTrustCommands [2][2]
 
UINTN mMaxTransferBlockNumber []
 

Detailed Description

This file implements ATA pass through transaction for ATA bus driver.

This file implements the low level execution of ATA pass through transaction. It transforms the high level identity, read/write, reset command to ATA pass through command and protocol.

NOTE: This file also implements the StorageSecurityCommandProtocol(SSP). For input parameter SecurityProtocolSpecificData, ATA spec has no explicitly definition for Security Protocol Specific layout. This implementation uses big endian for Cylinder register.

Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file AtaPassThruExecute.c.

Macro Definition Documentation

◆ ATA_CMD_TRUST_NON_DATA

#define ATA_CMD_TRUST_NON_DATA   0x5B

Definition at line 22 of file AtaPassThruExecute.c.

◆ ATA_CMD_TRUST_RECEIVE

#define ATA_CMD_TRUST_RECEIVE   0x5C

Definition at line 23 of file AtaPassThruExecute.c.

◆ ATA_CMD_TRUST_RECEIVE_DMA

#define ATA_CMD_TRUST_RECEIVE_DMA   0x5D

Definition at line 24 of file AtaPassThruExecute.c.

◆ ATA_CMD_TRUST_SEND

#define ATA_CMD_TRUST_SEND   0x5E

Definition at line 25 of file AtaPassThruExecute.c.

◆ ATA_CMD_TRUST_SEND_DMA

#define ATA_CMD_TRUST_SEND_DMA   0x5F

Definition at line 26 of file AtaPassThruExecute.c.

Function Documentation

◆ AccessAtaDevice()

EFI_STATUS AccessAtaDevice ( IN OUT ATA_DEVICE AtaDevice,
IN OUT UINT8 *  Buffer,
IN EFI_LBA  StartLba,
IN UINTN  NumberOfBlocks,
IN BOOLEAN  IsWrite,
IN OUT EFI_BLOCK_IO2_TOKEN Token 
)

Read or write a number of blocks from ATA device.

This function performs ATA pass through transactions to read/write data from/to ATA device. It may separate the read/write request into several ATA pass through transactions.

Parameters
[in,out]AtaDeviceThe ATA child device involved for the operation.
[in,out]BufferThe pointer to the current transaction buffer.
[in]StartLbaThe starting logical block address to be accessed.
[in]NumberOfBlocksThe block number or sector count of the transfer.
[in]IsWriteIndicates whether it is a write operation.
[in,out]TokenA pointer to the token associated with the transaction.
Return values
EFI_SUCCESSThe data transfer is complete successfully.
Returns
others Some error occurs when transferring data.

Definition at line 765 of file AtaPassThruExecute.c.

◆ AtaDevicePassThru()

EFI_STATUS AtaDevicePassThru ( IN OUT ATA_DEVICE AtaDevice,
IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *TaskPacket  OPTIONAL,
IN OUT EFI_EVENT Event  OPTIONAL 
)

Wrapper for EFI_ATA_PASS_THRU_PROTOCOL.PassThru().

This function wraps the PassThru() invocation for ATA pass through function for an ATA device. It assembles the ATA pass through command packet for ATA transaction.

Parameters
[in,out]AtaDeviceThe ATA child device involved for the operation.
[in,out]TaskPacketPointer to a Pass Thru Command Packet. Optional, if it is NULL, blocking mode, and use the packet in AtaDevice. If it is not NULL, non blocking mode, and pass down this Packet.
[in,out]EventIf Event is NULL, then blocking I/O is performed. If Event is not NULL and non-blocking I/O is supported,then non-blocking I/O is performed, and Event will be signaled when the write request is completed.
Returns
The return status from EFI_ATA_PASS_THRU_PROTOCOL.PassThru().

Definition at line 112 of file AtaPassThruExecute.c.

◆ AtaNonBlockingCallBack()

VOID EFIAPI AtaNonBlockingCallBack ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Call back function when the event is signaled.

Parameters
[in]EventThe Event this notify function registered to.
[in]ContextPointer to the context data registered to the Event.

Definition at line 645 of file AtaPassThruExecute.c.

◆ AtaTerminateNonBlockingTask()

VOID EFIAPI AtaTerminateNonBlockingTask ( IN ATA_DEVICE AtaDevice)

Terminate any in-flight non-blocking I/O requests by signaling an EFI_ABORTED in the TransactionStatus member of the EFI_BLOCK_IO2_TOKEN for the non-blocking I/O. After that it is safe to free any Token or Buffer data structures that were allocated to initiate the non-blockingI/O requests that were in-flight for this device.

Parameters
[in]AtaDeviceThe ATA child device involved for the operation.

Definition at line 590 of file AtaPassThruExecute.c.

◆ DiscoverAtaDevice()

EFI_STATUS DiscoverAtaDevice ( IN OUT ATA_DEVICE AtaDevice)

Discovers whether it is a valid ATA device.

This function issues ATA_CMD_IDENTIFY_DRIVE command to the ATA device to identify it. If the command is executed successfully, it then identifies it and initializes the Media information in Block IO protocol interface.

Parameters
AtaDeviceThe ATA child device involved for the operation.
Return values
EFI_SUCCESSThe device is successfully identified and Media information is correctly initialized.
Returns
others Some error occurs when discovering the ATA device.

Definition at line 394 of file AtaPassThruExecute.c.

◆ FreeAtaSubTask()

VOID EFIAPI FreeAtaSubTask ( IN OUT ATA_BUS_ASYN_SUB_TASK Task)

Free SubTask.

Parameters
[in,out]TaskPointer to task to be freed.

Definition at line 563 of file AtaPassThruExecute.c.

◆ GetAtapi6Capacity()

EFI_LBA GetAtapi6Capacity ( IN ATA_DEVICE AtaDevice)

Gets ATA device Capacity according to ATA 6.

This function returns the capacity of the ATA device if it follows ATA 6 to support 48 bit addressing.

Parameters
AtaDeviceThe ATA child device involved for the operation.
Returns
The capacity of the ATA device or 0 if the device does not support 48-bit addressing defined in ATA 6.

Definition at line 242 of file AtaPassThruExecute.c.

◆ IdentifyAtaDevice()

EFI_STATUS IdentifyAtaDevice ( IN OUT ATA_DEVICE AtaDevice)

Identifies ATA device via the Identify data.

This function identifies the ATA device and initializes the Media information in Block IO protocol interface.

Parameters
AtaDeviceThe ATA child device involved for the operation.
Return values
EFI_UNSUPPORTEDThe device is not a valid ATA device (hard disk).
EFI_SUCCESSThe device is successfully identified and Media information is correctly initialized.

Definition at line 288 of file AtaPassThruExecute.c.

◆ PrintAtaModelName()

VOID PrintAtaModelName ( IN OUT ATA_DEVICE AtaDevice)

Prints ATA model name to ATA device structure.

This function converts ATA device model name from ATA identify data to a string in ATA device structure. It needs to change the character order in the original model name string.

Parameters
AtaDeviceThe ATA child device involved for the operation.

Definition at line 207 of file AtaPassThruExecute.c.

◆ ResetAtaDevice()

EFI_STATUS ResetAtaDevice ( IN ATA_DEVICE AtaDevice)

Wrapper for EFI_ATA_PASS_THRU_PROTOCOL.ResetDevice().

This function wraps the ResetDevice() invocation for ATA pass through function for an ATA device.

Parameters
AtaDeviceThe ATA child device involved for the operation.
Returns
The return status from EFI_ATA_PASS_THRU_PROTOCOL.PassThru().

Definition at line 172 of file AtaPassThruExecute.c.

◆ TransferAtaDevice()

EFI_STATUS TransferAtaDevice ( IN OUT ATA_DEVICE AtaDevice,
IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *TaskPacket  OPTIONAL,
IN OUT VOID *  Buffer,
IN EFI_LBA  StartLba,
IN UINT32  TransferLength,
IN BOOLEAN  IsWrite,
IN EFI_EVENT Event  OPTIONAL 
)

Transfer data from ATA device.

This function performs one ATA pass through transaction to transfer data from/to ATA device. It chooses the appropriate ATA command and protocol to invoke PassThru interface of ATA pass through.

Parameters
[in,out]AtaDeviceThe ATA child device involved for the operation.
[in,out]TaskPacketPointer to a Pass Thru Command Packet. Optional, if it is NULL, blocking mode, and use the packet in AtaDevice. If it is not NULL, non blocking mode, and pass down this Packet.
[in,out]BufferThe pointer to the current transaction buffer.
[in]StartLbaThe starting logical block address to be accessed.
[in]TransferLengthThe block number or sector count of the transfer.
[in]IsWriteIndicates whether it is a write operation.
[in]EventIf Event is NULL, then blocking I/O is performed. If Event is not NULL and non-blocking I/O is supported,then non-blocking I/O is performed, and Event will be signaled when the write request is completed.
Return values
EFI_SUCCESSThe data transfer is complete successfully.
Returns
others Some error occurs when transferring data.

Definition at line 462 of file AtaPassThruExecute.c.

◆ TrustTransferAtaDevice()

EFI_STATUS EFIAPI TrustTransferAtaDevice ( IN OUT ATA_DEVICE AtaDevice,
IN OUT VOID *  Buffer,
IN UINT8  SecurityProtocolId,
IN UINT16  SecurityProtocolSpecificData,
IN UINTN  TransferLength,
IN BOOLEAN  IsTrustSend,
IN UINT64  Timeout,
OUT UINTN TransferLengthOut 
)

Trust transfer data from/to ATA device.

This function performs one ATA pass through transaction to do a trust transfer from/to ATA device. It chooses the appropriate ATA command and protocol to invoke PassThru interface of ATA pass through.

Parameters
AtaDeviceThe ATA child device involved for the operation.
BufferThe pointer to the current transaction buffer.
SecurityProtocolIdThe value of the "Security Protocol" parameter of the security protocol command to be sent.
SecurityProtocolSpecificDataThe value of the "Security Protocol Specific" parameter of the security protocol command to be sent.
TransferLengthThe block number or sector count of the transfer.
IsTrustSendIndicates whether it is a trust send operation or not.
TimeoutThe timeout, in 100ns units, to use for the execution of the security protocol command. A Timeout value of 0 means that this function will wait indefinitely for the security protocol command to execute. If Timeout is greater than zero, then this function will return EFI_TIMEOUT if the time required to execute the receive data command is greater than Timeout.
TransferLengthOutA pointer to a buffer to store the size in bytes of the data written to the buffer. Ignore it when IsTrustSend is TRUE.
Return values
EFI_SUCCESSThe data transfer is complete successfully.
Returns
others Some error occurs when transferring data.

Definition at line 987 of file AtaPassThruExecute.c.

Variable Documentation

◆ mAtaCommands

UINT8 mAtaCommands[][2][2]
Initial value:
= {
{
{
},
{
}
},
{
{
},
{
}
}
}
#define ATA_CMD_WRITE_DMA_EXT
defined from ATA-6
Definition: Atapi.h:681
#define ATA_CMD_WRITE_DMA
defined from ATA-1
Definition: Atapi.h:679
#define ATA_CMD_READ_DMA_EXT
defined from ATA-6
Definition: Atapi.h:678
#define ATA_CMD_READ_SECTORS
defined from ATA-1
Definition: Atapi.h:544
#define ATA_CMD_WRITE_SECTORS_EXT
defined from ATA-6
Definition: Atapi.h:563
#define ATA_CMD_READ_SECTORS_EXT
defined from ATA-6
Definition: Atapi.h:548
#define ATA_CMD_WRITE_SECTORS
defined from ATA-1
Definition: Atapi.h:558
#define ATA_CMD_READ_DMA
defined from ATA-1
Definition: Atapi.h:676

Definition at line 45 of file AtaPassThruExecute.c.

◆ mAtaPassThruCmdProtocols

EFI_ATA_PASS_THRU_CMD_PROTOCOL mAtaPassThruCmdProtocols[][2]
Initial value:
= {
{
EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_IN,
EFI_ATA_PASS_THRU_PROTOCOL_PIO_DATA_OUT
},
{
EFI_ATA_PASS_THRU_PROTOCOL_UDMA_DATA_IN,
EFI_ATA_PASS_THRU_PROTOCOL_UDMA_DATA_OUT,
}
}

Definition at line 31 of file AtaPassThruExecute.c.

◆ mAtaTrustCommands

UINT8 mAtaTrustCommands[2][2]
Initial value:
= {
{
ATA_CMD_TRUST_RECEIVE,
ATA_CMD_TRUST_SEND
},
{
ATA_CMD_TRUST_RECEIVE_DMA,
ATA_CMD_TRUST_SEND_DMA
}
}

Definition at line 71 of file AtaPassThruExecute.c.

◆ mMaxTransferBlockNumber

UINTN mMaxTransferBlockNumber[]
Initial value:
= {
MAX_28BIT_TRANSFER_BLOCK_NUM,
MAX_48BIT_TRANSFER_BLOCK_NUM
}

Definition at line 85 of file AtaPassThruExecute.c.