]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix GCC build bug and add a debug library to dump load and unload commands into the...
authorAJFISH <AJFISH@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 14 Jan 2010 16:18:02 +0000 (16:18 +0000)
committerAJFISH <AJFISH@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 14 Jan 2010 16:18:02 +0000 (16:18 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9752 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/ArmPkg.dsc
ArmPkg/Drivers/CpuDxe/Exception.c
ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.c [new file with mode: 0644]
ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.inf [new file with mode: 0644]

index 7001f28f17cc6d7cfad755d39e92d7ecca725236..5925466bcc8b190052947d663daf51b3f690d10f 100644 (file)
@@ -43,6 +43,7 @@
   UefiLib|MdePkg/Library/UefiLib/UefiLib.inf
   DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
   UefiRuntimeServicesTableLib|MdePkg/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
+  PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
 
   SemihostLib|ArmPkg/Library/SemihostLib/SemihostLib.inf
   UncachedMemoryAllocationLib|ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.inf
@@ -82,6 +83,7 @@
   ArmPkg/Library/SemihostLib/SemihostLib.inf
   ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.inf
   ArmPkg/Library/DebugUncachedMemoryAllocationLib/DebugUncachedMemoryAllocationLib.inf
+  ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.inf
 
   ArmPkg/Drivers/CpuDxe/CpuDxe.inf
   ArmPkg/Drivers/DebugSupportDxe/DebugSupportDxe.inf
index 1f84e314b4a80d7017b440265f7a6ec98f9bf868..1487fe8b2e3d0c79a95222d5661957dc8e83980d 100644 (file)
@@ -14,7 +14,7 @@
 \r
 #include "CpuDxe.h" \r
 \r
-EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *gDebugImageTableHeader = NULL;
+EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *gDebugImageTableHeader = NULL;\r
 \r
 VOID\r
 ExceptionHandlersStart (\r
@@ -122,36 +122,38 @@ RegisterDebuggerInterruptHandler (
 }\r
 \r
 \r
-UINT32
-EFIAPI
-PeCoffGetSizeOfHeaders (
-  IN VOID     *Pe32Data
-  )
-{
-  EFI_IMAGE_DOS_HEADER                  *DosHdr;
-  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;
-  UINTN                                 SizeOfHeaders;
-
-  DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
-  if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
-    //
-    // DOS image header is present, so read the PE header after the DOS image header.
-    //
-    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
-  } else {
-    //
-    // DOS image header is not present, so PE header is at the image base.
-    //
-    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
-  }
-
-  if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
-   SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize;
-  } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
-    SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders;
-  }
-
-  return SizeOfHeaders;
+UINT32\r
+EFIAPI\r
+PeCoffGetSizeOfHeaders (\r
+  IN VOID     *Pe32Data\r
+  )\r
+{\r
+  EFI_IMAGE_DOS_HEADER                  *DosHdr;\r
+  EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION   Hdr;\r
+  UINTN                                 SizeOfHeaders;\r
+\r
+  DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;\r
+  if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {\r
+    //\r
+    // DOS image header is present, so read the PE header after the DOS image header.\r
+    //\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));\r
+  } else {\r
+    //\r
+    // DOS image header is not present, so PE header is at the image base.\r
+    //\r
+    Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;\r
+  }\r
+\r
+  if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {\r
+    SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize;\r
+  } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {\r
+    SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders;\r
+  } else {\r
+    SizeOfHeaders = 0;\r
+  }\r
+\r
+  return SizeOfHeaders;\r
 }\r
 \r
 \r
@@ -162,10 +164,10 @@ GetImageName (
   OUT UINT32  *PeCoffSizeOfHeaders\r
   )\r
 {\r
-  EFI_DEBUG_IMAGE_INFO  *DebugTable;
-  UINTN                 Entry;
-  CHAR8                 *Address;
-
+  EFI_DEBUG_IMAGE_INFO  *DebugTable;\r
+  UINTN                 Entry;\r
+  CHAR8                 *Address;\r
+\r
   \r
   DebugTable = gDebugImageTableHeader->EfiDebugImageInfoTable;\r
   if (DebugTable == NULL) {\r
@@ -173,18 +175,18 @@ GetImageName (
   }\r
 \r
   Address = (CHAR8 *)(UINTN)FaultAddress;\r
-  for (Entry = 0; Entry < gDebugImageTableHeader->TableSize; Entry++, DebugTable++) {
-    if (DebugTable->NormalImage != NULL) {
-      if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) && 
-          (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
-        if ((Address >= DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) &&
-            (Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize))) {
-          *ImageBase = (UINT32)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;
-          *PeCoffSizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID *)(UINTN)*ImageBase);
-          return PeCoffLoaderGetPdbPointer (DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase);
-        }           
-      }
-    }  
+  for (Entry = 0; Entry < gDebugImageTableHeader->TableSize; Entry++, DebugTable++) {\r
+    if (DebugTable->NormalImage != NULL) {\r
+      if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) && \r
+          (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {\r
+        if ((Address >= (CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase) &&\r
+            (Address <= ((CHAR8 *)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase + DebugTable->NormalImage->LoadedImageProtocolInstance->ImageSize))) {\r
+          *ImageBase = (UINT32)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;\r
+          *PeCoffSizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID *)(UINTN)*ImageBase);\r
+          return PeCoffLoaderGetPdbPointer (DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase);\r
+        }           \r
+      }\r
+    }  \r
   }\r
 \r
   return NULL;\r
