]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Pei/Image/Image.c
Patch to remove STATIC modifier. This is on longer recommended by EFI Framework codin...
[mirror_edk2.git] / MdeModulePkg / Core / Pei / Image / Image.c
index 88633e2729e1af21a05c8275254a8f3967773206..23f26d3813e2b01c6d5ec72c43dc5addccbf73cd 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Pei Core Load Image Support\r
   \r
-Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+Copyright (c) 2006 - 2008, 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
 which accompanies this distribution.  The full text of the license may be found at        \r
@@ -14,32 +14,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <PeiMain.h>\r
 \r
-/**\r
-  Routine for loading file image.\r
-\r
-  @param PeiServices      The PEI core services table.\r
-  @param FileHandle       Pointer to the FFS file header of the image.\r
-  @param ImageAddressArg  Pointer to PE/TE image.\r
-  @param ImageSizeArg     Size of PE/TE image.\r
-  @param EntryPoint       Pointer to entry point of specified image file for output.\r
-  @param AuthenticationState - Pointer to attestation authentication state of image.\r
-\r
-  @retval EFI_SUCCESS    - Image is successfully loaded.\r
-  @retval EFI_NOT_FOUND  - Fail to locate necessary PPI\r
-  @retval Others         - Fail to load file.\r
-\r
-**/\r
-EFI_STATUS\r
-PeiLoadImageLoadImage (\r
-  IN     EFI_PEI_SERVICES             **PeiServices,\r
-  IN     EFI_PEI_FILE_HANDLE          FileHandle,\r
-  OUT    EFI_PHYSICAL_ADDRESS         *ImageAddressArg,  OPTIONAL\r
-  OUT    UINT64                       *ImageSizeArg,     OPTIONAL\r
-  OUT    EFI_PHYSICAL_ADDRESS         *EntryPoint,\r
-  OUT    UINT32                       *AuthenticationState\r
-  )\r
-;\r
-\r
 /**\r
   The wrapper function of PeiLoadImageLoadImage().\r
 \r
@@ -62,15 +36,14 @@ PeiLoadImageLoadImageWrapper (
   OUT    UINT64                       *ImageSizeArg,     OPTIONAL\r
   OUT    EFI_PHYSICAL_ADDRESS         *EntryPoint,\r
   OUT    UINT32                       *AuthenticationState\r
-  )\r
-;\r
+  );\r
 \r
-STATIC EFI_PEI_LOAD_FILE_PPI   mPeiLoadImagePpi = {\r
+EFI_PEI_LOAD_FILE_PPI   mPeiLoadImagePpi = {\r
   PeiLoadImageLoadImageWrapper\r
 };\r
 \r
 \r
-STATIC EFI_PEI_PPI_DESCRIPTOR     gPpiLoadFilePpiList = {\r
+EFI_PEI_PPI_DESCRIPTOR     gPpiLoadFilePpiList = {\r
   (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
   &gEfiPeiLoadFilePpiGuid,\r
   &mPeiLoadImagePpi\r
@@ -94,7 +67,7 @@ EFIAPI
 PeiImageRead (\r
   IN     VOID    *FileHandle,\r
   IN     UINTN   FileOffset,\r
-  IN OUT UINTN   *ReadSize,\r
+  IN     UINTN   *ReadSize,\r
   OUT    VOID    *Buffer\r
   )\r
 {\r
@@ -105,7 +78,7 @@ PeiImageRead (
   Destination8  = Buffer;\r
   Source8       = (CHAR8 *) ((UINTN) FileHandle + FileOffset);\r
   Length        = *ReadSize;\r
-  while (Length--) {\r
+  while ((Length--) > 0) {\r
     *(Destination8++) = *(Source8++);\r
   }\r
 \r
@@ -114,7 +87,7 @@ PeiImageRead (
 \r
 /**\r
 \r
-  Support routine to return the Image Read.\r
+  Support routine to get the Image read file function.\r
 \r
   @param ImageContext    - The context of the image being loaded\r
 \r
@@ -150,6 +123,7 @@ GetImageReadFunction (
 \r
   @retval EFI_SUCCESS           The file was loaded and relocated\r
   @retval EFI_OUT_OF_RESOURCES  There was not enough memory to load and relocate the PE/COFF file\r
+  @retval EFI_INVALID_PARAMETER The image withou .reloc section can't be relocated.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -223,23 +197,25 @@ LoadAndRelocatePeCoffImage (
 }\r
 \r
 /**\r
-  Routine for loading file image.\r
+  Loads a PEIM into memory for subsequent execution. If there are compressed \r
+  images or images that need to be relocated into memory for performance reasons, \r
+  this service performs that transformation.\r
 \r
-  @param PeiServices      The PEI core services table.\r
+  @param PeiServices      An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
   @param FileHandle       Pointer to the FFS file header of the image.\r
   @param ImageAddressArg  Pointer to PE/TE image.\r
   @param ImageSizeArg     Size of PE/TE image.\r
   @param EntryPoint       Pointer to entry point of specified image file for output.\r
   @param AuthenticationState - Pointer to attestation authentication state of image.\r
 \r
-  @retval EFI_SUCCESS    - Image is successfully loaded.\r
-  @retval EFI_NOT_FOUND  - Fail to locate necessary PPI\r
-  @retval Others         - Fail to load file.\r
+  @retval EFI_SUCCESS      Image is successfully loaded.\r
+  @retval EFI_NOT_FOUND    Fail to locate necessary PPI.\r
+  @retval EFI_UNSUPPORTED  Image Machine Type is not supported.\r
 \r
 **/\r
 EFI_STATUS\r
 PeiLoadImageLoadImage (\r
-  IN     EFI_PEI_SERVICES             **PeiServices,\r
+  IN     CONST EFI_PEI_SERVICES       **PeiServices,\r
   IN     EFI_PEI_FILE_HANDLE          FileHandle,\r
   OUT    EFI_PHYSICAL_ADDRESS         *ImageAddressArg,  OPTIONAL\r
   OUT    UINT64                       *ImageSizeArg,     OPTIONAL\r
@@ -428,11 +404,11 @@ PeiLoadImageLoadImageWrapper (
 }\r
 \r
 /**\r
+  Routine to load image file for subsequent execution by LoadFile Ppi.\r
+  If any LoadFile Ppi is not found, the build-in support function for the PE32+/TE \r
+  XIP image format is used.\r
 \r
-  Routine for load image file.\r
-\r
-\r
-  @param PeiServices     - The PEI core services table.\r
+  @param PeiServices     - An indirect pointer to the EFI_PEI_SERVICES table published by the PEI Foundation\r
   @param FileHandle      - Pointer to the FFS file header of the image.\r
   @param EntryPoint      - Pointer to entry point of specified image file for output.\r
   @param AuthenticationState - Pointer to attestation authentication state of image.\r
@@ -444,7 +420,7 @@ PeiLoadImageLoadImageWrapper (
 **/\r
 EFI_STATUS\r
 PeiLoadImage (\r
-  IN     EFI_PEI_SERVICES             **PeiServices,\r
+  IN     CONST EFI_PEI_SERVICES       **PeiServices,\r
   IN     EFI_PEI_FILE_HANDLE          FileHandle,\r
   OUT    EFI_PHYSICAL_ADDRESS         *EntryPoint,\r
   OUT    UINT32                       *AuthenticationState\r