]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add a PE/COFF extra action lib that DEBUG prints the debugger command to load symbols...
authorandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 14 Apr 2010 21:52:26 +0000 (21:52 +0000)
committerandrewfish <andrewfish@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 14 Apr 2010 21:52:26 +0000 (21:52 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10373 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c [new file with mode: 0755]
ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf [new file with mode: 0755]
BeagleBoardPkg/BeagleBoardPkg.dsc
BeagleBoardPkg/Sec/Cache.c
BeagleBoardPkg/Sec/Sec.c
BeagleBoardPkg/Sec/Sec.inf

diff --git a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.c
new file mode 100755 (executable)
index 0000000..a1d3c06
--- /dev/null
@@ -0,0 +1,122 @@
+/**@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
+#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/PrintLib.h>\r
+\r
+\r
+/**\r
+  If the build is done on cygwin the paths are cygpaths. \r
+  /cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert\r
+  them to work with RVD commands\r
+\r
+  @param  Name  Path to convert if needed\r
+\r
+**/\r
+CHAR8 *\r
+DeCygwinPathIfNeeded (\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 Name;\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
+  return Name;\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
+#ifdef __CC_ARM\r
+  // Print out the command for the RVD debugger to load symbols for this image\r
+  DEBUG ((EFI_D_ERROR, "load /a /ni /np %a &0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r
+#elif __GNUC__\r
+  // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required\r
+  DEBUG ((EFI_D_ERROR, "add-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r
+#else\r
+  DEBUG ((EFI_D_ERROR, "Loading driver at 0x%11p EntryPoint=0x%11p ", (VOID *)(UINTN) ImageContext->ImageAddress, FUNCTION_ENTRY_POINT (ImageContext->EntryPoint)));\r
+#endif\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
+#ifdef __CC_ARM\r
+  // Print out the command for the RVD debugger to load symbols for this image\r
+  DEBUG ((EFI_D_ERROR, "unload symbols_only %a", DeCygwinPathIfNeeded (ImageContext->PdbPointer)));\r
+#elif __GNUC__\r
+  // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required\r
+  DEBUG ((EFI_D_ERROR, "remove-symbol-file %a 0x%08x\n", DeCygwinPathIfNeeded (ImageContext->PdbPointer), (UINTN)(ImageContext->ImageAddress + ImageContext->SizeOfHeaders)));\r
+#else\r
+  DEBUG ((EFI_D_ERROR, "Unloading %a", ImageContext->PdbPointer));\r
+#endif\r
+}\r
diff --git a/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf b/ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
new file mode 100755 (executable)
index 0000000..4b23c5b
--- /dev/null
@@ -0,0 +1,39 @@
+#/** @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                      = DebugUnixPeCoffExtraActionLib
+  FILE_GUID                      = C3E9448E-1726-42fb-9368-41F75B038C0C
+  MODULE_TYPE                    = BASE
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = PeCoffExtraActionLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+#  VALID_ARCHITECTURES           = ARM
+#
+
+[Sources.common]
+  DebugPeCoffExtraActionLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+
+[LibraryClasses]
+  DebugLib
index 9135a43a8c856159bbf1e7d5e18848d062a1f144..4ad5c16108d9d09352bc4e82f4578f3aa871a622 100644 (file)
@@ -37,7 +37,8 @@
   UncachedMemoryAllocationLib|ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.inf
 !else
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
-  UncachedMemoryAllocationLib|ArmPkg/Library/DebugUncachedMemoryAllocationLib/DebugUncachedMemoryAllocationLib.inf
+  UncachedMemoryAllocationLib|ArmPkg/Library/UncachedMemoryAllocationLib/UncachedMemoryAllocationLib.inf
+#  UncachedMemoryAllocationLib|ArmPkg/Library/DebugUncachedMemoryAllocationLib/DebugUncachedMemoryAllocationLib.inf
 !endif
 
   ArmLib|ArmPkg/Library/ArmLib/ArmV7/ArmV7Lib.inf
@@ -66,7 +67,8 @@
   # the version of RVD I have does not support scipts accessing system memory.
   #
 #  PeCoffExtraActionLib|ArmPkg/Library/RvdPeCoffExtraActionLib/RvdPeCoffExtraActionLib.inf
-  PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
+  PeCoffExtraActionLib|ArmPkg/Library/DebugPeCoffExtraActionLib/DebugPeCoffExtraActionLib.inf
+#  PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
 
   
   CacheMaintenanceLib|ArmPkg/Library/ArmCacheMaintenanceLib/ArmCacheMaintenanceLib.inf
   ArmDisassemblerLib|ArmPkg/Library/ArmDisassemblerLib/ArmDisassemblerLib.inf
   DebugAgentLib|MdeModulePkg/Library/DebugAgentLibNull/DebugAgentLibNull.inf
 
+  UsbLib|AppleCommonPkg/Library/AppleUsbLib/AppleUsbDxeLib.inf
 
 [LibraryClasses.common.SEC]
   ArmLib|ArmPkg/Library/ArmLib/ArmV7/ArmV7LibPrePi.inf
   gEfiMdePkgTokenSpaceGuid.PcdMaximumLinkedListLength|1000000
   gEfiMdePkgTokenSpaceGuid.PcdSpinLockTimeout|10000000
   gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue|0xAF
-  gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|0
+  gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|1
   gEfiMdePkgTokenSpaceGuid.PcdPostCodePropertyMask|0
   gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|320
 
 #  DEBUG_EVENT     0x00080000  // Event messages
 #  DEBUG_ERROR     0x80000000  // Error
 
-  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000004
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000000
 
   gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07
 
   MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
   MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
 
+  AppleCommonPkg/Bus/Pci/EhciDxe/Ehci.inf {
+    <PcdsFixedAtBuild>
+      gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x800fffff
+  }
+  AppleCommonPkg/Bus/Usb/UsbBotDxe/UsbBot.inf\r
+  AppleCommonPkg/Bus/Usb/UsbCbiDxe/Cbi0/UsbCbi0.inf\r
+  AppleCommonPkg/Bus/Usb/UsbCbiDxe/Cbi1/UsbCbi1.inf\r
+  AppleCommonPkg/Bus/Usb/UsbBusDxe/UsbBus.inf\r
+  AppleCommonPkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorage.inf\r
+
   #
   # Nand Flash
   #
index 12b585e7cf92fb42bf64c1389192990992354aa7..7bb3ba10bf80c17295b1e3f0d9c5c1eeeaf6b40f 100644 (file)
@@ -75,5 +75,5 @@ InitCache (
   \r
   ArmConfigureMmu (MemoryTable, &TranslationTableBase, &TranslationTableSize);\r
   \r
-  BuildMemoryAllocationHob((EFI_PHYSICAL_ADDRESS)(UINTN)TranslationTableBase, TranslationTableSize, EfiBootServicesData);\r
+  BuildMemoryAllocationHob((EFI_PHYSICAL_ADDRESS)(UINTN)TranslationTableBase, TranslationTableSize, EfiBootServicesData);
 }\r
index fa18038a9a055a3dec6cfa2267f2d67d1f85dbc0..a9bd00690f99b2076875e2b55b8814a3cc7f2571 100644 (file)
@@ -22,6 +22,7 @@
 #include <Library/OmapLib.h>\r
 #include <Library/ArmLib.h>\r
 #include <Library/PeCoffGetEntryPointLib.h>\r
+#include <Library/DebugAgentLib.h>\r
 \r
 #include <Ppi/GuidedSectionExtraction.h>\r
 #include <Guid/LzmaDecompress.h>\r
 \r
 #include "LzmaDecompress.h"\r
 \r
-VOID\r
-EFIAPI \r
-_ModuleEntryPoint(\r
-  VOID\r
-  );\r
-\r
-CHAR8 *\r
-DeCygwinPathIfNeeded (\r
-  IN  CHAR8   *Name\r
-  );\r
-\r
 VOID\r
 PadConfiguration (\r
   VOID\r
@@ -50,6 +40,7 @@ ClockInit (
   VOID\r
   );\r
 \r
+\r
 VOID\r
 TimerInit (\r
   VOID\r
@@ -59,8 +50,7 @@ TimerInit (
   UINT32 TimerBaseAddress = TimerBase(Timer);\r
 \r
   // Set source clock for GPT3 & GPT4 to SYS_CLK\r
-  MmioOr32(CM_CLKSEL_PER, CM_CLKSEL_PER_CLKSEL_GPT3_SYS \r
-                          | CM_CLKSEL_PER_CLKSEL_GPT4_SYS);\r
+  MmioOr32 (CM_CLKSEL_PER, CM_CLKSEL_PER_CLKSEL_GPT3_SYS | CM_CLKSEL_PER_CLKSEL_GPT4_SYS);\r
 \r
   // Set count & reload registers\r
   MmioWrite32 (TimerBaseAddress + GPTIMER_TCRR, 0x00000000);\r
@@ -127,52 +117,6 @@ LzmaDecompressLibConstructor (
   VOID\r
   );\r
 \r
-/**\r
-  If the build is done on cygwin the paths are cygpaths. \r
-  /cygdrive/c/tmp.txt vs c:\tmp.txt so we need to convert\r
-  them to work with RVD commands\r
-\r
-  This is just code to help print out RVD symbol load command.\r
-  If you build with cygwin paths aren't compatible with RVD.\r
-\r
-  @param  Name  Path to convert if needed\r
-\r
-**/\r
-CHAR8 *\r
-SecDeCygwinPathIfNeeded (\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 Name;\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
-  return Name;\r
-}\r
-\r
 \r
 VOID\r
 CEntryPoint (\r
@@ -209,52 +153,11 @@ CEntryPoint (
 \r
   // Start talking\r
   UartInit ();\r
-  DEBUG ((EFI_D_ERROR, "UART Enabled\n"));\r
-\r
-  DEBUG_CODE_BEGIN ();\r
-    //\r
-    // On a debug build print out information about the SEC. This is really info about\r
-    // the PE/COFF file we are currently running from. Useful for loading symbols in a\r
-    // debugger. Remember our image is really part of the FV.\r
-    //\r
-    RETURN_STATUS       Status;\r
-    EFI_PEI_FV_HANDLE   VolumeHandle;\r
-    EFI_PEI_FILE_HANDLE FileHandle;\r
-    VOID                *PeCoffImage;\r
-    UINT32              Offset;\r
-    CHAR8               *FilePath;\r
-    FfsAnyFvFindFirstFile (EFI_FV_FILETYPE_SECURITY_CORE, &VolumeHandle, &FileHandle);\r
-    Status = FfsFindSectionData (EFI_SECTION_TE, FileHandle, &PeCoffImage);\r
-    if (EFI_ERROR (Status)) {\r
-      // Usually is a TE (PI striped down PE/COFF), but could be a full PE/COFF\r
-      Status = FfsFindSectionData (EFI_SECTION_PE32, FileHandle, &PeCoffImage);\r
-    }\r
-    if (!EFI_ERROR (Status)) {\r
-      Offset = PeCoffGetSizeOfHeaders (PeCoffImage);\r
-      FilePath = PeCoffLoaderGetPdbPointer (PeCoffImage);\r
-      if (FilePath != NULL) {\r
-      \r
-        // \r
-        // In general you should never have to use #ifdef __CC_ARM in the code. It\r
-        // is hidden in the away in the MdePkg. But here we would like to print differnt things\r
-        // for different toolchains. \r
-        //\r
-#ifdef __CC_ARM\r
-        // Print out the command for the RVD debugger to load symbols for this image\r
-        DEBUG ((EFI_D_ERROR, "load /a /ni /np %a &0x%08x\n", SecDeCygwinPathIfNeeded (FilePath), (CHAR8 *)PeCoffImage + Offset));\r
-#elif __GNUC__\r
-        // This may not work correctly if you generate PE/COFF directlyas then the Offset would not be required\r
-        DEBUG ((EFI_D_ERROR, "add-symbol-file %a 0x%08x\n", FilePath, PeCoffImage + Offset));\r
-#else\r
-        DEBUG ((EFI_D_ERROR, "SEC starts at 0x%08x with an entry point at 0x%08x %a\n", PeCoffImage, _ModuleEntryPoint, FilePath));\r
-#endif\r
-      }\r
-    }\r
-\r
-   \r
-  DEBUG_CODE_END ();\r
-\r
\r
+  InitializeDebugAgent (DEBUG_AGENT_INIT_PREMEM_SEC, NULL);\r
+  SaveAndSetDebugTimerInterrupt (TRUE);\r
 \r
+  DEBUG ((EFI_D_ERROR, "UART Enabled\n"));\r
 \r
   // Start up a free running time so that the timer lib will work\r
   TimerInit ();\r
index ff48d3bfc041e7f0fc4ef2789d2cec6572f283b7..435975db70d9a12a3b54338a798da4567a235814 100644 (file)
@@ -48,6 +48,7 @@
   LzmaDecompressLib
   OmapLib
   PeCoffGetEntryPointLib
+  DebugAgentLib
 
 [FeaturePcd]  
   gEmbeddedTokenSpaceGuid.PcdCacheEnable