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