summaryrefslogtreecommitdiffstats
path: root/src/VBox/Devices/EFI/Firmware/MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdRegister.c
blob: 7f023724bf8e0a992f2a2fb94f67b79539f7d64a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/** @file

Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent


**/

#include "Edb.h"

/**

  DebuggerCommand - Register.

  @param  CommandArg      - The argument for this command
  @param  DebuggerPrivate - EBC Debugger private data structure
  @param  ExceptionType   - Exception type.
  @param  SystemContext   - EBC system context.

  @retval EFI_DEBUG_CONTINUE - formal return value

**/
EFI_DEBUG_STATUS
DebuggerRegister (
  IN     CHAR16                    *CommandArg,
  IN     EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
  IN     EFI_EXCEPTION_TYPE        ExceptionType,
  IN OUT EFI_SYSTEM_CONTEXT        SystemContext
  )
{
  CHAR16  *RegName;
  CHAR16  *RegValStr;
  UINT64  RegVal;

  //
  // Check Argument, NULL means print all register
  //
  if (CommandArg == 0) {
    EDBPrint (
      L"  R0 - 0x%016lx, R1 - 0x%016lx\n",
      SystemContext.SystemContextEbc->R0,
      SystemContext.SystemContextEbc->R1
      );
    EDBPrint (
      L"  R2 - 0x%016lx, R3 - 0x%016lx\n",
      SystemContext.SystemContextEbc->R2,
      SystemContext.SystemContextEbc->R3
      );
    EDBPrint (
      L"  R4 - 0x%016lx, R5 - 0x%016lx\n",
      SystemContext.SystemContextEbc->R4,
      SystemContext.SystemContextEbc->R5
      );
    EDBPrint (
      L"  R6 - 0x%016lx, R7 - 0x%016lx\n",
      SystemContext.SystemContextEbc->R6,
      SystemContext.SystemContextEbc->R7
      );
    EDBPrint (
      L"  Flags - 0x%016lx, ControlFlags - 0x%016lx\n",
      SystemContext.SystemContextEbc->Flags,
      SystemContext.SystemContextEbc->ControlFlags
      );
    EDBPrint (
      L"  Ip - 0x%016lx\n",
      SystemContext.SystemContextEbc->Ip
      );
    return EFI_DEBUG_CONTINUE;
  }

  //
  // Get register name
  //
  RegName = CommandArg;
  //
  // Get register value
  //
  RegValStr = StrGetNextTokenLine (L" ");
  if (RegValStr == NULL) {
    EDBPrint (L"Invalid Register Value\n");
    return EFI_DEBUG_CONTINUE;
  }
  RegVal = LXtoi (RegValStr);

  //
  // Assign register value
  //
  if (StriCmp (RegName, L"R0") == 0) {
    SystemContext.SystemContextEbc->R0 = RegVal;
  } else if (StriCmp (RegName, L"R1") == 0) {
    SystemContext.SystemContextEbc->R1 = RegVal;
  } else if (StriCmp (RegName, L"R2") == 0) {
    SystemContext.SystemContextEbc->R2 = RegVal;
  } else if (StriCmp (RegName, L"R3") == 0) {
    SystemContext.SystemContextEbc->R3 = RegVal;
  } else if (StriCmp (RegName, L"R4") == 0) {
    SystemContext.SystemContextEbc->R4 = RegVal;
  } else if (StriCmp (RegName, L"R5") == 0) {
    SystemContext.SystemContextEbc->R5 = RegVal;
  } else if (StriCmp (RegName, L"R6") == 0) {
    SystemContext.SystemContextEbc->R6 = RegVal;
  } else if (StriCmp (RegName, L"R7") == 0) {
    SystemContext.SystemContextEbc->R7 = RegVal;
  } else if (StriCmp (RegName, L"Flags") == 0) {
    SystemContext.SystemContextEbc->Flags = RegVal;
  } else if (StriCmp (RegName, L"ControlFlags") == 0) {
    SystemContext.SystemContextEbc->ControlFlags = RegVal;
  } else if (StriCmp (RegName, L"Ip") == 0) {
    SystemContext.SystemContextEbc->Ip = RegVal;
  } else {
    EDBPrint (L"Invalid Register - %s\n", RegName);
  }

  //
  // Done
  //
  return EFI_DEBUG_CONTINUE;
}