OvmfPkg: QemuFlashFvbServicesRuntimeDxe: Abstract out SMM/DXE functions

This update refactors QemuFlashFvbServicesRuntimeDxe to abstract out
direct calls to SMM and DXE specific functions.

Specifically, dynamic PCD usage and gBS references have been moved to SMM
specific files.

The constructor functionality has been relocated to a common
implementation and is invoked from their respective entry points.

These changes lay the groundwork for supporting a Standalone MM-based
solution in the future.

Signed-off-by: Kun Qin <kun.qin@microsoft.com>
This commit is contained in:
Kun Qin
2025-04-04 16:43:53 -07:00
committed by mergify[bot]
parent cf4534c9da
commit aedcb46e6f
4 changed files with 30 additions and 5 deletions

View File

@@ -27,9 +27,7 @@
#include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h>
#include <Library/DevicePathLib.h>
#include <Library/DxeServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include "FwBlockService.h"
#include "QemuFlash.h"
@@ -976,7 +974,6 @@ FvbInitialize (
EFI_PHYSICAL_ADDRESS BaseAddress;
UINTN Length;
UINTN NumOfBlocks;
RETURN_STATUS PcdStatus;
if (EFI_ERROR (QemuFlashInitialize ())) {
//
@@ -1129,7 +1126,8 @@ FvbInitialize (
//
InstallVirtualAddressChangeHandler ();
PcdStatus = PcdSetBoolS (PcdOvmfFlashVariablesEnable, TRUE);
ASSERT_RETURN_ERROR (PcdStatus);
// Abstract dynamic PCD set to support Standalone MM
UpdateQemuFlashVariablesEnable ();
return EFI_SUCCESS;
}

View File

@@ -194,4 +194,9 @@ SetPcdFlashNvStorageBaseAddresses (
VOID
);
VOID
UpdateQemuFlashVariablesEnable (
VOID
);
#endif

View File

@@ -244,3 +244,14 @@ SetPcdFlashNvStorageBaseAddresses (
);
ASSERT_RETURN_ERROR (PcdStatus);
}
VOID
UpdateQemuFlashVariablesEnable (
VOID
)
{
RETURN_STATUS PcdStatus;
PcdStatus = PcdSetBoolS (PcdOvmfFlashVariablesEnable, TRUE);
ASSERT_RETURN_ERROR (PcdStatus);
}

View File

@@ -84,3 +84,14 @@ SetPcdFlashNvStorageBaseAddresses (
// Do nothing.
//
}
VOID
UpdateQemuFlashVariablesEnable (
VOID
)
{
RETURN_STATUS PcdStatus;
PcdStatus = PcdSetBoolS (PcdOvmfFlashVariablesEnable, TRUE);
ASSERT_RETURN_ERROR (PcdStatus);
}