diff options
author | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-06-11 02:15:11 +0000 |
---|---|---|
committer | vanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-06-11 02:15:11 +0000 |
commit | 93c0bdec2807cd968a89a0ac01a379a90fa50f93 (patch) | |
tree | 6d5fea7bf8312b2101fe64c295877e20047ed420 /SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.c | |
parent | 44538ba5aa759c4039fc6c588d33a7fe03503c3f (diff) | |
download | edk2-platforms-93c0bdec2807cd968a89a0ac01a379a90fa50f93.tar.xz |
This revision can only work with Intel(c) UDK Debugger Tool version 1.2 or greater. Detailed change log is as below:
1. Define the transfer protocol revision mechanism. Increase the revision number to 0.2 and inform user to use the latest one when the HOST software is too old.
New HOST software will implement logic to handle all other revision mismatch cases.
2. Define new debug message packet to print the debug agent trace information by debug port channel.
3. Add check sum mechanism in the communication protocol between TARGET/HOST.
4. Introduced one "try" mechanism to avoid Debug Agent crashed by some invalid HOST command.
5. Enable the late-attach feature: Change the break in from "!" to "\xFC". Add a new short symbol "\xFA" for attach and a new debug command for detach.
6. Support Terminal work on debug port by install EFI Serial IO protocol upon Debug Communication Library.
7. Enable CPUID feature.
8. Enable the hardware data breakpoint.
9. add handshake to improve usb debug cable identify stability issue.
10.Refine all the communication protocol packet to improve extensibility and debugging performance.
a. Use 64bit for IO port address.
b. Add additional Width field to READ_MEMORY/WRITE_MEMORY.
c. Add SEARCH_SIGNATURE support to speed the symbol finding for late attach.
d. Remove READ_GROUP register.
e. Add READ_ALL_REGISTERS support (WinDbg always requests to read all registers).
11.Move AcquireDebugPortControl () in advance to fix resource collision on IpiSentByApFlag.
12.Fix IO break point does not work issue in PEI phase.
13.Avoid BSP/APs collision when they met break point at the same time.
14.Solve a bug of calculating debug handle in sec phase.
15.Use mailbox content at Dxe phase but not clear it and reinitialize again.
16.Fix FP/MMX/XMM/IO/MSR access issue in both Gdb and WinDbg.
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Signed-off-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13437 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.c')
-rw-r--r-- | SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.c | 202 |
1 files changed, 7 insertions, 195 deletions
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.c b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.c index 3c18b8676f..9803f0f76f 100644 --- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.c +++ b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.c @@ -1,7 +1,7 @@ /** @file
- Supporting functions for x64 architecture.
+ Supporting functions for X64 architecture.
- Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -15,199 +15,6 @@ #include "DebugAgent.h"
/**
- Read the offset of FP / MMX / XMM registers by register index.
-
- @param[in] Index Register index.
- @param[out] Width Register width returned.
-
- @return Offset in register address range.
-
-**/
-UINT16
-ArchReadFxStatOffset (
- IN UINT8 Index,
- OUT UINT8 *Width
- )
-{
- if (Index < SOFT_DEBUGGER_REGISTER_ST0) {
- switch (Index) {
- case SOFT_DEBUGGER_REGISTER_FP_FCW:
- *Width = (UINT8) sizeof (UINT16);
- return OFFSET_OF(DEBUG_DATA_X64_FX_SAVE_STATE, Fcw);
-
- case SOFT_DEBUGGER_REGISTER_FP_FSW:
- *Width = (UINT8) sizeof (UINT16);
- return OFFSET_OF(DEBUG_DATA_X64_FX_SAVE_STATE, Fsw);
-
- case SOFT_DEBUGGER_REGISTER_FP_FTW:
- *Width = (UINT8) sizeof (UINT16);
- return OFFSET_OF(DEBUG_DATA_X64_FX_SAVE_STATE, Ftw);
-
- case SOFT_DEBUGGER_REGISTER_FP_OPCODE:
- *Width = (UINT8) sizeof (UINT16);
- return OFFSET_OF(DEBUG_DATA_X64_FX_SAVE_STATE, Opcode);
-
- case SOFT_DEBUGGER_REGISTER_FP_EIP:
- *Width = (UINT8) sizeof (UINTN);
- return OFFSET_OF(DEBUG_DATA_X64_FX_SAVE_STATE, Rip);
-
- case SOFT_DEBUGGER_REGISTER_FP_DATAOFFSET:
- *Width = (UINT8) sizeof (UINTN);
- return OFFSET_OF(DEBUG_DATA_X64_FX_SAVE_STATE, DataOffset);
-
- case SOFT_DEBUGGER_REGISTER_FP_MXCSR:
- *Width = (UINT8) sizeof (UINT32);
- return OFFSET_OF(DEBUG_DATA_X64_FX_SAVE_STATE, Mxcsr);
-
- case SOFT_DEBUGGER_REGISTER_FP_MXCSR_MASK:
- *Width = (UINT8) sizeof (UINT32);
- return OFFSET_OF(DEBUG_DATA_X64_FX_SAVE_STATE, Mxcsr_Mask);
-
- default:
- return (UINT16) (-1);
- }
- }
-
- if (Index < SOFT_DEBUGGER_REGISTER_XMM0) {
- *Width = 10;
- } else if (Index < SOFT_DEBUGGER_REGISTER_MM0 ) {
- *Width = 16;
- } else {
- *Width = 8;
- Index -= SOFT_DEBUGGER_REGISTER_MM0 - SOFT_DEBUGGER_REGISTER_ST0;
- }
-
- return OFFSET_OF(DEBUG_DATA_X64_FX_SAVE_STATE, St0Mm0) + (Index - SOFT_DEBUGGER_REGISTER_ST0) * 16;
-}
-
-/**
- Write specified register into save CPU context.
-
- @param[in] CpuContext Pointer to saved CPU context.
- @param[in] Index Register index value.
- @param[in] Offset Offset in register address range
- @param[in] Width Data width to read.
- @param[in] RegisterBuffer Pointer to input buffer with data.
-
-**/
-VOID
-ArchWriteRegisterBuffer (
- IN DEBUG_CPU_CONTEXT *CpuContext,
- IN UINT8 Index,
- IN UINT8 Offset,
- IN UINT8 Width,
- IN UINT8 *RegisterBuffer
- )
-{
- UINT8 *Buffer;
- if (Index < SOFT_DEBUGGER_REGISTER_FP_BASE) {
- Buffer = (UINT8 *) CpuContext + sizeof (DEBUG_DATA_X64_FX_SAVE_STATE) + Index * 8;
- } else {
- //
- // If it is MMX register, adjust its index position
- //
- if (Index >= SOFT_DEBUGGER_REGISTER_MM0) {
- Index -= SOFT_DEBUGGER_REGISTER_MM0 - SOFT_DEBUGGER_REGISTER_ST0;
- }
-
- //
- // FPU/MMX/XMM registers
- //
- Buffer = (UINT8 *) CpuContext + ArchReadFxStatOffset (Index, &Width);
- }
-
- CopyMem (Buffer + Offset, RegisterBuffer, Width);
-}
-
-/**
- Read register value from saved CPU context.
-
- @param[in] CpuContext Pointer to saved CPU context.
- @param[in] Index Register index value.
- @param[in] Offset Offset in register address range
- @param[in] Width Data width to read.
-
- @return The address of register value.
-
-**/
-UINT8 *
-ArchReadRegisterBuffer (
- IN DEBUG_CPU_CONTEXT *CpuContext,
- IN UINT8 Index,
- IN UINT8 Offset,
- IN UINT8 *Width
- )
-{
- UINT8 *Buffer;
-
- if (Index < SOFT_DEBUGGER_REGISTER_FP_BASE) {
- Buffer = (UINT8 *) CpuContext + sizeof (DEBUG_DATA_X64_FX_SAVE_STATE) + Index * 8;
- if (*Width == 0) {
- *Width = (UINT8) sizeof (UINTN);
- }
- } else {
- //
- // FPU/MMX/XMM registers
- //
- Buffer = (UINT8 *) CpuContext + ArchReadFxStatOffset (Index, Width);
- }
-
- return Buffer;
-}
-
-/**
- Read group register of common registers.
-
- @param[in] CpuContext Pointer to saved CPU context.
- @param[in] RegisterGroup Pointer to Group registers.
-
-**/
-VOID
-ReadRegisterGroup (
- IN DEBUG_CPU_CONTEXT *CpuContext,
- IN DEBUG_DATA_REPONSE_READ_REGISTER_GROUP *RegisterGroup
- )
-{
- RegisterGroup->Cs = (UINT16) CpuContext->Cs;
- RegisterGroup->Ds = (UINT16) CpuContext->Ds;
- RegisterGroup->Es = (UINT16) CpuContext->Es;
- RegisterGroup->Fs = (UINT16) CpuContext->Fs;
- RegisterGroup->Gs = (UINT16) CpuContext->Gs;
- RegisterGroup->Ss = (UINT16) CpuContext->Ss;
- RegisterGroup->Eflags = (UINT32) CpuContext->Eflags;
- RegisterGroup->Rbp = CpuContext->Rbp;
- RegisterGroup->Eip = CpuContext->Eip;
- RegisterGroup->Rsp = CpuContext->Rsp;
- RegisterGroup->Eax = CpuContext->Rax;
- RegisterGroup->Rbx = CpuContext->Rbx;
- RegisterGroup->Rcx = CpuContext->Rcx;
- RegisterGroup->Rdx = CpuContext->Rdx;
- RegisterGroup->Rsi = CpuContext->Rsi;
- RegisterGroup->Rdi = CpuContext->Rdi;
- RegisterGroup->R8 = CpuContext->R8;
- RegisterGroup->R9 = CpuContext->R9;
- RegisterGroup->R10 = CpuContext->R10;
- RegisterGroup->R11 = CpuContext->R11;
- RegisterGroup->R12 = CpuContext->R12;
- RegisterGroup->R13 = CpuContext->R13;
- RegisterGroup->R14 = CpuContext->R14;
- RegisterGroup->R15 = CpuContext->R15;
- RegisterGroup->Dr0 = CpuContext->Dr0;
- RegisterGroup->Dr1 = CpuContext->Dr1;
- RegisterGroup->Dr2 = CpuContext->Dr2;
- RegisterGroup->Dr3 = CpuContext->Dr3;
- RegisterGroup->Dr6 = CpuContext->Dr6;
- RegisterGroup->Dr7 = CpuContext->Dr7;
- RegisterGroup->Cr0 = CpuContext->Cr0;
- RegisterGroup->Cr2 = CpuContext->Cr2;
- RegisterGroup->Cr3 = CpuContext->Cr3;
- RegisterGroup->Cr4 = CpuContext->Cr4;
- RegisterGroup->Cr8 = CpuContext->Cr8;
-
- CopyMem ((UINT8 *) &RegisterGroup->Xmm0[0], (UINT8 *) &CpuContext->FxSaveState.Xmm0[0], 16 * 10);
-}
-
-/**
Initialize IDT entries to support source level debug.
**/
@@ -252,4 +59,9 @@ InitializeDebugIdt ( IdtEntry[DEBUG_TIMER_VECTOR].Bits.OffsetUpper = (UINT32)((UINTN)InterruptHandler >> 32);
IdtEntry[DEBUG_TIMER_VECTOR].Bits.Selector = CodeSegment;
IdtEntry[DEBUG_TIMER_VECTOR].Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
+
+ //
+ // Set DE flag in CR4 to enable IO breakpoint
+ //
+ AsmWriteCr4 (AsmReadCr4 () | BIT3);
}
|