]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Library/EblCmdLib/EblCmdLib.c
ARM Packages: Removed trailing spaces
[mirror_edk2.git] / ArmPlatformPkg / Library / EblCmdLib / EblCmdLib.c
index b75dbfbb6fbd7dd30b8e97dd09016114700a89c7..899991062fc90518862ebbe191cd0acb00e44784 100644 (file)
@@ -1,14 +1,14 @@
 /** @file\r
 *\r
-*  Copyright (c) 2011, ARM Limited. All rights reserved.\r
-*  \r
-*  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
+*  Copyright (c) 2011-2013, ARM Limited. All rights reserved.\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
+*  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
@@ -43,16 +43,22 @@ EblDumpMmu (
   IN CHAR8  **Argv\r
   );\r
 \r
+EFI_STATUS\r
+EblDumpFdt (\r
+  IN UINTN  Argc,\r
+  IN CHAR8  **Argv\r
+  );\r
+\r
 /**\r
   Simple arm disassembler via a library\r
 \r
   Argv[0] - symboltable\r
-  Argv[1] - Optional qoted format string \r
+  Argv[1] - Optional qoted format string\r
   Argv[2] - Optional flag\r
 \r
   @param  Argc   Number of command arguments in Argv\r
-  @param  Argv   Array of strings that represent the parsed command line. \r
-                 Argv[0] is the comamnd name\r
+  @param  Argv   Array of strings that represent the parsed command line.\r
+                 Argv[0] is the command name\r
 \r
   @return EFI_SUCCESS\r
 \r
@@ -72,17 +78,21 @@ EblSymbolTable (
   UINT32                            PeCoffSizeOfHeaders;\r
   UINT32                            ImageBase;\r
   BOOLEAN                           Elf;\r
-  \r
+\r
   // Need to add lots of error checking on the passed in string\r
   // Default string is for RealView debugger\r
+#if (__ARMCC_VERSION < 500000)\r
   Format = (Argc > 1) ? Argv[1] : "load /a /ni /np %a &0x%x";\r
+#else\r
+  Format = (Argc > 1) ? Argv[1] : "add-symbol-file %a 0x%x";\r
+#endif\r
   Elf = (Argc > 2) ? FALSE : TRUE;\r
-  \r
+\r
   Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&DebugImageTableHeader);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
-  \r
+\r
   DebugTable = DebugImageTableHeader->EfiDebugImageInfoTable;\r
   if (DebugTable == NULL) {\r
     return EFI_SUCCESS;\r
@@ -91,20 +101,20 @@ EblSymbolTable (
   for (Entry = 0; Entry < DebugImageTableHeader->TableSize; Entry++, DebugTable++) {\r
     if (DebugTable->NormalImage != NULL) {\r
       if ((DebugTable->NormalImage->ImageInfoType == EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL) && (DebugTable->NormalImage->LoadedImageProtocolInstance != NULL)) {\r
-        ImageBase = (UINT32)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;\r
+        ImageBase = (UINTN)DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase;\r
         PeCoffSizeOfHeaders = PeCoffGetSizeOfHeaders ((VOID *)(UINTN)ImageBase);\r
         Pdb = PeCoffLoaderGetPdbPointer (DebugTable->NormalImage->LoadedImageProtocolInstance->ImageBase);\r
         if (Pdb != NULL) {\r
           if (Elf) {\r
             // ELF and Mach-O images don't include the header so the linked address does not include header\r
             ImageBase += PeCoffSizeOfHeaders;\r
-          } \r
+          }\r
           AsciiPrint (Format, Pdb, ImageBase);\r
           AsciiPrint ("\n");\r
         } else {\r
         }\r
       }\r
-    }  \r
+    }\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -119,7 +129,7 @@ EblSymbolTable (
   ARgv[2] - Number of instructions to disassembly (optional)\r
 \r
   @param  Argc   Number of command arguments in Argv\r
-  @param  Argv   Array of strings that represent the parsed command line. \r
+  @param  Argv   Array of strings that represent the parsed command line.\r
                  Argv[0] is the command name\r
 \r
   @return EFI_SUCCESS\r
@@ -136,22 +146,22 @@ EblDisassembler (
   UINT32  Count;\r
   CHAR8   Buffer[80];\r
   UINT32  ItBlock;\r
-  \r
+\r
   if (Argc < 2) {\r
     return EFI_INVALID_PARAMETER;\r
   }\r
-  \r
+\r
   Address = AsciiStrHexToUintn (Argv[1]);\r
   Count   = (Argc > 2) ? (UINT32)AsciiStrHexToUintn (Argv[2]) : 20;\r
 \r
-  Ptr = (UINT8 *)(UINTN)Address;  \r
+  Ptr = (UINT8 *)(UINTN)Address;\r
   ItBlock = 0;\r
   do {\r
     CurrentAddress = Ptr;\r
     DisassembleInstruction (&Ptr, TRUE, TRUE, &ItBlock, Buffer, sizeof (Buffer));\r
     AsciiPrint ("0x%08x: %a\n", CurrentAddress, Buffer);\r
   } while (Count-- > 0);\r
\r
+\r
 \r
   return EFI_SUCCESS;\r
 }\r
@@ -201,7 +211,7 @@ STATIC CHAR8 *mTokenList[] = {
   ARgv[2] - Number of instructions to disassembly (optional)\r
 \r
   @param  Argc   Number of command arguments in Argv\r
-  @param  Argv   Array of strings that represent the parsed command line. \r
+  @param  Argv   Array of strings that represent the parsed command line.\r
                  Argv[0] is the command name\r
 \r
   @return EFI_SUCCESS\r
@@ -219,8 +229,14 @@ EblPerformance (
   UINT64      Start, Stop, TimeStamp;\r
   UINT64      Delta, TicksPerSecond, Milliseconds, Microseconds;\r
   UINTN       Index;\r
+  BOOLEAN     CountUp;\r
 \r
-  TicksPerSecond = GetPerformanceCounterProperties (NULL, NULL);\r
+  TicksPerSecond = GetPerformanceCounterProperties (&Start, &Stop);\r
+  if (Start < Stop) {\r
+    CountUp = TRUE;\r
+  } else {\r
+    CountUp = FALSE;\r
+  }\r
 \r
   Key       = 0;\r
   do {\r
@@ -231,7 +247,7 @@ EblPerformance (
           // The entry for EBL is still running so the stop time will be zero. Skip it\r
           AsciiPrint ("   running     %a\n", ImageHandleToPdbFileName ((EFI_HANDLE)Handle));\r
         } else {\r
-          Delta = Start - Stop;\r
+          Delta =  CountUp?(Stop - Start):(Start - Stop);\r
           Microseconds = DivU64x64Remainder (MultU64x32 (Delta, 1000000), TicksPerSecond, NULL);\r
           AsciiPrint ("%10ld us  %a\n", Microseconds, ImageHandleToPdbFileName ((EFI_HANDLE)Handle));\r
         }\r
@@ -248,13 +264,13 @@ EblPerformance (
     if (Key != 0) {\r
       for (Index = 0; mTokenList[Index] != NULL; Index++) {\r
         if (AsciiStriCmp (mTokenList[Index], Token) == 0) {\r
-          Delta = Start - Stop;\r
+          Delta =  CountUp?(Stop - Start):(Start - Stop);\r
           TimeStamp += Delta;\r
           Milliseconds = DivU64x64Remainder (MultU64x32 (Delta, 1000), TicksPerSecond, NULL);\r
           AsciiPrint ("%6a %6ld ms\n", Token, Milliseconds);\r
           break;\r
         }\r
-      }   \r
+      }\r
     }\r
   } while (Key != 0);\r
 \r
@@ -321,6 +337,8 @@ EblDumpGcd (
     AsciiPrint ("\n");\r
   }\r
 \r
+  FreePool (MemorySpaceMap);\r
+\r
   Status = gDS->GetIoSpaceMap(&NumberOfDescriptors,&IoSpaceMap);\r
   if (EFI_ERROR (Status)) {\r
       return Status;\r
@@ -339,6 +357,8 @@ EblDumpGcd (
     AsciiPrint ("\n");\r
   }\r
 \r
+  FreePool (IoSpaceMap);\r
+\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -373,7 +393,7 @@ EblDevicePaths (
   for (Index = 0; Index < HandleCount; Index++) {\r
     Status = gBS->HandleProtocol (HandleBuffer[Index], &gEfiDevicePathProtocolGuid, (VOID **)&DevicePathProtocol);\r
     String = DevicePathToTextProtocol->ConvertDevicePathToText(DevicePathProtocol,TRUE,TRUE);\r
-    Print (L"[0x%X] %s\n",(UINT32)HandleBuffer[Index], String);\r
+    Print (L"[0x%X] %s\n",(UINTN)HandleBuffer[Index], String);\r
   }\r
 \r
   return EFI_SUCCESS;\r
@@ -416,6 +436,12 @@ GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mLibCmdTemplate[] =
     " list all the Device Paths",\r
     NULL,\r
     EblDevicePaths\r
+  },\r
+  {\r
+    "dumpfdt",\r
+    " dump the current fdt or the one defined in the arguments",\r
+    NULL,\r
+    EblDumpFdt\r
   }\r
 };\r
 \r