[edk2-devel] [edk2-platforms][PATCH v2 3/3] MinPlatformPkg/SpiFvbService: Add Standalone MM support

Michael Kubacki mikuback at linux.microsoft.com
Thu Feb 11 20:38:55 UTC 2021


From: Michael Kubacki <michael.kubacki at microsoft.com>

Adds support for MM_STANDALONE. Retains the directory path to the
SMM INF instance for backward compatibility with existing platforms.

Cc: Chasel Chiu <chasel.chiu at intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone at intel.com>
Cc: Liming Gao <gaoliming at byosoft.com.cn>
Cc: Eric Dong <eric.dong at intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki at microsoft.com>
---
 Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/{Common => }/FvbInfo.c                                  |  0
 Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/{Common => }/SpiFvbServiceCommon.c                      |  0
 Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/{Smm/SpiFvbServiceSmm.c => SpiFvbServiceMm.c}           | 35 ++++++-----------
 Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.c                             | 32 ++++++++++++++++
 Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceTraditionalMm.c                            | 32 ++++++++++++++++
 Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/{Common => }/SpiFvbServiceCommon.h                      |  4 --
 Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.h                                       | 22 +++++++++++
 Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf                                    | 17 +++++----
 Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/{SpiFvbServiceSmm.inf => SpiFvbServiceStandaloneMm.inf} | 40 ++++++++++----------
 Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc                                                          |  2 +
 10 files changed, 130 insertions(+), 54 deletions(-)

diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Common/FvbInfo.c b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/FvbInfo.c
similarity index 100%
rename from Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Common/FvbInfo.c
rename to Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/FvbInfo.c
diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Common/SpiFvbServiceCommon.c b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.c
similarity index 100%
rename from Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Common/SpiFvbServiceCommon.c
rename to Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.c
diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Smm/SpiFvbServiceSmm.c b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.c
similarity index 89%
rename from Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Smm/SpiFvbServiceSmm.c
rename to Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.c
index 251fcae30b90..016f19587c91 100644
--- a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Smm/SpiFvbServiceSmm.c
+++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.c
@@ -1,14 +1,16 @@
 /** @file
-  Common driver source for several Serial Flash devices
+  MM driver source for several Serial Flash devices
   which are compliant with the Intel(R) Serial Flash Interface Compatibility Specification.
 
-Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
-SPDX-License-Identifier: BSD-2-Clause-Patent
+  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+  Copyright (c) Microsoft Corporation.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
 #include "SpiFvbServiceCommon.h"
-#include <Library/SmmServicesTableLib.h>
+#include <Library/MmServicesTableLib.h>
+#include <Library/UefiDriverEntryPoint.h>
 #include <Protocol/SmmFirmwareVolumeBlock.h>
 
 /**
@@ -74,7 +76,7 @@ InstallFvbProtocol (
   //
   FvbHandle = NULL;
 
-  Status = gSmst->SmmInstallProtocolInterface (
+  Status = gMmst->MmInstallProtocolInterface (
                     &FvbHandle,
                     &gEfiSmmFirmwareVolumeBlockProtocolGuid,
                     EFI_NATIVE_INTERFACE,
@@ -82,7 +84,7 @@ InstallFvbProtocol (
                     );
   ASSERT_EFI_ERROR (Status);
 
-  Status = gSmst->SmmInstallProtocolInterface (
+  Status = gMmst->MmInstallProtocolInterface (
                     &FvbHandle,
                     &gEfiDevicePathProtocolGuid,
                     EFI_NATIVE_INTERFACE,
@@ -92,22 +94,13 @@ InstallFvbProtocol (
 }
 
 /**
-
   The function does the necessary initialization work for
   Firmware Volume Block Driver.
 
-  @param[in]  ImageHandle       The firmware allocated handle for the UEFI image.
-  @param[in]  SystemTable       A pointer to the EFI system table.
-
-  @retval     EFI_SUCCESS       This funtion always return EFI_SUCCESS.
-                                It will ASSERT on errors.
-
 **/
-EFI_STATUS
-EFIAPI
+VOID
 FvbInitialize (
-  IN EFI_HANDLE        ImageHandle,
-  IN EFI_SYSTEM_TABLE  *SystemTable
+  VOID
   )
 {
   EFI_FVB_INSTANCE                      *FvbInstance;
@@ -219,8 +212,7 @@ FvbInitialize (
     mFvbModuleGlobal.FvbInstance =  (EFI_FVB_INSTANCE *) AllocateRuntimeZeroPool (BufferSize);
     if (mFvbModuleGlobal.FvbInstance == NULL) {
       ASSERT (FALSE);
-      Status = EFI_OUT_OF_RESOURCES;
-      goto ERROR;
+      return;
     }
 
     MaxLbaSize      = 0;
@@ -276,9 +268,4 @@ FvbInitialize (
 
     }
   }
-
-  return EFI_SUCCESS;
-
-ERROR:
-  return Status;
 }
diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.c b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.c
new file mode 100644
index 000000000000..252c818d6551
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.c
@@ -0,0 +1,32 @@
+/** @file
+  MM driver source for several Serial Flash devices
+  which are compliant with the Intel(R) Serial Flash Interface Compatibility Specification.
+
+  Copyright (c) Microsoft Corporation.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "SpiFvbServiceCommon.h"
+#include "SpiFvbServiceMm.h"
+
+/**
+  The driver Standalone MM entry point.
+
+  @param[in] ImageHandle          Image handle of this driver.
+  @param[in] MmSystemTable        A pointer to the MM system table.
+
+  @retval EFI_SUCCESS             This function always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+SpiFvbStandaloneMmInitialize (
+  IN EFI_HANDLE            ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE   *MmSystemTable
+  )
+{
+  FvbInitialize ();
+
+  return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceTraditionalMm.c b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceTraditionalMm.c
new file mode 100644
index 000000000000..1c2dac70e3c6
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceTraditionalMm.c
@@ -0,0 +1,32 @@
+/** @file
+  MM driver source for several Serial Flash devices
+  which are compliant with the Intel(R) Serial Flash Interface Compatibility Specification.
+
+  Copyright (c) Microsoft Corporation.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include "SpiFvbServiceCommon.h"
+#include "SpiFvbServiceMm.h"
+
+/**
+  The driver Traditional MM entry point.
+
+  @param[in] ImageHandle          Image handle of this driver.
+  @param[in] SystemTable          A pointer to the EFI system table.
+
+  @retval EFI_SUCCESS             This function always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+SpiFvbTraditionalMmInitialize (
+  IN EFI_HANDLE            ImageHandle,
+  IN EFI_SYSTEM_TABLE      *SystemTable
+  )
+{
+  FvbInitialize ();
+
+  return EFI_SUCCESS;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Common/SpiFvbServiceCommon.h b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.h
similarity index 94%
rename from Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Common/SpiFvbServiceCommon.h
rename to Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.h
index 6379fc86d52e..e9d69e985814 100644
--- a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/Common/SpiFvbServiceCommon.h
+++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceCommon.h
@@ -15,9 +15,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Protocol/DevicePath.h>
 #include <Protocol/FirmwareVolumeBlock.h>
 
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
 #include <Library/BaseLib.h>
 #include <Library/DebugLib.h>
 #include <Library/BaseMemoryLib.h>
@@ -159,4 +156,3 @@ extern FV_INFO                            mPlatformFvBaseAddress[];
 extern FV_INFO                            mPlatformDefaultBaseAddress[];
 
 #endif
-
diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.h b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.h
new file mode 100644
index 000000000000..36af1130c8ee
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceMm.h
@@ -0,0 +1,22 @@
+/** @file
+  Definitions common to MM implementation in this driver.
+
+  Copyright (c) Microsoft Corporation.<BR>
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef _SPI_FVB_SERVICE_MM_H_
+#define _SPI_FVB_SERVICE_MM_H_
+
+/**
+  The function does the necessary initialization work for
+  Firmware Volume Block Driver.
+
+**/
+VOID
+FvbInitialize (
+  VOID
+  );
+
+#endif
diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf
index d59c499b2e9e..10e51e11756f 100644
--- a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf
+++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf
@@ -2,6 +2,7 @@
 # Component description file for the Serial Flash device Runtime driver.
 #
 # Copyright (c) 2017-2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) Microsoft Corporation.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
@@ -14,7 +15,8 @@ [Defines]
   VERSION_STRING                 = 1.0
   MODULE_TYPE                    = DXE_SMM_DRIVER
   PI_SPECIFICATION_VERSION       = 1.10
-  ENTRY_POINT                    = FvbInitialize
+  ENTRY_POINT                    = SpiFvbTraditionalMmInitialize
+
 #
 # The following information is for reference only and not required by the build tools.
 #
@@ -28,11 +30,10 @@ [LibraryClasses]
   BaseMemoryLib
   DebugLib
   BaseLib
-  UefiLib
   UefiBootServicesTableLib
   UefiDriverEntryPoint
   SpiFlashCommonLib
-  SmmServicesTableLib
+  MmServicesTableLib
 
 [Packages]
   MdePkg/MdePkg.dec
