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