public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Marvin Häuser" <mhaeuser@posteo.de>
To: devel@edk2.groups.io
Cc: Jian J Wang <jian.j.wang@intel.com>,
	Hao A Wu <hao.a.wu@intel.com>, Eric Dong <eric.dong@intel.com>,
	Ray Ni <ray.ni@intel.com>,
	Vitaly Cheptsov <vit9696@protonmail.com>
Subject: [PATCH 1/1] MdeModulePkg: Move PiSmmCoreMemoryAllocationLib into PiSmmCore
Date: Sat, 21 Aug 2021 19:55:46 +0000	[thread overview]
Message-ID: <e080b0e173dc9b3796f9d8849551c71b06f201d7.1629575003.git.mhaeuser@posteo.de> (raw)
In-Reply-To: <cover.1629574351.git.mhaeuser@posteo.de>

PiSmmCoreMemoryAllocationLib duplicates private definitions of
PiSmmCore, namely the SMM_CORE_PRIVATE_DATA structure. Move this code
into PiSmmCore, so that the struct definition can be consumed
directly instead.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Vitaly Cheptsov <vit9696@protonmail.com>
Signed-off-by: Marvin Häuser <mhaeuser@posteo.de>
---
 MdeModulePkg/{Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c => Core/PiSmmCore/MemoryAllocation.c} |   3 +-
 MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf                                                                      |   1 +
 MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf                             |   5 +-
 MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationProfileLib.inf                      |   6 +-
 MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h                          | 185 --------------------
 5 files changed, 10 insertions(+), 190 deletions(-)

diff --git a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c b/MdeModulePkg/Core/PiSmmCore/MemoryAllocation.c
similarity index 96%
rename from MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c
rename to MdeModulePkg/Core/PiSmmCore/MemoryAllocation.c
index fd20a779cdcc..fb99174c9d8d 100644
--- a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/MemoryAllocationLib.c
+++ b/MdeModulePkg/Core/PiSmmCore/MemoryAllocation.c
@@ -22,7 +22,8 @@
 #include <Library/UefiBootServicesTableLib.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/DebugLib.h>
-#include "PiSmmCoreMemoryAllocationServices.h"
+#include "PiSmmCore.h"
+#include "PiSmmCorePrivateData.h"
 
 #include <Library/MemoryProfileLib.h>
 
diff --git a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
index c8bfae3860fc..85628f927134 100644
--- a/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
+++ b/MdeModulePkg/Core/PiSmmCore/PiSmmCore.inf
@@ -37,6 +37,7 @@ [Sources]
   SmiHandlerProfile.c
   HeapGuard.c
   HeapGuard.h
+  MemoryAllocation.c
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf
index 5c51c48b0b1e..8812c9604103 100644
--- a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf
+++ b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationLib.inf
@@ -19,6 +19,9 @@ [Defines]
   VERSION_STRING                 = 1.0
   PI_SPECIFICATION_VERSION       = 0x0001000A
   LIBRARY_CLASS                  = MemoryAllocationLib|SMM_CORE
+  #
+  # This function is defined in PiSmmCore.
+  #
   CONSTRUCTOR                    = PiSmmCoreMemoryAllocationLibConstructor
 
 #
@@ -28,8 +31,6 @@ [Defines]
 #
 
 [Sources]
-  MemoryAllocationLib.c
-  PiSmmCoreMemoryAllocationServices.h
   PiSmmCoreMemoryProfileLibNull.c
 
 [Packages]
diff --git a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationProfileLib.inf b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationProfileLib.inf
index 89658c0f6ccb..c3b8a4fdce7b 100644
--- a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationProfileLib.inf
+++ b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationProfileLib.inf
@@ -19,6 +19,9 @@ [Defines]
   VERSION_STRING                 = 1.0
   PI_SPECIFICATION_VERSION       = 0x0001000A
   LIBRARY_CLASS                  = MemoryAllocationLib|SMM_CORE
+  #
+  # This function is defined in PiSmmCore.
+  #
   CONSTRUCTOR                    = PiSmmCoreMemoryAllocationLibConstructor
   LIBRARY_CLASS                  = MemoryProfileLib|SMM_CORE
   CONSTRUCTOR                    = PiSmmCoreMemoryProfileLibConstructor
@@ -30,8 +33,6 @@ [Defines]
 #
 
 [Sources]
-  MemoryAllocationLib.c
-  PiSmmCoreMemoryAllocationServices.h
   PiSmmCoreMemoryProfileLib.c
   PiSmmCoreMemoryProfileServices.h
 
@@ -43,6 +44,7 @@ [LibraryClasses]
   DebugLib
   BaseMemoryLib
   UefiBootServicesTableLib
+  MemoryAllocationLib
 
 [Guids]
   gEdkiiMemoryProfileGuid   ## SOMETIMES_CONSUMES   ## GUID # Locate protocol
