]> git.proxmox.com Git - mirror_edk2.git/commitdiff
retain gEfiLoadPeImageProtocolGuid, and only published by DxeCore to keep backward...
authoreric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 17 Apr 2009 04:47:55 +0000 (04:47 +0000)
committereric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 17 Apr 2009 04:47:55 +0000 (04:47 +0000)
Native EDKII module should not use such protocol to load image

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8110 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Core/Dxe/DxeMain.h
MdeModulePkg/Core/Dxe/DxeMain.inf
MdeModulePkg/Core/Dxe/Image/Image.c
MdeModulePkg/Core/Dxe/Image/Image.h
MdeModulePkg/Include/Protocol/LoadPe32Image.h [new file with mode: 0644]
MdeModulePkg/MdeModulePkg.dec

index 865cece9bbdda3f855a3ce7c5a32c4bb90c0da1b..d499ab48500dfd04f1a81a21b1d9a295e1beb373 100644 (file)
@@ -39,6 +39,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/MonotonicCounter.h>\r
 #include <Protocol/StatusCode.h>\r
 #include <Protocol/Decompress.h>\r
+#include <Protocol/LoadPe32Image.h>\r
 #include <Protocol/Security.h>\r
 #include <Protocol/Ebc.h>\r
 #include <Protocol/Reset.h>\r
index 9819d435437805e073f24f20712b7133b60d706e..9baef70b7e1e2c570f2b4ca5e372832253c78c4d 100644 (file)
   gEfiStatusCodeRuntimeProtocolGuid             ## SOMETIMES_CONSUMES\r
   gEfiCapsuleArchProtocolGuid                   ## CONSUMES\r
   gEfiDecompressProtocolGuid                    ## CONSUMES\r
+  gEfiLoadPeImageProtocolGuid                   ## PRODUCES\r
   gEfiSimpleFileSystemProtocolGuid              ## CONSUMES\r
   gEfiLoadFileProtocolGuid                      ## CONSUMES\r
   gEfiLoadFile2ProtocolGuid                     ## CONSUMES\r
index aae9acbe4e30947744602bb89278296ec3456dd5..5502c7ab189261f038384e6a9c8072ad2b35ea5e 100644 (file)
@@ -15,15 +15,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include "DxeMain.h"\r
 #include "Image.h"\r
 \r
-#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_NONE                                 0x00\r
-#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_RUNTIME_REGISTRATION                 0x01\r
-#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_DEBUG_IMAGE_INFO_TABLE_REGISTRATION  0x02\r
-\r
 //\r
 // Module Globals\r
 //\r
 LOADED_IMAGE_PRIVATE_DATA  *mCurrentImage = NULL;\r
 \r
+LOAD_PE32_IMAGE_PRIVATE_DATA  mLoadPe32PrivateData = {\r
+  LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE,\r
+  NULL,\r
+  {\r
+    CoreLoadImageEx,\r
+    CoreUnloadImageEx\r
+  }\r
+};\r
+\r
 \r
 //\r
 // This code is needed to build the Image handle for the DXE Core\r
@@ -142,7 +147,12 @@ CoreInitializeImageServices (
   //\r
   // Export DXE Core PE Loader functionality\r
   //\r
-  return EFI_SUCCESS;\r
+  return CoreInstallProtocolInterface (\r
+           &mLoadPe32PrivateData.Handle,\r
+           &gEfiLoadPeImageProtocolGuid,\r
+           EFI_NATIVE_INTERFACE,\r
+           &mLoadPe32PrivateData.Pe32Image\r
+           );\r
 }\r
 \r
 \r
@@ -990,6 +1000,66 @@ CoreLoadImage (
 }\r
 \r
 \r
