/** @file\r
*\r
-* Copyright (c) 2011, ARM Limited. All rights reserved.\r
+* Copyright (c) 2011-2012, 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
#include <Library/PeCoffGetEntryPointLib.h>\r
#include <Library/PerformanceLib.h>\r
#include <Library/TimerLib.h>\r
+#include <Library/BdsLib.h>\r
\r
#include <Guid/DebugImageInfoTable.h>\r
\r
#include <Protocol/DebugSupport.h>\r
#include <Protocol/LoadedImage.h>\r
+#include <Protocol/DevicePathToText.h>\r
\r
EFI_STATUS\r
EblDumpMmu (\r
IN UINTN Argc,\r
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
@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
+ Argv[0] is the command name\r
\r
@return EFI_SUCCESS\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
Status = EfiGetSystemConfigurationTable (&gEfiDebugImageInfoTableGuid, (VOID **)&DebugImageTableHeader);\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
+ Argv[0] is the command name\r
\r
@return EFI_SUCCESS\r
\r
}\r
\r
\r
-CHAR8 *mTokenList[] = {\r
+STATIC CHAR8 *mTokenList[] = {\r
/*"SEC",*/\r
"PEI",\r
"DXE",\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
+ Argv[0] is the command name\r
\r
@return EFI_SUCCESS\r
\r
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
// 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
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
IN CHAR8 **Argv\r
)\r
{\r
- EFI_STATUS Status;\r
- UINTN NumberOfDescriptors;\r
- UINTN i;\r
- EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;\r
- EFI_GCD_IO_SPACE_DESCRIPTOR *IoSpaceMap;\r
-\r
- Status = gDS->GetMemorySpaceMap(&NumberOfDescriptors,&MemorySpaceMap);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- AsciiPrint (" Address Range Image Device Attributes\n");\r
- AsciiPrint ("__________________________________________________________\n");\r
- for (i=0; i < NumberOfDescriptors; i++) {\r
- //AsciiPrint ("%016lx - %016lx",MemorySpaceMap[i].BaseAddress,MemorySpaceMap[i].BaseAddress+MemorySpaceMap[i].Length);\r
- AsciiPrint ("MEM %08lx - %08lx",(UINT64)MemorySpaceMap[i].BaseAddress,MemorySpaceMap[i].BaseAddress+MemorySpaceMap[i].Length-1);\r
- AsciiPrint (" %08x %08x",MemorySpaceMap[i].ImageHandle,MemorySpaceMap[i].DeviceHandle);\r
-\r
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_RUNTIME)\r
- AsciiPrint (" RUNTIME");\r
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_PORT_IO)\r
- AsciiPrint (" PORT_IO");\r
-\r
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_UC)\r
- AsciiPrint (" MEM_UC");\r
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_WC)\r
- AsciiPrint (" MEM_WC");\r
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_WT)\r
- AsciiPrint (" MEM_WT");\r
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_WB)\r
- AsciiPrint (" MEM_WB");\r
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_UCE)\r
- AsciiPrint (" MEM_UCE");\r
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_WP)\r
- AsciiPrint (" MEM_WP");\r
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_RP)\r
- AsciiPrint (" MEM_RP");\r
- if (MemorySpaceMap[i].Attributes & EFI_MEMORY_XP)\r
- AsciiPrint (" MEM_XP");\r
-\r
- if (MemorySpaceMap[i].GcdMemoryType & EfiGcdMemoryTypeNonExistent)\r
- AsciiPrint (" TYPE_NONEXISTENT");\r
- if (MemorySpaceMap[i].GcdMemoryType & EfiGcdMemoryTypeReserved)\r
- AsciiPrint (" TYPE_RESERVED");\r
- if (MemorySpaceMap[i].GcdMemoryType & EfiGcdMemoryTypeSystemMemory)\r
- AsciiPrint (" TYPE_SYSMEM");\r
- if (MemorySpaceMap[i].GcdMemoryType & EfiGcdMemoryTypeMemoryMappedIo)\r
- AsciiPrint (" TYPE_MEMMAP");\r
-\r
- AsciiPrint ("\n");\r
- }\r
+ EFI_STATUS Status;\r
+ UINTN NumberOfDescriptors;\r
+ UINTN i;\r
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;\r
+ EFI_GCD_IO_SPACE_DESCRIPTOR *IoSpaceMap;\r
\r
- Status = gDS->GetIoSpaceMap(&NumberOfDescriptors,&IoSpaceMap);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
- for (i=0; i < NumberOfDescriptors; i++) {\r
- AsciiPrint ("IO %08lx - %08lx",IoSpaceMap[i].BaseAddress,IoSpaceMap[i].BaseAddress+IoSpaceMap[i].Length);\r
- AsciiPrint ("\t%08x %08x",IoSpaceMap[i].ImageHandle,IoSpaceMap[i].DeviceHandle);\r
-\r
- if (IoSpaceMap[i].GcdIoType & EfiGcdMemoryTypeNonExistent)\r
- AsciiPrint (" TYPE_NONEXISTENT");\r
- if (IoSpaceMap[i].GcdIoType & EfiGcdMemoryTypeReserved)\r
- AsciiPrint (" TYPE_RESERVED");\r
- if (IoSpaceMap[i].GcdIoType & EfiGcdIoTypeIo)\r
- AsciiPrint (" TYPE_IO");\r
-\r
- AsciiPrint ("\n");\r
- }\r
+ Status = gDS->GetMemorySpaceMap(&NumberOfDescriptors,&MemorySpaceMap);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ AsciiPrint (" Address Range Image Device Attributes\n");\r
+ AsciiPrint ("__________________________________________________________\n");\r
+ for (i=0; i < NumberOfDescriptors; i++) {\r
+ AsciiPrint ("MEM %016lx - %016lx",(UINT64)MemorySpaceMap[i].BaseAddress,MemorySpaceMap[i].BaseAddress+MemorySpaceMap[i].Length-1);\r
+ AsciiPrint (" %08x %08x",MemorySpaceMap[i].ImageHandle,MemorySpaceMap[i].DeviceHandle);\r
+\r
+ if (MemorySpaceMap[i].Attributes & EFI_MEMORY_RUNTIME)\r
+ AsciiPrint (" RUNTIME");\r
+ if (MemorySpaceMap[i].Attributes & EFI_MEMORY_PORT_IO)\r
+ AsciiPrint (" PORT_IO");\r
+\r
+ if (MemorySpaceMap[i].Attributes & EFI_MEMORY_UC)\r
+ AsciiPrint (" MEM_UC");\r
+ if (MemorySpaceMap[i].Attributes & EFI_MEMORY_WC)\r
+ AsciiPrint (" MEM_WC");\r
+ if (MemorySpaceMap[i].Attributes & EFI_MEMORY_WT)\r
+ AsciiPrint (" MEM_WT");\r
+ if (MemorySpaceMap[i].Attributes & EFI_MEMORY_WB)\r
+ AsciiPrint (" MEM_WB");\r
+ if (MemorySpaceMap[i].Attributes & EFI_MEMORY_UCE)\r
+ AsciiPrint (" MEM_UCE");\r
+ if (MemorySpaceMap[i].Attributes & EFI_MEMORY_WP)\r
+ AsciiPrint (" MEM_WP");\r
+ if (MemorySpaceMap[i].Attributes & EFI_MEMORY_RP)\r
+ AsciiPrint (" MEM_RP");\r
+ if (MemorySpaceMap[i].Attributes & EFI_MEMORY_XP)\r
+ AsciiPrint (" MEM_XP");\r
+\r
+ if (MemorySpaceMap[i].GcdMemoryType & EfiGcdMemoryTypeNonExistent)\r
+ AsciiPrint (" TYPE_NONEXISTENT");\r
+ if (MemorySpaceMap[i].GcdMemoryType & EfiGcdMemoryTypeReserved)\r
+ AsciiPrint (" TYPE_RESERVED");\r
+ if (MemorySpaceMap[i].GcdMemoryType & EfiGcdMemoryTypeSystemMemory)\r
+ AsciiPrint (" TYPE_SYSMEM");\r
+ if (MemorySpaceMap[i].GcdMemoryType & EfiGcdMemoryTypeMemoryMappedIo)\r
+ AsciiPrint (" TYPE_MEMMAP");\r
+\r
+ AsciiPrint ("\n");\r
+ }\r
+\r
+ Status = gDS->GetIoSpaceMap(&NumberOfDescriptors,&IoSpaceMap);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ for (i=0; i < NumberOfDescriptors; i++) {\r
+ AsciiPrint ("IO %08lx - %08lx",IoSpaceMap[i].BaseAddress,IoSpaceMap[i].BaseAddress+IoSpaceMap[i].Length);\r
+ AsciiPrint ("\t%08x %08x",IoSpaceMap[i].ImageHandle,IoSpaceMap[i].DeviceHandle);\r
+\r
+ if (IoSpaceMap[i].GcdIoType & EfiGcdMemoryTypeNonExistent)\r
+ AsciiPrint (" TYPE_NONEXISTENT");\r
+ if (IoSpaceMap[i].GcdIoType & EfiGcdMemoryTypeReserved)\r
+ AsciiPrint (" TYPE_RESERVED");\r
+ if (IoSpaceMap[i].GcdIoType & EfiGcdIoTypeIo)\r
+ AsciiPrint (" TYPE_IO");\r
+\r
+ AsciiPrint ("\n");\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
+EFI_STATUS\r
+EblDevicePaths (\r
+ IN UINTN Argc,\r
+ IN CHAR8 **Argv\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ UINTN HandleCount;\r
+ EFI_HANDLE *HandleBuffer;\r
+ UINTN Index;\r
+ CHAR16* String;\r
+ EFI_DEVICE_PATH_PROTOCOL* DevicePathProtocol;\r
+ EFI_DEVICE_PATH_TO_TEXT_PROTOCOL* DevicePathToTextProtocol;\r
+\r
+ BdsConnectAllDrivers();\r
\r
+ Status = gBS->LocateProtocol(&gEfiDevicePathToTextProtocolGuid, NULL, (VOID **)&DevicePathToTextProtocol);\r
+ if (EFI_ERROR (Status)) {\r
+ AsciiPrint ("Did not find the DevicePathToTextProtocol.\n");\r
+ return EFI_SUCCESS;\r
+ }\r
+\r
+ Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiDevicePathProtocolGuid, NULL, &HandleCount, &HandleBuffer);\r
+ if (EFI_ERROR (Status)) {\r
+ AsciiPrint ("No device path found\n");\r
return EFI_SUCCESS;\r
+ }\r
+\r
+ 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
+ }\r
+\r
+ return EFI_SUCCESS;\r
}\r
\r
GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mLibCmdTemplate[] =\r
" dump MMU Table",\r
NULL,\r
EblDumpMmu\r
+ },\r
+ {\r
+ "devicepaths",\r
+ " 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