diff --git a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h b/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h
deleted file mode 100644
index 789fcf2c01ea..000000000000
--- a/MdeModulePkg/Library/PiSmmCoreMemoryAllocationLib/PiSmmCoreMemoryAllocationServices.h
+++ /dev/null
@@ -1,185 +0,0 @@
-/** @file
-  Contains function prototypes for Memory Services in the SMM Core.
-
-  This header file borrows the PiSmmCore Memory Allocation services as the primitive
-  for memory allocation.
-
-  Copyright (c) 2008 - 2018, Intel Corporation. All rights reserved.<BR>
-  SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef _PI_SMM_CORE_MEMORY_ALLOCATION_SERVICES_H_
-#define _PI_SMM_CORE_MEMORY_ALLOCATION_SERVICES_H_
-
-//
-// It should be aligned with the definition in PiSmmCore.
-//
-typedef struct {
-  UINTN                           Signature;
-
-  ///
-  /// The ImageHandle passed into the entry point of the SMM IPL.  This ImageHandle
-  /// is used by the SMM Core to fill in the ParentImageHandle field of the Loaded
-  /// Image Protocol for each SMM Driver that is dispatched by the SMM Core.
-  ///
-  EFI_HANDLE                      SmmIplImageHandle;
-
-  ///
-  /// The number of SMRAM ranges passed from the SMM IPL to the SMM Core.  The SMM
-  /// Core uses these ranges of SMRAM to initialize the SMM Core memory manager.
-  ///
-  UINTN                           SmramRangeCount;
-
-  ///
-  /// A table of SMRAM ranges passed from the SMM IPL to the SMM Core.  The SMM
-  /// Core uses these ranges of SMRAM to initialize the SMM Core memory manager.
-  ///
-  EFI_SMRAM_DESCRIPTOR            *SmramRanges;
-
-  ///
-  /// The SMM Foundation Entry Point.  The SMM Core fills in this field when the
-  /// SMM Core is initialized.  The SMM IPL is responsbile for registering this entry
-  /// point with the SMM Configuration Protocol.  The SMM Configuration Protocol may
-  /// not be available at the time the SMM IPL and SMM Core are started, so the SMM IPL
-  /// sets up a protocol notification on the SMM Configuration Protocol and registers
-  /// the SMM Foundation Entry Point as soon as the SMM Configuration Protocol is
-  /// available.
-  ///
-  EFI_SMM_ENTRY_POINT             SmmEntryPoint;
-
-  ///
-  /// Boolean flag set to TRUE while an SMI is being processed by the SMM Core.
-  ///
-  BOOLEAN                         SmmEntryPointRegistered;
-
-  ///
-  /// Boolean flag set to TRUE while an SMI is being processed by the SMM Core.
-  ///
-  BOOLEAN                         InSmm;
-
-  ///
-  /// This field is set by the SMM Core then the SMM Core is initialized.  This field is
-  /// used by the SMM Base 2 Protocol and SMM Communication Protocol implementations in
-  /// the SMM IPL.
-  ///
-  EFI_SMM_SYSTEM_TABLE2           *Smst;
-
-  ///
-  /// This field is used by the SMM Communicatioon Protocol to pass a buffer into
-  /// a software SMI handler and for the software SMI handler to pass a buffer back to
-  /// the caller of the SMM Communication Protocol.
-  ///
-  VOID                            *CommunicationBuffer;
-
-  ///
-  /// This field is used by the SMM Communicatioon Protocol to pass the size of a buffer,
-  /// in bytes, into a software SMI handler and for the software SMI handler to pass the
-  /// size, in bytes, of a buffer back to the caller of the SMM Communication Protocol.
-  ///
-  UINTN                           BufferSize;
-
-  ///
-  /// This field is used by the SMM Communication Protocol to pass the return status from
-  /// a software SMI handler back to the caller of the SMM Communication Protocol.
-  ///
-  EFI_STATUS                      ReturnStatus;
-
-  EFI_PHYSICAL_ADDRESS            PiSmmCoreImageBase;
-  UINT64                          PiSmmCoreImageSize;
-  EFI_PHYSICAL_ADDRESS            PiSmmCoreEntryPoint;
-} SMM_CORE_PRIVATE_DATA;
-
-/**
-  Called to initialize the memory service.
-
-  @param   SmramRangeCount       Number of SMRAM Regions
-  @param   SmramRanges           Pointer to SMRAM Descriptors
-
-**/
-VOID
-SmmInitializeMemoryServices (
-  IN UINTN                 SmramRangeCount,
-  IN EFI_SMRAM_DESCRIPTOR  *SmramRanges
-  );
-
-/**
-  Allocates pages from the memory map.
-
-  @param  Type                   The type of allocation to perform
-  @param  MemoryType             The type of memory to turn the allocated pages
-                                 into
-  @param  NumberOfPages          The number of pages to allocate
-  @param  Memory                 A pointer to receive the base allocated memory
-                                 address
-
-  @retval EFI_INVALID_PARAMETER  Parameters violate checking rules defined in spec.
-  @retval EFI_NOT_FOUND          Could not allocate pages match the requirement.
-  @retval EFI_OUT_OF_RESOURCES   No enough pages to allocate.
-  @retval EFI_SUCCESS            Pages successfully allocated.
-
-**/
-EFI_STATUS
-EFIAPI
-SmmAllocatePages (
-  IN      EFI_ALLOCATE_TYPE         Type,
-  IN      EFI_MEMORY_TYPE           MemoryType,
-  IN      UINTN                     NumberOfPages,
-  OUT     EFI_PHYSICAL_ADDRESS      *Memory
-  );
-
-/**
-  Frees previous allocated pages.
-
-  @param  Memory                 Base address of memory being freed
-  @param  NumberOfPages          The number of pages to free
-
-  @retval EFI_NOT_FOUND          Could not find the entry that covers the range
-  @retval EFI_INVALID_PARAMETER  Address not aligned
-  @return EFI_SUCCESS            Pages successfully freed.
-
-**/
-EFI_STATUS
-EFIAPI
-SmmFreePages (
-  IN      EFI_PHYSICAL_ADDRESS      Memory,
-  IN      UINTN                     NumberOfPages
-  );
-
-/**
-  Allocate pool of a particular type.
-
-  @param  PoolType               Type of pool to allocate
-  @param  Size                   The amount of pool to allocate
-  @param  Buffer                 The address to return a pointer to the allocated
-                                 pool
-
-  @retval EFI_INVALID_PARAMETER  PoolType not valid
-  @retval EFI_OUT_OF_RESOURCES   Size exceeds max pool size or allocation failed.
-  @retval EFI_SUCCESS            Pool successfully allocated.
-
-**/
-EFI_STATUS
-EFIAPI
-SmmAllocatePool (
-  IN      EFI_MEMORY_TYPE           PoolType,
-  IN      UINTN                     Size,
-  OUT     VOID                      **Buffer
-  );
-
-/**
-  Frees pool.
-
-  @param  Buffer                 The allocated pool entry to free
-
-  @retval EFI_INVALID_PARAMETER  Buffer is not a valid value.
-  @retval EFI_SUCCESS            Pool successfully freed.
-
-**/
-EFI_STATUS
-EFIAPI
-SmmFreePool (
-  IN      VOID                      *Buffer
-  );
-
-#endif
-- 
2.31.1


  parent reply	other threads:[~2021-08-21 19:56 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-21 19:55 [PATCH 0/3] Update GDB and RVCT symbols loading to use the Image base address Marvin Häuser
2021-08-21 19:55 ` [PATCH 1/3] EmulatorPkg: Use Image base address for GDB symbols loading Marvin Häuser
2021-08-21 19:55 ` Marvin Häuser [this message]
2021-09-01  4:21   ` [PATCH 1/1] MdeModulePkg: Move PiSmmCoreMemoryAllocationLib into PiSmmCore Ni, Ray
2021-09-01  7:17     ` Marvin Häuser
2021-09-02 10:53       ` Ni, Ray
2021-09-02 13:22         ` [edk2-devel] " Marvin Häuser
2021-09-03  1:29           ` 回复: " gaoliming
2021-08-21 19:55 ` [PATCH 1/5] MdeModulePkg/PeiCore: Align fixed-address error behaviour Marvin Häuser
2021-08-21 19:55   ` [PATCH 2/5] MdeModulePkg/DxeCore: " Marvin Häuser
2021-08-21 19:55   ` [PATCH 3/5] MdeModulePkg/DxeCore: Check for fixed-address Image relocations Marvin Häuser
2021-08-21 19:55   ` [PATCH 4/5] MdeModulePkg/PiSmmIpl: Disallow stripped " Marvin Häuser
2021-08-21 19:55   ` [PATCH 5/5] MdeModulePkg/PiSmmCore: " Marvin Häuser
2021-08-21 20:10   ` [edk2-devel] [PATCH 1/5] MdeModulePkg/PeiCore: Align fixed-address error behaviour Marvin Häuser
2021-08-22  9:28     ` Marvin Häuser
2021-08-21 19:55 ` [PATCH 2/3] ArmPkg: Use Image base address for GDB symbols loading Marvin Häuser
2021-08-21 19:55 ` [PATCH 3/3] ArmPkg: Use Image base address for RVCT " Marvin Häuser

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e080b0e173dc9b3796f9d8849551c71b06f201d7.1629575003.git.mhaeuser@posteo.de \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox