2 Data structure and functions to load and unload PeImage.
4 Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #define LOADED_IMAGE_PRIVATE_DATA_SIGNATURE SIGNATURE_32('l','d','r','i')
27 /// If entrypoint has been called
29 /// The image's entry point
30 EFI_IMAGE_ENTRY_POINT EntryPoint
;
31 /// loaded image protocol
32 EFI_LOADED_IMAGE_PROTOCOL Info
;
33 /// Location in memory
34 EFI_PHYSICAL_ADDRESS ImageBasePage
;
37 /// Original fixup data
39 /// Tpl of started image
41 /// Status returned by started image
43 /// Size of ExitData from started image
45 /// Pointer to exit data from started image
47 /// Pointer to pool allocation for context save/retore
49 /// Pointer to buffer for context save/retore
50 BASE_LIBRARY_JUMP_BUFFER
*JumpContext
;
51 /// Machine type from PE image
53 /// EBC Protocol pointer
54 EFI_EBC_PROTOCOL
*Ebc
;
55 /// Runtime image list
56 EFI_RUNTIME_IMAGE_ENTRY
*RuntimeData
;
57 /// Pointer to Loaded Image Device Path Protocl
58 EFI_DEVICE_PATH_PROTOCOL
*LoadedImageDevicePath
;
59 /// PeCoffLoader ImageContext
60 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext
;
62 } LOADED_IMAGE_PRIVATE_DATA
;
64 #define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \
65 CR(a, LOADED_IMAGE_PRIVATE_DATA, Info, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE)
68 #define LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE SIGNATURE_32('l','p','e','i')
74 EFI_PE32_IMAGE_PROTOCOL Pe32Image
;
75 } LOAD_PE32_IMAGE_PRIVATE_DATA
;
77 #define LOAD_PE32_IMAGE_PRIVATE_DATA_FROM_THIS(a) \
78 CR(a, LOAD_PE32_IMAGE_PRIVATE_DATA, Pe32Image, LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE)
84 #define IMAGE_FILE_HANDLE_SIGNATURE SIGNATURE_32('i','m','g','f')
93 Loads an EFI image into memory and returns a handle to the image with extended parameters.
95 @param This Calling context
96 @param ParentImageHandle The caller's image handle.
97 @param FilePath The specific file path from which the image is
99 @param SourceBuffer If not NULL, a pointer to the memory location
100 containing a copy of the image to be loaded.
101 @param SourceSize The size in bytes of SourceBuffer.
102 @param DstBuffer The buffer to store the image.
103 @param NumberOfPages For input, specifies the space size of the
104 image by caller if not NULL. For output,
105 specifies the actual space size needed.
106 @param ImageHandle Image handle for output.
107 @param EntryPoint Image entry point for output.
108 @param Attribute The bit mask of attributes to set for the load
111 @retval EFI_SUCCESS The image was loaded into memory.
112 @retval EFI_NOT_FOUND The FilePath was not found.
113 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
114 @retval EFI_UNSUPPORTED The image type is not supported, or the device
115 path cannot be parsed to locate the proper
116 protocol for loading the file.
117 @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
124 IN EFI_PE32_IMAGE_PROTOCOL
*This
,
125 IN EFI_HANDLE ParentImageHandle
,
126 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
127 IN VOID
*SourceBuffer OPTIONAL
,
129 IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL
,
130 OUT UINTN
*NumberOfPages OPTIONAL
,
131 OUT EFI_HANDLE
*ImageHandle
,
132 OUT EFI_PHYSICAL_ADDRESS
*EntryPoint OPTIONAL
,
138 Unload the specified image.
140 @param This Indicates the calling context.
141 @param ImageHandle The specified image handle.
143 @retval EFI_INVALID_PARAMETER Image handle is NULL.
144 @retval EFI_UNSUPPORTED Attempt to unload an unsupported image.
145 @retval EFI_SUCCESS Image successfully unloaded.
151 IN EFI_PE32_IMAGE_PROTOCOL
*This
,
152 IN EFI_HANDLE ImageHandle