[PATCH] StandaloneMmPkg/StandaloneMmCore: Drop code for traditional drivers


Marvin Häuser
 

StandaloneMmCore has code paths in place to support traditional MM
drivers based on the availability of mEfiSystemTable. This variable
is not populated anywhere however, rendering said paths unreachable.
Remove the unreachable support code.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
Cc: Vitaly Cheptsov <vit9696@protonmail.com>
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
---
StandaloneMmPkg/Core/Dependency.c | 6 ---
StandaloneMmPkg/Core/Dispatcher.c | 51 +-------------------
StandaloneMmPkg/Core/StandaloneMmCore.c | 1 -
StandaloneMmPkg/Core/StandaloneMmCore.h | 1 -
4 files changed, 2 insertions(+), 57 deletions(-)

diff --git a/StandaloneMmPkg/Core/Dependency.c b/StandaloneMmPkg/Core/Dependency.c
index eb4baa4086f0..3ae0201eb647 100644
--- a/StandaloneMmPkg/Core/Dependency.c
+++ b/StandaloneMmPkg/Core/Dependency.c
@@ -242,12 +242,6 @@ MmIsSchedulable (
CopyMem (&DriverGuid, Iterator + 1, sizeof (EFI_GUID));

Status = MmLocateProtocol (&DriverGuid, NULL, &Interface);
- if (EFI_ERROR (Status) && (mEfiSystemTable != NULL)) {
- //
- // For MM Driver, it may depend on uefi protocols
- //
- Status = mEfiSystemTable->BootServices->LocateProtocol (&DriverGuid, NULL, &Interface);
- }

if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_DISPATCH, " PUSH GUID(%g) = FALSE\n", &DriverGuid));
diff --git a/StandaloneMmPkg/Core/Dispatcher.c b/StandaloneMmPkg/Core/Dispatcher.c
index 7e4bf5e94025..76d33f81fef1 100644
--- a/StandaloneMmPkg/Core/Dispatcher.c
+++ b/StandaloneMmPkg/Core/Dispatcher.c
@@ -364,45 +364,6 @@ MmLoadImage (
DriverEntry->ImageBuffer = DstBuffer;
DriverEntry->NumberOfPage = PageCount;

- if (mEfiSystemTable != NULL) {
- Status = mEfiSystemTable->BootServices->AllocatePool (
- EfiBootServicesData,
- sizeof (EFI_LOADED_IMAGE_PROTOCOL),
- (VOID **)&DriverEntry->LoadedImage
- );
- if (EFI_ERROR (Status)) {
- MmFreePages (DstBuffer, PageCount);
- return Status;
- }
-
- ZeroMem (DriverEntry->LoadedImage, sizeof (EFI_LOADED_IMAGE_PROTOCOL));
- //
- // Fill in the remaining fields of the Loaded Image Protocol instance.
- // Note: ImageBase is an SMRAM address that can not be accessed outside of SMRAM if SMRAM window is closed.
- //
- DriverEntry->LoadedImage->Revision = EFI_LOADED_IMAGE_PROTOCOL_REVISION;
- DriverEntry->LoadedImage->ParentHandle = NULL;
- DriverEntry->LoadedImage->SystemTable = mEfiSystemTable;
- DriverEntry->LoadedImage->DeviceHandle = NULL;
- DriverEntry->LoadedImage->FilePath = NULL;
-
- DriverEntry->LoadedImage->ImageBase = (VOID *)(UINTN)DriverEntry->ImageBuffer;
- DriverEntry->LoadedImage->ImageSize = ImageContext.ImageSize;
- DriverEntry->LoadedImage->ImageCodeType = EfiRuntimeServicesCode;
- DriverEntry->LoadedImage->ImageDataType = EfiRuntimeServicesData;
-
- //
- // Create a new image handle in the UEFI handle database for the MM Driver
- //
- DriverEntry->ImageHandle = NULL;
- Status = mEfiSystemTable->BootServices->InstallMultipleProtocolInterfaces (
- &DriverEntry->ImageHandle,
- &gEfiLoadedImageProtocolGuid,
- DriverEntry->LoadedImage,
- NULL
- );
- }
-
//
// Print the load address and the PDB file name if it is available
//
@@ -637,16 +598,8 @@ MmDispatcher (
//
// For each MM driver, pass NULL as ImageHandle
//
- if (mEfiSystemTable == NULL) {
- DEBUG ((DEBUG_INFO, "StartImage - 0x%x (Standalone Mode)\n", DriverEntry->ImageEntryPoint));
- Status = ((MM_IMAGE_ENTRY_POINT)(UINTN)DriverEntry->ImageEntryPoint) (DriverEntry->ImageHandle, &gMmCoreMmst);
- } else {
- DEBUG ((DEBUG_INFO, "StartImage - 0x%x (Tradition Mode)\n", DriverEntry->ImageEntryPoint));
- Status = ((EFI_IMAGE_ENTRY_POINT)(UINTN)DriverEntry->ImageEntryPoint) (
- DriverEntry->ImageHandle,
- mEfiSystemTable
- );
- }
+ DEBUG ((DEBUG_INFO, "StartImage - 0x%x (Standalone Mode)\n", DriverEntry->ImageEntryPoint));
+ Status = ((MM_IMAGE_ENTRY_POINT)(UINTN)DriverEntry->ImageEntryPoint) (DriverEntry->ImageHandle, &gMmCoreMmst);
if (EFI_ERROR(Status)) {
DEBUG ((DEBUG_INFO, "StartImage Status - %r\n", Status));
MmFreePages(DriverEntry->ImageBuffer, DriverEntry->NumberOfPage);
diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.c b/StandaloneMmPkg/Core/StandaloneMmCore.c
index fbb0ec75e557..45976f203dd9 100644
--- a/StandaloneMmPkg/Core/StandaloneMmCore.c
+++ b/StandaloneMmPkg/Core/StandaloneMmCore.c
@@ -92,7 +92,6 @@ MM_CORE_MMI_HANDLERS mMmCoreMmiHandlers[] = {
{ NULL, NULL, NULL, FALSE },
};

-EFI_SYSTEM_TABLE *mEfiSystemTable;
UINTN mMmramRangeCount;
EFI_MMRAM_DESCRIPTOR *mMmramRanges;

diff --git a/StandaloneMmPkg/Core/StandaloneMmCore.h b/StandaloneMmPkg/Core/StandaloneMmCore.h
index 2a89edd0fc46..f6b3cc861e39 100644
--- a/StandaloneMmPkg/Core/StandaloneMmCore.h
+++ b/StandaloneMmPkg/Core/StandaloneMmCore.h
@@ -848,6 +848,5 @@ DumpMmramInfo (

extern UINTN mMmramRangeCount;
extern EFI_MMRAM_DESCRIPTOR *mMmramRanges;
-extern EFI_SYSTEM_TABLE *mEfiSystemTable;

#endif
--
2.31.1

Join devel@edk2.groups.io to automatically receive all group messages.