]>
Commit | Line | Data |
---|---|---|
23c98c94 | 1 | /** @file\r |
504214c4 | 2 | Data structure and functions to load and unload PeImage.\r |
23c98c94 | 3 | \r |
4 | Copyright (c) 2006 - 2008, Intel Corporation. <BR>\r | |
28a00297 | 5 | All rights reserved. This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT 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 |
21 | typedef struct {\r | |
22 | UINTN Signature;\r | |
ec90508b | 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 | |
28a00297 | 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 | |
28a00297 | 68 | //\r |
69 | // Private Data Types\r | |
70 | //\r | |
f3f2e05d | 71 | #define IMAGE_FILE_HANDLE_SIGNATURE SIGNATURE_32('i','m','g','f')\r |
28a00297 | 72 | typedef struct {\r |
73 | UINTN Signature;\r | |
74 | BOOLEAN FreeBuffer;\r | |
75 | VOID *Source;\r | |
76 | UINTN SourceSize;\r | |
77 | } IMAGE_FILE_HANDLE;\r | |
78 | \r | |
79 | \r | |
162ed594 | 80 | /**\r |
81 | Opens a file for (simple) reading. The simple read abstraction\r | |
82 | will access the file either from a memory copy, from a file\r | |
83 | system interface, or from the load file interface.\r | |
84 | \r | |
022c6d45 | 85 | @param BootPolicy Policy for Open Image File.\r |
86 | @param SourceBuffer Pointer to the memory location containing copy\r | |
87 | of the image to be loaded.\r | |
88 | @param SourceSize The size in bytes of SourceBuffer.\r | |
89 | @param FilePath The specific file path from which the image is\r | |
90 | loaded\r | |
91 | @param DeviceHandle Pointer to the return device handle.\r | |
92 | @param ImageFileHandle Pointer to the image file handle.\r | |
93 | @param AuthenticationStatus Pointer to a caller-allocated UINT32 in which\r | |
94 | the authentication status is returned.\r | |
95 | \r | |
96 | @retval EFI_SUCCESS Image file successfully opened.\r | |
97 | @retval EFI_LOAD_ERROR If the caller passed a copy of the file, and\r | |
98 | SourceSize is 0.\r | |
99 | @retval EFI_INVALID_PARAMETER File path is not valid.\r | |
162ed594 | 100 | @retval EFI_NOT_FOUND File not found.\r |
101 | \r | |
102 | **/\r | |
28a00297 | 103 | EFI_STATUS\r |
104 | CoreOpenImageFile (\r | |
105 | IN BOOLEAN BootPolicy,\r | |
106 | IN VOID *SourceBuffer OPTIONAL,\r | |
107 | IN UINTN SourceSize,\r | |
cfe9de52 | 108 | IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,\r |
28a00297 | 109 | OUT EFI_HANDLE *DeviceHandle,\r |
110 | IN IMAGE_FILE_HANDLE *ImageFileHandle,\r | |
111 | OUT UINT32 *AuthenticationStatus\r | |
23c98c94 | 112 | );\r |
28a00297 | 113 | \r |
28a00297 | 114 | \r |
28a00297 | 115 | \r |
162ed594 | 116 | /**\r |
117 | Read image file (specified by UserHandle) into user specified buffer with specified offset\r | |
118 | and length.\r | |
28a00297 | 119 | \r |
022c6d45 | 120 | @param UserHandle Image file handle\r |
121 | @param Offset Offset to the source file\r | |
122 | @param ReadSize For input, pointer of size to read; For output,\r | |
123 | pointer of size actually read.\r | |
124 | @param Buffer Buffer to write into\r | |
28a00297 | 125 | \r |
022c6d45 | 126 | @retval EFI_SUCCESS Successfully read the specified part of file\r |
162ed594 | 127 | into buffer.\r |
28a00297 | 128 | \r |
162ed594 | 129 | **/\r |
28a00297 | 130 | EFI_STATUS\r |
131 | EFIAPI\r | |
132 | CoreReadImageFile (\r | |
23c98c94 | 133 | IN VOID *UserHandle,\r |
134 | IN UINTN Offset,\r | |
135 | IN OUT UINTN *ReadSize,\r | |
136 | OUT VOID *Buffer\r | |
137 | );\r | |
28a00297 | 138 | \r |
28a00297 | 139 | \r |
162ed594 | 140 | \r |
28a00297 | 141 | #endif\r |