17 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
18 &gEdkiiPeiAtaPassThruPpiGuid,
23 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
24 &gEfiPeiVirtualBlockIoPpiGuid,
29 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
30 &gEfiPeiVirtualBlockIo2PpiGuid,
35 (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
36 &gEdkiiPeiStorageSecurityCommandPpiGuid,
41 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
42 &gEfiEndOfPeiSignalPpiGuid,
47 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
48 &gEdkiiPeiAtaAhciHostControllerPpiGuid,
53 (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
54 &gEdkiiPeiPciDevicePpiGuid,
72 ASSERT (Private !=
NULL);
74 AhciRegisters = &Private->AhciRegisters;
76 if (AhciRegisters->AhciRFisMap !=
NULL) {
79 AhciRegisters->AhciRFis,
80 AhciRegisters->AhciRFisMap
84 if (AhciRegisters->AhciCmdListMap !=
NULL) {
87 AhciRegisters->AhciCmdList,
88 AhciRegisters->AhciCmdListMap
92 if (AhciRegisters->AhciCmdTableMap !=
NULL) {
95 AhciRegisters->AhciCmdTable,
96 AhciRegisters->AhciCmdTableMap
122 Private = GET_AHCI_PEIM_HC_PRIVATE_DATA_FROM_THIS_NOTIFY (NotifyDescriptor);
152 DEBUG ((DEBUG_INFO,
"Initializing private data for ATA\n"));
158 if (EFI_ERROR (Status)) {
159 DEBUG ((DEBUG_ERROR,
"%a: Fail to get the current boot mode.\n", __func__));
167 if (EFI_ERROR (Status)) {
170 "%a: The device path is invalid.\n",
182 if (BootMode == BOOT_ON_S3_RESUME) {
184 if (NumberOfPorts == 0) {
188 PortBitMap = MAX_UINT32;
195 if (Private ==
NULL) {
198 "%a: Fail to allocate private data.\n",
201 return EFI_OUT_OF_RESOURCES;
207 Private->Signature = AHCI_PEI_CONTROLLER_PRIVATE_DATA_SIGNATURE;
208 Private->MmioBase = MmioBase;
209 Private->DevicePathLength = DevicePathLength;
210 Private->DevicePath = DevicePath;
211 Private->PortBitMap = PortBitMap;
215 if (EFI_ERROR (Status)) {
221 Private->AtaPassThruMode.IoAlign =
sizeof (
UINTN);
222 Private->AtaPassThruPpi.Revision = EDKII_PEI_ATA_PASS_THRU_PPI_REVISION;
223 Private->AtaPassThruPpi.Mode = &Private->AtaPassThruMode;
229 &Private->AtaPassThruPpiList,
230 &mAhciAtaPassThruPpiListTemplate,
233 Private->AtaPassThruPpiList.
Ppi = &Private->AtaPassThruPpi;
240 &Private->BlkIoPpiList,
241 &mAhciBlkIoPpiListTemplate,
244 Private->BlkIoPpiList.
Ppi = &Private->BlkIoPpi;
247 Private->BlkIo2Ppi.
Revision = EFI_PEI_RECOVERY_BLOCK_IO2_PPI_REVISION;
252 &Private->BlkIo2PpiList,
253 &mAhciBlkIo2PpiListTemplate,
256 Private->BlkIo2PpiList.
Ppi = &Private->BlkIo2Ppi;
259 if (Private->TrustComputingDevices != 0) {
262 "%a: Security Security Command PPI will be produced.\n",
265 Private->StorageSecurityPpi.Revision = EDKII_STORAGE_SECURITY_PPI_REVISION;
271 &Private->StorageSecurityPpiList,
272 &mAhciStorageSecurityPpiListTemplate,
275 Private->StorageSecurityPpiList.
Ppi = &Private->StorageSecurityPpi;
280 &Private->EndOfPeiNotifyList,
281 &mAhciEndOfPeiNotifyListTemplate,
303 UINTN DevicePathLength;
310 Status = AhciHcPpi->GetAhciHcMmioBar (
318 if (EFI_ERROR (Status)) {
322 Status = AhciHcPpi->GetAhciHcDevicePath (
328 if (EFI_ERROR (Status)) {
331 "%a: Fail to allocate get the device path for Controller %d.\n",
339 if (EFI_ERROR (Status)) {
342 "%a: Controller initialization fail for Controller %d with Status - %r.\n",
350 "%a: Controller %d has been successfully initialized.\n",
385 return EFI_INVALID_PARAMETER;
410 UINTN DevicePathLength;
411 UINT64 EnabledPciAttributes;
417 Status = PciDevice->PciIo.Pci.Read (
420 PCI_CLASSCODE_OFFSET,
421 sizeof (PciData.Hdr.ClassCode),
422 PciData.Hdr.ClassCode
424 if (EFI_ERROR (Status)) {
425 return EFI_UNSUPPORTED;
429 return EFI_UNSUPPORTED;
432 Status = PciDevice->PciIo.Attributes (
436 &EnabledPciAttributes
438 if (EFI_ERROR (Status)) {
439 return EFI_UNSUPPORTED;
441 EnabledPciAttributes &= (UINT64)EFI_PCI_DEVICE_ENABLE;
442 Status = PciDevice->PciIo.Attributes (
445 EnabledPciAttributes,
448 if (EFI_ERROR (Status)) {
449 return EFI_UNSUPPORTED;
453 Status = PciDevice->PciIo.Pci.Read (
460 if (EFI_ERROR (Status)) {
461 return EFI_UNSUPPORTED;
464 MmioBase &= 0xFFFFFFF0;
467 DevicePath = PciDevice->DevicePath;
470 if (EFI_ERROR (Status)) {
473 "%a: Failed to init controller, with Status - %r\n",
525 DEBUG ((DEBUG_INFO,
"%a: Enters.\n", __func__));
EFI_STATUS AhciModeInitialization(IN OUT PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private)
EFI_STATUS AtaAhciInitPrivateDataFromPciDevice(EDKII_PCI_DEVICE_PPI *PciDevice)
EFI_STATUS EFIAPI AtaAhciPeimEntry(IN EFI_PEI_FILE_HANDLE FileHandle, IN CONST EFI_PEI_SERVICES **PeiServices)
EFI_STATUS EFIAPI AhciPeimEndOfPei(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
VOID AhciFreeDmaResource(IN PEI_AHCI_CONTROLLER_PRIVATE_DATA *Private)
EFI_STATUS AtaAhciInitPrivateDataFromHostControllerPpi(IN EDKII_ATA_AHCI_HOST_CONTROLLER_PPI *AhciHcPpi)
EFI_STATUS EFIAPI AtaAhciPciDevicePpiInstallationCallback(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
EFI_STATUS EFIAPI AtaAhciHostControllerPpiInstallationCallback(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor, IN VOID *Ppi)
EFI_STATUS AtaAhciInitPrivateData(IN UINTN MmioBase, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN UINTN DevicePathLength)
UINT8 AhciS3GetEumeratePorts(IN EFI_DEVICE_PATH_PROTOCOL *HcDevicePath, IN UINTN HcDevicePathLength, OUT UINT32 *PortBitMap)
EFI_STATUS IoMmuFreeBuffer(IN UINTN Pages, IN VOID *HostAddress, IN VOID *Mapping)
EFI_STATUS AhciIsHcDevicePathValid(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN UINTN DevicePathLength)
EFI_STATUS EFIAPI AhciBlockIoGetDeviceNo(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, OUT UINTN *NumberBlockDevices)
EFI_STATUS EFIAPI AhciBlockIoReadBlocks(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, IN UINTN DeviceIndex, IN EFI_PEI_LBA StartLBA, IN UINTN BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI AhciBlockIoGetMediaInfo(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO_PPI *This, IN UINTN DeviceIndex, OUT EFI_PEI_BLOCK_IO_MEDIA *MediaInfo)
EFI_STATUS EFIAPI AhciBlockIoGetDeviceNo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, OUT UINTN *NumberBlockDevices)
EFI_STATUS EFIAPI AhciBlockIoGetMediaInfo2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, IN UINTN DeviceIndex, OUT EFI_PEI_BLOCK_IO2_MEDIA *MediaInfo)
EFI_STATUS EFIAPI AhciBlockIoReadBlocks2(IN EFI_PEI_SERVICES **PeiServices, IN EFI_PEI_RECOVERY_BLOCK_IO2_PPI *This, IN UINTN DeviceIndex, IN EFI_PEI_LBA StartLBA, IN UINTN BufferSize, OUT VOID *Buffer)
EFI_STATUS EFIAPI AhciAtaPassThruGetNextDevice(IN EDKII_PEI_ATA_PASS_THRU_PPI *This, IN UINT16 Port, IN OUT UINT16 *PortMultiplierPort)
EFI_STATUS EFIAPI AhciAtaPassThruGetDevicePath(IN EDKII_PEI_ATA_PASS_THRU_PPI *This, OUT UINTN *DevicePathLength, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
EFI_STATUS EFIAPI AhciAtaPassThruPassThru(IN EDKII_PEI_ATA_PASS_THRU_PPI *This, IN UINT16 Port, IN UINT16 PortMultiplierPort, IN OUT EFI_ATA_PASS_THRU_COMMAND_PACKET *Packet)
EFI_STATUS EFIAPI AhciAtaPassThruGetNextPort(IN EDKII_PEI_ATA_PASS_THRU_PPI *This, IN OUT UINT16 *Port)
EFI_STATUS EFIAPI AhciStorageSecurityGetDevicePath(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, IN UINTN DeviceIndex, OUT UINTN *DevicePathLength, OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath)
EFI_STATUS EFIAPI AhciStorageSecuritySendData(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, IN UINTN DeviceIndex, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, IN VOID *PayloadBuffer)
EFI_STATUS EFIAPI AhciStorageSecurityReceiveData(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, IN UINTN DeviceIndex, IN UINT64 Timeout, IN UINT8 SecurityProtocolId, IN UINT16 SecurityProtocolSpecificData, IN UINTN PayloadBufferSize, OUT VOID *PayloadBuffer, OUT UINTN *PayloadTransferSize)
EFI_STATUS EFIAPI AhciStorageSecurityGetDeviceNo(IN EDKII_PEI_STORAGE_SECURITY_CMD_PPI *This, OUT UINTN *NumberofDevices)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
UINTN EFIAPI GetDevicePathSize(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
EFI_STATUS EFIAPI PeiServicesGetBootMode(OUT EFI_BOOT_MODE *BootMode)
EFI_STATUS EFIAPI PeiServicesNotifyPpi(IN CONST EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList)
EFI_STATUS EFIAPI PeiServicesInstallPpi(IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList)
#define DEBUG(Expression)
#define EFI_ATA_PASS_THRU_ATTRIBUTES_PHYSICAL
#define EFI_ATA_PASS_THRU_ATTRIBUTES_LOGICAL
@ EfiPciIoAttributeOperationEnable
@ EfiPciIoAttributeOperationSupported
#define IS_PCI_SATADPA(_p)
VOID * EFI_PEI_FILE_HANDLE
#define EFI_SIZE_TO_PAGES(Size)
EFI_PEI_READ_BLOCKS2 ReadBlocks
EFI_PEI_GET_DEVICE_MEDIA_INFORMATION2 GetBlockDeviceMediaInfo
EFI_PEI_GET_NUMBER_BLOCK_DEVICES2 GetNumberOfBlockDevices
EFI_PEI_READ_BLOCKS ReadBlocks
EFI_PEI_GET_NUMBER_BLOCK_DEVICES GetNumberOfBlockDevices
EFI_PEI_GET_DEVICE_MEDIA_INFORMATION GetBlockDeviceMediaInfo