]> git.proxmox.com Git - mirror_edk2.git/blame - EdkModulePkg/Core/Dxe/Image.h
Add enumeration type for EfiProcessorFamilyIntelPentiumM, EfiProcessorFamilyIntelCele...
[mirror_edk2.git] / EdkModulePkg / Core / Dxe / Image.h
CommitLineData
878ddf1f 1/*++\r
2\r
3Copyright (c) 2006, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 Image.h\r
15\r
16Abstract:\r
17\r
18Revision History\r
19\r
20--*/\r
21\r
22\r
23#ifndef _IMAGE_H_\r
24#define _IMAGE_H_\r
25\r
26\r
27\r
28#define LOADED_IMAGE_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32('l','d','r','i')\r
29\r
30typedef struct {\r
31 UINTN Signature;\r
32 EFI_HANDLE Handle; // Image handle\r
33 UINTN Type; // Image type\r
34\r
35 BOOLEAN Started; // If entrypoint has been called\r
36\r
37 EFI_IMAGE_ENTRY_POINT EntryPoint; // The image's entry point\r
38 EFI_LOADED_IMAGE_PROTOCOL Info; // loaded image protocol\r
39\r
40 EFI_PHYSICAL_ADDRESS ImageBasePage; // Location in memory\r
41 UINTN NumberOfPages; // Number of pages\r
42\r
43 CHAR8 *FixupData; // Original fixup data\r
44\r
45 EFI_TPL Tpl; // Tpl of started image\r
46 EFI_STATUS Status; // Status returned by started image\r
47\r
48 UINTN ExitDataSize; // Size of ExitData from started image\r
49 VOID *ExitData; // Pointer to exit data from started image\r
d57427a7 50 VOID *JumpBuffer; // Pointer to pool allocation for context save/retore\r
878ddf1f 51 BASE_LIBRARY_JUMP_BUFFER *JumpContext; // Pointer to buffer for context save/retore\r
52 UINT16 Machine; // Machine type from PE image\r
53\r
54 EFI_EBC_PROTOCOL *Ebc; // EBC Protocol pointer\r
55\r
56 BOOLEAN RuntimeFixupValid; // True if RT image needs fixup\r
57 VOID *RuntimeFixup; // Copy of fixup data;\r
58 LIST_ENTRY Link; // List of RT LOADED_IMAGE_PRIVATE_DATA\r
59\r
60 PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; // PeCoffLoader ImageContext\r
61\r
62} LOADED_IMAGE_PRIVATE_DATA;\r
63\r
64#define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \\r
65 CR(a, LOADED_IMAGE_PRIVATE_DATA, Info, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE)\r
66\r
67\r
68\r
69#define LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32('l','p','e','i')\r
70\r
71typedef struct {\r
72 UINTN Signature;\r
73 EFI_HANDLE Handle; // Image handle\r
74 EFI_PE32_IMAGE_PROTOCOL Pe32Image;\r
75} LOAD_PE32_IMAGE_PRIVATE_DATA;\r
76\r
77#define LOAD_PE32_IMAGE_PRIVATE_DATA_FROM_THIS(a) \\r
78 CR(a, LOAD_PE32_IMAGE_PRIVATE_DATA, Pe32Image, LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE)\r
79\r
80\r
81\r
82//\r
83// Private Data Types\r
84//\r
85#define IMAGE_FILE_HANDLE_SIGNATURE EFI_SIGNATURE_32('i','m','g','f')\r
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
93\r
94//\r
95// Abstractions for reading image contents\r
96//\r
97\r
98EFI_STATUS\r
99CoreOpenImageFile (\r
100 IN BOOLEAN BootPolicy,\r
101 IN VOID *SourceBuffer OPTIONAL,\r
102 IN UINTN SourceSize,\r
103 IN OUT EFI_DEVICE_PATH_PROTOCOL *FilePath,\r
104 OUT EFI_HANDLE *DeviceHandle,\r
105 IN IMAGE_FILE_HANDLE *ImageFileHandle,\r
106 OUT UINT32 *AuthenticationStatus\r
107 )\r
108/*++\r
109\r
110Routine Description:\r
111\r
112 Opens a file for (simple) reading. The simple read abstraction\r
113 will access the file either from a memory copy, from a file\r
114 system interface, or from the load file interface.\r
115\r
116Arguments:\r
117\r
118 BootPolicy - Policy for Open Image File.\r
119 SourceBuffer - Pointer to the memory location containing copy\r
120 of the image to be loaded.\r
121 SourceSize - The size in bytes of SourceBuffer.\r
122 FilePath - The specific file path from which the image is loaded\r
123 DeviceHandle - Pointer to the return device handle.\r
124 ImageFileHandle - Pointer to the image file handle.\r
125 AuthenticationStatus - Pointer to a caller-allocated UINT32 in which the authentication status is returned.\r
126\r
127Returns:\r
128\r
129 A handle to access the file\r
130\r
131--*/\r
132;\r
133\r
134\r
135EFI_STATUS\r
136EFIAPI\r
137CoreReadImageFile (\r
138 IN VOID *UserHandle,\r
139 IN UINTN Offset,\r
140 IN OUT UINTN *ReadSize,\r
141 OUT VOID *Buffer\r
142 )\r
143/*++\r
144\r
145Routine Description:\r
146\r
147 Read image file (specified by UserHandle) into user specified buffer with specified offset\r
148 and length.\r
149\r
150Arguments:\r
151\r
152 UserHandle - Image file handle\r
153\r
154 Offset - Offset to the source file\r
155\r
156 ReadSize - For input, pointer of size to read;\r
157 For output, pointer of size actually read.\r
158\r
159 Buffer - Buffer to write into\r
160\r
161Returns:\r
162\r
163 EFI_SUCCESS - Successfully read the specified part of file into buffer.\r
164\r
165--*/\r
166;\r
167\r
168VOID\r
169EFIAPI\r
170CoreCloseImageFile (\r
171 IN IMAGE_FILE_HANDLE *ImageFileHandle\r
172 )\r
173/*++\r
174\r
175Routine Description:\r
176\r
177 A function out of date, should be removed.\r
178\r
179Arguments:\r
180\r
181 ImageFileHandle - Handle of the file to close\r
182\r
183Returns:\r
184\r
185 None\r
186\r
187--*/\r
188;\r
189\r
190//\r
191// Image processing worker functions\r
192//\r
193EFI_STATUS\r
194CoreDevicePathToInterface (\r
195 IN EFI_GUID *Protocol,\r
196 IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,\r
197 OUT VOID **Interface,\r
198 OUT EFI_HANDLE *Handle\r
199 )\r
200/*++\r
201\r
202Routine Description:\r
203\r
204 Search a handle to a device on a specified device path that supports a specified protocol,\r
205 interface of that protocol on that handle is another output.\r
206\r
207Arguments:\r
208\r
209 Protocol - The protocol to search for\r
210\r
211 FilePath - The specified device path\r
212\r
213 Interface - Interface of the protocol on the handle\r
214\r
215 Handle - The handle to the device on the specified device path that supports the protocol.\r
216\r
217Returns:\r
218\r
219 Status code.\r
220\r
221--*/\r
222;\r
223\r
224EFI_STATUS\r
225CoreLoadPeImage (\r
226 IN VOID *Pe32Handle,\r
227 IN LOADED_IMAGE_PRIVATE_DATA *Image,\r
228 IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL,\r
229 OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,\r
230 IN UINT32 Attribute\r
231 )\r
232/*++\r
233\r
234Routine Description:\r
235\r
236 Loads, relocates, and invokes a PE/COFF image\r
237\r
238Arguments:\r
239\r
240 Pe32Handle - The handle of PE32 image\r
241 Image - PE image to be loaded\r
242 DstBuffer - The buffer to store the image\r
243 EntryPoint - A pointer to the entry point\r
244 Attribute - The bit mask of attributes to set for the load PE image\r
245\r
246Returns:\r
247\r
248 EFI_SUCCESS - The file was loaded, relocated, and invoked\r
249\r
250 EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file\r
251\r
252 EFI_INVALID_PARAMETER - Invalid parameter\r
253\r
254 EFI_BUFFER_TOO_SMALL - Buffer for image is too small\r
255\r
256--*/\r
257;\r
258\r
259LOADED_IMAGE_PRIVATE_DATA *\r
260CoreLoadedImageInfo (\r
261 IN EFI_HANDLE ImageHandle\r
262 )\r
263/*++\r
264\r
265Routine Description:\r
266\r
267 TODO: Add function description\r
268\r
269Arguments:\r
270\r
271 ImageHandle - TODO: add argument description\r
272\r
273Returns:\r
274\r
275 TODO: add return values\r
276\r
277--*/\r
278;\r
279\r
280VOID\r
281CoreUnloadAndCloseImage (\r
282 IN LOADED_IMAGE_PRIVATE_DATA *Image,\r
283 IN BOOLEAN FreePage\r
284 )\r
285/*++\r
286\r
287Routine Description:\r
288\r
289 Unloads EFI image from memory.\r
290\r
291Arguments:\r
292\r
293 Image - EFI image\r
294 FreePage - Free allocated pages\r
295\r
296Returns:\r
297\r
298 None\r
299\r
300--*/\r
301;\r
302\r
303\r
304//\r
305// Exported Image functions\r
306//\r
307\r
308EFI_STATUS\r
309EFIAPI\r
310CoreLoadImageEx (\r
311 IN EFI_PE32_IMAGE_PROTOCOL *This,\r
312 IN EFI_HANDLE ParentImageHandle,\r
313 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r
314 IN VOID *SourceBuffer OPTIONAL,\r
315 IN UINTN SourceSize,\r
316 IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL,\r
317 OUT UINTN *NumberOfPages OPTIONAL,\r
318 OUT EFI_HANDLE *ImageHandle,\r
319 OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,\r
320 IN UINT32 Attribute\r
321 )\r
322/*++\r
323\r
324Routine Description:\r
325\r
326 Loads an EFI image into memory and returns a handle to the image with extended parameters.\r
327\r
328Arguments:\r
329\r
330 ParentImageHandle - The caller's image handle.\r
331 FilePath - The specific file path from which the image is loaded.\r
332 SourceBuffer - If not NULL, a pointer to the memory location containing a copy of\r
333 the image to be loaded.\r
334 SourceSize - The size in bytes of SourceBuffer.\r
335 DstBuffer - The buffer to store the image.\r
336 NumberOfPages - For input, specifies the space size of the image by caller if not NULL.\r
337 For output, specifies the actual space size needed.\r
338 ImageHandle - Image handle for output.\r
339 EntryPoint - Image entry point for output.\r
340 Attribute - The bit mask of attributes to set for the load PE image.\r
341\r
342Returns:\r
343\r
344 EFI_SUCCESS - The image was loaded into memory.\r
345 EFI_NOT_FOUND - The FilePath was not found.\r
346 EFI_INVALID_PARAMETER - One of the parameters has an invalid value.\r
347 EFI_UNSUPPORTED - The image type is not supported, or the device path cannot be\r
348 parsed to locate the proper protocol for loading the file.\r
349 EFI_OUT_OF_RESOURCES - Image was not loaded due to insufficient resources.\r
350--*/\r
351;\r
352\r
353EFI_STATUS\r
354EFIAPI\r
355CoreUnloadImageEx (\r
356 IN EFI_PE32_IMAGE_PROTOCOL *This,\r
357 IN EFI_HANDLE ImageHandle\r
358 )\r
359/*++\r
360\r
361Routine Description:\r
362\r
363 Unload the specified image.\r
364\r
365Arguments:\r
366\r
367 This - Indicates the calling context.\r
368\r
369 ImageHandle - The specified image handle.\r
370\r
371Returns:\r
372\r
373 EFI_INVALID_PARAMETER - Image handle is NULL.\r
374\r
375 EFI_UNSUPPORTED - Attempt to unload an unsupported image.\r
376\r
377 EFI_SUCCESS - Image successfully unloaded.\r
378\r
379--*/\r
380;\r
381#endif\r