]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbCmdStep.c
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / EbcDebugger / EdbCmdStep.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 Check whether current IP is EBC CALL instruction (NOTE: CALLEX is exclusive)
14
15 @param Address - EBC IP address.
16
17 @retval TRUE - Current IP is EBC CALL instruction
18 @retval FALSE - Current IP is not EBC CALL instruction
19
20 **/
21 BOOLEAN
22 IsEBCCALL (
23 IN UINTN Address
24 )
25 {
26 if (GET_OPCODE(Address) != OPCODE_CALL) {
27 return FALSE;
28 }
29
30 if (GET_OPERANDS (Address) & OPERAND_M_NATIVE_CALL) {
31 return FALSE;
32 } else {
33 return TRUE;
34 }
35 }
36
37 /**
38
39 Check whether current IP is EBC RET instruction.
40
41 @param Address - EBC IP address.
42
43 @retval TRUE - Current IP is EBC RET instruction
44 @retval FALSE - Current IP is not EBC RET instruction
45
46 **/
47 BOOLEAN
48 IsEBCRET (
49 IN UINTN Address
50 )
51 {
52 if (GET_OPCODE(Address) != OPCODE_RET) {
53 return FALSE;
54 }
55
56 if (GET_OPERANDS (Address) != 0) {
57 return FALSE;
58 } else {
59 return TRUE;
60 }
61 }
62
63 /**
64
65 DebuggerCommand - StepInto.
66
67 @param CommandArg - The argument for this command
68 @param DebuggerPrivate - EBC Debugger private data structure
69 @param ExceptionType - Exception type.
70 @param SystemContext - EBC system context.
71
72 @retval EFI_DEBUG_CONTINUE - formal return value
73
74 **/
75 EFI_DEBUG_STATUS
76 DebuggerStepInto (
77 IN CHAR16 *CommandArg,
78 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
79 IN EFI_EXCEPTION_TYPE ExceptionType,
80 IN OUT EFI_SYSTEM_CONTEXT SystemContext
81 )
82 {
83 SystemContext.SystemContextEbc->Flags |= VMFLAGS_STEP;
84
85 return EFI_DEBUG_BREAK;
86 }
87
88 /**
89
90 DebuggerCommand - StepOver.
91
92 @param CommandArg - The argument for this command
93 @param DebuggerPrivate - EBC Debugger private data structure
94 @param ExceptionType - Exception type.
95 @param SystemContext - EBC system context.
96
97 @retval EFI_DEBUG_CONTINUE - formal return value
98
99 **/
100 EFI_DEBUG_STATUS
101 DebuggerStepOver (
102 IN CHAR16 *CommandArg,
103 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
104 IN EFI_EXCEPTION_TYPE ExceptionType,
105 IN OUT EFI_SYSTEM_CONTEXT SystemContext
106 )
107 {
108 if (IsEBCCALL((UINTN)SystemContext.SystemContextEbc->Ip)) {
109 //
110 // Check CALL (NOTE: CALLEX is exclusive)
111 //
112 DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_STEPOVER;
113 } else {
114 //
115 // Other instruction including CALLEX
116 //
117 SystemContext.SystemContextEbc->Flags |= VMFLAGS_STEP;
118 }
119
120 return EFI_DEBUG_BREAK;
121 }
122
123 /**
124
125 DebuggerCommand - StepOut.
126
127 @param CommandArg - The argument for this command
128 @param DebuggerPrivate - EBC Debugger private data structure
129 @param ExceptionType - Exception type.
130 @param SystemContext - EBC system context.
131
132 @retval EFI_DEBUG_CONTINUE - formal return value
133
134 **/
135 EFI_DEBUG_STATUS
136 DebuggerStepOut (
137 IN CHAR16 *CommandArg,
138 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
139 IN EFI_EXCEPTION_TYPE ExceptionType,
140 IN OUT EFI_SYSTEM_CONTEXT SystemContext
141 )
142 {
143 if (IsEBCRET((UINTN)SystemContext.SystemContextEbc->Ip)) {
144 //
145 // Check RET
146 //
147 SystemContext.SystemContextEbc->Flags |= VMFLAGS_STEP;
148 } else {
149 //
150 // Other instruction
151 //
152 DebuggerPrivate->FeatureFlags |= EFI_DEBUG_FLAG_EBC_STEPOUT;
153 }
154
155 return EFI_DEBUG_BREAK;
156 }