Add PeiDxePeCoffLoaderLib instance in MdeModulePkg.
authoryshang1 <yshang1@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 4 Jul 2007 10:44:50 +0000 (10:44 +0000)
committeryshang1 <yshang1@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 4 Jul 2007 10:44:50 +0000 (10:44 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@3043 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Library/PeiDxePeCoffLoaderLib/PeCoffLoader.c [new file with mode: 0644]
MdeModulePkg/Library/PeiDxePeCoffLoaderLib/PeCoffLoaderLib.inf [new file with mode: 0644]
MdeModulePkg/Library/PeiDxePeCoffLoaderLib/PeCoffLoaderLib.msa [new file with mode: 0644]

diff --git a/MdeModulePkg/Library/PeiDxePeCoffLoaderLib/PeCoffLoader.c b/MdeModulePkg/Library/PeiDxePeCoffLoaderLib/PeCoffLoader.c
new file mode 100644 (file)
index 0000000..783e875
--- /dev/null
@@ -0,0 +1,129 @@
+/*++\r
+\r
+Copyright (c) 2006 - 2007, 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:\r
+\r
+  EdkPeCoffLoader.c\r
+\r
+Abstract:\r
+\r
+  Wrap the Base PE/COFF loader with the PE COFF Protocol\r
+\r
+\r
+--*/\r
+\r
+//\r
+// The package level header files this module uses\r
+//\r
+#include <PiPei.h>\r
+//\r
+// The protocols, PPI and GUID defintions for this module\r
+//\r
+#include <Guid/PeiPeCoffLoader.h>\r
+//\r
+// The Library classes this module consumes\r
+//\r
+#include <Library/PeCoffLib.h>\r
+\r
+#include <IndustryStandard/PeImage.h>\r
+\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+PeCoffLoaderLibGetImageInfo (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL          *This,\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext\r
+  )\r
+{\r
+  EFI_STATUS  Status;\r
+\r
+  Status = PeCoffLoaderGetImageInfo (ImageContext);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  switch (ImageContext->ImageType) {\r
+\r
+  case EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION:\r
+    ImageContext->ImageCodeMemoryType = EfiLoaderCode;\r
+    ImageContext->ImageDataMemoryType = EfiLoaderData;\r
+    break;\r
+\r
+  case EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:\r
+    ImageContext->ImageCodeMemoryType = EfiBootServicesCode;\r
+    ImageContext->ImageDataMemoryType = EfiBootServicesData;\r
+    break;\r
+\r
+  case EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:\r
+  case EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER:\r
+    ImageContext->ImageCodeMemoryType = EfiRuntimeServicesCode;\r
+    ImageContext->ImageDataMemoryType = EfiRuntimeServicesData;\r
+    break;\r
+\r
+  default:\r
+    ImageContext->ImageError = IMAGE_ERROR_INVALID_SUBSYSTEM;\r
+    return RETURN_UNSUPPORTED;\r
+  }\r
+\r
+  return Status;\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+PeCoffLoaderLibLoadImage (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL          *This,\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext\r
+  )\r
+{\r
+  return PeCoffLoaderLoadImage (ImageContext);\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+PeCoffLoaderLibRelocateImage (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL          *This,\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext\r
+  )\r
+{\r
+  return PeCoffLoaderRelocateImage (ImageContext);\r
+}\r
+\r
+STATIC\r
+EFI_STATUS\r
+EFIAPI\r
+PeCoffLoaderLibUnloadimage (\r
+  IN EFI_PEI_PE_COFF_LOADER_PROTOCOL      *This,\r
+  IN PE_COFF_LOADER_IMAGE_CONTEXT         *ImageContext\r
+  )\r
+{\r
+  return EFI_SUCCESS;\r
+}\r
+\r
+\r
+EFI_PEI_PE_COFF_LOADER_PROTOCOL  mPeiEfiPeiPeCoffLoader = {\r
+  PeCoffLoaderLibGetImageInfo,\r
+  PeCoffLoaderLibLoadImage,\r
+  PeCoffLoaderLibRelocateImage,\r
+  PeCoffLoaderLibUnloadimage\r
+};\r
+\r
+EFI_PEI_PE_COFF_LOADER_PROTOCOL *\r
+EFIAPI\r
+GetPeCoffLoaderProtocol (\r
+  )\r
+{\r
+  return &mPeiEfiPeiPeCoffLoader;\r
+}\r
+\r
+\r
diff --git a/MdeModulePkg/Library/PeiDxePeCoffLoaderLib/PeCoffLoaderLib.inf b/MdeModulePkg/Library/PeiDxePeCoffLoaderLib/PeCoffLoaderLib.inf
new file mode 100644 (file)
index 0000000..236f7e8
--- /dev/null
@@ -0,0 +1,70 @@
+#/** @file\r
+# DxePeCoffLoaderLib library instance\r
+#\r
+# This library provides PeCoffLoader protocol based on PeCoffLib functions.\r
+# Copyright (c) 2006, Intel Corporation.\r
+#\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
+#  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
+#\r
+#**/\r
+\r
+################################################################################\r
+#\r
+# Defines Section - statements that will be processed to create a Makefile.\r
+#\r
+################################################################################\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = PeiDxePeCoffLoaderLib\r
+  FILE_GUID                      = 858bbbc9-474f-4556-a361-0ae52a44ffa5\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = PeiDxeCorePeCoffLoaderLib|DXE_CORE PEIM \r
+  EDK_RELEASE_VERSION            = 0x00020000\r
+  EFI_SPECIFICATION_VERSION      = 0x00020000\r
+\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
+#\r
+\r
+################################################################################\r
+#\r
+# Sources Section - list of files that are required for the build to succeed.\r
+#\r
+################################################################################\r
+\r
+[Sources.common]\r
+  PeCoffLoader.c\r
+\r
+\r
+################################################################################\r
+#\r
+# Package Dependency Section - list of Package files that are required for\r
+#                              this module.\r
+#\r
+################################################################################\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+\r
+################################################################################\r
+#\r
+# Library Class Section - list of Library Classes that are required for\r
+#                         this module.\r
+#\r
+################################################################################\r
+\r
+[LibraryClasses]\r
+  PeCoffLib\r
+\r
diff --git a/MdeModulePkg/Library/PeiDxePeCoffLoaderLib/PeCoffLoaderLib.msa b/MdeModulePkg/Library/PeiDxePeCoffLoaderLib/PeCoffLoaderLib.msa
new file mode 100644 (file)
index 0000000..b015020
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<ModuleSurfaceArea xmlns="http://www.TianoCore.org/2006/Edk2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\r
+  <MsaHeader>\r
+    <ModuleName>PeiDxePeCoffLoaderLib</ModuleName>\r
+    <ModuleType>PEIM</ModuleType>\r
+    <GuidValue>858bbbc9-474f-4556-a361-0ae52a44ffa5</GuidValue>\r
+    <Version>1.0</Version>\r
+    <Abstract>DxePeCoffLoaderLib library instance</Abstract>\r
+    <Description>This library provides PeCoffLoader protocol based on PeCoffLib functions.</Description>\r
+    <Copyright>Copyright (c) 2006, Intel Corporation.</Copyright>\r
+    <License>All rights reserved. This program and the accompanying materials
+      are licensed and made available under the terms and conditions of the BSD License
+      which accompanies this distribution.  The full text of the license may be found at
+      http://opensource.org/licenses/bsd-license.php
+      THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+      WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.</License>\r
+    <Specification>FRAMEWORK_BUILD_PACKAGING_SPECIFICATION   0x00000052</Specification>\r
+  </MsaHeader>\r
+  <ModuleDefinitions>\r
+    <SupportedArchitectures>IA32 X64 IPF EBC</SupportedArchitectures>\r
+    <BinaryModule>false</BinaryModule>\r
+    <OutputFileBasename>PeiDxePeCoffLoaderLib</OutputFileBasename>\r
+  </ModuleDefinitions>\r
+  <LibraryClassDefinitions>\r
+    <LibraryClass Usage="ALWAYS_PRODUCED" SupModuleList="DXE_CORE PEIM">\r
+      <Keyword>PeiDxeCorePeCoffLoaderLib</Keyword>\r
+    </LibraryClass>\r
+    <LibraryClass Usage="ALWAYS_CONSUMED">\r
+      <Keyword>PeCoffLib</Keyword>\r
+    </LibraryClass>\r
+  </LibraryClassDefinitions>\r
+  <SourceFiles>\r
+    <Filename>PeCoffLoader.c</Filename>\r
+    <Filename>PeCoffLoaderLibInternals.h</Filename>\r
+  </SourceFiles>\r
+  <PackageDependencies>\r
+    <Package PackageGuid="5e0e9358-46b6-4ae2-8218-4ab8b9bbdcec"/>\r
+    <Package PackageGuid="68169ab0-d41b-4009-9060-292c253ac43d"/>\r
+  </PackageDependencies>\r
+  <Externs>\r
+    <Specification>EFI_SPECIFICATION_VERSION 0x00020000</Specification>\r
+    <Specification>EDK_RELEASE_VERSION 0x00020000</Specification>\r
+  </Externs>\r
+</ModuleSurfaceArea>
\ No newline at end of file