TianoCore EDK2 master
Loading...
Searching...
No Matches
EdbDisasm.c
Go to the documentation of this file.
1
9#include "Edb.h"
10
11//
12// Debugger Disasm definition
13//
14#define EDB_DISASM_DEFINE(func) \
15UINTN \
16func ( \
17 IN EFI_PHYSICAL_ADDRESS InstructionAddress, \
18 IN EFI_SYSTEM_CONTEXT SystemContext, \
19 OUT CHAR16 **DisasmString \
20 )
21
22EDB_DISASM_DEFINE (EdbDisasmBREAK);
23EDB_DISASM_DEFINE (EdbDisasmJMP);
24EDB_DISASM_DEFINE (EdbDisasmJMP8);
25EDB_DISASM_DEFINE (EdbDisasmCALL);
26EDB_DISASM_DEFINE (EdbDisasmRET);
27EDB_DISASM_DEFINE (EdbDisasmCMP);
28EDB_DISASM_DEFINE (EdbDisasmUnsignedDataManip);
29EDB_DISASM_DEFINE (EdbDisasmSignedDataManip);
30EDB_DISASM_DEFINE (EdbDisasmMOVxx);
31EDB_DISASM_DEFINE (EdbDisasmMOVsnw);
32EDB_DISASM_DEFINE (EdbDisasmMOVsnd);
33EDB_DISASM_DEFINE (EdbDisasmLOADSP);
34EDB_DISASM_DEFINE (EdbDisasmSTORESP);
35EDB_DISASM_DEFINE (EdbDisasmPUSH);
36EDB_DISASM_DEFINE (EdbDisasmPOP);
37EDB_DISASM_DEFINE (EdbDisasmCMPI);
38EDB_DISASM_DEFINE (EdbDisasmPUSHn);
39EDB_DISASM_DEFINE (EdbDisasmPOPn);
40EDB_DISASM_DEFINE (EdbDisasmMOVI);
41EDB_DISASM_DEFINE (EdbDisasmMOVIn);
42EDB_DISASM_DEFINE (EdbDisasmMOVREL);
43
44//
45// Debugger Disasm Table
46//
47EDB_DISASM_INSTRUCTION mEdbDisasmInstructionTable[] = {
48 EdbDisasmBREAK, // opcode 0x00 BREAK
49 EdbDisasmJMP, // opcode 0x01 JMP
50 EdbDisasmJMP8, // opcode 0x02 JMP8
51 EdbDisasmCALL, // opcode 0x03 CALL
52 EdbDisasmRET, // opcode 0x04 RET
53 EdbDisasmCMP, // opcode 0x05 CMPEQ
54 EdbDisasmCMP, // opcode 0x06 CMPLTE
55 EdbDisasmCMP, // opcode 0x07 CMPGTE
56 EdbDisasmCMP, // opcode 0x08 CMPULTE
57 EdbDisasmCMP, // opcode 0x09 CMPUGTE
58 EdbDisasmUnsignedDataManip, // opcode 0x0A NOT
59 EdbDisasmSignedDataManip, // opcode 0x0B NEG
60 EdbDisasmSignedDataManip, // opcode 0x0C ADD
61 EdbDisasmSignedDataManip, // opcode 0x0D SUB
62 EdbDisasmSignedDataManip, // opcode 0x0E MUL
63 EdbDisasmUnsignedDataManip, // opcode 0x0F MULU
64 EdbDisasmSignedDataManip, // opcode 0x10 DIV
65 EdbDisasmUnsignedDataManip, // opcode 0x11 DIVU
66 EdbDisasmSignedDataManip, // opcode 0x12 MOD
67 EdbDisasmUnsignedDataManip, // opcode 0x13 MODU
68 EdbDisasmUnsignedDataManip, // opcode 0x14 AND
69 EdbDisasmUnsignedDataManip, // opcode 0x15 OR
70 EdbDisasmUnsignedDataManip, // opcode 0x16 XOR
71 EdbDisasmUnsignedDataManip, // opcode 0x17 SHL
72 EdbDisasmUnsignedDataManip, // opcode 0x18 SHR
73 EdbDisasmSignedDataManip, // opcode 0x19 ASHR
74 EdbDisasmUnsignedDataManip, // opcode 0x1A EXTNDB
75 EdbDisasmUnsignedDataManip, // opcode 0x1B EXTNDW
76 EdbDisasmUnsignedDataManip, // opcode 0x1C EXTNDD
77 EdbDisasmMOVxx, // opcode 0x1D MOVBW
78 EdbDisasmMOVxx, // opcode 0x1E MOVWW
79 EdbDisasmMOVxx, // opcode 0x1F MOVDW
80 EdbDisasmMOVxx, // opcode 0x20 MOVQW
81 EdbDisasmMOVxx, // opcode 0x21 MOVBD
82 EdbDisasmMOVxx, // opcode 0x22 MOVWD
83 EdbDisasmMOVxx, // opcode 0x23 MOVDD
84 EdbDisasmMOVxx, // opcode 0x24 MOVQD
85 EdbDisasmMOVsnw, // opcode 0x25 MOVSNW
86 EdbDisasmMOVsnd, // opcode 0x26 MOVSND
87 NULL, // opcode 0x27
88 EdbDisasmMOVxx, // opcode 0x28 MOVQQ
89 EdbDisasmLOADSP, // opcode 0x29 LOADSP
90 EdbDisasmSTORESP, // opcode 0x2A STORESP
91 EdbDisasmPUSH, // opcode 0x2B PUSH
92 EdbDisasmPOP, // opcode 0x2C POP
93 EdbDisasmCMPI, // opcode 0x2D CMPIEQ
94 EdbDisasmCMPI, // opcode 0x2E CMPILTE
95 EdbDisasmCMPI, // opcode 0x2F CMPIGTE
96 EdbDisasmCMPI, // opcode 0x30 CMPIULTE
97 EdbDisasmCMPI, // opcode 0x31 CMPIUGTE
98 EdbDisasmMOVxx, // opcode 0x32 MOVNW
99 EdbDisasmMOVxx, // opcode 0x33 MOVND
100 NULL, // opcode 0x34
101 EdbDisasmPUSHn, // opcode 0x35 PUSHN
102 EdbDisasmPOPn, // opcode 0x36 POPN
103 EdbDisasmMOVI, // opcode 0x37 MOVI
104 EdbDisasmMOVIn, // opcode 0x38 MOVIN
105 EdbDisasmMOVREL, // opcode 0x39 MOVREL
106};
107
119UINTN
121 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
122 IN EFI_SYSTEM_CONTEXT SystemContext,
123 OUT CHAR16 **DisasmString
124 )
125{
126 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_BREAK);
127
128 if (*(UINT8 *)(UINTN)(InstructionAddress + 1) > 6) {
129 return 0;
130 }
131
132 //
133 // Construct Disasm String
134 //
135 if (DisasmString != NULL) {
136 *DisasmString = EdbPreInstructionString ();
137
138 EdbPrintInstructionName (L"BREAK");
139 EdbPrintDatan (*(UINT8 *)(UINTN)(InstructionAddress + 1));
140
142 }
143
144 return 2;
145}
146
147extern CONST UINT8 mJMPLen[];
148
160UINTN
162 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
163 IN EFI_SYSTEM_CONTEXT SystemContext,
164 OUT CHAR16 **DisasmString
165 )
166{
167 UINT8 Modifiers;
168 UINT8 Operands;
169 UINTN Size;
170 UINT32 Data32;
171 UINT64 Data64;
172
173 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_JMP);
174
175 Modifiers = GET_MODIFIERS (InstructionAddress);
176 Operands = GET_OPERANDS (InstructionAddress);
177 Size = (UINTN)mJMPLen[(Modifiers >> 6) & 0x03];
178
179 //
180 // Construct Disasm String
181 //
182 if (DisasmString != NULL) {
183 *DisasmString = EdbPreInstructionString ();
184
186 // if (Modifiers & OPCODE_M_IMMDATA64) {
187 // EdbPrintInstructionName (L"64");
188 // } else {
189 // EdbPrintInstructionName (L"32");
190 // }
191 if ((Modifiers & CONDITION_M_CONDITIONAL) != 0) {
192 if ((Modifiers & JMP_M_CS) != 0) {
194 } else {
196 }
197 }
198
199 InstructionAddress += 2;
200 if ((Modifiers & OPCODE_M_IMMDATA64) != 0) {
201 CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT64));
202 if ((Modifiers & OPCODE_M_IMMDATA) != 0) {
203 EdbPrintData64 (Data64);
204 } else {
205 return 0;
206 }
207 } else {
208 CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
209 EdbPrintRegister1 (Operands);
210
211 if ((Operands & OPERAND_M_INDIRECT1) == 0) {
212 if ((Modifiers & OPCODE_M_IMMDATA) == 0) {
213 Data32 = 0;
214 }
215
216 EdbPrintImmDatan (Data32);
217 } else {
218 EdbPrintRawIndexData32 (Data32);
219 }
220 }
221
223 }
224
225 return Size;
226}
227
239UINTN
241 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
242 IN EFI_SYSTEM_CONTEXT SystemContext,
243 OUT CHAR16 **DisasmString
244 )
245{
246 UINT8 Modifiers;
247
248 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_JMP8);
249 Modifiers = GET_MODIFIERS (InstructionAddress);
250
251 //
252 // Construct Disasm String
253 //
254 if (DisasmString != NULL) {
255 *DisasmString = EdbPreInstructionString ();
256
257 EdbPrintInstructionName (L"JMP8");
258 if ((Modifiers & CONDITION_M_CONDITIONAL) != 0) {
259 if ((Modifiers & JMP_M_CS) != 0) {
261 } else {
263 }
264 }
265
266 EdbPrintData8 (*(UINT8 *)(UINTN)(InstructionAddress + 1));
267
269 }
270
271 return 2;
272}
273
285UINTN
287 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
288 IN EFI_SYSTEM_CONTEXT SystemContext,
289 OUT CHAR16 **DisasmString
290 )
291{
292 UINT8 Modifiers;
293 UINT8 Operands;
294 UINTN Size;
295 UINT32 Data32;
296 UINT64 Data64;
297 UINT64 Ip;
298 UINTN Result;
299 EFI_PHYSICAL_ADDRESS SavedInstructionAddress;
300
301 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_CALL);
302 SavedInstructionAddress = InstructionAddress;
303
304 Modifiers = GET_MODIFIERS (InstructionAddress);
305 Operands = GET_OPERANDS (InstructionAddress);
306 Size = (UINTN)mJMPLen[(Modifiers >> 6) & 0x03];
307
308 //
309 // Construct Disasm String
310 //
311 if (DisasmString != NULL) {
312 *DisasmString = EdbPreInstructionString ();
313
314 EdbPrintInstructionName (L"CALL");
315 // if (Modifiers & OPCODE_M_IMMDATA64) {
316 // EdbPrintInstructionName (L"64");
317 // } else {
318 // EdbPrintInstructionName (L"32");
319 // }
320 if ((Operands & OPERAND_M_NATIVE_CALL) != 0) {
322 }
323
324 // if ((Operands & OPERAND_M_RELATIVE_ADDR) == 0) {
325 // EdbPrintInstructionName (L"a");
326 // }
327
328 InstructionAddress += 2;
329 if ((Modifiers & OPCODE_M_IMMDATA64) != 0) {
330 CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT64));
331 Ip = Data64;
332 if ((Modifiers & OPCODE_M_IMMDATA) != 0) {
333 Result = EdbFindAndPrintSymbol ((UINTN)Ip);
334 if (Result == 0) {
335 EdbPrintData64 (Data64);
336 }
337 } else {
338 return 0;
339 }
340 } else {
341 if ((Modifiers & OPCODE_M_IMMDATA) != 0) {
342 CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
343 } else {
344 Data32 = 0;
345 }
346
347 if ((Operands & OPERAND_M_OP1) == 0) {
348 Ip = (UINT64)Data32;
349 } else {
350 Ip = GetRegisterValue (SystemContext, (Operands & OPERAND_M_OP1));
351 }
352
353 if ((Operands & OPERAND_M_INDIRECT1) == 0) {
354 if ((Operands & OPERAND_M_RELATIVE_ADDR) != 0) {
355 Result = EdbFindAndPrintSymbol ((UINTN)(SavedInstructionAddress + Ip + Size));
356 } else {
357 Result = EdbFindAndPrintSymbol ((UINTN)Ip);
358 }
359
360 if (Result == 0) {
361 EdbPrintRegister1 (Operands);
362 if ((Modifiers & OPCODE_M_IMMDATA) != 0) {
363 EdbPrintImmData32 (Data32);
364 }
365 }
366 } else {
367 EdbPrintRegister1 (Operands);
368 if ((Modifiers & OPCODE_M_IMMDATA) != 0) {
369 EdbPrintRawIndexData32 (Data32);
370 }
371 }
372 }
373
375 }
376
377 return Size;
378}
379
391UINTN
393 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
394 IN EFI_SYSTEM_CONTEXT SystemContext,
395 OUT CHAR16 **DisasmString
396 )
397{
398 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_RET);
399
400 if (*(UINT8 *)(UINTN)(InstructionAddress + 1) != 0) {
401 return 0;
402 }
403
404 //
405 // Construct Disasm String
406 //
407 if (DisasmString != NULL) {
408 *DisasmString = EdbPreInstructionString ();
409
411
413 }
414
415 return 2;
416}
417
429UINTN
431 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
432 IN EFI_SYSTEM_CONTEXT SystemContext,
433 OUT CHAR16 **DisasmString
434 )
435{
436 UINT8 Opcode;
437 UINT8 Modifiers;
438 UINT8 Operands;
439 UINT16 Data16;
440 UINTN Size;
441
442 ASSERT (
443 (GET_OPCODE (InstructionAddress) == OPCODE_CMPEQ) ||
444 (GET_OPCODE (InstructionAddress) == OPCODE_CMPLTE) ||
445 (GET_OPCODE (InstructionAddress) == OPCODE_CMPGTE) ||
446 (GET_OPCODE (InstructionAddress) == OPCODE_CMPULTE) ||
447 (GET_OPCODE (InstructionAddress) == OPCODE_CMPUGTE)
448 );
449
450 Opcode = GET_OPCODE (InstructionAddress);
451 Modifiers = GET_MODIFIERS (InstructionAddress);
452 Operands = GET_OPERANDS (InstructionAddress);
453 if ((Modifiers & OPCODE_M_IMMDATA) != 0) {
454 Size = 4;
455 } else {
456 Size = 2;
457 }
458
459 //
460 // Construct Disasm String
461 //
462 if (DisasmString != NULL) {
463 *DisasmString = EdbPreInstructionString ();
464
466 // if (Modifiers & OPCODE_M_64BIT) {
467 // EdbPrintInstructionName (L"64");
468 // } else {
469 // EdbPrintInstructionName (L"32");
470 // }
471 switch (Opcode) {
472 case OPCODE_CMPEQ:
474 break;
475 case OPCODE_CMPLTE:
477 break;
478 case OPCODE_CMPGTE:
480 break;
481 case OPCODE_CMPULTE:
482 EdbPrintInstructionName (L"ulte");
483 break;
484 case OPCODE_CMPUGTE:
485 EdbPrintInstructionName (L"ugte");
486 break;
487 }
488
489 EdbPrintRegister1 (Operands);
490 InstructionAddress += 2;
491
492 EdbPrintComma ();
493 EdbPrintRegister2 (Operands);
494
495 if ((Modifiers & OPCODE_M_IMMDATA) != 0) {
496 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
497 if ((Operands & OPERAND_M_INDIRECT2) != 0) {
498 EdbPrintRawIndexData16 (Data16);
499 } else {
500 EdbPrintImmDatan (Data16);
501 }
502 }
503
505 }
506
507 return Size;
508}
509
521UINTN
523 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
524 IN EFI_SYSTEM_CONTEXT SystemContext,
525 OUT CHAR16 **DisasmString
526 )
527{
528 UINT8 Modifiers;
529 UINT8 Opcode;
530 UINT8 Operands;
531 UINTN Size;
532 UINT16 Data16;
533
534 ASSERT (
535 (GET_OPCODE (InstructionAddress) == OPCODE_NOT) ||
536 (GET_OPCODE (InstructionAddress) == OPCODE_MULU) ||
537 (GET_OPCODE (InstructionAddress) == OPCODE_DIVU) ||
538 (GET_OPCODE (InstructionAddress) == OPCODE_MODU) ||
539 (GET_OPCODE (InstructionAddress) == OPCODE_AND) ||
540 (GET_OPCODE (InstructionAddress) == OPCODE_OR) ||
541 (GET_OPCODE (InstructionAddress) == OPCODE_XOR) ||
542 (GET_OPCODE (InstructionAddress) == OPCODE_SHL) ||
543 (GET_OPCODE (InstructionAddress) == OPCODE_SHR) ||
544 (GET_OPCODE (InstructionAddress) == OPCODE_EXTNDB) ||
545 (GET_OPCODE (InstructionAddress) == OPCODE_EXTNDW) ||
546 (GET_OPCODE (InstructionAddress) == OPCODE_EXTNDD)
547 );
548
549 Opcode = GET_OPCODE (InstructionAddress);
550 Operands = GET_OPERANDS (InstructionAddress);
551 Modifiers = GET_MODIFIERS (InstructionAddress);
552 if ((Modifiers & DATAMANIP_M_IMMDATA) != 0) {
553 Size = 4;
554 } else {
555 Size = 2;
556 }
557
558 //
559 // Construct Disasm String
560 //
561 if (DisasmString != NULL) {
562 *DisasmString = EdbPreInstructionString ();
563
564 switch (Opcode) {
565 case OPCODE_NOT:
567 break;
568 case OPCODE_MULU:
569 EdbPrintInstructionName (L"MULU");
570 break;
571 case OPCODE_DIVU:
572 EdbPrintInstructionName (L"DIVU");
573 break;
574 case OPCODE_MODU:
575 EdbPrintInstructionName (L"MODU");
576 break;
577 case OPCODE_AND:
579 break;
580 case OPCODE_OR:
582 break;
583 case OPCODE_XOR:
585 break;
586 case OPCODE_SHL:
588 break;
589 case OPCODE_SHR:
591 break;
592 case OPCODE_EXTNDB:
593 EdbPrintInstructionName (L"EXTNDB");
594 break;
595 case OPCODE_EXTNDW:
596 EdbPrintInstructionName (L"EXTNDW");
597 break;
598 case OPCODE_EXTNDD:
599 EdbPrintInstructionName (L"EXTNDD");
600 break;
601 }
602
603 // if (Modifiers & DATAMANIP_M_64) {
604 // EdbPrintInstructionName (L"64");
605 // } else {
606 // EdbPrintInstructionName (L"32");
607 // }
608
609 EdbPrintRegister1 (Operands);
610 EdbPrintComma ();
611 EdbPrintRegister2 (Operands);
612
613 InstructionAddress += 2;
614 if ((Modifiers & DATAMANIP_M_IMMDATA) != 0) {
615 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
616 if ((Operands & OPERAND_M_INDIRECT2) != 0) {
617 EdbPrintRawIndexData16 (Data16);
618 } else {
619 EdbPrintImmDatan (Data16);
620 }
621 }
622
624 }
625
626 return Size;
627}
628
640UINTN
642 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
643 IN EFI_SYSTEM_CONTEXT SystemContext,
644 OUT CHAR16 **DisasmString
645 )
646{
647 UINT8 Modifiers;
648 UINT8 Opcode;
649 UINT8 Operands;
650 UINTN Size;
651 UINT16 Data16;
652
653 ASSERT (
654 (GET_OPCODE (InstructionAddress) == OPCODE_NEG) ||
655 (GET_OPCODE (InstructionAddress) == OPCODE_ADD) ||
656 (GET_OPCODE (InstructionAddress) == OPCODE_SUB) ||
657 (GET_OPCODE (InstructionAddress) == OPCODE_MUL) ||
658 (GET_OPCODE (InstructionAddress) == OPCODE_DIV) ||
659 (GET_OPCODE (InstructionAddress) == OPCODE_MOD) ||
660 (GET_OPCODE (InstructionAddress) == OPCODE_ASHR)
661 );
662
663 Opcode = GET_OPCODE (InstructionAddress);
664 Operands = GET_OPERANDS (InstructionAddress);
665 Modifiers = GET_MODIFIERS (InstructionAddress);
666 if ((Modifiers & DATAMANIP_M_IMMDATA) != 0) {
667 Size = 4;
668 } else {
669 Size = 2;
670 }
671
672 //
673 // Construct Disasm String
674 //
675 if (DisasmString != NULL) {
676 *DisasmString = EdbPreInstructionString ();
677
678 switch (Opcode) {
679 case OPCODE_NEG:
681 break;
682 case OPCODE_ADD:
684 break;
685 case OPCODE_SUB:
687 break;
688 case OPCODE_MUL:
690 break;
691 case OPCODE_DIV:
693 break;
694 case OPCODE_MOD:
696 break;
697 case OPCODE_ASHR:
698 EdbPrintInstructionName (L"ASHR");
699 break;
700 }
701
702 // if (Modifiers & DATAMANIP_M_64) {
703 // EdbPrintInstructionName (L"64");
704 // } else {
705 // EdbPrintInstructionName (L"32");
706 // }
707
708 EdbPrintRegister1 (Operands);
709 EdbPrintComma ();
710 EdbPrintRegister2 (Operands);
711
712 InstructionAddress += 2;
713 if ((Modifiers & DATAMANIP_M_IMMDATA) != 0) {
714 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
715 if ((Operands & OPERAND_M_INDIRECT2) != 0) {
716 EdbPrintRawIndexData16 (Data16);
717 } else {
718 EdbPrintImmDatan (Data16);
719 }
720 }
721
723 }
724
725 return Size;
726}
727
739UINTN
741 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
742 IN EFI_SYSTEM_CONTEXT SystemContext,
743 OUT CHAR16 **DisasmString
744 )
745{
746 UINT8 Modifiers;
747 UINT8 Opcode;
748 UINT8 Operands;
749 UINTN Size;
750 UINT16 Data16;
751 UINT32 Data32;
752 UINT64 Data64;
753
754 ASSERT (
755 (GET_OPCODE (InstructionAddress) == OPCODE_MOVBW) ||
756 (GET_OPCODE (InstructionAddress) == OPCODE_MOVWW) ||
757 (GET_OPCODE (InstructionAddress) == OPCODE_MOVDW) ||
758 (GET_OPCODE (InstructionAddress) == OPCODE_MOVQW) ||
759 (GET_OPCODE (InstructionAddress) == OPCODE_MOVBD) ||
760 (GET_OPCODE (InstructionAddress) == OPCODE_MOVWD) ||
761 (GET_OPCODE (InstructionAddress) == OPCODE_MOVDD) ||
762 (GET_OPCODE (InstructionAddress) == OPCODE_MOVQD) ||
763 (GET_OPCODE (InstructionAddress) == OPCODE_MOVQQ) ||
764 (GET_OPCODE (InstructionAddress) == OPCODE_MOVNW) ||
765 (GET_OPCODE (InstructionAddress) == OPCODE_MOVND)
766 );
767
768 Opcode = GET_OPCODE (InstructionAddress);
769 Modifiers = GET_MODIFIERS (InstructionAddress);
770 Operands = GET_OPERANDS (InstructionAddress);
771 Size = 2;
772 if ((Modifiers & (OPCODE_M_IMMED_OP1 | OPCODE_M_IMMED_OP2)) != 0) {
773 if ((Opcode <= OPCODE_MOVQW) || (Opcode == OPCODE_MOVNW)) {
774 if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
775 Size += 2;
776 }
777
778 if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
779 Size += 2;
780 }
781 } else if (((Opcode <= OPCODE_MOVQD) || (Opcode == OPCODE_MOVND)) != 0) {
782 if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
783 Size += 4;
784 }
785
786 if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
787 Size += 4;
788 }
789 } else if (Opcode == OPCODE_MOVQQ) {
790 if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
791 Size += 8;
792 }
793
794 if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
795 Size += 8;
796 }
797 }
798 }
799
800 //
801 // Construct Disasm String
802 //
803 if (DisasmString != NULL) {
804 *DisasmString = EdbPreInstructionString ();
805
807 switch (Opcode) {
808 case OPCODE_MOVBW:
810 break;
811 case OPCODE_MOVWW:
813 break;
814 case OPCODE_MOVDW:
816 break;
817 case OPCODE_MOVQW:
819 break;
820 case OPCODE_MOVBD:
822 break;
823 case OPCODE_MOVWD:
825 break;
826 case OPCODE_MOVDD:
828 break;
829 case OPCODE_MOVQD:
831 break;
832 case OPCODE_MOVQQ:
834 break;
835 case OPCODE_MOVNW:
837 break;
838 case OPCODE_MOVND:
840 break;
841 }
842
843 EdbPrintRegister1 (Operands);
844
845 InstructionAddress += 2;
846 if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
847 if ((Opcode <= OPCODE_MOVQW) || (Opcode == OPCODE_MOVNW)) {
848 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
849 InstructionAddress += 2;
850 EdbPrintRawIndexData16 (Data16);
851 } else if ((Opcode <= OPCODE_MOVQD) || (Opcode == OPCODE_MOVND)) {
852 CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
853 InstructionAddress += 4;
854 EdbPrintRawIndexData32 (Data32);
855 } else if (Opcode == OPCODE_MOVQQ) {
856 CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT64));
857 InstructionAddress += 8;
858 EdbPrintRawIndexData64 (Data64);
859 }
860 }
861
862 EdbPrintComma ();
863 EdbPrintRegister2 (Operands);
864
865 if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
866 if ((Opcode <= OPCODE_MOVQW) || (Opcode == OPCODE_MOVNW)) {
867 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
868 EdbPrintRawIndexData16 (Data16);
869 } else if ((Opcode <= OPCODE_MOVQD) || (Opcode == OPCODE_MOVND)) {
870 CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
871 EdbPrintRawIndexData32 (Data32);
872 } else if (Opcode == OPCODE_MOVQQ) {
873 CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT64));
874 EdbPrintRawIndexData64 (Data64);
875 }
876 }
877
879 }
880
881 return Size;
882}
883
895UINTN
897 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
898 IN EFI_SYSTEM_CONTEXT SystemContext,
899 OUT CHAR16 **DisasmString
900 )
901{
902 UINT8 Modifiers;
903 UINT8 Operands;
904 UINTN Size;
905 UINT16 Data16;
906
907 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_MOVSNW);
908
909 Modifiers = GET_MODIFIERS (InstructionAddress);
910 Operands = GET_OPERANDS (InstructionAddress);
911 Size = 2;
912 if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
913 Size += 2;
914 }
915
916 if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
917 Size += 2;
918 }
919
920 //
921 // Construct Disasm String
922 //
923 if (DisasmString != NULL) {
924 *DisasmString = EdbPreInstructionString ();
925
926 EdbPrintInstructionName (L"MOVsnw");
927
928 EdbPrintRegister1 (Operands);
929
930 InstructionAddress += 2;
931 if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
932 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
933 InstructionAddress += 2;
934 EdbPrintRawIndexData16 (Data16);
935 }
936
937 EdbPrintComma ();
938 EdbPrintRegister2 (Operands);
939
940 if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
941 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
942 if ((Operands & OPERAND_M_INDIRECT2) != 0) {
943 EdbPrintRawIndexData16 (Data16);
944 } else {
945 EdbPrintImmDatan (Data16);
946 }
947 }
948
950 }
951
952 return Size;
953}
954
966UINTN
968 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
969 IN EFI_SYSTEM_CONTEXT SystemContext,
970 OUT CHAR16 **DisasmString
971 )
972{
973 UINT8 Modifiers;
974 UINT8 Operands;
975 UINTN Size;
976 UINT32 Data32;
977
978 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_MOVSND);
979
980 Modifiers = GET_MODIFIERS (InstructionAddress);
981 Operands = GET_OPERANDS (InstructionAddress);
982 Size = 2;
983 if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
984 Size += 4;
985 }
986
987 if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
988 Size += 4;
989 }
990
991 //
992 // Construct Disasm String
993 //
994 if (DisasmString != NULL) {
995 *DisasmString = EdbPreInstructionString ();
996
997 EdbPrintInstructionName (L"MOVsnd");
998
999 EdbPrintRegister1 (Operands);
1000
1001 InstructionAddress += 2;
1002 if ((Modifiers & OPCODE_M_IMMED_OP1) != 0) {
1003 CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
1004 InstructionAddress += 4;
1005 EdbPrintRawIndexData32 (Data32);
1006 }
1007
1008 EdbPrintComma ();
1009 EdbPrintRegister2 (Operands);
1010
1011 if ((Modifiers & OPCODE_M_IMMED_OP2) != 0) {
1012 CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
1013 if ((Operands & OPERAND_M_INDIRECT2) != 0) {
1014 EdbPrintRawIndexData32 (Data32);
1015 } else {
1016 EdbPrintImmDatan (Data32);
1017 }
1018 }
1019
1021 }
1022
1023 return Size;
1024}
1025
1037UINTN
1039 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
1040 IN EFI_SYSTEM_CONTEXT SystemContext,
1041 OUT CHAR16 **DisasmString
1042 )
1043{
1044 UINT8 Operands;
1045
1046 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_LOADSP);
1047
1048 Operands = GET_OPERANDS (InstructionAddress);
1049
1050 //
1051 // Construct Disasm String
1052 //
1053 if (DisasmString != NULL) {
1054 *DisasmString = EdbPreInstructionString ();
1055
1056 EdbPrintInstructionName (L"LOADSP");
1057
1058 EdbPrintDedicatedRegister1 (Operands);
1059
1060 EdbPrintRegister2 (Operands);
1061
1063 }
1064
1065 return 2;
1066}
1067
1079UINTN
1081 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
1082 IN EFI_SYSTEM_CONTEXT SystemContext,
1083 OUT CHAR16 **DisasmString
1084 )
1085{
1086 UINT8 Operands;
1087
1088 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_STORESP);
1089
1090 Operands = GET_OPERANDS (InstructionAddress);
1091
1092 //
1093 // Construct Disasm String
1094 //
1095 if (DisasmString != NULL) {
1096 *DisasmString = EdbPreInstructionString ();
1097
1098 EdbPrintInstructionName (L"STORESP");
1099
1100 EdbPrintRegister1 (Operands);
1101
1102 EdbPrintDedicatedRegister2 (Operands);
1103
1105 }
1106
1107 return 2;
1108}
1109
1121UINTN
1123 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
1124 IN EFI_SYSTEM_CONTEXT SystemContext,
1125 OUT CHAR16 **DisasmString
1126 )
1127{
1128 UINT8 Modifiers;
1129 UINT8 Operands;
1130 UINTN Size;
1131 UINT16 Data16;
1132
1133 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_PUSH);
1134
1135 Operands = GET_OPERANDS (InstructionAddress);
1136 Modifiers = GET_MODIFIERS (InstructionAddress);
1137 if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
1138 Size = 4;
1139 } else {
1140 Size = 2;
1141 }
1142
1143 //
1144 // Construct Disasm String
1145 //
1146 if (DisasmString != NULL) {
1147 *DisasmString = EdbPreInstructionString ();
1148
1149 EdbPrintInstructionName (L"PUSH");
1150 // if (Modifiers & PUSHPOP_M_64) {
1151 // EdbPrintInstructionName (L"64");
1152 // } else {
1153 // EdbPrintInstructionName (L"32");
1154 // }
1155
1156 EdbPrintRegister1 (Operands);
1157
1158 InstructionAddress += 2;
1159 if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
1160 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
1161 if ((Operands & OPERAND_M_INDIRECT1) != 0) {
1162 EdbPrintRawIndexData16 (Data16);
1163 } else {
1164 EdbPrintImmDatan (Data16);
1165 }
1166 }
1167
1169 }
1170
1171 return Size;
1172}
1173
1185UINTN
1187 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
1188 IN EFI_SYSTEM_CONTEXT SystemContext,
1189 OUT CHAR16 **DisasmString
1190 )
1191{
1192 UINT8 Modifiers;
1193 UINT8 Operands;
1194 UINTN Size;
1195 UINT16 Data16;
1196
1197 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_POP);
1198
1199 Operands = GET_OPERANDS (InstructionAddress);
1200 Modifiers = GET_MODIFIERS (InstructionAddress);
1201 if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
1202 Size = 4;
1203 } else {
1204 Size = 2;
1205 }
1206
1207 //
1208 // Construct Disasm String
1209 //
1210 if (DisasmString != NULL) {
1211 *DisasmString = EdbPreInstructionString ();
1212
1213 EdbPrintInstructionName (L"POP");
1214 // if (Modifiers & PUSHPOP_M_64) {
1215 // EdbPrintInstructionName (L"64");
1216 // } else {
1217 // EdbPrintInstructionName (L"32");
1218 // }
1219
1220 EdbPrintRegister1 (Operands);
1221
1222 InstructionAddress += 2;
1223 if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
1224 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
1225 if ((Operands & OPERAND_M_INDIRECT1) != 0) {
1226 EdbPrintRawIndexData16 (Data16);
1227 } else {
1228 EdbPrintImmDatan (Data16);
1229 }
1230 }
1231
1233 }
1234
1235 return Size;
1236}
1237
1249UINTN
1251 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
1252 IN EFI_SYSTEM_CONTEXT SystemContext,
1253 OUT CHAR16 **DisasmString
1254 )
1255{
1256 UINT8 Modifiers;
1257 UINT8 Opcode;
1258 UINT8 Operands;
1259 UINT16 Data16;
1260 UINT32 Data32;
1261 UINTN Size;
1262
1263 ASSERT (
1264 (GET_OPCODE (InstructionAddress) == OPCODE_CMPIEQ) ||
1265 (GET_OPCODE (InstructionAddress) == OPCODE_CMPILTE) ||
1266 (GET_OPCODE (InstructionAddress) == OPCODE_CMPIGTE) ||
1267 (GET_OPCODE (InstructionAddress) == OPCODE_CMPIULTE) ||
1268 (GET_OPCODE (InstructionAddress) == OPCODE_CMPIUGTE)
1269 );
1270
1271 Modifiers = GET_MODIFIERS (InstructionAddress);
1272 Opcode = GET_OPCODE (InstructionAddress);
1273 Operands = GET_OPERANDS (InstructionAddress);
1274
1275 if ((Operands & 0xE0) != 0) {
1276 return 0;
1277 }
1278
1279 Size = 2;
1280 if ((Operands & OPERAND_M_CMPI_INDEX) != 0) {
1281 Size += 2;
1282 }
1283
1284 if ((Modifiers & OPCODE_M_CMPI32_DATA) != 0) {
1285 Size += 4;
1286 } else {
1287 Size += 2;
1288 }
1289
1290 //
1291 // Construct Disasm String
1292 //
1293 if (DisasmString != NULL) {
1294 *DisasmString = EdbPreInstructionString ();
1295
1296 EdbPrintInstructionName (L"CMPI");
1297 // if (Modifiers & OPCODE_M_CMPI64) {
1298 // EdbPrintInstructionName (L"64");
1299 // } else {
1300 // EdbPrintInstructionName (L"32");
1301 // }
1302 if ((Modifiers & OPCODE_M_CMPI32_DATA) != 0) {
1304 } else {
1306 }
1307
1308 switch (Opcode) {
1309 case OPCODE_CMPIEQ:
1311 break;
1312 case OPCODE_CMPILTE:
1313 EdbPrintInstructionName (L"lte");
1314 break;
1315 case OPCODE_CMPIGTE:
1316 EdbPrintInstructionName (L"gte");
1317 break;
1318 case OPCODE_CMPIULTE:
1319 EdbPrintInstructionName (L"ulte");
1320 break;
1321 case OPCODE_CMPIUGTE:
1322 EdbPrintInstructionName (L"ugte");
1323 break;
1324 }
1325
1326 EdbPrintRegister1 (Operands);
1327
1328 InstructionAddress += 2;
1329 if ((Operands & OPERAND_M_CMPI_INDEX) != 0) {
1330 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
1331 InstructionAddress += 2;
1332 EdbPrintRawIndexData16 (Data16);
1333 }
1334
1335 EdbPrintComma ();
1336
1337 if ((Modifiers & OPCODE_M_CMPI32_DATA) != 0) {
1338 CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
1339 EdbPrintDatan (Data32);
1340 } else {
1341 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
1342 EdbPrintDatan (Data16);
1343 }
1344
1346 }
1347
1348 return Size;
1349}
1350
1362UINTN
1364 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
1365 IN EFI_SYSTEM_CONTEXT SystemContext,
1366 OUT CHAR16 **DisasmString
1367 )
1368{
1369 UINT8 Modifiers;
1370 UINT8 Operands;
1371 UINTN Size;
1372 UINT16 Data16;
1373
1374 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_PUSHN);
1375
1376 Operands = GET_OPERANDS (InstructionAddress);
1377 Modifiers = GET_MODIFIERS (InstructionAddress);
1378 if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
1379 Size = 4;
1380 } else {
1381 Size = 2;
1382 }
1383
1384 //
1385 // Construct Disasm String
1386 //
1387 if (DisasmString != NULL) {
1388 *DisasmString = EdbPreInstructionString ();
1389
1390 EdbPrintInstructionName (L"PUSHn");
1391
1392 EdbPrintRegister1 (Operands);
1393
1394 InstructionAddress += 2;
1395 if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
1396 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
1397 if ((Operands & OPERAND_M_INDIRECT1) != 0) {
1398 EdbPrintRawIndexData16 (Data16);
1399 } else {
1400 EdbPrintImmDatan (Data16);
1401 }
1402 }
1403
1405 }
1406
1407 return Size;
1408}
1409
1421UINTN
1423 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
1424 IN EFI_SYSTEM_CONTEXT SystemContext,
1425 OUT CHAR16 **DisasmString
1426 )
1427{
1428 UINT8 Modifiers;
1429 UINT8 Operands;
1430 UINTN Size;
1431 UINT16 Data16;
1432
1433 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_POPN);
1434
1435 Operands = GET_OPERANDS (InstructionAddress);
1436 Modifiers = GET_MODIFIERS (InstructionAddress);
1437 if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
1438 Size = 4;
1439 } else {
1440 Size = 2;
1441 }
1442
1443 //
1444 // Construct Disasm String
1445 //
1446 if (DisasmString != NULL) {
1447 *DisasmString = EdbPreInstructionString ();
1448
1449 EdbPrintInstructionName (L"POPn");
1450
1451 EdbPrintRegister1 (Operands);
1452
1453 InstructionAddress += 2;
1454 if ((Modifiers & PUSHPOP_M_IMMDATA) != 0) {
1455 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
1456 if ((Operands & OPERAND_M_INDIRECT1) != 0) {
1457 EdbPrintRawIndexData16 (Data16);
1458 } else {
1459 EdbPrintImmDatan (Data16);
1460 }
1461 }
1462
1464 }
1465
1466 return Size;
1467}
1468
1480UINTN
1482 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
1483 IN EFI_SYSTEM_CONTEXT SystemContext,
1484 OUT CHAR16 **DisasmString
1485 )
1486{
1487 UINT8 Modifiers;
1488 UINT8 Operands;
1489 UINTN Size;
1490 UINT16 Data16;
1491 UINT32 Data32;
1492 UINT64 Data64;
1493
1494 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_MOVI);
1495
1496 Modifiers = GET_MODIFIERS (InstructionAddress);
1497 Operands = GET_OPERANDS (InstructionAddress);
1498
1499 if ((Operands & MOVI_M_IMMDATA) != 0) {
1500 Size = 4;
1501 } else {
1502 Size = 2;
1503 }
1504
1505 if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH16) {
1506 Size += 2;
1507 } else if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH32) {
1508 Size += 4;
1509 } else if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH64) {
1510 Size += 8;
1511 }
1512
1513 //
1514 // Construct Disasm String
1515 //
1516 if (DisasmString != NULL) {
1517 *DisasmString = EdbPreInstructionString ();
1518
1519 EdbPrintInstructionName (L"MOVI");
1520 switch (Operands & MOVI_M_MOVEWIDTH) {
1521 case MOVI_MOVEWIDTH8:
1523 break;
1524 case MOVI_MOVEWIDTH16:
1526 break;
1527 case MOVI_MOVEWIDTH32:
1529 break;
1530 case MOVI_MOVEWIDTH64:
1532 break;
1533 }
1534
1535 switch (Modifiers & MOVI_M_DATAWIDTH) {
1536 case MOVI_DATAWIDTH16:
1538 break;
1539 case MOVI_DATAWIDTH32:
1541 break;
1542 case MOVI_DATAWIDTH64:
1544 break;
1545 }
1546
1547 EdbPrintRegister1 (Operands);
1548
1549 InstructionAddress += 2;
1550 if ((Operands & MOVI_M_IMMDATA) != 0) {
1551 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
1552 InstructionAddress += 2;
1553 EdbPrintRawIndexData16 (Data16);
1554 }
1555
1556 EdbPrintComma ();
1557
1558 switch (Modifiers & MOVI_M_DATAWIDTH) {
1559 case MOVI_DATAWIDTH16:
1560 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
1561 EdbPrintDatan (Data16);
1562 break;
1563 case MOVI_DATAWIDTH32:
1564 CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
1565 EdbPrintDatan (Data32);
1566 break;
1567 case MOVI_DATAWIDTH64:
1568 CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT64));
1569 EdbPrintData64n (Data64);
1570 break;
1571 }
1572
1574 }
1575
1576 return Size;
1577}
1578
1590UINTN
1592 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
1593 IN EFI_SYSTEM_CONTEXT SystemContext,
1594 OUT CHAR16 **DisasmString
1595 )
1596{
1597 UINT8 Modifiers;
1598 UINT8 Operands;
1599 UINTN Size;
1600 UINT16 Data16;
1601 UINT32 Data32;
1602 UINT64 Data64;
1603
1604 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_MOVIN);
1605
1606 Modifiers = GET_MODIFIERS (InstructionAddress);
1607 Operands = GET_OPERANDS (InstructionAddress);
1608
1609 if ((Operands & MOVI_M_IMMDATA) != 0) {
1610 Size = 4;
1611 } else {
1612 Size = 2;
1613 }
1614
1615 if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH16) {
1616 Size += 2;
1617 } else if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH32) {
1618 Size += 4;
1619 } else if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH64) {
1620 Size += 8;
1621 }
1622
1623 //
1624 // Construct Disasm String
1625 //
1626 if (DisasmString != NULL) {
1627 *DisasmString = EdbPreInstructionString ();
1628
1629 EdbPrintInstructionName (L"MOVIn");
1630 switch (Modifiers & MOVI_M_DATAWIDTH) {
1631 case MOVI_DATAWIDTH16:
1633 break;
1634 case MOVI_DATAWIDTH32:
1636 break;
1637 case MOVI_DATAWIDTH64:
1639 break;
1640 }
1641
1642 EdbPrintRegister1 (Operands);
1643
1644 InstructionAddress += 2;
1645 if ((Operands & MOVI_M_IMMDATA) != 0) {
1646 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
1647 InstructionAddress += 2;
1648 EdbPrintRawIndexData16 (Data16);
1649 }
1650
1651 EdbPrintComma ();
1652
1653 switch (Modifiers & MOVI_M_DATAWIDTH) {
1654 case MOVI_DATAWIDTH16:
1655 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
1656 EdbPrintRawIndexData16 (Data16);
1657 break;
1658 case MOVI_DATAWIDTH32:
1659 CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
1660 EdbPrintRawIndexData32 (Data32);
1661 break;
1662 case MOVI_DATAWIDTH64:
1663 CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT64));
1664 EdbPrintRawIndexData64 (Data64);
1665 break;
1666 }
1667
1669 }
1670
1671 return Size;
1672}
1673
1685UINTN
1687 IN EFI_PHYSICAL_ADDRESS InstructionAddress,
1688 IN EFI_SYSTEM_CONTEXT SystemContext,
1689 OUT CHAR16 **DisasmString
1690 )
1691{
1692 UINT8 Modifiers;
1693 UINT8 Operands;
1694 UINTN Size;
1695 UINT16 Data16;
1696 UINT32 Data32;
1697 UINT64 Data64;
1698 UINTN Result;
1699 EFI_PHYSICAL_ADDRESS SavedInstructionAddress;
1700
1701 ASSERT (GET_OPCODE (InstructionAddress) == OPCODE_MOVREL);
1702 SavedInstructionAddress = InstructionAddress;
1703
1704 Modifiers = GET_MODIFIERS (InstructionAddress);
1705 Operands = GET_OPERANDS (InstructionAddress);
1706
1707 if ((Operands & MOVI_M_IMMDATA) != 0) {
1708 Size = 4;
1709 } else {
1710 Size = 2;
1711 }
1712
1713 if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH16) {
1714 Size += 2;
1715 } else if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH32) {
1716 Size += 4;
1717 } else if ((Modifiers & MOVI_M_DATAWIDTH) == MOVI_DATAWIDTH64) {
1718 Size += 8;
1719 } else {
1720 return 0;
1721 }
1722
1723 //
1724 // Construct Disasm String
1725 //
1726 if (DisasmString != NULL) {
1727 *DisasmString = EdbPreInstructionString ();
1728
1729 EdbPrintInstructionName (L"MOVrel");
1730 switch (Modifiers & MOVI_M_DATAWIDTH) {
1731 case MOVI_DATAWIDTH16:
1733 break;
1734 case MOVI_DATAWIDTH32:
1736 break;
1737 case MOVI_DATAWIDTH64:
1739 break;
1740 }
1741
1742 EdbPrintRegister1 (Operands);
1743
1744 InstructionAddress += 2;
1745 if ((Operands & MOVI_M_IMMDATA) != 0) {
1746 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
1747 InstructionAddress += 2;
1748 EdbPrintRawIndexData16 (Data16);
1749 }
1750
1751 EdbPrintComma ();
1752
1753 switch (Modifiers & MOVI_M_DATAWIDTH) {
1754 case MOVI_DATAWIDTH16:
1755 CopyMem (&Data16, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT16));
1756 Result = EdbFindAndPrintSymbol ((UINTN)(SavedInstructionAddress + Size + (INT16)Data16));
1757 if (Result == 0) {
1758 EdbPrintData16 (Data16);
1759 }
1760
1761 break;
1762 case MOVI_DATAWIDTH32:
1763 CopyMem (&Data32, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT32));
1764 Result = EdbFindAndPrintSymbol ((UINTN)(SavedInstructionAddress + Size + (INT32)Data32));
1765 if (Result == 0) {
1766 EdbPrintData32 (Data32);
1767 }
1768
1769 break;
1770 case MOVI_DATAWIDTH64:
1771 CopyMem (&Data64, (VOID *)(UINTN)(InstructionAddress), sizeof (UINT64));
1772 if (sizeof (UINTN) == sizeof (UINT64)) {
1773 Result = EdbFindAndPrintSymbol ((UINTN)(SavedInstructionAddress + Size + (INT64)Data64));
1774 } else {
1775 Result = 0;
1776 }
1777
1778 if (Result == 0) {
1779 EdbPrintData64 (Data64);
1780 }
1781
1782 break;
1783 }
1784
1786 }
1787
1788 return Size;
1789}
UINT64 UINTN
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
UINTN EdbDisasmMOVsnd(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:967
UINTN EdbDisasmMOVREL(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:1686
UINTN EdbDisasmSignedDataManip(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:641
UINTN EdbDisasmPUSH(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:1122
UINTN EdbDisasmCMPI(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:1250
UINTN EdbDisasmPOP(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:1186
UINTN EdbDisasmCALL(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:286
UINTN EdbDisasmSTORESP(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:1080
UINTN EdbDisasmBREAK(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:120
UINTN EdbDisasmUnsignedDataManip(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:522
UINTN EdbDisasmMOVIn(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:1591
UINTN EdbDisasmMOVI(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:1481
UINTN EdbDisasmJMP8(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:240
UINTN EdbDisasmRET(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:392
UINTN EdbDisasmJMP(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:161
UINTN EdbDisasmPOPn(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:1422
UINTN EdbDisasmMOVsnw(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:896
UINTN EdbDisasmPUSHn(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:1363
UINTN EdbDisasmCMP(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:430
UINTN EdbDisasmLOADSP(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:1038
UINTN EdbDisasmMOVxx(IN EFI_PHYSICAL_ADDRESS InstructionAddress, IN EFI_SYSTEM_CONTEXT SystemContext, OUT CHAR16 **DisasmString)
Definition: EdbDisasm.c:740
UINTN EdbPrintRawIndexData16(IN UINT16 Data16)
UINTN EdbPrintData64n(IN UINT64 Data64)
UINTN EdbPrintInstructionName(IN CHAR16 *Name)
UINTN EdbPrintRegister1(IN UINT8 Operands)
CHAR16 * EdbPreInstructionString(VOID)
UINTN EdbPrintImmData32(IN UINT32 Data)
UINTN EdbPrintDatan(IN UINTN Data)
CHAR16 * EdbPostInstructionString(VOID)
UINTN EdbPrintRawIndexData32(IN UINT32 Data32)
UINTN EdbPrintData8(IN UINT8 Data8)
UINT64 GetRegisterValue(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINT8 Index)
UINTN EdbPrintRawIndexData64(IN UINT64 Data64)
UINTN EdbPrintData16(IN UINT16 Data16)
UINTN EdbPrintDedicatedRegister1(IN UINT8 Operands)
UINTN EdbPrintDedicatedRegister2(IN UINT8 Operands)
UINTN EdbPrintComma(VOID)
UINTN EdbFindAndPrintSymbol(IN UINTN Address)
UINTN EdbPrintRegister2(IN UINT8 Operands)
UINTN EdbPrintData32(IN UINT32 Data32)
UINTN EdbPrintImmDatan(IN UINTN Data)
UINTN EdbPrintData64(IN UINT64 Data64)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50