18 { EXCEPT_IA32_DEBUG, GDB_SIGTRAP },
19 { EXCEPT_IA32_NMI, GDB_SIGEMT },
20 { EXCEPT_IA32_BREAKPOINT, GDB_SIGTRAP },
21 { EXCEPT_IA32_OVERFLOW, GDB_SIGSEGV },
22 { EXCEPT_IA32_BOUND, GDB_SIGSEGV },
23 { EXCEPT_IA32_INVALID_OPCODE, GDB_SIGILL },
24 { EXCEPT_IA32_DOUBLE_FAULT, GDB_SIGEMT },
25 { EXCEPT_IA32_STACK_FAULT, GDB_SIGSEGV },
26 { EXCEPT_IA32_GP_FAULT, GDB_SIGSEGV },
27 { EXCEPT_IA32_PAGE_FAULT, GDB_SIGSEGV },
28 { EXCEPT_IA32_FP_ERROR, GDB_SIGEMT },
29 { EXCEPT_IA32_ALIGNMENT_CHECK, GDB_SIGEMT },
30 { EXCEPT_IA32_MACHINE_CHECK, GDB_SIGEMT }
37UINTN gRegisterOffsets[] = {
62 Print ((CHAR16 *)L
"EAX: %x ", SystemContext.SystemContextIa32->Eax);
63 Print ((CHAR16 *)L
"ECX: %x ", SystemContext.SystemContextIa32->Ecx);
64 Print ((CHAR16 *)L
"EDX: %x ", SystemContext.SystemContextIa32->Edx);
65 Print ((CHAR16 *)L
"EBX: %x ", SystemContext.SystemContextIa32->Ebx);
66 Print ((CHAR16 *)L
"ESP: %x ", SystemContext.SystemContextIa32->Esp);
67 Print ((CHAR16 *)L
"EBP: %x ", SystemContext.SystemContextIa32->Ebp);
68 Print ((CHAR16 *)L
"ESI: %x ", SystemContext.SystemContextIa32->Esi);
69 Print ((CHAR16 *)L
"EDI: %x ", SystemContext.SystemContextIa32->Edi);
70 Print ((CHAR16 *)L
"EIP: %x\n", SystemContext.SystemContextIa32->Eip);
71 Print ((CHAR16 *)L
"EFlags: %x\n", SystemContext.SystemContextIa32->Eflags);
80 Print ((CHAR16 *)L
"DR0: %x ", SystemContext.SystemContextIa32->Dr0);
81 Print ((CHAR16 *)L
"DR1: %x ", SystemContext.SystemContextIa32->Dr1);
82 Print ((CHAR16 *)L
"DR2: %x ", SystemContext.SystemContextIa32->Dr2);
83 Print ((CHAR16 *)L
"DR3: %x ", SystemContext.SystemContextIa32->Dr3);
84 Print ((CHAR16 *)L
"DR6: %x ", SystemContext.SystemContextIa32->Dr6);
85 Print ((CHAR16 *)L
"DR7: %x\n", SystemContext.SystemContextIa32->Dr7);
111 return sizeof (gRegisterOffsets)/
sizeof (
UINTN);
126 return (BOOLEAN)(Isa ==
IsaIa32);
145 TempPtr = ((UINT8 *)SystemContext.SystemContextIa32) + gRegisterOffsets[RegNumber];
146 return (
UINTN *)TempPtr;
167 while (RegSize < REG_SIZE) {
168 *OutBufPtr++ = mHexToStr[((*
FindPointerToRegister (SystemContext, RegNumber) >> (RegSize+4)) & 0xf)];
170 RegSize = RegSize + 8;
200 OutBufPtr = OutBuffer;
219 CHAR8 OutBuffer[129];
222 OutBufPtr = OutBuffer;
253 while (RegSize < REG_SIZE) {
261 NewValue += (TempValue << (RegSize+4));
269 NewValue += (TempValue << RegSize);
270 RegSize = RegSize + 8;
291 CHAR8 RegNumBuffer[MAX_REG_NUM_BUF_SIZE];
296 InBufPtr = &InBuffer[1];
297 RegNumBufPtr = RegNumBuffer;
298 while (*InBufPtr !=
'=') {
299 *RegNumBufPtr++ = *InBufPtr++;
302 *RegNumBufPtr =
'\0';
341 InBufPtr = &InBuffer[1];
363 SystemContext.SystemContextIa32->Eflags |= TF_BIT;
376 SystemContext.SystemContextIa32->Eflags &= ~TF_BIT;
392 if (PacketData[1] !=
'\0') {
410 if (PacketData[1] !=
'\0') {
427GetBreakpointDataAddress (
434 if (BreakpointNumber == 1) {
435 Address = SystemContext.SystemContextIa32->Dr0;
436 }
else if (BreakpointNumber == 2) {
437 Address = SystemContext.SystemContextIa32->Dr1;
438 }
else if (BreakpointNumber == 3) {
439 Address = SystemContext.SystemContextIa32->Dr2;
440 }
else if (BreakpointNumber == 4) {
441 Address = SystemContext.SystemContextIa32->Dr3;
460GetBreakpointDetected (
465 UINTN BreakpointNumber;
467 Dr6.UintN = SystemContext.SystemContextIa32->Dr6;
469 if (Dr6.Bits.B0 == 1) {
470 BreakpointNumber = 1;
471 }
else if (Dr6.Bits.B1 == 1) {
472 BreakpointNumber = 2;
473 }
else if (Dr6.Bits.B2 == 1) {
474 BreakpointNumber = 3;
475 }
else if (Dr6.Bits.B3 == 1) {
476 BreakpointNumber = 4;
478 BreakpointNumber = 0;
481 return BreakpointNumber;
502 BREAK_TYPE Type = NotSupported;
504 Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
506 if (BreakpointNumber == 1) {
507 Type = (BREAK_TYPE)Dr7.Bits.RW0;
508 }
else if (BreakpointNumber == 2) {
509 Type = (BREAK_TYPE)Dr7.Bits.RW1;
510 }
else if (BreakpointNumber == 3) {
511 Type = (BREAK_TYPE)Dr7.Bits.RW2;
512 }
else if (BreakpointNumber == 4) {
513 Type = (BREAK_TYPE)Dr7.Bits.RW3;
537 }
else if (Length == 2) {
540 }
else if (Length == 4) {
567 Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
569 if (Dr7.Bits.G0 == 0) {
571 }
else if (Dr7.Bits.G1 == 0) {
573 }
else if (Dr7.Bits.G2 == 0) {
575 }
else if (Dr7.Bits.G3 == 0) {
578 return EFI_OUT_OF_RESOURCES;
613 if ((Type == 0) && (Length != 0)) {
614 return EFI_INVALID_PARAMETER;
619 if ((Type == (BREAK_TYPE)DataRead) ||
620 (Type == (BREAK_TYPE)SoftwareBreakpoint))
622 return EFI_UNSUPPORTED;
626 Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
629 SystemContext.SystemContextIa32->Dr0 = Address;
632 Dr7.Bits.LEN0 = Length;
634 SystemContext.SystemContextIa32->Dr1 = Address;
637 Dr7.Bits.LEN1 = Length;
639 SystemContext.SystemContextIa32->Dr2 = Address;
642 Dr7.Bits.LEN2 = Length;
644 SystemContext.SystemContextIa32->Dr3 = Address;
647 Dr7.Bits.LEN3 = Length;
649 return EFI_INVALID_PARAMETER;
653 SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
687 if ((Type == (BREAK_TYPE)DataRead) ||
688 (Type == (BREAK_TYPE)SoftwareBreakpoint))
690 return EFI_UNSUPPORTED;
696 Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
698 if ((Dr7.Bits.G0 == 1) &&
699 (Dr7.Bits.LEN0 == Length) &&
700 (Dr7.Bits.RW0 == Type) &&
701 (Address == SystemContext.SystemContextIa32->Dr0))
704 }
else if ((Dr7.Bits.G1 == 1) &&
705 (Dr7.Bits.LEN1 == Length) &&
706 (Dr7.Bits.RW1 == Type) &&
707 (Address == SystemContext.SystemContextIa32->Dr1))
710 }
else if ((Dr7.Bits.G2 == 1) &&
711 (Dr7.Bits.LEN2 == Length) &&
712 (Dr7.Bits.RW2 == Type) &&
713 (Address == SystemContext.SystemContextIa32->Dr2))
716 }
else if ((Dr7.Bits.G3 == 1) &&
717 (Dr7.Bits.LEN3 == Length) &&
718 (Dr7.Bits.RW3 == Type) &&
719 (Address == SystemContext.SystemContextIa32->Dr3))
723 Print ((CHAR16 *)L
"No match found..\n");
724 return EFI_NOT_FOUND;
749 Dr7.UintN = SystemContext.SystemContextIa32->Dr7;
752 SystemContext.SystemContextIa32->Dr0 = Address;
757 SystemContext.SystemContextIa32->Dr1 = Address;
762 SystemContext.SystemContextIa32->Dr2 = Address;
767 SystemContext.SystemContextIa32->Dr3 = Address;
772 return EFI_INVALID_PARAMETER;
776 SystemContext.SystemContextIa32->Dr7 = Dr7.UintN;
805 BREAK_TYPE BreakType = NotSupported;
816 BreakType = SoftwareBreakpoint;
820 BreakType = InstructionExecution;
824 BreakType = DataWrite;
828 BreakType = DataRead;
832 BreakType = DataReadWrite;
836 Print ((CHAR16 *)L
"Insert breakpoint default: %x\n", Type);
843 if (EFI_ERROR (Status)) {
844 Print ((CHAR16 *)L
"No space left on device\n");
851 if (EFI_ERROR (Status)) {
852 if (Status == EFI_UNSUPPORTED) {
853 Print ((CHAR16 *)L
"Not supported\n");
858 Print ((CHAR16 *)L
"Invalid argument\n");
888 BREAK_TYPE BreakType = NotSupported;
901 BreakType = SoftwareBreakpoint;
905 BreakType = InstructionExecution;
909 BreakType = DataWrite;
913 BreakType = DataRead;
917 BreakType = DataReadWrite;
927 if (EFI_ERROR (Status)) {
928 if (Status == EFI_UNSUPPORTED) {
929 Print ((CHAR16 *)L
"Not supported.\n");
934 Print ((CHAR16 *)L
"No matching register found.\n");
941 if (EFI_ERROR (Status)) {
942 Print ((CHAR16 *)L
"Invalid argument.\n");
UINTN MaxEfiException(VOID)
VOID EFIAPI RemoveBreakPoint(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData)
UINTN MaxRegisterCount(VOID)
VOID EFIAPI WriteGeneralRegisters(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *InBuffer)
CHAR8 * BasicReadRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber, IN CHAR8 *OutBufPtr)
VOID EFIAPI InsertBreakPoint(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData)
VOID ReadNthRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *InBuffer)
CHAR8 * BasicWriteRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber, IN CHAR8 *InBufPtr)
BOOLEAN CheckIsa(IN EFI_INSTRUCTION_SET_ARCHITECTURE Isa)
VOID EFIAPI ReadGeneralRegisters(IN EFI_SYSTEM_CONTEXT SystemContext)
VOID RemoveSingleStep(IN EFI_SYSTEM_CONTEXT SystemContext)
VOID AddSingleStep(IN EFI_SYSTEM_CONTEXT SystemContext)
VOID EFIAPI SingleStep(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData)
VOID WriteNthRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *InBuffer)
UINTN * FindPointerToRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN RegNumber)
VOID EFIAPI ContinueAtAddress(IN EFI_SYSTEM_CONTEXT SystemContext, IN CHAR8 *PacketData)
UINTN EFIAPI AsciiStrLen(IN CONST CHAR8 *String)
UINTN EFIAPI AsciiStrHexToUintn(IN CONST CHAR8 *String)
UINTN ParseBreakpointPacket(IN CHAR8 *PacketData, OUT UINTN *Type, OUT UINTN *Address, OUT UINTN *Length)
VOID EFIAPI SendNotSupported(VOID)
UINTN SendPacket(IN CHAR8 *PacketData)
VOID EFIAPI SendSuccess(VOID)
INTN HexCharToInt(IN CHAR8 Char)
VOID EFIAPI SendError(IN UINT8 ErrorNum)
UINTN ConvertLengthData(IN UINTN Length)
EFI_STATUS FindMatchingDebugRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN Address, IN UINTN Length, IN UINTN Type, OUT UINTN *Register)
EFI_STATUS DisableDebugRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN Register)
EFI_STATUS EnableDebugRegister(IN EFI_SYSTEM_CONTEXT SystemContext, IN UINTN Register, IN UINTN Address, IN UINTN Length, IN UINTN Type)
EFI_STATUS FindNextFreeDebugRegister(IN EFI_SYSTEM_CONTEXT SystemContext, OUT UINTN *Register)
#define OFFSET_OF(TYPE, Field)
EFI_INSTRUCTION_SET_ARCHITECTURE
#define EXCEPT_IA32_DIVIDE_ERROR
EFI_STATUS EFIAPI Register(IN EFI_PEI_RSC_HANDLER_CALLBACK Callback)
UINTN EFIAPI Print(IN CONST CHAR16 *Format,...)