summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2013-04-09 10:29:44 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2013-04-09 10:29:44 +0000
commit70ca4dee8facb0f23ebae8f7d5b4ef74f8d1ba61 (patch)
tree6829d2fc0609a8723dd4bc58fd9c30032c87d194
parent56720a68d425cc8293099555d396a56da03e472e (diff)
downloadedk2-70ca4dee8facb0f23ebae8f7d5b4ef74f8d1ba61.zip
edk2-70ca4dee8facb0f23ebae8f7d5b4ef74f8d1ba61.tar.gz
edk2-70ca4dee8facb0f23ebae8f7d5b4ef74f8d1ba61.tar.bz2
Delete old SourceLevelDebugPkg.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/branches/UDK2010.SR1@14254 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--SourceLevelDebugPkg/Include/Guid/DebugAgentGuid.h32
-rw-r--r--SourceLevelDebugPkg/Include/Ia32/ProcessorContext.h310
-rw-r--r--SourceLevelDebugPkg/Include/ImageDebugSupport.h27
-rw-r--r--SourceLevelDebugPkg/Include/Library/DebugCommunicationLib.h152
-rw-r--r--SourceLevelDebugPkg/Include/TransferProtocol.h369
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c1826
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h246
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.c404
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.h237
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugTimer.c83
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugTimer.h28
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/ArchDebugSupport.c65
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/ArchDebugSupport.h27
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.S366
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.asm371
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/DebugException.h36
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.c67
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.h27
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/AsmFuncs.S407
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/AsmFuncs.asm374
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/DebugException.h36
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.c271
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.h45
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/SerialIo.c722
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf95
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c354
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.h28
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf80
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c175
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.h24
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf79
-rw-r--r--SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.c175
-rw-r--r--SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf39
-rw-r--r--SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c1174
-rw-r--r--SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf54
-rw-r--r--SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c195
-rw-r--r--SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf45
-rw-r--r--SourceLevelDebugPkg/Readme.txt6
-rw-r--r--SourceLevelDebugPkg/SourceLevelDebugPkg.dec74
-rw-r--r--SourceLevelDebugPkg/SourceLevelDebugPkg.dsc67
40 files changed, 0 insertions, 9192 deletions
diff --git a/SourceLevelDebugPkg/Include/Guid/DebugAgentGuid.h b/SourceLevelDebugPkg/Include/Guid/DebugAgentGuid.h
deleted file mode 100644
index 87776a3..0000000
--- a/SourceLevelDebugPkg/Include/Guid/DebugAgentGuid.h
+++ /dev/null
@@ -1,32 +0,0 @@
-/** @file
- This file defines the debug agent GUID for HOB and configuration table.
-
- Copyright (c) 2010, 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef __EFI_DEBUG_AGNET_GUID_H__
-#define __EFI_DEBUG_AGENT_GUID_H__
-
-///
-/// This guid is used as a variable GUID for the capsule variable
-/// if the capsule pointer is passed through reset via a variable.
-///
-/// This guid is also used as a hob GUID for the capsule data
-/// when the capsule pointer is passed from PEI phase to DXE phase.
-///
-#define EFI_DEBUG_AGENT_GUID \
- { \
- 0x865a5a9b, 0xb85d, 0x474c, { 0x84, 0x55, 0x65, 0xd1, 0xbe, 0x84, 0x4b, 0xe2 } \
- }
-
-extern EFI_GUID gEfiDebugAgentGuid;
-
-#endif
diff --git a/SourceLevelDebugPkg/Include/Ia32/ProcessorContext.h b/SourceLevelDebugPkg/Include/Ia32/ProcessorContext.h
deleted file mode 100644
index c549a7f..0000000
--- a/SourceLevelDebugPkg/Include/Ia32/ProcessorContext.h
+++ /dev/null
@@ -1,310 +0,0 @@
-/** @file
- IA32/x64 architecture specific defintions needed by debug transfer protocol.It is only
- intended to be used by Debug related module implementation.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef __PROCESSOR_CONTEXT_H__
-#define __PROCESSOR_CONTEXT_H__
-
-//
-// IA-32/x64 processor register index table
-//
-#define SOFT_DEBUGGER_REGISTER_DR0 0x00
-#define SOFT_DEBUGGER_REGISTER_DR1 0x01
-#define SOFT_DEBUGGER_REGISTER_DR2 0x02
-#define SOFT_DEBUGGER_REGISTER_DR3 0x03
-#define SOFT_DEBUGGER_REGISTER_DR6 0x04
-#define SOFT_DEBUGGER_REGISTER_DR7 0x05
-#define SOFT_DEBUGGER_REGISTER_EFLAGS 0x06
-#define SOFT_DEBUGGER_REGISTER_LDTR 0x07
-#define SOFT_DEBUGGER_REGISTER_TR 0x08
-#define SOFT_DEBUGGER_REGISTER_GDTR0 0x09 // the low 32bit of GDTR
-#define SOFT_DEBUGGER_REGISTER_GDTR1 0x0A // the high 32bit of GDTR
-#define SOFT_DEBUGGER_REGISTER_IDTR0 0x0B // the low 32bit of IDTR
-#define SOFT_DEBUGGER_REGISTER_IDTR1 0x0C // the high 32bot of IDTR
-#define SOFT_DEBUGGER_REGISTER_EIP 0x0D
-#define SOFT_DEBUGGER_REGISTER_GS 0x0E
-#define SOFT_DEBUGGER_REGISTER_FS 0x0F
-#define SOFT_DEBUGGER_REGISTER_ES 0x10
-#define SOFT_DEBUGGER_REGISTER_DS 0x11
-#define SOFT_DEBUGGER_REGISTER_CS 0x12
-#define SOFT_DEBUGGER_REGISTER_SS 0x13
-#define SOFT_DEBUGGER_REGISTER_CR0 0x14
-#define SOFT_DEBUGGER_REGISTER_CR1 0x15
-#define SOFT_DEBUGGER_REGISTER_CR2 0x16
-#define SOFT_DEBUGGER_REGISTER_CR3 0x17
-#define SOFT_DEBUGGER_REGISTER_CR4 0x18
-
-#define SOFT_DEBUGGER_REGISTER_DI 0x19
-#define SOFT_DEBUGGER_REGISTER_SI 0x1A
-#define SOFT_DEBUGGER_REGISTER_BP 0x1B
-#define SOFT_DEBUGGER_REGISTER_SP 0x1C
-#define SOFT_DEBUGGER_REGISTER_DX 0x1D
-#define SOFT_DEBUGGER_REGISTER_CX 0x1E
-#define SOFT_DEBUGGER_REGISTER_BX 0x1F
-#define SOFT_DEBUGGER_REGISTER_AX 0x20
-
-//
-// This below registers are only available for x64 (not valid for Ia32 mode)
-//
-#define SOFT_DEBUGGER_REGISTER_CR8 0x21
-#define SOFT_DEBUGGER_REGISTER_R8 0x22
-#define SOFT_DEBUGGER_REGISTER_R9 0x23
-#define SOFT_DEBUGGER_REGISTER_R10 0x24
-#define SOFT_DEBUGGER_REGISTER_R11 0x25
-#define SOFT_DEBUGGER_REGISTER_R12 0x26
-#define SOFT_DEBUGGER_REGISTER_R13 0x27
-#define SOFT_DEBUGGER_REGISTER_R14 0x28
-#define SOFT_DEBUGGER_REGISTER_R15 0x29
-
-//
-// This below registers are FP / MMX / XMM registers
-//
-#define SOFT_DEBUGGER_REGISTER_FP_BASE 0x30
-
-#define SOFT_DEBUGGER_REGISTER_FP_FCW (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x00)
-#define SOFT_DEBUGGER_REGISTER_FP_FSW (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x01)
-#define SOFT_DEBUGGER_REGISTER_FP_FTW (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x02)
-#define SOFT_DEBUGGER_REGISTER_FP_OPCODE (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x03)
-#define SOFT_DEBUGGER_REGISTER_FP_EIP (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x04)
-#define SOFT_DEBUGGER_REGISTER_FP_CS (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x05)
-#define SOFT_DEBUGGER_REGISTER_FP_DATAOFFSET (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x06)
-#define SOFT_DEBUGGER_REGISTER_FP_DS (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x07)
-#define SOFT_DEBUGGER_REGISTER_FP_MXCSR (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x08)
-#define SOFT_DEBUGGER_REGISTER_FP_MXCSR_MASK (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x09)
-#define SOFT_DEBUGGER_REGISTER_ST0 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x0A)
-#define SOFT_DEBUGGER_REGISTER_ST1 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x0B)
-#define SOFT_DEBUGGER_REGISTER_ST2 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x0C)
-#define SOFT_DEBUGGER_REGISTER_ST3 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x0D)
-#define SOFT_DEBUGGER_REGISTER_ST4 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x0E)
-#define SOFT_DEBUGGER_REGISTER_ST5 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x0F)
-#define SOFT_DEBUGGER_REGISTER_ST6 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x10)
-#define SOFT_DEBUGGER_REGISTER_ST7 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x11)
-#define SOFT_DEBUGGER_REGISTER_XMM0 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x12)
-#define SOFT_DEBUGGER_REGISTER_XMM1 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x13)
-#define SOFT_DEBUGGER_REGISTER_XMM2 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x14)
-#define SOFT_DEBUGGER_REGISTER_XMM3 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x15)
-#define SOFT_DEBUGGER_REGISTER_XMM4 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x16)
-#define SOFT_DEBUGGER_REGISTER_XMM5 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x17)
-#define SOFT_DEBUGGER_REGISTER_XMM6 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x18)
-#define SOFT_DEBUGGER_REGISTER_XMM7 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x19)
-#define SOFT_DEBUGGER_REGISTER_XMM8 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x1A)
-#define SOFT_DEBUGGER_REGISTER_XMM9 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x1B)
-#define SOFT_DEBUGGER_REGISTER_XMM10 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x1C)
-#define SOFT_DEBUGGER_REGISTER_XMM11 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x1D)
-#define SOFT_DEBUGGER_REGISTER_XMM12 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x1E)
-#define SOFT_DEBUGGER_REGISTER_XMM13 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x1F)
-#define SOFT_DEBUGGER_REGISTER_XMM14 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x20)
-#define SOFT_DEBUGGER_REGISTER_XMM15 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x21)
-#define SOFT_DEBUGGER_REGISTER_MM0 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x22)
-#define SOFT_DEBUGGER_REGISTER_MM1 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x23)
-#define SOFT_DEBUGGER_REGISTER_MM2 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x24)
-#define SOFT_DEBUGGER_REGISTER_MM3 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x25)
-#define SOFT_DEBUGGER_REGISTER_MM4 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x26)
-#define SOFT_DEBUGGER_REGISTER_MM5 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x27)
-#define SOFT_DEBUGGER_REGISTER_MM6 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x28)
-#define SOFT_DEBUGGER_REGISTER_MM7 (SOFT_DEBUGGER_REGISTER_FP_BASE + 0x29)
-
-#define SOFT_DEBUGGER_REGISTER_MAX SOFT_DEBUGGER_REGISTER_MM7
-
-#define SOFT_DEBUGGER_MSR_EFER (0xC0000080)
-
-#pragma pack(1)
-
-///
-/// FXSAVE_STATE
-/// FP / MMX / XMM registers (see fxrstor instruction definition)
-///
-typedef struct {
- UINT16 Fcw;
- UINT16 Fsw;
- UINT16 Ftw;
- UINT16 Opcode;
- UINT32 Eip;
- UINT16 Cs;
- UINT16 Reserved1;
- UINT32 DataOffset;
- UINT16 Ds;
- UINT8 Reserved2[2];
- UINT32 Mxcsr;
- UINT32 Mxcsr_Mask;
- UINT8 St0Mm0[10];
- UINT8 Reserved3[6];
- UINT8 St1Mm1[10];
- UINT8 Reserved4[6];
- UINT8 St2Mm2[10];
- UINT8 Reserved5[6];
- UINT8 St3Mm3[10];
- UINT8 Reserved6[6];
- UINT8 St4Mm4[10];
- UINT8 Reserved7[6];
- UINT8 St5Mm5[10];
- UINT8 Reserved8[6];
- UINT8 St6Mm6[10];
- UINT8 Reserved9[6];
- UINT8 St7Mm7[10];
- UINT8 Reserved10[6];
- UINT8 Xmm0[16];
- UINT8 Xmm1[16];
- UINT8 Xmm2[16];
- UINT8 Xmm3[16];
- UINT8 Xmm4[16];
- UINT8 Xmm5[16];
- UINT8 Xmm6[16];
- UINT8 Xmm7[16];
- UINT8 Reserved11[14 * 16];
-} DEBUG_DATA_IA32_FX_SAVE_STATE;
-
-///
-/// IA-32 processor context definition
-///
-typedef struct {
- UINT32 ExceptionData;
- DEBUG_DATA_IA32_FX_SAVE_STATE FxSaveState;
- UINT32 Dr0;
- UINT32 Dr1;
- UINT32 Dr2;
- UINT32 Dr3;
- UINT32 Dr6;
- UINT32 Dr7;
- UINT32 Eflags;
- UINT32 Ldtr;
- UINT32 Tr;
- UINT32 Gdtr[2];
- UINT32 Idtr[2];
- UINT32 Eip;
- UINT32 Gs;
- UINT32 Fs;
- UINT32 Es;
- UINT32 Ds;
- UINT32 Cs;
- UINT32 Ss;
- UINT32 Cr0;
- UINT32 Cr1; ///< Reserved
- UINT32 Cr2;
- UINT32 Cr3;
- UINT32 Cr4;
- UINT32 Edi;
- UINT32 Esi;
- UINT32 Ebp;
- UINT32 Esp;
- UINT32 Edx;
- UINT32 Ecx;
- UINT32 Ebx;
- UINT32 Eax;
-} DEBUG_DATA_IA32_SYSTEM_CONTEXT;
-
-///
-/// FXSAVE_STATE
-/// FP / MMX / XMM registers (see fxrstor instruction definition)
-///
-typedef struct {
- UINT16 Fcw;
- UINT16 Fsw;
- UINT16 Ftw;
- UINT16 Opcode;
- UINT32 Eip;
- UINT16 Cs;
- UINT16 Reserved1;
- UINT32 DataOffset;
- UINT16 Ds;
- UINT8 Reserved2[2];
- UINT32 Mxcsr;
- UINT32 Mxcsr_Mask;
- UINT8 St0Mm0[10];
- UINT8 Reserved3[6];
- UINT8 St1Mm1[10];
- UINT8 Reserved4[6];
- UINT8 St2Mm2[10];
- UINT8 Reserved5[6];
- UINT8 St3Mm3[10];
- UINT8 Reserved6[6];
- UINT8 St4Mm4[10];
- UINT8 Reserved7[6];
- UINT8 St5Mm5[10];
- UINT8 Reserved8[6];
- UINT8 St6Mm6[10];
- UINT8 Reserved9[6];
- UINT8 St7Mm7[10];
- UINT8 Reserved10[6];
- UINT8 Xmm0[16];
- UINT8 Xmm1[16];
- UINT8 Xmm2[16];
- UINT8 Xmm3[16];
- UINT8 Xmm4[16];
- UINT8 Xmm5[16];
- UINT8 Xmm6[16];
- UINT8 Xmm7[16];
- UINT8 Xmm8[16];
- UINT8 Xmm9[16];
- UINT8 Xmm10[16];
- UINT8 Xmm11[16];
- UINT8 Xmm12[16];
- UINT8 Xmm13[16];
- UINT8 Xmm14[16];
- UINT8 Xmm15[16];
- UINT8 Reserved11[6 * 16];
-} DEBUG_DATA_X64_FX_SAVE_STATE;
-
-///
-/// x64 processor context definition
-///
-typedef struct {
- UINT64 ExceptionData;
- DEBUG_DATA_X64_FX_SAVE_STATE FxSaveState;
- UINT64 Dr0;
- UINT64 Dr1;
- UINT64 Dr2;
- UINT64 Dr3;
- UINT64 Dr6;
- UINT64 Dr7;
- UINT64 Eflags;
- UINT64 Ldtr;
- UINT64 Tr;
- UINT64 Gdtr[2];
- UINT64 Idtr[2];
- UINT64 Eip;
- UINT64 Gs;
- UINT64 Fs;
- UINT64 Es;
- UINT64 Ds;
- UINT64 Cs;
- UINT64 Ss;
- UINT64 Cr0;
- UINT64 Cr1; ///< Reserved
- UINT64 Cr2;
- UINT64 Cr3;
- UINT64 Cr4;
- UINT64 Rdi;
- UINT64 Rsi;
- UINT64 Rbp;
- UINT64 Rsp;
- UINT64 Rdx;
- UINT64 Rcx;
- UINT64 Rbx;
- UINT64 Rax;
- UINT64 Cr8;
- UINT64 R8;
- UINT64 R9;
- UINT64 R10;
- UINT64 R11;
- UINT64 R12;
- UINT64 R13;
- UINT64 R14;
- UINT64 R15;
-} DEBUG_DATA_X64_SYSTEM_CONTEXT;
-
-#pragma pack()
-
-#endif
-
diff --git a/SourceLevelDebugPkg/Include/ImageDebugSupport.h b/SourceLevelDebugPkg/Include/ImageDebugSupport.h
deleted file mode 100644
index 6829985..0000000
--- a/SourceLevelDebugPkg/Include/ImageDebugSupport.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/** @file
- Public include file for Debug Agent Library instance and PE/COFF Extra
- Action Library instance.
-
- Copyright (c) 2010, 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef __IMAGE_DEBUG_SUPPORT_H__
-#define __IMAGE_DEBUG_SUPPORT_H__
-
-#define IO_PORT_BREAKPOINT_ADDRESS 0x84
-#define IMAGE_LOAD_SIGNATURE SIGNATURE_32('L','O','A','D')
-#define IMAGE_UNLOAD_SIGNATURE SIGNATURE_32('U','N','L','O')
-
-#define DEBUG_AGENT_IMAGE_WAIT 0x00
-#define DEBUG_AGENT_IMAGE_CONTINUE 0x01
-
-#endif
-
diff --git a/SourceLevelDebugPkg/Include/Library/DebugCommunicationLib.h b/SourceLevelDebugPkg/Include/Library/DebugCommunicationLib.h
deleted file mode 100644
index 8fc0aa7..0000000
--- a/SourceLevelDebugPkg/Include/Library/DebugCommunicationLib.h
+++ /dev/null
@@ -1,152 +0,0 @@
-/** @file
- Debug Communication Library definitions.
-
- Copyright (c) 2010, 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef __DEBUG_COMMUNICATION_LIB_H__
-#define __DEBUG_COMMUNICATION_LIB_H__
-
-typedef VOID * DEBUG_PORT_HANDLE;
-
-/**
- Caller provided function to be invoked at the end of DebugPortInitialize().
-
- Refer to the descrption for DebugPortInitialize() for more details.
-
- @param[in] Context The first input argument of DebugPortInitialize().
- @param[in] DebugPortHandle Debug port handle created by Debug Communication Libary.
-
-**/
-typedef
-VOID
-(EFIAPI * DEBUG_PORT_CONTINUE)(
- IN VOID *Context,
- IN DEBUG_PORT_HANDLE DebugPortHandle
- );
-
-/**
- Initialize the debug port.
-
- This function will initialize debug port to get it ready for data transmition. If
- certain Debug Communication Library instance has to save some private data in the
- stack, this function must work on the mode that doesn't return to the caller, then
- the caller needs to wrap up all rest of logic after DebugPortInitialize() into one
- function and pass it into DebugPortInitialize(). DebugPortInitialize() is
- responsible to invoke the passing-in funciton at the end of DebugPortInitialize().
-
- If the paramter Function is not NULL, Debug Communication Libary instance will
- invoke it by passing in the Context to be the first parameter. Debug Communication
- Library instance could create one debug port handle to be the second parameter
- passing into the Function. Debug Communication Library instance also could pass
- NULL to be the second parameter if it doesn't create the debug port handle.
-
- If the parameter Function is NULL, and Context is not NULL. At this time, Context
- is the debug port handle created by the previous Debug Communication Library
- instance.
- a) If the instance can understand and continue use the private data of the previous
- instance, it could return the same handle as passed in (as Context parameter).
- b) If the instance does not understand, or does not want to continue use the
- private data of the previous instance, it could ignore the input Context parameter
- and create the new hanlde to be returned.
-
- If Function() is NULL and Context is NULL, Debug Communication Library could create a
- new handle and return it. NULL is also a valid handle to be returned.
-
- @param[in] Context Context needed by callback function; it was optional.
- @param[in] Function Continue function called by Debug Communication library;
- it was optional.
-
- @return The debug port handle created by Debug Communication Library if Function
- is not NULL.
-
-**/
-DEBUG_PORT_HANDLE
-EFIAPI
-DebugPortInitialize (
- IN VOID *Context,
- IN DEBUG_PORT_CONTINUE Function
- );
-
-
-/**
- Read data from debug device and save the datas in buffer.
-
- Reads NumberOfBytes data bytes from a debug device into the buffer
- specified by Buffer. The number of bytes actually read is returned.
- If the return value is less than NumberOfBytes, then the rest operation failed.
- If NumberOfBytes is zero, then return 0.
-
- @param Handle Debug port handle.
- @param Buffer Pointer to the data buffer to store the data read from the debug device.
- @param NumberOfBytes Number of bytes which will be read.
- @param Timeout Timeout value for reading from debug device. It unit is Microsecond.
-
- @retval 0 Read data failed, no data is to be read.
- @retval >0 Actual number of bytes read from debug device.
-
-**/
-UINTN
-EFIAPI
-DebugPortReadBuffer (
- IN DEBUG_PORT_HANDLE Handle,
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes,
- IN UINTN Timeout
- );
-
-
-/**
- Write data from buffer to debug device.
-
- Writes NumberOfBytes data bytes from Buffer to the debug device.
- The number of bytes actually written to the debug device is returned.
- If the return value is less than NumberOfBytes, then the write operation failed.
- If NumberOfBytes is zero, then return 0.
-
- @param Handle Debug port handle.
- @param Buffer Pointer to the data buffer to be written.
- @param NumberOfBytes Number of bytes to written to the debug device.
-
- @retval 0 NumberOfBytes is 0.
- @retval >0 The number of bytes written to the debug device.
- If this value is less than NumberOfBytes, then the read operation failed.
-
-**/
-UINTN
-EFIAPI
-DebugPortWriteBuffer (
- IN DEBUG_PORT_HANDLE Handle,
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
- );
-
-/**
- Polls a debug device to see if there is any data waiting to be read.
-
- Polls a debug device to see if there is any data waiting to be read.
- If there is data waiting to be read from the debug device, then TRUE is returned.
- If there is no data waiting to be read from the debug device, then FALSE is returned.
-
- @param Handle Debug port handle.
-
- @retval TRUE Data is waiting to be read from the debug device.
- @retval FALSE There is no data waiting to be read from the serial device.
-
-**/
-BOOLEAN
-EFIAPI
-DebugPortPollBuffer (
- IN DEBUG_PORT_HANDLE Handle
- );
-
-#endif
-
diff --git a/SourceLevelDebugPkg/Include/TransferProtocol.h b/SourceLevelDebugPkg/Include/TransferProtocol.h
deleted file mode 100644
index bb7b07b..0000000
--- a/SourceLevelDebugPkg/Include/TransferProtocol.h
+++ /dev/null
@@ -1,369 +0,0 @@
-/** @file
- Transfer protocol defintions used by debug agent and host. It is only
- intended to be used by Debug related module implementation.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef __TRANSFER_PROTOCOL_H__
-#define __TRANSFER_PROTOCOL_H__
-
-#include "ProcessorContext.h"
-
-//
-// Current revision of transfer protocol
-//
-#define DEBUG_AGENT_REVISION ((0 << 16) | 02)
-#define DEBUG_AGENT_CAPABILITIES 0
-
-//
-// Definitions for break command.
-//
-#define DEBUG_STARTING_SYMBOL_BREAK (0xFC)
-
-//
-// Definitions for attach command
-//
-#define DEBUG_STARTING_SYMBOL_ATTACH (0xFA)
-
-//
-// Definition for starting symbol of a normal debug packet. Choose a non-ASCII to avoid conflict with other serial output.
-//
-#define DEBUG_STARTING_SYMBOL_NORMAL (0xFE)
-
-
-#pragma pack(1)
-
-//
-// Definition for debug packet header for normal debug packets (not including break/attach command)
-//
-typedef struct {
- UINT8 StartSymbol;
- UINT8 Command;
- UINT8 Length; // Length of Debug Packet including header and payload in byte
- UINT8 CheckSum;
-} DEBUG_PACKET_HEADER;
-
-//
-// Definition for Command field for debug packets
-//
-#define DEBUG_COMMAND_REQUEST (0 << 7)
-#define DEBUG_COMMAND_RESPONSE (1 << 7)
-
-//
-// HOST initiated commands
-//
-#define DEBUG_COMMAND_RESET (DEBUG_COMMAND_REQUEST | 0x00)
-#define DEBUG_COMMAND_GO (DEBUG_COMMAND_REQUEST | 0x01)
-#define DEBUG_COMMAND_BREAK_CAUSE (DEBUG_COMMAND_REQUEST | 0x02)
-#define DEBUG_COMMAND_SET_HW_BREAKPOINT (DEBUG_COMMAND_REQUEST | 0x03)
-#define DEBUG_COMMAND_CLEAR_HW_BREAKPOINT (DEBUG_COMMAND_REQUEST | 0x04)
-#define DEBUG_COMMAND_SINGLE_STEPPING (DEBUG_COMMAND_REQUEST | 0x05)
-#define DEBUG_COMMAND_SET_SW_BREAKPOINT (DEBUG_COMMAND_REQUEST | 0x06)
-#define DEBUG_COMMAND_READ_MEMORY (DEBUG_COMMAND_REQUEST | 0x07)
-#define DEBUG_COMMAND_WRITE_MEMORY (DEBUG_COMMAND_REQUEST | 0x08)
-#define DEBUG_COMMAND_READ_IO (DEBUG_COMMAND_REQUEST | 0x09)
-#define DEBUG_COMMAND_WRITE_IO (DEBUG_COMMAND_REQUEST | 0x0A)
-#define DEBUG_COMMAND_READ_REGISTER (DEBUG_COMMAND_REQUEST | 0x0B)
-#define DEBUG_COMMAND_WRITE_REGISTER (DEBUG_COMMAND_REQUEST | 0x0C)
-#define DEBUG_COMMAND_READ_ALL_REGISTERS (DEBUG_COMMAND_REQUEST | 0x0D)
-#define DEBUG_COMMAND_ARCH_MODE (DEBUG_COMMAND_REQUEST | 0x0E)
-#define DEBUG_COMMAND_READ_MSR (DEBUG_COMMAND_REQUEST | 0x0F)
-#define DEBUG_COMMAND_WRITE_MSR (DEBUG_COMMAND_REQUEST | 0x10)
-#define DEBUG_COMMAND_SET_DEBUG_SETTING (DEBUG_COMMAND_REQUEST | 0x11)
-#define DEBUG_COMMAND_GET_REVISION (DEBUG_COMMAND_REQUEST | 0x12)
-#define DEBUG_COMMAND_GET_EXCEPTION (DEBUG_COMMAND_REQUEST | 0x13)
-#define DEBUG_COMMAND_SET_VIEWPOINT (DEBUG_COMMAND_REQUEST | 0x14)
-#define DEBUG_COMMAND_GET_VIEWPOINT (DEBUG_COMMAND_REQUEST | 0x15)
-#define DEBUG_COMMAND_DETACH (DEBUG_COMMAND_REQUEST | 0x16)
-#define DEBUG_COMMAND_CPUID (DEBUG_COMMAND_REQUEST | 0x17)
-#define DEBUG_COMMAND_SEARCH_SIGNATURE (DEBUG_COMMAND_REQUEST | 0x18)
-
-//
-// TARGET initiated commands
-//
-#define DEBUG_COMMAND_INIT_BREAK (DEBUG_COMMAND_REQUEST | 0x3F)
-#define DEBUG_COMMAND_BREAK_POINT (DEBUG_COMMAND_REQUEST | 0x3E)
-#define DEBUG_COMMAND_MEMORY_READY (DEBUG_COMMAND_REQUEST | 0x3D)
-#define DEBUG_COMMAND_PRINT_MESSAGE (DEBUG_COMMAND_REQUEST | 0x3C)
-
-//
-// Response commands
-//
-#define DEBUG_COMMAND_OK (DEBUG_COMMAND_RESPONSE | 0x00)
-#define DEBUG_COMMAND_RESEND (DEBUG_COMMAND_RESPONSE | 0x01)
-#define DEBUG_COMMAND_ABORT (DEBUG_COMMAND_RESPONSE | 0x02)
-//
-// The below 2 commands are used when transferring big data (like > ~250 bytes).
-// The sequence is:
-// HOST TARGET
-// Request =>
-// <= IN_PROGRESS with partial data
-// CONTINUE =>
-// (could have multiple IN_PROGRESS and CONTINUE interactions)
-// <= OK with the last part of data
-// OK (no data as ACK) =>
-//
-#define DEBUG_COMMAND_IN_PROGRESS (DEBUG_COMMAND_RESPONSE | 0x03)
-#define DEBUG_COMMAND_CONTINUE (DEBUG_COMMAND_RESPONSE | 0x04)
-//
-// The below 2 commands are used to support deferred halt:
-// TARGET returns HALT_DEFERRED when it receives a HALT request in inter-active mode.
-// TARGET returns HALT_PROCESSED when it receives a GO request and has a pending HALT request.
-//
-#define DEBUG_COMMAND_HALT_DEFERRED (DEBUG_COMMAND_RESPONSE | 0x05)
-#define DEBUG_COMMAND_HALT_PROCESSED (DEBUG_COMMAND_RESPONSE | 0x06)
-
-#define DEBUG_COMMAND_TIMEOUT (DEBUG_COMMAND_RESPONSE | 0x07)
-#define DEBUG_COMMAND_NOT_SUPPORTED (DEBUG_COMMAND_RESPONSE | 0x0F)
-
-//
-// Definition for data field for debug packets
-//
-#define DEBUG_DATA_UPPER_LIMIT 0xff // Upper limit for the data size, by the limit of the packet header definition.
-
-#define DEBUG_DATA_MAXIMUM_REAL_DATA (DEBUG_DATA_UPPER_LIMIT - sizeof (DEBUG_PACKET_HEADER))
-
-//
-// Response data for DEBUG_COMMAND_BREAK_CAUSE
-//
-typedef struct {
- UINT8 Cause;
- UINT64 StopAddress;
-} DEBUG_DATA_RESPONSE_BREAK_CAUSE;
-//
-// Break type defintions for DEBUG_DATA_BREAK_CAUSE
-//
-#define DEBUG_DATA_BREAK_CAUSE_UNKNOWN 0
-#define DEBUG_DATA_BREAK_CAUSE_HW_BREAKPOINT 1
-#define DEBUG_DATA_BREAK_CAUSE_STEPPING 2
-#define DEBUG_DATA_BREAK_CAUSE_SW_BREAKPOINT 3
-#define DEBUG_DATA_BREAK_CAUSE_USER_HALT 4
-#define DEBUG_DATA_BREAK_CAUSE_IMAGE_LOAD 5
-#define DEBUG_DATA_BREAK_CAUSE_IMAGE_UNLOAD 6
-#define DEBUG_DATA_BREAK_CAUSE_SYSTEM_RESET 7
-#define DEBUG_DATA_BREAK_CAUSE_EXCEPTION 8
-#define DEBUG_DATA_BREAK_CAUSE_MEMORY_READY 9
-
-//
-// Response data for DEBUG_COMMAND_ARCH_MODE, defined as SOFT_DEBUGGER_PROCESSOR_...
-//
-typedef struct {
- UINT8 CpuMode;
-} DEBUG_DATA_RESPONSE_ARCH_MODE;
-//
-// Cpu architecture defintions for DEBUG_DATA_RESPONSE_ARCH_MODE
-//
-#define DEBUG_DATA_BREAK_CPU_ARCH_IA16 0
-#define DEBUG_DATA_BREAK_CPU_ARCH_IA32 1
-#define DEBUG_DATA_BREAK_CPU_ARCH_X64 2
-
-typedef struct {
- UINT8 Length:2; // Refer to below DEBUG_DATA_BREAKPOINT_LENGTH_XX macros
- UINT8 Access:2; // Refer to below DEBUG_DATA_BREAKPOINT_ACCESS_XX macros
- UINT8 Index:2; // Index of debug register
- UINT8 Reserved:2;
-} DEBUG_DATA_BREAKPOINT_TYPE;
-#define DEBUG_DATA_BREAKPOINT_MEMORY_ACCESS (0x3)
-#define DEBUG_DATA_BREAKPOINT_IO_ACCESS (0x2)
-#define DEBUG_DATA_BREAKPOINT_MEMORY_WRITE (0x1)
-#define DEBUG_DATA_BREAKPOINT_MEMORY_EXECUTE (0x0)
-#define DEBUG_DATA_BREAKPOINT_LENGTH_32 (0x3)
-#define DEBUG_DATA_BREAKPOINT_LENGTH_64 (0x2)
-#define DEBUG_DATA_BREAKPOINT_LENGTH_16 (0x1)
-#define DEBUG_DATA_BREAKPOINT_LENGTH_8 (0x0)
-
-//
-// Request data for DEBUG_COMMAND_SET_HW_BREAKPOINT
-//
-typedef struct {
- DEBUG_DATA_BREAKPOINT_TYPE Type;
- UINT64 Address;
-} DEBUG_DATA_SET_HW_BREAKPOINT;
-
-//
-// Request data for DEBUG_COMMAND_CLEAR_HW_BREAKPOINT
-//
-typedef struct {
- UINT8 IndexMask; // 0x0f will clear all hw breakpoints
-} DEBUG_DATA_CLEAR_HW_BREAKPOINT;
-
-//
-// Request and response data for DEBUG_COMMAND_SET_SW_BREAKPOINT
-//
-typedef struct {
- UINT64 Address;
-} DEBUG_DATA_SET_SW_BREAKPOINT;
-
-typedef struct {
- UINT8 OriginalData;
-} DEBUG_DATA_RESPONSE_SET_SW_BREAKPOINT;
-
-//
-// Request data for DEBUG_COMMAND_READ_MEMORY
-//
-typedef struct {
- UINT64 Address;
- UINT8 Width;
- UINT16 Count;
-} DEBUG_DATA_READ_MEMORY;
-
-//
-// Request data for DEBUG_COMMAND_WRITE_MEMORY
-//
-typedef struct {
- UINT64 Address;
- UINT8 Width;
- UINT16 Count;
- UINT8 Data[1]; // The actual length is (Width * Count)
-} DEBUG_DATA_WRITE_MEMORY;
-
-//
-// Request and response data for DEBUG_COMMAND_READ_IO
-//
-typedef struct {
- UINT64 Port;
- UINT8 Width;
-} DEBUG_DATA_READ_IO;
-
-typedef struct {
- UINT8 Data[1]; // The actual length depends on the packet header
-} DEBUG_DATA_RESPONSE_READ_IO;
-
-//
-// Request data for DEBUG_COMMAND_WRITE_IO
-//
-typedef struct {
- UINT64 Port;
- UINT8 Width;
- UINT8 Data[1]; // The actual length is Width
-} DEBUG_DATA_WRITE_IO;
-
-//
-// Request data for DEBUG_COMMAND_READ_REGISTER
-//
-typedef struct {
- UINT8 Index; // defined as SOFT_DEBUGGER_REGISTER_XX
-} DEBUG_DATA_READ_REGISTER;
-
-//
-// Request data for DEBUG_COMMAND_WRITE_REGISTER
-//
-typedef struct {
- UINT8 Index; // defined as SOFT_DEBUGGER_REGISTER_XX
- UINT8 Length;
- UINT8 Data[1]; // The actual length is Length
-} DEBUG_DATA_WRITE_REGISTER;
-
-//
-// Request and response data for DEBUG_COMMAND_READ_MSR
-//
-typedef struct {
- UINT32 Index;
-} DEBUG_DATA_READ_MSR;
-
-typedef struct {
- UINT64 Value;
-} DEBUG_DATA_RESPONSE_READ_MSR;
-
-//
-// Request data for DEBUG_COMMAND_WRITE_MSR
-//
-typedef struct {
- UINT32 Index;
- UINT64 Value;
-} DEBUG_DATA_WRITE_MSR;
-
-//
-// Response data for DEBUG_COMMAND_GET_REVISION
-//
-typedef struct {
- UINT32 Revision;
- UINT32 Capabilities;
-} DEBUG_DATA_RESPONSE_GET_REVISION;
-
-//
-// Response data for DEBUG_COMMAND_GET_EXCEPTION
-//
-typedef struct {
- UINT8 ExceptionNum;
- UINT32 ExceptionData;
-} DEBUG_DATA_RESPONSE_GET_EXCEPTION;
-
-//
-// Request data for DEBUG_DATA_SET_DEBUG_SETTING
-//
-typedef struct {
- UINT8 Key;
- UINT8 Value;
-} DEBUG_DATA_SET_DEBUG_SETTING;
-//
-// Supported keys
-//
-#define DEBUG_AGENT_SETTING_SMM_ENTRY_BREAK 1
-#define DEBUG_AGENT_SETTING_PRINT_ERROR_LEVEL 2
-//
-// Bitmask of print error level for debug message
-//
-#define DEBUG_AGENT_ERROR BIT0
-#define DEBUG_AGENT_WARNING BIT1
-#define DEBUG_AGENT_INFO BIT2
-#define DEBUG_AGENT_VERBOSE BIT3
-
-//
-// Request data for DEBUG_COMMAND_SET_VIEWPOINT
-//
-typedef struct {
- UINT32 ViewPoint; // The index of viewpoint will be set
-} DEBUG_DATA_SET_VIEWPOINT;
-
-//
-// Response data for DEBUG_COMMAND_GET_VIEWPOINT
-//
-typedef struct {
- UINT32 ViewPoint; // The index of viewpoint will be returned
-} DEBUG_DATA_RESPONSE_GET_VIEWPOINT;
-
-//
-// Request and response data for DEBUG_COMMAND_CPUID
-//
-typedef struct {
- UINT32 Eax; // The value of EAX prior to invoking the CPUID instruction
- UINT32 Ecx; // The value of ECX prior to invoking the CPUID instruction
-} DEBUG_DATA_CPUID;
-
-typedef struct {
- UINT32 Eax; // The value of EAX returned by the CPUID instruction
- UINT32 Ebx; // The value of EBX returned by the CPUID instruction
- UINT32 Ecx; // The value of ECX returned by the CPUID instruction
- UINT32 Edx; // The value of EDX returned by the CPUID instruction
-} DEBUG_DATA_RESPONSE_CPUID;
-
-//
-// Request and response data for DEBUG_COMMAND_SEARCH_SIGNATURE
-//
-typedef struct {
- UINT64 Start;
- UINT32 Count;
- UINT32 Alignment;
- BOOLEAN Positive; // TRUE to search in higher address memory
- UINT8 DataLength;
- UINT8 Data[1];
-} DEBUG_DATA_SEARCH_SIGNATURE;
-
-typedef struct {
- UINT64 Address; // -1 indicates not found
-} DEBUG_DATA_RESPONSE_SEARCH_SIGNATURE;
-
-#pragma pack()
-
-#endif
-
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c
deleted file mode 100644
index 04dae34..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c
+++ /dev/null
@@ -1,1826 +0,0 @@
-/** @file
- Commond Debug Agent library implementition. It mainly includes
- the first C function called by exception/interrupt handlers,
- read/write debug packet to communication with HOST based on transfer
- protocol.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "DebugAgent.h"
-#include "Ia32/DebugException.h"
-
-#define INIT_BREAK_ACK_TIMEOUT (200 * 1000)
-
-CHAR8 mErrorMsgVersionAlert[] = "\rThe SourceLevelDebugPkg you are using requires a newer version of the Intel(R) UDK Debugger Tool.\r\n";
-CHAR8 mErrorMsgSendInitPacket[] = "\rSend INIT break packet to HOST ...\r\n";
-CHAR8 mErrorMsgConnectOK[] = "HOST connection is successful!\r\n";
-CHAR8 mErrorMsgConnectFail[] = "HOST connection is failed!\r\n";
-
-/**
- Send a debug message packet to the debug port.
-
- @param[in] Buffer The debug message.
- @param[in] Length The length of debug message.
-
-**/
-VOID
-SendDebugMsgPacket (
- IN CHAR8 *Buffer,
- IN UINTN Length
- )
-{
- DEBUG_PACKET_HEADER DebugHeader;
- DEBUG_PORT_HANDLE Handle;
-
- Handle = GetDebugPortHandle();
-
- DebugHeader.StartSymbol = DEBUG_STARTING_SYMBOL_NORMAL;
- DebugHeader.Command = DEBUG_COMMAND_PRINT_MESSAGE;
- DebugHeader.Length = sizeof (DEBUG_PACKET_HEADER) + (UINT8) Length;
- DebugHeader.CheckSum = 0;
- DebugHeader.CheckSum = CalculateCheckSum8 ((UINT8 *)&DebugHeader, sizeof (DEBUG_PACKET_HEADER));
-
- DebugPortWriteBuffer (Handle, (UINT8 *)&DebugHeader, sizeof (DEBUG_PACKET_HEADER));
- DebugPortWriteBuffer (Handle, (UINT8 *)Buffer, Length);
-}
-
-/**
- Prints a debug message to the debug port if the specified error level is enabled.
-
- If any bit in ErrorLevel is also set in Mainbox, then print the message specified
- by Format and the associated variable argument list to the debug port.
-
- @param[in] ErrorLevel The error level of the debug message.
- @param[in] Format Format string for the debug message to print.
- @param[in] ... Variable argument list whose contents are accessed
- based on the format string specified by Format.
-
-**/
-VOID
-EFIAPI
-DebugAgentMsgPrint (
- IN UINT8 ErrorLevel,
- IN CHAR8 *Format,
- ...
- )
-{
- DEBUG_AGENT_MAILBOX *Mailbox;
- CHAR8 Buffer[DEBUG_DATA_MAXIMUM_REAL_DATA];
- VA_LIST Marker;
-
- Mailbox = GetMailboxPointer ();
- //
- // Check driver debug mask value and global mask
- //
- if ((ErrorLevel & Mailbox->DebugFlag.PrintErrorLevel) == 0) {
- return;
- }
-
- //
- // Convert the DEBUG() message to an ASCII String
- //
- VA_START (Marker, Format);
- AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
- VA_END (Marker);
-
- SendDebugMsgPacket (Buffer, AsciiStrLen (Buffer));
-}
-
-/**
- Prints a debug message to the debug output device if the specified error level is enabled.
-
- If any bit in ErrorLevel is also set in DebugPrintErrorLevelLib function
- GetDebugPrintErrorLevel (), then print the message specified by Format and the
- associated variable argument list to the debug output device.
-
- If Format is NULL, then ASSERT().
-
- @param[in] ErrorLevel The error level of the debug message.
- @param[in] IsSend Flag of debug message to declare that the data is being sent or being received.
- @param[in] Data Variable argument list whose contents are accessed
- @param[in] Length based on the format string specified by Format.
-
-**/
-VOID
-EFIAPI
-DebugAgentDataMsgPrint (
- IN UINT8 ErrorLevel,
- IN BOOLEAN IsSend,
- IN UINT8 *Data,
- IN UINT8 Length
- )
-{
- DEBUG_AGENT_MAILBOX *Mailbox;
- CHAR8 Buffer[DEBUG_DATA_MAXIMUM_REAL_DATA];
- CHAR8 *DestBuffer;
- UINTN Index;
-
- Mailbox = GetMailboxPointer ();
- //
- // Check driver debug mask value and global mask
- //
- if ((ErrorLevel & Mailbox->DebugFlag.PrintErrorLevel) == 0) {
- return;
- }
-
- DestBuffer = Buffer;
- if (IsSend) {
- DestBuffer += AsciiSPrint (DestBuffer, DEBUG_DATA_MAXIMUM_REAL_DATA, "Sent data [ ");
- } else {
- DestBuffer += AsciiSPrint (DestBuffer, DEBUG_DATA_MAXIMUM_REAL_DATA, "Received data [ ");
- }
-
- Index = 0;
- while (TRUE) {
- if (DestBuffer - Buffer > DEBUG_DATA_MAXIMUM_REAL_DATA - 6) {
- //
- // If there was no enough space in buffer, send out the debug message,
- // reserving 6 bytes is for the last data and end characters "]\n".
- //
- SendDebugMsgPacket (Buffer, DestBuffer - Buffer);
- DestBuffer = Buffer;
- }
- DestBuffer += AsciiSPrint (DestBuffer, DEBUG_DATA_MAXIMUM_REAL_DATA - (DestBuffer - Buffer), "%02x ", Data[Index]);
- Index ++;
- if (Index >= Length) {
- //s
- // The last character of debug message has been foramtted in buffer
- //
- DestBuffer += AsciiSPrint(DestBuffer, DEBUG_DATA_MAXIMUM_REAL_DATA - (DestBuffer - Buffer), "]\n");
- SendDebugMsgPacket (Buffer, DestBuffer - Buffer);
- break;
- }
- }
-}
-
-
-/**
- Check if HOST is attached based on Mailbox.
-
- @retval TRUE HOST is attached.
- @retval FALSE HOST is not attached.
-
-**/
-BOOLEAN
-IsHostAttached (
- VOID
- )
-{
- return (BOOLEAN) (GetMailboxPointer ()->DebugFlag.HostAttached == 1);
-}
-
-/**
- Set HOST connect flag in Mailbox.
-
- @param[in] Attached Attach status.
-
-**/
-VOID
-SetHostAttached (
- IN BOOLEAN Attached
- )
-{
- DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Attach status is %d\n", Attached);
- GetMailboxPointer ()->DebugFlag.HostAttached = Attached;
-}
-
-/**
- Set debug setting of Debug Agent in Mailbox.
-
- @param DebugSetting Pointer to Debug Setting defined by transfer protocol.
-
- @retval RETURN_SUCCESS The setting is set successfully.
- @retval RETURN_UNSUPPORTED The Key value is not supported.
-
-**/
-RETURN_STATUS
-SetDebugSetting (
- IN DEBUG_DATA_SET_DEBUG_SETTING *DebugSetting
- )
-{
- RETURN_STATUS Status;
- DEBUG_AGENT_MAILBOX *Mailbox;
-
- Mailbox = GetMailboxPointer ();
-
- Status = RETURN_SUCCESS;
- switch (DebugSetting->Key) {
- case DEBUG_AGENT_SETTING_SMM_ENTRY_BREAK:
- Mailbox->DebugFlag.BreakOnNextSmi = DebugSetting->Value;
- break;
- case DEBUG_AGENT_SETTING_PRINT_ERROR_LEVEL:
- Mailbox->DebugFlag.PrintErrorLevel = DebugSetting->Value;
- break;
- default:
- Status = RETURN_UNSUPPORTED;
- }
- return Status;
-}
-
-/**
- Exectue GO command.
-
- @param[in] CpuContext Pointer to saved CPU context.
-
-**/
-VOID
-CommandGo (
- IN DEBUG_CPU_CONTEXT *CpuContext
- )
-{
- IA32_EFLAGS32 *Eflags;
-
- Eflags = (IA32_EFLAGS32 *) &CpuContext->Eflags;
- Eflags->Bits.TF = 0;
- Eflags->Bits.RF = 1;
-}
-
-/**
- Exectue Stepping command.
-
- @param[in] CpuContext Pointer to saved CPU context.
-
-**/
-VOID
-CommandStepping (
- IN DEBUG_CPU_CONTEXT *CpuContext
- )
-{
- IA32_EFLAGS32 *Eflags;
-
- Eflags = (IA32_EFLAGS32 *) &CpuContext->Eflags;
- Eflags->Bits.TF = 1;
- Eflags->Bits.RF = 1;
-}
-
-/**
- Set debug register for hardware breakpoint.
-
- @param[in] CpuContext Pointer to saved CPU context.
- @param[in] SetHwBreakpoint Hardware breakpoint to be set.
-
-**/
-VOID
-SetDebugRegister (
- IN DEBUG_CPU_CONTEXT *CpuContext,
- IN DEBUG_DATA_SET_HW_BREAKPOINT *SetHwBreakpoint
- )
-{
- UINT8 RegisterIndex;
- UINTN Dr7Value;
-
- RegisterIndex = SetHwBreakpoint->Type.Index;
-
- //
- // Set debug address
- //
- * ((UINTN *) &CpuContext->Dr0 + RegisterIndex) = (UINTN) SetHwBreakpoint->Address;
-
- Dr7Value = CpuContext->Dr7;
-
- //
- // Enable Gx, Lx
- //
- Dr7Value |= 0x3 << (RegisterIndex * 2);
- //
- // Set RWx and Lenx
- //
- Dr7Value &= ~(0xf << (16 + RegisterIndex * 4));
- Dr7Value |= (UINTN) ((SetHwBreakpoint->Type.Length << 2) | SetHwBreakpoint->Type.Access) << (16 + RegisterIndex * 4);
- //
- // Enable GE, LE
- //
- Dr7Value |= 0x300;
-
- CpuContext->Dr7 = Dr7Value;
-}
-
-/**
- Clear debug register for hardware breakpoint.
-
- @param[in] CpuContext Pointer to saved CPU context.
- @param[in] ClearHwBreakpoint Hardware breakpoint to be cleared.
-
-**/
-VOID
-ClearDebugRegister (
- IN DEBUG_CPU_CONTEXT *CpuContext,
- IN DEBUG_DATA_CLEAR_HW_BREAKPOINT *ClearHwBreakpoint
- )
-{
- if ((ClearHwBreakpoint->IndexMask & BIT0) != 0) {
- CpuContext->Dr0 = 0;
- CpuContext->Dr7 &= ~(0x3 << 0);
- }
- if ((ClearHwBreakpoint->IndexMask & BIT1) != 0) {
- CpuContext->Dr1 = 0;
- CpuContext->Dr7 &= ~(0x3 << 2);
- }
- if ((ClearHwBreakpoint->IndexMask & BIT2) != 0) {
- CpuContext->Dr2 = 0;
- CpuContext->Dr7 &= ~(0x3 << 4);
- }
- if ((ClearHwBreakpoint->IndexMask & BIT3) != 0) {
- CpuContext->Dr3 = 0;
- CpuContext->Dr7 &= ~(0x3 << 6);
- }
-}
-
-
-/**
- Return the offset of FP / MMX / XMM registers in the FPU saved state by register index.
-
- @param[in] Index Register index.
- @param[out] Width Register width returned.
-
- @return Offset in the FPU Save State.
-
-**/
-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_FX_SAVE_STATE, Fcw);
-
- case SOFT_DEBUGGER_REGISTER_FP_FSW:
- *Width = (UINT8) sizeof (UINT16);
- return OFFSET_OF(DEBUG_DATA_FX_SAVE_STATE, Fsw);
-
- case SOFT_DEBUGGER_REGISTER_FP_FTW:
- *Width = (UINT8) sizeof (UINT16);
- return OFFSET_OF(DEBUG_DATA_FX_SAVE_STATE, Ftw);
-
- case SOFT_DEBUGGER_REGISTER_FP_OPCODE:
- *Width = (UINT8) sizeof (UINT16);
- return OFFSET_OF(DEBUG_DATA_FX_SAVE_STATE, Opcode);
-
- case SOFT_DEBUGGER_REGISTER_FP_EIP:
- *Width = (UINT8) sizeof (UINT32);
- return OFFSET_OF(DEBUG_DATA_FX_SAVE_STATE, Eip);
-
- case SOFT_DEBUGGER_REGISTER_FP_CS:
- *Width = (UINT8) sizeof (UINT16);
- return OFFSET_OF(DEBUG_DATA_FX_SAVE_STATE, Cs);
-
- case SOFT_DEBUGGER_REGISTER_FP_DATAOFFSET:
- *Width = (UINT8) sizeof (UINT32);
- return OFFSET_OF(DEBUG_DATA_FX_SAVE_STATE, DataOffset);
-
- case SOFT_DEBUGGER_REGISTER_FP_DS:
- *Width = (UINT8) sizeof (UINT16);
- return OFFSET_OF(DEBUG_DATA_FX_SAVE_STATE, Ds);
-
- case SOFT_DEBUGGER_REGISTER_FP_MXCSR:
- *Width = (UINT8) sizeof (UINT32);
- return OFFSET_OF(DEBUG_DATA_FX_SAVE_STATE, Mxcsr);
-
- case SOFT_DEBUGGER_REGISTER_FP_MXCSR_MASK:
- *Width = (UINT8) sizeof (UINT32);
- return OFFSET_OF(DEBUG_DATA_FX_SAVE_STATE, Mxcsr_Mask);
- }
- }
-
- if (Index <= SOFT_DEBUGGER_REGISTER_ST7) {
- *Width = 10;
- } else if (Index <= SOFT_DEBUGGER_REGISTER_XMM15) {
- *Width = 16;
- } else {
- //
- // MMX register
- //
- *Width = 8;
- Index -= SOFT_DEBUGGER_REGISTER_MM0 - SOFT_DEBUGGER_REGISTER_ST0;
- }
-
- return OFFSET_OF (DEBUG_DATA_FX_SAVE_STATE, St0Mm0) + (Index - SOFT_DEBUGGER_REGISTER_ST0) * 16;
-}
-
-/**
- Return the pointer of the register value in the CPU saved context.
-
- @param[in] CpuContext Pointer to saved CPU context.
- @param[in] Index Register index value.
- @param[out] Width Data width to read.
-
- @return The pointer in the CPU saved context.
-
-**/
-UINT8 *
-ArchReadRegisterBuffer (
- IN DEBUG_CPU_CONTEXT *CpuContext,
- IN UINT8 Index,
- OUT UINT8 *Width
- )
-{
- UINT8 *Buffer;
-
- if (Index < SOFT_DEBUGGER_REGISTER_FP_BASE) {
- Buffer = (UINT8 *) CpuContext + OFFSET_OF (DEBUG_CPU_CONTEXT, Dr0) + Index * sizeof (UINTN);
- *Width = (UINT8) sizeof (UINTN);
- } else {
- //
- // FPU/MMX/XMM registers
- //
- Buffer = (UINT8 *) CpuContext + OFFSET_OF (DEBUG_CPU_CONTEXT, FxSaveState) + ArchReadFxStatOffset (Index, Width);
- }
-
- return Buffer;
-}
-
-/**
- Send the packet without data to HOST.
-
- @param[in] CommandType Type of Command.
-
-**/
-VOID
-SendPacketWithoutData (
- IN UINT8 CommandType
- )
-{
- DEBUG_PACKET_HEADER DebugHeader;
- DEBUG_PORT_HANDLE Handle;
-
- Handle = GetDebugPortHandle();
-
- DebugHeader.StartSymbol = DEBUG_STARTING_SYMBOL_NORMAL;
- DebugHeader.Command = CommandType;
- DebugHeader.Length = sizeof (DEBUG_PACKET_HEADER);
- DebugHeader.CheckSum = 0;
- DebugHeader.CheckSum = CalculateCheckSum8 ((UINT8 *)&DebugHeader, sizeof (DEBUG_PACKET_HEADER));
-
- DebugAgentDataMsgPrint (DEBUG_AGENT_VERBOSE, TRUE, (UINT8 *) &DebugHeader, DebugHeader.Length);
- DebugPortWriteBuffer (Handle, (UINT8 *) &DebugHeader, DebugHeader.Length);
-}
-
-/**
- Send acknowledge packet to HOST.
-
- @param[in] AckCommand Type of Acknowledge packet.
-
-**/
-VOID
-SendAckPacket (
- IN UINT8 AckCommand
- )
-{
- if (AckCommand != DEBUG_COMMAND_OK) {
- DebugAgentMsgPrint (DEBUG_AGENT_ERROR, "Send ACK(%d)\n", AckCommand);
- }
- SendPacketWithoutData (AckCommand);
-}
-
-/**
- Receive acknowledge packet from HOST in specified time.
-
- @param[out] Ack Returned acknowlege type from HOST.
- @param[in] Timeout Time out value to wait for acknowlege from HOST.
- The unit is microsecond.
- @param[out] BreakReceived If BreakReceived is not NULL,
- TRUE is retured if break-in symbol received.
- FALSE is retured if break-in symbol not received.
- @param[out] CheckSumStatus If CheckSumStatus is not NULL,
- RETURN_SUCCESS CheckSum is OK.
- RETURN_NOT_FOUND Not find the CheckSum field.
-
- @retval RETRUEN_SUCCESS Succeed to receive acknowlege packet from HOST,
- the type of acknowlege packet saved in Ack.
- @retval RETURN_TIMEOUT Specified timeout value was up.
-
-**/
-RETURN_STATUS
-ReceiveAckPacket (
- OUT UINT8 *Ack,
- IN UINTN Timeout,
- OUT BOOLEAN *BreakReceived, OPTIONAL
- OUT RETURN_STATUS *CheckSumStatus OPTIONAL
- )
-{
- DEBUG_PACKET_HEADER DebugHeader;
- DEBUG_PORT_HANDLE Handle;
-
- Handle = GetDebugPortHandle();
-
- while (TRUE) {
- if (DebugPortReadBuffer (Handle, (UINT8 *) &DebugHeader.StartSymbol, sizeof (DebugHeader.StartSymbol), Timeout) == 0) {
- return RETURN_TIMEOUT;
- }
- if (DebugHeader.StartSymbol == DEBUG_STARTING_SYMBOL_BREAK) {
- if (BreakReceived != NULL) {
- SendAckPacket (DEBUG_COMMAND_HALT_DEFERRED);
- *BreakReceived = TRUE;
- }
- }
- if (DebugHeader.StartSymbol == DEBUG_STARTING_SYMBOL_NORMAL) {
- break;
- }
- DebugAgentMsgPrint (DEBUG_AGENT_ERROR, "Invalid start symbol received [%02x]\n", DebugHeader.StartSymbol);
- }
- //
- // Read ACK packet header till field Length (not including StartSymbol and CheckSum)
- //
- DebugHeader.Length = 0;
- if (DebugPortReadBuffer (
- Handle,
- (UINT8 *)&DebugHeader.Command,
- OFFSET_OF (DEBUG_PACKET_HEADER, Length) + sizeof (DebugHeader.Length) - sizeof (DebugHeader.StartSymbol),
- Timeout
- ) == 0) {
- return RETURN_TIMEOUT;
- }
-
- if (DebugHeader.Length == 0) {
- //
- // The CheckSum field does not exist
- //
- if (CheckSumStatus != NULL) {
- *CheckSumStatus = RETURN_NOT_FOUND;
- }
- } else {
- if (CheckSumStatus != NULL) {
- *CheckSumStatus = RETURN_SUCCESS;
- }
- if (DebugPortReadBuffer (Handle, &DebugHeader.CheckSum, sizeof (DebugHeader.CheckSum), Timeout) == 0) {
- return RETURN_TIMEOUT;
- }
- }
-
- DebugAgentDataMsgPrint (DEBUG_AGENT_VERBOSE, FALSE, (UINT8 *)&DebugHeader, DebugHeader.Length);
- *Ack = DebugHeader.Command;
- return RETURN_SUCCESS;
-}
-
-/**
- Receive acknowledge packet OK from HOST in specified time.
-
- @param[in] Command The command type issued by TARGET.
- @param[in] Timeout Time out value to wait for acknowlege from HOST.
- The unit is microsecond.
- @param[out] BreakReceived If BreakReceived is not NULL,
- TRUE is retured if break-in symbol received.
- FALSE is retured if break-in symbol not received.
- @param[out] CheckSumStatus If CheckSumStatus is not NULL,
- RETURN_SUCCESS CheckSum is OK.
- RETURN_NOT_FOUND Not find the CheckSum field.
-
- @retval RETRUEN_SUCCESS Succeed to receive acknowlege packet from HOST,
- the type of acknowlege packet saved in Ack.
- @retval RETURN_TIMEOUT Specified timeout value was up.
-
-**/
-RETURN_STATUS
-SendCommandAndWaitForAckOK (
- IN UINT8 Command,
- IN UINTN Timeout,
- OUT BOOLEAN *BreakReceived, OPTIONAL
- OUT RETURN_STATUS *CheckSumStatus OPTIONAL
- )
-{
- RETURN_STATUS Status;
- UINT8 Ack;
-
- while (TRUE) {
- SendPacketWithoutData (Command);
- while (TRUE) {
- Status = ReceiveAckPacket (&Ack, Timeout, BreakReceived, CheckSumStatus);
- if (Status == RETURN_SUCCESS && Ack == DEBUG_COMMAND_RESEND) {
- //
- // Resend the last command
- //
- break;
- }
- if ((Status == RETURN_SUCCESS && Ack == DEBUG_COMMAND_OK) ||
- Status == RETURN_TIMEOUT) {
- //
- // Received Ack OK or timeout
- //
- return Status;
- }
- }
- }
-}
-
-/**
- Receive valid packet from HOST.
-
- @param[out] InputPacket Buffer to receive packet.
- @param[out] BreakReceived TRUE means break-in symbol received.
- FALSE means break-in symbol not received.
-
- @retval RETURN_SUCCESS A valid package was reveived in InputPacket.
- @retval RETURN_TIMEOUT Timeout occurs.
-
-**/
-RETURN_STATUS
-ReceivePacket (
- OUT UINT8 *InputPacket,
- OUT BOOLEAN *BreakReceived
- )
-{
- DEBUG_PACKET_HEADER *DebugHeader;
- UINTN Received;
- DEBUG_PORT_HANDLE Handle;
- UINT8 CheckSum;
-
- Handle = GetDebugPortHandle();
-
- DebugHeader = (DEBUG_PACKET_HEADER *) InputPacket;
- while (TRUE) {
- //
- // Find the valid start symbol
- //
- DebugPortReadBuffer (Handle, &DebugHeader->StartSymbol, sizeof (DebugHeader->StartSymbol), 0);
-
- if (DebugHeader->StartSymbol == DEBUG_STARTING_SYMBOL_BREAK) {
- *BreakReceived = TRUE;
- SendAckPacket (DEBUG_COMMAND_HALT_DEFERRED);
- }
-
- if (DebugHeader->StartSymbol != DEBUG_STARTING_SYMBOL_NORMAL) {
- DebugAgentMsgPrint (DEBUG_AGENT_ERROR, "Invalid start symbol received [%02x]\n", DebugHeader->StartSymbol);
- continue;
- }
-
- //
- // Read Package header except for checksum
- //
- Received = DebugPortReadBuffer (
- Handle,
- &DebugHeader->Command,
- OFFSET_OF (DEBUG_PACKET_HEADER, Length) + sizeof (DebugHeader->Length) - sizeof (DebugHeader->StartSymbol),
- 0
- );
- if (Received == 0) {
- return RETURN_TIMEOUT;
- }
-
- //
- // Read the payload data include the checksum
- //
- Received = DebugPortReadBuffer (Handle, &DebugHeader->CheckSum, DebugHeader->Length - OFFSET_OF (DEBUG_PACKET_HEADER, CheckSum), 0);
- if (Received == 0) {
- return RETURN_TIMEOUT;
- }
- //
- // Calculate the checksum of Debug Packet
- //
- CheckSum = CalculateCheckSum8 ((UINT8 *) DebugHeader, DebugHeader->Length);
- if (CheckSum == 0) {
- break;
- }
- DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "CheckSum Error (Caculated checksum is %x, received checksum is %x\n", CheckSum, DebugHeader->CheckSum);
- DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "Send DEBUG_COMMAND_RESEND command.\n");
- SendAckPacket (DEBUG_COMMAND_RESEND);
- }
-
- DebugAgentDataMsgPrint (DEBUG_AGENT_VERBOSE, FALSE, (UINT8 *) DebugHeader, DebugHeader->Length);
-
- return RETURN_SUCCESS;
-}
-
-/**
- Get current break cause.
-
- @param[in] Vector Vector value of exception or interrupt.
- @param[in] CpuContext Pointer to save CPU context.
-
- @return The type of break cause defined by XXXX
-
-**/
-UINT8
-GetBreakCause (
- IN UINTN Vector,
- IN DEBUG_CPU_CONTEXT *CpuContext
- )
-{
- UINT8 Cause;
-
- Cause = DEBUG_DATA_BREAK_CAUSE_UNKNOWN;
-
- switch (Vector) {
- case DEBUG_INT1_VECTOR:
- case DEBUG_INT3_VECTOR:
-
- if (Vector == DEBUG_INT1_VECTOR) {
- //
- // INT 1
- //
- if ((CpuContext->Dr6 & BIT14) != 0) {
- Cause = DEBUG_DATA_BREAK_CAUSE_STEPPING;
- //
- // If it's single step, no need to check DR0, to ensure single step work in PeCoffExtraActionLib
- // (right after triggering a breakpoint to report image load/unload).
- //
- return Cause;
-
- } else {
- Cause = DEBUG_DATA_BREAK_CAUSE_HW_BREAKPOINT;
- }
- } else {
- //
- // INT 3
- //
- Cause = DEBUG_DATA_BREAK_CAUSE_SW_BREAKPOINT;
- }
-
- switch (CpuContext->Dr0) {
- case IMAGE_LOAD_SIGNATURE:
- case IMAGE_UNLOAD_SIGNATURE:
-
- if (CpuContext->Dr3 == IO_PORT_BREAKPOINT_ADDRESS) {
-
- Cause = (UINT8) ((CpuContext->Dr0 == IMAGE_LOAD_SIGNATURE) ?
- DEBUG_DATA_BREAK_CAUSE_IMAGE_LOAD : DEBUG_DATA_BREAK_CAUSE_IMAGE_UNLOAD);
- }
- break;
-
- case SOFT_INTERRUPT_SIGNATURE:
-
- if (CpuContext->Dr1 == MEMORY_READY_SIGNATURE) {
- Cause = DEBUG_DATA_BREAK_CAUSE_MEMORY_READY;
- CpuContext->Dr0 = 0;
- } else if (CpuContext->Dr1 == SYSTEM_RESET_SIGNATURE) {
- Cause = DEBUG_DATA_BREAK_CAUSE_SYSTEM_RESET;
- CpuContext->Dr0 = 0;
- }
- break;
-
- default:
- break;
-
- }
-
- break;
-
- case DEBUG_TIMER_VECTOR:
- Cause = DEBUG_DATA_BREAK_CAUSE_USER_HALT;
- break;
-
- default:
- if (Vector < 20) {
- if (GetMailboxPointer()->DebugFlag.SteppingFlag == 1) {
- //
- // If stepping command is executing
- //
- Cause = DEBUG_DATA_BREAK_CAUSE_STEPPING;
- } else {
- Cause = DEBUG_DATA_BREAK_CAUSE_EXCEPTION;
- }
- }
- break;
- }
-
- return Cause;
-}
-
-/**
- Send command packet with data to HOST.
-
- @param[in] Command Command type.
- @param[in] Data Pointer to response data buffer.
- @param[in] DataSize Size of response data in byte.
-
- @retval RETURN_SUCCESS Response data was sent successfully.
- @retval RETURN_DEVICE_ERROR Cannot receive DEBUG_COMMAND_OK from HOST.
-
-**/
-RETURN_STATUS
-SendCommandWithDataPacket (
- IN UINT8 Command,
- IN UINT8 *Data,
- IN UINT16 DataSize
- )
-{
- DEBUG_PACKET_HEADER *DebugHeader;
- BOOLEAN LastPacket;
- UINT8 Ack;
- UINT8 DebugPacket[DEBUG_DATA_UPPER_LIMIT];
- DEBUG_PORT_HANDLE Handle;
-
- Handle = GetDebugPortHandle();
-
- DebugHeader = (DEBUG_PACKET_HEADER *) &DebugPacket;
- DebugHeader->StartSymbol = DEBUG_STARTING_SYMBOL_NORMAL;
-
- while (TRUE) {
- if (DataSize <= DEBUG_DATA_MAXIMUM_REAL_DATA) {
- LastPacket = TRUE;
- DebugHeader->Command = Command;
- DebugHeader->Length = (UINT8) (DataSize + sizeof (DEBUG_PACKET_HEADER));
- DebugHeader->CheckSum = 0;
- CopyMem (DebugHeader + 1, Data, DataSize);
-
- } else {
- LastPacket = FALSE;
- DebugHeader->Command = DEBUG_COMMAND_IN_PROGRESS;
- DebugHeader->Length = DEBUG_DATA_MAXIMUM_REAL_DATA + sizeof (DEBUG_PACKET_HEADER);
- DebugHeader->CheckSum = 0;
- CopyMem (DebugHeader + 1, Data, DEBUG_DATA_MAXIMUM_REAL_DATA);
- }
-
- //
- // Calculate and fill the checksum
- //
- DebugHeader->CheckSum = CalculateCheckSum8 ((UINT8 *) DebugHeader, DebugHeader->Length);
-
- DebugAgentDataMsgPrint (DEBUG_AGENT_VERBOSE, TRUE, (UINT8 *) DebugHeader, DebugHeader->Length);
-
- DebugPortWriteBuffer (Handle, (UINT8 *) DebugHeader, DebugHeader->Length);
-
- ReceiveAckPacket(&Ack, 0, NULL, NULL);
- switch (Ack) {
- case DEBUG_COMMAND_RESEND:
- //
- // Send the packet again
- //
- DebugAgentMsgPrint (DEBUG_AGENT_WARNING, "Received DEBUG_COMMAND_RESEND.\n");
- break;
-
- case DEBUG_COMMAND_CONTINUE:
- //
- // Send the rest packet
- //
- Data += DEBUG_DATA_MAXIMUM_REAL_DATA;
- DataSize -= DEBUG_DATA_MAXIMUM_REAL_DATA;
- break;
-
- case DEBUG_COMMAND_OK:
- if (LastPacket) {
- //
- // If this is the last packet, return RETURN_SUCCESS.
- //
- return RETURN_SUCCESS;
- } else {
- return RETURN_DEVICE_ERROR;
- }
-
- default:
- return RETURN_DEVICE_ERROR;
-
- }
- }
-}
-
-/**
- Send packet with response data to HOST.
-
- @param[in] Data Pointer to response data buffer.
- @param[in] DataSize Size of response data in byte.
-
- @retval RETURN_SUCCESS Response data was sent successfully.
- @retval RETURN_DEVICE_ERROR Cannot receive DEBUG_COMMAND_OK from HOST.
-
-**/
-RETURN_STATUS
-SendDataResponsePacket (
- IN UINT8 *Data,
- IN UINT16 DataSize
- )
-{
- return SendCommandWithDataPacket (DEBUG_COMMAND_OK, Data, DataSize);
-}
-
-/**
- Send break cause packet to HOST.
-
- @param[in] Vector Vector value of exception or interrutp.
- @param[in] CpuContext Pointer to save CPU context.
-
- @retval RETURN_SUCCESS Response data was sent successfully.
- @retval RETURN_DEVICE_ERROR Cannot receive DEBUG_COMMAND_OK from HOST.
-
-**/
-RETURN_STATUS
-SendBreakCausePacket (
- IN UINTN Vector,
- IN DEBUG_CPU_CONTEXT *CpuContext
- )
-{
- DEBUG_DATA_RESPONSE_BREAK_CAUSE DebugDataBreakCause;
-
- DebugDataBreakCause.StopAddress = CpuContext->Eip;
- DebugDataBreakCause.Cause = GetBreakCause (Vector, CpuContext);
-
- return SendDataResponsePacket ((UINT8 *) &DebugDataBreakCause, (UINT16) sizeof (DEBUG_DATA_RESPONSE_BREAK_CAUSE));
-}
-
-/**
- Try to attach the HOST.
-
- Send init break packet to HOST:
- If no acknowlege received in specified Timeout, return RETURN_TIMEOUT.
- If received acknowlege, check the revision of HOST.
- Set Attach Flag if attach successfully.
-
- @param[in] Timeout Time out value to wait for acknowlege from HOST.
- The unit is microsecond.
- @param[out] BreakReceived If BreakReceived is not NULL,
- TRUE is retured if break-in symbol received.
- FALSE is retured if break-in symbol not received.
-**/
-RETURN_STATUS
-AttachHost (
- IN UINTN Timeout,
- OUT BOOLEAN *BreakReceived
- )
-{
- RETURN_STATUS Status;
- DEBUG_PORT_HANDLE Handle;
- RETURN_STATUS CheckSumStatus;
-
- Handle = GetDebugPortHandle();
-
- //
- // Send init break and wait ack in Timeout
- //
- DebugPortWriteBuffer (Handle, (UINT8 *) mErrorMsgSendInitPacket, AsciiStrLen (mErrorMsgSendInitPacket));
- Status = SendCommandAndWaitForAckOK (DEBUG_COMMAND_INIT_BREAK, Timeout, BreakReceived, &CheckSumStatus);
- if (RETURN_ERROR (Status)) {
- DebugPortWriteBuffer (Handle, (UINT8 *) mErrorMsgConnectFail, AsciiStrLen (mErrorMsgConnectFail));
- return Status;
- }
-
- if (CheckSumStatus == RETURN_NOT_FOUND) {
- //
- // If the CheckSum field does not exist in Debug Packet,
- // the HOST should be running with 0.1 transfer protocol.
- // It could be UDK Debugger for Windows v1.1 or for Linux v0.8.
- //
- DebugPortWriteBuffer (Handle, (UINT8 *) mErrorMsgVersionAlert, AsciiStrLen (mErrorMsgVersionAlert));
- CpuDeadLoop ();
- }
-
- DebugPortWriteBuffer (Handle, (UINT8 *) mErrorMsgConnectOK, AsciiStrLen (mErrorMsgConnectOK));
- //
- // Set Attach flag
- //
- SetHostAttached (TRUE);
-
- return Status;
-}
-
-/**
- Send Break point packet to HOST.
-
- Only the first breaking processor could sent BREAK_POINT packet.
-
- @param[in] ProcessorIndex Processor index value.
- @param[out] BreakReceived If BreakReceived is not NULL,
- TRUE is retured if break-in symbol received.
- FALSE is retured if break-in symbol not received.
-
-**/
-VOID
-SendBreakPacketToHost (
- IN UINT32 ProcessorIndex,
- OUT BOOLEAN *BreakReceived
- )
-{
- UINT8 InputCharacter;
- DEBUG_PORT_HANDLE Handle;
-
- Handle = GetDebugPortHandle();
-
- if (IsHostAttached ()) {
- DebugAgentMsgPrint (DEBUG_AGENT_INFO, "processor[%x]:Send Break Packet to HOST.\n", ProcessorIndex);
- SendCommandAndWaitForAckOK (DEBUG_COMMAND_BREAK_POINT, 0, BreakReceived, NULL);
- } else {
- DebugAgentMsgPrint (DEBUG_AGENT_INFO, "processor[%x]:Try to attach HOST.\n", ProcessorIndex);
- //
- // If HOST is not attached, try to attach it firstly.
- //
- //
- // Poll Attach symbols from HOST and ack OK
- //
- do {
- DebugPortReadBuffer (Handle, &InputCharacter, 1, 0);
- } while (InputCharacter != DEBUG_STARTING_SYMBOL_ATTACH);
- SendAckPacket (DEBUG_COMMAND_OK);
-
- //
- // Try to attach HOST
- //
- while (AttachHost (0, NULL) != RETURN_SUCCESS);
-
- }
-}
-
-/**
- The main function to process communication with HOST.
-
- It received the command packet from HOST, and sent response data packet to HOST.
-
- @param[in] Vector Vector value of exception or interrutp.
- @param[in, out] CpuContext Pointer to saved CPU context.
- @param[in] BreakReceived TRUE means break-in symbol received.
- FALSE means break-in symbol not received.
-
-**/
-VOID
-CommandCommunication (
- IN UINTN Vector,
- IN OUT DEBUG_CPU_CONTEXT *CpuContext,
- IN BOOLEAN BreakReceived
- )
-{
- RETURN_STATUS Status;
- UINT8 InputPacketBuffer[DEBUG_DATA_UPPER_LIMIT];
- DEBUG_PACKET_HEADER *DebugHeader;
- UINT8 Width;
- UINT8 Data8;
- UINT32 Data32;
- UINT64 Data64;
- DEBUG_DATA_READ_MEMORY *MemoryRead;
- DEBUG_DATA_WRITE_MEMORY *MemoryWrite;
- DEBUG_DATA_READ_IO *IoRead;
- DEBUG_DATA_WRITE_IO *IoWrite;
- DEBUG_DATA_READ_REGISTER *RegisterRead;
- DEBUG_DATA_WRITE_REGISTER *RegisterWrite;
- UINT8 *RegisterBuffer;
- DEBUG_DATA_READ_MSR *MsrRegisterRead;
- DEBUG_DATA_WRITE_MSR *MsrRegisterWrite;
- DEBUG_DATA_CPUID *Cpuid;
- DEBUG_DATA_RESPONSE_CPUID CpuidResponse;
- DEBUG_DATA_SEARCH_SIGNATURE *SearchSignature;
- DEBUG_DATA_RESPONSE_GET_EXCEPTION Exception;
- DEBUG_DATA_RESPONSE_GET_REVISION DebugAgentRevision;
- DEBUG_DATA_SET_VIEWPOINT *SetViewPoint;
- BOOLEAN HaltDeferred;
- UINT32 ProcessorIndex;
- DEBUG_PORT_HANDLE Handle;
- DEBUG_AGENT_EXCEPTION_BUFFER AgentExceptionBuffer;
- UINT32 IssuedViewPoint;
-
- ProcessorIndex = 0;
- IssuedViewPoint = 0;
- HaltDeferred = BreakReceived;
-
- if (MultiProcessorDebugSupport) {
- ProcessorIndex = GetProcessorIndex ();
- SetCpuStopFlagByIndex (ProcessorIndex, TRUE);
- if (mDebugMpContext.ViewPointIndex == ProcessorIndex) {
- //
- // Only the current view processor could set AgentInProgress Flag.
- //
- IssuedViewPoint = ProcessorIndex;
- }
- }
-
- if (IssuedViewPoint == ProcessorIndex) {
- //
- // Set AgentInProgress Flag.
- //
- GetMailboxPointer()->DebugFlag.AgentInProgress = 1;
- }
-
- Handle = GetDebugPortHandle();
-
- while (TRUE) {
-
- if (MultiProcessorDebugSupport) {
- //
- // Check if the current processor is HOST view point
- //
- if (mDebugMpContext.ViewPointIndex != ProcessorIndex) {
- if (mDebugMpContext.RunCommandSet) {
- //
- // If HOST view point sets RUN flag, run GO command to leave
- //
- SetCpuStopFlagByIndex (ProcessorIndex, FALSE);
- CommandGo (CpuContext);
- break;
- } else {
- //
- // Run into loop again
- //
- CpuPause ();
- continue;
- }
- }
- }
-
- AcquireDebugPortControl ();
-
- Status = ReceivePacket (InputPacketBuffer, &BreakReceived);
-
- if (BreakReceived) {
- HaltDeferred = TRUE;
- BreakReceived = FALSE;
- }
-
- if (Status != RETURN_SUCCESS) {
- ReleaseDebugPortControl ();
- continue;
- }
-
- Data8 = 1;
-
- DebugHeader =(DEBUG_PACKET_HEADER *) InputPacketBuffer;
-
- GetMailboxPointer()->ExceptionBufferPointer = (UINT64)(UINTN) &AgentExceptionBuffer.JumpBuffer;
- //
- // Save CPU content before executing HOST commond
- //
- if (SetJump (&AgentExceptionBuffer.JumpBuffer) != 0) {
- //
- // If HOST command failed, continue to wait for HOST's next command
- // If needed, agent could send exception info to HOST.
- //
- SendAckPacket (DEBUG_COMMAND_ABORT);
- ReleaseDebugPortControl ();
- continue;
- }
-
- DebugAgentMsgPrint (DEBUG_AGENT_INFO, "Processor[%x]:Received one command(%x)\n", mDebugMpContext.ViewPointIndex, DebugHeader->Command);
-
- switch (DebugHeader->Command) {
-
- case DEBUG_COMMAND_RESET:
- SendAckPacket (DEBUG_COMMAND_OK);
- ReleaseDebugPortControl ();
-
- ResetCold ();
- //
- // Assume system resets in 2 seconds, otherwise send TIMEOUT packet.
- // PCD can be used if 2 seconds isn't long enough for some platforms.
- //
- MicroSecondDelay (2000000);
- SendAckPacket (DEBUG_COMMAND_TIMEOUT);
- break;
-
- case DEBUG_COMMAND_GO:
- CommandGo (CpuContext);
- //
- // Clear Dr0 to avoid to be recognized as IMAGE_LOAD/_UNLOAD again when hitting a breakpoint after GO
- // If HOST changed Dr0 before GO, we will not change Dr0 here
- //
- Data8 = GetBreakCause (Vector, CpuContext);
- if (Data8 == DEBUG_DATA_BREAK_CAUSE_IMAGE_LOAD || Data8 == DEBUG_DATA_BREAK_CAUSE_IMAGE_UNLOAD) {
- CpuContext->Dr0 = 0;
- }
- //
- // Clear Stepping Flag
- //
- GetMailboxPointer()->DebugFlag.SteppingFlag = 0;
-
- if (!HaltDeferred) {
- //
- // If no HALT command received when being in-active mode
- //
- if (MultiProcessorDebugSupport) {
- Data32 = FindNextPendingBreakCpu ();
- if (Data32 != -1) {
- //
- // If there are still others processors being in break state,
- // send OK packet to HOST to finish this go command
- //
- SendAckPacket (DEBUG_COMMAND_OK);
- CpuPause ();
- //
- // Set current view to the next breaking processor
- //
- mDebugMpContext.ViewPointIndex = Data32;
- mDebugMpContext.BreakAtCpuIndex = mDebugMpContext.ViewPointIndex;
- SetCpuBreakFlagByIndex (mDebugMpContext.ViewPointIndex, FALSE);
- //
- // Send break packet to HOST to let HOST break again
- //
- SendBreakPacketToHost (0, &BreakReceived);
- //
- // Continue to run into loop to read command packet from HOST
- //
- ReleaseDebugPortControl ();
- break;
- }
-
- //
- // If no else processor break, set stop bitmask,
- // and set Running flag for all processors.
- //
- SetCpuStopFlagByIndex (ProcessorIndex, FALSE);
- SetCpuRunningFlag (TRUE);
- CpuPause ();
- //
- // Wait for all processors are in running state
- //
- while (TRUE) {
- if (IsAllCpuRunning ()) {
- break;
- }
- }
- //
- // Set BSP to be current view point.
- //
- SetDebugViewPoint (mDebugMpContext.BspIndex);
- CpuPause ();
- //
- // Clear breaking processor index and running flag
- //
- mDebugMpContext.BreakAtCpuIndex = (UINT32) (-1);
- SetCpuRunningFlag (FALSE);
- }
-
- //
- // Send OK packet to HOST to finish this go command
- //
- SendAckPacket (DEBUG_COMMAND_OK);
-
- ReleaseDebugPortControl ();
-
- return;
-
- } else {
- //
- // If reveived HALT command, need to defer the GO command
- //
- SendAckPacket (DEBUG_COMMAND_HALT_PROCESSED);
- HaltDeferred = FALSE;
-
- Vector = DEBUG_TIMER_VECTOR;
- }
- break;
-
- case DEBUG_COMMAND_BREAK_CAUSE:
-
- if (MultiProcessorDebugSupport && ProcessorIndex != mDebugMpContext.BreakAtCpuIndex) {
- Status = SendBreakCausePacket (DEBUG_TIMER_VECTOR, CpuContext);
-
- } else {
- Status = SendBreakCausePacket (Vector, CpuContext);
- }
-
- break;
-
- case DEBUG_COMMAND_SET_HW_BREAKPOINT:
- SetDebugRegister (CpuContext, (DEBUG_DATA_SET_HW_BREAKPOINT *) (DebugHeader + 1));
- SendAckPacket (DEBUG_COMMAND_OK);
- break;
-
- case DEBUG_COMMAND_CLEAR_HW_BREAKPOINT:
- ClearDebugRegister (CpuContext, (DEBUG_DATA_CLEAR_HW_BREAKPOINT *) (DebugHeader + 1));
- SendAckPacket (DEBUG_COMMAND_OK);
- break;
-
- case DEBUG_COMMAND_SINGLE_STEPPING:
- CommandStepping (CpuContext);
- //
- // Clear Dr0 to avoid to be recognized as IMAGE_LOAD/_UNLOAD again when hitting a breakpoint after GO
- // If HOST changed Dr0 before GO, we will not change Dr0 here
- //
- Data8 = GetBreakCause (Vector, CpuContext);
- if (Data8 == DEBUG_DATA_BREAK_CAUSE_IMAGE_LOAD || Data8 == DEBUG_DATA_BREAK_CAUSE_IMAGE_UNLOAD) {
- CpuContext->Dr0 = 0;
- }
-
- mDebugMpContext.BreakAtCpuIndex = (UINT32) (-1);
- //
- // Set Stepping Flag
- //
- GetMailboxPointer()->DebugFlag.SteppingFlag = 1;
- ReleaseDebugPortControl ();
- //
- // Executing stepping command directly without sending ACK packet,
- // ACK packet will be sent after stepping done.
- //
- return;
-
- case DEBUG_COMMAND_SET_SW_BREAKPOINT:
- Data64 = (UINTN) (((DEBUG_DATA_SET_SW_BREAKPOINT *) (DebugHeader + 1))->Address);
- Data8 = *(UINT8 *) (UINTN) Data64;
- *(UINT8 *) (UINTN) Data64 = DEBUG_SW_BREAKPOINT_SYMBOL;
- Status = SendDataResponsePacket ((UINT8 *) &Data8, (UINT16) sizeof (UINT8));
- break;
-
- case DEBUG_COMMAND_READ_MEMORY:
- MemoryRead = (DEBUG_DATA_READ_MEMORY *) (DebugHeader + 1);
- Status = SendDataResponsePacket ((UINT8 *) (UINTN) MemoryRead->Address, (UINT16) (MemoryRead->Count * MemoryRead->Width));
- break;
-
- case DEBUG_COMMAND_WRITE_MEMORY:
- MemoryWrite = (DEBUG_DATA_WRITE_MEMORY *) (DebugHeader + 1);
- CopyMem ((VOID *) (UINTN) MemoryWrite->Address, &MemoryWrite->Data, MemoryWrite->Count * MemoryWrite->Width);
- SendAckPacket (DEBUG_COMMAND_OK);
- break;
-
- case DEBUG_COMMAND_READ_IO:
- IoRead = (DEBUG_DATA_READ_IO *) (DebugHeader + 1);
- switch (IoRead->Width) {
- case 1:
- Data64 = IoRead8 ((UINTN) IoRead->Port);
- break;
- case 2:
- Data64 = IoRead16 ((UINTN) IoRead->Port);
- break;
- case 4:
- Data64 = IoRead32 ((UINTN) IoRead->Port);
- break;
- case 8:
- Data64 = IoRead64 ((UINTN) IoRead->Port);
- break;
- default:
- Data64 = (UINT64) -1;
- }
- Status = SendDataResponsePacket ((UINT8 *) &Data64, IoRead->Width);
- break;
-
- case DEBUG_COMMAND_WRITE_IO:
- IoWrite = (DEBUG_DATA_WRITE_IO *) (DebugHeader + 1);
- switch (IoWrite->Width) {
- case 1:
- Data64 = IoWrite8 ((UINTN) IoWrite->Port, *(UINT8 *) &IoWrite->Data);
- break;
- case 2:
- Data64 = IoWrite16 ((UINTN) IoWrite->Port, *(UINT16 *) &IoWrite->Data);
- break;
- case 4:
- Data64 = IoWrite32 ((UINTN) IoWrite->Port, *(UINT32 *) &IoWrite->Data);
- break;
- case 8:
- Data64 = IoWrite64 ((UINTN) IoWrite->Port, *(UINT64 *) &IoWrite->Data);
- break;
- default:
- Data64 = (UINT64) -1;
- }
- SendAckPacket (DEBUG_COMMAND_OK);
- break;
-
- case DEBUG_COMMAND_READ_ALL_REGISTERS:
- Status = SendDataResponsePacket ((UINT8 *) CpuContext, sizeof (*CpuContext));
- break;
-
- case DEBUG_COMMAND_READ_REGISTER:
- RegisterRead = (DEBUG_DATA_READ_REGISTER *) (DebugHeader + 1);
-
- if (RegisterRead->Index <= SOFT_DEBUGGER_REGISTER_MAX) {
- RegisterBuffer = ArchReadRegisterBuffer (CpuContext, RegisterRead->Index, &Width);
- Status = SendDataResponsePacket (RegisterBuffer, Width);
- } else {
- Status = RETURN_UNSUPPORTED;
- }
- break;
-
- case DEBUG_COMMAND_WRITE_REGISTER:
- RegisterWrite = (DEBUG_DATA_WRITE_REGISTER *) (DebugHeader + 1);
- if (RegisterWrite->Index <= SOFT_DEBUGGER_REGISTER_MAX) {
- RegisterBuffer = ArchReadRegisterBuffer (CpuContext, RegisterWrite->Index, &Width);
- ASSERT (Width == RegisterWrite->Length);
- CopyMem (RegisterBuffer, RegisterWrite->Data, Width);
- SendAckPacket (DEBUG_COMMAND_OK);
- } else {
- Status = RETURN_UNSUPPORTED;
- }
- break;
-
- case DEBUG_COMMAND_ARCH_MODE:
- Data8 = DEBUG_ARCH_SYMBOL;
- Status = SendDataResponsePacket ((UINT8 *) &Data8, (UINT16) sizeof (UINT8));
- break;
-
- case DEBUG_COMMAND_READ_MSR:
- MsrRegisterRead = (DEBUG_DATA_READ_MSR *) (DebugHeader + 1);
- Data64 = AsmReadMsr64 (MsrRegisterRead->Index);
- Status = SendDataResponsePacket ((UINT8 *) &Data64, (UINT16) sizeof (UINT64));
- break;
-
- case DEBUG_COMMAND_WRITE_MSR:
- MsrRegisterWrite = (DEBUG_DATA_WRITE_MSR *) (DebugHeader + 1);
- AsmWriteMsr64 (MsrRegisterWrite->Index, MsrRegisterWrite->Value);
- SendAckPacket (DEBUG_COMMAND_OK);
- break;
-
- case DEBUG_COMMAND_SET_DEBUG_SETTING:
- Status = SetDebugSetting ((DEBUG_DATA_SET_DEBUG_SETTING *)(DebugHeader + 1));
- if (Status == RETURN_SUCCESS) {
- SendAckPacket (DEBUG_COMMAND_OK);
- }
- break;
-
- case DEBUG_COMMAND_GET_REVISION:
- DebugAgentRevision.Revision = DEBUG_AGENT_REVISION;
- DebugAgentRevision.Capabilities = DEBUG_AGENT_CAPABILITIES;
- Status = SendDataResponsePacket ((UINT8 *) &DebugAgentRevision, (UINT16) sizeof (DEBUG_DATA_RESPONSE_GET_REVISION));
- break;
-
- case DEBUG_COMMAND_GET_EXCEPTION:
- Exception.ExceptionNum = (UINT8) Vector;
- Exception.ExceptionData = (UINT32) CpuContext->ExceptionData;
- Status = SendDataResponsePacket ((UINT8 *) &Exception, (UINT16) sizeof (DEBUG_DATA_RESPONSE_GET_EXCEPTION));
- break;
-
- case DEBUG_COMMAND_SET_VIEWPOINT:
- SetViewPoint = (DEBUG_DATA_SET_VIEWPOINT *) (DebugHeader + 1);
- if (MultiProcessorDebugSupport) {
- if (IsCpuStopped (SetViewPoint->ViewPoint)) {
- SetDebugViewPoint (SetViewPoint->ViewPoint);
- SendAckPacket (DEBUG_COMMAND_OK);
- } else {
- //
- // If CPU is not halted
- //
- SendAckPacket (DEBUG_COMMAND_NOT_SUPPORTED);
- }
- } else if (SetViewPoint->ViewPoint == 0) {
- SendAckPacket (DEBUG_COMMAND_OK);
-
- } else {
- SendAckPacket (DEBUG_COMMAND_NOT_SUPPORTED);
- }
-
- break;
-
- case DEBUG_COMMAND_GET_VIEWPOINT:
- Data32 = mDebugMpContext.ViewPointIndex;
- SendDataResponsePacket((UINT8 *) &Data32, (UINT16) sizeof (UINT32));
- break;
-
- case DEBUG_COMMAND_MEMORY_READY:
- Data8 = (UINT8) GetMailboxPointer ()->DebugFlag.MemoryReady;
- SendDataResponsePacket (&Data8, (UINT16) sizeof (UINT8));
- break;
-
- case DEBUG_COMMAND_DETACH:
- SetHostAttached (FALSE);
- SendAckPacket (DEBUG_COMMAND_OK);
- break;
-
- case DEBUG_COMMAND_CPUID:
- Cpuid = (DEBUG_DATA_CPUID *) (DebugHeader + 1);
- AsmCpuidEx (
- Cpuid->Eax, Cpuid->Ecx,
- &CpuidResponse.Eax, &CpuidResponse.Ebx,
- &CpuidResponse.Ecx, &CpuidResponse.Edx
- );
- SendDataResponsePacket ((UINT8 *) &CpuidResponse, (UINT16) sizeof (CpuidResponse));
- break;
-
- case DEBUG_COMMAND_SEARCH_SIGNATURE:
- SearchSignature = (DEBUG_DATA_SEARCH_SIGNATURE *) (DebugHeader + 1);
- if ((SearchSignature->Alignment != 0) &&
- (SearchSignature->Alignment == GetPowerOfTwo32 (SearchSignature->Alignment))
- ) {
- if (SearchSignature->Positive) {
- for (
- Data64 = ALIGN_VALUE ((UINTN) SearchSignature->Start, SearchSignature->Alignment);
- Data64 <= SearchSignature->Start + SearchSignature->Count - SearchSignature->DataLength;
- Data64 += SearchSignature->Alignment
- ) {
- if (CompareMem ((VOID *) (UINTN) Data64, &SearchSignature->Data, SearchSignature->DataLength) == 0) {
- break;
- }
- }
- if (Data64 > SearchSignature->Start + SearchSignature->Count - SearchSignature->DataLength) {
- Data64 = (UINT64) -1;
- }
- } else {
- for (
- Data64 = ALIGN_VALUE ((UINTN) SearchSignature->Start - SearchSignature->Alignment, SearchSignature->Alignment);
- Data64 >= SearchSignature->Start - SearchSignature->Count;
- Data64 -= SearchSignature->Alignment
- ) {
- if (CompareMem ((VOID *) (UINTN) Data64, &SearchSignature->Data, SearchSignature->DataLength) == 0) {
- break;
- }
- }
- if (Data64 < SearchSignature->Start - SearchSignature->Count) {
- Data64 = (UINT64) -1;
- }
- }
- SendDataResponsePacket ((UINT8 *) &Data64, (UINT16) sizeof (Data64));
- } else {
- Status = RETURN_UNSUPPORTED;
- }
- break;
-
- default:
- SendAckPacket (DEBUG_COMMAND_NOT_SUPPORTED);
- break;
- }
-
- if (Status == RETURN_UNSUPPORTED) {
- SendAckPacket (DEBUG_COMMAND_NOT_SUPPORTED);
- } else if (Status != RETURN_SUCCESS) {
- SendAckPacket (DEBUG_COMMAND_ABORT);
- }
-
- ReleaseDebugPortControl ();
- CpuPause ();
- }
-}
-
-/**
- C function called in interrupt handler.
-
- @param[in] Vector Vector value of exception or interrutp.
- @param[in] CpuContext Pointer to save CPU context.
-
-**/
-VOID
-EFIAPI
-InterruptProcess (
- IN UINT32 Vector,
- IN DEBUG_CPU_CONTEXT *CpuContext
- )
-{
- UINT8 InputCharacter;
- UINT8 BreakCause;
- UINTN SavedEip;
- BOOLEAN BreakReceived;
- UINT32 ProcessorIndex;
- UINT32 CurrentDebugTimerInitCount;
- DEBUG_PORT_HANDLE Handle;
- UINT8 Data8;
- UINT8 *Al;
- UINT32 IssuedViewPoint;
- DEBUG_AGENT_EXCEPTION_BUFFER *ExceptionBuffer;
-
- ProcessorIndex = 0;
- IssuedViewPoint = 0;
- BreakReceived = FALSE;
-
- if (MultiProcessorDebugSupport) {
- ProcessorIndex = GetProcessorIndex ();
- //
- // If this processor has alreay halted before, need to check it later
- //
- if (IsCpuStopped (ProcessorIndex)) {
- IssuedViewPoint = ProcessorIndex;
- }
- }
-
- if (IssuedViewPoint == ProcessorIndex) {
- //
- // Check if this exception is issued by Debug Agent itself
- // If yes, fill the debug agent exception buffer and LongJump() back to
- // the saved CPU content in CommandCommunication()
- //
- if (GetMailboxPointer()->DebugFlag.AgentInProgress == 1) {
- DebugAgentMsgPrint (DEBUG_AGENT_ERROR, "Debug agent meet one Exception, ExceptionNum is %d.\n", Vector);
- ExceptionBuffer = (DEBUG_AGENT_EXCEPTION_BUFFER *) (UINTN) GetMailboxPointer()->ExceptionBufferPointer;
- ExceptionBuffer->ExceptionContent.ExceptionNum = (UINT8) Vector;
- ExceptionBuffer->ExceptionContent.ExceptionData = (UINT32) CpuContext->ExceptionData;
- LongJump ((BASE_LIBRARY_JUMP_BUFFER *)(UINTN)(GetMailboxPointer()->ExceptionBufferPointer), 1);
- }
- }
-
- if (MultiProcessorDebugSupport) {
- //
- // If RUN commmand is executing, wait for it done.
- //
- while (mDebugMpContext.RunCommandSet) {
- CpuPause ();
- }
- }
-
- Handle = GetDebugPortHandle();
-
- switch (Vector) {
- case DEBUG_INT1_VECTOR:
- case DEBUG_INT3_VECTOR:
- BreakCause = GetBreakCause (Vector, CpuContext);
-
- switch (BreakCause) {
- case DEBUG_DATA_BREAK_CAUSE_SYSTEM_RESET:
- if (AttachHost (INIT_BREAK_ACK_TIMEOUT, &BreakReceived) != RETURN_SUCCESS) {
- //
- // Try to connect HOST, return if fails
- //
- break;
- }
- CommandCommunication (Vector, CpuContext, BreakReceived);
- break;
-
- case DEBUG_DATA_BREAK_CAUSE_STEPPING:
- //
- // Stepping is finished, send Ack package.
- //
- if (MultiProcessorDebugSupport) {
- mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;
- }
- SendAckPacket (DEBUG_COMMAND_OK);
- CommandCommunication (Vector, CpuContext, BreakReceived);
- break;
-
- case DEBUG_DATA_BREAK_CAUSE_MEMORY_READY:
- //
- // Memory is ready
- //
- SendCommandAndWaitForAckOK (DEBUG_COMMAND_MEMORY_READY, 0, &BreakReceived, NULL);
- CommandCommunication (Vector, CpuContext, BreakReceived);
- break;
-
- case DEBUG_DATA_BREAK_CAUSE_IMAGE_LOAD:
- case DEBUG_DATA_BREAK_CAUSE_IMAGE_UNLOAD:
- //
- // Set AL to DEBUG_AGENT_IMAGE_CONTINUE
- //
- Al = ArchReadRegisterBuffer (CpuContext, SOFT_DEBUGGER_REGISTER_AX, &Data8);
- *Al = DEBUG_AGENT_IMAGE_CONTINUE;
-
- if (!IsHostAttached ()) {
- //
- // If HOST is not connected for image load/unload, return
- //
- break;
- }
- //
- // Continue to run the following common code
- //
-
- case DEBUG_DATA_BREAK_CAUSE_HW_BREAKPOINT:
- case DEBUG_DATA_BREAK_CAUSE_SW_BREAKPOINT:
- default:
- //
- // Send Break packet to HOST
- //
- AcquireDebugPortControl ();
- //
- // Only the first breaking processor could send BREAK_POINT to HOST
- //
- if (IsFirstBreakProcessor (ProcessorIndex)) {
- SendBreakPacketToHost (ProcessorIndex, &BreakReceived);
- }
- ReleaseDebugPortControl ();
-
- if (Vector == DEBUG_INT3_VECTOR) {
- //
- // go back address located "0xCC"
- //
- CpuContext->Eip--;
- SavedEip = CpuContext->Eip;
- CommandCommunication (Vector, CpuContext, BreakReceived);
- if ((SavedEip == CpuContext->Eip) &&
- (*(UINT8 *) (UINTN) CpuContext->Eip == DEBUG_SW_BREAKPOINT_SYMBOL)) {
- //
- // If this is not a software breakpoint set by HOST,
- // restore EIP
- //
- CpuContext->Eip++;
- }
- } else {
- CommandCommunication (Vector, CpuContext, BreakReceived);
- }
- break;
- }
-
- break;
-
- case DEBUG_TIMER_VECTOR:
-
- AcquireDebugPortControl ();
-
- if (MultiProcessorDebugSupport) {
- if (IsBsp (ProcessorIndex)) {
- //
- // If current processor is BSP, check Apic timer's init count if changed,
- // it may be re-written when switching BSP.
- // If it changed, re-initialize debug timer
- //
- CurrentDebugTimerInitCount = GetApicTimerInitCount ();
- if (mDebugMpContext.DebugTimerInitCount != CurrentDebugTimerInitCount) {
- InitializeDebugTimer ();
- }
- }
-
- if (!IsBsp (ProcessorIndex) || mDebugMpContext.IpiSentByAp) {
- ReleaseDebugPortControl ();
- //
- // If current processor is not BSP or this is one IPI sent by AP
- //
- if (mDebugMpContext.BreakAtCpuIndex != (UINT32) (-1)) {
- CommandCommunication (Vector, CpuContext, FALSE);
- }
-
- //
- // Clear EOI before exiting interrupt process routine.
- //
- SendApicEoi ();
- break;
- }
- }
-
- //
- // Only BSP could run here
- //
- while (TRUE) {
- //
- // If there is data in debug port, will check whether it is break(attach/break-in) symbol,
- // If yes, go into communication mode with HOST.
- // If no, exit interrupt process.
- //
- if (DebugReadBreakSymbol (Handle, &InputCharacter) == EFI_NOT_FOUND) {
- break;
- }
- if ((!IsHostAttached () && (InputCharacter == DEBUG_STARTING_SYMBOL_ATTACH)) ||
- (IsHostAttached () && (InputCharacter == DEBUG_STARTING_SYMBOL_BREAK))
- ) {
- DebugAgentMsgPrint (DEBUG_AGENT_VERBOSE, "Received data [%02x]\n", InputCharacter);
- //
- // Ack OK for break-in symbol
- //
- SendAckPacket (DEBUG_COMMAND_OK);
-
- if (!IsHostAttached ()) {
- //
- // Try to attach HOST, if no ack received after 200ms, return
- //
- if (AttachHost (INIT_BREAK_ACK_TIMEOUT, &BreakReceived) != RETURN_SUCCESS) {
- break;
- }
- }
-
- if (MultiProcessorDebugSupport) {
- if(FindNextPendingBreakCpu () != -1) {
- SetCpuBreakFlagByIndex (ProcessorIndex, TRUE);
- } else {
- HaltOtherProcessors (ProcessorIndex);
- }
- }
- ReleaseDebugPortControl ();
- CommandCommunication (Vector, CpuContext, BreakReceived);
- AcquireDebugPortControl ();
- break;
- }
- }
-
- //
- // Clear EOI before exiting interrupt process routine.
- //
- SendApicEoi ();
-
- ReleaseDebugPortControl ();
-
- break;
-
- default:
-
- if (Vector <= DEBUG_EXCEPT_SIMD) {
- BreakCause = GetBreakCause (Vector, CpuContext);
- if (BreakCause == DEBUG_DATA_BREAK_CAUSE_STEPPING) {
- //
- // Stepping is finished, send Ack package.
- //
- if (MultiProcessorDebugSupport) {
- mDebugMpContext.BreakAtCpuIndex = ProcessorIndex;
- }
- SendAckPacket (DEBUG_COMMAND_OK);
- } else {
- //
- // Exception occurs, send Break packet to HOST
- //
- AcquireDebugPortControl ();
- //
- // Only the first breaking processor could send BREAK_POINT to HOST
- //
- if (IsFirstBreakProcessor (ProcessorIndex)) {
- SendBreakPacketToHost (ProcessorIndex, &BreakReceived);
- }
- ReleaseDebugPortControl ();
- }
-
- CommandCommunication (Vector, CpuContext, BreakReceived);
- }
- break;
- }
-
- if (MultiProcessorDebugSupport) {
- //
- // Clear flag and wait for all processors run here
- //
- SetIpiSentByApFlag (FALSE);
- while (mDebugMpContext.RunCommandSet) {
- CpuPause ();
- }
-
- //
- // Only current (view) processor could clean up AgentInProgress flag.
- //
- if (mDebugMpContext.ViewPointIndex == ProcessorIndex) {
- IssuedViewPoint = mDebugMpContext.ViewPointIndex;
- }
- }
-
- if (IssuedViewPoint == ProcessorIndex) {
- //
- // Clean up AgentInProgress flag
- //
- GetMailboxPointer()->DebugFlag.AgentInProgress = 0;
- }
-
- return;
-}
-
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h
deleted file mode 100644
index 6144844..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h
+++ /dev/null
@@ -1,246 +0,0 @@
-/** @file
- Command header of for Debug Agent library instance.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _DEBUG_AGENT_H_
-#define _DEBUG_AGENT_H_
-
-#include <Register/LocalApic.h>
-
-#include <Guid/DebugAgentGuid.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/ResetSystemLib.h>
-#include <Library/IoLib.h>
-#include <Library/HobLib.h>
-#include <Library/DebugCommunicationLib.h>
-#include <Library/DebugAgentLib.h>
-#include <Library/PcdLib.h>
-#include <Library/SynchronizationLib.h>
-#include <Library/LocalApicLib.h>
-#include <Library/DebugLib.h>
-#include <Library/TimerLib.h>
-#include <Library/PrintLib.h>
-
-#include <TransferProtocol.h>
-#include <ImageDebugSupport.h>
-
-#include "DebugMp.h"
-#include "DebugTimer.h"
-#include "ArchDebugSupport.h"
-
-#define DEBUG_INT1_VECTOR 1
-#define DEBUG_INT3_VECTOR 3
-#define DEBUG_TIMER_VECTOR 32
-#define DEBUG_MAILBOX_VECTOR 33
-
-#define SOFT_INTERRUPT_SIGNATURE SIGNATURE_32('S','O','F','T')
-#define SYSTEM_RESET_SIGNATURE SIGNATURE_32('S','Y','S','R')
-#define MEMORY_READY_SIGNATURE SIGNATURE_32('M','E','M','R')
-
-extern UINTN Exception0Handle;
-extern UINTN TimerInterruptHandle;
-extern UINT16 ExceptionStubHeaderSize;
-
-//
-// CPU exception information issued by debug agent
-//
-typedef struct {
- //
- // This field is used to save CPU content before executing HOST command
- //
- BASE_LIBRARY_JUMP_BUFFER JumpBuffer;
- //
- // This filed returens the exception information issued by HOST command
- //
- DEBUG_DATA_RESPONSE_GET_EXCEPTION ExceptionContent;
-} DEBUG_AGENT_EXCEPTION_BUFFER;
-
-#pragma pack(1)
-typedef struct {
- //
- // Lower 32 bits to store the status of DebugAgent
- //
- UINT32 HostAttached : 1; // 1: HOST is attached
- UINT32 AgentInProgress : 1; // 1: Debug Agent is communicating with HOST
- UINT32 MemoryReady : 1; // 1: Memory is ready
- UINT32 SteppingFlag : 1; // 1: Agent is running stepping command
- UINT32 Reserved1 : 28;
-
- //
- // Higher 32bits to control the behavior of DebugAgent
- //
- UINT32 BreakOnNextSmi : 1; // 1: Break on next SMI
- UINT32 PrintErrorLevel : 8; // Bitmask of print error level for debug message
- UINT32 Reserved2 : 23;
-} DEBUG_AGENT_FLAG;
-
-typedef struct {
- DEBUG_AGENT_FLAG DebugFlag;
- UINT64 DebugPortHandle;
- //
- // Pointer to DEBUG_AGENT_EXCEPTION_BUFFER
- //
- UINT64 ExceptionBufferPointer;
-} DEBUG_AGENT_MAILBOX;
-#pragma pack()
-
-typedef union {
- struct {
- UINT32 LimitLow : 16;
- UINT32 BaseLow : 16;
- UINT32 BaseMid : 8;
- UINT32 Type : 4;
- UINT32 System : 1;
- UINT32 Dpl : 2;
- UINT32 Present : 1;
- UINT32 LimitHigh : 4;
- UINT32 Software : 1;
- UINT32 Reserved : 1;
- UINT32 DefaultSize : 1;
- UINT32 Granularity : 1;
- UINT32 BaseHigh : 8;
- } Bits;
- UINT64 Uint64;
-} IA32_GDT;
-
-/**
- Caller provided function to be invoked at the end of DebugPortInitialize().
-
- Refer to the descrption for DebugPortInitialize() for more details.
-
- @param[in] Context The first input argument of DebugPortInitialize().
- @param[in] DebugPortHandle Debug port handle created by Debug Communication Libary.
-
-**/
-VOID
-EFIAPI
-InitializeDebugAgentPhase2 (
- IN VOID *Context,
- IN DEBUG_PORT_HANDLE DebugPortHandle
- );
-
-/**
- Initialize IDT entries to support source level debug.
-
-**/
-VOID
-InitializeDebugIdt (
- VOID
- );
-
-/**
- Read register value from saved CPU context.
-
- @param[in] CpuContext Pointer to saved CPU context.
- @param[in] Index Register index value.
- @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 *Width
- );
-
-/**
- Send packet with response data to HOST.
-
- @param[in] Data Pointer to response data buffer.
- @param[in] DataSize Size of response data in byte.
-
- @retval RETURN_SUCCESS Response data was sent successfully.
- @retval RETURN_DEVICE_ERROR Cannot receive DEBUG_COMMAND_OK from HOST.
-
-**/
-RETURN_STATUS
-SendDataResponsePacket (
- IN UINT8 *Data,
- IN UINT16 DataSize
- );
-
-/**
- Check if HOST is attached based on Mailbox.
-
- @retval TRUE HOST is attached.
- @retval FALSE HOST is not attached.
-
-**/
-BOOLEAN
-IsHostAttached (
- VOID
- );
-
-/**
- Get Debug Agent Mailbox pointer.
-
- @return Mailbox pointer.
-
-**/
-DEBUG_AGENT_MAILBOX *
-GetMailboxPointer (
- VOID
- );
-
-/**
- Get debug port handle.
-
- @return Debug port handle.
-
-**/
-DEBUG_PORT_HANDLE
-GetDebugPortHandle (
- VOID
- );
-
-/**
- Read the Attach/Break-in symbols from the debug port.
-
- @param[in] Handle Pointer to Debug Port handle.
- @param[out] BreakSymbol Returned break symbol.
-
- @retval EFI_SUCCESS Read the symbol in BreakSymbol.
- @retval EFI_NOT_FOUND No read the break symbol.
-
-**/
-EFI_STATUS
-DebugReadBreakSymbol (
- IN DEBUG_PORT_HANDLE Handle,
- OUT UINT8 *BreakSymbol
- );
-
-/**
- Prints a debug message to the debug port if the specified error level is enabled.
-
- If any bit in ErrorLevel is also set in Mainbox, then print the message specified
- by Format and the associated variable argument list to the debug port.
-
- @param[in] ErrorLevel The error level of the debug message.
- @param[in] Format Format string for the debug message to print.
- @param[in] ... Variable argument list whose contents are accessed
- based on the format string specified by Format.
-
-**/
-VOID
-EFIAPI
-DebugAgentMsgPrint (
- IN UINT8 ErrorLevel,
- IN CHAR8 *Format,
- ...
- );
-#endif
-
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.c b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.c
deleted file mode 100644
index 5275b09..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.c
+++ /dev/null
@@ -1,404 +0,0 @@
-/** @file
- Multi-Processor support functions implementation.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "DebugAgent.h"
-
-DEBUG_MP_CONTEXT volatile mDebugMpContext = {0,0,0,0,0,0,0,0,FALSE,FALSE};
-
-DEBUG_CPU_DATA volatile mDebugCpuData = {0};
-
-/**
- Acquire access control on debug port.
-
- It will block in the function if cannot get the access control.
-
-**/
-VOID
-AcquireDebugPortControl (
- VOID
- )
-{
- if (!MultiProcessorDebugSupport) {
- return;
- }
-
- while (TRUE) {
- if (AcquireSpinLockOrFail (&mDebugMpContext.DebugPortSpinLock)) {
- break;
- }
- CpuPause ();
- continue;
- }
-}
-
-/**
- Release access control on debug port.
-
-**/
-VOID
-ReleaseDebugPortControl (
- VOID
- )
-{
- if (!MultiProcessorDebugSupport) {
- return;
- }
-
- ReleaseSpinLock (&mDebugMpContext.DebugPortSpinLock);
-}
-
-/**
- Acquire access control on MP context.
-
- It will block in the function if cannot get the access control.
-
-**/
-VOID
-AcquireMpContextControl (
- VOID
- )
-{
- while (TRUE) {
- if (AcquireSpinLockOrFail (&mDebugMpContext.MpContextSpinLock)) {
- break;
- }
- CpuPause ();
- continue;
- }
-}
-
-/**
- Release access control on MP context.
-
-**/
-VOID
-ReleaseMpContextControl (
- VOID
- )
-{
- ReleaseSpinLock (&mDebugMpContext.MpContextSpinLock);
-}
-
-/**
- Break the other processor by send IPI.
-
- @param[in] CurrentProcessorIndex Current processor index value.
-
-**/
-VOID
-HaltOtherProcessors (
- IN UINT32 CurrentProcessorIndex
- )
-{
- DebugAgentMsgPrint (DEBUG_AGENT_INFO, "processor[%x]:Try to halt other processors.\n", CurrentProcessorIndex);
- if (!IsBsp (CurrentProcessorIndex)) {
- SetIpiSentByApFlag (TRUE);;
- }
-
- mDebugMpContext.BreakAtCpuIndex = CurrentProcessorIndex;
-
- //
- // Set the debug viewpoint to the current breaking CPU.
- //
- SetDebugViewPoint (CurrentProcessorIndex);
-
- //
- // Send fixed IPI to other processors.
- //
- SendFixedIpiAllExcludingSelf (DEBUG_TIMER_VECTOR);
-
-}
-
-/**
- Get the current processor's index.
-
- @return Processor index value.
-
-**/
-UINT32
-GetProcessorIndex (
- VOID
- )
-{
- UINT32 Index;
- UINT16 LocalApicID;
-
- LocalApicID = (UINT16) GetApicId ();
-
- AcquireMpContextControl ();
-
- for (Index = 0; Index < mDebugCpuData.CpuCount; Index ++) {
- if (mDebugCpuData.ApicID[Index] == LocalApicID) {
- break;
- }
- }
-
- if (Index == mDebugCpuData.CpuCount) {
- mDebugCpuData.ApicID[Index] = LocalApicID;
- mDebugCpuData.CpuCount ++ ;
- }
-
- ReleaseMpContextControl ();
-
- return Index;
-}
-
-/**
- Check if the specified processor is BSP or not.
-
- @param[in] ProcessorIndex Processor index value.
-
- @retval TRUE It is BSP.
- @retval FALSE It isn't BSP.
-
-**/
-BOOLEAN
-IsBsp (
- IN UINT32 ProcessorIndex
- )
-{
- if (AsmMsrBitFieldRead64 (MSR_IA32_APIC_BASE_ADDRESS, 8, 8) == 1) {
- if (mDebugMpContext.BspIndex != ProcessorIndex) {
- AcquireMpContextControl ();
- mDebugMpContext.BspIndex = ProcessorIndex;
- ReleaseMpContextControl ();
- }
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-/**
- Set processor stop flag bitmask in MP context.
-
- @param[in] ProcessorIndex Processor index value.
- @param[in] StopFlag TRUE means set stop flag.
- FALSE means clean break flag.
-
-**/
-VOID
-SetCpuStopFlagByIndex (
- IN UINT32 ProcessorIndex,
- IN BOOLEAN StopFlag
- )
-{
- UINT8 Value;
- UINTN Index;
-
- AcquireMpContextControl ();
-
- Value = mDebugMpContext.CpuStopStatusMask[ProcessorIndex / 8];
- Index = ProcessorIndex % 8;
- if (StopFlag) {
- Value = BitFieldWrite8 (Value, Index, Index, 1);
- } else {
- Value = BitFieldWrite8 (Value, Index, Index, 0);
- }
- mDebugMpContext.CpuStopStatusMask[ProcessorIndex / 8] = Value;
-
- ReleaseMpContextControl ();
-}
-
-/**
- Set processor break flag bitmask in MP context.
-
- @param[in] ProcessorIndex Processor index value.
- @param[in] BreakFlag TRUE means set break flag.
- FALSE means clean break flag.
-
-**/
-VOID
-SetCpuBreakFlagByIndex (
- IN UINT32 ProcessorIndex,
- IN BOOLEAN BreakFlag
- )
-{
- UINT8 Value;
- UINTN Index;
-
- AcquireMpContextControl ();
-
- Value = mDebugMpContext.CpuBreakMask[ProcessorIndex / 8];
- Index = ProcessorIndex % 8;
- if (BreakFlag) {
- Value = BitFieldWrite8 (Value, Index, Index, 1);
- } else {
- Value = BitFieldWrite8 (Value, Index, Index, 0);
- }
- mDebugMpContext.CpuBreakMask[ProcessorIndex / 8] = Value;
-
- ReleaseMpContextControl ();
-}
-
-/**
- Check if processor is stopped already.
-
- @param[in] ProcessorIndex Processor index value.
-
- @retval TRUE Processor is stopped already.
- @retval TRUE Processor isn't stopped.
-
-**/
-BOOLEAN
-IsCpuStopped (
- IN UINT32 ProcessorIndex
- )
-{
- UINT8 CpuMask;
-
- CpuMask = (UINT8) (1 << (ProcessorIndex % 8));
-
- if ((mDebugMpContext.CpuStopStatusMask[ProcessorIndex / 8] & CpuMask) != 0) {
- return TRUE;
- } else {
- return FALSE;
- }
-}
-
-/**
- Set the run command flag.
-
- @param[in] RunningFlag TRUE means run command flag is set.
- FALSE means run command flag is cleared.
-
-**/
-VOID
-SetCpuRunningFlag (
- IN BOOLEAN RunningFlag
- )
-{
- AcquireMpContextControl ();
-
- mDebugMpContext.RunCommandSet = RunningFlag;
-
- ReleaseMpContextControl ();
-}
-
-/**
- Set the current view point to be debugged.
-
- @param[in] ProcessorIndex Processor index value.
-
-**/
-VOID
-SetDebugViewPoint (
- IN UINT32 ProcessorIndex
- )
-{
- AcquireMpContextControl ();
-
- mDebugMpContext.ViewPointIndex = ProcessorIndex;
-
- ReleaseMpContextControl ();
-}
-
-/**
- Set the IPI send by BPS/AP flag.
-
- @param[in] IpiSentByApFlag TRUE means this IPI is sent by AP.
- FALSE means this IPI is sent by BSP.
-
-**/
-VOID
-SetIpiSentByApFlag (
- IN BOOLEAN IpiSentByApFlag
- )
-{
- AcquireMpContextControl ();
-
- mDebugMpContext.IpiSentByAp = IpiSentByApFlag;
-
- ReleaseMpContextControl ();
-}
-
-/**
- Check the next pending breaking CPU.
-
- @retval others There is at least one processor broken, the minimum
- index number of Processor returned.
- @retval -1 No any processor broken.
-
-**/
-UINT32
-FindNextPendingBreakCpu (
- VOID
- )
-{
- UINT32 Index;
-
- for (Index = 0; Index < DEBUG_CPU_MAX_COUNT / 8; Index ++) {
- if (mDebugMpContext.CpuBreakMask[Index] != 0) {
- return (UINT32) LowBitSet32 (mDebugMpContext.CpuBreakMask[Index]) + Index * 8;
- }
- }
- return (UINT32)-1;
-}
-
-/**
- Check if all processors are in running status.
-
- @retval TRUE All processors run.
- @retval FALSE At least one processor does not run.
-
-**/
-BOOLEAN
-IsAllCpuRunning (
- VOID
- )
-{
- UINTN Index;
-
- for (Index = 0; Index < DEBUG_CPU_MAX_COUNT / 8; Index ++) {
- if (mDebugMpContext.CpuStopStatusMask[Index] != 0) {
- return FALSE;
- }
- }
- return TRUE;
-}
-
-/**
- Check if the current processor is the first breaking processor.
-
- If yes, halt other processors.
-
- @param[in] ProcessorIndex Processor index value.
-
- @return TRUE This processor is the first breaking processor.
- @return FALSE This processor is not the first breaking processor.
-
-**/
-BOOLEAN
-IsFirstBreakProcessor (
- IN UINT32 ProcessorIndex
- )
-{
- if (MultiProcessorDebugSupport) {
- if (mDebugMpContext.BreakAtCpuIndex != (UINT32) -1) {
- //
- // The current processor is not the first breaking one.
- //
- SetCpuBreakFlagByIndex (ProcessorIndex, TRUE);
- return FALSE;
- } else {
- //
- // If no any processor breaks, try to halt other processors
- //
- HaltOtherProcessors (ProcessorIndex);
- return TRUE;
- }
- }
- return TRUE;
-}
-
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.h b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.h
deleted file mode 100644
index 183887c..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugMp.h
+++ /dev/null
@@ -1,237 +0,0 @@
-/** @file
- Header file for Multi-Processor support.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _DEBUG_MP_H_
-#define _DEBUG_MP_H_
-
-#define DEBUG_CPU_MAX_COUNT 256
-
-typedef struct {
- UINT32 CpuCount; ///< Processor count
- UINT16 ApicID[DEBUG_CPU_MAX_COUNT]; ///< Record the local apic id for each processor
-} DEBUG_CPU_DATA;
-
-typedef struct {
- SPIN_LOCK MpContextSpinLock; ///< Lock for writting MP context
- SPIN_LOCK DebugPortSpinLock; ///< Lock for access debug port
- UINT8 CpuBreakMask[DEBUG_CPU_MAX_COUNT/8]; ///< Bitmask of all breaking CPUs
- UINT8 CpuStopStatusMask[DEBUG_CPU_MAX_COUNT/8]; ///< Bitmask of CPU stop status
- UINT32 ViewPointIndex; ///< Current view point to be debugged
- UINT32 BspIndex; ///< Processor index value of BSP
- UINT32 BreakAtCpuIndex; ///< Processor index value of the current breaking CPU
- UINT32 DebugTimerInitCount; ///< Record BSP's init timer count
- BOOLEAN IpiSentByAp; ///< TRUR: IPI is sent by AP. TALSE: IPI is sent by BSP
- BOOLEAN RunCommandSet; ///< TRUE: RUN commmand is executing. FALSE : RUN command has been executed.
-} DEBUG_MP_CONTEXT;
-
-extern CONST BOOLEAN MultiProcessorDebugSupport;
-extern DEBUG_MP_CONTEXT volatile mDebugMpContext;
-extern DEBUG_CPU_DATA volatile mDebugCpuData;
-
-/**
- Break the other processor by send IPI.
-
- @param[in] CurrentProcessorIndex Current processor index value.
-
-**/
-VOID
-HaltOtherProcessors (
- IN UINT32 CurrentProcessorIndex
- );
-
-/**
- Get the current processor's index.
-
- @return Processor index value.
-
-**/
-UINT32
-GetProcessorIndex (
- VOID
- );
-
-/**
- Acquire access control on MP context.
-
- It will block in the function if cannot get the access control.
-
-**/
-VOID
-AcquireMpContextControl (
- VOID
- );
-
-/**
- Release access control on MP context.
-
-**/
-VOID
-ReleaseMpContextControl (
- VOID
- );
-
-/**
- Acquire access control on debug port.
-
- It will block in the function if cannot get the access control.
-
-**/
-VOID
-AcquireDebugPortControl (
- VOID
- );
-
-/**
- Release access control on debug port.
-
-**/
-VOID
-ReleaseDebugPortControl (
- VOID
- );
-
-/**
- Check if the specified processor is BSP or not.
-
- @param[in] ProcessorIndex Processor index value.
-
- @retval TRUE It is BSP.
- @retval FALSE It isn't BSP.
-
-**/
-BOOLEAN
-IsBsp (
- IN UINT32 ProcessorIndex
- );
-
-/**
- Set processor stop flag bitmask in MP context.
-
- @param[in] ProcessorIndex Processor index value.
- @param[in] StopFlag TRUE means set stop flag.
- FALSE means clean break flag.
-
-**/
-VOID
-SetCpuStopFlagByIndex (
- IN UINT32 ProcessorIndex,
- IN BOOLEAN StopFlag
- );
-
-/**
- Set processor break flag bitmask in MP context.
-
- @param[in] ProcessorIndex Processor index value.
- @param[in] BreakFlag TRUE means set break flag.
- FALSE means clean break flag.
-
-**/
-VOID
-SetCpuBreakFlagByIndex (
- IN UINT32 ProcessorIndex,
- IN BOOLEAN BreakFlag
- );
-
-/**
- Check if processor is stopped already.
-
- @param[in] ProcessorIndex Processor index value.
-
- @retval TRUE Processor is stopped already.
- @retval FALSE Processor isn't stopped.
-
-**/
-BOOLEAN
-IsCpuStopped (
- IN UINT32 ProcessorIndex
- );
-
-/**
- Set the run command flag.
-
- @param[in] RunningFlag TRUE means run command flag is set.
- FALSE means run command flag is cleared.
-
-**/
-VOID
-SetCpuRunningFlag (
- IN BOOLEAN RunningFlag
- );
-
-/**
- Set the current view point to be debugged.
-
- @param[in] ProcessorIndex Processor index value.
-
-**/
-VOID
-SetDebugViewPoint (
- IN UINT32 ProcessorIndex
- );
-
-/**
- Set the IPI send by BPS/AP flag.
-
- @param[in] IpiSentByApFlag TRUE means this IPI is sent by AP.
- FALSE means this IPI is sent by BSP.
-
-**/
-VOID
-SetIpiSentByApFlag (
- IN BOOLEAN IpiSentByApFlag
- );
-
-/**
- Check the next pending breaking CPU.
-
- @retval others There is at least one processor broken, the minimum
- index number of Processor returned.
- @retval -1 No any processor broken.
-
-**/
-UINT32
-FindNextPendingBreakCpu (
- VOID
- );
-
-/**
- Check if all processors are in running status.
-
- @retval TRUE All processors run.
- @retval FALSE At least one processor does not run.
-
-**/
-BOOLEAN
-IsAllCpuRunning (
- VOID
- );
-
-/**
- Check if the current processor is the first breaking processor.
-
- If yes, halt other processors.
-
- @param[in] ProcessorIndex Processor index value.
-
- @return TRUE This processor is the first breaking processor.
- @return FALSE This processor is not the first breaking processor.
-
-**/
-BOOLEAN
-IsFirstBreakProcessor (
- IN UINT32 ProcessorIndex
- );
-
-#endif
-
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugTimer.c b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugTimer.c
deleted file mode 100644
index d473df8..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugTimer.c
+++ /dev/null
@@ -1,83 +0,0 @@
-/** @file
- Code for debug timer to support debug agent library implementation.
-
- Copyright (c) 2010, 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "DebugAgent.h"
-
-/**
- Initialize CPU local APIC timer.
-
-**/
-VOID
-InitializeDebugTimer (
- VOID
- )
-{
- UINTN ApicTimerDivisor;
- UINT32 InitialCount;
-
- GetApicTimerState (&ApicTimerDivisor, NULL, NULL);
-
- //
- // Cpu Local Apic timer interrupt frequency, it is set to 0.1s
- //
- InitialCount = (UINT32)DivU64x32 (
- MultU64x64 (
- PcdGet32(PcdFSBClock) / (UINT32)ApicTimerDivisor,
- 100
- ),
- 1000
- );
-
- InitializeApicTimer (ApicTimerDivisor, InitialCount, TRUE, DEBUG_TIMER_VECTOR);
-
- if (MultiProcessorDebugSupport) {
- mDebugMpContext.DebugTimerInitCount = InitialCount;
- }
-}
-
-/**
- Enable/Disable the interrupt of debug timer and return the interrupt state
- prior to the operation.
-
- If EnableStatus is TRUE, enable the interrupt of debug timer.
- If EnableStatus is FALSE, disable the interrupt of debug timer.
-
- @param[in] EnableStatus Enable/Disable.
-
- @retval TRUE Debug timer interrupt were enabled on entry to this call.
- @retval FALSE Debug timer interrupt were disabled on entry to this call.
-
-**/
-BOOLEAN
-EFIAPI
-SaveAndSetDebugTimerInterrupt (
- IN BOOLEAN EnableStatus
- )
-{
- BOOLEAN OldInterruptState;
- BOOLEAN OldDebugTimerInterruptState;
-
- OldInterruptState = SaveAndDisableInterrupts ();
- OldDebugTimerInterruptState = GetApicTimerInterruptState ();
-
- if (EnableStatus) {
- EnableApicTimerInterrupt ();
- } else {
- DisableApicTimerInterrupt ();
- }
-
- SetInterruptState (OldInterruptState);
- return OldDebugTimerInterruptState;
-}
-
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugTimer.h b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugTimer.h
deleted file mode 100644
index 4970f93..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugTimer.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/** @file
- Header file for debug timer to support debug agent library implementation.
-
- Copyright (c) 2010, 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _DEBUG_TIMER_H_
-#define _DEBUG_TIMER_H_
-
-/**
- Initialize debug timer.
-
-**/
-VOID
-InitializeDebugTimer (
- VOID
- );
-
-#endif
-
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/ArchDebugSupport.c b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/ArchDebugSupport.c
deleted file mode 100644
index 52ed647..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/ArchDebugSupport.c
+++ /dev/null
@@ -1,65 +0,0 @@
-/** @file
- Supporting functions for IA32 architecture.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "DebugAgent.h"
-
-/**
- Initialize IDT entries to support source level debug.
-
-**/
-VOID
-InitializeDebugIdt (
- VOID
- )
-{
- IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
- UINTN InterruptHandler;
- IA32_DESCRIPTOR IdtDescriptor;
- UINTN Index;
- UINT16 CodeSegment;
-
- AsmReadIdtr (&IdtDescriptor);
-
- //
- // Use current CS as the segment selector of interrupt gate in IDT
- //
- CodeSegment = AsmReadCs ();
-
- IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *) IdtDescriptor.Base;
-
- for (Index = 0; Index < 20; Index ++) {
- if ((PcdGet32 (PcdExceptionsIgnoredByDebugger) & (1 << Index)) != 0) {
- //
- // If the exception is masked to be reserved, skip it
- //
- continue;
- }
- InterruptHandler = (UINTN)&Exception0Handle + Index * ExceptionStubHeaderSize;
- IdtEntry[Index].Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler;
- IdtEntry[Index].Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16);
- IdtEntry[Index].Bits.Selector = CodeSegment;
- IdtEntry[Index].Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
- }
-
- InterruptHandler = (UINTN) &TimerInterruptHandle;
- IdtEntry[DEBUG_TIMER_VECTOR].Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler;
- IdtEntry[DEBUG_TIMER_VECTOR].Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16);
- 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);
-}
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/ArchDebugSupport.h b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/ArchDebugSupport.h
deleted file mode 100644
index fa1c2f1..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/ArchDebugSupport.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/** @file
- IA32 specific defintions for debug agent library instance.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _ARCH_DEBUG_SUPPORT_H_
-#define _ARCH_DEBUG_SUPPORT_H_
-
-#include "ProcessorContext.h"
-#include "TransferProtocol.h"
-
-#define DEBUG_SW_BREAKPOINT_SYMBOL 0xcc
-#define DEBUG_ARCH_SYMBOL DEBUG_DATA_BREAK_CPU_ARCH_IA32
-
-typedef DEBUG_DATA_IA32_FX_SAVE_STATE DEBUG_DATA_FX_SAVE_STATE;
-typedef DEBUG_DATA_IA32_SYSTEM_CONTEXT DEBUG_CPU_CONTEXT;
-
-#endif
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.S b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.S
deleted file mode 100644
index cfeeea0..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.S
+++ /dev/null
@@ -1,366 +0,0 @@
-#------------------------------------------------------------------------------
-#
-# 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
-# http://opensource.org/licenses/bsd-license.php.
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-# Module Name:
-#
-# AsmFuncs.S
-#
-# Abstract:
-#
-# Debug interrupt handle functions.
-#
-#------------------------------------------------------------------------------
-
-#include "DebugException.h"
-
-ASM_GLOBAL ASM_PFX(InterruptProcess)
-ASM_GLOBAL ASM_PFX(Exception0Handle)
-ASM_GLOBAL ASM_PFX(ExceptionStubHeaderSize)
-ASM_GLOBAL ASM_PFX(TimerInterruptHandle)
-ASM_GLOBAL ASM_PFX(CommonEntry)
-
-.data
-
-ASM_PFX(ExceptionStubHeaderSize): .word ASM_PFX(Exception1Handle) - ASM_PFX(Exception0Handle)
-
-.text
-
-ASM_PFX(Exception0Handle):
- cli
- pushl %eax
- mov $0, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception1Handle):
- cli
- pushl %eax
- mov $1, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception2Handle):
- cli
- pushl %eax
- mov $2, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception3Handle):
- cli
- pushl %eax
- mov $3, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception4Handle):
- cli
- pushl %eax
- mov $4, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception5Handle):
- cli
- pushl %eax
- mov $5, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception6Handle):
- cli
- pushl %eax
- mov $6, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception7Handle):
- cli
- pushl %eax
- mov $7, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception8Handle):
- cli
- pushl %eax
- mov $8, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception9Handle):
- cli
- pushl %eax
- mov $9, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception10Handle):
- cli
- pushl %eax
- mov $10, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception11Handle):
- cli
- pushl %eax
- mov $11, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception12Handle):
- cli
- pushl %eax
- mov $12, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception13Handle):
- cli
- pushl %eax
- mov $13, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception14Handle):
- cli
- pushl %eax
- mov $14, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception15Handle):
- cli
- pushl %eax
- mov $15, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception16Handle):
- cli
- pushl %eax
- mov $16, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception17Handle):
- cli
- pushl %eax
- mov $17, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception18Handle):
- cli
- pushl %eax
- mov $18, %eax
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception19Handle):
- cli
- pushl %eax
- mov $19, %eax
- jmp ASM_PFX(CommonEntry)
-
-ASM_PFX(TimerInterruptHandle):
- cli
- pushl %eax
- mov $32, %eax
- jmp ASM_PFX(CommonEntry)
-
-
-ASM_PFX(CommonEntry):
-
-#---------------------------------------;
-# _CommonEntry ;
-#----------------------------------------------------------------------------;
-# The follow algorithm is used for the common interrupt routine.
-# Entry from each interrupt with a push eax and eax=interrupt number
-#
-# +---------------------+
-# + EFlags +
-# +---------------------+
-# + CS +
-# +---------------------+
-# + EIP +
-# +---------------------+
-# + Error Code +
-# +---------------------+
-# + EAX / Vector Number +
-# +---------------------+
-# + EBP +
-# +---------------------+ <-- EBP
-#
-
-# We need to determine if any extra data was pushed by the exception
- cmpl $DEBUG_EXCEPT_DOUBLE_FAULT, %eax
- je NoExtrPush
- cmpl $DEBUG_EXCEPT_INVALID_TSS, %eax
- je NoExtrPush
- cmpl $DEBUG_EXCEPT_SEG_NOT_PRESENT, %eax
- je NoExtrPush
- cmpl $DEBUG_EXCEPT_STACK_FAULT, %eax
- je NoExtrPush
- cmpl $DEBUG_EXCEPT_GP_FAULT, %eax
- je NoExtrPush
- cmpl $DEBUG_EXCEPT_PAGE_FAULT, %eax
- je NoExtrPush
- cmpl $DEBUG_EXCEPT_ALIGNMENT_CHECK, %eax
- je NoExtrPush
-
- pushl (%esp)
- movl $0, 4(%esp)
-
-NoExtrPush:
-
- pushl %ebp
- movl %esp,%ebp
-
- #
- # Align stack to make sure that EFI_FX_SAVE_STATE_IA32 of EFI_SYSTEM_CONTEXT_IA32
- # is 16-byte aligned
- #
- andl $0xfffffff0,%esp
- subl $12,%esp
-
-## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
- pushl 0x4(%ebp)
- pushl %ebx
- pushl %ecx
- pushl %edx
- mov %eax, %ebx # save vector in ebx
- leal 24(%ebp),%ecx
- pushl %ecx # save original ESP
- pushl (%ebp)
- pushl %esi
- pushl %edi
-
-## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
- movl %cr4, %eax
- orl $0x208,%eax
- movl %eax, %cr4
- pushl %eax
- movl %cr3, %eax
- pushl %eax
- movl %cr2, %eax
- pushl %eax
- xorl %eax,%eax
- pushl %eax
- movl %cr0, %eax
- pushl %eax
-
-## UINT32 Gs, Fs, Es, Ds, Cs, Ss;
- movl %ss,%eax
- pushl %eax
- movzwl 16(%ebp), %eax
- pushl %eax
- movl %ds,%eax
- pushl %eax
- movl %es,%eax
- pushl %eax
- movl %fs,%eax
- pushl %eax
- movl %gs,%eax
- pushl %eax
-
-## UINT32 Eip;
- pushl 12(%ebp)
-
-## UINT32 Gdtr[2], Idtr[2];
- subl $8,%esp
- sidt (%esp)
- subl $8,%esp
- sgdt (%esp)
-
-## UINT32 Ldtr, Tr;
- xorl %eax,%eax
- strl %eax
- pushl %eax
- sldtl %eax
- pushl %eax
-
-## UINT32 EFlags;
- pushl 20(%ebp)
-
-## UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
- movl %dr7, %eax
- pushl %eax
-## clear Dr7 while executing debugger itself
- xorl %eax,%eax
-# movl %eax, %dr7
-
- movl %dr6, %eax
- pushl %eax
-## insure all status bits in dr6 are clear...
- xorl %eax,%eax
- movl %eax, %dr6
-
- movl %dr3, %eax
- pushl %eax
- movl %dr2, %eax
- pushl %eax
- movl %dr1, %eax
- pushl %eax
- movl %dr0, %eax
- pushl %eax
-
-## FX_SAVE_STATE_IA32 FxSaveState;
- subl $512,%esp
- movl %esp,%edi
- .byte 0x0f, 0xae, 0x07 # fxsave [edi]
-
-## save the exception data
- pushl 8(%esp)
-
-## Clear Direction Flag
- cld
-
-## Prepare parameter and call C function
- pushl %esp
- pushl %ebx
- call ASM_PFX(InterruptProcess)
- addl $8,%esp
-
-## skip the exception data
- addl $4,%esp
-
-## FX_SAVE_STATE_IA32 FxSaveState;
- movl %esp,%esi
- .byte 0x0f, 0xae, 0x0e # fxrstor [esi]
- addl $512,%esp
-
-## UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
- popl %eax
- movl %eax, %dr0
- popl %eax
- movl %eax, %dr1
- popl %eax
- movl %eax, %dr2
- popl %eax
- movl %eax, %dr3
-## skip restore of dr6. We cleared dr6 during the context save.
- addl $4,%esp
- popl %eax
- movl %eax, %dr7
-
-## UINT32 EFlags;
- popl 20(%ebp)
-
-## UINT32 Ldtr, Tr;
-## UINT32 Gdtr[2], Idtr[2];
-## Best not let anyone mess with these particular registers...
- addl $24,%esp
-
-## UINT32 Eip;
- pop 12(%ebp)
-
-## UINT32 Gs, Fs, Es, Ds, Cs, Ss;
-## NOTE - modified segment registers could hang the debugger... We
-## could attempt to insulate ourselves against this possibility,
-## but that poses risks as well.
-##
- popl %gs
- popl %fs
- popl %es
- popl %ds
- popl 16(%ebp)
- popl %ss
-
-## UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
- popl %eax
- movl %eax, %cr0
- addl $4,%esp # not for Cr1
- popl %eax
- movl %eax, %cr2
- popl %eax
- movl %eax, %cr3
- popl %eax
- movl %eax, %cr4
-
-## UINT32 Edi, Esi, Ebp, Esp, Ebx, Edx, Ecx, Eax;
- popl %edi
- popl %esi
- addl $4,%esp # not for ebp
- addl $4,%esp # not for esp
- popl %edx
- popl %ecx
- popl %ebx
- popl %eax
-
- movl %ebp,%esp
- popl %ebp
- addl $8,%esp # skip eax
- iretl
-
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.asm b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.asm
deleted file mode 100644
index 6f3b3bc..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.asm
+++ /dev/null
@@ -1,371 +0,0 @@
-;------------------------------------------------------------------------------
-;
-; 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
-; http://opensource.org/licenses/bsd-license.php.
-;
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-;
-; Module Name:
-;
-; AsmFuncs.asm
-;
-; Abstract:
-;
-; Debug interrupt handle functions.
-;
-;------------------------------------------------------------------------------
-
-#include "DebugException.h"
-
-.686p
-.xmm
-.model flat,c
-
-;
-; InterruptProcess()
-;
-InterruptProcess PROTO C
-
-public Exception0Handle, TimerInterruptHandle, ExceptionStubHeaderSize
-
-.data
-
-ExceptionStubHeaderSize DW Exception1Handle - Exception0Handle
-CommonEntryAddr DD CommonEntry
-
-.code
-
-Exception0Handle:
- cli
- push eax
- mov eax, 0
- jmp dword ptr [CommonEntryAddr]
-Exception1Handle:
- cli
- push eax
- mov eax, 1
- jmp dword ptr [CommonEntryAddr]
-Exception2Handle:
- cli
- push eax
- mov eax, 2
- jmp dword ptr [CommonEntryAddr]
-Exception3Handle:
- cli
- push eax
- mov eax, 3
- jmp dword ptr [CommonEntryAddr]
-Exception4Handle:
- cli
- push eax
- mov eax, 4
- jmp dword ptr [CommonEntryAddr]
-Exception5Handle:
- cli
- push eax
- mov eax, 5
- jmp dword ptr [CommonEntryAddr]
-Exception6Handle:
- cli
- push eax
- mov eax, 6
- jmp dword ptr [CommonEntryAddr]
-Exception7Handle:
- cli
- push eax
- mov eax, 7
- jmp dword ptr [CommonEntryAddr]
-Exception8Handle:
- cli
- push eax
- mov eax, 8
- jmp dword ptr [CommonEntryAddr]
-Exception9Handle:
- cli
- push eax
- mov eax, 9
- jmp dword ptr [CommonEntryAddr]
-Exception10Handle:
- cli
- push eax
- mov eax, 10
- jmp dword ptr [CommonEntryAddr]
-Exception11Handle:
- cli
- push eax
- mov eax, 11
- jmp dword ptr [CommonEntryAddr]
-Exception12Handle:
- cli
- push eax
- mov eax, 12
- jmp dword ptr [CommonEntryAddr]
-Exception13Handle:
- cli
- push eax
- mov eax, 13
- jmp dword ptr [CommonEntryAddr]
-Exception14Handle:
- cli
- push eax
- mov eax, 14
- jmp dword ptr [CommonEntryAddr]
-Exception15Handle:
- cli
- push eax
- mov eax, 15
- jmp dword ptr [CommonEntryAddr]
-Exception16Handle:
- cli
- push eax
- mov eax, 16
- jmp dword ptr [CommonEntryAddr]
-Exception17Handle:
- cli
- push eax
- mov eax, 17
- jmp dword ptr [CommonEntryAddr]
-Exception18Handle:
- cli
- push eax
- mov eax, 18
- jmp dword ptr [CommonEntryAddr]
-Exception19Handle:
- cli
- push eax
- mov eax, 19
- jmp dword ptr [CommonEntryAddr]
-
-TimerInterruptHandle:
- cli
- push eax
- mov eax, 32
- jmp dword ptr [CommonEntryAddr]
-
-CommonEntry:
-;
-; +---------------------+
-; + EFlags +
-; +---------------------+
-; + CS +
-; +---------------------+
-; + EIP +
-; +---------------------+
-; + Error Code +
-; +---------------------+
-; + EAX / Vector Number +
-; +---------------------+
-; + EBP +
-; +---------------------+ <-- EBP
-;
- cmp eax, DEBUG_EXCEPT_DOUBLE_FAULT
- je NoExtrPush
- cmp eax, DEBUG_EXCEPT_INVALID_TSS
- je NoExtrPush
- cmp eax, DEBUG_EXCEPT_SEG_NOT_PRESENT
- je NoExtrPush
- cmp eax, DEBUG_EXCEPT_STACK_FAULT
- je NoExtrPush
- cmp eax, DEBUG_EXCEPT_GP_FAULT
- je NoExtrPush
- cmp eax, DEBUG_EXCEPT_PAGE_FAULT
- je NoExtrPush
- cmp eax, DEBUG_EXCEPT_ALIGNMENT_CHECK
- je NoExtrPush
-
- push [esp]
- mov dword ptr [esp + 4], 0
-
-NoExtrPush:
-
- push ebp
- mov ebp, esp ; save esp in ebp
- ;
- ; Make stack 16-byte alignment to make sure save fxrstor later
- ;
- and esp, 0fffffff0h
- sub esp, 12
-
- ; store UINT32 Edi, Esi, Ebp, Ebx, Edx, Ecx, Eax;
- push dword ptr [ebp + 4] ; original eax
- push ebx
- push ecx
- push edx
- mov ebx, eax ; save vector in ebx
- mov eax, ebp
- add eax, 4 * 6
- push eax ; original ESP
- push dword ptr [ebp] ; EBP
- push esi
- push edi
-
- ;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
- ;; insure FXSAVE/FXRSTOR is enabled in CR4...
- ;; ... while we're at it, make sure DE is also enabled...
- mov eax, cr4
- push eax ; push cr4 firstly
- or eax, 208h
- mov cr4, eax
- mov eax, cr3
- push eax
- mov eax, cr2
- push eax
- push 0 ; cr0 will not saved???
- mov eax, cr0
- push eax
-
- xor ecx, ecx
- mov ecx, Ss
- push ecx
- mov ecx, Cs
- push ecx
- mov ecx, Ds
- push ecx
- mov ecx, Es
- push ecx
- mov ecx, Fs
- push ecx
- mov ecx, Gs
- push ecx
-
- ;; EIP
- mov ecx, [ebp + 4 * 3] ; EIP
- push ecx
-
- ;; UINT32 Gdtr[2], Idtr[2];
- sub esp, 8
- sidt fword ptr [esp]
- sub esp, 8
- sgdt fword ptr [esp]
-
- ;; UINT32 Ldtr, Tr;
- xor eax, eax
- str ax
- push eax
- sldt ax
- push eax
-
- ;; EFlags
- mov ecx, [ebp + 4 * 5]
- push ecx
-
- ;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
- mov eax, dr7
- push eax
-
- ;; clear Dr7 while executing debugger itself
- xor eax, eax
- ;; mov dr7, eax
-
- ;; Dr6
- mov eax, dr6
- push eax
-
- ;; insure all status bits in dr6 are clear...
- xor eax, eax
- mov dr6, eax
-
- mov eax, dr3
- push eax
- mov eax, dr2
- push eax
- mov eax, dr1
- push eax
- mov eax, dr0
- push eax
-
- ;; FX_SAVE_STATE_IA32 FxSaveState;
- sub esp, 512
- mov edi, esp
- db 0fh, 0aeh, 00000111y ;fxsave [edi]
-
- ;; save the exception data
- push dword ptr [ebp + 8]
-
- ;; Clear Direction Flag
- cld
-
- ; call the C interrupt process function
- push esp ; Structure
- push ebx ; vector
- call InterruptProcess
- add esp, 8
-
- ; skip the exception data
- add esp, 4
-
- ;; FX_SAVE_STATE_IA32 FxSaveState;
- mov esi, esp
- db 0fh, 0aeh, 00001110y ; fxrstor [esi]
- add esp, 512
-
- ;; UINT32 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
- pop eax
- mov dr0, eax
- pop eax
- mov dr1, eax
- pop eax
- mov dr2, eax
- pop eax
- mov dr3, eax
- ;; skip restore of dr6. We cleared dr6 during the context save.
- add esp, 4
- pop eax
- mov dr7, eax
-
- ;; set EFlags
- pop dword ptr [ebp + 4 * 5] ; set EFLAGS in stack
-
- ;; UINT32 Ldtr, Tr;
- ;; UINT32 Gdtr[2], Idtr[2];
- ;; Best not let anyone mess with these particular registers...
- add esp, 24
-
- ;; UINT32 Eip;
- pop dword ptr [ebp + 4 * 3] ; set EIP in stack
-
- ;; UINT32 Gs, Fs, Es, Ds, Cs, Ss;
- ;; NOTE - modified segment registers could hang the debugger... We
- ;; could attempt to insulate ourselves against this possibility,
- ;; but that poses risks as well.
- ;;
- pop gs
- pop fs
- pop es
- pop ds
- pop dword ptr [ebp + 4 * 4] ; set CS in stack
- pop ss
-
- ;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
- pop eax
- mov cr0, eax
- add esp, 4 ; skip for Cr1
- pop eax
- mov cr2, eax
- pop eax
- mov cr3, eax
- pop eax
- mov cr4, eax
-
- ;; restore general register
- pop edi
- pop esi
- pop dword ptr [ebp] ; save updated ebp
- pop dword ptr [ebp + 4] ; save updated esp
- pop edx
- pop ecx
- pop ebx
- pop eax
-
- mov esp, ebp
- pop ebp ; restore ebp maybe updated
- pop esp ; restore esp maybe updated
- sub esp, 4 * 3 ; restore interupt pushced stack
-
- iretd
-
-END
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/DebugException.h b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/DebugException.h
deleted file mode 100644
index 13a7d23..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/DebugException.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/** @file
- Exception defintions.
-
- Copyright (c) 2010, 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _DEBUG_EXCEPTION_H_
-#define _DEBUG_EXCEPTION_H_
-
-#define DEBUG_EXCEPT_DIVIDE_ERROR 0
-#define DEBUG_EXCEPT_DEBUG 1
-#define DEBUG_EXCEPT_NMI 2
-#define DEBUG_EXCEPT_BREAKPOINT 3
-#define DEBUG_EXCEPT_OVERFLOW 4
-#define DEBUG_EXCEPT_BOUND 5
-#define DEBUG_EXCEPT_INVALID_OPCODE 6
-#define DEBUG_EXCEPT_DOUBLE_FAULT 8
-#define DEBUG_EXCEPT_INVALID_TSS 10
-#define DEBUG_EXCEPT_SEG_NOT_PRESENT 11
-#define DEBUG_EXCEPT_STACK_FAULT 12
-#define DEBUG_EXCEPT_GP_FAULT 13
-#define DEBUG_EXCEPT_PAGE_FAULT 14
-#define DEBUG_EXCEPT_FP_ERROR 16
-#define DEBUG_EXCEPT_ALIGNMENT_CHECK 17
-#define DEBUG_EXCEPT_MACHINE_CHECK 18
-#define DEBUG_EXCEPT_SIMD 19
-
-#endif
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.c b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.c
deleted file mode 100644
index 9803f0f..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/** @file
- Supporting functions for X64 architecture.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "DebugAgent.h"
-
-/**
- Initialize IDT entries to support source level debug.
-
-**/
-VOID
-InitializeDebugIdt (
- VOID
- )
-{
- IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
- UINTN InterruptHandler;
- IA32_DESCRIPTOR IdtDescriptor;
- UINTN Index;
- UINT16 CodeSegment;
-
- AsmReadIdtr (&IdtDescriptor);
-
- //
- // Use current CS as the segment selector of interrupt gate in IDT
- //
- CodeSegment = AsmReadCs ();
-
- IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *) IdtDescriptor.Base;
-
- for (Index = 0; Index < 20; Index ++) {
- if ((PcdGet32 (PcdExceptionsIgnoredByDebugger) & (1 << Index)) != 0) {
- //
- // If the exception is masked to be reserved, skip it
- //
- continue;
- }
- InterruptHandler = (UINTN)&Exception0Handle + Index * ExceptionStubHeaderSize;
- IdtEntry[Index].Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler;
- IdtEntry[Index].Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16);
- IdtEntry[Index].Bits.OffsetUpper = (UINT32)((UINTN)InterruptHandler >> 32);
- IdtEntry[Index].Bits.Selector = CodeSegment;
- IdtEntry[Index].Bits.GateType = IA32_IDT_GATE_TYPE_INTERRUPT_32;
- }
-
- InterruptHandler = (UINTN) &TimerInterruptHandle;
- IdtEntry[DEBUG_TIMER_VECTOR].Bits.OffsetLow = (UINT16)(UINTN)InterruptHandler;
- IdtEntry[DEBUG_TIMER_VECTOR].Bits.OffsetHigh = (UINT16)((UINTN)InterruptHandler >> 16);
- 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);
-}
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.h b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.h
deleted file mode 100644
index 26e6d8a..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/ArchDebugSupport.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/** @file
- X64 specific defintions for debug agent library instance.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _ARCH_DEBUG_SUPPORT_H_
-#define _ARCH_DEBUG_SUPPORT_H_
-
-#include "ProcessorContext.h"
-#include "TransferProtocol.h"
-
-#define DEBUG_SW_BREAKPOINT_SYMBOL 0xcc
-#define DEBUG_ARCH_SYMBOL DEBUG_DATA_BREAK_CPU_ARCH_X64
-
-typedef DEBUG_DATA_X64_FX_SAVE_STATE DEBUG_DATA_FX_SAVE_STATE;
-typedef DEBUG_DATA_X64_SYSTEM_CONTEXT DEBUG_CPU_CONTEXT;
-
-#endif
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/AsmFuncs.S b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/AsmFuncs.S
deleted file mode 100644
index 3de9767..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/AsmFuncs.S
+++ /dev/null
@@ -1,407 +0,0 @@
-#------------------------------------------------------------------------------
-#
-# Copyright (c) 2006 - 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
-# http://opensource.org/licenses/bsd-license.php.
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-# Module Name:
-#
-# AsmFuncs.S
-#
-# Abstract:
-#
-# Debug interrupt handle functions.
-#
-#------------------------------------------------------------------------------
-
-#include "DebugException.h"
-
-ASM_GLOBAL ASM_PFX(InterruptProcess)
-
-ASM_GLOBAL ASM_PFX(Exception0Handle)
-ASM_GLOBAL ASM_PFX(ExceptionStubHeaderSize)
-ASM_GLOBAL ASM_PFX(TimerInterruptHandle)
-ASM_GLOBAL ASM_PFX(CommonEntry)
-
-.data
-
-ASM_PFX(ExceptionStubHeaderSize): .word ASM_PFX(Exception1Handle) - ASM_PFX(Exception0Handle)
-
-
-.text
-
-ASM_PFX(Exception0Handle):
- cli
- pushq %rcx
- mov $0, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception1Handle):
- cli
- pushq %rcx
- mov $1, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception2Handle):
- cli
- pushq %rcx
- mov $2, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception3Handle):
- cli
- pushq %rcx
- mov $3, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception4Handle):
- cli
- pushq %rcx
- mov $4, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception5Handle):
- cli
- pushq %rcx
- mov $5, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception6Handle):
- cli
- pushq %rcx
- mov $6, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception7Handle):
- cli
- pushq %rcx
- mov $7, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception8Handle):
- cli
- pushq %rcx
- mov $8, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception9Handle):
- cli
- pushq %rcx
- mov $9, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception10Handle):
- cli
- pushq %rcx
- mov $10, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception11Handle):
- cli
- pushq %rcx
- mov $11, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception12Handle):
- cli
- pushq %rcx
- mov $12, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception13Handle):
- cli
- pushq %rcx
- mov $13, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception14Handle):
- cli
- pushq %rcx
- mov $14, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception15Handle):
- cli
- pushq %rcx
- mov $15, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception16Handle):
- cli
- pushq %rcx
- mov $16, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception17Handle):
- cli
- pushq %rcx
- mov $17, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception18Handle):
- cli
- pushq %rcx
- mov $18, %rcx
- jmp ASM_PFX(CommonEntry)
-ASM_PFX(Exception19Handle):
- cli
- pushq %rcx
- mov $19, %rcx
- jmp ASM_PFX(CommonEntry)
-
-ASM_PFX(TimerInterruptHandle):
- cli
- pushq %rcx
- mov $32, %rcx
- jmp ASM_PFX(CommonEntry)
-
-
-ASM_PFX(CommonEntry):
-
-#---------------------------------------;
-# CommonInterruptEntry ;
-#---------------------------------------;
-# The follow algorithm is used for the common interrupt routine.
-
-#
-# +---------------------+ <-- 16-byte aligned ensured by processor
-# + Old SS +
-# +---------------------+
-# + Old RSP +
-# +---------------------+
-# + RFlags +
-# +---------------------+
-# + CS +
-# +---------------------+
-# + RIP +
-# +---------------------+
-# + Error Code +
-# +---------------------+
-# + RCX / Vector Number +
-# +---------------------+
-# + RBP +
-# +---------------------+ <-- RBP, 16-byte aligned
-#
-
-# We need to determine if any extra data was pushed by the exception
- cmpq $DEBUG_EXCEPT_DOUBLE_FAULT, %rcx
- je NoExtrPush
- cmpq $DEBUG_EXCEPT_INVALID_TSS, %rcx
- je NoExtrPush
- cmpq $DEBUG_EXCEPT_SEG_NOT_PRESENT, %rcx
- je NoExtrPush
- cmpq $DEBUG_EXCEPT_STACK_FAULT, %rcx
- je NoExtrPush
- cmpq $DEBUG_EXCEPT_GP_FAULT, %rcx
- je NoExtrPush
- cmpq $DEBUG_EXCEPT_PAGE_FAULT, %rcx
- je NoExtrPush
- cmpq $DEBUG_EXCEPT_ALIGNMENT_CHECK, %rcx
- je NoExtrPush
-
- pushq (%rsp)
- movq $0, 8(%rsp)
-
-NoExtrPush:
- #
- # All interrupt handlers are invoked through interrupt gates, so
- # IF flag automatically cleared at the entry point
- pushq %rbp
- movq %rsp, %rbp
-
- #
- # Since here the stack pointer is 16-byte aligned, so
- # EFI_FX_SAVE_STATE_X64 of EFI_SYSTEM_CONTEXT_x64
- # is 16-byte aligned
- #
-
-## UINT64 R8, R9, R10, R11, R12, R13, R14, R15;
- pushq %r15
- pushq %r14
- pushq %r13
- pushq %r12
- pushq %r11
- pushq %r10
- pushq %r9
- pushq %r8
-
- movq %cr8, %r8
- pushq %r8
-
-## UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax;
- pushq %rax
- pushq %rbx
- pushq 8(%rbp) # original rcx
- pushq %rdx
- pushq 48(%rbp) # original rsp
- pushq (%rbp) # original rbp
- pushq %rsi
- pushq %rdi
-
-## UINT64 Cr0, Cr1, Cr2, Cr3, Cr4;
- movq %cr4, %rax
- orq $0x208, %rax
- movq %rax, %cr4
- pushq %rax
- movq %cr3, %rax
- pushq %rax
- movq %cr2, %rax
- pushq %rax
- xorq %rax, %rax
- pushq %rax
- movq %cr0, %rax
- pushq %rax
-
-## UINT64 Gs, Fs, Es, Ds, Cs, Ss; insure high 16 bits of each is zero
- xorq %rax, %rax # set rax to 0
- movzwq 56(%rbp), %rax
-# movq %ss, %rax
- pushq %rax
- movzwq 32(%rbp), %rax
-# movq %cs, %rax
- pushq %rax
- movq %ds, %rax
- pushq %rax
- movq %es, %rax
- pushq %rax
- movq %fs, %rax
- pushq %rax
- movq %gs, %rax
- pushq %rax
-
-## UINT64 Rip;
- pushq 24(%rbp)
-
-## UINT64 Gdtr[2], Idtr[2];
- subq $16, %rsp
- sidt (%rsp)
- subq $16, %rsp
- sgdt (%rsp)
-
-## UINT64 Ldtr, Tr;
- xorq %rax, %rax
- strw %ax
- pushq %rax
- sldtw %ax
- pushq %rax
-
-## UINT64 RFlags;
- pushq 40(%rbp)
-
-## UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
- movq %dr7, %rax
- pushq %rax
-## clear Dr7 while executing debugger itself
- xorq %rax, %rax
-#debug movq %rax, %dr7
-
- movq %dr6, %rax
- pushq %rax
-## insure all status bits in dr6 are clear...
- xorq %rax, %rax
- movq %rax, %dr6
-
- movq %dr3, %rax
- pushq %rax
- movq %dr2, %rax
- pushq %rax
- movq %dr1, %rax
- pushq %rax
- movq %dr0, %rax
- pushq %rax
-
-## FX_SAVE_STATE_X64 FxSaveState;
- subq $512, %rsp
- movq %rsp, %rdi
- .byte 0x0f, 0xae, 0b00000111
-
-## save the exception data;
- pushq 16(%rbp)
-
-## Clear Direction Flag
- cld
-
-## Prepare parameter and call
-# movq 8(%rbp), %rcx
- movq %rsp, %rdx
- movq %rcx, %r15 # save vector in r15
- #
- # Per X64 calling convention, allocate maximum parameter stack space
- # and make sure RSP is 16-byte aligned
- #
- subq $(32 + 8), %rsp
- call ASM_PFX(InterruptProcess)
- addq $(32 + 8), %rsp
-
-## skip the exception data;
- addq $8, %rsp
-
-## FX_SAVE_STATE_X64 FxSaveState;
-
- movq %rsp, %rsi
- .byte 0x0f, 0xae, 0b00001110
- addq $512, %rsp
-
-## UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
- popq %rax
- movq %rax, %dr0
- popq %rax
- movq %rax, %dr1
- popq %rax
- movq %rax, %dr2
- popq %rax
- movq %rax, %dr3
-## skip restore of dr6. We cleared dr6 during the context save.
- addq $8, %rsp
- popq %rax
- movq %rax, %dr7
-
-## UINT64 RFlags;
- popq 40(%rbp)
-
-## UINT64 Ldtr, Tr;
-## UINT64 Gdtr[2], Idtr[2];
-## Best not let anyone mess with these particular registers...
- addq $48, %rsp
-
-## UINT64 Rip;
- popq 24(%rbp)
-
-## UINT64 Gs, Fs, Es, Ds, Cs, Ss;
- popq %rax
- # mov gs, rax ; not for gs
- popq %rax
- # mov fs, rax ; not for fs
- # (X64 will not use fs and gs, so we do not restore it)
- popq %rax
- movw %rax, %es
- popq %rax
- movw %rax, %ds
- popq 32(%rbp)
- popq 56(%rbp)
-
-## UINT64 Cr0, Cr1, Cr2, Cr3, Cr4, Cr8;
- popq %rax
- movq %rax, %cr0
- addq $8, %rsp
- popq %rax
- movq %rax, %cr2
- popq %rax
- movq %rax, %cr3
- popq %rax
- movq %rax, %cr4
-
-## UINT64 Rdi, Rsi, Rbp, Rsp, Rbx, Rdx, Rcx, Rax;
-## UINT64 R8, R9, R10, R11, R12, R13, R14, R15;
- popq %rdi
- popq %rsi
- addq $8, %rsp
- addq $8, %rsp
- popq %rdx
- popq %rcx
- popq %rbx
- popq %rax
-
- popq %r8
- movq %r8, %cr8
-
- popq %r8
- popq %r9
- popq %r10
- popq %r11
- popq %r12
- popq %r13
- popq %r14
- popq %r15
-
- movq %rbp, %rsp
- popq %rbp
- addq $16, %rsp
- iretq
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/AsmFuncs.asm b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/AsmFuncs.asm
deleted file mode 100644
index 16d73a4..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/AsmFuncs.asm
+++ /dev/null
@@ -1,374 +0,0 @@
-;------------------------------------------------------------------------------
-;
-; 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
-; http://opensource.org/licenses/bsd-license.php.
-;
-; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-;
-; Module Name:
-;
-; AsmFuncs.asm
-;
-; Abstract:
-;
-; Debug interrupt handle functions.
-;
-;------------------------------------------------------------------------------
-
-#include "DebugException.h"
-
-
-externdef InterruptProcess:near
-
-data SEGMENT
-
-public Exception0Handle, TimerInterruptHandle, ExceptionStubHeaderSize
-
-ExceptionStubHeaderSize dw Exception1Handle - Exception0Handle ;
-CommonEntryAddr dq CommonEntry ;
-
-.code
-
-Exception0Handle:
- cli
- push rcx
- mov rcx, 0
- jmp qword ptr [CommonEntryAddr]
-Exception1Handle:
- cli
- push rcx
- mov rcx, 1
- jmp qword ptr [CommonEntryAddr]
-Exception2Handle:
- cli
- push rcx
- mov rcx, 2
- jmp qword ptr [CommonEntryAddr]
-Exception3Handle:
- cli
- push rcx
- mov rcx, 3
- jmp qword ptr [CommonEntryAddr]
-Exception4Handle:
- cli
- push rcx
- mov rcx, 4
- jmp qword ptr [CommonEntryAddr]
-Exception5Handle:
- cli
- push rcx
- mov rcx, 5
- jmp qword ptr [CommonEntryAddr]
-Exception6Handle:
- cli
- push rcx
- mov rcx, 6
- jmp qword ptr [CommonEntryAddr]
-Exception7Handle:
- cli
- push rcx
- mov rcx, 7
- jmp qword ptr [CommonEntryAddr]
-Exception8Handle:
- cli
- push rcx
- mov rcx, 8
- jmp qword ptr [CommonEntryAddr]
-Exception9Handle:
- cli
- push rcx
- mov rcx, 9
- jmp qword ptr [CommonEntryAddr]
-Exception10Handle:
- cli
- push rcx
- mov rcx, 10
- jmp qword ptr [CommonEntryAddr]
-Exception11Handle:
- cli
- push rcx
- mov rcx, 11
- jmp qword ptr [CommonEntryAddr]
-Exception12Handle:
- cli
- push rcx
- mov rcx, 12
- jmp qword ptr [CommonEntryAddr]
-Exception13Handle:
- cli
- push rcx
- mov rcx, 13
- jmp qword ptr [CommonEntryAddr]
-Exception14Handle:
- cli
- push rcx
- mov rcx, 14
- jmp qword ptr [CommonEntryAddr]
-Exception15Handle:
- cli
- push rcx
- mov rcx, 15
- jmp qword ptr [CommonEntryAddr]
-Exception16Handle:
- cli
- push rcx
- mov rcx, 16
- jmp qword ptr [CommonEntryAddr]
-Exception17Handle:
- cli
- push rcx
- mov rcx, 17
- jmp qword ptr [CommonEntryAddr]
-Exception18Handle:
- cli
- push rcx
- mov rcx, 18
- jmp qword ptr [CommonEntryAddr]
-Exception19Handle:
- cli
- push rcx
- mov rcx, 19
- jmp qword ptr [CommonEntryAddr]
-
-TimerInterruptHandle:
- cli
- push rcx
- mov rcx, 32
- jmp qword ptr [CommonEntryAddr]
-
-CommonEntry:
- ; We need to determine if any extra data was pushed by the exception
- cmp rcx, DEBUG_EXCEPT_DOUBLE_FAULT
- je NoExtrPush
- cmp rcx, DEBUG_EXCEPT_INVALID_TSS
- je NoExtrPush
- cmp rcx, DEBUG_EXCEPT_SEG_NOT_PRESENT
- je NoExtrPush
- cmp rcx, DEBUG_EXCEPT_STACK_FAULT
- je NoExtrPush
- cmp rcx, DEBUG_EXCEPT_GP_FAULT
- je NoExtrPush
- cmp rcx, DEBUG_EXCEPT_PAGE_FAULT
- je NoExtrPush
- cmp rcx, DEBUG_EXCEPT_ALIGNMENT_CHECK
- je NoExtrPush
-
- push [rsp]
- mov qword ptr [rsp + 8], 0
-
-NoExtrPush:
- push rbp
- mov rbp, rsp
-
- ; store UINT64 r8, r9, r10, r11, r12, r13, r14, r15;
- push r15
- push r14
- push r13
- push r12
- push r11
- push r10
- push r9
- push r8
-
- mov r8, cr8
- push r8
-
- ; store UINT64 Rdi, Rsi, Rbp, Rsp, Rdx, Rcx, Rbx, Rax;
- push rax
- push rbx
- push qword ptr [rbp + 8] ; original rcx
- push rdx
- push qword ptr [rbp + 6 * 8] ; original rsp
- push qword ptr [rbp] ; original rbp
- push rsi
- push rdi
-
- ;; UINT32 Cr0, Cr1, Cr2, Cr3, Cr4;
- ;; insure FXSAVE/FXRSTOR is enabled in CR4...
- ;; ... while we're at it, make sure DE is also enabled...
- mov rax, cr4
- or rax, 208h
- mov cr4, rax
- push rax
- mov rax, cr3
- push rax
- mov rax, cr2
- push rax
- push 0 ; cr0 will not saved???
- mov rax, cr0
- push rax
-
- xor rax, rax
- mov rax, Ss
- push rax
- mov rax, Cs
- push rax
- mov rax, Ds
- push rax
- mov rax, Es
- push rax
- mov rax, Fs
- push rax
- mov rax, Gs
- push rax
-
- ;; EIP
- mov rax, [rbp + 8 * 3] ; EIP
- push rax
-
- ;; UINT64 Gdtr[2], Idtr[2];
- sub rsp, 16
- sidt fword ptr [rsp]
- sub rsp, 16
- sgdt fword ptr [rsp]
-
- ;; UINT64 Ldtr, Tr;
- xor rax, rax
- str ax
- push rax
- sldt ax
- push rax
-
- ;; EFlags
- mov rax, [rbp + 8 * 5]
- push rax
-
- ;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
- mov rax, dr7
- push rax
-
- ;; clear Dr7 while executing debugger itself
- xor rax, rax
- mov dr7, rax
-
- ;; Dr6
- mov rax, dr6
- push rax
-
- ;; insure all status bits in dr6 are clear...
- xor rax, rax
- mov dr6, rax
-
- mov rax, dr3
- push rax
- mov rax, dr2
- push rax
- mov rax, dr1
- push rax
- mov rax, dr0
- push rax
-
- sub rsp, 512
- mov rdi, rsp
- db 0fh, 0aeh, 00000111y ;fxsave [rdi]
-
- ;; save the exception data
- push qword ptr [rbp + 16]
-
- ;; Clear Direction Flag
- cld
-
- ; call the C interrupt process function
- mov rdx, rsp ; Structure
- mov r15, rcx ; save vector in r15
-
- ;
- ; Per X64 calling convention, allocate maximum parameter stack space
- ; and make sure RSP is 16-byte aligned
- ;
- sub rsp, 32 + 8
- call InterruptProcess
- add rsp, 32 + 8
-
- ;; skip the exception data
- add rsp, 8
-
- mov rsi, rsp
- db 0fh, 0aeh, 00001110y ; fxrstor [rsi]
- add rsp, 512
-
- ;; UINT64 Dr0, Dr1, Dr2, Dr3, Dr6, Dr7;
- pop rax
- mov dr0, rax
- pop rax
- mov dr1, rax
- pop rax
- mov dr2, rax
- pop rax
- mov dr3, rax
- ;; skip restore of dr6. We cleared dr6 during the context save.
- add rsp, 8
- pop rax
- mov dr7, rax
-
- ;; set EFlags
- pop qword ptr [rbp + 8 * 5]
-
- ;; UINT64 Ldtr, Tr;
- ;; UINT64 Gdtr[2], Idtr[2];
- ;; Best not let anyone mess with these particular registers...
- add rsp, 24 * 2
-
- ;; UINT64 Eip;
- pop qword ptr [rbp + 8 * 3] ; set EIP in stack
-
- ;; UINT64 Gs, Fs, Es, Ds, Cs, Ss;
- ;; NOTE - modified segment registers could hang the debugger... We
- ;; could attempt to insulate ourselves against this possibility,
- ;; but that poses risks as well.
- ;;
- pop rax
- pop rax
- pop rax
- mov es, rax
- pop rax
- mov ds, rax
- pop qword ptr [rbp + 8 * 4] ; Set CS in stack
- pop rax
- mov ss, rax
-
- ;; UINT64 Cr0, Cr1, Cr2, Cr3, Cr4;
- pop rax
- mov cr0, rax
- add rsp, 8 ; skip for Cr1
- pop rax
- mov cr2, rax
- pop rax
- mov cr3, rax
- pop rax
- mov cr4, rax
-
- ;; restore general register
- pop rdi
- pop rsi
- add rsp, 8 ; skip rbp
- add rsp, 8 ; skip rsp
- pop rdx
- pop rcx
- pop rbx
- pop rax
-
- pop r8
- mov cr8, r8
-
- ; store UINT64 r8, r9, r10, r11, r12, r13, r14, r15;
- pop r8
- pop r9
- pop r10
- pop r11
- pop r12
- pop r13
- pop r14
- pop r15
-
- mov rsp, rbp
- pop rbp
- add rsp, 16 ; skip rcx and error code
-
- iretq
-
-END
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/DebugException.h b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/DebugException.h
deleted file mode 100644
index 13a7d23..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/DebugException.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/** @file
- Exception defintions.
-
- Copyright (c) 2010, 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _DEBUG_EXCEPTION_H_
-#define _DEBUG_EXCEPTION_H_
-
-#define DEBUG_EXCEPT_DIVIDE_ERROR 0
-#define DEBUG_EXCEPT_DEBUG 1
-#define DEBUG_EXCEPT_NMI 2
-#define DEBUG_EXCEPT_BREAKPOINT 3
-#define DEBUG_EXCEPT_OVERFLOW 4
-#define DEBUG_EXCEPT_BOUND 5
-#define DEBUG_EXCEPT_INVALID_OPCODE 6
-#define DEBUG_EXCEPT_DOUBLE_FAULT 8
-#define DEBUG_EXCEPT_INVALID_TSS 10
-#define DEBUG_EXCEPT_SEG_NOT_PRESENT 11
-#define DEBUG_EXCEPT_STACK_FAULT 12
-#define DEBUG_EXCEPT_GP_FAULT 13
-#define DEBUG_EXCEPT_PAGE_FAULT 14
-#define DEBUG_EXCEPT_FP_ERROR 16
-#define DEBUG_EXCEPT_ALIGNMENT_CHECK 17
-#define DEBUG_EXCEPT_MACHINE_CHECK 18
-#define DEBUG_EXCEPT_SIMD 19
-
-#endif
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.c
deleted file mode 100644
index f8e3f6c..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.c
+++ /dev/null
@@ -1,271 +0,0 @@
-/** @file
- Debug Agent library implementition for Dxe Core and Dxr modules.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "DxeDebugAgentLib.h"
-
-DEBUG_AGENT_MAILBOX mMailbox;
-DEBUG_AGENT_MAILBOX *mMailboxPointer;
-IA32_IDT_GATE_DESCRIPTOR mIdtEntryTable[33];
-BOOLEAN mDxeCoreFlag = FALSE;
-CONST BOOLEAN MultiProcessorDebugSupport = TRUE;
-
-/**
- Constructor allocates the NVS memory to store Mailbox and install configuration table
- in system table to store its pointer.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval RETURN_SUCCESS Allocate the global memory space to store guid and function tables.
-
-**/
-RETURN_STATUS
-EFIAPI
-DxeDebugAgentLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS Address;
- EFI_EVENT Event;
- VOID *EventRegistration;
-
- if (!mDxeCoreFlag) {
- return RETURN_SUCCESS;
- }
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- InstallSerialIoNotification,
- NULL,
- &Event
- );
- ASSERT_EFI_ERROR (Status);
-
- //
- // Register for protocol notifications on this event
- //
-
- Status = gBS->RegisterProtocolNotify (
- &gEfiPcdProtocolGuid,
- Event,
- &EventRegistration
- );
-
- ASSERT_EFI_ERROR (Status);
-
- Address = 0;
- Status = gBS->AllocatePages (
- AllocateAnyPages,
- EfiACPIMemoryNVS,
- EFI_SIZE_TO_PAGES (sizeof (DEBUG_AGENT_MAILBOX)),
- &Address
- );
- ASSERT_EFI_ERROR (Status);
-
- CopyMem (
- (UINT8 *) (UINTN) Address,
- (UINT8 *) (UINTN) mMailboxPointer,
- sizeof (DEBUG_AGENT_MAILBOX)
- );
-
- mMailboxPointer = (DEBUG_AGENT_MAILBOX *) (UINTN) Address;
-
- Status = gBS->InstallConfigurationTable (&gEfiDebugAgentGuid, (VOID *) mMailboxPointer);
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
-
-/**
- Get the pointer to Mailbox from the GUIDed HOB.
-
- @param[in] HobStart The starting HOB pointer to search from.
-
- @return Pointer to Mailbox.
-
-**/
-DEBUG_AGENT_MAILBOX *
-GetMailboxFromHob (
- IN VOID *HobStart
- )
-{
- EFI_HOB_GUID_TYPE *GuidHob;
-
- GuidHob = GetNextGuidHob (&gEfiDebugAgentGuid, HobStart);
- if (GuidHob == NULL) {
- return NULL;
- }
-
- return (DEBUG_AGENT_MAILBOX *) (GET_GUID_HOB_DATA(GuidHob));
-}
-
-/**
- Get Debug Agent Mailbox pointer.
-
- @return Mailbox pointer.
-
-**/
-DEBUG_AGENT_MAILBOX *
-GetMailboxPointer (
- VOID
- )
-{
- return mMailboxPointer;
-}
-
-/**
- Get debug port handle.
-
- @return Debug port handle.
-
-**/
-DEBUG_PORT_HANDLE
-GetDebugPortHandle (
- VOID
- )
-{
- return (DEBUG_PORT_HANDLE) (UINTN)(mMailboxPointer->DebugPortHandle);
-}
-
-
-/**
- Initialize debug agent.
-
- This function is used to set up debug enviroment for DXE phase.
-
- If this function is called by DXE Core, Context must be the pointer
- to HOB list which will be used to get GUIDed HOB. It will enable
- interrupt to support break-in feature.
- If this function is called by DXE module, Context must be NULL. It
- will enable interrupt to support break-in feature.
-
- @param[in] InitFlag Init flag is used to decide initialize process.
- @param[in] Context Context needed according to InitFlag.
- @param[in] Function Continue function called by debug agent library; it was
- optional.
-
-**/
-VOID
-EFIAPI
-InitializeDebugAgent (
- IN UINT32 InitFlag,
- IN VOID *Context, OPTIONAL
- IN DEBUG_AGENT_CONTINUE Function OPTIONAL
- )
-{
- DEBUG_AGENT_MAILBOX *Mailbox;
- IA32_DESCRIPTOR Idtr;
- UINT16 IdtEntryCount;
- BOOLEAN InterruptStatus;
-
- if (InitFlag != DEBUG_AGENT_INIT_DXE_CORE &&
- InitFlag != DEBUG_AGENT_INIT_S3 &&
- InitFlag != DEBUG_AGENT_INIT_DXE_AP) {
- return;
- }
-
- //
- // Save and disable original interrupt status
- //
- InterruptStatus = SaveAndDisableInterrupts ();
-
- if (InitFlag == DEBUG_AGENT_INIT_DXE_CORE) {
- //
- // Try to get Mailbox from GUIDed HOB.
- //
- mDxeCoreFlag = TRUE;
- Mailbox = GetMailboxFromHob (Context);
-
- //
- // Clear Break CPU index value
- //
- mDebugMpContext.BreakAtCpuIndex = (UINT32) -1;
-
- } else if (InitFlag == DEBUG_AGENT_INIT_DXE_AP) {
-
- EnableInterrupts ();
-
- return;
-
- } else {
- //
- // If it is in S3 path, needn't to install configuration table.
- //
- Mailbox = NULL;
- }
-
- if (Mailbox != NULL) {
- //
- // If Mailbox exists, copy it into one global variable.
- //
- CopyMem (&mMailbox, Mailbox, sizeof (DEBUG_AGENT_MAILBOX));
- } else {
- //
- // If Mailbox not exists, used the local Mailbox.
- //
- ZeroMem (&mMailbox, sizeof (DEBUG_AGENT_MAILBOX));
- }
-
- mMailboxPointer = &mMailbox;
-
- //
- // Get original IDT address and size.
- //
- AsmReadIdtr ((IA32_DESCRIPTOR *) &Idtr);
- IdtEntryCount = (UINT16) ((Idtr.Limit + 1) / sizeof (IA32_IDT_GATE_DESCRIPTOR));
- if (IdtEntryCount < 33) {
- Idtr.Limit = (UINT16) (sizeof (IA32_IDT_GATE_DESCRIPTOR) * 33 - 1);
- Idtr.Base = (UINTN) &mIdtEntryTable;
- ZeroMem (&mIdtEntryTable, Idtr.Limit + 1);
- AsmWriteIdtr ((IA32_DESCRIPTOR *) &Idtr);
- }
-
- //
- // Initialize the IDT table entries to support source level debug.
- //
- InitializeDebugIdt ();
-
- //
- // Initialize debug communication port
- //
- mMailboxPointer->DebugPortHandle = (UINT64) (UINTN)DebugPortInitialize ((VOID *)(UINTN)mMailbox.DebugPortHandle, NULL);
-
- InitializeSpinLock (&mDebugMpContext.MpContextSpinLock);
- InitializeSpinLock (&mDebugMpContext.DebugPortSpinLock);
-
- if (InitFlag == DEBUG_AGENT_INIT_DXE_CORE) {
- //
- // Initialize Debug Timer hardware and enable interrupt.
- //
- InitializeDebugTimer ();
- EnableInterrupts ();
-
- return;
- } else {
- //
- // Disable Debug Timer interrupt in S3 path.
- //
- SaveAndSetDebugTimerInterrupt (FALSE);
-
- //
- // Restore interrupt state.
- //
- SetInterruptState (InterruptStatus);
- }
-
-}
-
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.h b/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.h
deleted file mode 100644
index ab56181..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/** @file
- Header file for Dxe Core Debug Agent Library instance.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _DXE_CORE_DEBUG_AGENT_LIB_H_
-#define _DXE_CORE_DEBUG_AGENT_LIB_H_
-
-#include <PiDxe.h>
-
-#include <Protocol/SerialIo.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/PiPcd.h>
-
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <Library/DevicePathLib.h>
-
-#include "DebugAgent.h"
-
-/**
- Notification function on EFI PCD protocol to install EFI Serial IO protocol based
- on Debug Communication Library.
-
- @param[in] Event The event of notify protocol.
- @param[in] Context Notify event context.
-
-**/
-VOID
-EFIAPI
-InstallSerialIoNotification (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-#endif
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/SerialIo.c b/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/SerialIo.c
deleted file mode 100644
index 726eec6..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/SerialIo.c
+++ /dev/null
@@ -1,722 +0,0 @@
-/** @file
- Install Serial IO Protocol that layers on top of a Debug Communication Library instance.
-
- Copyright (c) 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "DxeDebugAgentLib.h"
-
-//
-// Serial I/O Protocol Interface defintions.
-//
-
-/**
- Reset serial device.
-
- @param[in] This Pointer to EFI_SERIAL_IO_PROTOCOL.
-
- @retval EFI_SUCCESS Reset successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-SerialReset (
- IN EFI_SERIAL_IO_PROTOCOL *This
- );
-
-/**
- Set new attributes to a serial device.
-
- @param[in] This Pointer to EFI_SERIAL_IO_PROTOCOL.
- @param[in] BaudRate The baudrate of the serial device.
- @param[in] ReceiveFifoDepth The depth of receive FIFO buffer.
- @param[in] Timeout The request timeout for a single char.
- @param[in] Parity The type of parity used in serial device.
- @param[in] DataBits Number of databits used in serial device.
- @param[in] StopBits Number of stopbits used in serial device.
-
- @retval EFI_SUCCESS The new attributes were set.
- @retval EFI_INVALID_PARAMETER One or more attributes have an unsupported value.
- @retval EFI_DEVICE_ERROR The serial device is not functioning correctly (no return).
-
-**/
-EFI_STATUS
-EFIAPI
-SerialSetAttributes (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN UINT32 Timeout,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
- );
-
-/**
- Set Control Bits.
-
- @param[in] This Pointer to EFI_SERIAL_IO_PROTOCOL.
- @param[in] Control Control bits that can be settable.
-
- @retval EFI_SUCCESS New Control bits were set successfully.
- @retval EFI_UNSUPPORTED The Control bits wanted to set are not supported.
-
-**/
-EFI_STATUS
-EFIAPI
-SerialSetControl (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN UINT32 Control
- );
-
-/**
- Get ControlBits.
-
- @param[in] This Pointer to EFI_SERIAL_IO_PROTOCOL.
- @param[out] Control Control signals of the serial device.
-
- @retval EFI_SUCCESS Get Control signals successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-SerialGetControl (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- OUT UINT32 *Control
- );
-
-/**
- Write the specified number of bytes to serial device.
-
- @param[in] This Pointer to EFI_SERIAL_IO_PROTOCOL.
- @param[in, out] BufferSize On input the size of Buffer, on output the amount of
- data actually written.
- @param[in] Buffer The buffer of data to write.
-
- @retval EFI_SUCCESS The data were written successfully.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_TIMEOUT The write operation was stopped due to timeout.
-
-**/
-EFI_STATUS
-EFIAPI
-SerialWrite (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
- );
-
-/**
- Read the specified number of bytes from serial device.
-
- @param[in] This Pointer to EFI_SERIAL_IO_PROTOCOL.
- @param[in, out] BufferSize On input the size of Buffer, on output the amount of
- data returned in buffer.
- @param[out] Buffer The buffer to return the data into.
-
- @retval EFI_SUCCESS The data were read successfully.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_TIMEOUT The read operation was stopped due to timeout.
-
-**/
-EFI_STATUS
-EFIAPI
-SerialRead (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
- );
-
-//
-// Serial Driver Defaults
-//
-#define SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH 1
-#define SERIAL_PORT_DEFAULT_TIMEOUT 1000000
-#define SERIAL_PORT_DEFAULT_CONTROL_MASK 0
-#define SERIAL_PORT_LOOPBACK_BUFFER_FULL BIT8
-
-//
-// EFI_SERIAL_IO_MODE instance
-//
-EFI_SERIAL_IO_MODE mSerialIoMode = {
- SERIAL_PORT_DEFAULT_CONTROL_MASK,
- SERIAL_PORT_DEFAULT_TIMEOUT,
- 0, // BaudRate
- SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH,
- 0, // DataBits
- 0, // Parity
- 0 // StopBits
-};
-
-//
-// EFI_SERIAL_IO_PROTOCOL instance
-//
-EFI_SERIAL_IO_PROTOCOL mSerialIo = {
- SERIAL_IO_INTERFACE_REVISION,
- SerialReset,
- SerialSetAttributes,
- SerialSetControl,
- SerialGetControl,
- SerialWrite,
- SerialRead,
- &mSerialIoMode
-};
-
-//
-// Serial IO Device Path definition
-//
-typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- UART_DEVICE_PATH UartDevicePath;
- EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
-} SERIAL_IO_DEVICE_PATH;
-
-//
-// Serial IO Device Patch instance
-//
-SERIAL_IO_DEVICE_PATH mSerialIoDevicePath = {
- {
- {
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- (UINT8) (sizeof (VENDOR_DEVICE_PATH)),
- (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
- },
- EFI_DEBUG_AGENT_GUID,
- },
- {
- {
- MESSAGING_DEVICE_PATH,
- MSG_UART_DP,
- (UINT8) (sizeof (UART_DEVICE_PATH)),
- (UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)
- },
- 0,
- 0, // BaudRate
- 0, // DataBits
- 0, // Parity
- 0, // StopBits
- },
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- {
- END_DEVICE_PATH_LENGTH,
- 0
- }
- }
-};
-
-#define DEBGU_SERIAL_IO_FIFO_DEPTH 10
-//
-// Data buffer for Terminal input character and Debug Symbols.
-// The depth is DEBGU_SERIAL_IO_FIFO_DEPTH.
-// Fields:
-// First UINT8: The index of the first data in array Data[].
-// Last UINT8: The index, which you can put a new data into array Data[].
-// Surplus UINT8: Identify how many data you can put into array Data[].
-// Data[] UINT8: An array, which used to store data.
-//
-typedef struct {
- UINT8 First;
- UINT8 Last;
- UINT8 Surplus;
- UINT8 Data[DEBGU_SERIAL_IO_FIFO_DEPTH];
-} DEBUG_SERIAL_FIFO;
-
-//
-// Global Varibles
-//
-EFI_HANDLE mSerialIoHandle = NULL;
-UINTN mLoopbackBuffer = 0;
-DEBUG_SERIAL_FIFO mSerialFifoForTerminal = {0, 0, DEBGU_SERIAL_IO_FIFO_DEPTH, { 0 }};
-DEBUG_SERIAL_FIFO mSerialFifoForDebug = {0, 0, DEBGU_SERIAL_IO_FIFO_DEPTH, { 0 }};
-
-/**
- Detect whether specific FIFO is empty or not.
-
- @param[in] Fifo A pointer to the Data Structure DEBUG_SERIAL_FIFO.
-
- @return whether specific FIFO is empty or not.
-
-**/
-BOOLEAN
-IsDebugTermianlFifoEmpty (
- IN DEBUG_SERIAL_FIFO *Fifo
- )
-{
- if (Fifo->Surplus == DEBGU_SERIAL_IO_FIFO_DEPTH) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- Detect whether specific FIFO is full or not.
-
- @param[in] Fifo A pointer to the Data Structure DEBUG_SERIAL_FIFO.
-
- @return whether specific FIFO is full or not.
-
-**/
-BOOLEAN
-IsDebugTerminalFifoFull (
- IN DEBUG_SERIAL_FIFO *Fifo
- )
-
-{
- if (Fifo->Surplus == 0) {
- return TRUE;
- }
-
- return FALSE;
-}
-
-/**
- Add data to specific FIFO.
-
- @param[in] Fifo A pointer to the Data Structure DEBUG_SERIAL_FIFO.
- @param[in] Data The data added to FIFO.
-
- @retval EFI_SUCCESS Add data to specific FIFO successfully.
- @retval EFI_OUT_OF_RESOURCE Failed to add data because FIFO is already full.
-
-**/
-EFI_STATUS
-DebugTerminalFifoAdd (
- IN DEBUG_SERIAL_FIFO *Fifo,
- IN UINT8 Data
- )
-
-{
- //
- // if FIFO full can not add data
- //
- if (IsDebugTerminalFifoFull (Fifo)) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // FIFO is not full can add data
- //
- Fifo->Data[Fifo->Last] = Data;
- Fifo->Surplus--;
- Fifo->Last++;
- if (Fifo->Last == DEBGU_SERIAL_IO_FIFO_DEPTH) {
- Fifo->Last = 0;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Remove data from specific FIFO.
-
- @param[in] Fifo A pointer to the Data Structure DEBUG_SERIAL_FIFO.
- @param[out] Data The data removed from FIFO.
-
- @retval EFI_SUCCESS Remove data from specific FIFO successfully.
- @retval EFI_OUT_OF_RESOURCE Failed to remove data because FIFO is empty.
-
-**/
-EFI_STATUS
-DebugTerminalFifoRemove (
- IN DEBUG_SERIAL_FIFO *Fifo,
- OUT UINT8 *Data
- )
-{
- //
- // if FIFO is empty, no data can remove
- //
- if (IsDebugTermianlFifoEmpty (Fifo)) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // FIFO is not empty, can remove data
- //
- *Data = Fifo->Data[Fifo->First];
- Fifo->Surplus++;
- Fifo->First++;
- if (Fifo->First == DEBGU_SERIAL_IO_FIFO_DEPTH) {
- Fifo->First = 0;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Notification function on EFI PCD protocol to install EFI Serial IO protocol based
- on Debug Communication Library.
-
- @param[in] Event The event of notify protocol.
- @param[in] Context Notify event context.
-
-**/
-VOID
-EFIAPI
-InstallSerialIoNotification (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
-
- //
- // Get Debug Port parameters from PCDs
- //
- mSerialIoDevicePath.UartDevicePath.BaudRate = PcdGet64 (PcdUartDefaultBaudRate);
- mSerialIoDevicePath.UartDevicePath.DataBits = PcdGet8 (PcdUartDefaultDataBits);
- mSerialIoDevicePath.UartDevicePath.Parity = PcdGet8 (PcdUartDefaultParity);
- mSerialIoDevicePath.UartDevicePath.StopBits = PcdGet8 (PcdUartDefaultStopBits);
-
- mSerialIoMode.BaudRate = mSerialIoDevicePath.UartDevicePath.BaudRate;
- mSerialIoMode.DataBits = mSerialIoDevicePath.UartDevicePath.DataBits;
- mSerialIoMode.Parity = mSerialIoDevicePath.UartDevicePath.Parity;
- mSerialIoMode.StopBits = mSerialIoDevicePath.UartDevicePath.StopBits;
-
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mSerialIoHandle,
- &gEfiDevicePathProtocolGuid, &mSerialIoDevicePath,
- &gEfiSerialIoProtocolGuid, &mSerialIo,
- NULL
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "Debug Agent: Failed to install EFI Serial IO Protocol on Debug Port!\n"));
- }
-}
-
-/**
- Reset serial device.
-
- @param[in] This Pointer to EFI_SERIAL_IO_PROTOCOL.
-
- @retval EFI_SUCCESS Reset successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-SerialReset (
- IN EFI_SERIAL_IO_PROTOCOL *This
- )
-{
- mSerialIoMode.ControlMask = SERIAL_PORT_DEFAULT_CONTROL_MASK;
- mLoopbackBuffer = 0;
- //
- // Not reset serial devcie hardware indeed.
- //
- return EFI_SUCCESS;
-}
-
-/**
- Set new attributes to a serial device.
-
- @param[in] This Pointer to EFI_SERIAL_IO_PROTOCOL.
- @param[in] BaudRate The baudrate of the serial device.
- @param[in] ReceiveFifoDepth The depth of receive FIFO buffer.
- @param[in] Timeout The request timeout for a single char.
- @param[in] Parity The type of parity used in serial device.
- @param[in] DataBits Number of databits used in serial device.
- @param[in] StopBits Number of stopbits used in serial device.
-
- @retval EFI_SUCCESS The new attributes were set.
- @retval EFI_INVALID_PARAMETER One or more attributes have an unsupported value.
- @retval EFI_DEVICE_ERROR The serial device is not functioning correctly (no return).
-
-**/
-EFI_STATUS
-EFIAPI
-SerialSetAttributes (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN UINT64 BaudRate,
- IN UINT32 ReceiveFifoDepth,
- IN UINT32 Timeout,
- IN EFI_PARITY_TYPE Parity,
- IN UINT8 DataBits,
- IN EFI_STOP_BITS_TYPE StopBits
- )
-{
- //
- // The Debug Communication Library does not support changing communications parameters, so unless
- // the request is to use the default value or the value the Debug Communication Library is already
- // using, then return EFI_INVALID_PARAMETER.
- //
- if (BaudRate != 0 && BaudRate != PcdGet64 (PcdUartDefaultBaudRate)) {
- return EFI_INVALID_PARAMETER;
- }
- if (Parity != DefaultParity && Parity != PcdGet8 (PcdUartDefaultParity)) {
- return EFI_INVALID_PARAMETER;
- }
- if (DataBits != 0 && DataBits != PcdGet8 (PcdUartDefaultDataBits)) {
- return EFI_INVALID_PARAMETER;
- }
- if (StopBits != DefaultStopBits && StopBits != PcdGet8 (PcdUartDefaultStopBits)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Update the Timeout value in the mode structure based on the request.
- // The Debug Communication Library can not support a timeout on writes, but the timeout on
- // reads can be provided by this module.
- //
- if (Timeout == 0) {
- mSerialIoMode.Timeout = SERIAL_PORT_DEFAULT_TIMEOUT;
- } else {
- mSerialIoMode.Timeout = Timeout;
- }
-
- //
- // Update the ReceiveFifoDepth value in the mode structure based on the request.
- // This module assumes that the Debug Communication Library uses a FIFO depth of
- // SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH. The Debug Communication Library may actually be
- // using a larger FIFO, but there is no way to tell.
- //
- if (ReceiveFifoDepth == 0 || ReceiveFifoDepth >= SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH) {
- mSerialIoMode.ReceiveFifoDepth = SERIAL_PORT_DEFAULT_RECEIVE_FIFO_DEPTH;
- } else {
- return EFI_INVALID_PARAMETER;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Set Control Bits.
-
- @param[in] This Pointer to EFI_SERIAL_IO_PROTOCOL.
- @param[in] Control Control bits that can be settable.
-
- @retval EFI_SUCCESS New Control bits were set successfully.
- @retval EFI_UNSUPPORTED The Control bits wanted to set are not supported.
-
-**/
-EFI_STATUS
-EFIAPI
-SerialSetControl (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN UINT32 Control
- )
-{
- //
- // The only control bit supported by this module is software loopback.
- // If any other bit is set, then return an error
- //
- if ((Control & (~EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE)) != 0) {
- return EFI_UNSUPPORTED;
- }
- mSerialIoMode.ControlMask = Control;
- return EFI_SUCCESS;
-}
-
-/**
- Get ControlBits.
-
- @param[in] This Pointer to EFI_SERIAL_IO_PROTOCOL.
- @param[out] Control Control signals of the serial device.
-
- @retval EFI_SUCCESS Get Control signals successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-SerialGetControl (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- OUT UINT32 *Control
- )
-{
- DEBUG_PORT_HANDLE Handle;
-
- Handle = GetDebugPortHandle ();
-
- //
- // Always assume the output buffer is empty and the Debug Communication Library can process
- // more write requests.
- //
- *Control = mSerialIoMode.ControlMask | EFI_SERIAL_OUTPUT_BUFFER_EMPTY;
-
- //
- // Check to see if the Terminal FIFO is empty and
- // check to see if the input buffer in the Debug Communication Library is empty
- //
- if (!IsDebugTermianlFifoEmpty (&mSerialFifoForTerminal) || DebugPortPollBuffer (Handle)) {
- *Control &= ~EFI_SERIAL_INPUT_BUFFER_EMPTY;
- }
- return EFI_SUCCESS;
-}
-
-/**
- Write the specified number of bytes to serial device.
-
- @param[in] This Pointer to EFI_SERIAL_IO_PROTOCOL.
- @param[in, out] BufferSize On input the size of Buffer, on output the amount of
- data actually written.
- @param[in] Buffer The buffer of data to write.
-
- @retval EFI_SUCCESS The data were written successfully.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_TIMEOUT The write operation was stopped due to timeout.
-
-**/
-EFI_STATUS
-EFIAPI
-SerialWrite (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- IN VOID *Buffer
- )
-{
- DEBUG_PORT_HANDLE Handle;
-
- Handle = GetDebugPortHandle ();
-
- if ((mSerialIoMode.ControlMask & EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE) != 0) {
- if (*BufferSize == 0) {
- return EFI_SUCCESS;
- }
- if ((mLoopbackBuffer & SERIAL_PORT_LOOPBACK_BUFFER_FULL) != 0) {
- *BufferSize = 0;
- return EFI_TIMEOUT;
- }
- mLoopbackBuffer = SERIAL_PORT_LOOPBACK_BUFFER_FULL | *(UINT8 *)Buffer;
- *BufferSize = 1;
- } else {
- *BufferSize = DebugPortWriteBuffer (Handle, Buffer, *BufferSize);
- }
- return EFI_SUCCESS;
-}
-
-/**
- Read the specified number of bytes from serial device.
-
- @param[in] This Pointer to EFI_SERIAL_IO_PROTOCOL.
- @param[in, out] BufferSize On input the size of Buffer, on output the amount of
- data returned in buffer.
- @param[out] Buffer The buffer to return the data into.
-
- @retval EFI_SUCCESS The data were read successfully.
- @retval EFI_DEVICE_ERROR The device reported an error.
- @retval EFI_TIMEOUT The read operation was stopped due to timeout.
-
-**/
-EFI_STATUS
-EFIAPI
-SerialRead (
- IN EFI_SERIAL_IO_PROTOCOL *This,
- IN OUT UINTN *BufferSize,
- OUT VOID *Buffer
- )
-{
- EFI_STATUS Status;
- UINTN Index;
- UINT8 *Uint8Buffer;
- BOOLEAN OldInterruptState;
- DEBUG_PORT_HANDLE Handle;
- UINT8 Data;
-
- Handle = GetDebugPortHandle ();
-
- //
- // Save and disable Debug Timer interrupt to avoid it to access Debug Port
- //
- OldInterruptState = SaveAndSetDebugTimerInterrupt (FALSE);
-
- Uint8Buffer = (UINT8 *)Buffer;
- if ((mSerialIoMode.ControlMask & EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE) != 0) {
- if ((mLoopbackBuffer & SERIAL_PORT_LOOPBACK_BUFFER_FULL) == 0) {
- return EFI_TIMEOUT;
- }
- *Uint8Buffer = (UINT8)(mLoopbackBuffer & 0xff);
- mLoopbackBuffer = 0;
- *BufferSize = 1;
- } else {
- for (Index = 0; Index < *BufferSize; Index++) {
- //
- // Read input character from terminal FIFO firstly
- //
- Status = DebugTerminalFifoRemove (&mSerialFifoForTerminal, &Data);
- if (Status == EFI_SUCCESS) {
- *Uint8Buffer = Data;
- Uint8Buffer ++;
- continue;
- }
- //
- // Read the input character from Debug Port
- //
- if (!DebugPortPollBuffer (Handle)) {
- break;
- }
- DebugPortReadBuffer (Handle, &Data, 1, 0);
-
- if (Data== DEBUG_STARTING_SYMBOL_ATTACH ||
- Data == DEBUG_STARTING_SYMBOL_BREAK) {
- //
- // Add the debug symbol into Debug FIFO
- //
- DebugTerminalFifoAdd (&mSerialFifoForDebug, Data);
- } else {
- *Uint8Buffer = Data;
- Uint8Buffer ++;
- }
- }
- *BufferSize = (UINTN)Uint8Buffer - (UINTN)Buffer;
- }
-
- //
- // Restore Debug Timer interrupt
- //
- SaveAndSetDebugTimerInterrupt (OldInterruptState);
-
- return EFI_SUCCESS;
-}
-
-/**
- Read the Attach/Break-in symbols from the debug port.
-
- @param[in] Handle Pointer to Debug Port handle.
- @param[out] BreakSymbol Returned break symbol.
-
- @retval EFI_SUCCESS Read the symbol in BreakSymbol.
- @retval EFI_NOT_FOUND No read the break symbol.
-
-**/
-EFI_STATUS
-DebugReadBreakSymbol (
- IN DEBUG_PORT_HANDLE Handle,
- OUT UINT8 *BreakSymbol
- )
-{
- EFI_STATUS Status;
- UINT8 Data;
-
- Status = DebugTerminalFifoRemove (&mSerialFifoForDebug, &Data);
- if (Status != EFI_SUCCESS) {
- if (!DebugPortPollBuffer (Handle)) {
- //
- // No data in Debug Port buffer.
- //
- return EFI_NOT_FOUND;
- } else {
- //
- // Read one character from Debug Port.
- //
- DebugPortReadBuffer (Handle, &Data, 1, 0);
- if ((Data != DEBUG_STARTING_SYMBOL_ATTACH) && (Data != DEBUG_STARTING_SYMBOL_BREAK)) {
- //
- // If the data is not Break symbol, add it into Terminal FIFO
- //
- DebugTerminalFifoAdd (&mSerialFifoForTerminal, Data);
- return EFI_NOT_FOUND;
- }
- }
- }
-
- *BreakSymbol = Data;
- return EFI_SUCCESS;
-}
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf b/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
deleted file mode 100644
index 434d21a..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
+++ /dev/null
@@ -1,95 +0,0 @@
-## @file
-# Debug Agent library instance for Dxe Core and Dxe modules.
-#
-# 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
-# http://opensource.org/licenses/bsd-license.php.
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = DxeDebugAgentLib
- FILE_GUID = BA6BAD25-B814-4747-B0B0-0FBB61D40B90
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 0.7
- LIBRARY_CLASS = DebugAgentLib|DXE_CORE DXE_DRIVER
-
- CONSTRUCTOR = DxeDebugAgentLibConstructor
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64
-#
-
-[Sources.common]
- DxeDebugAgent/DxeDebugAgentLib.c
- DxeDebugAgent/DxeDebugAgentLib.h
- DxeDebugAgent/SerialIo.c
- DebugAgentCommon/DebugAgent.c
- DebugAgentCommon/DebugAgent.h
- DebugAgentCommon/DebugTimer.c
- DebugAgentCommon/DebugTimer.h
- DebugAgentCommon/DebugMp.c
- DebugAgentCommon/DebugMp.h
-
-[Sources.Ia32]
- DebugAgentCommon/Ia32/AsmFuncs.S | GCC
- DebugAgentCommon/Ia32/AsmFuncs.asm | MSFT
- DebugAgentCommon/Ia32/ArchDebugSupport.h
- DebugAgentCommon/Ia32/ArchDebugSupport.c
- DebugAgentCommon/Ia32/DebugException.h
-
-[Sources.X64]
- DebugAgentCommon/X64/AsmFuncs.S | GCC
- DebugAgentCommon/X64/AsmFuncs.asm | MSFT
- DebugAgentCommon/X64/ArchDebugSupport.h
- DebugAgentCommon/X64/ArchDebugSupport.c
- DebugAgentCommon/X64/DebugException.h
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- UefiCpuPkg/UefiCpuPkg.dec
- SourceLevelDebugPkg/SourceLevelDebugPkg.dec
-
-[LibraryClasses]
- BaseLib
- BaseMemoryLib
- ResetSystemLib
- IoLib
- HobLib
- DebugCommunicationLib
- UefiBootServicesTableLib
- UefiLib
- PcdLib
- SynchronizationLib
- MemoryAllocationLib
- LocalApicLib
- TimerLib
- PrintLib
-
-[Guids]
- gEfiDebugAgentGuid ## PRODUCES ## Configuration Table
- gEfiDebugAgentGuid ## CONSUMES ## HOB
-
-[Protocols]
- gEfiSerialIoProtocolGuid ## PRODUCES
- gEfiDevicePathProtocolGuid ## PRODUCES
- gEfiPcdProtocolGuid ## NOTIFY
-
-[Pcd]
- gEfiMdePkgTokenSpaceGuid.PcdFSBClock ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity ## CONSUMES
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits ## CONSUMES
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdExceptionsIgnoredByDebugger ## CONSUMES
-
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
deleted file mode 100644
index ea702e6..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
+++ /dev/null
@@ -1,354 +0,0 @@
-/** @file
- SEC Core Debug Agent Library instance implementition.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "SecPeiDebugAgentLib.h"
-
-CONST BOOLEAN MultiProcessorDebugSupport = FALSE;
-
-/**
- Read the Attach/Break-in symbols from the debug port.
-
- @param[in] Handle Pointer to Debug Port handle.
- @param[out] BreakSymbol Returned break symbol.
-
- @retval EFI_SUCCESS Read the symbol in BreakSymbol.
- @retval EFI_NOT_FOUND No read the break symbol.
-
-**/
-EFI_STATUS
-DebugReadBreakSymbol (
- IN DEBUG_PORT_HANDLE Handle,
- OUT UINT8 *BreakSymbol
- )
-{
- *BreakSymbol = 0;
- //
- // If Debug Port buffer has data, read it till it was break symbol or Debug Port buffer emty.
- //
- while (DebugPortPollBuffer (Handle)) {
- DebugPortReadBuffer (Handle, BreakSymbol, 1, 0);
- if (*BreakSymbol == DEBUG_STARTING_SYMBOL_ATTACH || *BreakSymbol == DEBUG_STARTING_SYMBOL_BREAK) {
- return EFI_SUCCESS;
- }
- }
-
- return EFI_NOT_FOUND;
-}
-
-/**
- Get pointer to Mailbox from IDT entry before memory is ready.
-
-**/
-VOID *
-GetMailboxPointerInIdtEntry (
- VOID
- )
-{
- IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
- IA32_DESCRIPTOR IdtDescriptor;
- UINTN Mailbox;
-
- AsmReadIdtr (&IdtDescriptor);
- IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *) IdtDescriptor.Base;
-
- Mailbox = IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetLow + (IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetHigh << 16);
- return (VOID *) Mailbox;
-}
-
-/**
- Set the pointer of Mailbox into IDT entry before memory is ready.
-
- @param[in] Mailbox The pointer of Mailbox.
-
-**/
-VOID
-SetMailboxPointerInIdtEntry (
- IN VOID *Mailbox
- )
-{
- IA32_IDT_GATE_DESCRIPTOR *IdtEntry;
- IA32_DESCRIPTOR IdtDescriptor;
-
- AsmReadIdtr (&IdtDescriptor);
- IdtEntry = (IA32_IDT_GATE_DESCRIPTOR *) IdtDescriptor.Base;
-
- IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetLow = (UINT16)(UINTN)Mailbox;
- IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetHigh = (UINT16)((UINTN)Mailbox >> 16);
-}
-
-/**
- Get the pointer to Mailbox from IDT entry and build the Mailbox into GUIDed Hob
- after memory is ready.
-
- @return Pointer to Mailbox.
-
-**/
-DEBUG_AGENT_MAILBOX *
-BuildMailboxHob (
- VOID
- )
-{
- DEBUG_AGENT_MAILBOX *Mailbox;
-
- Mailbox = (DEBUG_AGENT_MAILBOX *) GetMailboxPointerInIdtEntry ();
-
- return BuildGuidDataHob (
- &gEfiDebugAgentGuid,
- Mailbox,
- sizeof (DEBUG_AGENT_MAILBOX)
- );
-}
-
-/**
- Get Debug Agent Mailbox pointer.
-
- @return Mailbox pointer.
-
-**/
-DEBUG_AGENT_MAILBOX *
-GetMailboxPointer (
- VOID
- )
-{
- return (DEBUG_AGENT_MAILBOX *) GetMailboxPointerInIdtEntry ();
-}
-
-/**
- Get debug port handle.
-
- @return Debug port handle.
-
-**/
-DEBUG_PORT_HANDLE
-GetDebugPortHandle (
- VOID
- )
-{
- DEBUG_AGENT_MAILBOX *DebugAgentMailbox;
-
- DebugAgentMailbox = (DEBUG_AGENT_MAILBOX *)GetMailboxPointerInIdtEntry ();
-
- return (DEBUG_PORT_HANDLE) (UINTN)(DebugAgentMailbox->DebugPortHandle);
-}
-
-/**
- Trigger one software interrupt to debug agent to handle it.
-
- @param Signature Software interrupt signature.
-
-**/
-VOID
-TriggerSoftInterrupt (
- UINT32 Signature
- )
-{
- UINTN Dr0;
- UINTN Dr1;
-
- //
- // Save Debug Register State
- //
- Dr0 = AsmReadDr0 ();
- Dr1 = AsmReadDr1 ();
-
- //
- // DR0 = Signature
- //
- AsmWriteDr0 (SOFT_INTERRUPT_SIGNATURE);
- AsmWriteDr1 (Signature);
-
- //
- // Do INT3 to communicate with HOST side
- //
- CpuBreakpoint ();
-
- //
- // Restore Debug Register State only when Host didn't change it inside exception handler.
- // Dr registers can only be changed by setting the HW breakpoint.
- //
- AsmWriteDr0 (Dr0);
- AsmWriteDr1 (Dr1);
-
-}
-
-/**
- Initialize debug agent.
-
- This function is used to set up debug environment for SEC and PEI phase.
-
- If InitFlag is DEBUG_AGENT_INIT_PREMEM_SEC, it will overirde IDT table entries
- and initialize debug port. It will enable interrupt to support break-in feature.
- It will set up debug agent Mailbox in cache-as-ramfrom. It will be called before
- physical memory is ready.
- If InitFlag is DEBUG_AGENT_INIT_POSTMEM_SEC, debug agent will build one GUIDed
- HOB to copy debug agent Mailbox. It will be called after physical memory is ready.
-
- This function is used to set up debug environment to support source level debugging.
- If certain Debug Agent Library instance has to save some private data in the stack,
- this function must work on the mode that doesn't return to the caller, then
- the caller needs to wrap up all rest of logic after InitializeDebugAgent() into one
- function and pass it into InitializeDebugAgent(). InitializeDebugAgent() is
- responsible to invoke the passing-in function at the end of InitializeDebugAgent().
-
- If the parameter Function is not NULL, Debug Agent Libary instance will invoke it by
- passing in the Context to be its parameter.
-
- If Function() is NULL, Debug Agent Library instance will return after setup debug
- environment.
-
- @param[in] InitFlag Init flag is used to decide the initialize process.
- @param[in] Context Context needed according to InitFlag; it was optional.
- @param[in] Function Continue function called by debug agent library; it was
- optional.
-
-**/
-VOID
-EFIAPI
-InitializeDebugAgent (
- IN UINT32 InitFlag,
- IN VOID *Context, OPTIONAL
- IN DEBUG_AGENT_CONTINUE Function OPTIONAL
- )
-{
- DEBUG_AGENT_MAILBOX *Mailbox;
- DEBUG_AGENT_MAILBOX MailboxInStack;
- DEBUG_AGENT_PHASE2_CONTEXT Phase2Context;
- DEBUG_AGENT_CONTEXT_POSTMEM_SEC *DebugAgentContext;
-
- DisableInterrupts ();
-
- switch (InitFlag) {
-
- case DEBUG_AGENT_INIT_PREMEM_SEC:
-
- InitializeDebugIdt ();
-
- Mailbox = &MailboxInStack;
- ZeroMem ((VOID *) Mailbox, sizeof (DEBUG_AGENT_MAILBOX));
-
- //
- // Get and save debug port handle and set the length of memory block.
- //
- SetMailboxPointerInIdtEntry ((VOID *) Mailbox);
-
- InitializeDebugTimer ();
-
- Phase2Context.Context = Context;
- Phase2Context.Function = Function;
- DebugPortInitialize ((VOID *) &Phase2Context, InitializeDebugAgentPhase2);
-
- //
- // If reaches here, it means Debug Port initialization failed.
- //
- DEBUG ((EFI_D_ERROR, "Debug Agent: Debug port initialization failed.\n"));
-
- break;
-
- case DEBUG_AGENT_INIT_POSTMEM_SEC:
-
- //
- // Memory has been ready
- //
- if (IsHostAttached()) {
- //
- // Trigger one software interrupt to inform HOST
- //
- TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
- }
-
- DebugAgentContext = (DEBUG_AGENT_CONTEXT_POSTMEM_SEC *) Context;
-
- Mailbox = (DEBUG_AGENT_MAILBOX *) GetMailboxPointerInIdtEntry ();
- Mailbox->DebugPortHandle = (UINT64)(UINT32)(Mailbox->DebugPortHandle + DebugAgentContext->StackMigrateOffset);
- Mailbox->DebugFlag.MemoryReady = 1;
-
- Mailbox = BuildMailboxHob ();
- Mailbox = (DEBUG_AGENT_MAILBOX *) ((UINTN) Mailbox + DebugAgentContext->HeapMigrateOffset);
-
- SetMailboxPointerInIdtEntry ((VOID *) Mailbox);
-
- EnableInterrupts ();
-
- break;
-
- default:
-
- //
- // Only DEBUG_AGENT_INIT_PREMEM_SEC and DEBUG_AGENT_INIT_POSTMEM_SEC are allowed for this
- // Debug Agent library instance.
- //
- DEBUG ((EFI_D_ERROR, "Debug Agent: The InitFlag value is not allowed!\n"));
- CpuDeadLoop ();
- break;
-
- }
-
- //
- // If Function is not NULL, invoke it always whatever debug agent was initialized sucesssfully or not.
- //
- if (Function != NULL) {
- Function (Context);
- }
-}
-
-/**
- Caller provided function to be invoked at the end of DebugPortInitialize().
-
- Refer to the descrption for DebugPortInitialize() for more details.
-
- @param[in] Context The first input argument of DebugPortInitialize().
- @param[in] DebugPortHandle Debug port handle created by Debug Communication Libary.
-
-**/
-VOID
-EFIAPI
-InitializeDebugAgentPhase2 (
- IN VOID *Context,
- IN DEBUG_PORT_HANDLE DebugPortHandle
- )
-{
- DEBUG_AGENT_PHASE2_CONTEXT *Phase2Context;
- DEBUG_AGENT_MAILBOX *Mailbox;
- EFI_SEC_PEI_HAND_OFF *SecCoreData;
-
- Mailbox = GetMailboxPointerInIdtEntry ();
- Mailbox->DebugPortHandle = (UINT64) (UINTN)DebugPortHandle;
-
- //
- // Trigger one software interrupt to inform HOST
- //
- TriggerSoftInterrupt (SYSTEM_RESET_SIGNATURE);
-
- //
- // If Temporary RAM region is below 128 MB, then send message to
- // host to disable low memory filtering.
- //
- Phase2Context = (DEBUG_AGENT_PHASE2_CONTEXT *) Context;
- SecCoreData = (EFI_SEC_PEI_HAND_OFF *)Phase2Context->Context;
- if ((UINTN)SecCoreData->TemporaryRamBase < BASE_128MB && IsHostAttached ()) {
- TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
- }
-
- //
- // Enable CPU interrupts so debug timer interrupts can be delivered
- //
- EnableInterrupts ();
-
- //
- // Call continuation function if it is not NULL.
- //
- if (Phase2Context->Function != NULL) {
- Phase2Context->Function (Phase2Context->Context);
- }
-}
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.h b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.h
deleted file mode 100644
index 9ca5e87..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/** @file
- Header file for Sec Core Debug Agent Library instance.
-
- Copyright (c) 2010, 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _SEC_CORE_DEBUG_AGENT_LIB_H_
-#define _SEC_CORE_DEBUG_AGENT_LIB_H_
-
-#include <PiPei.h>
-
-#include "DebugAgent.h"
-
-typedef struct {
- VOID *Context;
- DEBUG_AGENT_CONTINUE Function;
-} DEBUG_AGENT_PHASE2_CONTEXT;
-
-#endif
-
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
deleted file mode 100644
index 577a635..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
+++ /dev/null
@@ -1,80 +0,0 @@
-## @file
-# Debug Agent library instance for SEC Core and PEI modules.
-#
-# 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
-# http://opensource.org/licenses/bsd-license.php.
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = SecPeiDebugAgentLib
- FILE_GUID = 508B7D59-CD4E-4a6b-A45B-6D3B2D90111E
- MODULE_TYPE = PEIM
- VERSION_STRING = 0.7
- LIBRARY_CLASS = DebugAgentLib|SEC PEIM
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64
-#
-
-[Sources.common]
- SecPeiDebugAgent/SecPeiDebugAgentLib.c
- SecPeiDebugAgent/SecPeiDebugAgentLib.h
- DebugAgentCommon/DebugAgent.c
- DebugAgentCommon/DebugAgent.h
- DebugAgentCommon/DebugTimer.c
- DebugAgentCommon/DebugTimer.h
- DebugAgentCommon/DebugMp.c
- DebugAgentCommon/DebugMp.h
-
-[Sources.Ia32]
- DebugAgentCommon/Ia32/AsmFuncs.S | GCC
- DebugAgentCommon/Ia32/AsmFuncs.asm | MSFT
- DebugAgentCommon/Ia32/ArchDebugSupport.h
- DebugAgentCommon/Ia32/ArchDebugSupport.c
- DebugAgentCommon/Ia32/DebugException.h
-
-[Sources.X64]
- DebugAgentCommon/X64/AsmFuncs.S | GCC
- DebugAgentCommon/X64/AsmFuncs.asm | MSFT
- DebugAgentCommon/X64/ArchDebugSupport.h
- DebugAgentCommon/X64/ArchDebugSupport.c
- DebugAgentCommon/X64/DebugException.h
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- UefiCpuPkg/UefiCpuPkg.dec
- SourceLevelDebugPkg/SourceLevelDebugPkg.dec
-
-[LibraryClasses]
- BaseLib
- BaseMemoryLib
- ResetSystemLib
- IoLib
- HobLib
- PcdLib
- DebugCommunicationLib
- SynchronizationLib
- LocalApicLib
- DebugLib
- TimerLib
- PrintLib
-
-[Guids]
- gEfiDebugAgentGuid ## PRODUCES ## HOB
-
-[Pcd]
- gEfiMdePkgTokenSpaceGuid.PcdFSBClock ## CONSUMES
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdExceptionsIgnoredByDebugger ## CONSUMES
-
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c
deleted file mode 100644
index 3326c0a..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/** @file
- Debug Agent library implementition.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "SmmDebugAgentLib.h"
-
-DEBUG_AGENT_MAILBOX *mMailboxPointer = NULL;
-DEBUG_AGENT_MAILBOX mLocalMailbox;
-UINTN mSavedDebugRegisters[6];
-CONST BOOLEAN MultiProcessorDebugSupport = FALSE;
-
-/**
- Read the Attach/Break-in symbols from the debug port.
-
- @param[in] Handle Pointer to Debug Port handle.
- @param[out] BreakSymbol Returned break symbol.
-
- @retval EFI_SUCCESS Read the symbol in BreakSymbol.
- @retval EFI_NOT_FOUND No read the break symbol.
-
-**/
-EFI_STATUS
-DebugReadBreakSymbol (
- IN DEBUG_PORT_HANDLE Handle,
- OUT UINT8 *BreakSymbol
- )
-{
- //
- // Smm instance has no debug timer to poll break symbol.
- //
- return EFI_NOT_FOUND;
-}
-
-/**
- Get Debug Agent Mailbox pointer.
-
- @return Mailbox pointer.
-
-**/
-DEBUG_AGENT_MAILBOX *
-GetMailboxPointer (
- VOID
- )
-{
- return mMailboxPointer;
-}
-
-/**
- Get debug port handle.
-
- @return Debug port handle.
-
-**/
-DEBUG_PORT_HANDLE
-GetDebugPortHandle (
- VOID
- )
-{
- return (DEBUG_PORT_HANDLE) (UINTN)(mMailboxPointer->DebugPortHandle);
-}
-
-/**
- Store debug register when SMI exit.
-
-**/
-VOID
-SaveDebugRegister (
- VOID
- )
-{
- mSavedDebugRegisters[0] = AsmReadDr0 ();
- mSavedDebugRegisters[1] = AsmReadDr1 ();
- mSavedDebugRegisters[2] = AsmReadDr2 ();
- mSavedDebugRegisters[3] = AsmReadDr3 ();
- mSavedDebugRegisters[4] = AsmReadDr6 ();
- mSavedDebugRegisters[5] = AsmReadDr7 ();
-}
-
-/**
- Restore debug register when SMI exit.
-
-**/
-VOID
-RestoreDebugRegister (
- VOID
- )
-{
- AsmWriteDr7 (0);
- AsmWriteDr0 (mSavedDebugRegisters[0]);
- AsmWriteDr1 (mSavedDebugRegisters[1]);
- AsmWriteDr2 (mSavedDebugRegisters[2]);
- AsmWriteDr3 (mSavedDebugRegisters[3]);
- AsmWriteDr6 (mSavedDebugRegisters[4]);
- AsmWriteDr7 (mSavedDebugRegisters[5]);
-}
-
-/**
- Initialize debug agent.
-
- This function is used to set up debug enviroment for source level debug
- in SMM code.
-
- If InitFlag is DEBUG_AGENT_INIT_SMM, it will overirde IDT table entries
- and initialize debug port. It will get debug agent Mailbox from GUIDed HOB,
- it it exists, debug agent wiil copied it into the local Mailbox in SMM space.
- it will overirde IDT table entries and initialize debug port. Context will be
- NULL.
- If InitFlag is DEBUG_AGENT_INIT_ENTER_SMI, debug agent will save Debug
- Registers and get local Mailbox in SMM space. Context will be NULL.
- If InitFlag is DEBUG_AGENT_INIT_EXIT_SMI, debug agent will restore Debug
- Registers. Context will be NULL.
-
- @param[in] InitFlag Init flag is used to decide initialize process.
- @param[in] Context Context needed according to InitFlag.
- @param[in] Function Continue function called by debug agent library; it was
- optional.
-
-**/
-VOID
-EFIAPI
-InitializeDebugAgent (
- IN UINT32 InitFlag,
- IN VOID *Context, OPTIONAL
- IN DEBUG_AGENT_CONTINUE Function OPTIONAL
- )
-{
- EFI_STATUS Status;
- UINT64 DebugPortHandle;
-
- switch (InitFlag) {
- case DEBUG_AGENT_INIT_SMM:
- Status = EfiGetSystemConfigurationTable (&gEfiDebugAgentGuid, (VOID **) &mMailboxPointer);
- if (EFI_ERROR (Status) || mMailboxPointer == NULL) {
- ZeroMem (&mLocalMailbox, sizeof (DEBUG_AGENT_MAILBOX));
- mMailboxPointer = &mLocalMailbox;
- }
-
- break;
-
- case DEBUG_AGENT_INIT_ENTER_SMI:
- SaveDebugRegister ();
- InitializeDebugIdt ();
-
- if (mMailboxPointer != NULL) {
- //
- // Initialize debug communication port
- //
- DebugPortHandle = (UINT64) (UINTN)DebugPortInitialize ((DEBUG_PORT_HANDLE) (UINTN)mMailboxPointer->DebugPortHandle, NULL);
- mMailboxPointer->DebugPortHandle = DebugPortHandle;
-
- if (mMailboxPointer->DebugFlag.BreakOnNextSmi == 1) {
- //
- // If SMM entry break is set, SMM code will be break at here.
- //
- CpuBreakpoint ();
- }
- }
- break;
-
- case DEBUG_AGENT_INIT_EXIT_SMI:
- RestoreDebugRegister ();
- break;
- }
-}
-
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.h b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.h
deleted file mode 100644
index ccb55f8..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.h
+++ /dev/null
@@ -1,24 +0,0 @@
-/** @file
- Header file for Smm Debug Agent Library instance.
-
- Copyright (c) 2010, 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _SMM_DEBUG_AGENT_LIB_H_
-#define _SMM_DEBUG_AGENT_LIB_H_
-
-#include <PiDxe.h>
-
-#include <Library/UefiLib.h>
-
-#include "DebugAgent.h"
-
-#endif
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf
deleted file mode 100644
index f62d997..0000000
--- a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf
+++ /dev/null
@@ -1,79 +0,0 @@
-## @file
-# Debug Agent library instance for SMM modules.
-#
-# 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
-# http://opensource.org/licenses/bsd-license.php.
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = SecDebugAgentLib
- FILE_GUID = CB07D74C-598F-4268-A5D1-644FB4A481E8
- MODULE_TYPE = DXE_SMM_DRIVER
- VERSION_STRING = 0.7
- LIBRARY_CLASS = DebugAgentLib|DXE_SMM_DRIVER
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64
-#
-
-[Sources.common]
- SmmDebugAgent/SmmDebugAgentLib.c
- SmmDebugAgent/SmmDebugAgentLib.h
- DebugAgentCommon/DebugAgent.c
- DebugAgentCommon/DebugAgent.h
- DebugAgentCommon/DebugTimer.c
- DebugAgentCommon/DebugTimer.h
- DebugAgentCommon/DebugMp.c
- DebugAgentCommon/DebugMp.h
-
-[Sources.Ia32]
- DebugAgentCommon/Ia32/AsmFuncs.S | GCC
- DebugAgentCommon/Ia32/AsmFuncs.asm | MSFT
- DebugAgentCommon/Ia32/ArchDebugSupport.h
- DebugAgentCommon/Ia32/ArchDebugSupport.c
- DebugAgentCommon/Ia32/DebugException.h
-
-[Sources.X64]
- DebugAgentCommon/X64/AsmFuncs.S | GCC
- DebugAgentCommon/X64/AsmFuncs.asm | MSFT
- DebugAgentCommon/X64/ArchDebugSupport.h
- DebugAgentCommon/X64/ArchDebugSupport.c
- DebugAgentCommon/X64/DebugException.h
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- UefiCpuPkg/UefiCpuPkg.dec
- SourceLevelDebugPkg/SourceLevelDebugPkg.dec
-
-[LibraryClasses]
- BaseLib
- BaseMemoryLib
- ResetSystemLib
- IoLib
- DebugCommunicationLib
- UefiLib
- PcdLib
- SynchronizationLib
- LocalApicLib
- TimerLib
- PrintLib
-
-[Guids]
- gEfiDebugAgentGuid ## CONSUMES ## Configuration Table
-
-[Pcd]
- gEfiMdePkgTokenSpaceGuid.PcdFSBClock ## CONSUMES
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdExceptionsIgnoredByDebugger ## CONSUMES
-
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.c
deleted file mode 100644
index dd88e7d..0000000
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/** @file
- Debug Port Library implementation based on serial port.
-
- Copyright (c) 2010 - 2011, 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Base.h>
-
-#include <Library/DebugCommunicationLib.h>
-#include <Library/SerialPortLib.h>
-#include <Library/TimerLib.h>
-#include <Library/DebugLib.h>
-
-/**
- Initialize the debug port.
-
- This function will initialize debug port to get it ready for data transmition. If
- certain Debug Communication Library instance has to save some private data in the
- stack, this function must work on the mode that doesn't return to the caller, then
- the caller needs to wrap up all rest of logic after DebugPortInitialize() into one
- function and pass it into DebugPortInitialize(). DebugPortInitialize() is
- responsible to invoke the passing-in funciton at the end of DebugPortInitialize().
-
- If the paramter Function is not NULL, Debug Communication Libary instance will
- invoke it by passing in the Context to be the first parameter. Debug Communication
- Library instance could create one debug port handle to be the second parameter
- passing into the Function. Debug Communication Library instance also could pass
- NULL to be the second parameter if it doesn't create the debug port handle.
-
- If the parameter Function is NULL, and Context is not NULL. At this time, Context
- is the debug port handle created by the previous Debug Communication Library
- instance.
- a) If the instance can understand and continue use the private data of the previous
- instance, it could return the same handle as passed in (as Context parameter).
- b) If the instance does not understand, or does not want to continue use the
- private data of the previous instance, it could ignore the input Context parameter
- and create the new hanlde to be returned.
-
- If Function() is NULL and Context is NULL, Debug Communication Library could create a
- new handle and return it. NULL is also a valid handle to be returned.
-
- @param[in] Context Context needed by callback function; it was optional.
- @param[in] Function Continue function called by Debug Communication library;
- it was optional.
-
- @return The debug port handle created by Debug Communication Library if Function
- is not NULL.
-
-**/
-DEBUG_PORT_HANDLE
-EFIAPI
-DebugPortInitialize (
- IN VOID *Context,
- IN DEBUG_PORT_CONTINUE Function
- )
-{
- RETURN_STATUS Status;
-
- Status = SerialPortInitialize ();
- if (RETURN_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "Debug Serial Port: Initialization failed!\n"));
- }
-
- if (Function != NULL) {
- Function (Context, NULL);
- }
-
- return NULL;
-}
-
-/**
- Read data from debug device and save the datas in buffer.
-
- Reads NumberOfBytes data bytes from a debug device into the buffer
- specified by Buffer. The number of bytes actually read is returned.
- If the return value is less than NumberOfBytes, then the rest operation failed.
- If NumberOfBytes is zero, then return 0.
-
- @param Handle Debug port handle.
- @param Buffer Pointer to the data buffer to store the data read from the debug device.
- @param NumberOfBytes Number of bytes which will be read.
- @param Timeout Timeout value for reading from debug device. It unit is Microsecond.
-
- @retval 0 Read data failed, no data is to be read.
- @retval >0 Actual number of bytes read from debug device.
-
-**/
-UINTN
-EFIAPI
-DebugPortReadBuffer (
- IN DEBUG_PORT_HANDLE Handle,
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes,
- IN UINTN Timeout
- )
-{
- UINTN Index;
- INTN Elapsed;
-
- for (Index = 0; Index < NumberOfBytes; Index ++) {
- Elapsed = (INTN) Timeout;
- while (TRUE) {
- if (SerialPortPoll () || Timeout == 0) {
- SerialPortRead (Buffer + Index, 1);
- break;
- }
- MicroSecondDelay (1000);
- Elapsed -= 1000;
- if (Elapsed < 0) {
- return 0;
- }
- }
- }
-
- return NumberOfBytes;
-}
-
-/**
- Write data from buffer to debug device.
-
- Writes NumberOfBytes data bytes from Buffer to the debug device.
- The number of bytes actually written to the debug device is returned.
- If the return value is less than NumberOfBytes, then the write operation failed.
- If NumberOfBytes is zero, then return 0.
-
- @param Handle Debug port handle.
- @param Buffer Pointer to the data buffer to be written.
- @param NumberOfBytes Number of bytes to written to the debug device.
-
- @retval 0 NumberOfBytes is 0.
- @retval >0 The number of bytes written to the debug device.
- If this value is less than NumberOfBytes, then the read operation failed.
-
-**/
-UINTN
-EFIAPI
-DebugPortWriteBuffer (
- IN DEBUG_PORT_HANDLE Handle,
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
- )
-{
- return SerialPortWrite (Buffer, NumberOfBytes);
-}
-
-/**
- Polls a debug device to see if there is any data waiting to be read.
-
- Polls a debug device to see if there is any data waiting to be read.
- If there is data waiting to be read from the debug device, then TRUE is returned.
- If there is no data waiting to be read from the debug device, then FALSE is returned.
-
- @param Handle Debug port handle.
-
- @retval TRUE Data is waiting to be read from the debug device.
- @retval FALSE There is no data waiting to be read from the serial device.
-
-**/
-BOOLEAN
-EFIAPI
-DebugPortPollBuffer (
- IN DEBUG_PORT_HANDLE Handle
- )
-{
- return SerialPortPoll ();
-}
-
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf b/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf
deleted file mode 100644
index 6d36cef..0000000
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf
+++ /dev/null
@@ -1,39 +0,0 @@
-## @file
-# Debug Communication Library instance based on serila port.
-#
-# Copyright (c) 2010 - 2011, 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
-# http://opensource.org/licenses/bsd-license.php.
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = DebugCommunicationLibSerialPort
- FILE_GUID = 8CC435C5-6330-4269-B0C3-E3BD05C86FB8
- MODULE_TYPE = BASE
- VERSION_STRING = 0.7
- LIBRARY_CLASS = DebugCommunicationLib
-
-#
-# VALID_ARCHITECTURES = IA32 X64
-#
-
-[Sources.common]
- DebugCommunicationLibSerialPort.c
-
-[Packages]
- MdePkg/MdePkg.dec
- SourceLevelDebugPkg/SourceLevelDebugPkg.dec
-
-[LibraryClasses]
- SerialPortLib
- TimerLib
- DebugLib
-
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
deleted file mode 100644
index aafd52d..0000000
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.c
+++ /dev/null
@@ -1,1174 +0,0 @@
-/** @file
- Debug Port Library implementation based on usb debug port.
-
- Copyright (c) 2010 - 2011, 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Base.h>
-#include <IndustryStandard/Pci.h>
-#include <IndustryStandard/Usb.h>
-#include <Library/IoLib.h>
-#include <Library/PciLib.h>
-#include <Library/PcdLib.h>
-#include <Library/TimerLib.h>
-#include <Library/DebugCommunicationLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-
-#define SETUP_PID 0x2D
-#define INPUT_PID 0x69
-#define OUTPUT_PID 0xE1
-#define ERROR_PID 0x55
-#define DATA0_PID 0xC3
-#define DATA1_PID 0x4B
-#define DATA2_PID 0x87
-#define MDATA_PID 0x0F
-#define ACK_PID 0xD2
-#define NAK_PID 0x5A
-#define STALL_PID 0x1E
-#define NYET_PID 0x96
-
-#define PCI_CAPABILITY_ID_DEBUG_PORT 0x0A
-#define USB_DEBUG_PORT_MAX_PACKET_SIZE 0x08
-
-#define USB_DEBUG_PORT_IN_USE BIT10
-#define USB_DEBUG_PORT_ENABLE BIT28
-#define USB_DEBUG_PORT_OWNER BIT30
-
-#define USB_PORT_LINE_STATUS_LS 0x400
-#define USB_PORT_LINE_STATUS_MASK 0xC00
-
-//
-// Usb debug device descriptor, which is defined at
-// USB2 Debug Device Specification.
-//
-typedef struct _USB_DEBUG_PORT_DESCRIPTOR {
- UINT8 Length;
- UINT8 DescriptorType;
- UINT8 DebugInEndpoint;
- UINT8 DebugOutEndpoint;
-}USB_DEBUG_PORT_DESCRIPTOR;
-
-USB_DEVICE_REQUEST mGetDebugDescriptor = {
- 0x80,
- USB_REQ_GET_DESCRIPTOR,
- (UINT16)(0x0A << 8),
- 0x0000,
- sizeof(USB_DEBUG_PORT_DESCRIPTOR)
- };
-
-USB_DEVICE_REQUEST mSetDebugFeature = {
- 0x0,
- USB_REQ_SET_FEATURE,
- (UINT16)(0x06),
- 0x0000,
- 0x0
- };
-
-USB_DEVICE_REQUEST mSetDebugAddress = {
- 0x0,
- USB_REQ_SET_ADDRESS,
- (UINT16)(0x7F),
- 0x0000,
- 0x0
- };
-
-//
-// Usb debug port register file, which is defined at
-// EHCI Specification.
-//
-typedef struct _USB_DEBUG_PORT_REGISTER {
- UINT32 ControlStatus;
- UINT8 TokenPid;
- UINT8 SendPid;
- UINT8 ReceivedPid;
- UINT8 Reserved1;
- UINT8 DataBuffer[8];
- UINT8 UsbEndPoint;
- UINT8 UsbAddress;
- UINT8 Reserved2;
- UINT8 Reserved3;
-}USB_DEBUG_PORT_REGISTER;
-
-//
-// The state machine of usb debug port
-//
-#define USBDBG_NO_DEV 0 // No device present at debug port
-#define USBDBG_NO_DBG_CAB 1 // The device attached is not usb debug cable
-#define USBDBG_DBG_CAB 2 // The device attached is usb debug cable
-#define USBDBG_INIT_DONE 4 // The usb debug cable device is initialized
-#define USBDBG_RESET 8 // The system is reset
-
-#pragma pack(1)
-//
-// The internal data structure of DEBUG_PORT_HANDLE, which stores some
-// important datum which are used across various phases.
-//
-typedef struct _USB_DEBUG_PORT_HANDLE{
- //
- // The usb debug port memory BAR number in EHCI configuration space.
- //
- UINT8 DebugPortBarNumber;
- UINT8 Initialized;
- //
- // The offset of usb debug port registers in EHCI memory range.
- //
- UINT16 DebugPortOffset;
- //
- // The usb debug port memory BAR address.
- //
- UINT32 UsbDebugPortMemoryBase;
- //
- // The EHCI memory BAR address.
- //
- UINT32 EhciMemoryBase;
- //
- // The Bulk In endpoint toggle bit.
- //
- UINT8 BulkInToggle;
- //
- // The Bulk Out endpoint toggle bit.
- //
- UINT8 BulkOutToggle;
- //
- // The available data length in the following data buffer.
- //
- UINT8 DataCount;
- //
- // The data buffer. Maximum length is 8 bytes.
- //
- UINT8 Data[8];
-} USB_DEBUG_PORT_HANDLE;
-#pragma pack()
-
-//
-// The global variable which can be used after memory is ready.
-//
-USB_DEBUG_PORT_HANDLE mUsbDebugPortHandle;
-
-/**
- Calculate the usb debug port bar address.
-
- @param DebugPortOffset Get usb debug port offset in the usb debug port memory space.
- @param DebugPortBarNumbar Get the bar number at which usb debug port is located.
-
- @retval RETURN_UNSUPPORTED The usb host controller does not supported usb debug port capability.
- @retval RETURN_SUCCESS Get bar and offset successfully.
-
-**/
-RETURN_STATUS
-EFIAPI
-CalculateUsbDebugPortBar (
- OUT UINT16 *DebugPortOffset,
- OUT UINT8 *DebugPortBarNumbar
- )
-{
- UINT16 PciStatus;
- UINT16 VendorId;
- UINT16 DeviceId;
- UINT8 ProgInterface;
- UINT8 SubClassCode;
- UINT8 BaseCode;
- UINT8 CapabilityPtr;
- UINT8 CapabilityId;
-
- VendorId = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_VENDOR_ID_OFFSET);
- DeviceId = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_DEVICE_ID_OFFSET);
-
- if ((VendorId == 0xFFFF) || (DeviceId == 0xFFFF)) {
- return RETURN_UNSUPPORTED;
- }
-
- ProgInterface = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET);
- SubClassCode = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET + 1);
- BaseCode = PciRead8 (PcdGet32(PcdUsbEhciPciAddress) + PCI_CLASSCODE_OFFSET + 2);
-
- if ((ProgInterface != PCI_IF_EHCI) || (SubClassCode != PCI_CLASS_SERIAL_USB) || (BaseCode != PCI_CLASS_SERIAL)) {
- return RETURN_UNSUPPORTED;
- }
-
- //
- // Enable Ehci Host Controller MMIO Space.
- //
- PciStatus = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_PRIMARY_STATUS_OFFSET);
-
- if ((PciStatus & EFI_PCI_STATUS_CAPABILITY) == 0) {
- //
- // The Pci Device Doesn't Support Capability Pointer.
- //
- return RETURN_UNSUPPORTED;
- }
-
- //
- // Get Pointer To Capability List
- //
- CapabilityPtr = PciRead8(PcdGet32(PcdUsbEhciPciAddress) + PCI_CAPBILITY_POINTER_OFFSET);
-
- //
- // Find Capability ID 0xA, Which Is For Debug Port
- //
- while (CapabilityPtr != 0) {
- CapabilityId = PciRead8(PcdGet32(PcdUsbEhciPciAddress) + CapabilityPtr);
- if (CapabilityId == PCI_CAPABILITY_ID_DEBUG_PORT) {
- break;
- }
- CapabilityPtr = PciRead8(PcdGet32(PcdUsbEhciPciAddress) + CapabilityPtr + 1);
- }
-
- //
- // No Debug Port Capability Found
- //
- if (CapabilityPtr == 0) {
- return RETURN_UNSUPPORTED;
- }
-
- //
- // Get The Base Address Of Debug Port Register In Debug Port Capability Register
- //
- *DebugPortOffset = (UINT16)(PciRead16(PcdGet32(PcdUsbEhciPciAddress) + CapabilityPtr + 2) & 0x1FFF);
- *DebugPortBarNumbar = (UINT8)((PciRead16(PcdGet32(PcdUsbEhciPciAddress) + CapabilityPtr + 2) >> 13) - 1);
-
- return RETURN_SUCCESS;
-}
-
-/**
- Do a usb IN transaction by usb debug port.
-
- @param DebugPortRegister Pointer to the base address of usb debug port register interface.
- @param Buffer Pointer to the buffer receiving data.
- @param Length Number of bytes of the received data.
- @param Token The token PID for each USB transaction.
- @param Addr The usb device address for usb transaction.
- @param Ep The endpoint for usb transaction.
- @param DataToggle The toggle bit used at usb transaction.
-
- @retval RETURN_SUCCESS The IN transaction is executed successfully.
- @retval RETURN_INVALID_PARAMETER The parameters passed in are invalid.
- @retval RETURN_DEVICE_ERROR The IN transaction comes across error.
-
-**/
-RETURN_STATUS
-EFIAPI
-UsbDebugPortIn (
- IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,
- IN OUT UINT8 *Buffer,
- OUT UINT8 *Length,
- IN UINT8 Token,
- IN UINT8 Addr,
- IN UINT8 Ep,
- IN UINT8 DataToggle
- )
-{
- UINTN Index;
-
- if (Length == NULL) {
- return RETURN_INVALID_PARAMETER;
- }
- *Length = 0;
-
- DebugPortRegister->TokenPid = Token;
- if (DataToggle != 0) {
- DebugPortRegister->SendPid = DATA1_PID;
- } else {
- DebugPortRegister->SendPid = DATA0_PID;
- }
-
- DebugPortRegister->UsbAddress = (UINT8)(Addr & 0x7F);
- DebugPortRegister->UsbEndPoint = (UINT8)(Ep & 0xF);
-
- //
- // Clearing W/R bit to indicate it's a READ operation
- //
- MmioAnd32((UINTN)&DebugPortRegister->ControlStatus, (UINT32)~BIT4);
-
- //
- // Setting GO bit as well as clearing DONE bit
- //
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, (UINT32)BIT5);
-
- //
- // Wait for completing the request
- //
- while ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & (UINT32)BIT16) == 0) {
- if ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE)) {
- return RETURN_DEVICE_ERROR;
- }
- }
-
- //
- // Clearing DONE bit by writing 1
- //
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, BIT16);
-
- //
- // Check if the request is executed successfully or not.
- //
- if ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus)) & BIT6) {
- return RETURN_DEVICE_ERROR;
- }
-
- //
- // Make sure the received data are not beyond the allowable maximum length - 8 byte
- //
- if (((MmioRead32((UINTN)&DebugPortRegister->ControlStatus)) & 0xF) > USB_DEBUG_PORT_MAX_PACKET_SIZE) {
- return RETURN_DEVICE_ERROR;
- }
-
- *Length = (UINT8)(MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & 0xF);
- if (*Length > 8) {
- return RETURN_DEVICE_ERROR;
- }
-
- for (Index = 0; Index < *Length; Index++) {
- Buffer[Index] = DebugPortRegister->DataBuffer[Index];
- }
- return RETURN_SUCCESS;
-}
-
-/**
- Do a usb SETUP/OUT transaction by usb debug port.
-
- @param DebugPortRegister Pointer to the base address of usb debug port register interface.
- @param Buffer Pointer to the buffer receiving data.
- @param Length Number of bytes of the received data.
- @param Token The token PID for each USB transaction.
- @param Addr The usb device address for usb transaction.
- @param Ep The endpoint for usb transaction.
- @param DataToggle The toggle bit used at usb transaction.
-
- @retval RETURN_SUCCESS The IN transaction is executed successfully.
- @retval RETURN_INVALID_PARAMETER The parameters passed in are invalid.
- @retval RETURN_DEVICE_ERROR The IN transaction comes across error.
-
-**/
-RETURN_STATUS
-EFIAPI
-UsbDebugPortOut (
- IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,
- IN UINT8 *Buffer,
- IN UINT8 Length,
- IN UINT8 Token,
- IN UINT8 Addr,
- IN UINT8 Ep,
- IN UINT8 DataToggle
- )
-{
- UINT8 Index;
-
- if (Length > 8) {
- return RETURN_INVALID_PARAMETER;
- }
-
- DebugPortRegister->TokenPid = Token;
- if (DataToggle != 0) {
- DebugPortRegister->SendPid = DATA1_PID;
- } else {
- DebugPortRegister->SendPid = DATA0_PID;
- }
- DebugPortRegister->UsbAddress = (UINT8)(Addr & 0x7F);
- DebugPortRegister->UsbEndPoint = (UINT8)(Ep & 0xF);
-
- //
- // Fill in the data length and corresponding data.
- //
- MmioAnd32((UINTN)&DebugPortRegister->ControlStatus, (UINT32)~0xF);
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, Length & 0xF);
- for (Index = 0; Index < Length; Index++) {
- DebugPortRegister->DataBuffer[Index] = Buffer[Index];
- }
-
- //
- // Setting W/R bit to indicate it's a WRITE operation
- //
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, BIT4);
- //
- // Setting GO bit as well as clearing DONE bit
- //
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, BIT5);
-
- //
- // Wait for completing the request
- //
- while ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & BIT16) == 0) {
- if ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE)) {
- return RETURN_DEVICE_ERROR;
- }
- }
-
- //
- // Clearing DONE bit by writing 1
- //
- MmioOr32((UINTN)&DebugPortRegister->ControlStatus, BIT16);
-
- //
- // Check if the request is executed successfully or not.
- //
- if ((MmioRead32((UINTN)&DebugPortRegister->ControlStatus)) & BIT6) {
- return RETURN_DEVICE_ERROR;
- }
-
- //
- // Make sure the sent data are not beyond the allowable maximum length - 8 byte
- //
- if (((MmioRead32((UINTN)&DebugPortRegister->ControlStatus)) & 0xF) > USB_DEBUG_PORT_MAX_PACKET_SIZE) {
- return RETURN_DEVICE_ERROR;
- }
-
- return RETURN_SUCCESS;
-}
-
-/**
- Do a usb control transfer by usb debug port.
-
- @param DebugPortRegister Pointer to the base address of usb debug port register interface.
- @param SetupPacket The token PID for each USB transaction.
- @param Addr The usb device address for usb transaction.
- @param Ep The endpoint for usb transaction.
- @param Data Pointer to the buffer receiving data.
- @param DataLength Number of bytes of the received data.
-
- @retval RETURN_SUCCESS The IN transaction is executed successfully.
- @retval RETURN_INVALID_PARAMETER The parameters passed in are invalid.
- @retval RETURN_DEVICE_ERROR The IN transaction comes across error.
-
-**/
-RETURN_STATUS
-EFIAPI
-UsbDebugPortControlTransfer (
- IN USB_DEBUG_PORT_REGISTER *DebugPortRegister,
- IN USB_DEVICE_REQUEST *SetupPacket,
- IN UINT8 Addr,
- IN UINT8 Ep,
- OUT UINT8 *Data,
- IN OUT UINT8 *DataLength
- )
-{
- RETURN_STATUS Status;
- UINT8 Temp;
- UINT8 ReturnStatus[8];
-
- //
- // Setup Phase
- //
- Status = UsbDebugPortOut(DebugPortRegister, (UINT8 *)SetupPacket, (UINT8)sizeof(USB_DEVICE_REQUEST), SETUP_PID, Addr, Ep, 0);
- if (RETURN_ERROR(Status)) {
- return Status;
- }
-
- //
- // Data Phase
- //
- if (DataLength != 0) {
- if ((SetupPacket->RequestType & BIT7) != 0) {
- //
- // Get Data From Device
- //
- Status = UsbDebugPortIn(DebugPortRegister, Data, DataLength, INPUT_PID, Addr, Ep, 1);
- if (RETURN_ERROR(Status)) {
- return Status;
- }
- } else {
- //
- // Send Data To Device
- //
- Status = UsbDebugPortOut(DebugPortRegister, Data, *DataLength, OUTPUT_PID, Addr, Ep, 1);
- if (RETURN_ERROR(Status)) {
- return Status;
- }
- }
- }
-
- //
- // Status Phase
- //
- if ((SetupPacket->RequestType & BIT7) != 0) {
- //
- // For READ operation, Data Toggle in Status Phase Should be 1.
- //
- Status = UsbDebugPortOut(DebugPortRegister, NULL, 0, OUTPUT_PID, Addr, Ep, 1);
- } else {
- //
- // For WRITE operation, Data Toggle in Status Phase Should be 1.
- //
- Status = UsbDebugPortIn(DebugPortRegister, ReturnStatus, &Temp, INPUT_PID, Addr, Ep, 1);
- }
-
- return Status;
-}
-
-/**
- Check if it needs to re-initialize usb debug port hardware.
-
- During different phases switch, such as SEC to PEI or PEI to DXE or DXE to SMM, we should check
- whether the usb debug port hardware configuration is changed. Such case can be triggerred by
- Pci bus resource allocation and so on.
-
- @param Handle Debug port handle.
-
- @retval TRUE The usb debug port hardware configuration is changed.
- @retval FALSE The usb debug port hardware configuration is not changed.
-
-**/
-BOOLEAN
-EFIAPI
-NeedReinitializeHardware(
- IN USB_DEBUG_PORT_HANDLE *Handle
- )
-{
- UINT16 PciCmd;
- UINT32 UsbDebugPortMemoryBase;
- UINT32 EhciMemoryBase;
- BOOLEAN Status;
- USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;
-
- Status = FALSE;
-
- EhciMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);
- if (EhciMemoryBase != Handle->EhciMemoryBase) {
- Handle->EhciMemoryBase = EhciMemoryBase;
- Status = TRUE;
- }
-
- UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle->DebugPortBarNumber * 4);
- if (UsbDebugPortMemoryBase != Handle->UsbDebugPortMemoryBase) {
- Handle->UsbDebugPortMemoryBase = UsbDebugPortMemoryBase;
- Status = TRUE;
- }
-
- //
- // Enable Ehci Memory Space Access
- //
- PciCmd = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_COMMAND_OFFSET);
- if (((PciCmd & EFI_PCI_COMMAND_MEMORY_SPACE) == 0) || ((PciCmd & EFI_PCI_COMMAND_BUS_MASTER) == 0)) {
- PciCmd |= EFI_PCI_COMMAND_MEMORY_SPACE | EFI_PCI_COMMAND_BUS_MASTER;
- PciWrite16(PcdGet32(PcdUsbEhciPciAddress) + PCI_COMMAND_OFFSET, PciCmd);
- Status = TRUE;
- }
-
- //
- // If the owner and in_use bit is not set, it means system is doing cold/warm boot or EHCI host controller is reset by system software.
- //
- UsbDebugPortRegister = (USB_DEBUG_PORT_REGISTER *)(UINTN)(Handle->UsbDebugPortMemoryBase + Handle->DebugPortOffset);
- if ((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_ENABLE | USB_DEBUG_PORT_IN_USE))
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_ENABLE | USB_DEBUG_PORT_IN_USE)) {
- Status = TRUE;
- }
-
- if (Handle->Initialized == USBDBG_RESET) {
- Status = TRUE;
- } else if (Handle->Initialized != USBDBG_INIT_DONE) {
- Status = TRUE;
- }
- return Status;
-}
-
-/**
- Initialize usb debug port hardware.
-
- 1. reset ehci host controller.
- 2. set right port to debug port.
- 3. find a usb debug device is attached by getting debug device descriptor.
- 4. set address for the usb debug device.
- 5. configure the usb debug device to debug mode.
-
- @param Handle Debug port handle.
-
- @retval TRUE The usb debug port hardware configuration is changed.
- @retval FALSE The usb debug port hardware configuration is not changed.
-
-**/
-RETURN_STATUS
-EFIAPI
-InitializeUsbDebugHardware (
- IN USB_DEBUG_PORT_HANDLE *Handle
-)
-{
- RETURN_STATUS Status;
- USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;
- USB_DEBUG_PORT_DESCRIPTOR UsbDebugPortDescriptor;
- UINT16 PciCmd;
- UINT32 *PortStatus;
- UINT32 *UsbCmd;
- UINT32 *UsbStatus;
- UINT32 *UsbHCSParam;
- UINT8 DebugPortNumber;
- UINT8 Length;
-
- UsbDebugPortRegister = (USB_DEBUG_PORT_REGISTER *)(UINTN)(Handle->UsbDebugPortMemoryBase + Handle->DebugPortOffset);
- PciCmd = PciRead16 (PcdGet32(PcdUsbEhciPciAddress) + PCI_COMMAND_OFFSET);
- UsbHCSParam = (UINT32 *)(UINTN)(Handle->EhciMemoryBase + 0x04);
- UsbCmd = (UINT32 *)(UINTN)(Handle->EhciMemoryBase + 0x20);
- UsbStatus = (UINT32 *)(UINTN)(Handle->EhciMemoryBase + 0x24);
-
- //
- // Check if the debug port is enabled and owned by myself.
- //
- if (((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE))
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE)) || (Handle->Initialized == USBDBG_RESET)) {
- //
- // If the host controller is not halted, then halt it.
- //
- if ((MmioRead32((UINTN)UsbStatus) & BIT12) == 0) {
- MmioAnd32((UINTN)UsbCmd, (UINT32)~BIT0);
- while ((MmioRead32((UINTN)UsbStatus) & BIT12) == 0);
- }
- //
- // reset the host controller.
- //
- MmioOr32((UINTN)UsbCmd, BIT1);
- //
- // ensure that the host controller is reset.
- //
- while (MmioRead32((UINTN)UsbCmd) & BIT1);
-
- //
- // Start the host controller if it's not running
- //
- if (MmioRead32((UINTN)UsbStatus) & BIT12) {
- MmioOr32((UINTN)UsbCmd, BIT0);
- // ensure that the host controller is started (HALTED bit must be cleared)
- while (MmioRead32((UINTN)UsbStatus) & BIT12);
- }
-
- //
- // First get the ownership of port 0.
- //
- MmioOr32((UINTN)&UsbDebugPortRegister->ControlStatus, USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE);
-
- MicroSecondDelay (200000);
- }
- //
- // Find out which port is used as debug port.
- //
- DebugPortNumber = (UINT8)((MmioRead32((UINTN)UsbHCSParam) & 0x00F00000) >> 20);
- //
- // Should find a device is connected at debug port
- //
- PortStatus = (UINT32 *)(UINTN)(Handle->EhciMemoryBase + 0x64 + (DebugPortNumber - 1) * 4);
- if (!(MmioRead32((UINTN)PortStatus) & BIT0)) {
- Handle->Initialized = USBDBG_NO_DEV;
- return RETURN_NOT_FOUND;
- }
-
- if (Handle->Initialized != USBDBG_INIT_DONE) {
- //
- // Reset the debug port
- //
- MmioOr32((UINTN)PortStatus, BIT8);
- MicroSecondDelay (500000);
- MmioAnd32((UINTN)PortStatus, (UINT32)~BIT8);
- while (MmioRead32((UINTN)PortStatus) & BIT8);
-
- //
- // The port enabled bit should be set by HW.
- //
- if ((MmioRead32((UINTN)PortStatus) & BIT2) == 0) {
- Handle->Initialized = USBDBG_NO_DBG_CAB;
- return RETURN_DEVICE_ERROR;
- }
-
- //
- // Enable Usb Debug Port Capability
- //
- MmioOr32((UINTN)&UsbDebugPortRegister->ControlStatus, USB_DEBUG_PORT_ENABLE);
-
- //
- // initialize the data toggle used by bulk in/out endpoint.
- //
- Handle->BulkInToggle = 0;
- Handle->BulkOutToggle = 0;
-
- //
- // set usb debug device address as 0x7F.
- //
- Status = UsbDebugPortControlTransfer (UsbDebugPortRegister, &mSetDebugAddress, 0x0, 0x0, NULL, NULL);
- if (RETURN_ERROR(Status)) {
- //
- // The device can not work well.
- //
- Handle->Initialized = USBDBG_NO_DBG_CAB;
- return Status;
- }
-
- //
- // Start to communicate with Usb Debug Device to see if the attached device is usb debug device or not.
- //
- Length = (UINT8)sizeof (USB_DEBUG_PORT_DESCRIPTOR);
-
- //
- // Get debug descriptor.
- //
- Status = UsbDebugPortControlTransfer (UsbDebugPortRegister, &mGetDebugDescriptor, 0x7F, 0x0, (UINT8*)&UsbDebugPortDescriptor, &Length);
- if (RETURN_ERROR(Status)) {
- //
- // The device is not a usb debug device.
- //
- Handle->Initialized = USBDBG_NO_DBG_CAB;
- return Status;
- }
-
- if (Length != sizeof(USB_DEBUG_PORT_DESCRIPTOR)) {
- Handle->Initialized = USBDBG_NO_DBG_CAB;
- return RETURN_DEVICE_ERROR;
- }
-
- //
- // enable the usb debug feature.
- //
- Status = UsbDebugPortControlTransfer (UsbDebugPortRegister, &mSetDebugFeature, 0x7F, 0x0, NULL, NULL);
- if (RETURN_ERROR(Status)) {
- //
- // The device can not work well.
- //
- Handle->Initialized = USBDBG_NO_DBG_CAB;
- return Status;
- }
-
- Handle->Initialized = USBDBG_DBG_CAB;
- }
-
- //
- // Set initialized flag
- //
- Handle->Initialized = USBDBG_INIT_DONE;
-
- return RETURN_SUCCESS;
-}
-
-/**
- Read data from debug device and save the datas in buffer.
-
- Reads NumberOfBytes data bytes from a debug device into the buffer
- specified by Buffer. The number of bytes actually read is returned.
- If the return value is less than NumberOfBytes, then the rest operation failed.
- If NumberOfBytes is zero, then return 0.
-
- @param Handle Debug port handle.
- @param Buffer Pointer to the data buffer to store the data read from the debug device.
- @param NumberOfBytes Number of bytes which will be read.
- @param Timeout Timeout value for reading from debug device. It unit is Microsecond.
-
- @retval 0 Read data failed, no data is to be read.
- @retval >0 Actual number of bytes read from debug device.
-
-**/
-UINTN
-EFIAPI
-DebugPortReadBuffer (
- IN DEBUG_PORT_HANDLE Handle,
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes,
- IN UINTN Timeout
- )
-{
- USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
- USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;
- RETURN_STATUS Status;
- UINT8 Received;
- UINTN Total;
- UINTN Remaining;
- UINT8 Index;
- UINT8 Length;
-
- if (NumberOfBytes == 0 || Buffer == NULL) {
- return 0;
- }
-
- Received = 0;
- Total = 0;
- Remaining = 0;
-
- //
- // If Handle is NULL, it means memory is ready for use.
- // Use global variable to store handle value.
- //
- if (Handle == NULL) {
- UsbDebugPortHandle = &mUsbDebugPortHandle;
- } else {
- UsbDebugPortHandle = (USB_DEBUG_PORT_HANDLE *)Handle;
- }
-
- if (NeedReinitializeHardware(UsbDebugPortHandle)) {
- Status = InitializeUsbDebugHardware (UsbDebugPortHandle);
- if (RETURN_ERROR(Status)) {
- return 0;
- }
- }
-
- UsbDebugPortRegister = (USB_DEBUG_PORT_REGISTER *)(UINTN)(UsbDebugPortHandle->UsbDebugPortMemoryBase + UsbDebugPortHandle->DebugPortOffset);
-
- //
- // First read data from buffer, then read debug port hw to get received data.
- //
- if (UsbDebugPortHandle->DataCount > 0) {
- if (NumberOfBytes <= UsbDebugPortHandle->DataCount) {
- Total = NumberOfBytes;
- } else {
- Total = UsbDebugPortHandle->DataCount;
- }
-
- for (Index = 0; Index < Total; Index++) {
- Buffer[Index] = UsbDebugPortHandle->Data[Index];
- }
-
- for (Index = 0; Index < UsbDebugPortHandle->DataCount - Total; Index++) {
- if (Total + Index >= 8) {
- return 0;
- }
- UsbDebugPortHandle->Data[Index] = UsbDebugPortHandle->Data[Total + Index];
- }
- UsbDebugPortHandle->DataCount = (UINT8)(UsbDebugPortHandle->DataCount - (UINT8)Total);
- }
-
- //
- // If Timeout is equal to 0, then it means it should always wait until all datum required are received.
- //
- if (Timeout == 0) {
- Timeout = 0xFFFFFFFF;
- }
-
- //
- // Read remaining data by executing one or more usb debug transfer transactions at usb debug port hw.
- //
- while ((Total < NumberOfBytes) && (Timeout != 0)) {
- Remaining = NumberOfBytes - Total;
- if (Remaining >= USB_DEBUG_PORT_MAX_PACKET_SIZE) {
- Status = UsbDebugPortIn(UsbDebugPortRegister, Buffer + Total, &Received, INPUT_PID, 0x7f, 0x82, UsbDebugPortHandle->BulkInToggle);
-
- if (RETURN_ERROR(Status)) {
- return Total;
- }
- } else {
- Status = UsbDebugPortIn(UsbDebugPortRegister, &UsbDebugPortHandle->Data[0], &Received, INPUT_PID, 0x7f, 0x82, UsbDebugPortHandle->BulkInToggle);
-
- if (RETURN_ERROR(Status)) {
- return Total;
- }
-
- UsbDebugPortHandle->DataCount = Received;
-
- if (Remaining <= Received) {
- Length = (UINT8)Remaining;
- } else {
- Length = (UINT8)Received;
- }
-
- //
- // Copy required data from the data buffer to user buffer.
- //
- for (Index = 0; Index < Length; Index++) {
- (Buffer + Total)[Index] = UsbDebugPortHandle->Data[Index];
- UsbDebugPortHandle->DataCount--;
- }
-
- //
- // reorder the data buffer to make available data arranged from the beginning of the data buffer.
- //
- for (Index = 0; Index < Received - Length; Index++) {
- if (Length + Index >= 8) {
- return 0;
- }
- UsbDebugPortHandle->Data[Index] = UsbDebugPortHandle->Data[Length + Index];
- }
- //
- // fixup the real received length in Buffer.
- //
- Received = Length;
- }
- UsbDebugPortHandle->BulkInToggle ^= 1;
-
- Total += Received;
- Timeout -= 100;
- }
-
- return Total;
-}
-
-/**
- Write data from buffer to debug device.
-
- Writes NumberOfBytes data bytes from Buffer to the debug device.
- The number of bytes actually written to the debug device is returned.
- If the return value is less than NumberOfBytes, then the write operation failed.
- If NumberOfBytes is zero, then return 0.
-
- @param Handle Debug port handle.
- @param Buffer Pointer to the data buffer to be written.
- @param NumberOfBytes Number of bytes to written to the debug device.
-
- @retval 0 NumberOfBytes is 0.
- @retval >0 The number of bytes written to the debug device.
- If this value is less than NumberOfBytes, then the read operation failed.
-
-**/
-UINTN
-EFIAPI
-DebugPortWriteBuffer (
- IN DEBUG_PORT_HANDLE Handle,
- IN UINT8 *Buffer,
- IN UINTN NumberOfBytes
- )
-{
- USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
- USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;
- RETURN_STATUS Status;
- UINT8 Sent;
- UINTN Total;
- UINT8 ReceivedPid;
-
- if (NumberOfBytes == 0 || Buffer == NULL) {
- return 0;
- }
-
- Sent = 0;
- Total = 0;
-
- //
- // If Handle is NULL, it means memory is ready for use.
- // Use global variable to store handle value.
- //
- if (Handle == NULL) {
- UsbDebugPortHandle = &mUsbDebugPortHandle;
- } else {
- UsbDebugPortHandle = (USB_DEBUG_PORT_HANDLE *)Handle;
- }
-
- if (NeedReinitializeHardware(UsbDebugPortHandle)) {
- Status = InitializeUsbDebugHardware (UsbDebugPortHandle);
- if (RETURN_ERROR(Status)) {
- return 0;
- }
- }
-
- UsbDebugPortRegister = (USB_DEBUG_PORT_REGISTER *)(UINTN)(UsbDebugPortHandle->UsbDebugPortMemoryBase + UsbDebugPortHandle->DebugPortOffset);
-
- while ((Total < NumberOfBytes)) {
- if (NumberOfBytes - Total > USB_DEBUG_PORT_MAX_PACKET_SIZE) {
- Sent = USB_DEBUG_PORT_MAX_PACKET_SIZE;
- } else {
- Sent = (UINT8)(NumberOfBytes - Total);
- }
-
- Status = UsbDebugPortOut(UsbDebugPortRegister, Buffer + Total, Sent, OUTPUT_PID, 0x7F, 0x01, UsbDebugPortHandle->BulkOutToggle);
-
- if (RETURN_ERROR(Status)) {
- return Total;
- }
-
- ReceivedPid = (MmioRead8((UINTN)&UsbDebugPortRegister->ReceivedPid));
- //
- // If received a NAK_PID on write transaction, it means the usb debug device is busy and can not handle this transaction.
- // should send the packet again.
- //
- if (ReceivedPid == NAK_PID) {
- Sent = 0;
- } else {
- UsbDebugPortHandle->BulkOutToggle ^= 1;
- }
- Total += Sent;
- }
- return Total;
-}
-
-/**
- Polls a debug device to see if there is any data waiting to be read.
-
- Polls a debug device to see if there is any data waiting to be read.
- If there is data waiting to be read from the debug device, then TRUE is returned.
- If there is no data waiting to be read from the debug device, then FALSE is returned.
-
- @param Handle Debug port handle.
-
- @retval TRUE Data is waiting to be read from the debug device.
- @retval FALSE There is no data waiting to be read from the serial device.
-
-**/
-BOOLEAN
-EFIAPI
-DebugPortPollBuffer (
- IN DEBUG_PORT_HANDLE Handle
- )
-{
- USB_DEBUG_PORT_HANDLE *UsbDebugPortHandle;
- USB_DEBUG_PORT_REGISTER *UsbDebugPortRegister;
- UINT8 Length;
- UINT8 Index;
- RETURN_STATUS Status;
-
- //
- // If Handle is NULL, it means memory is ready for use.
- // Use global variable to store handle value.
- //
- if (Handle == NULL) {
- UsbDebugPortHandle = &mUsbDebugPortHandle;
- } else {
- UsbDebugPortHandle = (USB_DEBUG_PORT_HANDLE *)Handle;
- }
-
- if (NeedReinitializeHardware(UsbDebugPortHandle)) {
- Status = InitializeUsbDebugHardware(UsbDebugPortHandle);
- if (RETURN_ERROR(Status)) {
- return FALSE;
- }
- }
-
- //
- // If the data buffer is not empty, then return TRUE directly.
- // else initialize a usb read transaction and read data to the data buffer.
- //
- if (UsbDebugPortHandle->DataCount != 0) {
- return TRUE;
- }
-
- UsbDebugPortRegister = (USB_DEBUG_PORT_REGISTER *)(UINTN)(UsbDebugPortHandle->UsbDebugPortMemoryBase + UsbDebugPortHandle->DebugPortOffset);
-
- UsbDebugPortRegister->TokenPid = INPUT_PID;
- if (UsbDebugPortHandle->BulkInToggle == 0) {
- UsbDebugPortRegister->SendPid = DATA0_PID;
- } else {
- UsbDebugPortRegister->SendPid = DATA1_PID;
- }
- UsbDebugPortRegister->UsbAddress = 0x7F;
- UsbDebugPortRegister->UsbEndPoint = 0x82 & 0x0F;
-
- //
- // Clearing W/R bit to indicate it's a READ operation
- //
- MmioAnd32((UINTN)&UsbDebugPortRegister->ControlStatus, (UINT32)~BIT4);
- //
- // Setting GO bit as well as clearing DONE bit
- //
- MmioOr32((UINTN)&UsbDebugPortRegister->ControlStatus, (UINT32)BIT5);
-
- //
- // Wait for completing the request
- //
- while ((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & (UINT32)BIT16) == 0) {
- if ((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE))
- != (USB_DEBUG_PORT_OWNER | USB_DEBUG_PORT_IN_USE | USB_DEBUG_PORT_ENABLE)) {
- return FALSE;
- }
- }
-
- if ((MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus)) & BIT6) {
- return FALSE;
- }
-
- Length = (UINT8)(MmioRead32((UINTN)&UsbDebugPortRegister->ControlStatus) & 0xF);
-
- if (Length > 8) {
- return FALSE;
- }
-
- UsbDebugPortHandle->BulkInToggle ^= 1;
-
- if (Length == 0) {
- return FALSE;
- }
-
- for (Index = 0; Index < Length; Index++) {
- UsbDebugPortHandle->Data[Index] = UsbDebugPortRegister->DataBuffer[Index];
- }
- UsbDebugPortHandle->DataCount = Length;
-
- return TRUE;
-}
-
-/**
- Initialize the debug port.
-
- If Function is not NULL, Debug Communication Libary will call this function
- by passing in the Context to be the first parameter. If needed, Debug Communication
- Library will create one debug port handle to be the second argument passing in
- calling the Function, otherwise it will pass NULL to be the second argument of
- Function.
-
- If Function is NULL, and Context is not NULL, the Debug Communication Library could
- a) Return the same handle as passed in (as Context parameter).
- b) Ignore the input Context parameter and create new hanlde to be returned.
-
- If parameter Function is NULL and Context is NULL, Debug Communication Library could
- created a new handle if needed and return it, otherwise it will return NULL.
-
- @param[in] Context Context needed by callback function; it was optional.
- @param[in] Function Continue function called by Debug Communication library;
- it was optional.
-
- @return The debug port handle created by Debug Communication Library if Function
- is not NULL.
-
-**/
-DEBUG_PORT_HANDLE
-EFIAPI
-DebugPortInitialize (
- IN VOID *Context,
- IN DEBUG_PORT_CONTINUE Function
- )
-{
- RETURN_STATUS Status;
- USB_DEBUG_PORT_HANDLE Handle;
- if (Function == NULL && Context != NULL) {
- return (DEBUG_PORT_HANDLE *) Context;
- }
-
- ZeroMem(&Handle, sizeof (USB_DEBUG_PORT_HANDLE));
-
- Status = CalculateUsbDebugPortBar(&Handle.DebugPortOffset, &Handle.DebugPortBarNumber);
- if (RETURN_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "UsbDbg: the pci device pointed by PcdUsbEhciPciAddress is not EHCI host controller or does not support debug port capability!\n"));
- goto Exit;
- }
-
- Handle.EhciMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);
-
- if (Handle.EhciMemoryBase == 0) {
- //
- // Usb Debug Port MMIO Space Is Not Enabled. Assumption here that DebugPortBase is zero
- //
- PciWrite32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET, PcdGet32(PcdUsbEhciMemorySpaceBase));
- Handle.EhciMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET);
- }
-
- Handle.UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4);
-
- if (Handle.UsbDebugPortMemoryBase == 0) {
- //
- // Usb Debug Port MMIO Space Is Not Enabled. Assumption here that DebugPortBase is zero
- //
- PciWrite32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4, PcdGet32(PcdUsbDebugPortMemorySpaceBase));
- Handle.UsbDebugPortMemoryBase = 0xFFFFFC00 & PciRead32(PcdGet32(PcdUsbEhciPciAddress) + PCI_BASE_ADDRESSREG_OFFSET + Handle.DebugPortBarNumber * 4);
- }
-
- Handle.Initialized = USBDBG_RESET;
-
- if (NeedReinitializeHardware(&Handle)) {
- DEBUG ((EFI_D_ERROR, "UsbDbg: Start EHCI debug port initialization!\n"));
- Status = InitializeUsbDebugHardware (&Handle);
- if (RETURN_ERROR(Status)) {
- DEBUG ((EFI_D_ERROR, "UsbDbg: Initialization failed, please check if USB debug cable is plugged into EHCI debug port correctly!\n"));
- goto Exit;
- }
- }
-
-Exit:
-
- if (Function != NULL) {
- Function (Context, &Handle);
- } else {
- CopyMem(&mUsbDebugPortHandle, &Handle, sizeof (USB_DEBUG_PORT_HANDLE));
- }
-
- return (DEBUG_PORT_HANDLE)(UINTN)&mUsbDebugPortHandle;
-}
-
diff --git a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf b/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf
deleted file mode 100644
index 61e8a7f..0000000
--- a/SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf
+++ /dev/null
@@ -1,54 +0,0 @@
-## @file
-# Debug Communication Library instance based on usb debug port.
-#
-# Copyright (c) 2010, 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
-# http://opensource.org/licenses/bsd-license.php.
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = DebugCommunicationLibUsb
- FILE_GUID = 87438836-AD8D-4e3e-9249-895120A67240
- MODULE_TYPE = BASE
- VERSION_STRING = 0.7
- LIBRARY_CLASS = DebugCommunicationLib
-
-#
-# VALID_ARCHITECTURES = IA32 X64
-#
-
-[Sources.common]
- DebugCommunicationLibUsb.c
-
-[Packages]
- MdePkg/MdePkg.dec
- SourceLevelDebugPkg/SourceLevelDebugPkg.dec
-
-[Pcd]
- ## The memory BAR of usb debug port, it may be different with the memory bar of ehci host controller.
- ## Note that the memory BAR address is only used before Pci bus resource allocation.
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbDebugPortMemorySpaceBase
-
- ## The memory BAR of ehci host controller, in which usb debug feature is enabled.
- ## Note that the memory BAR address is only used before Pci bus resource allocation.
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbEhciMemorySpaceBase
-
- ## The pci address of ehci host controller, in which usb debug feature is enabled.
- ## The format of pci address please refer to SourceLevelDebugPkg.dec
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbEhciPciAddress
-
-[LibraryClasses]
- TimerLib
- IoLib
- PciLib
- PcdLib
- DebugLib
-
diff --git a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c b/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c
deleted file mode 100644
index 7b551f2..0000000
--- a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/** @file
- PE/Coff Extra Action library instances.
-
- 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
- http://opensource.org/licenses/bsd-license.php.
-
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include <Base.h>
-#include <Library/PeCoffExtraActionLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseLib.h>
-#include <Library/IoLib.h>
-#include <Library/PcdLib.h>
-
-#include <ImageDebugSupport.h>
-
-#define DEBUG_LOAD_IMAGE_METHOD_IO_HW_BREAKPOINT 1
-#define DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3 2
-
-/**
- Check if the hardware breakpoint in Drx is enabled by checking the Lx and Gx bit in Dr7.
-
- It assumes that DebugAgent will set both Lx and Gx bit when setting up the hardware breakpoint.
-
-
- @param RegisterIndex Index of Dr register. The value range is from 0 to 3.
- @param Dr7 Value of Dr7 register.
-
- @return TRUE The hardware breakpoint specified in the Drx is enabled.
- @return FALSE The hardware breakpoint specified in the Drx is disabled.
-
-**/
-BOOLEAN
-IsDrxEnabled (
- IN UINT8 RegisterIndex,
- IN UINTN Dr7
- )
-{
- return (BOOLEAN) (((Dr7 >> (RegisterIndex * 2)) & (BIT0 | BIT1)) == (BIT0 | BIT1));
-}
-
-/**
- Common routine to report the PE/COFF image loading/relocating or unloading event.
-
- If ImageContext is NULL, then ASSERT().
-
- @param ImageContext Pointer to the image context structure that describes the
- PE/COFF image.
- @param Signature IMAGE_LOAD_SIGNATURE or IMAGE_UNLOAD_SIGNATURE.
-
-**/
-VOID
-PeCoffLoaderExtraActionCommon (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
- IN UINTN Signature
- )
-{
- BOOLEAN InterruptState;
- UINTN Dr0;
- UINTN Dr1;
- UINTN Dr2;
- UINTN Dr3;
- UINTN Dr7;
- UINTN Cr4;
- UINTN NewDr7;
- UINT8 LoadImageMethod;
- UINT8 DebugAgentStatus;
-
- ASSERT (ImageContext != NULL);
-
- if (ImageContext->PdbPointer != NULL) {
- DEBUG((EFI_D_ERROR, " PDB = %a\n", ImageContext->PdbPointer));
- }
-
- //
- // Disable interrupts and save the current interrupt state
- //
- InterruptState = SaveAndDisableInterrupts ();
-
- //
- // Save Debug Register State
- //
- Dr0 = AsmReadDr0 ();
- Dr1 = AsmReadDr1 ();
- Dr2 = AsmReadDr2 ();
- Dr3 = AsmReadDr3 ();
- Dr7 = AsmReadDr7 ();
- Cr4 = AsmReadCr4 ();
-
- //
- // DR0 = Signature
- // DR1 = The address of the Null-terminated ASCII string for the PE/COFF image's PDB file name
- // DR2 = The pointer to the ImageContext structure
- // DR3 = IO_PORT_BREAKPOINT_ADDRESS
- // DR7 = Disables all HW breakpoints except for DR3 I/O port access of length 1 byte
- // CR4 = Make sure DE(BIT3) is set
- //
- AsmWriteDr7 (0);
- AsmWriteDr0 (Signature);
- AsmWriteDr1 ((UINTN) ImageContext->PdbPointer);
- AsmWriteDr2 ((UINTN) ImageContext);
- AsmWriteDr3 (IO_PORT_BREAKPOINT_ADDRESS);
-
- LoadImageMethod = PcdGet8 (PcdDebugLoadImageMethod);
- if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_IO_HW_BREAKPOINT) {
- AsmWriteDr7 (0x20000480);
- AsmWriteCr4 (Cr4 | BIT3);
- //
- // Do an IN from IO_PORT_BREAKPOINT_ADDRESS to generate a HW breakpoint until the port
- // returns a read value other than DEBUG_AGENT_IMAGE_WAIT
- //
- do {
- DebugAgentStatus = IoRead8 (IO_PORT_BREAKPOINT_ADDRESS);
- } while (DebugAgentStatus == DEBUG_AGENT_IMAGE_WAIT);
-
- } else if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3) {
- //
- // Generate a software break point.
- //
- CpuBreakpoint ();
- }
-
- //
- // Restore Debug Register State only when Host didn't change it inside exception handler.
- // E.g.: User halts the target and sets the HW breakpoint while target is
- // in the above exception handler
- //
- NewDr7 = AsmReadDr7 ();
- if (!IsDrxEnabled (0, NewDr7) && (AsmReadDr0 () == 0 || AsmReadDr0 () == Signature)) {
- //
- // If user changed Dr3 (by setting HW bp in the above exception handler,
- // we will not set Dr0 to 0 in GO/STEP handler because the break cause is not IMAGE_LOAD/_UNLOAD.
- //
- AsmWriteDr0 (Dr0);
- }
- if (!IsDrxEnabled (1, NewDr7) && (AsmReadDr1 () == (UINTN) ImageContext->PdbPointer)) {
- AsmWriteDr1 (Dr1);
- }
- if (!IsDrxEnabled (2, NewDr7) && (AsmReadDr2 () == (UINTN) ImageContext)) {
- AsmWriteDr2 (Dr2);
- }
- if (!IsDrxEnabled (3, NewDr7) && (AsmReadDr3 () == IO_PORT_BREAKPOINT_ADDRESS)) {
- AsmWriteDr3 (Dr3);
- }
- if (AsmReadCr4 () == (Cr4 | BIT3)) {
- AsmWriteCr4 (Cr4);
- }
- if (NewDr7 == 0x20000480) {
- AsmWriteDr7 (Dr7);
- }
- //
- // Restore the interrupt state
- //
- SetInterruptState (InterruptState);
-}
-
-/**
- Performs additional actions after a PE/COFF image has been loaded and relocated.
-
- @param ImageContext Pointer to the image context structure that describes the
- PE/COFF image that has already been loaded and relocated.
-
-**/
-VOID
-EFIAPI
-PeCoffLoaderRelocateImageExtraAction (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
- )
-{
- PeCoffLoaderExtraActionCommon (ImageContext, IMAGE_LOAD_SIGNATURE);
-}
-
-/**
- Performs additional actions just before a PE/COFF image is unloaded. Any resources
- that were allocated by PeCoffLoaderRelocateImageExtraAction() must be freed.
-
- @param ImageContext Pointer to the image context structure that describes the
- PE/COFF image that is being unloaded.
-
-**/
-VOID
-EFIAPI
-PeCoffLoaderUnloadImageExtraAction (
- IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
- )
-{
- PeCoffLoaderExtraActionCommon (ImageContext, IMAGE_UNLOAD_SIGNATURE);
-}
diff --git a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf b/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
deleted file mode 100644
index e3712af..0000000
--- a/SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
+++ /dev/null
@@ -1,45 +0,0 @@
-## @file
-# PeCoffExtraAction Library to support source level debug.
-#
-# Copyright (c) 2010, 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
-# http://opensource.org/licenses/bsd-license.php.
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-##
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = PeCoffExtraActionLib
- FILE_GUID = 8F01CBD5-E069-44d7-90C9-35F0318603AD
- MODULE_TYPE = BASE
- VERSION_STRING = 0.7
- LIBRARY_CLASS = PeCoffExtraActionLib
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64
-#
-
-[Sources.common]
- PeCoffExtraActionLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- SourceLevelDebugPkg/SourceLevelDebugPkg.dec
-
-[LibraryClasses]
- BaseLib
- DebugLib
- IoLib
- PcdLib
-
-[Pcd]
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod
-
diff --git a/SourceLevelDebugPkg/Readme.txt b/SourceLevelDebugPkg/Readme.txt
deleted file mode 100644
index 70ab31d..0000000
--- a/SourceLevelDebugPkg/Readme.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-UDK based firmware on UEFI IA-32 and UEFI x64 platforms can be debugged with
-SourceLevelDebugPkg in conjunction with Intel(R) UEFI Development Kit Debugger
-Tool (Intel (R) UDK Debugger Tool).
-
-The Intel(R) UDK Debugger Tool and its detailed user manual can be obtained
-from: http://www.intel.com/technology/efi.
diff --git a/SourceLevelDebugPkg/SourceLevelDebugPkg.dec b/SourceLevelDebugPkg/SourceLevelDebugPkg.dec
deleted file mode 100644
index 34d7006..0000000
--- a/SourceLevelDebugPkg/SourceLevelDebugPkg.dec
+++ /dev/null
@@ -1,74 +0,0 @@
-## @file SourceLevelDebugPkg.dec
-#
-# This package provides target side modules to support source level debug.
-# The target side components includes the Debug Agent Library instance
-# to communicate with host side modules, Debug Communication Library and
-# instances to provide the communication I/O functions between Debug Agent
-# and host, PeCoffExtraActionLib instance to report symbol path information,
-# etc.
-#
-# 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 that accompanies this distribution.
-# The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php.
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-##
-
-[Defines]
- DEC_SPECIFICATION = 0x00010005
- PACKAGE_NAME = SourceLevelDebugPkg
- PACKAGE_GUID = DBF00C27-D8D7-443d-918B-4E85CDA1373B
- PACKAGE_VERSION = 0.80
-
-[Includes]
- Include
-
-[Includes.IA32]
- Include/Ia32
-
-[Includes.X64]
- Include/Ia32
-
-[LibraryClasses]
- ## @libraryclass Provides communication I/O functions between Debug Agent and HOST.
- ##
- DebugCommunicationLib|Include/Library/DebugCommunicationLib.h
-
-[Guids]
- ## MdeModule package token space guid
- # Include/Guid/DebugAgentGuid.h
- gEfiDebugAgentGuid = {0x865a5a9b, 0xb85d, 0x474c, { 0x84, 0x55, 0x65, 0xd1, 0xbe, 0x84, 0x4b, 0xe2 }}
- gEfiSourceLevelDebugPkgTokenSpaceGuid = {0x865a5aab, 0xb85d, 0x474c, { 0x84, 0x55, 0x65, 0xd1, 0xbe, 0x84, 0x4b, 0xe2 }}
-
-[PcdsFixedAtBuild, PcdsPatchableInModule]
- ## The memory BAR of usb debug port, it may be different with the memory bar of ehci host controller.
- ## Note that the memory BAR address is only used before Pci bus resource allocation.
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbDebugPortMemorySpaceBase|0xd0000000|UINT32|0x00000001
-
- ## The memory BAR of ehci host controller, in which usb debug feature is enabled.
- ## Note that the memory BAR address is only used before Pci bus resource allocation.
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbEhciMemorySpaceBase|0xd0000000|UINT32|0x00000002
-
- ## The pci address of ehci host controller, in which usb debug feature is enabled.
- ## The format of pci address is :
- ## -----------------------------------------------------------------------
- ## | Bits 28..31 | Bits 20..27 | Bits 15..19 | Bits 12..14 | Bits 00..11 |
- ## -----------------------------------------------------------------------
- ## | 0 | Bus | Device | Function | 0 |
- ## -----------------------------------------------------------------------
- ##
- ## For the value below, it means the pci address at bus 0x0, device 0x1D, function 0x7.
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdUsbEhciPciAddress|0x000EF000|UINT32|0x00000003
-
- ## The mask of exception numbers whose handlers would be ignored and cannot be replaced or
- ## hooked by Debug Agent Library.
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdExceptionsIgnoredByDebugger|0x00000000|UINT32|0x00000004
-
- ## The method to issue break point to Debug Agent Library when Loading/UnLoading image.
- ## 1: Use I/O Port 84 to issue hardware break point
- ## 2: Use INT3 to issue software break point
- gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x1|UINT8|0x00000005
diff --git a/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc b/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc
deleted file mode 100644
index 461cbf8..0000000
--- a/SourceLevelDebugPkg/SourceLevelDebugPkg.dsc
+++ /dev/null
@@ -1,67 +0,0 @@
-## @file
-#
-# Source Level Debug Package.
-#
-# 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
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-##
-
-################################################################################
-#
-# Defines Section - statements that will be processed to create a Makefile.
-#
-################################################################################
-[Defines]
- PLATFORM_NAME = SourceLevelDebugPkg
- PLATFORM_GUID = 38C85805-883F-4ee8-A854-95B966ED73AA
- PLATFORM_VERSION = 0.80
- DSC_SPECIFICATION = 0x00010005
- OUTPUT_DIRECTORY = Build/SourceLevelDebugPkg
- SUPPORTED_ARCHITECTURES = IA32|X64
- BUILD_TARGETS = DEBUG|RELEASE
- SKUID_IDENTIFIER = DEFAULT
-
-[LibraryClasses.common]
- DebugLib|MdePkg/Library/UefiDebugLibStdErr/UefiDebugLibStdErr.inf
- DebugPrintErrorLevelLib|MdePkg/Library/BaseDebugPrintErrorLevelLib/BaseDebugPrintErrorLevelLib.inf
- BaseLib|MdePkg/Library/BaseLib/BaseLib.inf
- BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
- TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf
- PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
- DebugCommunicationLib|SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf
-
-###################################################################################################
-#
-# Components Section - list of the modules and components that will be processed by compilation
-# tools and the EDK II tools to generate PE32/PE32+/Coff image files.
-#
-# Note: The EDK II DSC file is not used to specify how compiled binary images get placed
-# into firmware volume images. This section is just a list of modules to compile from
-# source into UEFI-compliant binaries.
-# It is the FDF file that contains information on combining binary files into firmware
-# volume images, whose concept is beyond UEFI and is described in PI specification.
-# Binary modules do not need to be listed in this section, as they should be
-# specified in the FDF file. For example: Shell binary (Shell_Full.efi), FAT binary (Fat.efi),
-# Logo (Logo.bmp), and etc.
-# There may also be modules listed in this section that are not required in the FDF file,
-# When a module listed here is excluded from FDF file, then UEFI-compliant binary will be
-# generated for it, but the binary will not be put into any firmware volume.
-#
-###################################################################################################
-
-[Components.common]
- SourceLevelDebugPkg/Library/DebugCommunicationLibSerialPort/DebugCommunicationLibSerialPort.inf
- SourceLevelDebugPkg/Library/DebugCommunicationLibUsb/DebugCommunicationLibUsb.inf
- SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLibDebug.inf
- SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
- SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
- SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf
-