]> git.proxmox.com Git - mirror_edk2.git/commitdiff
IntelFsp2WrapperPkg: Support UPD allocation outside FspWrapper
authorChasel, Chiu <chasel.chiu@intel.com>
Thu, 23 Nov 2017 02:22:45 +0000 (10:22 +0800)
committerChasel, Chiu <chasel.chiu@intel.com>
Wed, 29 Nov 2017 07:52:25 +0000 (15:52 +0800)
UPD allocation and patching can be done outside FspWrapper
as implementation choice so adding a PCD to select between
original FspWrapper allocation model or outside model

Cc: Jiewen Yao <Jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.c
IntelFsp2WrapperPkg/FspmWrapperPeim/FspmWrapperPeim.inf
IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.c
IntelFsp2WrapperPkg/FspsWrapperPeim/FspsWrapperPeim.inf
IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec

index f1d1cd642181dbefee8a1f1f4593c7191eeaf6ba..7b7c5f5d86a465fd3062a5f5a853ffbcdfe593c2 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 - 2017, 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
   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
index 2b3d240d08ef6e60dd7d14ab4faaa9bcdc6cceb8..542356b5821f0bd1558e606b95408adcd90d6d57 100644 (file)
@@ -59,7 +59,8 @@
   IntelFsp2WrapperPkg/IntelFsp2WrapperPkg.dec\r
 \r
 [Pcd]\r
-  gIntelFsp2WrapperTokenSpaceGuid.PcdFspmBaseAddress  ## CONSUMES\r
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspmBaseAddress     ## CONSUMES\r
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspmUpdDataAddress  ## CONSUMES\r
 \r
 [Sources]\r
   FspmWrapperPeim.c\r
