#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
//\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
}\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
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