]> git.proxmox.com Git - mirror_edk2.git/blame - BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.c
Update input of disasmembler to support IfThen construct. Add prototype dos script...
[mirror_edk2.git] / BeagleBoardPkg / Library / EblCmdLib / EblCmdLib.c
CommitLineData
2ef2b01e
A
1/** @file\r
2 Add custom commands for BeagleBoard development.\r
3\r
4 Copyright (c) 2008-2009, Apple Inc. All rights reserved.\r
5 \r
6 All rights reserved. This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#include <PiDxe.h>\r
17#include <Library/ArmLib.h>\r
18#include <Library/CacheMaintenanceLib.h>\r
19#include <Library/EblCmdLib.h>\r
20#include <Library/BaseLib.h>\r
21#include <Library/DebugLib.h>\r
22#include <Library/UefiBootServicesTableLib.h>\r
23#include <Library/UefiRuntimeServicesTableLib.h>\r
24#include <Library/MemoryAllocationLib.h>\r
25#include <Library/UefiLib.h>\r
26#include <Library/PcdLib.h>\r
27#include <Library/EfiFileLib.h>\r
f9f937d2 28#include <Library/ArmDisassemblerLib.h>\r
2ef2b01e 29\r
6f72e28d 30//PcdEmbeddedFdBaseAddress\r
31\r
32/**\r
33 Fill Me In\r
34\r
35 Argv[0] - "%CommandName%"\r
36\r
37 @param Argc Number of command arguments in Argv\r
38 @param Argv Array of strings that represent the parsed command line. \r
39 Argv[0] is the comamnd name\r
40\r
41 @return EFI_SUCCESS\r
42\r
43**/\r
44EFI_STATUS\r
f9f937d2 45EblDisassembler (\r
6f72e28d 46 IN UINTN Argc,\r
47 IN CHAR8 **Argv\r
48 )\r
49{\r
77844905 50 UINT8 *Ptr, *CurrentAddress;\r
f9f937d2 51 UINT32 Address;\r
52 UINT32 Count;\r
53 CHAR8 Buffer[80];\r
f3198cba 54 UINT32 ItBlock;\r
f9f937d2 55 \r
56 if (Argc < 2) {\r
57 return EFI_INVALID_PARAMETER;\r
58 }\r
59 \r
60 Address = AsciiStrHexToUintn (Argv[1]);\r
77844905 61 Count = (Argc > 2) ? (UINT32)AsciiStrHexToUintn (Argv[2]) : 20;\r
f9f937d2 62\r
63 Ptr = (UINT8 *)(UINTN)Address; \r
f3198cba 64 ItBlock = 0;\r
77844905 65 do {\r
66 CurrentAddress = Ptr;\r
f3198cba 67 DisassembleInstruction (&Ptr, TRUE, TRUE, &ItBlock, Buffer, sizeof (Buffer));\r
77844905 68 AsciiPrint ("0x%08x: %a\n", CurrentAddress, Buffer);\r
69 } while (Count-- > 0);\r
70 \r
f9f937d2 71\r
6f72e28d 72 return EFI_SUCCESS;\r
73}\r
74\r
75\r
2ef2b01e
A
76GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mLibCmdTemplate[] =\r
77{\r
6f72e28d 78 {\r
f9f937d2 79 "disasm address [count]",\r
80 " disassemble count instructions",\r
6f72e28d 81 NULL,\r
f9f937d2 82 EblDisassembler\r
6f72e28d 83 }\r
2ef2b01e
A
84};\r
85\r
86\r
87VOID\r
88EblInitializeExternalCmd (\r
89 VOID\r
90 )\r
91{\r
92 EblAddCommands (mLibCmdTemplate, sizeof (mLibCmdTemplate)/sizeof (EBL_COMMAND_TABLE));\r
93 return;\r
94}\r