]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Use new API GetSectionFromAnyFvByFileType() of MdePkg DxeServicesLib library to...
authorlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 5 May 2010 01:58:36 +0000 (01:58 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 5 May 2010 01:58:36 +0000 (01:58 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10457 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/PiSmmCore/PiSmmIpl.c
MdeModulePkg/Core/PiSmmCore/PiSmmIpl.inf

index 6f84a855ad23e6e2e464320331bb5eac7cb74c5b..61ed062d27b5b8df5db7f018f84c0b5cde4c662a 100644 (file)
@@ -20,7 +20,6 @@
 #include <Protocol/SmmConfiguration.h>\r
 #include <Protocol/SmmControl2.h>\r
 #include <Protocol/DxeSmmReadyToLock.h>\r
-#include <Protocol/FirmwareVolume2.h>\r
 \r
 #include <Guid/EventGroup.h>\r
 #include <Guid/EventLegacyBios.h>\r
@@ -34,6 +33,7 @@
 #include <Library/DebugLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/DxeServicesTableLib.h>\r
+#include <Library/DxeServicesLib.h>\r
 #include <Library/UefiLib.h>\r
 #include <Library/UefiRuntimeLib.h>\r
 #include <Library/PcdLib.h>\r
@@ -683,81 +683,6 @@ SmmIplSetVirtualAddressNotify (
   EfiConvertPointer (0x0, (VOID **)&mSmmControl2);\r
 }\r
 \r
-/**\r
-  Searches all Firmware Volumes for the first file matching FileType and SectionType and returns the section data.\r
-\r
-  @param   FileType                FileType to search for within any of the firmware volumes in the platform.\r
-  @param   SectionType             SectionType to search for within any of the matching FileTypes in the firmware volumes in the platform.\r
-  @param   SourceSize              Return the size of the returned section data..\r
-\r
-  @retval  != NULL                 Pointer to the allocated buffer containing the section data.\r
-  @retval  NULL                    Section data was not found.\r
-\r
-**/\r
-VOID *\r
-GetSectionInAnyFv (\r
-  IN  EFI_FV_FILETYPE   FileType,\r
-  IN  EFI_SECTION_TYPE  SectionType,\r
-  OUT UINTN             *SourceSize\r
-  )\r
-{\r
-  EFI_STATUS                    Status;\r
-  UINTN                         HandleCount;\r
-  EFI_HANDLE                    *HandleBuffer;\r
-  UINTN                         Index;\r
-  EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
-  UINTN                         Key;\r
-  EFI_GUID                      NameGuid;\r
-  EFI_FV_FILE_ATTRIBUTES        Attributes;\r
-  VOID                          *SourceBuffer;\r
-  UINT32                        AuthenticationStatus;\r
-\r
-  HandleBuffer = NULL;\r
-  Status = gBS->LocateHandleBuffer (\r
-                  ByProtocol,\r
-                  &gEfiFirmwareVolume2ProtocolGuid,\r
-                  NULL,\r
-                  &HandleCount,\r
-                  &HandleBuffer\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return NULL;\r
-  }\r
-\r
-  for (Index = 0; Index < HandleCount; Index++) {\r
-    Status = gBS->HandleProtocol (\r
-                    HandleBuffer[Index],\r
-                    &gEfiFirmwareVolume2ProtocolGuid,\r
-                    (VOID **)&Fv\r
-                    );\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Use Firmware Volume 2 Protocol to search for a file of type FileType\r
-    //\r
-    Key = 0;   \r
-    Status = Fv->GetNextFile (Fv, &Key, &FileType, &NameGuid, &Attributes, SourceSize);\r
-    if (EFI_ERROR (Status)) {\r
-      continue;\r
-    }\r
-\r
-    //\r
-    // Use Firmware Volume 2 Protocol to read a section of type SectionType\r
-    //\r
-    SourceBuffer = NULL;\r
-    Status = Fv->ReadSection (Fv, &NameGuid, SectionType, 0, &SourceBuffer, SourceSize, &AuthenticationStatus);\r
-    if (!EFI_ERROR (Status)) {\r
-      FreePool (HandleBuffer);\r
-      return SourceBuffer;\r
-    }\r
-  }  \r
-\r
-  FreePool(HandleBuffer);\r
-  \r
-  return NULL;\r
-}\r
 /**\r
   Get the fixed loadding address from image header assigned by build tool. This function only be called\r
   when Loading module at Fixed address feature enabled.\r
@@ -880,9 +805,16 @@ ExecuteSmmCoreFromSmram (
   //\r
   // Search all Firmware Volumes for a PE/COFF image in a file of type SMM_CORE\r
   //  \r
-  SourceBuffer = GetSectionInAnyFv (EFI_FV_FILETYPE_SMM_CORE, EFI_SECTION_PE32, &SourceSize);\r
-  if (SourceBuffer == NULL) {\r
-    return EFI_NOT_FOUND;\r
+  Status = GetSectionFromAnyFvByFileType (\r
+             EFI_FV_FILETYPE_SMM_CORE, \r
+             0,\r
+             EFI_SECTION_PE32, \r
+             0,\r
+             &SourceBuffer, \r
+             &SourceSize\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
   }\r
   \r
   //\r
index a7e0c962d4ca810bfc84f93a6f73bf4b932b8537..8cbaf8d5d31cb45cb8cc10828131025fd9b88204 100644 (file)
@@ -47,6 +47,7 @@
   DxeServicesTableLib\r
   UefiLib\r
   UefiRuntimeLib\r
+  DxeServicesLib\r
   \r
 [Protocols]\r
   gEfiSmmBase2ProtocolGuid                      # PROTOCOL ALWAYS_PRODUCED\r
@@ -55,7 +56,6 @@
   gEfiSmmConfigurationProtocolGuid              # PROTOCOL ALWAYS_CONSUMED\r
   gEfiSmmControl2ProtocolGuid                   # PROTOCOL ALWAYS_CONSUMED\r
   gEfiDxeSmmReadyToLockProtocolGuid             # PROTOCOL ALWAYS_CONSUMED\r
-  gEfiFirmwareVolume2ProtocolGuid               # PROTOCOL ALWAYS_CONSUMED\r
   gEfiCpuArchProtocolGuid                       # PROTOCOL ALWAYS_CONSUMED\r
 \r
 [Guids]\r