From 025cec183deaaef4942f37958b9cc09e69112ef0 Mon Sep 17 00:00:00 2001 From: Dun Tan Date: Wed, 18 Sep 2024 17:23:23 +0800 Subject: StandaloneMmPkg/MemLib: Add an internal header file Add a internal header file for StandaloneMmMemLib. Move some common reference and declaration into StandaloneMmMemLibInternal.h. Signed-off-by: Dun Tan --- .../ArmStandaloneMmMemLibInternal.c | 8 ++-- .../StandaloneMmMemLib/StandaloneMmMemLib.c | 40 ++---------------- .../StandaloneMmMemLib/StandaloneMmMemLib.inf | 3 +- .../StandaloneMmMemLibInternal.h | 48 ++++++++++++++++++++++ .../X86StandaloneMmMemLibInternal.c | 8 ++-- 5 files changed, 59 insertions(+), 48 deletions(-) create mode 100644 StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLibInternal.h diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c index fddcecf6da..f1e1ec3103 100644 --- a/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/ArmStandaloneMmMemLibInternal.c @@ -6,15 +6,13 @@ all MMRAM range via MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core and MM driver) and/or specific dedicated hardware. - Copyright (c) 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2024, Intel Corporation. All rights reserved.
Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ -#include -#include -#include +#include "StandaloneMmMemLibInternal.h" // // Maximum support address used to check input buffer // @@ -25,7 +23,7 @@ extern EFI_PHYSICAL_ADDRESS mMmMemLibInternalMaximumSupportAddress; **/ VOID -MmMemLibInternalCalculateMaximumSupportAddress ( +MmMemLibCalculateMaximumSupportAddress ( VOID ) { diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.c index 814352369e..e8b50c5a59 100644 --- a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.c +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.c @@ -6,18 +6,14 @@ all MMRAM range via MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core and MM driver) and/or specific dedicated hardware. - Copyright (c) 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2024, Intel Corporation. All rights reserved.
Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ -#include - -#include -#include -#include +#include "StandaloneMmMemLibInternal.h" EFI_MMRAM_DESCRIPTOR *mMmMemLibInternalMmramRanges; UINTN mMmMemLibInternalMmramCount; @@ -27,36 +23,6 @@ UINTN mMmMemLibInternalMmramCount; // EFI_PHYSICAL_ADDRESS mMmMemLibInternalMaximumSupportAddress = 0; -/** - Calculate and save the maximum support address. - -**/ -VOID -MmMemLibInternalCalculateMaximumSupportAddress ( - VOID - ); - -/** - Initialize cached Mmram Ranges from HOB. - - @retval EFI_UNSUPPORTED The routine is unable to extract MMRAM information. - @retval EFI_SUCCESS MmRanges are populated successfully. - -**/ -EFI_STATUS -MmMemLibInternalPopulateMmramRanges ( - VOID - ); - -/** - Deinitialize cached Mmram Ranges. - -**/ -VOID -MmMemLibInternalFreeMmramRanges ( - VOID - ); - /** This function check if the buffer is valid per processor architecture and not overlap with MMRAM. @@ -293,7 +259,7 @@ MemLibConstructor ( // // Calculate and save maximum support address // - MmMemLibInternalCalculateMaximumSupportAddress (); + MmMemLibCalculateMaximumSupportAddress (); // // Initialize cached Mmram Ranges from HOB. diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf index a748af5ea5..54d9a7b10e 100644 --- a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLib.inf @@ -6,7 +6,7 @@ # all MMRAM range via MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core # and MM driver) and/or specific dedicated hardware. # -# Copyright (c) 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2015 - 2024, Intel Corporation. All rights reserved.
# Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
# Copyright (c) Microsoft Corporation. # @@ -33,6 +33,7 @@ [Sources.Common] StandaloneMmMemLib.c + StandaloneMmMemLibInternal.h [Sources.IA32, Sources.X64] X86StandaloneMmMemLibInternal.c diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLibInternal.h b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLibInternal.h new file mode 100644 index 0000000000..d2fba8f909 --- /dev/null +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/StandaloneMmMemLibInternal.h @@ -0,0 +1,48 @@ +/** @file + Internal header for StandaloneMmMemLib. + + Copyright (c) 2024, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef STANDALONE_MM_MEM_LIB_INTERNAL_H_ +#define STANDALONE_MM_MEM_LIB_INTERNAL_H_ + +#include + +#include +#include +#include + +/** + Calculate and save the maximum support address. + +**/ +VOID +MmMemLibCalculateMaximumSupportAddress ( + VOID + ); + +/** + Initialize cached Mmram Ranges from HOB. + + @retval EFI_UNSUPPORTED The routine is unable to extract MMRAM information. + @retval EFI_SUCCESS MmRanges are populated successfully. + +**/ +EFI_STATUS +MmMemLibInternalPopulateMmramRanges ( + VOID + ); + +/** + Deinitialize cached Mmram Ranges. + +**/ +VOID +MmMemLibInternalFreeMmramRanges ( + VOID + ); + +#endif diff --git a/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c b/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c index 19e1736ae1..81b959230f 100644 --- a/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c +++ b/StandaloneMmPkg/Library/StandaloneMmMemLib/X86StandaloneMmMemLibInternal.c @@ -6,18 +6,16 @@ all MMRAM range via MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core and MM driver) and/or specific dedicated hardware. - Copyright (c) 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2024, Intel Corporation. All rights reserved.
Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent **/ +#include "StandaloneMmMemLibInternal.h" #include -#include -#include #include -#include #include #include @@ -34,7 +32,7 @@ extern UINTN mMmMemLibInternalMmramCount; **/ VOID -MmMemLibInternalCalculateMaximumSupportAddress ( +MmMemLibCalculateMaximumSupportAddress ( VOID ) { -- cgit