]> git.proxmox.com Git - mirror_edk2.git/blame - BeagleBoardPkg/Library/EblCmdLib/EblCmdLib.c
Fix some disasm issues
[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
54 \r
55 if (Argc < 2) {\r
56 return EFI_INVALID_PARAMETER;\r
57 }\r
58 \r
59 Address = AsciiStrHexToUintn (Argv[1]);\r
77844905 60 Count = (Argc > 2) ? (UINT32)AsciiStrHexToUintn (Argv[2]) : 20;\r
f9f937d2 61\r
62 Ptr = (UINT8 *)(UINTN)Address; \r
77844905 63 do {\r
64 CurrentAddress = Ptr;\r
f9f937d2 65 DisassembleInstruction (&Ptr, TRUE, TRUE, Buffer, sizeof (Buffer));\r
77844905 66 AsciiPrint ("0x%08x: %a\n", CurrentAddress, Buffer);\r
67 } while (Count-- > 0);\r
68 \r
f9f937d2 69\r
6f72e28d 70 return EFI_SUCCESS;\r
71}\r
72\r
73\r
2ef2b01e
A
74GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mLibCmdTemplate[] =\r
75{\r
6f72e28d 76 {\r
f9f937d2 77 "disasm address [count]",\r
78 " disassemble count instructions",\r
6f72e28d 79 NULL,\r
f9f937d2 80 EblDisassembler\r
6f72e28d 81 }\r
2ef2b01e
A
82};\r
83\r
84\r
85VOID\r
86EblInitializeExternalCmd (\r
87 VOID\r
88 )\r
89{\r
90 EblAddCommands (mLibCmdTemplate, sizeof (mLibCmdTemplate)/sizeof (EBL_COMMAND_TABLE));\r
91 return;\r
92}\r