diff --git a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c index 0b3c222ed1..8c7d863a41 100644 --- a/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c +++ b/MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c @@ -7,6 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include "DxeMain.h" +#include // // DXE Core Global Variables for Protocols from PEI @@ -87,8 +88,8 @@ EFI_BOOT_SERVICES mBootServices = { (EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES)CoreInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces (EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES)CoreUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces (EFI_CALCULATE_CRC32)CoreEfiNotAvailableYetArg3, // CalculateCrc32 - (EFI_COPY_MEM)CopyMem, // CopyMem - (EFI_SET_MEM)SetMem, // SetMem + (EFI_COPY_MEM)EfiCopyMem, // CopyMem + (EFI_SET_MEM)EfiSetMem, // SetMem (EFI_CREATE_EVENT_EX)CoreCreateEventEx // CreateEventEx }; diff --git a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c index fb1b989038..96d3589b2f 100644 --- a/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c +++ b/MdeModulePkg/Core/Pei/PeiMain/PeiMain.c @@ -7,6 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include "PeiMain.h" +#include EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = { (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST), @@ -48,8 +49,8 @@ EFI_PEI_SERVICES gPs = { PeiInstallPeiMemory, PeiAllocatePages, PeiAllocatePool, - (EFI_PEI_COPY_MEM)CopyMem, - (EFI_PEI_SET_MEM)SetMem, + EfiCopyMem, + EfiSetMem, PeiReportStatusCode, PeiResetSystem, diff --git a/MdePkg/Include/Library/BaseEfiMemWrapper.h b/MdePkg/Include/Library/BaseEfiMemWrapper.h new file mode 100644 index 0000000000..0c36f3933a --- /dev/null +++ b/MdePkg/Include/Library/BaseEfiMemWrapper.h @@ -0,0 +1,78 @@ +/** @file + Provide strictly specification compliant instances of SetMem and CopyMem + for those interfaces which need it. + +Copyright (c) 2025, TianoCore and contributors. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +*/ + +#ifndef __BASE_EFI_MEM_WRAPPER__ +#define __BASE_EFI_MEM_WRAPPER__ + +#include "BaseMemoryLib.h" + +/** + Copies a source buffer to a destination buffer, and returns the destination buffer. + + This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns + DestinationBuffer. The implementation must be reentrant, and it must handle the case + where SourceBuffer overlaps DestinationBuffer. + + If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT(). + If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT(). + + @param DestinationBuffer The pointer to the destination buffer of the memory copy. + @param SourceBuffer The pointer to the source buffer of the memory copy. + @param Length The number of bytes to copy from SourceBuffer to DestinationBuffer. + + @return None. + +**/ +STATIC +VOID +EFIAPI +EfiCopyMem ( + IN VOID *Destination, + IN VOID *Source, + IN UINTN Length + ) +{ + CopyMem ( + Destination, + Source, + Length + ); +} + +/** + Fills a target buffer with a byte value, and returns the target buffer. + + This function fills Length bytes of Buffer with Value, and returns Buffer. + + If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT(). + + @param Buffer The memory to set. + @param Length The number of bytes to set. + @param Value The value with which to fill Length bytes of Buffer. + + @return None. + +**/ +STATIC +VOID +EFIAPI +EfiSetMem ( + IN VOID *Buffer, + IN UINTN Size, + IN UINT8 Value + ) +{ + SetMem ( + Buffer, + Size, + Value + ); +} + +#endif diff --git a/UnitTestFrameworkPkg/Library/UnitTestPeiServicesTablePointerLib/UnitTestPeiServicesTablePointerLib.c b/UnitTestFrameworkPkg/Library/UnitTestPeiServicesTablePointerLib/UnitTestPeiServicesTablePointerLib.c index a1b982fbae..11030d2bfd 100644 --- a/UnitTestFrameworkPkg/Library/UnitTestPeiServicesTablePointerLib/UnitTestPeiServicesTablePointerLib.c +++ b/UnitTestFrameworkPkg/Library/UnitTestPeiServicesTablePointerLib/UnitTestPeiServicesTablePointerLib.c @@ -9,6 +9,7 @@ **/ #include "UnitTestPeiServicesTablePointerLib.h" +#include /// /// Pei service instance @@ -39,8 +40,8 @@ EFI_PEI_SERVICES mPeiServices = { UnitTestInstallPeiMemory, // InstallPeiMemory UnitTestAllocatePages, // AllocatePages UnitTestAllocatePool, // AllocatePool - (EFI_PEI_COPY_MEM)CopyMem, - (EFI_PEI_SET_MEM)SetMem, + EfiCopyMem, + EfiSetMem, UnitTestReportStatusCode, // ReportStatusCode UnitTestResetSystem, // ResetSystem diff --git a/UnitTestFrameworkPkg/Library/UnitTestUefiBootServicesTableLib/UnitTestUefiBootServicesTableLib.c b/UnitTestFrameworkPkg/Library/UnitTestUefiBootServicesTableLib/UnitTestUefiBootServicesTableLib.c index a6fc13e7d2..0675674e57 100644 --- a/UnitTestFrameworkPkg/Library/UnitTestUefiBootServicesTableLib/UnitTestUefiBootServicesTableLib.c +++ b/UnitTestFrameworkPkg/Library/UnitTestUefiBootServicesTableLib/UnitTestUefiBootServicesTableLib.c @@ -15,6 +15,7 @@ **/ #include "UnitTestUefiBootServicesTableLib.h" +#include EFI_HANDLE gImageHandle = NULL; EFI_SYSTEM_TABLE *gST = NULL; @@ -68,8 +69,8 @@ STATIC EFI_BOOT_SERVICES mBootServices = { (EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES)UnitTestInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces (EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES)UnitTestUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces (EFI_CALCULATE_CRC32)UnitTestCalculateCrc32, // CalculateCrc32 - (EFI_COPY_MEM)CopyMem, // CopyMem - (EFI_SET_MEM)SetMem, // SetMem + (EFI_COPY_MEM)EfiCopyMem, // CopyMem + (EFI_SET_MEM)EfiSetMem, // SetMem (EFI_CREATE_EVENT_EX)UnitTestCreateEventEx // CreateEventEx };