]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdRegister.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / EbcDebugger / EdbCmdRegister.c
1 /** @file
2
3 Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
4 SPDX-License-Identifier: BSD-2-Clause-Patent
5
6
7 **/
8
9 #include "Edb.h"
10
11 /**
12
13 DebuggerCommand - Register.
14
15 @param CommandArg - The argument for this command
16 @param DebuggerPrivate - EBC Debugger private data structure
17 @param ExceptionType - Exception type.
18 @param SystemContext - EBC system context.
19
20 @retval EFI_DEBUG_CONTINUE - formal return value
21
22 **/
23 EFI_DEBUG_STATUS
24 DebuggerRegister (
25 IN CHAR16 *CommandArg,
26 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
27 IN EFI_EXCEPTION_TYPE ExceptionType,
28 IN OUT EFI_SYSTEM_CONTEXT SystemContext
29 )
30 {
31 CHAR16 *RegName;
32 CHAR16 *RegValStr;
33 UINT64 RegVal;
34
35 //
36 // Check Argument, NULL means print all register
37 //
38 if (CommandArg == 0) {
39 EDBPrint (
40 L" R0 - 0x%016lx, R1 - 0x%016lx\n",
41 SystemContext.SystemContextEbc->R0,
42 SystemContext.SystemContextEbc->R1
43 );
44 EDBPrint (
45 L" R2 - 0x%016lx, R3 - 0x%016lx\n",
46 SystemContext.SystemContextEbc->R2,
47 SystemContext.SystemContextEbc->R3
48 );
49 EDBPrint (
50 L" R4 - 0x%016lx, R5 - 0x%016lx\n",
51 SystemContext.SystemContextEbc->R4,
52 SystemContext.SystemContextEbc->R5
53 );
54 EDBPrint (
55 L" R6 - 0x%016lx, R7 - 0x%016lx\n",
56 SystemContext.SystemContextEbc->R6,
57 SystemContext.SystemContextEbc->R7
58 );
59 EDBPrint (
60 L" Flags - 0x%016lx, ControlFlags - 0x%016lx\n",
61 SystemContext.SystemContextEbc->Flags,
62 SystemContext.SystemContextEbc->ControlFlags
63 );
64 EDBPrint (
65 L" Ip - 0x%016lx\n",
66 SystemContext.SystemContextEbc->Ip
67 );
68 return EFI_DEBUG_CONTINUE;
69 }
70
71 //
72 // Get register name
73 //
74 RegName = CommandArg;
75 //
76 // Get register value
77 //
78 RegValStr = StrGetNextTokenLine (L" ");
79 if (RegValStr == NULL) {
80 EDBPrint (L"Invalid Register Value\n");
81 return EFI_DEBUG_CONTINUE;
82 }
83 RegVal = LXtoi (RegValStr);
84
85 //
86 // Assign register value
87 //
88 if (StriCmp (RegName, L"R0") == 0) {
89 SystemContext.SystemContextEbc->R0 = RegVal;
90 } else if (StriCmp (RegName, L"R1") == 0) {
91 SystemContext.SystemContextEbc->R1 = RegVal;
92 } else if (StriCmp (RegName, L"R2") == 0) {
93 SystemContext.SystemContextEbc->R2 = RegVal;
94 } else if (StriCmp (RegName, L"R3") == 0) {
95 SystemContext.SystemContextEbc->R3 = RegVal;
96 } else if (StriCmp (RegName, L"R4") == 0) {
97 SystemContext.SystemContextEbc->R4 = RegVal;
98 } else if (StriCmp (RegName, L"R5") == 0) {
99 SystemContext.SystemContextEbc->R5 = RegVal;
100 } else if (StriCmp (RegName, L"R6") == 0) {
101 SystemContext.SystemContextEbc->R6 = RegVal;
102 } else if (StriCmp (RegName, L"R7") == 0) {
103 SystemContext.SystemContextEbc->R7 = RegVal;
104 } else if (StriCmp (RegName, L"Flags") == 0) {
105 SystemContext.SystemContextEbc->Flags = RegVal;
106 } else if (StriCmp (RegName, L"ControlFlags") == 0) {
107 SystemContext.SystemContextEbc->ControlFlags = RegVal;
108 } else if (StriCmp (RegName, L"Ip") == 0) {
109 SystemContext.SystemContextEbc->Ip = RegVal;
110 } else {
111 EDBPrint (L"Invalid Register - %s\n", RegName);
112 }
113
114 //
115 // Done
116 //
117 return EFI_DEBUG_CONTINUE;
118 }