]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/Dxe/Image/Image.h
Add PI1.2.1 SAP2 support and UEFI231B mantis 896
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Image / Image.h
CommitLineData
23c98c94 1/** @file\r
504214c4 2 Data structure and functions to load and unload PeImage.\r
23c98c94 3\r
b695e7ff 4Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>\r
cd5ebaa0 5This program and the accompanying materials\r
28a00297 6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
504214c4 13**/\r
28a00297 14\r
15\r
16#ifndef _IMAGE_H_\r
17#define _IMAGE_H_\r
18\r
f3f2e05d 19#define LOADED_IMAGE_PRIVATE_DATA_SIGNATURE SIGNATURE_32('l','d','r','i')\r
28a00297 20\r
21typedef struct {\r
853adefc 22 UINTN Signature;\r
23 /// Image handle\r
24 EFI_HANDLE Handle; \r
25 /// Image type\r
26 UINTN Type; \r
27 /// If entrypoint has been called\r
28 BOOLEAN Started; \r
29 /// The image's entry point\r
30 EFI_IMAGE_ENTRY_POINT EntryPoint; \r
31 /// loaded image protocol\r
32 EFI_LOADED_IMAGE_PROTOCOL Info; \r
33 /// Location in memory\r
34 EFI_PHYSICAL_ADDRESS ImageBasePage; \r
35 /// Number of pages\r
36 UINTN NumberOfPages; \r
37 /// Original fixup data\r
38 CHAR8 *FixupData; \r
39 /// Tpl of started image\r
40 EFI_TPL Tpl; \r
41 /// Status returned by started image\r
42 EFI_STATUS Status; \r
43 /// Size of ExitData from started image\r
44 UINTN ExitDataSize; \r
45 /// Pointer to exit data from started image\r
46 VOID *ExitData; \r
47 /// Pointer to pool allocation for context save/retore\r
48 VOID *JumpBuffer; \r
49 /// Pointer to buffer for context save/retore\r
50 BASE_LIBRARY_JUMP_BUFFER *JumpContext; \r
51 /// Machine type from PE image\r
52 UINT16 Machine; \r
53 /// EBC Protocol pointer\r
54 EFI_EBC_PROTOCOL *Ebc; \r
55 /// Runtime image list\r
56 EFI_RUNTIME_IMAGE_ENTRY *RuntimeData; \r
57 /// Pointer to Loaded Image Device Path Protocl\r
58 EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath; \r
59 /// PeCoffLoader ImageContext\r
60 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; \r
bc2dfdbc
LG
61 /// Status returned by LoadImage() service.\r
62 EFI_STATUS LoadImageStatus;\r
28a00297 63} LOADED_IMAGE_PRIVATE_DATA;\r
64\r
65#define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \\r
66 CR(a, LOADED_IMAGE_PRIVATE_DATA, Info, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE)\r
67\r
68\r
023c0fec 69#define LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE SIGNATURE_32('l','p','e','i')\r
70\r
71typedef struct {\r
853adefc 72 UINTN Signature;\r
73 /// Image handle\r
74 EFI_HANDLE Handle; \r
75 EFI_PE32_IMAGE_PROTOCOL Pe32Image;\r
023c0fec 76} LOAD_PE32_IMAGE_PRIVATE_DATA;\r
77\r
78#define LOAD_PE32_IMAGE_PRIVATE_DATA_FROM_THIS(a) \\r
79 CR(a, LOAD_PE32_IMAGE_PRIVATE_DATA, Pe32Image, LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE)\r
80\r
81\r
28a00297 82//\r
83// Private Data Types\r
84//\r
f3f2e05d 85#define IMAGE_FILE_HANDLE_SIGNATURE SIGNATURE_32('i','m','g','f')\r
28a00297 86typedef struct {\r
87 UINTN Signature;\r
88 BOOLEAN FreeBuffer;\r
89 VOID *Source;\r
90 UINTN SourceSize;\r
91} IMAGE_FILE_HANDLE;\r
92\r
023c0fec 93/**\r
94 Loads an EFI image into memory and returns a handle to the image with extended parameters.\r
95\r
96 @param This Calling context\r
97 @param ParentImageHandle The caller's image handle.\r
98 @param FilePath The specific file path from which the image is\r
99 loaded.\r
100 @param SourceBuffer If not NULL, a pointer to the memory location\r
101 containing a copy of the image to be loaded.\r
102 @param SourceSize The size in bytes of SourceBuffer.\r
103 @param DstBuffer The buffer to store the image.\r
104 @param NumberOfPages For input, specifies the space size of the\r
105 image by caller if not NULL. For output,\r
106 specifies the actual space size needed.\r
107 @param ImageHandle Image handle for output.\r
108 @param EntryPoint Image entry point for output.\r
109 @param Attribute The bit mask of attributes to set for the load\r
110 PE image.\r
111\r
112 @retval EFI_SUCCESS The image was loaded into memory.\r
113 @retval EFI_NOT_FOUND The FilePath was not found.\r
114 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
115 @retval EFI_UNSUPPORTED The image type is not supported, or the device\r
116 path cannot be parsed to locate the proper\r
117 protocol for loading the file.\r
118 @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient\r
119 resources.\r
b695e7ff
LG
120 @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not\r
121 understood.\r
122 @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.\r
123 @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the \r
124 image from being loaded. NULL is returned in *ImageHandle.\r
125 @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a \r
126 valid EFI_LOADED_IMAGE_PROTOCOL. However, the current \r
127 platform policy specifies that the image should not be started.\r
023c0fec 128\r
129**/\r
130EFI_STATUS\r
131EFIAPI\r
132CoreLoadImageEx (\r
133 IN EFI_PE32_IMAGE_PROTOCOL *This,\r
134 IN EFI_HANDLE ParentImageHandle,\r
135 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r
136 IN VOID *SourceBuffer OPTIONAL,\r
137 IN UINTN SourceSize,\r
138 IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL,\r
139 OUT UINTN *NumberOfPages OPTIONAL,\r
140 OUT EFI_HANDLE *ImageHandle,\r
141 OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,\r
142 IN UINT32 Attribute\r
143 );\r
144\r
145\r
146/**\r
147 Unload the specified image.\r
148\r
149 @param This Indicates the calling context.\r
150 @param ImageHandle The specified image handle.\r
162ed594 151\r
023c0fec 152 @retval EFI_INVALID_PARAMETER Image handle is NULL.\r
153 @retval EFI_UNSUPPORTED Attempt to unload an unsupported image.\r
154 @retval EFI_SUCCESS Image successfully unloaded.\r
155\r
156**/\r
157EFI_STATUS\r
158EFIAPI\r
159CoreUnloadImageEx (\r
160 IN EFI_PE32_IMAGE_PROTOCOL *This,\r
161 IN EFI_HANDLE ImageHandle\r
162 );\r
28a00297 163#endif\r