index ddc19c7e8f69ceb760782ebebd12bcc7ed8c10f8..70dac7a4142dc62c1ba8b549599fe17b097d8eea 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 - 2017, 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
@@ -44,14 +44,14 @@ extern EFI_PEI_NOTIFY_DESCRIPTOR mS3EndOfPeiNotifyDesc;
 extern EFI_GUID                  gFspHobGuid;\r
 \r
 /**\r
-This function handles S3 resume task at the end of PEI\r
+  This function handles S3 resume task at the end of PEI\r
 \r
-@param[in] PeiServices    Pointer to PEI Services Table.\r
-@param[in] NotifyDesc     Pointer to the descriptor for the Notification event that\r
-caused this function to execute.\r
-@param[in] Ppi            Pointer to the PPI data associated with this function.\r
+  @param[in] PeiServices    Pointer to PEI Services Table.\r
+  @param[in] NotifyDesc     Pointer to the descriptor for the Notification event that\r
+                            caused this function to execute.\r
+  @param[in] Ppi            Pointer to the PPI data associated with this function.\r
 \r
-@retval EFI_STATUS        Always return EFI_SUCCESS\r
+  @retval EFI_STATUS        Always return EFI_SUCCESS\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -68,14 +68,14 @@ EFI_PEI_NOTIFY_DESCRIPTOR mS3EndOfPeiNotifyDesc = {
 };\r
 \r
 /**\r
-This function handles S3 resume task at the end of PEI\r
+  This function handles S3 resume task at the end of PEI\r
 \r
-@param[in] PeiServices    Pointer to PEI Services Table.\r
-@param[in] NotifyDesc     Pointer to the descriptor for the Notification event that\r
-caused this function to execute.\r
-@param[in] Ppi            Pointer to the PPI data associated with this function.\r
+  @param[in] PeiServices    Pointer to PEI Services Table.\r
+  @param[in] NotifyDesc     Pointer to the descriptor for the Notification event that\r
+                            caused this function to execute.\r
+  @param[in] Ppi            Pointer to the PPI data associated with this function.\r
 \r
-@retval EFI_STATUS        Always return EFI_SUCCESS\r
+  @retval EFI_STATUS        Always return EFI_SUCCESS\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -130,13 +130,13 @@ S3EndOfPeiNotify(
 }\r
 \r
 /**\r
-Return Hob list produced by FSP.\r
+  Return Hob list produced by FSP.\r
 \r
-@param[in]  PeiServices  The pointer to the PEI Services Table.\r
-@param[in]  This         The pointer to this instance of this PPI.\r
-@param[out] FspHobList   The pointer to Hob list produced by FSP.\r
+  @param[in]  PeiServices  The pointer to the PEI Services Table.\r
+  @param[in]  This         The pointer to this instance of this PPI.\r
+  @param[out] FspHobList   The pointer to Hob list produced by FSP.\r
 \r
-@return EFI_SUCCESS FReturn Hob list produced by FSP successfully.\r
+  @return EFI_SUCCESS FReturn Hob list produced by FSP successfully.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -157,13 +157,13 @@ EFI_PEI_PPI_DESCRIPTOR            mPeiFspSiliconInitDonePpi = {
 };\r
 \r
 /**\r
-Return Hob list produced by FSP.\r
+  Return Hob list produced by FSP.\r
 \r
-@param[in]  PeiServices  The pointer to the PEI Services Table.\r
-@param[in]  This         The pointer to this instance of this PPI.\r
-@param[out] FspHobList   The pointer to Hob list produced by FSP.\r
+  @param[in]  PeiServices  The pointer to the PEI Services Table.\r
+  @param[in]  This         The pointer to this instance of this PPI.\r
+  @param[out] FspHobList   The pointer to Hob list produced by FSP.\r
 \r
-@return EFI_SUCCESS FReturn Hob list produced by FSP successfully.\r
+  @return EFI_SUCCESS FReturn Hob list produced by FSP successfully.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -209,14 +209,14 @@ EFI_PEI_NOTIFY_DESCRIPTOR mPeiMemoryDiscoveredNotifyDesc = {
 };\r
 \r
 /**\r
-This function is called after PEI core discover memory and finish migration.\r
+  This function is called after PEI core discover memory and finish migration.\r
 \r
-@param[in] PeiServices    Pointer to PEI Services Table.\r
-@param[in] NotifyDesc     Pointer to the descriptor for the Notification event that\r
-caused this function to execute.\r
-@param[in] Ppi            Pointer to the PPI data associated with this function.\r
+  @param[in] PeiServices    Pointer to PEI Services Table.\r
+  @param[in] NotifyDesc     Pointer to the descriptor for the Notification event that\r
+                            caused this function to execute.\r
+  @param[in] Ppi            Pointer to the PPI data associated with this function.\r
 \r
-@retval EFI_STATUS        Always return EFI_SUCCESS\r
+  @retval EFI_STATUS        Always return EFI_SUCCESS\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -234,22 +234,27 @@ PeiMemoryDiscoveredNotify (
   FSPS_UPD_COMMON           *FspsUpdDataPtr;\r
   UINTN                     *SourceData;\r
 \r
-  \r
   DEBUG ((DEBUG_INFO, "PeiMemoryDiscoveredNotify enter\n"));\r
-  \r
-  //\r
-  // Copy default FSP-S UPD data from Flash\r
-  //\r
+  FspsUpdDataPtr = NULL;\r
+\r
   FspsHeaderPtr = (FSP_INFO_HEADER *)FspFindFspHeader (PcdGet32 (PcdFspsBaseAddress));\r
   DEBUG ((DEBUG_INFO, "FspsHeaderPtr - 0x%x\n", FspsHeaderPtr));\r
   if (FspsHeaderPtr == NULL) {\r
     return EFI_DEVICE_ERROR;\r
   }\r
 \r
-  FspsUpdDataPtr = (FSPS_UPD_COMMON *)AllocateZeroPool ((UINTN)FspsHeaderPtr->CfgRegionSize);\r
-  ASSERT (FspsUpdDataPtr != NULL);\r
-  SourceData = (UINTN *)((UINTN)FspsHeaderPtr->ImageBase + (UINTN)FspsHeaderPtr->CfgRegionOffset);\r
-  CopyMem (FspsUpdDataPtr, SourceData, (UINTN)FspsHeaderPtr->CfgRegionSize);\r
+  if (PcdGet32 (PcdFspsUpdDataAddress) == 0 && (FspsHeaderPtr->CfgRegionSize != 0) && (FspsHeaderPtr->CfgRegionOffset != 0)) {\r
+    //\r
+    // Copy default FSP-S UPD data from Flash\r
+    //\r
+    FspsUpdDataPtr = (FSPS_UPD_COMMON *)AllocateZeroPool ((UINTN)FspsHeaderPtr->CfgRegionSize);\r
+    ASSERT (FspsUpdDataPtr != NULL);\r
+    SourceData = (UINTN *)((UINTN)FspsHeaderPtr->ImageBase + (UINTN)FspsHeaderPtr->CfgRegionOffset);\r
+    CopyMem (FspsUpdDataPtr, SourceData, (UINTN)FspsHeaderPtr->CfgRegionSize);\r
+  } else {\r
+    FspsUpdDataPtr = (FSPS_UPD_COMMON *)PcdGet32 (PcdFspsUpdDataAddress);\r
+    ASSERT (FspsUpdDataPtr != NULL);\r
+  }\r
 \r
   UpdateFspsUpdData ((VOID *)FspsUpdDataPtr);\r
 \r
@@ -314,7 +319,7 @@ FspsWrapperInit (
   //\r
   Status = PeiServicesNotifyPpi (&mPeiMemoryDiscoveredNotifyDesc);\r
   ASSERT_EFI_ERROR (Status);\r
-      \r
+\r
   //\r
   // Register EndOfPei Notify for S3 to run FSP NotifyPhase\r
   //\r
@@ -342,7 +347,6 @@ FspsWrapperPeimEntryPoint (
   IN CONST EFI_PEI_SERVICES     **PeiServices\r
   )\r
 {\r
-\r
   DEBUG ((DEBUG_INFO, "FspsWrapperPeimEntryPoint\n"));\r
 \r
   FspsWrapperInit ();\r
index c858e7097d06c3b8dc73ed5f04668fef4efb57f9..cd87a99c40af8706108fc24ee5466a55da5cb487 100644 (file)
@@ -66,7 +66,8 @@
   gEfiPeiMemoryDiscoveredPpiGuid        ## NOTIFY\r
 \r
 [Pcd]\r
-  gIntelFsp2WrapperTokenSpaceGuid.PcdFspsBaseAddress  ## CONSUMES\r
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspsBaseAddress     ## CONSUMES\r
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspsUpdDataAddress  ## CONSUMES\r
 \r
 [Guids]\r
   gFspHobGuid                           ## CONSUMES ## HOB\r
index c0881852c577a55ce2e289fb09b9678cd4b1be5d..7634619f80282c2d40f8ece29a8d411a5d0ac100 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Provides drivers and definitions to support fsp in EDKII bios.\r
 #\r
-# Copyright (c) 2014 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2014 - 2017, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials are licensed and made available under\r
 # the terms and conditions of the BSD License that accompanies this distribution.\r
 # The full text of the license may be found at\r
 \r
 [PcdsFixedAtBuild, PcdsPatchableInModule,PcdsDynamic,PcdsDynamicEx]\r
   gIntelFsp2WrapperTokenSpaceGuid.PcdFspsBaseAddress|0x00000000|UINT32|0x00001001\r
-  
\ No newline at end of file
+  #\r
+  # To provide flexibility for platform to pre-allocate FSP UPD buffer\r
+  #\r
+  # The PCDs define the pre-allocated FSPM and FSPS UPD Data Buffer Address.\r
+  # 0x00000000 - Platform will not pre-allocate UPD buffer before FspWrapper module\r
+  # non-zero   - Platform will pre-allocate UPD buffer and patch this value to\r
+  #              buffer address before FspWrapper module executing.\r
+  #\r
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspmUpdDataAddress|0x00000000|UINT32|0x50000000\r
+  gIntelFsp2WrapperTokenSpaceGuid.PcdFspsUpdDataAddress|0x00000000|UINT32|0x50000001
\ No newline at end of file