]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/EbcDxe/EbcDebugger/EdbDisasmSupport.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Universal / EbcDxe / EbcDebugger / EdbDisasmSupport.h
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 #ifndef _EFI_EDB_DISASM_SUPPORT_H_
10 #define _EFI_EDB_DISASM_SUPPORT_H_
11
12 #include <Uefi.h>
13
14 #define EDB_BYTECODE_NUMBER_IN_LINE 5
15
16 #ifdef EFI32
17 #define EDB_PRINT_ADDRESS_FORMAT L"%08x: "
18 #else
19 // To use 012l instead of 016l because space is not enough
20 #define EDB_PRINT_ADDRESS_FORMAT L"%012lx: "
21 #endif
22
23 #define OPCODE_MAX 0x40
24
25 #define EDB_INSTRUCTION_NAME_MAX_LENGTH 10
26 #define EDB_INSTRUCTION_NAME_MAX_SIZE (EDB_INSTRUCTION_NAME_MAX_LENGTH * sizeof(CHAR16))
27 #define EDB_INSTRUCTION_CONTENT_MAX_LENGTH 30
28 #define EDB_INSTRUCTION_CONTENT_MAX_SIZE (EDB_INSTRUCTION_CONTENT_MAX_LENGTH * sizeof(CHAR16))
29
30 /**
31
32 Set offset for Instruction name and content.
33
34 @param InstructionNameOffset - Instruction name offset
35 @param InstructionContentOffset - Instruction content offset
36
37 **/
38 VOID
39 EdbSetOffset (
40 IN UINTN InstructionNameOffset,
41 IN UINTN InstructionContentOffset
42 );
43
44 /**
45
46 Pre instruction string construction.
47
48 @return Instruction string
49
50 **/
51 CHAR16 *
52 EdbPreInstructionString (
53 VOID
54 );
55
56 /**
57
58 Post instruction string construction.
59
60 @return Instruction string
61
62 **/
63 CHAR16 *
64 EdbPostInstructionString (
65 VOID
66 );
67
68 /**
69
70 Print the instruction name.
71
72 @param Name - instruction name
73
74 @return Instruction name offset
75
76 **/
77 UINTN
78 EdbPrintInstructionName (
79 IN CHAR16 *Name
80 );
81
82 /**
83
84 Get Sign, NaturalUnits, and ConstantUnits of the WORD data.
85
86 @param Data16 - WORD data
87 @param NaturalUnits - Natural Units of the WORD
88 @param ConstantUnits - Constant Units of the WORD
89
90 @return Sign value of WORD
91
92 **/
93 BOOLEAN
94 EdbGetNaturalIndex16 (
95 IN UINT16 Data16,
96 OUT UINTN *NaturalUnits,
97 OUT UINTN *ConstantUnits
98 );
99
100 /**
101
102 Get Sign, NaturalUnits, and ConstantUnits of the DWORD data.
103
104 @param Data32 - DWORD data
105 @param NaturalUnits - Natural Units of the DWORD
106 @param ConstantUnits - Constant Units of the DWORD
107
108 @return Sign value of DWORD
109
110 **/
111 BOOLEAN
112 EdbGetNaturalIndex32 (
113 IN UINT32 Data32,
114 OUT UINTN *NaturalUnits,
115 OUT UINTN *ConstantUnits
116 );
117
118 /**
119
120 Get Sign, NaturalUnits, and ConstantUnits of the QWORD data.
121
122 @param Data64 - QWORD data
123 @param NaturalUnits - Natural Units of the QWORD
124 @param ConstantUnits - Constant Units of the QWORD
125
126 @return Sign value of QWORD
127
128 **/
129 BOOLEAN
130 EdbGetNaturalIndex64 (
131 IN UINT64 Data64,
132 OUT UINT64 *NaturalUnits,
133 OUT UINT64 *ConstantUnits
134 );
135
136 /**
137
138 Print the hexical WORD raw index data to instruction content.
139
140 @param Data16 - WORD data
141
142 @return Instruction content offset
143
144 **/
145 UINTN
146 EdbPrintRawIndexData16 (
147 IN UINT16 Data16
148 );
149
150 /**
151
152 Print the hexical DWORD raw index data to instruction content.
153
154 @param Data32 - DWORD data
155
156 @return Instruction content offset
157
158 **/
159 UINTN
160 EdbPrintRawIndexData32 (
161 IN UINT32 Data32
162 );
163
164 /**
165
166 Print the hexical QWORD raw index data to instruction content.
167
168 @param Data64 - QWORD data
169
170 @return Instruction content offset
171
172 **/
173 UINTN
174 EdbPrintRawIndexData64 (
175 IN UINT64 Data64
176 );
177
178 /**
179
180 Print register 1 in operands.
181
182 @param Operands - instruction operands
183
184 @return Instruction content offset
185
186 **/
187 UINTN
188 EdbPrintRegister1 (
189 IN UINT8 Operands
190 );
191
192 /**
193
194 Print register 2 in operands.
195
196 @param Operands - instruction operands
197
198 @return Instruction content offset
199
200 **/
201 UINTN
202 EdbPrintRegister2 (
203 IN UINT8 Operands
204 );
205
206 /**
207
208 Print dedicated register 1 in operands.
209
210 @param Operands - instruction operands
211
212 @return Instruction content offset
213
214 **/
215 UINTN
216 EdbPrintDedicatedRegister1 (
217 IN UINT8 Operands
218 );
219
220 /**
221
222 Print dedicated register 2 in operands.
223
224 @param Operands - instruction operands
225
226 @return Instruction content offset
227
228 **/
229 UINTN
230 EdbPrintDedicatedRegister2 (
231 IN UINT8 Operands
232 );
233
234 /**
235
236 Print the hexical UINTN index data to instruction content.
237
238 @param Sign - Signed bit of UINTN data
239 @param NaturalUnits - natural units of UINTN data
240 @param ConstantUnits - natural units of UINTN data
241
242 @return Instruction content offset
243
244 **/
245 UINTN
246 EdbPrintIndexData (
247 IN BOOLEAN Sign,
248 IN UINTN NaturalUnits,
249 IN UINTN ConstantUnits
250 );
251
252 /**
253
254 Print the hexical QWORD index data to instruction content.
255
256 @param Sign - Signed bit of QWORD data
257 @param NaturalUnits - natural units of QWORD data
258 @param ConstantUnits - natural units of QWORD data
259
260 @return Instruction content offset
261
262 **/
263 UINTN
264 EdbPrintIndexData64 (
265 IN BOOLEAN Sign,
266 IN UINT64 NaturalUnits,
267 IN UINT64 ConstantUnits
268 );
269
270 /**
271
272 Print the hexical BYTE immediate data to instruction content.
273
274 @param Data - BYTE data
275
276 @return Instruction content offset
277
278 **/
279 UINTN
280 EdbPrintImmData8 (
281 IN UINT8 Data
282 );
283
284 /**
285
286 Print the hexical WORD immediate data to instruction content.
287
288 @param Data - WORD data
289
290 @return Instruction content offset
291
292 **/
293 UINTN
294 EdbPrintImmData16 (
295 IN UINT16 Data
296 );
297
298 /**
299
300 Print the hexical DWORD immediate data to instruction content.
301
302 @param Data - DWORD data
303
304 @return Instruction content offset
305
306 **/
307 UINTN
308 EdbPrintImmData32 (
309 IN UINT32 Data
310 );
311
312 /**
313
314 Print the hexical QWORD immediate data to instruction content.
315
316 @param Data - QWORD data
317
318 @return Instruction content offset
319
320 **/
321 UINTN
322 EdbPrintImmData64 (
323 IN UINT64 Data
324 );
325
326 /**
327
328 Print the decimal UINTN immediate data to instruction content.
329
330 @param Data - UINTN data
331
332 @return Instruction content offset
333
334 **/
335 UINTN
336 EdbPrintImmDatan (
337 IN UINTN Data
338 );
339
340 /**
341
342 Print the decimal QWORD immediate data to instruction content.
343
344 @param Data64 - QWORD data
345
346 @return Instruction content offset
347
348 **/
349 UINTN
350 EdbPrintImmData64n (
351 IN UINT64 Data64
352 );
353
354 /**
355
356 Print the hexical BYTE to instruction content.
357
358 @param Data8 - BYTE data
359
360 @return Instruction content offset
361
362 **/
363 UINTN
364 EdbPrintData8 (
365 IN UINT8 Data8
366 );
367
368 /**
369
370 Print the hexical WORD to instruction content.
371
372 @param Data16 - WORD data
373
374 @return Instruction content offset
375
376 **/
377 UINTN
378 EdbPrintData16 (
379 IN UINT16 Data16
380 );
381
382 /**
383
384 Print the hexical DWORD to instruction content.
385
386 @param Data32 - DWORD data
387
388 @return Instruction content offset
389
390 **/
391 UINTN
392 EdbPrintData32 (
393 IN UINT32 Data32
394 );
395
396 /**
397
398 Print the hexical QWORD to instruction content.
399
400 @param Data64 - QWORD data
401
402 @return Instruction content offset
403
404 **/
405 UINTN
406 EdbPrintData64 (
407 IN UINT64 Data64
408 );
409
410 /**
411
412 Print the decimal unsigned UINTN to instruction content.
413
414 @param Data - unsigned UINTN data
415
416 @return Instruction content offset
417
418 **/
419 UINTN
420 EdbPrintDatan (
421 IN UINTN Data
422 );
423
424 /**
425
426 Print the decimal unsigned QWORD to instruction content.
427
428 @param Data64 - unsigned QWORD data
429
430 @return Instruction content offset
431
432 **/
433 UINTN
434 EdbPrintData64n (
435 IN UINT64 Data64
436 );
437
438 /**
439
440 Print the decimal signed BYTE to instruction content.
441
442 @param Data8 - signed BYTE data
443
444 @return Instruction content offset
445
446 **/
447 UINTN
448 EdbPrintData8s (
449 IN UINT8 Data8
450 );
451
452 /**
453
454 Print the decimal signed WORD to instruction content.
455
456 @param Data16 - signed WORD data
457
458 @return Instruction content offset
459
460 **/
461 UINTN
462 EdbPrintData16s (
463 IN UINT16 Data16
464 );
465
466 /**
467
468 Print the decimal signed DWORD to instruction content.
469
470 @param Data32 - signed DWORD data
471
472 @return Instruction content offset
473
474 **/
475 UINTN
476 EdbPrintData32s (
477 IN UINT32 Data32
478 );
479
480 /**
481
482 Print the decimal signed QWORD to instruction content.
483
484 @param Data64 - signed QWORD data
485
486 @return Instruction content offset
487
488 **/
489 UINTN
490 EdbPrintData64s (
491 IN UINT64 Data64
492 );
493
494 /**
495
496 Print the comma to instruction content.
497
498 @return Instruction content offset
499
500 **/
501 UINTN
502 EdbPrintComma (
503 VOID
504 );
505
506 /**
507
508 Find the symbol string according to address, then print it.
509
510 @param Address - instruction address
511
512 @retval 1 - symbol string is found and printed
513 @retval 0 - symbol string not found
514
515 **/
516 UINTN
517 EdbFindAndPrintSymbol (
518 IN UINTN Address
519 );
520
521 /**
522
523 Print the EBC byte code.
524
525 @param InstructionAddress - instruction address
526 @param InstructionNumber - instruction number
527
528 **/
529 VOID
530 EdbPrintRaw (
531 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
532 IN UINTN InstructionNumber
533 );
534
535 /**
536
537 Print the EBC asm code.
538
539 @param DebuggerPrivate - EBC Debugger private data structure
540 @param SystemContext - EBC system context.
541
542 @retval EFI_SUCCESS - show disasm successfully
543
544 **/
545 EFI_STATUS
546 EdbShowDisasm (
547 IN EFI_DEBUGGER_PRIVATE_DATA *DebuggerPrivate,
548 IN EFI_SYSTEM_CONTEXT SystemContext
549 );
550
551 /**
552
553 Get register value according to the system context, and register index.
554
555 @param SystemContext - EBC system context.
556 @param Index - EBC register index
557
558 @return register value
559
560 **/
561 UINT64
562 GetRegisterValue (
563 IN EFI_SYSTEM_CONTEXT SystemContext,
564 IN UINT8 Index
565 );
566
567 #endif