+\r
+/**\r
+  Loads an EFI image into memory and returns a handle to the image with extended parameters.\r
+\r
+  @param  This                    Calling context\r
+  @param  ParentImageHandle       The caller's image handle.\r
+  @param  FilePath                The specific file path from which the image is\r
+                                  loaded.\r
+  @param  SourceBuffer            If not NULL, a pointer to the memory location\r
+                                  containing a copy of the image to be loaded.\r
+  @param  SourceSize              The size in bytes of SourceBuffer.\r
+  @param  DstBuffer               The buffer to store the image.\r
+  @param  NumberOfPages           For input, specifies the space size of the\r
+                                  image by caller if not NULL. For output,\r
+                                  specifies the actual space size needed.\r
+  @param  ImageHandle             Image handle for output.\r
+  @param  EntryPoint              Image entry point for output.\r
+  @param  Attribute               The bit mask of attributes to set for the load\r
+                                  PE image.\r
+\r
+  @retval EFI_SUCCESS             The image was loaded into memory.\r
+  @retval EFI_NOT_FOUND           The FilePath was not found.\r
+  @retval EFI_INVALID_PARAMETER   One of the parameters has an invalid value.\r
+  @retval EFI_UNSUPPORTED         The image type is not supported, or the device\r
+                                  path cannot be parsed to locate the proper\r
+                                  protocol for loading the file.\r
+  @retval EFI_OUT_OF_RESOURCES    Image was not loaded due to insufficient\r
+                                  resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CoreLoadImageEx (\r
+  IN  EFI_PE32_IMAGE_PROTOCOL          *This,\r
+  IN  EFI_HANDLE                       ParentImageHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL         *FilePath,\r
+  IN  VOID                             *SourceBuffer       OPTIONAL,\r
+  IN  UINTN                            SourceSize,\r
+  IN  EFI_PHYSICAL_ADDRESS             DstBuffer           OPTIONAL,\r
+  OUT UINTN                            *NumberOfPages      OPTIONAL,\r
+  OUT EFI_HANDLE                       *ImageHandle,\r
+  OUT EFI_PHYSICAL_ADDRESS             *EntryPoint         OPTIONAL,\r
+  IN  UINT32                           Attribute\r
+  )\r
+{\r
+  return CoreLoadImageCommon (\r
+           TRUE,\r
+           ParentImageHandle,\r
+           FilePath,\r
+           SourceBuffer,\r
+           SourceSize,\r
+           DstBuffer,\r
+           NumberOfPages,\r
+           ImageHandle,\r
+           EntryPoint,\r
+           Attribute\r
+           );\r
+}\r
+\r
+\r
 /**\r
   Transfer control to a loaded image's entry point.\r
 \r
@@ -1310,3 +1380,25 @@ Done:
   return Status;\r
 }\r
 \r
+\r
+\r
+/**\r
+  Unload the specified image.\r
+\r
+  @param  This                    Indicates the calling context.\r
+  @param  ImageHandle             The specified image handle.\r
+\r
+  @retval EFI_INVALID_PARAMETER   Image handle is NULL.\r
+  @retval EFI_UNSUPPORTED         Attempt to unload an unsupported image.\r
+  @retval EFI_SUCCESS             Image successfully unloaded.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CoreUnloadImageEx (\r
+  IN EFI_PE32_IMAGE_PROTOCOL  *This,\r
+  IN EFI_HANDLE                         ImageHandle\r
+  )\r
+{\r
+  return CoreUnloadImage (ImageHandle);\r
+}\r
index 1f6d68ce83f7c05c6239d02a22560e7ec893987d..54f71c3820364c90e50f66d4d79aa3a70481ef1b 100644 (file)
@@ -65,6 +65,19 @@ typedef struct {
           CR(a, LOADED_IMAGE_PRIVATE_DATA, Info, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE)\r
 \r
 \r
+#define LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE  SIGNATURE_32('l','p','e','i')\r
+\r
+typedef struct {\r
+    UINTN                       Signature;\r
+       /// Image handle\r
+    EFI_HANDLE                  Handle;         \r
+    EFI_PE32_IMAGE_PROTOCOL     Pe32Image;\r
+} LOAD_PE32_IMAGE_PRIVATE_DATA;\r
+\r
+#define LOAD_PE32_IMAGE_PRIVATE_DATA_FROM_THIS(a) \\r
+          CR(a, LOAD_PE32_IMAGE_PRIVATE_DATA, Pe32Image, LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE)\r
+\r
+\r
 //\r
 // Private Data Types\r
 //\r
@@ -137,5 +150,66 @@ CoreReadImageFile (
   );\r
 \r
 \r
+/**\r
+  Loads an EFI image into memory and returns a handle to the image with extended parameters.\r
+\r
+  @param  This                    Calling context\r
+  @param  ParentImageHandle       The caller's image handle.\r
+  @param  FilePath                The specific file path from which the image is\r
+                                  loaded.\r
+  @param  SourceBuffer            If not NULL, a pointer to the memory location\r
+                                  containing a copy of the image to be loaded.\r
+  @param  SourceSize              The size in bytes of SourceBuffer.\r
+  @param  DstBuffer               The buffer to store the image.\r
+  @param  NumberOfPages           For input, specifies the space size of the\r
+                                  image by caller if not NULL. For output,\r
+                                  specifies the actual space size needed.\r
+  @param  ImageHandle             Image handle for output.\r
+  @param  EntryPoint              Image entry point for output.\r
+  @param  Attribute               The bit mask of attributes to set for the load\r
+                                  PE image.\r
+\r
+  @retval EFI_SUCCESS             The image was loaded into memory.\r
+  @retval EFI_NOT_FOUND           The FilePath was not found.\r
+  @retval EFI_INVALID_PARAMETER   One of the parameters has an invalid value.\r
+  @retval EFI_UNSUPPORTED         The image type is not supported, or the device\r
+                                  path cannot be parsed to locate the proper\r
+                                  protocol for loading the file.\r
+  @retval EFI_OUT_OF_RESOURCES    Image was not loaded due to insufficient\r
+                                  resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CoreLoadImageEx (\r
+  IN  EFI_PE32_IMAGE_PROTOCOL          *This,\r
+  IN  EFI_HANDLE                       ParentImageHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL         *FilePath,\r
+  IN  VOID                             *SourceBuffer       OPTIONAL,\r
+  IN  UINTN                            SourceSize,\r
+  IN  EFI_PHYSICAL_ADDRESS             DstBuffer           OPTIONAL,\r
+  OUT UINTN                            *NumberOfPages      OPTIONAL,\r
+  OUT EFI_HANDLE                       *ImageHandle,\r
+  OUT EFI_PHYSICAL_ADDRESS             *EntryPoint         OPTIONAL,\r
+  IN  UINT32                           Attribute\r
+  );\r
+\r
+\r
+/**\r
+  Unload the specified image.\r
+\r
+  @param  This                    Indicates the calling context.\r
+  @param  ImageHandle             The specified image handle.\r
 \r
+  @retval EFI_INVALID_PARAMETER   Image handle is NULL.\r
+  @retval EFI_UNSUPPORTED         Attempt to unload an unsupported image.\r
+  @retval EFI_SUCCESS             Image successfully unloaded.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CoreUnloadImageEx (\r
+  IN EFI_PE32_IMAGE_PROTOCOL  *This,\r
+  IN EFI_HANDLE                         ImageHandle\r
+  );\r
 #endif\r
diff --git a/MdeModulePkg/Include/Protocol/LoadPe32Image.h b/MdeModulePkg/Include/Protocol/LoadPe32Image.h
new file mode 100644 (file)
index 0000000..b290e14
--- /dev/null
@@ -0,0 +1,95 @@
+/** @file\r
+\r
+  Load Pe32 Image protocol provides capability to load and unload EFI image into memory and execute it.\r
+  This protocol bases on File Device Path to get EFI image.\r
+\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
+http://opensource.org/licenses/bsd-license.php\r
+\r
+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
+**/\r
+\r
+#ifndef __LOAD_PE32_IMAGE_H__\r
+#define __LOAD_PE32_IMAGE_H__\r
+\r
+#define PE32_IMAGE_PROTOCOL_GUID  \\r
+  {0x5cb5c776,0x60d5,0x45ee,{0x88,0x3c,0x45,0x27,0x8,0xcd,0x74,0x3f }}\r
+\r
+#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_NONE                                 0x00\r
+#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_RUNTIME_REGISTRATION                 0x01\r
+#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_DEBUG_IMAGE_INFO_TABLE_REGISTRATION  0x02\r
+\r
+typedef struct _EFI_PE32_IMAGE_PROTOCOL   EFI_PE32_IMAGE_PROTOCOL;\r
+\r
+/**\r
+\r
+  Loads an EFI image into memory and returns a handle to the image with extended parameters.\r
+\r
+  @param  This                Pointer to the LoadPe32Image protocol instance\r
+  @param  ParentImageHandle   The caller's image handle.\r
+  @param  FilePath            The specific file path from which the image is loaded.\r
+  @param  SourceBuffer        If not NULL, a pointer to the memory location containing a copy of\r
+                              the image to be loaded.\r
+  @param  SourceSize          The size in bytes of SourceBuffer.\r
+  @param  DstBuffer           The buffer to store the image.\r
+  @param  NumberOfPages       For input, specifies the space size of the image by caller if not NULL.\r
+                              For output, specifies the actual space size needed.\r
+  @param  ImageHandle         Image handle for output.\r
+  @param  EntryPoint          Image entry point for output.\r
+  @param  Attribute           The bit mask of attributes to set for the load PE image.\r
+\r
+  @retval EFI_SUCCESS           The image was loaded into memory.\r
+  @retval EFI_NOT_FOUND         The FilePath was not found.\r
+  @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
+  @retval EFI_UNSUPPORTED       The image type is not supported, or the device path cannot be\r
+                                parsed to locate the proper protocol for loading the file.\r
+  @retval EFI_OUT_OF_RESOURCES  Image was not loaded due to insufficient memory resources.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *LOAD_PE_IMAGE)(\r
+  IN EFI_PE32_IMAGE_PROTOCOL           *This,\r
+  IN  EFI_HANDLE                       ParentImageHandle,\r
+  IN  EFI_DEVICE_PATH_PROTOCOL         *FilePath,\r
+  IN  VOID                             *SourceBuffer       OPTIONAL,\r
+  IN  UINTN                            SourceSize,\r
+  IN  EFI_PHYSICAL_ADDRESS             DstBuffer           OPTIONAL,\r
+  OUT UINTN                            *NumberOfPages      OPTIONAL,\r
+  OUT EFI_HANDLE                       *ImageHandle,\r
+  OUT EFI_PHYSICAL_ADDRESS             *EntryPoint         OPTIONAL,\r
+  IN  UINT32                           Attribute\r
+  );\r
+\r
+/**\r
+\r
+  Unload the specified image.\r
+\r
+  @param  This             Pointer to the LoadPe32Image protocol instance\r
+  @param  ImageHandle      The specified image handle to be unloaded.\r
+\r
+  @retval EFI_INVALID_PARAMETER Image handle is NULL.\r
+  @retval EFI_UNSUPPORTED       Attempt to unload an unsupported image.\r
+  @retval EFI_SUCCESS           Image is successfully unloaded.\r
+\r
+--*/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *UNLOAD_PE_IMAGE)(\r
+  IN EFI_PE32_IMAGE_PROTOCOL          *This,\r
+  IN EFI_HANDLE                       ImageHandle\r
+  );\r
+\r
+struct _EFI_PE32_IMAGE_PROTOCOL {\r
+  LOAD_PE_IMAGE     LoadPeImage;\r
+  UNLOAD_PE_IMAGE   UnLoadPeImage;\r
+};\r
+\r
+extern EFI_GUID gEfiLoadPeImageProtocolGuid;\r
+\r
+#endif\r
+\r
index a6d223d1d361902acbf7bd87433fc25afb17b696..af613b5e89258fee563c0e7a7059b63b00c5be02 100644 (file)
   gEfiCrc32GuidedSectionExtractionGuid = { 0xFC1BCDB0, 0x7D31, 0x49aa, {0x93, 0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 } }\r
 \r
 [Protocols.common] \r
+  ## Load File protocol provides capability to load and unload EFI image into memory and execute it.\r
+  ## Include/Protocol/LoadPe32Image.h\r
+  ## This protocol is deprecated. Native EDKII module should NOT use this protocol to load/unload image.\r
+  ## If developer need implement such functionality, they should use BasePeCoffLib.\r
+  gEfiLoadPeImageProtocolGuid    = { 0x5CB5C776, 0x60D5, 0x45EE, { 0x88, 0x3C, 0x45, 0x27, 0x08, 0xCD, 0x74, 0x3F }}\r
+  \r
   ## Print protocol defines six basic print functions to print the format unicode and ascii string.\r
   ## Include/Protocol/Print2.h\r
   gEfiPrint2ProtocolGuid          = { 0x5bcc3dbc, 0x8c57, 0x450a, { 0xbb, 0x0c, 0xa1, 0xc0, 0xbd, 0xde, 0x48, 0x0c }}\r