diff options
author | AJFISH <AJFISH@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-01-14 16:18:02 +0000 |
---|---|---|
committer | AJFISH <AJFISH@6f19259b-4bc3-4df7-8a09-765794883524> | 2010-01-14 16:18:02 +0000 |
commit | 62e797a489341b13a095b3cd7c0f7bd9eac12efe (patch) | |
tree | 2f75da867ce80104e6d15dc497c2f5edf30fd6ee /ArmPkg | |
parent | c11fa40c4e8124c7dfb8660b67aea1175e91cc13 (diff) | |
download | edk2-62e797a489341b13a095b3cd7c0f7bd9eac12efe.zip edk2-62e797a489341b13a095b3cd7c0f7bd9eac12efe.tar.gz edk2-62e797a489341b13a095b3cd7c0f7bd9eac12efe.tar.bz2 |
Fix GCC build bug and add a debug library to dump load and unload commands into the RVI debugger window.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9752 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPkg')
-rw-r--r-- | ArmPkg/ArmPkg.dsc | 2 | ||||
-rw-r--r-- | ArmPkg/Drivers/CpuDxe/Exception.c | 112 | ||||
-rw-r--r-- | ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.c | 109 | ||||
-rw-r--r-- | ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.inf | 45 |
4 files changed, 213 insertions, 55 deletions
diff --git a/ArmPkg/ArmPkg.dsc b/ArmPkg/ArmPkg.dsc index 7001f28..5925466 100644 --- a/ArmPkg/ArmPkg.dsc +++ b/ArmPkg/ArmPkg.dsc @@ -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 diff --git a/ArmPkg/Drivers/CpuDxe/Exception.c b/ArmPkg/Drivers/CpuDxe/Exception.c index 1f84e31..1487fe8 100644 --- a/ArmPkg/Drivers/CpuDxe/Exception.c +++ b/ArmPkg/Drivers/CpuDxe/Exception.c @@ -14,7 +14,7 @@ #include "CpuDxe.h"
-EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *gDebugImageTableHeader = NULL; +EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *gDebugImageTableHeader = NULL;
VOID
ExceptionHandlersStart (
@@ -122,36 +122,38 @@ RegisterDebuggerInterruptHandler ( }
-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
+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;
+ } else {
+ SizeOfHeaders = 0;
+ }
+
+ return SizeOfHeaders;
}
@@ -162,10 +164,10 @@ GetImageName ( OUT UINT32 *PeCoffSizeOfHeaders
)
{
- EFI_DEBUG_IMAGE_INFO *DebugTable; - UINTN Entry; - CHAR8 *Address; - + EFI_DEBUG_IMAGE_INFO *DebugTable;
+ UINTN Entry;
+ CHAR8 *Address;
+
DebugTable = gDebugImageTableHeader->EfiDebugImageInfoTable;
if (DebugTable == NULL) {
@@ -173,18 +175,18 @@ GetImageName ( }
Address = (CHAR8 *)(UINTN)FaultAddress;
- 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++) {
+ if (DebugTable->NormalImage != NULL) {
+ if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) &&
+ (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {
+ if ((Address >= (CHAR8 *)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);
+ }
+ }
+ }
}
return NULL;
@@ -249,10 +251,10 @@ CommonCExceptionHandler ( //
DEBUG ((EFI_D_ERROR, "\n%a Exception from instruction at 0x%08x CPSR 0x%08x\n", gExceptionTypeString[ExceptionType], SystemContext.SystemContextArm->PC, SystemContext.SystemContextArm->CPSR));
DEBUG_CODE_BEGIN ();
- CHAR8 *Pdb; - UINT32 ImageBase; - UINT32 PeCoffSizeOfHeader; - UINT32 Offset; + CHAR8 *Pdb;
+ UINT32 ImageBase;
+ UINT32 PeCoffSizeOfHeader;
+ UINT32 Offset;
Pdb = GetImageName (SystemContext.SystemContextArm->PC, &ImageBase, &PeCoffSizeOfHeader);
Offset = SystemContext.SystemContextArm->PC - ImageBase;
@@ -296,10 +298,10 @@ InitializeExceptions ( BOOLEAN Enabled;
EFI_PHYSICAL_ADDRESS Base;
- Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&gDebugImageTableHeader); - if (EFI_ERROR (Status)) { - gDebugImageTableHeader = NULL; - } + Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&gDebugImageTableHeader);
+ if (EFI_ERROR (Status)) {
+ gDebugImageTableHeader = NULL;
+ }
//
// Disable interrupts
diff --git a/ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.c b/ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.c new file mode 100644 index 0000000..2e44c62 --- /dev/null +++ b/ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.c @@ -0,0 +1,109 @@ +/**@file
+
+Copyright (c) 2006 - 2009, Intel Corporation
+Portions copyright (c) 2008-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.
+
+
+
+**/
+
+#include <PiDxe.h>
+#include <Library/PeCoffLib.h>
+
+#include <Library/BaseLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/PeCoffExtraActionLib.h>
+#include <Library/SerialPortLib.h>
+#include <Library/PrintLib.h>
+
+
+VOID
+DeCygwinIfNeeded (
+ IN CHAR8 *Name
+ )
+{
+ CHAR8 *Ptr;
+ UINTN Index;
+ UINTN Len;
+
+ Ptr = AsciiStrStr (Name, "/cygdrive/");
+ if (Ptr == NULL) {
+ return;
+ }
+
+ Len = AsciiStrLen (Ptr);
+
+ // convert "/cygdrive" to spaces
+ for (Index = 0; Index < 9; Index++) {
+ Ptr[Index] = ' ';
+ }
+
+ // convert /c to c:
+ Ptr[9] = Ptr[10];
+ Ptr[10] = ':';
+
+ // switch path seperators
+ for (Index = 11; Index < Len; Index++) {
+ if (Ptr[Index] == '/') {
+ Ptr[Index] = '\\' ;
+ }
+ }
+}
+
+
+/**
+ Performs additional actions after a PE/COFF image has been loaded and relocated.
+
+ If ImageContext is NULL, then ASSERT().
+
+ @param ImageContext Pointer to the image context structure that describes the
+ PE/COFF image that has already been loaded and relocated.
+
+**/
+VOID
+EFIAPI
+PeCoffLoaderRelocateImageExtraAction (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+{
+ CHAR8 Buffer[256];
+
+ AsciiSPrint (Buffer, sizeof(Buffer), "load /a /ni /np %a &0x%08x\n", ImageContext->PdbPointer, (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders));
+ DeCygwinIfNeeded (&Buffer[16]);
+
+ SerialPortWrite ((UINT8 *) Buffer, AsciiStrLen (Buffer));
+}
+
+
+
+/**
+ Performs additional actions just before a PE/COFF image is unloaded. Any resources
+ that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
+
+ If ImageContext is NULL, then ASSERT().
+
+ @param ImageContext Pointer to the image context structure that describes the
+ PE/COFF image that is being unloaded.
+
+**/
+VOID
+EFIAPI
+PeCoffLoaderUnloadImageExtraAction (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+{
+ CHAR8 Buffer[256];
+
+ AsciiSPrint (Buffer, sizeof(Buffer), "unload symbols_only %a", ImageContext->PdbPointer);
+ DeCygwinIfNeeded (Buffer);
+
+ SerialPortWrite ((UINT8 *) Buffer, AsciiStrLen (Buffer));
+}
diff --git a/ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.inf b/ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.inf new file mode 100644 index 0000000..947fcf4 --- /dev/null +++ b/ArmPkg/Library/RviPeCoffExtraActionLib/RviPeCoffExtraActionLib.inf @@ -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 |