TianoCore EDK2 master
|
#include <PiPei.h>
#include <IndustryStandard/Atapi.h>
#include <Ppi/AtaAhciController.h>
#include <Ppi/IoMmu.h>
#include <Ppi/EndOfPeiPhase.h>
#include <Ppi/AtaPassThru.h>
#include <Ppi/BlockIo.h>
#include <Ppi/BlockIo2.h>
#include <Ppi/StorageSecurityCommand.h>
#include <Library/DebugLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/IoLib.h>
#include <Library/TimerLib.h>
#include <Library/DevicePathLib.h>
#include "AhciPeiPassThru.h"
#include "AhciPeiBlockIo.h"
#include "AhciPeiStorageSecurity.h"
Go to the source code of this file.
Data Structures | |
struct | DATA_32 |
union | DATA_64 |
struct | EFI_AHCI_RECEIVED_FIS |
struct | EFI_AHCI_COMMAND_LIST |
struct | EFI_AHCI_COMMAND_FIS |
struct | EFI_AHCI_ATAPI_COMMAND |
struct | EFI_AHCI_COMMAND_PRDT |
struct | EFI_AHCI_COMMAND_TABLE |
struct | EFI_AHCI_REGISTERS |
struct | PEI_AHCI_ATA_DEVICE_DATA |
struct | _PEI_AHCI_CONTROLLER_PRIVATE_DATA |
Typedefs | |
typedef struct _PEI_AHCI_CONTROLLER_PRIVATE_DATA | PEI_AHCI_CONTROLLER_PRIVATE_DATA |
Functions | |
EFI_STATUS EFIAPI | AtaAhciHostControllerPpiInstallationCallback (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi) |
EFI_STATUS EFIAPI | AtaAhciPciDevicePpiInstallationCallback (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi) |
EFI_STATUS | IoMmuAllocateBuffer (IN UINTN Pages, OUT VOID **HostAddress, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping) |
EFI_STATUS | IoMmuFreeBuffer (IN UINTN Pages, IN VOID *HostAddress, IN VOID *Mapping) |
EFI_STATUS | IoMmuMap (IN EDKII_IOMMU_OPERATION Operation, IN VOID *HostAddress, IN OUT UINTN *NumberOfBytes, OUT EFI_PHYSICAL_ADDRESS *DeviceAddress, OUT VOID **Mapping) |
EFI_STATUS | IoMmuUnmap (IN VOID *Mapping) |
EFI_STATUS EFIAPI | AhciPeimEndOfPei (IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi) |
UINT8 | AhciGetNumberOfPortsFromMap (IN UINT32 PortBitMap) |
EFI_STATUS | AhciPioTransfer (IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private, IN UINT8 Port, IN UINT8 PortMultiplier, IN UINT8 FisIndex, IN BOOLEAN Read, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN OUT VOID *MemoryAddr, IN UINT32 DataCount, IN UINT64 Timeout) |
EFI_STATUS | AhciNonDataTransfer (IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private, IN UINT8 Port, IN UINT8 PortMultiplier, IN UINT8 FisIndex, IN EFI_ATA_COMMAND_BLOCK *AtaCommandBlock, IN OUT EFI_ATA_STATUS_BLOCK *AtaStatusBlock, IN UINT64 Timeout) |
EFI_STATUS | AhciModeInitialization (IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private) |
EFI_STATUS | TransferAtaDevice (IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData, IN OUT VOID *Buffer, IN EFI_LBA StartLba, IN UINT32 TransferLength, IN BOOLEAN IsWrite) |
EFI_STATUS | TrustTransferAtaDevice (IN PEI_AHCI_ATA_DEVICE_DATA *DeviceData, IN OUT VOID *Buffer, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN TransferLength, IN BOOLEAN IsTrustSend, IN UINT64 Timeout, OUT UINTN *TransferLengthOut) |
EFI_STATUS | GetDevicePathInstanceSize (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, OUT UINTN *InstanceSize, OUT BOOLEAN *EntireDevicePathEnd) |
EFI_STATUS | AhciIsHcDevicePathValid (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN UINTN DevicePathLength) |
EFI_STATUS | AhciBuildDevicePath (IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private, IN UINT16 Port, IN UINT16 PortMultiplierPort, OUT UINTN *DevicePathLength, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath) |
UINT8 | AhciS3GetEumeratePorts (IN EFI_DEVICE_PATH_PROTOCOL *HcDevicePath, IN UINTN HcDevicePathLength, OUT UINT32 *PortBitMap) |
Variables | |
UINT32 | mMaxTransferBlockNumber [2] |
The AhciPei driver is used to manage ATA hard disk device working under AHCI mode at PEI phase.
Copyright (c) 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file AhciPei.h.
#define AHCI_PEI_ATA_DEVICE_DATA_SIGNATURE SIGNATURE_32 ('A', 'P', 'A', 'D') |
#define AHCI_PEI_ATA_DEVICE_INFO_FROM_THIS | ( | a | ) |
#define AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('A','P','C','P') |
#define AHCI_PORT_CMD_ICC_MASK (BIT28 | BIT29 | BIT30 | BIT31) |
#define GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO | ( | a | ) | CR (a, PEI_AHCI_CONTROLLER_PRIVATE_DATA, BlkIoPpi, AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE) |
#define GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_BLKIO2 | ( | a | ) | CR (a, PEI_AHCI_CONTROLLER_PRIVATE_DATA, BlkIo2Ppi, AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE) |
#define GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY | ( | a | ) | CR (a, PEI_AHCI_CONTROLLER_PRIVATE_DATA, EndOfPeiNotifyList, AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE) |
#define GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_PASS_THRU | ( | a | ) | CR (a, PEI_AHCI_CONTROLLER_PRIVATE_DATA, AtaPassThruPpi, AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE) |
#define GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_STROAGE_SECURITY | ( | a | ) | CR (a, PEI_AHCI_CONTROLLER_PRIVATE_DATA, StorageSecurityPpi, AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE) |
#define TIMER_PERIOD_SECONDS | ( | Seconds | ) | MultU64x32((UINT64)(Seconds), 10000000) |
EFI_STATUS AhciBuildDevicePath | ( | IN PEI_AHCI_CONTROLLER_PRIVATE_DATA * | Private, |
IN UINT16 | Port, | ||
IN UINT16 | PortMultiplierPort, | ||
OUT UINTN * | DevicePathLength, | ||
OUT EFI_DEVICE_PATH_PROTOCOL ** | DevicePath | ||
) |
Build the device path for an ATA device with given port and port multiplier number.
[in] | Private | A pointer to the PEI_AHCI_CONTROLLER_PRIVATE_DATA data structure. |
[in] | Port | The given port number. |
[in] | PortMultiplierPort | The given port multiplier number. |
[out] | DevicePathLength | The length of the device path in bytes specified by DevicePath. |
[out] | DevicePath | The device path of ATA device. |
EFI_SUCCESS | The operation succeeds. |
EFI_INVALID_PARAMETER | The parameters are invalid. |
EFI_OUT_OF_RESOURCES | The operation fails due to lack of resources. |
Definition at line 177 of file DevicePath.c.
UINT8 AhciGetNumberOfPortsFromMap | ( | IN UINT32 | PortBitMap | ) |
Collect the number of bits set within a port bitmap.
[in] | PortBitMap | A 32-bit wide bit map of ATA AHCI ports. |
The | number of bits set in the bitmap. |
Definition at line 1190 of file AhciMode.c.
EFI_STATUS AhciIsHcDevicePathValid | ( | IN EFI_DEVICE_PATH_PROTOCOL * | DevicePath, |
IN UINTN | DevicePathLength | ||
) |
Check the validity of the device path of a ATA AHCI host controller.
[in] | DevicePath | A pointer to the EFI_DEVICE_PATH_PROTOCOL structure. |
[in] | DevicePathLength | The length of the device path. |
EFI_SUCCESS | The device path is valid. |
EFI_INVALID_PARAMETER | The device path is invalid. |
Definition at line 106 of file DevicePath.c.
EFI_STATUS AhciModeInitialization | ( | IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA * | Private | ) |
Initialize ATA host controller at AHCI mode.
The function is designed to initialize ATA host controller.
[in,out] | Private | A pointer to the PEI_AHCI_CONTROLLER_PRIVATE_DATA instance. |
EFI_SUCCESS | The ATA AHCI controller is initialized successfully. |
EFI_OUT_OF_RESOURCES | Not enough resource to complete while initializing the controller. |
Others | A device error occurred while initializing the controller. |
Definition at line 1664 of file AhciMode.c.
EFI_STATUS AhciNonDataTransfer | ( | IN PEI_AHCI_CONTROLLER_PRIVATE_DATA * | Private, |
IN UINT8 | Port, | ||
IN UINT8 | PortMultiplier, | ||
IN UINT8 | FisIndex, | ||
IN EFI_ATA_COMMAND_BLOCK * | AtaCommandBlock, | ||
IN OUT EFI_ATA_STATUS_BLOCK * | AtaStatusBlock, | ||
IN UINT64 | Timeout | ||
) |
Start a non data transfer on specific port.
[in] | Private | The pointer to the PEI_AHCI_CONTROLLER_PRIVATE_DATA. |
[in] | Port | The number of port. |
[in] | PortMultiplier | The number of port multiplier. |
[in] | FisIndex | The offset index of the FIS base address. |
[in] | AtaCommandBlock | The EFI_ATA_COMMAND_BLOCK data. |
[in,out] | AtaStatusBlock | The EFI_ATA_STATUS_BLOCK data. |
[in] | Timeout | The timeout value of non data transfer, uses 100ns as a unit. |
EFI_DEVICE_ERROR | The non data transfer abort with error occurs. |
EFI_TIMEOUT | The operation is time out. |
EFI_UNSUPPORTED | The device is not ready for transfer. |
EFI_SUCCESS | The non data transfer executes successfully. |
Definition at line 981 of file AhciMode.c.
EFI_STATUS EFIAPI AhciPeimEndOfPei | ( | IN EFI_PEI_SERVICES ** | PeiServices, |
IN EFI_PEI_NOTIFY_DESCRIPTOR * | NotifyDescriptor, | ||
IN VOID * | Ppi | ||
) |
One notified function to cleanup the allocated DMA buffers at EndOfPei.
[in] | PeiServices | Pointer to PEI Services Table. |
[in] | NotifyDescriptor | Pointer to the descriptor for the Notification event that caused this function to execute. |
[in] | Ppi | Pointer to the PPI data associated with this function. |
EFI_SUCCESS | The function completes successfully |
EFI_STATUS AhciPioTransfer | ( | IN PEI_AHCI_CONTROLLER_PRIVATE_DATA * | Private, |
IN UINT8 | Port, | ||
IN UINT8 | PortMultiplier, | ||
IN UINT8 | FisIndex, | ||
IN BOOLEAN | Read, | ||
IN EFI_ATA_COMMAND_BLOCK * | AtaCommandBlock, | ||
IN OUT EFI_ATA_STATUS_BLOCK * | AtaStatusBlock, | ||
IN OUT VOID * | MemoryAddr, | ||
IN UINT32 | DataCount, | ||
IN UINT64 | Timeout | ||
) |
Start a PIO Data transfer on specific port.
[in] | Private | The pointer to the PEI_AHCI_CONTROLLER_PRIVATE_DATA. |
[in] | Port | The number of port. |
[in] | PortMultiplier | The number of port multiplier. |
[in] | FisIndex | The offset index of the FIS base address. |
[in] | Read | The transfer direction. |
[in] | AtaCommandBlock | The EFI_ATA_COMMAND_BLOCK data. |
[in,out] | AtaStatusBlock | The EFI_ATA_STATUS_BLOCK data. |
[in,out] | MemoryAddr | The pointer to the data buffer. |
[in] | DataCount | The data count to be transferred. |
[in] | Timeout | The timeout value of PIO data transfer, uses 100ns as a unit. |
EFI_DEVICE_ERROR | The PIO data transfer abort with error occurs. |
EFI_TIMEOUT | The operation is time out. |
EFI_UNSUPPORTED | The device is not ready for transfer. |
EFI_OUT_OF_RESOURCES | The operation fails due to lack of resources. |
EFI_SUCCESS | The PIO data transfer executes successfully. |
Definition at line 717 of file AhciMode.c.
UINT8 AhciS3GetEumeratePorts | ( | IN EFI_DEVICE_PATH_PROTOCOL * | HcDevicePath, |
IN UINTN | HcDevicePathLength, | ||
OUT UINT32 * | PortBitMap | ||
) |
Collect the ports that need to be enumerated on a controller for S3 phase.
[in] | HcDevicePath | Device path of the controller. |
[in] | HcDevicePathLength | Length of the device path specified by HcDevicePath. |
[out] | PortBitMap | Bitmap that indicates the ports that need to be enumerated on the controller. |
The | number of ports that need to be enumerated. |
Definition at line 30 of file AhciPeiS3.c.
EFI_STATUS EFIAPI AtaAhciHostControllerPpiInstallationCallback | ( | IN EFI_PEI_SERVICES ** | PeiServices, |
IN EFI_PEI_NOTIFY_DESCRIPTOR * | NotifyDescriptor, | ||
IN VOID * | Ppi | ||
) |
Callback for EDKII_ATA_AHCI_HOST_CONTROLLER_PPI installation.
[in] | PeiServices | Pointer to PEI Services Table. |
[in] | NotifyDescriptor | Pointer to the descriptor for the Notification event that caused this function to execute. |
[in] | Ppi | Pointer to the PPI data associated with this function. |
EFI_SUCCESS | The function completes successfully |
Others | Cannot initialize AHCI controller from given EDKII_ATA_AHCI_HOST_CONTROLLER_PPI |
EFI_STATUS EFIAPI AtaAhciPciDevicePpiInstallationCallback | ( | IN EFI_PEI_SERVICES ** | PeiServices, |
IN EFI_PEI_NOTIFY_DESCRIPTOR * | NotifyDescriptor, | ||
IN VOID * | Ppi | ||
) |
Callback for EDKII_PCI_DEVICE_PPI installation.
[in] | PeiServices | Pointer to PEI Services Table. |
[in] | NotifyDescriptor | Pointer to the descriptor for the Notification event that caused this function to execute. |
[in] | Ppi | Pointer to the PPI data associated with this function. |
EFI_SUCCESS | The function completes successfully |
Others | Cannot initialize AHCI controller from given PCI_DEVICE_PPI |
EFI_STATUS GetDevicePathInstanceSize | ( | IN EFI_DEVICE_PATH_PROTOCOL * | DevicePath, |
OUT UINTN * | InstanceSize, | ||
OUT BOOLEAN * | EntireDevicePathEnd | ||
) |
Get the size of the current device path instance.
[in] | DevicePath | A pointer to the EFI_DEVICE_PATH_PROTOCOL structure. |
[out] | InstanceSize | The size of the current device path instance. |
[out] | EntireDevicePathEnd | Indicate whether the instance is the last one in the device path strucure. |
EFI_SUCCESS | The size of the current device path instance is fetched. |
Others | Fails to get the size of the current device path instance. |
Definition at line 55 of file DevicePath.c.
EFI_STATUS IoMmuAllocateBuffer | ( | IN UINTN | Pages, |
OUT VOID ** | HostAddress, | ||
OUT EFI_PHYSICAL_ADDRESS * | DeviceAddress, | ||
OUT VOID ** | Mapping | ||
) |
Allocates pages that are suitable for an OperationBusMasterCommonBuffer or OperationBusMasterCommonBuffer64 mapping.
Pages | The number of pages to allocate. |
HostAddress | A pointer to store the base system memory address of the allocated range. |
DeviceAddress | The resulting map address for the bus master PCI controller to use to access the hosts HostAddress. |
Mapping | A resulting value to pass to Unmap(). |
EFI_SUCCESS | The requested memory pages were allocated. |
EFI_UNSUPPORTED | Attributes is unsupported. The only legal attribute bits are MEMORY_WRITE_COMBINE and MEMORY_CACHED. |
EFI_INVALID_PARAMETER | One or more parameters are invalid. |
EFI_OUT_OF_RESOURCES | The memory pages could not be allocated. |
EFI_STATUS IoMmuFreeBuffer | ( | IN UINTN | Pages, |
IN VOID * | HostAddress, | ||
IN VOID * | Mapping | ||
) |
Frees memory that was allocated with AllocateBuffer().
Pages | The number of pages to free. |
HostAddress | The base system memory address of the allocated range. |
Mapping | The mapping value returned from Map(). |
EFI_SUCCESS | The requested memory pages were freed. |
EFI_INVALID_PARAMETER | The memory range specified by HostAddress and Pages was not allocated with AllocateBuffer(). |
EFI_STATUS IoMmuMap | ( | IN EDKII_IOMMU_OPERATION | Operation, |
IN VOID * | HostAddress, | ||
IN OUT UINTN * | NumberOfBytes, | ||
OUT EFI_PHYSICAL_ADDRESS * | DeviceAddress, | ||
OUT VOID ** | Mapping | ||
) |
Provides the controller-specific addresses required to access system memory from a DMA bus master.
Operation | Indicates if the bus master is going to read or write to system memory. |
HostAddress | The system memory address to map to the PCI controller. |
NumberOfBytes | On input the number of bytes to map. On output the number of bytes that were mapped. |
DeviceAddress | The resulting map address for the bus master PCI controller to use to access the hosts HostAddress. |
Mapping | A resulting value to pass to Unmap(). |
EFI_SUCCESS | The range was mapped for the returned NumberOfBytes. |
EFI_UNSUPPORTED | The HostAddress cannot be mapped as a common buffer. |
EFI_INVALID_PARAMETER | One or more parameters are invalid. |
EFI_OUT_OF_RESOURCES | The request could not be completed due to a lack of resources. |
EFI_DEVICE_ERROR | The system hardware could not map the requested address. |
EFI_STATUS IoMmuUnmap | ( | IN VOID * | Mapping | ) |
Completes the Map() operation and releases any corresponding resources.
Mapping | The mapping value returned from Map(). |
EFI_SUCCESS | The range was unmapped. |
EFI_INVALID_PARAMETER | Mapping is not a value that was returned by Map(). |
EFI_DEVICE_ERROR | The data was not committed to the target system memory. |
EFI_STATUS TransferAtaDevice | ( | IN PEI_AHCI_ATA_DEVICE_DATA * | DeviceData, |
IN OUT VOID * | Buffer, | ||
IN EFI_LBA | StartLba, | ||
IN UINT32 | TransferLength, | ||
IN BOOLEAN | IsWrite | ||
) |
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.
[in] | DeviceData | A pointer to PEI_AHCI_ATA_DEVICE_DATA structure. |
[in,out] | Buffer | The pointer to the current transaction buffer. |
[in] | StartLba | The starting logical block address to be accessed. |
[in] | TransferLength | The block number or sector count of the transfer. |
[in] | IsWrite | Indicates whether it is a write operation. |
EFI_SUCCESS | The data transfer is complete successfully. |
Definition at line 1924 of file AhciMode.c.
EFI_STATUS TrustTransferAtaDevice | ( | IN PEI_AHCI_ATA_DEVICE_DATA * | DeviceData, |
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.
[in] | DeviceData | Pointer to PEI_AHCI_ATA_DEVICE_DATA structure. |
[in,out] | Buffer | The pointer to the current transaction buffer. |
[in] | SecurityProtocolId | The value of the "Security Protocol" parameter of the security protocol command to be sent. |
[in] | SecurityProtocolSpecificData | The value of the "Security Protocol Specific" parameter of the security protocol command to be sent. |
[in] | TransferLength | The block number or sector count of the transfer. |
[in] | IsTrustSend | Indicates whether it is a trust send operation or not. |
[in] | Timeout | The 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. |
[out] | TransferLengthOut | A pointer to a buffer to store the size in bytes of the data written to the buffer. Ignore it when IsTrustSend is TRUE. |
EFI_SUCCESS | The data transfer is complete successfully. |
Definition at line 2063 of file AhciMode.c.
|
extern |
Definition at line 59 of file AhciMode.c.