Skip to content

Commit

Permalink
Ampere: Change to use MmCommunicationDxe from ArmPkg
Browse files Browse the repository at this point in the history
It's unnecessary to duplicate a ready-to-use module while we can change
our code to adapt it. This change is to remove the Ampere version of
MmCommunicationDxe and turn to use the one from ArmPkg. It also changed
from MmCommunicationProtocol to MmCommunication2Protocol with a bit
update in the function parameters.

Signed-off-by: Vu Nguyen <Vu@amperecomputing.com>
  • Loading branch information
vu-ampere committed Sep 27, 2021
1 parent 1bfb334 commit be29316
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 637 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeLib.h>
#include <Platform/Ac01.h>
#include <Protocol/MmCommunication.h>
#include <Protocol/MmCommunication2.h>

#define EFI_MM_MAX_PAYLOAD_U64_E 10
#define EFI_MM_MAX_PAYLOAD_SIZE (EFI_MM_MAX_PAYLOAD_U64_E * sizeof (UINT64))

EFI_MM_COMMUNICATION_PROTOCOL *mFlashLibMmCommProtocol = NULL;
EFI_MM_COMMUNICATION2_PROTOCOL *mFlashLibMmCommProtocol = NULL;

typedef struct {
/* Allows for disambiguation of the message format */
Expand Down Expand Up @@ -170,12 +170,12 @@ FailSafeGetRegionInfo (

if (mFlashLibMmCommProtocol == NULL) {
Status = gBS->LocateProtocol (
&gEfiMmCommunicationProtocolGuid,
&gEfiMmCommunication2ProtocolGuid,
NULL,
(VOID **)&mFlashLibMmCommProtocol
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "%a: Can't locate gEfiMmCommunicationProtocolGuid\n", __FUNCTION__));
DEBUG ((DEBUG_ERROR, "%a: Can't locate gEfiMmCommunication2ProtocolGuid\n", __FUNCTION__));
return Status;
}
}
Expand All @@ -187,6 +187,7 @@ FailSafeGetRegionInfo (
Status = mFlashLibMmCommProtocol->Communicate (
mFlashLibMmCommProtocol,
(VOID *)&mEfiMmSpiNorReq,
(VOID *)&mEfiMmSpiNorReq,
&DataSize
);
ASSERT_EFI_ERROR (Status);
Expand Down Expand Up @@ -238,6 +239,7 @@ FailSafeBootSuccessfully (
Status = mFlashLibMmCommProtocol->Communicate (
mFlashLibMmCommProtocol,
(VOID *)&mEfiMmSpiNorReq,
(VOID *)&mEfiMmSpiNorReq,
&Size
);
ASSERT_EFI_ERROR (Status);
Expand Down Expand Up @@ -272,6 +274,7 @@ FailSafeBootSuccessfully (
Status = mFlashLibMmCommProtocol->Communicate (
mFlashLibMmCommProtocol,
(VOID *)&mEfiMmSpiNorReq,
(VOID *)&mEfiMmSpiNorReq,
&Size
);
ASSERT_EFI_ERROR (Status);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
FailSafeLib.c

[Protocols]
gEfiMmCommunicationProtocolGuid ## CONSUMES
gEfiMmCommunication2ProtocolGuid ## CONSUMES

[Packages]
ArmPkg/ArmPkg.dec
Expand Down
6 changes: 3 additions & 3 deletions Platform/Ampere/JadePkg/Jade.fdf
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ APRIORI PEI {
INF ArmPlatformPkg/PlatformPei/PlatformPeim.inf
INF Silicon/Ampere/AmpereAltraPkg/Drivers/ATFHobPei/ATFHobPeim.inf
INF Silicon/Ampere/AmpereAltraPkg/Drivers/MemoryInitPeim/MemoryInitPeim.inf
INF Silicon/Ampere/AmpereAltraPkg/Drivers/MmCommunicationPei/MmCommunicationPei.inf
INF Silicon/Ampere/AmpereAltraPkg/Drivers/FlashPei/FlashPei.inf
INF Silicon/Ampere/AmpereAltraPkg/Drivers/BootProgress/BootProgressPeim/BootProgressPeim.inf
INF ArmPkg/Drivers/CpuPei/CpuPei.inf
Expand Down Expand Up @@ -207,7 +206,8 @@ APRIORI DXE {
INF MdeModulePkg/Universal/PCD/Dxe/Pcd.inf
INF MdeModulePkg/Universal/ReportStatusCodeRouter/RuntimeDxe/ReportStatusCodeRouterRuntimeDxe.inf
INF MdeModulePkg/Universal/StatusCodeHandler/RuntimeDxe/StatusCodeHandlerRuntimeDxe.inf
INF Silicon/Ampere/AmpereAltraPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
INF ArmPkg/Drivers/CpuDxe/CpuDxe.inf
INF ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
INF Silicon/Ampere/AmpereAltraPkg/Drivers/FlashFvbDxe/FlashFvbDxe.inf
}

Expand All @@ -234,7 +234,7 @@ APRIORI DXE {
INF EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
INF EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
INF Silicon/Ampere/AmpereAltraPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
INF ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf

#
# Fixup memory map
Expand Down
3 changes: 1 addition & 2 deletions Silicon/Ampere/AmpereAltraPkg/AmpereAltraPkg.dsc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,6 @@
Silicon/Ampere/AmpereAltraPkg/Drivers/ATFHobPei/ATFHobPeim.inf
Silicon/Ampere/AmpereAltraPkg/Drivers/MemoryInitPeim/MemoryInitPeim.inf
Silicon/Ampere/AmpereAltraPkg/Drivers/DebugInfoPei/DebugInfoPei.inf
Silicon/Ampere/AmpereAltraPkg/Drivers/MmCommunicationPei/MmCommunicationPei.inf
Silicon/Ampere/AmpereAltraPkg/Drivers/FlashPei/FlashPei.inf
ArmPkg/Drivers/CpuPei/CpuPei.inf
UefiCpuPkg/CpuIoPei/CpuIoPei.inf
Expand Down Expand Up @@ -661,7 +660,7 @@
EmbeddedPkg/ResetRuntimeDxe/ResetRuntimeDxe.inf
EmbeddedPkg/RealTimeClockRuntimeDxe/RealTimeClockRuntimeDxe.inf
EmbeddedPkg/MetronomeDxe/MetronomeDxe.inf
Silicon/Ampere/AmpereAltraPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
#
# Fix Memory Map
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

[Protocols]
gEfiFirmwareVolumeBlockProtocolGuid ## PRODUCES
gEfiMmCommunicationProtocolGuid ## CONSUMES
gEfiMmCommunication2ProtocolGuid ## CONSUMES

[Depex]
gEfiMmCommunicationProtocolGuid
gEfiMmCommunication2ProtocolGuid

This file was deleted.

Loading

0 comments on commit be29316

Please sign in to comment.