• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2 
3 Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
4 This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution.  The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8 
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 
12 
13 **/
14 
15 #include "Edb.h"
16 
17 /**
18 
19   DebuggerCommand - Register.
20 
21   @param  CommandArg      - The argument for this command
22   @param  DebuggerPrivate - EBC Debugger private data structure
23   @param  ExceptionType   - Exception type.
24   @param  SystemContext   - EBC system context.
25 
26   @retval EFI_DEBUG_CONTINUE - formal return value
27 
28 **/
29 EFI_DEBUG_STATUS
DebuggerRegister(IN CHAR16 * CommandArg,IN EFI_DEBUGGER_PRIVATE_DATA * DebuggerPrivate,IN EFI_EXCEPTION_TYPE ExceptionType,IN OUT EFI_SYSTEM_CONTEXT SystemContext)30 DebuggerRegister (
31   IN     CHAR16                    *CommandArg,
32   IN     EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
33   IN     EFI_EXCEPTION_TYPE        ExceptionType,
34   IN OUT EFI_SYSTEM_CONTEXT        SystemContext
35   )
36 {
37   CHAR16  *RegName;
38   CHAR16  *RegValStr;
39   UINT64  RegVal;
40 
41   //
42   // Check Argument, NULL means print all register
43   //
44   if (CommandArg == 0) {
45     EDBPrint (
46       L"  R0 - 0x%016lx, R1 - 0x%016lx\n",
47       SystemContext.SystemContextEbc->R0,
48       SystemContext.SystemContextEbc->R1
49       );
50     EDBPrint (
51       L"  R2 - 0x%016lx, R3 - 0x%016lx\n",
52       SystemContext.SystemContextEbc->R2,
53       SystemContext.SystemContextEbc->R3
54       );
55     EDBPrint (
56       L"  R4 - 0x%016lx, R5 - 0x%016lx\n",
57       SystemContext.SystemContextEbc->R4,
58       SystemContext.SystemContextEbc->R5
59       );
60     EDBPrint (
61       L"  R6 - 0x%016lx, R7 - 0x%016lx\n",
62       SystemContext.SystemContextEbc->R6,
63       SystemContext.SystemContextEbc->R7
64       );
65     EDBPrint (
66       L"  Flags - 0x%016lx, ControlFlags - 0x%016lx\n",
67       SystemContext.SystemContextEbc->Flags,
68       SystemContext.SystemContextEbc->ControlFlags
69       );
70     EDBPrint (
71       L"  Ip - 0x%016lx\n",
72       SystemContext.SystemContextEbc->Ip
73       );
74     return EFI_DEBUG_CONTINUE;
75   }
76 
77   //
78   // Get register name
79   //
80   RegName = CommandArg;
81   //
82   // Get register value
83   //
84   RegValStr = StrGetNextTokenLine (L" ");
85   if (RegValStr == NULL) {
86     EDBPrint (L"Invalid Register Value\n");
87     return EFI_DEBUG_CONTINUE;
88   }
89   RegVal = LXtoi (RegValStr);
90 
91   //
92   // Assign register value
93   //
94   if (StriCmp (RegName, L"R0") == 0) {
95     SystemContext.SystemContextEbc->R0 = RegVal;
96   } else if (StriCmp (RegName, L"R1") == 0) {
97     SystemContext.SystemContextEbc->R1 = RegVal;
98   } else if (StriCmp (RegName, L"R2") == 0) {
99     SystemContext.SystemContextEbc->R2 = RegVal;
100   } else if (StriCmp (RegName, L"R3") == 0) {
101     SystemContext.SystemContextEbc->R3 = RegVal;
102   } else if (StriCmp (RegName, L"R4") == 0) {
103     SystemContext.SystemContextEbc->R4 = RegVal;
104   } else if (StriCmp (RegName, L"R5") == 0) {
105     SystemContext.SystemContextEbc->R5 = RegVal;
106   } else if (StriCmp (RegName, L"R6") == 0) {
107     SystemContext.SystemContextEbc->R6 = RegVal;
108   } else if (StriCmp (RegName, L"R7") == 0) {
109     SystemContext.SystemContextEbc->R7 = RegVal;
110   } else if (StriCmp (RegName, L"Flags") == 0) {
111     SystemContext.SystemContextEbc->Flags = RegVal;
112   } else if (StriCmp (RegName, L"ControlFlags") == 0) {
113     SystemContext.SystemContextEbc->ControlFlags = RegVal;
114   } else if (StriCmp (RegName, L"Ip") == 0) {
115     SystemContext.SystemContextEbc->Ip = RegVal;
116   } else {
117     EDBPrint (L"Invalid Register - %s\n", RegName);
118   }
119 
120   //
121   // Done
122   //
123   return EFI_DEBUG_CONTINUE;
124 }
125