]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/SmmCpuFeaturesLib: Add Standalone MM support
authorMichael Kubacki <michael.kubacki@microsoft.com>
Wed, 17 Feb 2021 21:32:27 +0000 (13:32 -0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 8 Mar 2021 18:07:32 +0000 (18:07 +0000)
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3218

Adds an INF for StandaloneMmCpuFeaturesLib, which supports building
the SmmCpuFeaturesLib code for Standalone MM. Minimal code changes
are made to allow reuse of existing code for Standalone MM.

The original INF file names are left intact (continue to use SMM
terminology) to retain backward compatibility with platforms that
use those INFs. Similarly, the pre-existing C file names are
unchanged to be consistent with the INF file names.

Note that all references in library source files to PiSmm.h have
been changed to PiMm.h for consistency.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Message-Id: <20210217213227.1277-6-mikuback@linux.microsoft.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
UefiCpuPkg/Library/SmmCpuFeaturesLib/Ia32/SmmStmSupport.c
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibCommon.c
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibNoStm.c
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c
UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.c [new file with mode: 0644]
UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf [new file with mode: 0644]
UefiCpuPkg/Library/SmmCpuFeaturesLib/X64/SmmStmSupport.c
UefiCpuPkg/UefiCpuPkg.dsc

index 399ddd742dd794fffd9ee31777d63779295f22a1..24bd6d0a946d000700878bc93615cca2d47c870d 100644 (file)
@@ -6,7 +6,7 @@
 \r
 **/\r
 \r
-#include <PiSmm.h>\r
+#include <PiMm.h>\r
 #include <Library/DebugLib.h>\r
 \r
 #include "SmmStm.h"\r
index 00948a191fad534c1c15e135d92ae08cbc476ed2..29e3b650acee06103c30583fc53ae9b12ff2e111 100644 (file)
@@ -6,7 +6,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 \r
 **/\r
 \r
-#include <PiSmm.h>\r
+#include <PiMm.h>\r
 #include "CpuFeaturesLib.h"\r
 \r
 /**\r
index 50379f3aea1945ac0158ba2882644722810d8107..fa3a866ab6f672d3cdd0de656e6082b62ff2c27e 100644 (file)
@@ -7,7 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 \r
 **/\r
 \r
-#include <PiSmm.h>\r
+#include <PiMm.h>\r
 #include <Library/SmmCpuFeaturesLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/MtrrLib.h>\r
index c562582ccee067ea3e4cadc442c03dc800d72dda..823dbe906cb8f0028c369a453dd8ed7252a18a80 100644 (file)
@@ -7,7 +7,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 \r
 **/\r
 \r
-#include <PiSmm.h>\r
+#include <PiMm.h>\r
 #include <Library/SmmCpuFeaturesLib.h>\r
 #include "CpuFeaturesLib.h"\r
 \r
index dcc2e9f9a09a3c11ed5a747f4caa01e62d8e8fa6..c92387625ddc6da2b669bfd8734b4452c5d81679 100644 (file)
@@ -6,7 +6,7 @@
 \r
 **/\r
 \r
-#include <PiSmm.h>\r
+#include <PiMm.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.c b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.c
new file mode 100644 (file)
index 0000000..dec6e53
--- /dev/null
@@ -0,0 +1,50 @@
+/** @file\r
+Standalone MM CPU specific programming.\r
+\r
+Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) Microsoft Corporation.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <PiMm.h>\r
+#include <Library/PcdLib.h>\r
+#include "CpuFeaturesLib.h"\r
+\r
+/**\r
+  Gets the maximum number of logical processors from the PCD PcdCpuMaxLogicalProcessorNumber.\r
+\r
+  This access is abstracted from the PCD services to enforce that the PCD be\r
+  FixedAtBuild in the Standalone MM build of this driver.\r
+\r
+  @return  The value of PcdCpuMaxLogicalProcessorNumber.\r
+\r
+**/\r
+UINT32\r
+GetCpuMaxLogicalProcessorNumber (\r
+  VOID\r
+  )\r
+{\r
+  return FixedPcdGet32 (PcdCpuMaxLogicalProcessorNumber);\r
+}\r
+\r
+/**\r
+  The Standalone MM library constructor.\r
+\r
+  @param[in] ImageHandle  Image handle of this driver.\r
+  @param[in] SystemTable  A Pointer to the EFI System Table.\r
+\r
+  @retval EFI_SUCCESS     This constructor always returns success.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+StandaloneMmCpuFeaturesLibConstructor (\r
+  IN EFI_HANDLE           ImageHandle,\r
+  IN EFI_MM_SYSTEM_TABLE  *SystemTable\r
+  )\r
+{\r
+  CpuFeaturesLibInitialization ();\r
+\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf b/UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf
new file mode 100644 (file)
index 0000000..ec97041
--- /dev/null
@@ -0,0 +1,38 @@
+## @file\r
+#  Standalone MM CPU specific programming.\r
+#\r
+#  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) Microsoft Corporation.<BR>\r
+#  SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = StandaloneMmCpuFeaturesLib\r
+  MODULE_UNI_FILE                = SmmCpuFeaturesLib.uni\r
+  FILE_GUID                      = BB554A2D-F5DF-41D3-8C62-46476A2B2B18\r
+  MODULE_TYPE                    = MM_STANDALONE\r
+  VERSION_STRING                 = 1.0\r
+  PI_SPECIFICATION_VERSION       = 0x00010032\r
+  LIBRARY_CLASS                  = SmmCpuFeaturesLib\r
+  CONSTRUCTOR                    = StandaloneMmCpuFeaturesLibConstructor\r
+\r
+[Sources]\r
+  CpuFeaturesLib.h\r
+  StandaloneMmCpuFeaturesLib.c\r
+  SmmCpuFeaturesLibCommon.c\r
+  SmmCpuFeaturesLibNoStm.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  UefiCpuPkg/UefiCpuPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  DebugLib\r
+  MemoryAllocationLib\r
+  PcdLib\r
+\r
+[FixedPcd]\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuMaxLogicalProcessorNumber        ## SOMETIMES_CONSUMES\r
index aacc1455a90c4cef9f98f81ea92501d6a1c40fc1..c8a3f58e0ca5ef49e3ad03304498a5751050827c 100644 (file)
@@ -6,7 +6,7 @@
 \r
 **/\r
 \r
-#include <PiSmm.h>\r
+#include <PiMm.h>\r
 #include <Library/DebugLib.h>\r
 \r
 #include "SmmStm.h"\r
index 9128cef076dd18c2160c18fce7c5870ca8a1f115..7db419471deb6c843df824728e8ab0b721f97702 100644 (file)
   UefiCpuPkg/Library/SmmCpuPlatformHookLibNull/SmmCpuPlatformHookLibNull.inf\r
   UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf\r
   UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf\r
+  UefiCpuPkg/Library/SmmCpuFeaturesLib/StandaloneMmCpuFeaturesLib.inf\r
   UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf\r
   UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf\r
   UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf\r