]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
MdePkg: introduce standalone MM entry point library implementation
[mirror_edk2.git] / IntelFsp2WrapperPkg / FspmWrapperPeim / FspmWrapperPeim.c
index f1d1cd642181dbefee8a1f1f4593c7191eeaf6ba..18f04b541a21714a115dab64cd2516ff16a30103 100644 (file)
@@ -3,7 +3,7 @@
   register TemporaryRamDonePpi to call TempRamExit API, and register MemoryDiscoveredPpi\r
   notify to call FspSiliconInit API.\r
 \r
-  Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2014 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -63,20 +63,29 @@ PeiFspMemoryInit (
   DEBUG ((DEBUG_INFO, "PeiFspMemoryInit enter\n"));\r
 \r
   FspHobListPtr = NULL;\r
+  FspmUpdDataPtr = NULL;\r
 \r
-  //\r
-  // Copy default FSP-M UPD data from Flash\r
-  //\r
-  FspmHeaderPtr = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspmBaseAddress));\r
+  FspmHeaderPtr = (FSP_INFO_HEADER *) FspFindFspHeader (PcdGet32 (PcdFspmBaseAddress));\r
   DEBUG ((DEBUG_INFO, "FspmHeaderPtr - 0x%x\n", FspmHeaderPtr));\r
   if (FspmHeaderPtr == NULL) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
-  FspmUpdDataPtr = (FSPM_UPD_COMMON *)AllocateZeroPool ((UINTN)FspmHeaderPtr->CfgRegionSize);\r
-  ASSERT (FspmUpdDataPtr != NULL);\r
-  SourceData = (UINTN *)((UINTN)FspmHeaderPtr->ImageBase + (UINTN)FspmHeaderPtr->CfgRegionOffset);\r
-  CopyMem (FspmUpdDataPtr, SourceData, (UINTN)FspmHeaderPtr->CfgRegionSize);\r
+  if (PcdGet32 (PcdFspmUpdDataAddress) == 0 && (FspmHeaderPtr->CfgRegionSize != 0) && (FspmHeaderPtr->CfgRegionOffset != 0)) {\r
+    //\r
+    // Copy default FSP-M UPD data from Flash\r
+    //\r
+    FspmUpdDataPtr = (FSPM_UPD_COMMON *)AllocateZeroPool ((UINTN)FspmHeaderPtr->CfgRegionSize);\r
+    ASSERT (FspmUpdDataPtr != NULL);\r
+    SourceData = (UINTN *)((UINTN)FspmHeaderPtr->ImageBase + (UINTN)FspmHeaderPtr->CfgRegionOffset);\r
+    CopyMem (FspmUpdDataPtr, SourceData, (UINTN)FspmHeaderPtr->CfgRegionSize);\r
+  } else {\r
+    //\r
+    // External UPD is ready, get the buffer from PCD pointer.\r
+    //\r
+    FspmUpdDataPtr = (FSPM_UPD_COMMON *)PcdGet32 (PcdFspmUpdDataAddress);\r
+    ASSERT (FspmUpdDataPtr != NULL);\r
+  }\r
 \r
   DEBUG ((DEBUG_INFO, "UpdateFspmUpdData enter\n"));\r
   UpdateFspmUpdData ((VOID *)FspmUpdDataPtr);\r
@@ -146,8 +155,20 @@ FspmWrapperInit (
 {\r
   EFI_STATUS           Status;\r
 \r
-  Status = PeiFspMemoryInit ();\r
-  ASSERT_EFI_ERROR (Status);\r
+  Status = EFI_SUCCESS;\r
+\r
+  if (PcdGet8 (PcdFspModeSelection) == 1) {\r
+    Status = PeiFspMemoryInit ();\r
+    ASSERT_EFI_ERROR (Status);\r
+  } else {\r
+    PeiServicesInstallFvInfoPpi (\r
+      NULL,\r
+      (VOID *)(UINTN) PcdGet32 (PcdFspmBaseAddress),\r
+      (UINT32)((EFI_FIRMWARE_VOLUME_HEADER *) (UINTN) PcdGet32 (PcdFspmBaseAddress))->FvLength,\r
+      NULL,\r
+      NULL\r
+      );\r
+  }\r
 \r
   return Status;\r
 }\r