@@ -249,10 +251,10 @@ CommonCExceptionHandler (
   //\r
   DEBUG ((EFI_D_ERROR, "\n%a Exception from instruction at 0x%08x  CPSR 0x%08x\n", gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR));\r
   DEBUG_CODE_BEGIN ();\r
-    CHAR8   *Pdb;
-    UINT32  ImageBase;
-    UINT32  PeCoffSizeOfHeader;
-    UINT32  Offset;
+    CHAR8   *Pdb;\r
+    UINT32  ImageBase;\r
+    UINT32  PeCoffSizeOfHeader;\r
+    UINT32  Offset;\r
   \r
     Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase, &PeCoffSizeOfHeader);\r
     Offset = SystemContext.SystemContextArm->PC - ImageBase;\r
@@ -296,10 +298,10 @@ InitializeExceptions (
   BOOLEAN              Enabled;\r
   EFI_PHYSICAL_ADDRESS Base;\r
 \r
-  Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&gDebugImageTableHeader);
-  if (EFI_ERROR (Status)) {
-    gDebugImageTableHeader = NULL;
-  }
+  Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&gDebugImageTableHeader);\r
+  if (EFI_ERROR (Status)) {\r
+    gDebugImageTableHeader = NULL;\r
+  }\r
 \r
   //\r
   // Disable interrupts\r
diff --git a/ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.c b/ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.c
new file mode 100644 (file)
index 0000000..2e44c62
--- /dev/null
@@ -0,0 +1,109 @@
+/**@file\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation\r
+Portions copyright (c) 2008-2010 Apple Inc. All rights reserved.\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
+\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+#include <Library/PeCoffLib.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/PeCoffExtraActionLib.h>\r
+#include <Library/SerialPortLib.h>\r
+#include <Library/PrintLib.h>\r
+\r
+\r
+VOID\r
+DeCygwinIfNeeded (\r
+  IN  CHAR8   *Name\r
+  )\r
+{\r
+  CHAR8   *Ptr;\r
+  UINTN   Index;\r
+  UINTN   Len;\r
+  \r
+  Ptr = AsciiStrStr (Name, "/cygdrive/");\r
+  if (Ptr == NULL) {\r
+    return;\r
+  }\r
+  \r
+  Len = AsciiStrLen (Ptr);\r
+  \r
+  // convert "/cygdrive" to spaces\r
+  for (Index = 0; Index < 9; Index++) {\r
+    Ptr[Index] = ' ';\r
+  }\r
+\r
+  // convert /c to c:\r
+  Ptr[9]  = Ptr[10];\r
+  Ptr[10] = ':';\r
+  \r
+  // switch path seperators\r
+  for (Index = 11; Index < Len; Index++) {\r
+    if (Ptr[Index] == '/') {\r
+      Ptr[Index] = '\\' ;\r
+    }\r
+  }\r
+}\r
+\r
+\r
+/**\r
+  Performs additional actions after a PE/COFF image has been loaded and relocated.\r
+\r
+  If ImageContext is NULL, then ASSERT().\r
+\r
+  @param  ImageContext  Pointer to the image context structure that describes the\r
+                        PE/COFF image that has already been loaded and relocated.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeCoffLoaderRelocateImageExtraAction (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+{\r
+  CHAR8 Buffer[256];\r
+  \r
+  AsciiSPrint (Buffer, sizeof(Buffer), "load /a /ni /np %a &0x%08x\n", ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));\r
+  DeCygwinIfNeeded (&Buffer[16]);\r
\r
+  SerialPortWrite ((UINT8 *) Buffer, AsciiStrLen (Buffer));\r
+}\r
+\r
+\r
+\r
+/**\r
+  Performs additional actions just before a PE/COFF image is unloaded.  Any resources\r
+  that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.\r
+  \r
+  If ImageContext is NULL, then ASSERT().\r
+  \r
+  @param  ImageContext  Pointer to the image context structure that describes the\r
+                        PE/COFF image that is being unloaded.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeCoffLoaderUnloadImageExtraAction (\r
+  IN OUT PE_COFF_LOADER_IMAGE_CONTEXT  *ImageContext\r
+  )\r
+{\r
+  CHAR8 Buffer[256];\r
+  \r
+  AsciiSPrint (Buffer, sizeof(Buffer), "unload symbols_only %a", ImageContext->PdbPointer);\r
+  DeCygwinIfNeeded (Buffer);\r
\r
+  SerialPortWrite ((UINT8 *) Buffer, AsciiStrLen (Buffer));\r
+}\r
diff --git a/ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.inf b/ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.inf
new file mode 100644 (file)
index 0000000..947fcf4
--- /dev/null
@@ -0,0 +1,45 @@
+#/** @file
+# PeCoff extra action libary for DXE phase that run Unix emulator.
+#
+# Lib to provide memory journal status code reporting Routines
+# Copyright (c) 2007 - 2010, Intel Corporation
+# Portiions copyright (c) 2010 Apple, Inc. All rights reserved. 
+# 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.
+#
+#
+#**/
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = RviUnixPeCoffExtraActionLib
+  FILE_GUID                      = 5EDEB7E7-EA55-4E92-8216-335AC98A3B11
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = PeCoffExtraActionLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_DRIVER
+  EDK_RELEASE_VERSION            = 0x00020000
+  EFI_SPECIFICATION_VERSION      = 0x00020000
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = ARM
+#
+
+[Sources.common]
+  RviPeCoffExtraActionLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  ArmPkg/ArmPkg.dec
+
+[LibraryClasses]
+  DebugLib
+  HobLib
+  BaseMemoryLib
+  SerialLib