--- /dev/null
+/** @file\r
+ Memory Only PE COFF loader\r
+\r
+ Copyright (c) 2006, Intel Corporation \r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
+\r
+ Module Name: PeCoffLib.h\r
+\r
+**/\r
+\r
+#ifndef __BASE_PE_COFF_LIB_H__\r
+#define __BASE_PE_COFF_LIB_H__\r
+\r
+//\r
+// Return status codes from the PE/COFF Loader services\r
+// BUGBUG: Find where used and see if can be replaced by RETURN_STATUS codes\r
+//\r
+#define IMAGE_ERROR_SUCCESS 0\r
+#define IMAGE_ERROR_IMAGE_READ 1 \r
+#define IMAGE_ERROR_INVALID_PE_HEADER_SIGNATURE 2\r
+#define IMAGE_ERROR_INVALID_MACHINE_TYPE 3\r
+#define IMAGE_ERROR_INVALID_SUBSYSTEM 4\r
+#define IMAGE_ERROR_INVALID_IMAGE_ADDRESS 5\r
+#define IMAGE_ERROR_INVALID_IMAGE_SIZE 6\r
+#define IMAGE_ERROR_INVALID_SECTION_ALIGNMENT 7\r
+#define IMAGE_ERROR_SECTION_NOT_LOADED 8\r
+#define IMAGE_ERROR_FAILED_RELOCATION 9\r
+#define IMAGE_ERROR_FAILED_ICACHE_FLUSH 10\r
+\r
+\r
+//\r
+// PE/COFF Loader Read Function passed in by caller\r
+//\r
+typedef\r
+RETURN_STATUS\r
+(EFIAPI *PE_COFF_LOADER_READ_FILE) (\r
+ IN VOID *FileHandle,\r
+ IN UINTN FileOffset,\r
+ IN OUT UINTN *ReadSize,\r
+ OUT VOID *Buffer\r
+ );\r
+\r
+//\r
+// Context structure used while PE/COFF image is being loaded and relocated\r
+//\r
+typedef struct {\r
+ PHYSICAL_ADDRESS ImageAddress;\r
+ UINT64 ImageSize;\r
+ PHYSICAL_ADDRESS DestinationAddress;\r
+ PHYSICAL_ADDRESS EntryPoint;\r
+ PE_COFF_LOADER_READ_FILE ImageRead;\r
+ VOID *Handle;\r
+ VOID *FixupData;\r
+ UINT32 SectionAlignment;\r
+ UINT32 PeCoffHeaderOffset;\r
+ UINT32 DebugDirectoryEntryRva;\r
+ VOID *CodeView;\r
+ CHAR8 *PdbPointer;\r
+ UINTN SizeOfHeaders;\r
+ UINT32 ImageCodeMemoryType;\r
+ UINT32 ImageDataMemoryType;\r
+ UINT32 ImageError;\r
+ UINTN FixupDataSize;\r
+ UINT16 Machine;\r
+ UINT16 ImageType;\r
+ BOOLEAN RelocationsStripped;\r
+ BOOLEAN IsTeImage;\r
+} PE_COFF_LOADER_IMAGE_CONTEXT;\r
+\r
+\r
+/**\r
+ Retrieves information on a PE/COFF image\r
+\r
+ @param ImageContext The context of the image being loaded\r
+\r
+ @retval EFI_SUCCESS The information on the PE/COFF image was collected.\r
+ @retval EFI_INVALID_PARAMETER ImageContext is NULL.\r
+ @retval EFI_UNSUPPORTED The PE/COFF image is not supported.\r
+ @retval Otherwise The error status from reading the PE/COFF image using the\r
+ ImageContext->ImageRead() function\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderGetImageInfo (\r
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
+ )\r
+;\r
+\r
+/**\r
+ Relocates a PE/COFF image in memory\r
+\r
+ @param ImageContext Contains information on the loaded image to relocate\r
+\r
+ @retval EFI_SUCCESS if the PE/COFF image was relocated\r
+ @retval EFI_LOAD_ERROR if the image is not a valid PE/COFF image\r
+ @retval EFI_UNSUPPORTED not support\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderRelocateImage (\r
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
+ )\r
+;\r
+\r
+/**\r
+ Loads a PE/COFF image into memory\r
+\r
+ @param ImageContext Contains information on image to load into memory\r
+\r
+ @retval EFI_SUCCESS if the PE/COFF image was loaded\r
+ @retval EFI_BUFFER_TOO_SMALL if the caller did not provide a large enough buffer\r
+ @retval EFI_LOAD_ERROR if the image is a runtime driver with no relocations\r
+ @retval EFI_INVALID_PARAMETER if the image address is invalid\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+PeCoffLoaderLoadImage (\r
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext\r
+ )\r
+;\r
+\r
+#endif\r