1 /*++ 2 3 Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR> 4 This program and the accompanying materials 5 are licensed and made available under the terms and conditions of the BSD License 6 which accompanies this distribution. The full text of the license may be found at 7 http://opensource.org/licenses/bsd-license.php 8 9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 11 12 Module Name: 13 14 PeiPeCoffLoader.h 15 16 Abstract: 17 18 GUID for the PE/COFF Loader APIs shared between PEI and DXE 19 20 --*/ 21 22 #ifndef _PEI_PE_COFF_LOADER_H_ 23 #define _PEI_PE_COFF_LOADER_H_ 24 25 #include "EfiImage.h" 26 27 #define EFI_PEI_PE_COFF_LOADER_GUID \ 28 { 0xd8117cff, 0x94a6, 0x11d4, {0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d} } 29 30 EFI_FORWARD_DECLARATION (EFI_PEI_PE_COFF_LOADER_PROTOCOL); 31 32 #define EFI_IMAGE_ERROR_SUCCESS 0 33 #define EFI_IMAGE_ERROR_IMAGE_READ 1 34 #define EFI_IMAGE_ERROR_INVALID_PE_HEADER_SIGNATURE 2 35 #define EFI_IMAGE_ERROR_INVALID_MACHINE_TYPE 3 36 #define EFI_IMAGE_ERROR_INVALID_SUBSYSTEM 4 37 #define EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS 5 38 #define EFI_IMAGE_ERROR_INVALID_IMAGE_SIZE 6 39 #define EFI_IMAGE_ERROR_INVALID_SECTION_ALIGNMENT 7 40 #define EFI_IMAGE_ERROR_SECTION_NOT_LOADED 8 41 #define EFI_IMAGE_ERROR_FAILED_RELOCATION 9 42 #define EFI_IMAGE_ERROR_FAILED_ICACHE_FLUSH 10 43 44 typedef 45 EFI_STATUS 46 (EFIAPI *EFI_PEI_PE_COFF_LOADER_READ_FILE) ( 47 IN VOID *FileHandle, 48 IN UINTN FileOffset, 49 IN OUT UINTN *ReadSize, 50 OUT VOID *Buffer 51 ); 52 53 typedef struct { 54 EFI_PHYSICAL_ADDRESS ImageAddress; 55 UINT64 ImageSize; 56 EFI_PHYSICAL_ADDRESS DestinationAddress; 57 EFI_PHYSICAL_ADDRESS EntryPoint; 58 EFI_PEI_PE_COFF_LOADER_READ_FILE ImageRead; 59 VOID *Handle; 60 VOID *FixupData; 61 UINT32 SectionAlignment; 62 UINT32 PeCoffHeaderOffset; 63 UINT32 DebugDirectoryEntryRva; 64 VOID *CodeView; 65 CHAR8 *PdbPointer; 66 UINTN SizeOfHeaders; 67 UINT32 ImageCodeMemoryType; 68 UINT32 ImageDataMemoryType; 69 UINT32 ImageError; 70 UINTN FixupDataSize; 71 UINT16 Machine; 72 UINT16 ImageType; 73 BOOLEAN RelocationsStripped; 74 BOOLEAN IsTeImage; 75 #ifdef EFI_NT_EMULATOR 76 VOID **ModHandle; 77 #endif 78 #if (EFI_SPECIFICATION_VERSION >= 0x0002000A) 79 EFI_PHYSICAL_ADDRESS HiiResourceData; 80 #endif 81 } EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT; 82 83 typedef 84 EFI_STATUS 85 (EFIAPI *EFI_PEI_PE_COFF_LOADER_GET_IMAGE_INFO) ( 86 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, 87 IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext 88 ); 89 90 typedef 91 EFI_STATUS 92 (EFIAPI *EFI_PEI_PE_COFF_LOADER_LOAD_IMAGE) ( 93 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, 94 IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext 95 ); 96 97 typedef 98 EFI_STATUS 99 (EFIAPI *EFI_PEI_PE_COFF_LOADER_RELOCATE_IMAGE) ( 100 IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This, 101 IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext 102 ); 103 104 typedef 105 EFI_STATUS 106 (EFIAPI *EFI_PEI_PE_COFF_LOADER_UNLOAD_IMAGE) ( 107 IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext 108 ); 109 110 struct _EFI_PEI_PE_COFF_LOADER_PROTOCOL { 111 EFI_PEI_PE_COFF_LOADER_GET_IMAGE_INFO GetImageInfo; 112 EFI_PEI_PE_COFF_LOADER_LOAD_IMAGE LoadImage; 113 EFI_PEI_PE_COFF_LOADER_RELOCATE_IMAGE RelocateImage; 114 EFI_PEI_PE_COFF_LOADER_UNLOAD_IMAGE UnloadImage; 115 }; 116 117 extern EFI_GUID gEfiPeiPeCoffLoaderGuid; 118 119 #endif 120