TianoCore EDK2 master
Loading...
Searching...
No Matches
EdbCommon.h
Go to the documentation of this file.
1
8#ifndef _EFI_EDB_COMMON_H_
9#define _EFI_EDB_COMMON_H_
10
11#include <Uefi.h>
12#include <Library/BaseLib.h>
15#include <Library/DebugLib.h>
16#include <Library/UefiLib.h>
17#include <Library/PrintLib.h>
19#include <Protocol/Ebc.h>
20#include <Protocol/EbcVmTest.h>
25#include <Guid/FileInfo.h>
27
28typedef UINTN EFI_DEBUG_STATUS;
29
31
32//
33// Definition for Debugger Command
34//
35typedef
36EFI_DEBUG_STATUS
37(*EFI_DEBUGGER_COMMAND) (
38 IN CHAR16 *CommandArg,
39 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
40 IN EFI_EXCEPTION_TYPE ExceptionType,
41 IN OUT EFI_SYSTEM_CONTEXT SystemContext
42 );
43
44typedef struct {
45 CHAR16 *CommandName;
46 CHAR16 *CommandTitle;
47 CHAR16 *CommandHelp;
48 CHAR16 *CommandSyntax;
49 CHAR16 *ClassName;
50 EFI_INPUT_KEY CommandKey;
51 EFI_DEBUGGER_COMMAND CommandFunc;
53
54//
55// Definition for Debugger Symbol
56//
57#define EFI_DEBUGGER_SYMBOL_NAME_MAX 256
58#define EFI_DEBUGGER_SYMBOL_ENTRY_MAX 512
59#define EFI_DEBUGGER_SYMBOL_OBJECT_MAX 32
60
61//
62// We have following SYMBOL data structure:
63//
64// SYMBOL_CONTEXT -> SYMBOL_OBJECT -> SYMBOL_ENTRY (FuncXXX, 0xXXX)
65// SYMBOL_ENTRY (VarYYY, 0xYYY)
66// SYMBOL_ENTRY
67//
68// SYMBOL_OBJECT -> SYMBOL_ENTRY
69// SYMBOL_ENTRY
70//
71// SYMBOL_OBJECT -> SYMBOL_ENTRY
72// SYMBOL_ENTRY
73//
74
75typedef enum {
76 EfiDebuggerSymbolFunction,
77 EfiDebuggerSymbolStaticFunction,
78 EfiDebuggerSymbolGlobalVariable,
79 EfiDebuggerSymbolStaticVariable,
80 EfiDebuggerSymbolTypeMax,
81} EFI_DEBUGGER_SYMBOL_TYPE;
82
83typedef struct {
84 CHAR8 Name[EFI_DEBUGGER_SYMBOL_NAME_MAX];
85 UINTN Rva;
86 EFI_DEBUGGER_SYMBOL_TYPE Type;
87 CHAR8 ObjName[EFI_DEBUGGER_SYMBOL_NAME_MAX];
88 CHAR8 *CodBuffer;
89 UINTN CodBufferSize;
90 UINTN FuncOffsetBase;
91 CHAR8 *SourceBuffer;
93
94typedef struct {
95 CHAR16 Name[EFI_DEBUGGER_SYMBOL_NAME_MAX];
96 UINTN EntryCount;
97 UINTN MaxEntryCount;
98 UINTN BaseAddress;
99 UINTN StartEntrypointRVA;
100 UINTN MainEntrypointRVA;
102 VOID **SourceBuffer;
104
105typedef struct {
106 UINTN ObjectCount;
107 UINTN MaxObjectCount;
109 BOOLEAN DisplaySymbol;
110 BOOLEAN DisplayCodeOnly;
112
113//
114// Definition for Debugger Breakpoint
115//
116#define EFI_DEBUGGER_BREAKPOINT_MAX 0x10
117
118typedef struct {
119 EFI_PHYSICAL_ADDRESS BreakpointAddress;
120 UINT64 OldInstruction; // UINT64 is enough for an instruction
121 BOOLEAN State;
123
124//
125// Definition for Debugger Call-Stack
126//
127#define EFI_DEBUGGER_CALLSTACK_MAX 0x10
128
129typedef enum {
130 EfiDebuggerBranchTypeEbcCall,
131 EfiDebuggerBranchTypeEbcCallEx,
132 EfiDebuggerBranchTypeEbcRet,
133 EfiDebuggerBranchTypeEbcJmp,
134 EfiDebuggerBranchTypeEbcJmp8,
135 EfiDebuggerBranchTypeEbcMax,
136} EFI_DEBUGGER_BRANCH_TYPE;
137
138#define EFI_DEBUGGER_CALL_MAX_PARAMETER 0x16
139#define EFI_DEBUGGER_CALL_DEFAULT_PARAMETER 0x8
140
141typedef struct {
142 EFI_PHYSICAL_ADDRESS SourceAddress;
143 EFI_PHYSICAL_ADDRESS DestAddress;
144 //
145 // We save all parameter here, because code may update the parameter as local variable.
146 //
147 UINTN ParameterAddr;
148 UINTN Parameter[EFI_DEBUGGER_CALL_MAX_PARAMETER];
149 EFI_DEBUGGER_BRANCH_TYPE Type;
151
152//
153// Definition for Debugger Trace
154//
155#define EFI_DEBUGGER_TRACE_MAX 0x10
156
157typedef struct {
158 EFI_PHYSICAL_ADDRESS SourceAddress;
159 EFI_PHYSICAL_ADDRESS DestAddress;
160 EFI_DEBUGGER_BRANCH_TYPE Type;
162
163//
164// Definition for Debugger Step
165//
166typedef struct {
167 EFI_PHYSICAL_ADDRESS BreakAddress;
168 EFI_PHYSICAL_ADDRESS FramePointer;
170
171//
172// Definition for Debugger GoTil
173//
174typedef struct {
175 EFI_PHYSICAL_ADDRESS BreakAddress;
177
178//
179// Definition for Debugger private data structure
180//
181#define EFI_DEBUGGER_SIGNATURE SIGNATURE_32 ('e', 'd', 'b', '!')
182
183#define EFI_DEBUG_DEFAULT_INSTRUCTION_NUMBER 5
184
185#define EFI_DEBUG_BREAK_TIMER_INTERVAL 10000000 // 1 second
186
187#define EFI_DEBUG_FLAG_EBC 0x80000000
188#define EFI_DEBUG_FLAG_EBC_B_BOC 0x1
189#define EFI_DEBUG_FLAG_EBC_B_BOCX 0x2
190#define EFI_DEBUG_FLAG_EBC_B_BOR 0x4
191#define EFI_DEBUG_FLAG_EBC_B_BOE 0x8
192#define EFI_DEBUG_FLAG_EBC_B_BOT 0x10
193#define EFI_DEBUG_FLAG_EBC_B_STEPOVER 0x20
194#define EFI_DEBUG_FLAG_EBC_B_STEPOUT 0x40
195#define EFI_DEBUG_FLAG_EBC_B_BP 0x80
196#define EFI_DEBUG_FLAG_EBC_B_GT 0x100
197#define EFI_DEBUG_FLAG_EBC_B_BOK 0x200
198#define EFI_DEBUG_FLAG_EBC_BOC (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOC)
199#define EFI_DEBUG_FLAG_EBC_BOCX (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOCX)
200#define EFI_DEBUG_FLAG_EBC_BOR (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOR)
201#define EFI_DEBUG_FLAG_EBC_BOE (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOE)
202#define EFI_DEBUG_FLAG_EBC_BOT (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOT)
203#define EFI_DEBUG_FLAG_EBC_STEPOVER (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_STEPOVER)
204#define EFI_DEBUG_FLAG_EBC_STEPOUT (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_STEPOUT)
205#define EFI_DEBUG_FLAG_EBC_BP (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BP)
206#define EFI_DEBUG_FLAG_EBC_GT (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_GT)
207#define EFI_DEBUG_FLAG_EBC_BOK (EFI_DEBUG_FLAG_EBC | EFI_DEBUG_FLAG_EBC_B_BOK)
208
209//
210// Debugger private data structure
211//
213 UINT32 Signature;
215 UINT32 EfiDebuggerRevision;
216 UINT32 EbcVmRevision;
217 EFI_DEBUGGER_CONFIGURATION_PROTOCOL DebuggerConfiguration;
218 EFI_DEBUG_IMAGE_INFO_TABLE_HEADER *DebugImageInfoTableHeader;
220 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
221 EFI_DEBUGGER_COMMAND_SET *DebuggerCommandSet;
222 EFI_DEBUGGER_SYMBOL_CONTEXT DebuggerSymbolContext;
223 UINTN DebuggerBreakpointCount;
224 EFI_DEBUGGER_BREAKPOINT_CONTEXT DebuggerBreakpointContext[EFI_DEBUGGER_BREAKPOINT_MAX + 1];
225 UINTN CallStackEntryCount;
226 EFI_DEBUGGER_CALLSTACK_CONTEXT CallStackEntry[EFI_DEBUGGER_CALLSTACK_MAX + 1];
227 UINTN TraceEntryCount;
228 EFI_DEBUGGER_TRACE_CONTEXT TraceEntry[EFI_DEBUGGER_TRACE_MAX + 1];
229 EFI_DEBUGGER_STEP_CONTEXT StepContext;
230 EFI_DEBUGGER_GOTIL_CONTEXT GoTilContext;
231 EFI_PHYSICAL_ADDRESS InstructionScope;
232 UINTN InstructionNumber;
233 UINT32 FeatureFlags;
234 UINT32 StatusFlags;
235 BOOLEAN EnablePageBreak;
236 EFI_EVENT BreakEvent;
238
239#endif
UINT64 UINTN
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
INTN EFI_EXCEPTION_TYPE
Definition: DebugSupport.h:35
EFI_INSTRUCTION_SET_ARCHITECTURE
Definition: DebugSupport.h:836
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
VOID * EFI_EVENT
Definition: UefiBaseType.h:37