edk2/OvmfPkg/Library/MemDebugLogLib/MemDebugLogPeiCore.c
Luigi Leonardi 839e79f62b OvmfPkg/MemDebugLogLib: unoptimize PEIM and PEI_CORE
In AARCH64, the PEI phase runs from the flash memory, therefore global
variables are not allowed.

Remove this optimization so that this library can be used for this
architecture.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
2025-08-28 09:56:09 +00:00

52 lines
1.2 KiB
C

/** @file
*
Memory Debug Log Library - PEI Core
Copyright (C) 2025, Oracle and/or its affiliates.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <PiPei.h>
#include <Library/PeiServicesLib.h>
#include <Library/MemDebugLogLib.h>
EFI_STATUS
EFIAPI
MemDebugLogWrite (
IN CHAR8 *Buffer,
IN UINTN Length
)
{
EFI_PHYSICAL_ADDRESS MemDebugLogBufAddr;
EFI_STATUS Status;
//
// Obtain the Memory Debug Log buffer addr from HOB
// NOTE: This is expected to fail until the HOB is created.
//
Status = MemDebugLogAddrFromHOB (&MemDebugLogBufAddr);
if (EFI_ERROR (Status)) {
MemDebugLogBufAddr = 0;
}
if (MemDebugLogBufAddr != 0) {
Status = MemDebugLogWriteBuffer (MemDebugLogBufAddr, Buffer, Length);
} else {
//
// HOB has not yet been created, so
// write to the early debug log buffer.
//
if (FixedPcdGet32 (PcdOvmfEarlyMemDebugLogBase) != 0x0) {
Status = MemDebugLogWriteBuffer (
(EFI_PHYSICAL_ADDRESS)(UINTN)FixedPcdGet32 (PcdOvmfEarlyMemDebugLogBase),
Buffer,
Length
);
} else {
Status = EFI_NOT_FOUND;
}
}
return Status;
}