]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
Code scrub DxeIpl, Runtime, DevicePath, FvbServicesLib, DiskIo, Partition, English...
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Dispatcher / Dispatcher.c
index cf9ea5d173fe1a78ddb813cc405f3a2d3f014fcd..e6e3a11b168ff203e747ba02329a5400cc156893 100644 (file)
@@ -1,5 +1,6 @@
-/*++\r
-\r
+/** @file\r
+  EFI PEI Core dispatch services\r
+  \r
 Copyright (c) 2006, Intel Corporation\r
 All rights reserved. This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -9,46 +10,35 @@ http://opensource.org/licenses/bsd-license.php
 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 \r
-Module Name:\r
-\r
-  Dispatcher.c\r
-\r
-Abstract:\r
-\r
-  EFI PEI Core dispatch services\r
-\r
-Revision History\r
+**/\r
 \r
---*/\r
+#include "PeiMain.h"\r
 \r
-#include <PeiMain.h>\r
+///\r
+/// CAR is filled with this initial value during SEC phase\r
+///\r
+#define INIT_CAR_VALUE 0x5AA55AA5\r
 \r
 typedef struct {\r
   EFI_STATUS_CODE_DATA  DataHeader;\r
   EFI_HANDLE            Handle;\r
 } PEIM_FILE_HANDLE_EXTENDED_DATA;\r
 \r