@@ -48,10 +49,12 @@ [Pcd]
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvMicrocodeSize          ## CONSUMES
 
 [Sources]
-  Common/SpiFvbServiceCommon.c
-  Common/FvbInfo.c
-  Common/SpiFvbServiceCommon.h
-  Smm/SpiFvbServiceSmm.c
+  FvbInfo.c
+  SpiFvbServiceCommon.h
+  SpiFvbServiceCommon.c
+  SpiFvbServiceMm.h
+  SpiFvbServiceMm.c
+  SpiFvbServiceTraditionalMm.c
 
 [Protocols]
   gEfiDevicePathProtocolGuid                    ## PRODUCES
diff --git a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.inf
similarity index 64%
copy from Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf
copy to Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.inf
index d59c499b2e9e..9f08d3673f41 100644
--- a/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf
+++ b/Platform/Intel/MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.inf
@@ -1,20 +1,22 @@
 ### @file
-# Component description file for the Serial Flash device Runtime driver.
+# Component description file for the Serial Flash device Standalone MM driver.
 #
 # Copyright (c) 2017-2019, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) Microsoft Corporation.<BR>
 #
 # SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ###
 
 [Defines]
-  INF_VERSION                    = 0x00010017
-  BASE_NAME                      = SpiFvbServiceSmm
-  FILE_GUID                      = 68A10D85-6858-4402-B070-028B3EA21747
+  INF_VERSION                    = 0x0001001B
+  BASE_NAME                      = SpiFvbServiceStandaloneMm
+  FILE_GUID                      = E6313655-8BD0-4EAB-B319-AD5E212CE6AB
   VERSION_STRING                 = 1.0
-  MODULE_TYPE                    = DXE_SMM_DRIVER
-  PI_SPECIFICATION_VERSION       = 1.10
-  ENTRY_POINT                    = FvbInitialize
+  MODULE_TYPE                    = MM_STANDALONE
+  PI_SPECIFICATION_VERSION       = 0x00010032
+  ENTRY_POINT                    = SpiFvbStandaloneMmInitialize
+
 #
 # The following information is for reference only and not required by the build tools.
 #
@@ -22,17 +24,15 @@ [Defines]
 #
 
 [LibraryClasses]
-  PcdLib
-  MemoryAllocationLib
-  CacheMaintenanceLib
+  BaseLib
   BaseMemoryLib
+  CacheMaintenanceLib
   DebugLib
-  BaseLib
-  UefiLib
-  UefiBootServicesTableLib
-  UefiDriverEntryPoint
+  MemoryAllocationLib
+  PcdLib
+  MmServicesTableLib
   SpiFlashCommonLib
-  SmmServicesTableLib
+  StandaloneMmDriverEntryPoint
 
 [Packages]
   MdePkg/MdePkg.dec
@@ -48,10 +48,12 @@ [Pcd]
   gMinPlatformPkgTokenSpaceGuid.PcdFlashFvMicrocodeSize          ## CONSUMES
 
 [Sources]
-  Common/SpiFvbServiceCommon.c
-  Common/FvbInfo.c
-  Common/SpiFvbServiceCommon.h
-  Smm/SpiFvbServiceSmm.c
+  FvbInfo.c
+  SpiFvbServiceCommon.h
+  SpiFvbServiceCommon.c
+  SpiFvbServiceMm.h
+  SpiFvbServiceMm.c
+  SpiFvbServiceStandaloneMm.c
 
 [Protocols]
   gEfiDevicePathProtocolGuid                    ## PRODUCES
diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc
index 5e88de43e08d..0460fd5a3206 100644
--- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc
+++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc
@@ -117,6 +117,7 @@ [LibraryClasses.common.MM_STANDALONE]
   DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
   MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf
   MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
+  SpiFlashCommonLib|MinPlatformPkg/Flash/Library/SpiFlashCommonLibNull/SpiFlashCommonLibNull.inf
   StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
 
 ###################################################################################################
@@ -155,6 +156,7 @@ [Components]
   MinPlatformPkg/Bds/Library/DxePlatformBootManagerLib/DxePlatformBootManagerLib.inf
 
   MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceSmm.inf
+  MinPlatformPkg/Flash/SpiFvbService/SpiFvbServiceStandaloneMm.inf
   MinPlatformPkg/Flash/Library/SpiFlashCommonLibNull/SpiFlashCommonLibNull.inf
 
   MinPlatformPkg/FspWrapper/SaveMemoryConfig/SaveMemoryConfig.inf
-- 
2.28.0.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#71624): https://edk2.groups.io/g/devel/message/71624
Mute This Topic: https://groups.io/mt/80567998/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-






More information about the edk2-devel-archive mailing list