]> git.proxmox.com Git - mirror_edk2.git/commitdiff
move ProcessFv() from dispatcher.c to FwVol.c
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 3 Sep 2008 07:26:40 +0000 (07:26 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 3 Sep 2008 07:26:40 +0000 (07:26 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5787 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Pei/Dispatcher/Dispatcher.c
MdeModulePkg/Core/Pei/FwVol/FwVol.c

index f050ca9fd6f26683d8bb4db9e85470194c46d8fd..5d9226fc7ec376d187ef2fdb00f32e2ad12ffe45 100644 (file)
@@ -804,135 +804,3 @@ PeiRegisterForShadow (
   return EFI_SUCCESS;\r
 }\r
 \r
-/**\r
-  Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
-\r
-  @param PeiServices          An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
-  @param FvFileHandle         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
-  @retval EFI_OUT_OF_RESOURCES  Can not allocate page when aligning FV image\r
-  @retval Others                Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section\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  HobPtr;\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
-  HobPtr.Raw = GetHobList ();\r
-  while ((HobPtr.Raw = GetNextHob (EFI_HOB_TYPE_FV2, HobPtr.Raw)) != NULL) {\r
-    if (CompareGuid (&(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name), &HobPtr.FirmwareVolume2->FileName)) {\r
-      //\r
-      // this FILE has been dispatched, it will not be dispatched again.\r
-      //\r
-      return EFI_SUCCESS;\r
-    }\r
-    HobPtr.Raw = GET_NEXT_HOB (HobPtr);\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
-  //\r
-  // Collect FvImage Info.\r
-  //\r
-  Status = PeiFfsGetVolumeInfo (FvImageHandle, &FvImageInfo);\r
-  ASSERT_EFI_ERROR (Status);\r
-  \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
-  //\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 the extracted FvImage to Fv HOB consumer phase, i.e. DXE phase\r
-  // based on its parent Fvimage is informed or not.\r
-  // If FvHob of its parent fvimage is built, the extracted FvImage will be built also. \r
-  // Or, the extracted FvImage will not be built.\r
-  //\r
-  HobPtr.Raw = GetHobList ();\r
-  while ((HobPtr.Raw = GetNextHob (EFI_HOB_TYPE_FV, HobPtr.Raw)) != NULL) {\r
-    if (((EFI_PHYSICAL_ADDRESS) (UINTN)FvFileHandle > HobPtr.FirmwareVolume->BaseAddress) && \r
-        ((EFI_PHYSICAL_ADDRESS) (UINTN)FvFileHandle < HobPtr.FirmwareVolume->BaseAddress + HobPtr.FirmwareVolume->Length)) {\r
-      BuildFvHob (\r
-        (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,\r
-        FvImageInfo.FvSize\r
-      );\r
-      break;\r
-    }\r
-    HobPtr.Raw = GET_NEXT_HOB (HobPtr);\r
-  }\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
index f2b5cedd361b0038db287f6b6fe8ad53cce376a2..884029f4385d52f63a1d4415db41949d35ca33f8 100644 (file)
@@ -821,3 +821,137 @@ PeiFfsGetVolumeInfo (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Get Fv image from the FV type file, then install FV INFO ppi, Build FV hob.\r
+\r
+  @param PeiServices          An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation.\r
+  @param FvFileHandle         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
+  @retval EFI_OUT_OF_RESOURCES  Can not allocate page when aligning FV image\r
+  @retval Others                Can not find EFI_SECTION_FIRMWARE_VOLUME_IMAGE section\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  HobPtr;\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
+  HobPtr.Raw = GetHobList ();\r
+  while ((HobPtr.Raw = GetNextHob (EFI_HOB_TYPE_FV2, HobPtr.Raw)) != NULL) {\r
+    if (CompareGuid (&(((EFI_FFS_FILE_HEADER *)FvFileHandle)->Name), &HobPtr.FirmwareVolume2->FileName)) {\r
+      //\r
+      // this FILE has been dispatched, it will not be dispatched again.\r
+      //\r
+      return EFI_SUCCESS;\r
+    }\r
+    HobPtr.Raw = GET_NEXT_HOB (HobPtr);\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
+  //\r
+  // Collect FvImage Info.\r
+  //\r
+  Status = PeiFfsGetVolumeInfo (FvImageHandle, &FvImageInfo);\r
+  ASSERT_EFI_ERROR (Status);\r
+  \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
+  //\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 the extracted FvImage to Fv HOB consumer phase, i.e. DXE phase\r
+  // based on its parent Fvimage is informed or not.\r
+  // If FvHob of its parent fvimage is built, the extracted FvImage will be built also. \r
+  // Or, the extracted FvImage will not be built.\r
+  //\r
+  HobPtr.Raw = GetHobList ();\r
+  while ((HobPtr.Raw = GetNextHob (EFI_HOB_TYPE_FV, HobPtr.Raw)) != NULL) {\r
+    if (((EFI_PHYSICAL_ADDRESS) (UINTN)FvFileHandle > HobPtr.FirmwareVolume->BaseAddress) && \r
+        ((EFI_PHYSICAL_ADDRESS) (UINTN)FvFileHandle < HobPtr.FirmwareVolume->BaseAddress + HobPtr.FirmwareVolume->Length)) {\r
+      BuildFvHob (\r
+        (EFI_PHYSICAL_ADDRESS) (UINTN) FvImageInfo.FvStart,\r
+        FvImageInfo.FvSize\r
+      );\r
+      break;\r
+    }\r
+    HobPtr.Raw = GET_NEXT_HOB (HobPtr);\r
+  }\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
+\r
+\r