-VOID\r
-DiscoverPeimsAndOrderWithApriori (\r
-  IN  PEI_CORE_INSTANCE    *Private,\r
-  IN  EFI_PEI_FV_HANDLE    VolumeHandle\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
 \r
   Discover all Peims and optional Apriori file in one FV. There is at most one\r
   Apriori file in one FV.\r
 \r
-Arguments:\r
 \r
-  Private          - Pointer to the private data passed in from caller\r
-  VolumeHandle     - Fv handle.\r
-Returns:\r
+  @param Private         - Pointer to the private data passed in from caller\r
+  @param VolumeHandle    - Fv handle.\r
 \r
-  NONE\r
-\r
---*/\r
+**/\r
+VOID\r
+DiscoverPeimsAndOrderWithApriori (\r
+  IN  PEI_CORE_INSTANCE    *Private,\r
+  IN  EFI_PEI_FV_HANDLE    VolumeHandle\r
+  )\r
 {\r
   EFI_STATUS                          Status;\r
   EFI_PEI_FV_HANDLE                   FileHandle;\r
@@ -110,7 +100,7 @@ Returns:
       Private->AprioriCount -= sizeof (EFI_FFS_FILE_HEADER) - sizeof (EFI_COMMON_SECTION_HEADER);\r
       Private->AprioriCount /= sizeof (EFI_GUID);\r
 \r
-      SetMem (FileGuid, sizeof (FileGuid), 0);\r
+      ZeroMem (FileGuid, sizeof (FileGuid));\r
       for (Index = 0; Index < PeimCount; Index++) {\r
         //\r
         // Make an array of file name guids that matches the FileHandle array so we can convert\r
@@ -182,10 +172,18 @@ Returns:
 \r
 }\r
 \r
+/**\r
+  Shadow PeiCore module from flash to installed memory.\r
+  \r
+  @param PeiServices     An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param PrivateInMem    PeiCore's private data structure\r
+\r
+  @return PeiCore function address after shadowing.\r
+**/\r
 VOID*\r
 ShadowPeiCore(\r
-  EFI_PEI_SERVICES     **PeiServices,\r
-  PEI_CORE_INSTANCE    *PrivateInMem\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices,\r
+  IN       PEI_CORE_INSTANCE    *PrivateInMem\r
   )\r
 {\r
   EFI_PEI_FILE_HANDLE  PeiCoreFileHandle;\r
@@ -218,50 +216,39 @@ ShadowPeiCore(
               );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  //\r
+  // Compute the PeiCore's function address after shaowed PeiCore.\r
+  // _ModuleEntryPoint is PeiCore main function entry\r
+  //\r
   return (VOID*) ((UINTN) EntryPoint + (UINTN) PeiCore - (UINTN) _ModuleEntryPoint);\r
 }\r
 \r
-VOID\r
-PeiDispatcher (\r
-  IN CONST EFI_SEC_PEI_HAND_OFF  *SecCoreData,\r
-  IN PEI_CORE_INSTANCE           *Private\r
-  )\r
-\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Conduct PEIM dispatch.\r
 \r
-Arguments:\r
-\r
-  SecCoreData          - Points to a data structure containing information about the PEI core's operating\r
+  @param SecCoreData     Points to a data structure containing information about the PEI core's operating\r
                          environment, such as the size and location of temporary RAM, the stack location and\r
                          the BFV location.\r
-  PrivateData          - Pointer to the private data passed in from caller\r
-  DispatchData         - Pointer to PEI_CORE_DISPATCH_DATA data.\r
-\r
-Returns:\r
+  @param Private         Pointer to the private data passed in from caller\r
 \r
-  EFI_SUCCESS   - Successfully dispatched PEIM.\r
-  EFI_NOT_FOUND - The dispatch failed.\r
-\r
---*/\r
+**/\r
+VOID\r
+PeiDispatcher (\r
+  IN CONST EFI_SEC_PEI_HAND_OFF  *SecCoreData,\r
+  IN PEI_CORE_INSTANCE           *Private\r
+  )\r
 {\r
   EFI_STATUS                          Status;\r
   UINT32                              Index1;\r
   UINT32                              Index2;\r
-  EFI_PEI_SERVICES                    **PeiServices;\r
+  CONST EFI_PEI_SERVICES              **PeiServices;\r
   EFI_PEI_FV_HANDLE                   VolumeHandle;\r
-  //EFI_PHYSICAL_ADDRESS                PeiCoreFileHandle;\r
   EFI_PEI_FILE_HANDLE                 PeimFileHandle;\r
   UINTN                               FvCount;\r
   UINTN                               PeimCount;\r
   UINT32                              AuthenticationState;\r
   EFI_PHYSICAL_ADDRESS                EntryPoint;\r
   EFI_PEIM_ENTRY_POINT2               PeimEntryPoint;\r
-  BOOLEAN                             PeimNeedingDispatch;\r
-  BOOLEAN                             PeimDispatchOnThisPass;\r
   UINTN                               SaveCurrentPeimCount;\r
   UINTN                               SaveCurrentFvCount;\r
   EFI_PEI_FILE_HANDLE                 SaveCurrentFileHandle;\r
@@ -270,7 +257,8 @@ Returns:
   TEMPORARY_RAM_SUPPORT_PPI           *TemporaryRamSupportPpi;\r
   EFI_HOB_HANDOFF_INFO_TABLE          *OldHandOffTable;\r
   EFI_HOB_HANDOFF_INFO_TABLE          *NewHandOffTable;\r
-  INTN                                Offset;\r
+  INTN                                StackOffset;\r
+  INTN                                HeapOffset;\r
   PEI_CORE_INSTANCE                   *PrivateInMem;\r
   UINT64                              NewPeiStackSize;\r
   UINT64                              OldPeiStackSize;\r
@@ -280,7 +268,7 @@ Returns:
   UINTN                               OldCheckingBottom;\r
 \r
 \r
-  PeiServices = &Private->PS;\r
+  PeiServices = (CONST EFI_PEI_SERVICES **) &Private->PS;\r
   PeimEntryPoint = NULL;\r
   PeimFileHandle = NULL;\r
   EntryPoint     = 0;\r
@@ -299,7 +287,7 @@ Returns:
         if (Private->Fv[Index1].PeimState[Index2] == PEIM_STATE_REGISITER_FOR_SHADOW) {\r
           PeimFileHandle = Private->Fv[Index1].FvFileHandles[Index2];\r
           Status = PeiLoadImage (\r
-                    &Private->PS,\r
+                    (CONST EFI_PEI_SERVICES **) &Private->PS,\r
                     PeimFileHandle,\r
                     &EntryPoint,\r
                     &AuthenticationState\r
@@ -344,12 +332,22 @@ Returns:
   // satisfied, this dipatcher should run only once.\r
   //\r
   do {\r
-    PeimNeedingDispatch = FALSE;\r
-    PeimDispatchOnThisPass = FALSE;\r
-\r
+    //\r
+    // In case that reenter PeiCore happens, the last pass record is still available.   \r
+    //\r
+    if (!Private->PeimDispatcherReenter) {\r
+      Private->PeimNeedingDispatch      = FALSE;\r
+      Private->PeimDispatchOnThisPass   = FALSE;\r
+    } else {\r
+      Private->PeimDispatcherReenter    = FALSE;\r
+    }\r
+    \r
     for (FvCount = Private->CurrentPeimFvCount; FvCount < Private->FvCount; FvCount++) {\r
       Private->CurrentPeimFvCount = FvCount;\r
-      VolumeHandle = Private->Fv[FvCount].FvHeader;\r
+      //\r
+      // Get this Fv Handle by PeiService FvFindNextVolume.\r
+      //\r
+      PeiFvFindNextVolume (PeiServices, FvCount, &VolumeHandle);\r
 \r
       if (Private->CurrentPeimCount == 0) {\r
         //\r
@@ -371,7 +369,7 @@ Returns:
 \r
         if (Private->Fv[FvCount].PeimState[PeimCount] == PEIM_STATE_NOT_DISPATCHED) {\r
           if (!DepexSatisfied (Private, PeimFileHandle, PeimCount)) {\r
-            PeimNeedingDispatch = TRUE;\r
+            Private->PeimNeedingDispatch = TRUE;\r
           } else {\r
             Status = PeiFfsGetFileInfo (PeimFileHandle, &FvFileInfo);\r
             ASSERT_EFI_ERROR (Status);\r
@@ -423,7 +421,7 @@ Returns:
                   PeimEntryPoint (PeimFileHandle, (const EFI_PEI_SERVICES **) PeiServices);\r
                 }\r
 \r
-                PeimDispatchOnThisPass = TRUE;\r
+                Private->PeimDispatchOnThisPass = TRUE;\r
               }\r
 \r
               REPORT_STATUS_CODE_WITH_EXTENDED_DATA (\r
@@ -437,11 +435,32 @@ Returns:
             }\r
 \r
             if (Private->SwitchStackSignal) {\r
-\r
+              //\r
+              // Before switch stack from CAR to permenent memory, caculate the heap and stack\r
+              // usage in temporary memory for debuging.\r
+              //\r
+              DEBUG_CODE_BEGIN ();\r
+                UINT32  *StackPointer;\r
+                \r
+                for (StackPointer = (UINT32*)SecCoreData->StackBase;\r
+                     (StackPointer < (UINT32*)((UINTN)SecCoreData->StackBase + SecCoreData->StackSize)) \\r
+                     && (*StackPointer == INIT_CAR_VALUE);\r
+                     StackPointer ++);\r
+                     \r
+                DEBUG ((EFI_D_INFO, "Total Cache as RAM:    %d bytes.\n", (UINT32)SecCoreData->TemporaryRamSize));\r
+                DEBUG ((EFI_D_INFO, "  CAR stack ever used: %d bytes.\n",\r
+                       (SecCoreData->StackSize - ((UINTN) StackPointer - (UINTN)SecCoreData->StackBase))\r
+                      ));\r
+                DEBUG ((EFI_D_INFO, "  CAR heap used:       %d bytes.\n",\r
+                       ((UINTN) Private->HobList.HandoffInformationTable->EfiFreeMemoryBottom -\r
+                       (UINTN) Private->HobList.Raw)\r
+                      ));\r
+              DEBUG_CODE_END ();\r
+              \r
               //\r
               // Reserve the size of new stack at bottom of physical memory\r
               //\r
-              OldPeiStackSize = Private->StackSize;\r
+              OldPeiStackSize = (UINT64) SecCoreData->StackSize;\r
               NewPeiStackSize = (RShiftU64 (Private->PhysicalMemoryLength, 1) + EFI_PAGE_MASK) & ~EFI_PAGE_MASK;\r
               if (FixedPcdGet32(PcdPeiCoreMaxPeiStackSize) > (UINT32) NewPeiStackSize) {\r
                 Private->StackSize = NewPeiStackSize;\r
@@ -455,16 +474,15 @@ Returns:
               // But if new stack is smaller than the size of old stack, we also reserve\r
               // the size of old stack at bottom of permenent memory.\r
               //\r
-              StackGap = 0;\r
-              if (Private->StackSize > OldPeiStackSize) {\r
-                StackGap = Private->StackSize - OldPeiStackSize;\r
-              }\r
+              DEBUG ((EFI_D_ERROR, "Old Stack Size%d, New stack size%d\n", (INT32) Private->StackSize, (INT32) OldPeiStackSize));\r
+              ASSERT (Private->StackSize >= OldPeiStackSize);\r
+              StackGap = Private->StackSize - OldPeiStackSize;\r
 \r
               //\r
               // Update HandOffHob for new installed permenent memory\r
               //\r
               OldHandOffTable   = Private->HobList.HandoffInformationTable;\r
-              OldCheckingBottom = (UINTN)OldHandOffTable;\r
+              OldCheckingBottom = (UINTN)(SecCoreData->TemporaryRamBase);\r
               OldCheckingTop    = (UINTN)(OldCheckingBottom + SecCoreData->TemporaryRamSize);\r
 \r
               //\r
@@ -472,9 +490,21 @@ Returns:
               // CAUTION: The new base is computed accounding to gap of new stack.\r
               //\r
               NewPermenentMemoryBase = Private->PhysicalMemoryBegin + StackGap;\r
-              Offset                 = (UINTN) NewPermenentMemoryBase - (UINTN) SecCoreData->TemporaryRamBase;\r
-              NewHandOffTable        = (EFI_HOB_HANDOFF_INFO_TABLE *)((UINTN)OldHandOffTable + Offset);\r
-              PrivateInMem           = (PEI_CORE_INSTANCE *)((UINTN) (VOID*) Private + Offset);\r
+              \r
+              //\r
+              // Caculate stack offset and heap offset between CAR and new permement \r
+              // memory seperately.\r
+              //\r
+              StackOffset            = (UINTN) NewPermenentMemoryBase - (UINTN) SecCoreData->StackBase;\r
+              HeapOffset             = (INTN) ((UINTN) Private->PhysicalMemoryBegin + Private->StackSize - \\r
+                                               (UINTN) SecCoreData->PeiTemporaryRamBase);\r
+              DEBUG ((EFI_D_INFO, "Heap Offset = 0x%lX Stack Offset = 0x%lX\n", (INT64)HeapOffset, (INT64)StackOffset));\r
+              \r
+              //\r
+              // Caculate new HandOffTable and PrivateData address in permenet memory's stack\r
+              //\r
+              NewHandOffTable        = (EFI_HOB_HANDOFF_INFO_TABLE *)((UINTN)OldHandOffTable + HeapOffset);\r
+              PrivateInMem           = (PEI_CORE_INSTANCE *)((UINTN) (VOID*) Private + StackOffset);\r
 \r
               //\r
               // TemporaryRamSupportPpi is produced by platform's SEC\r
@@ -489,6 +519,12 @@ Returns:
 \r
 \r
               if (!EFI_ERROR (Status)) {\r
+                //\r
+                // Temporary Ram support Ppi is provided by platform, it will copy \r
+                // temporary memory to permenent memory and do stack switching.\r
+                // After invoken temporary Ram support, following code's stack is in \r
+                // memory but not in CAR.\r
+                //\r
                 TemporaryRamSupportPpi->TemporaryRamMigration (\r
                                           (CONST EFI_PEI_SERVICES **) PeiServices,\r
                                           (EFI_PHYSICAL_ADDRESS)(UINTN) SecCoreData->TemporaryRamBase,\r
@@ -497,11 +533,11 @@ Returns:
                                           );\r
 \r
               } else {\r
-                CopyMem (\r
-                  (VOID*)(UINTN) NewPermenentMemoryBase,\r
-                  SecCoreData->TemporaryRamBase,\r
-                  SecCoreData->TemporaryRamSize\r
-                  );\r
+                //\r
+                // In IA32/x64/Itanium architecture, we need platform provide\r
+                // TEMPORAY_RAM_MIGRATION_PPI.\r
+                //\r
+                ASSERT (FALSE);\r
               }\r
 \r
 \r
@@ -511,10 +547,10 @@ Returns:
               //\r
               PrivateInMem->PS          = &PrivateInMem->ServiceTableShadow;\r
               PrivateInMem->CpuIo       = &PrivateInMem->ServiceTableShadow.CpuIo;\r
-              PrivateInMem->HobList.Raw = (VOID*) ((UINTN) PrivateInMem->HobList.Raw + Offset);\r
+              PrivateInMem->HobList.Raw = (VOID*) ((UINTN) PrivateInMem->HobList.Raw + HeapOffset);\r
               PrivateInMem->StackBase   = (EFI_PHYSICAL_ADDRESS)(((UINTN)PrivateInMem->PhysicalMemoryBegin + EFI_PAGE_MASK) & ~EFI_PAGE_MASK);\r
 \r
-              PeiServices = &PrivateInMem->PS;\r
+              PeiServices = (CONST EFI_PEI_SERVICES **) &PrivateInMem->PS;\r
 \r
               //\r
               // Fixup for PeiService's address\r
@@ -525,7 +561,7 @@ Returns:
               // Update HandOffHob for new installed permenent memory\r
               //\r
               NewHandOffTable->EfiEndOfHobList =\r
-                (EFI_PHYSICAL_ADDRESS)(VOID*)((UINTN) NewHandOffTable->EfiEndOfHobList + Offset);\r
+                (EFI_PHYSICAL_ADDRESS)((UINTN) NewHandOffTable->EfiEndOfHobList + HeapOffset);\r
               NewHandOffTable->EfiMemoryTop        = PrivateInMem->PhysicalMemoryBegin +\r
                                                      PrivateInMem->PhysicalMemoryLength;\r
               NewHandOffTable->EfiMemoryBottom     = PrivateInMem->PhysicalMemoryBegin;\r
@@ -536,13 +572,14 @@ Returns:
               //\r
               // We need convert the PPI desciptor's pointer\r
               //\r
-              ConvertPpiPointers ((CONST EFI_PEI_SERVICES **)PeiServices\r
+              ConvertPpiPointers (PrivateInMem\r
                                   OldCheckingBottom, \r
                                   OldCheckingTop, \r
-                                  NewHandOffTable);\r
+                                  HeapOffset\r
+                                  );\r
 \r
-              DEBUG ((EFI_D_INFO, "Stack Hob: BaseAddress=0x%X Length=0x%X\n",\r
-                                  (UINTN)PrivateInMem->StackBase,\r
+              DEBUG ((EFI_D_INFO, "Stack Hob: BaseAddress=0x%lX Length=0x%lX\n",\r
+                                  PrivateInMem->StackBase,\r
                                   PrivateInMem->StackSize));\r
               BuildStackHob (PrivateInMem->StackBase, PrivateInMem->StackSize);\r
 \r
@@ -553,41 +590,14 @@ Returns:
               PrivateInMem->PeiMemoryInstalled     = TRUE;\r
 \r
               //\r
-              // Make sure we don't retry the same PEIM that added memory\r
+              // Indicate that PeiCore reenter\r
               //\r
-              PrivateInMem->CurrentPeimCount++;\r
-\r
+              PrivateInMem->PeimDispatcherReenter  = TRUE;\r
+              \r
               //\r
               // Shadow PEI Core. When permanent memory is avaiable, shadow\r
               // PEI Core and PEIMs to get high performance.\r
               //\r
-              //PeiCoreFileHandle = 0;\r
-              //\r
-              // Find the PEI Core in the BFV\r
-              //\r
-              //Status = PeiFindFileEx (\r
-              //          (EFI_PEI_FV_HANDLE)PrivateInMem->Fv[0].FvHeader,\r
-              //          NULL,\r
-               //         EFI_FV_FILETYPE_PEI_CORE,\r
-              //          (EFI_PEI_FILE_HANDLE*)&PeiCoreFileHandle,\r
-              //          NULL\r
-              //          );\r
-              //ASSERT_EFI_ERROR (Status);\r
-\r
-              //\r
-              // Shadow PEI Core into memory so it will run faster\r
-              //\r
-              //Status = PeiLoadImage (\r
-              //           PeiServices,\r
-              //           *((EFI_PEI_FILE_HANDLE*)&PeiCoreFileHandle),\r
-              //           &EntryPoint,\r
-               //          &AuthenticationState\r
-               //          );\r
-              //ASSERT_EFI_ERROR (Status);\r
-\r
-              //PrivateInMem->ShadowedPeiCore = (VOID*) ((UINTN) EntryPoint +\r
-              //                                         (UINTN) PeiCore    -\r
-              //                                         (UINTN) _ModuleEntryPoint);\r
               PrivateInMem->ShadowedPeiCore = ShadowPeiCore (\r
                                                 PeiServices,\r
                                                 PrivateInMem\r
@@ -603,12 +613,6 @@ Returns:
               //\r
               PeiCore (SecCoreData, NULL, PrivateInMem);\r
 \r
-              //((PEI_CORE_ENTRY_POINT) (UINTN) PrivateInMem->ShadowedPeiCore) (\r
-              //                                        SecCoreData,\r
-              //                                        NULL,\r
-              //                                        PrivateInMem\r
-              //                                        );\r
-\r
               //\r
               // Code should not come here\r
               //\r
@@ -673,67 +677,57 @@ Returns:
     //  pass. If we did not dispatch a PEIM there is no point in trying again\r
     //  as it will fail the next time too (nothing has changed).\r
     //\r
-  } while (PeimNeedingDispatch && PeimDispatchOnThisPass);\r
+  } while (Private->PeimNeedingDispatch && Private->PeimDispatchOnThisPass);\r
 \r
 }\r
 \r
-VOID\r
-InitializeDispatcherData (\r
-  IN PEI_CORE_INSTANCE            *PrivateData,\r
-  IN PEI_CORE_INSTANCE            *OldCoreData,\r
-  IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData\r
-  )\r
-/*++\r
-\r
-Routine Description:\r
-\r
+/**\r
   Initialize the Dispatcher's data members\r
 \r
-Arguments:\r
-\r
-  PeiServices          - The PEI core services table.\r
-  OldCoreData          - Pointer to old core data (before switching stack).\r
+  @param PrivateData     PeiCore's private data structure\r
+  @param OldCoreData     Old data from SecCore\r
                          NULL if being run in non-permament memory mode.\r
-  SecCoreData          - Points to a data structure containing information about the PEI core's operating\r
+  @param SecCoreData     Points to a data structure containing information about the PEI core's operating\r
                          environment, such as the size and location of temporary RAM, the stack location and\r
                          the BFV location.\r
 \r
-Returns:\r
-\r
-  None.\r
+  @return None.\r
 \r
---*/\r
+**/\r
+VOID\r
+InitializeDispatcherData (\r
+  IN PEI_CORE_INSTANCE            *PrivateData,\r
+  IN PEI_CORE_INSTANCE            *OldCoreData,\r
+  IN CONST EFI_SEC_PEI_HAND_OFF   *SecCoreData\r
+  )\r
 {\r
   if (OldCoreData == NULL) {\r
+    PrivateData->PeimDispatcherReenter = FALSE;\r
     PeiInitializeFv (PrivateData, SecCoreData);\r
   }\r
 \r
   return;\r
 }\r
 \r
+/**\r
+  This routine parses the Dependency Expression, if available, and\r
+  decides if the module can be executed.\r
 \r
+\r
+  @param Private         PeiCore's private data structure\r
+  @param FileHandle      PEIM's file handle\r
+  @param PeimCount       Peim count in all dispatched PEIMs.\r
+\r
+  @retval TRUE   Can be dispatched\r
+  @retval FALSE  Cannot be dispatched\r
+\r
+**/\r
 BOOLEAN\r
 DepexSatisfied (\r
   IN PEI_CORE_INSTANCE          *Private,\r
   IN EFI_PEI_FILE_HANDLE        FileHandle,\r
   IN UINTN                      PeimCount\r
   )\r
-/*++\r
-\r
-Routine Description:\r
-\r
-  This routine parses the Dependency Expression, if available, and\r
-  decides if the module can be executed.\r
-\r
-Arguments:\r
-  PeiServices - The PEI Service Table\r
-  CurrentPeimAddress - Address of the PEIM Firmware File under investigation\r
-\r
-Returns:\r
-  TRUE  - Can be dispatched\r
-  FALSE - Cannot be dispatched\r
-\r
---*/\r
 {\r
   EFI_STATUS           Status;\r
   VOID                 *DepexData;\r
@@ -771,11 +765,11 @@ Returns:
   This routine enable a PEIM to register itself to shadow when PEI Foundation\r
   discovery permanent memory.\r
 \r
-       @param FileHandle       File handle of a PEIM.\r
+  @param FileHandle             File handle of a PEIM.\r
 \r
-  @retval EFI_NOT_FOUND                                The file handle doesn't point to PEIM itself.\r
-  @retval EFI_ALREADY_STARTED          Indicate that the PEIM has been registered itself.\r
-  @retval EFI_SUCCESS                                          Successfully to register itself.\r
+  @retval EFI_NOT_FOUND         The file handle doesn't point to PEIM itself.\r
+  @retval EFI_ALREADY_STARTED   Indicate that the PEIM has been registered itself.\r
+  @retval EFI_SUCCESS           Successfully to register itself.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -806,120 +800,3 @@ PeiRegisterForShadow (
   return EFI_SUCCESS;\r
 }\r
 \r
-\r
-\r
-/**\r
-  Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
-\r
-       @param PeiServices          Pointer to the PEI Core Services Table.\r
-       @param FileHandle               File handle of a Fv type file.\r
-  @param AuthenticationState  Pointer to attestation authentication state of image.\r
-\r
-\r
-  @retval EFI_NOT_FOUND                                FV image can't be found.\r
-  @retval EFI_SUCCESS                                          Successfully to process it.\r
-\r
-**/\r
-EFI_STATUS\r
-ProcessFvFile (\r
-  IN  EFI_PEI_SERVICES      **PeiServices,\r
-  IN  EFI_PEI_FILE_HANDLE   FvFileHandle,\r
-  OUT UINT32                *AuthenticationState\r
-  )\r
-{\r
-  EFI_STATUS            Status;\r
-  EFI_PEI_FV_HANDLE     FvImageHandle;\r
-  EFI_FV_INFO           FvImageInfo;\r
-  UINT32                FvAlignment;\r
-  VOID                  *FvBuffer;\r
-  EFI_PEI_HOB_POINTERS  HobFv2;\r
-\r
-  FvBuffer             = NULL;\r
-  *AuthenticationState = 0;\r
-\r
-  //\r
-  // Check if this EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE file has already\r
-  // been extracted.\r
-  //\r
-  HobFv2.Raw = GetHobList ();\r
-  while ((HobFv2.Raw = GetNextHob (EFI_HOB_TYPE_FV2, HobFv2.Raw)) != NULL) {\r
-    if (CompareGuid (&(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name), &HobFv2.FirmwareVolume2->FileName)) {\r
-      //\r
-      // this FILE has been dispatched, it will not be dispatched again.\r
-      //\r
-      return EFI_SUCCESS;\r
-    }\r
-    HobFv2.Raw = GET_NEXT_HOB (HobFv2);\r
-  }\r
-\r
-  //\r
-  // Find FvImage in FvFile\r
-  //\r
-  Status = PeiFfsFindSectionData (\r
-             (CONST EFI_PEI_SERVICES **) PeiServices,\r
-             EFI_SECTION_FIRMWARE_VOLUME_IMAGE,\r
-             FvFileHandle,\r
-             (VOID **)&FvImageHandle\r
-             );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-  //\r
-  // Collect FvImage Info.\r
-  //\r
-  Status = PeiFfsGetVolumeInfo (FvImageHandle, &FvImageInfo);\r
-  ASSERT_EFI_ERROR (Status);\r
-  //\r
-  // FvAlignment must be more than 8 bytes required by FvHeader structure.\r
-  //\r
-  FvAlignment = 1 << ((FvImageInfo.FvAttributes & EFI_FVB2_ALIGNMENT) >> 16);\r
-  if (FvAlignment < 8) {\r
-    FvAlignment = 8;\r
-  }\r
-  //\r
-  // Check FvImage\r
-  //\r
-  if ((UINTN) FvImageInfo.FvStart % FvAlignment != 0) {\r
-    FvBuffer = AllocateAlignedPages (EFI_SIZE_TO_PAGES ((UINT32) FvImageInfo.FvSize), FvAlignment);\r
-    if (FvBuffer == NULL) {\r
-      return EFI_OUT_OF_RESOURCES;\r
-    }\r
-    CopyMem (FvBuffer, FvImageInfo.FvStart, (UINTN) FvImageInfo.FvSize);\r
-    //\r
-    // Update FvImageInfo after reload FvImage to new aligned memory\r
-    //\r
-    PeiFfsGetVolumeInfo ((EFI_PEI_FV_HANDLE) FvBuffer, &FvImageInfo);\r
-  }\r
-\r
-  //\r
-  // Install FvPpi and Build FvHob\r
-  //\r
-  PiLibInstallFvInfoPpi (\r
-    NULL,\r
-    FvImageInfo.FvStart,\r
-    (UINT32) FvImageInfo.FvSize,\r
-    &(FvImageInfo.FvName),\r
-    &(((EFI_FFS_FILE_HEADER*)FvFileHandle)->Name)\r
-    );\r
-\r
-  //\r
-  // Inform HOB consumer phase, i.e. DXE core, the existance of this FV\r
-  //\r
-  BuildFvHob (\r
-    (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,\r
-    FvImageInfo.FvSize\r
-  );\r
-  //\r
-  // Makes the encapsulated volume show up in DXE phase to skip processing of\r
-  // encapsulated file again.\r
-  //\r
-  BuildFv2Hob (\r
-    (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,\r
-    FvImageInfo.FvSize,\r
-    &FvImageInfo.FvName,\r
-    &(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name)\r
-    );\r
-\r
-  return EFI_SUCCESS;\r
-}\r