]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BasePeCoffLib/BasePeCoff.c
add the extra comments into BasePeCoffRelocateImage, BasePeCoffLoadImage and BasePeCo...
[mirror_edk2.git] / MdePkg / Library / BasePeCoffLib / BasePeCoff.c
index 3ecc015eaca271148efb1f85be6afeb2344a3950..d9359e98921b04fbf430ed748bfe4b97fe90bed6 100644 (file)
@@ -67,7 +67,7 @@ PeCoffLoaderGetPeHeader (
   UINT16                Magic;\r
 \r
   //\r
-  // Read the DOS image header to check for it's existance\r
+  // Read the DOS image header to check for its existence\r
   //\r
   Size = sizeof (EFI_IMAGE_DOS_HEADER);\r
   Status = ImageContext->ImageRead (\r
@@ -254,10 +254,11 @@ PeCoffLoaderGetImageInfo (
   ImageContext->DestinationAddress = 0;\r
 \r
   //\r
-  // Initialize the codeview pointer.\r
+  // Initialize the debug codeview pointer.\r
   //\r
-  ImageContext->CodeView    = NULL;\r
-  ImageContext->PdbPointer  = NULL;\r
+  ImageContext->DebugDirectoryEntryRva = 0;\r
+  ImageContext->CodeView               = NULL;\r
+  ImageContext->PdbPointer             = NULL;\r
 \r
   //\r
   // Three cases with regards to relocations:\r
@@ -494,6 +495,10 @@ PeCoffLoaderImageAddress (
     \r
   If ImageContext is NULL, then ASSERT().\r
 \r
+  Note that if the platform does not maintain coherency between the instruction cache(s) and the data\r
+  cache(s) in hardware, then the caller is responsible for performing cache maintenance operations\r
+  prior to transferring control to a PE/COFF image that is loaded using this library.\r
+\r
   @param  ImageContext        Pointer to the image context structure that describes the PE/COFF\r
                               image that is being relocated.\r
 \r
@@ -760,6 +765,10 @@ PeCoffLoaderRelocateImage (
   \r
   If ImageContext is NULL, then ASSERT().\r
 \r
+  Note that if the platform does not maintain coherency between the instruction cache(s) and the data\r
+  cache(s) in hardware, then the caller is responsible for performing cache maintenance operations\r
+  prior to transferring control to a PE/COFF image that is loaded using this library.\r
+\r
   @param  ImageContext              Pointer to the image context structure that describes the PE/COFF\r
                                     image that is being loaded.\r
 \r
@@ -1169,49 +1178,49 @@ PeCoffLoaderLoadImage (
 \r
     if (DirectoryEntry->Size != 0) {\r
       Base = PeCoffLoaderImageAddress (ImageContext, DirectoryEntry->VirtualAddress);\r
-\r
-      ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) Base;\r
-      ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);\r
-\r
-      for (Index = 0; Index < ResourceDirectory->NumberOfNamedEntries; Index++) {\r
-        if (ResourceDirectoryEntry->u1.s.NameIsString) {\r
-          ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (Base + ResourceDirectoryEntry->u1.s.NameOffset);\r
-\r
-          if (ResourceDirectoryString->Length == 3 &&\r
-              ResourceDirectoryString->String[0] == L'H' &&\r
-              ResourceDirectoryString->String[1] == L'I' &&\r
-              ResourceDirectoryString->String[2] == L'I') {\r
-            //\r
-            // Resource Type "HII" found\r
-            //\r
-            if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {\r
+      if (Base != NULL) {\r
+        ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) Base;\r
+        ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);\r
+\r
+        for (Index = 0; Index < ResourceDirectory->NumberOfNamedEntries; Index++) {\r
+          if (ResourceDirectoryEntry->u1.s.NameIsString) {\r
+            ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (Base + ResourceDirectoryEntry->u1.s.NameOffset);\r
+\r
+            if (ResourceDirectoryString->Length == 3 &&\r
+                ResourceDirectoryString->String[0] == L'H' &&\r
+                ResourceDirectoryString->String[1] == L'I' &&\r
+                ResourceDirectoryString->String[2] == L'I') {\r
               //\r
-              // Move to next level - resource Name\r
+              // Resource Type "HII" found\r
               //\r
-              ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);\r
-              ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);\r
-\r
               if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {\r
                 //\r
-                // Move to next level - resource Language\r
+                // Move to next level - resource Name\r
                 //\r
                 ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);\r
                 ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);\r
+\r
+                if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {\r
+                  //\r
+                  // Move to next level - resource Language\r
+                  //\r
+                  ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);\r
+                  ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);\r
+                }\r
               }\r
-            }\r
 \r
-            //\r
-            // Now it ought to be resource Data\r
-            //\r
-            if (!ResourceDirectoryEntry->u2.s.DataIsDirectory) {\r
-              ResourceDataEntry = (EFI_IMAGE_RESOURCE_DATA_ENTRY *) (Base + ResourceDirectoryEntry->u2.OffsetToData);\r
-              ImageContext->HiiResourceData = (PHYSICAL_ADDRESS) (UINTN) PeCoffLoaderImageAddress (ImageContext, ResourceDataEntry->OffsetToData);\r
-              break;\r
+              //\r
+              // Now it ought to be resource Data\r
+              //\r
+              if (!ResourceDirectoryEntry->u2.s.DataIsDirectory) {\r
+                ResourceDataEntry = (EFI_IMAGE_RESOURCE_DATA_ENTRY *) (Base + ResourceDirectoryEntry->u2.OffsetToData);\r
+                ImageContext->HiiResourceData = (PHYSICAL_ADDRESS) (UINTN) PeCoffLoaderImageAddress (ImageContext, ResourceDataEntry->OffsetToData);\r
+                break;\r
+              }\r
             }\r
           }\r
+          ResourceDirectoryEntry++;\r
         }\r
-\r
-        ResourceDirectoryEntry++;\r
       }\r
     }\r
   }\r
@@ -1230,6 +1239,10 @@ PeCoffLoaderLoadImage (
   to the FiuxupData buffer from the PE_COFF_LOADER_IMAGE_CONTEXT structure \r
   after this PE/COFF image was relocated with PeCoffLoaderRelocateImage().\r
 \r
+  Note that if the platform does not maintain coherency between the instruction cache(s) and the data\r
+  cache(s) in hardware, then the caller is responsible for performing cache maintenance operations\r
+  prior to transferring control to a PE/COFF image that is loaded using this library.\r
+\r
   @param  ImageBase          Base address of a PE/COFF image that has been loaded \r
                              and relocated into system memory.\r
   @param  VirtImageBase      The request virtual address that the PE/COFF image is to\r