]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Core/Dxe/Image/Image.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[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 - 2018, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9
10 #ifndef _IMAGE_H_
11 #define _IMAGE_H_
12
13 #define LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE SIGNATURE_32('l','p','e','i')
14
15 typedef struct {
16 UINTN Signature;
17 /// Image handle
18 EFI_HANDLE Handle;
19 EFI_PE32_IMAGE_PROTOCOL Pe32Image;
20 } LOAD_PE32_IMAGE_PRIVATE_DATA;
21
22 #define LOAD_PE32_IMAGE_PRIVATE_DATA_FROM_THIS(a) \
23 CR(a, LOAD_PE32_IMAGE_PRIVATE_DATA, Pe32Image, LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE)
24
25
26 //
27 // Private Data Types
28 //
29 #define IMAGE_FILE_HANDLE_SIGNATURE SIGNATURE_32('i','m','g','f')
30 typedef struct {
31 UINTN Signature;
32 BOOLEAN FreeBuffer;
33 VOID *Source;
34 UINTN SourceSize;
35 } IMAGE_FILE_HANDLE;
36
37 /**
38 Loads an EFI image into memory and returns a handle to the image with extended parameters.
39
40 @param This Calling context
41 @param ParentImageHandle The caller's image handle.
42 @param FilePath The specific file path from which the image is
43 loaded.
44 @param SourceBuffer If not NULL, a pointer to the memory location
45 containing a copy of the image to be loaded.
46 @param SourceSize The size in bytes of SourceBuffer.
47 @param DstBuffer The buffer to store the image.
48 @param NumberOfPages For input, specifies the space size of the
49 image by caller if not NULL. For output,
50 specifies the actual space size needed.
51 @param ImageHandle Image handle for output.
52 @param EntryPoint Image entry point for output.
53 @param Attribute The bit mask of attributes to set for the load
54 PE image.
55
56 @retval EFI_SUCCESS The image was loaded into memory.
57 @retval EFI_NOT_FOUND The FilePath was not found.
58 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
59 @retval EFI_UNSUPPORTED The image type is not supported, or the device
60 path cannot be parsed to locate the proper
61 protocol for loading the file.
62 @retval EFI_OUT_OF_RESOURCES Image was not loaded due to insufficient
63 resources.
64 @retval EFI_LOAD_ERROR Image was not loaded because the image format was corrupt or not
65 understood.
66 @retval EFI_DEVICE_ERROR Image was not loaded because the device returned a read error.
67 @retval EFI_ACCESS_DENIED Image was not loaded because the platform policy prohibits the
68 image from being loaded. NULL is returned in *ImageHandle.
69 @retval EFI_SECURITY_VIOLATION Image was loaded and an ImageHandle was created with a
70 valid EFI_LOADED_IMAGE_PROTOCOL. However, the current
71 platform policy specifies that the image should not be started.
72
73 **/
74 EFI_STATUS
75 EFIAPI
76 CoreLoadImageEx (
77 IN EFI_PE32_IMAGE_PROTOCOL *This,
78 IN EFI_HANDLE ParentImageHandle,
79 IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
80 IN VOID *SourceBuffer OPTIONAL,
81 IN UINTN SourceSize,
82 IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL,
83 OUT UINTN *NumberOfPages OPTIONAL,
84 OUT EFI_HANDLE *ImageHandle,
85 OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,
86 IN UINT32 Attribute
87 );
88
89
90 /**
91 Unload the specified image.
92
93 @param This Indicates the calling context.
94 @param ImageHandle The specified image handle.
95
96 @retval EFI_INVALID_PARAMETER Image handle is NULL.
97 @retval EFI_UNSUPPORTED Attempt to unload an unsupported image.
98 @retval EFI_SUCCESS Image successfully unloaded.
99
100 **/
101 EFI_STATUS
102 EFIAPI
103 CoreUnloadImageEx (
104 IN EFI_PE32_IMAGE_PROTOCOL *This,
105 IN EFI_HANDLE ImageHandle
106 );
107 #endif