]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Dxe/Image/Image.h
Updates function description per UEFI2.3d. No impact is for functionality. The main...
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Image / Image.h
1 /** @file
2 Data structure and functions to load and unload PeImage.
3
4 Copyright (c) 2006 - 2011, 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
9
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.
12
13 **/
14
15
16 #ifndef _IMAGE_H_
17 #define _IMAGE_H_
18
19 #define LOADED_IMAGE_PRIVATE_DATA_SIGNATURE SIGNATURE_32('l','d','r','i')
20
21 typedef struct {
22 UINTN Signature;
23 /// Image handle
24 EFI_HANDLE Handle;
25 /// Image type
26 UINTN Type;
27 /// If entrypoint has been called
28 BOOLEAN Started;
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;
35 /// Number of pages
36 UINTN NumberOfPages;
37 /// Original fixup data
38 CHAR8 *FixupData;
39 /// Tpl of started image
40 EFI_TPL Tpl;
41 /// Status returned by started image
42 EFI_STATUS Status;
43 /// Size of ExitData from started image
44 UINTN ExitDataSize;
45 /// Pointer to exit data from started image
46 VOID *ExitData;
47 /// Pointer to pool allocation for context save/retore
48 VOID *JumpBuffer;
49 /// Pointer to buffer for context save/retore
50 BASE_LIBRARY_JUMP_BUFFER *JumpContext;
51 /// Machine type from PE image
52 UINT16 Machine;
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;
61
62 } LOADED_IMAGE_PRIVATE_DATA;
63
64 #define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \
65 CR(a, LOADED_IMAGE_PRIVATE_DATA, Info, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE)
66
67
68 #define LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE SIGNATURE_32('l','p','e','i')
69
70 typedef struct {
71 UINTN Signature;
72 /// Image handle
73 EFI_HANDLE Handle;
74 EFI_PE32_IMAGE_PROTOCOL Pe32Image;
75 } LOAD_PE32_IMAGE_PRIVATE_DATA;
76
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)
79
80
81 //
82 // Private Data Types
83 //
84 #define IMAGE_FILE_HANDLE_SIGNATURE SIGNATURE_32('i','m','g','f')
85 typedef struct {
86 UINTN Signature;
87 BOOLEAN FreeBuffer;
88 VOID *Source;
89 UINTN SourceSize;
90 } IMAGE_FILE_HANDLE;
91
92 /**
93 Loads an EFI image into memory and returns a handle to the image with extended parameters.
94
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
98 loaded.
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
109 PE image.
110
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
118 resources.
119 @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not
120 understood.
121 @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.
122 @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the
123 image from being loaded. NULL is returned in *ImageHandle.
124 @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a
125 valid EFI_LOADED_IMAGE_PROTOCOL. However, the current
126 platform policy specifies that the image should not be started.
127
128 **/
129 EFI_STATUS
130 EFIAPI
131 CoreLoadImageEx (
132 IN EFI_PE32_IMAGE_PROTOCOL *This,
133 IN EFI_HANDLE ParentImageHandle,
134 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
135 IN VOID *SourceBuffer OPTIONAL,
136 IN UINTN SourceSize,
137 IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL,
138 OUT UINTN *NumberOfPages OPTIONAL,
139 OUT EFI_HANDLE *ImageHandle,
140 OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,
141 IN UINT32 Attribute
142 );
143
144
145 /**
146 Unload the specified image.
147
148 @param This Indicates the calling context.
149 @param ImageHandle The specified image handle.
150
151 @retval EFI_INVALID_PARAMETER Image handle is NULL.
152 @retval EFI_UNSUPPORTED Attempt to unload an unsupported image.
153 @retval EFI_SUCCESS Image successfully unloaded.
154
155 **/
156 EFI_STATUS
157 EFIAPI
158 CoreUnloadImageEx (
159 IN EFI_PE32_IMAGE_PROTOCOL *This,
160 IN EFI_HANDLE ImageHandle
161 );
162 #endif