]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. DebugAgentLib will install reserved vector table to persist vectors.
authorJeff Fan <jeff.fan@intel.com>
Fri, 22 Nov 2013 06:30:01 +0000 (06:30 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 22 Nov 2013 06:30:01 +0000 (06:30 +0000)
2. Update PeCoffExtraActionLib to detect if debug agent initialized or not by checking each IDT entry instead of whole IDT table.

Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14886 6f19259b-4bc3-4df7-8a09-765794883524

17 files changed:
SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.c
SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgent.h
SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.S
SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/AsmFuncs.asm
SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/AsmFuncs.S
SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/X64/AsmFuncs.asm
SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.c
SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgentLib.inf
SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgentLib.inf
SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c
SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.h
SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgentLib.inf
SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/Ia32/IntHandlerFuncs.c
SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.c
SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/PeCoffExtraActionLib.h
SourceLevelDebugPkg/Library/PeCoffExtraActionLibDebug/X64/IntHandlerFuncs.c

index 01711ff0853191179c42573a1854350f8ba03e94..239cf63f6b155ac864a3bc63f7ec26ac4eb1ac4d 100644 (file)
@@ -24,6 +24,114 @@ CHAR8 mErrorMsgConnectOK[]          = "HOST connection is successful!\r\n";
 CHAR8 mErrorMsgConnectFail[]        = "HOST connection is failed!\r\n";\r
 CHAR8 mWarningMsgIngoreBreakpoint[] = "Ignore break point in SMM for SMI issued during DXE debugging!\r\n";\r
 \r
+//\r
+// Vector Handoff Info list used by Debug Agent for persist\r
+//\r
+EFI_VECTOR_HANDOFF_INFO mVectorHandoffInfoDebugAgent[] = {\r
+  {\r
+    DEBUG_EXCEPT_DIVIDE_ERROR,         // Vector 0\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_DEBUG,                // Vector 1\r
+    EFI_VECTOR_HANDOFF_DO_NOT_HOOK,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_NMI,                  // Vector 2\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_BREAKPOINT,           // Vector 3\r
+    EFI_VECTOR_HANDOFF_DO_NOT_HOOK,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_OVERFLOW,             // Vector 4\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_BOUND,                // Vector 5\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_INVALID_OPCODE,       // Vector 6\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_DOUBLE_FAULT,         // Vector 8\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_INVALID_TSS,          // Vector 10\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_SEG_NOT_PRESENT,      // Vector 11\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_STACK_FAULT,          // Vector 12\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_GP_FAULT,             // Vector 13\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+    {\r
+    DEBUG_EXCEPT_PAGE_FAULT,           // Vector 14\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_FP_ERROR,             // Vector 16\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_ALIGNMENT_CHECK,      // Vector 17\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_MACHINE_CHECK,        // Vector 18\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_EXCEPT_SIMD,                 // Vector 19\r
+    EFI_VECTOR_HANDOFF_HOOK_BEFORE,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_TIMER_VECTOR,                // Vector 32\r
+    EFI_VECTOR_HANDOFF_DO_NOT_HOOK,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    DEBUG_MAILBOX_VECTOR,              // Vector 33\r
+    EFI_VECTOR_HANDOFF_DO_NOT_HOOK,\r
+    EFI_DEBUG_AGENT_GUID\r
+  },\r
+  {\r
+    0,\r
+    EFI_VECTOR_HANDOFF_LAST_ENTRY,\r
+    { 0 }\r
+  }\r
+};\r
+\r
+UINTN mVectorHandoffInfoCount = sizeof (mVectorHandoffInfoDebugAgent) / sizeof (EFI_VECTOR_HANDOFF_INFO);\r
+\r
 /**\r
   Calculate CRC16 for target data.\r
 \r
index 748d562a59f37f33a5ad4d2573da634a2b7072cb..deed55eafbab8134dfed8f98c13b8f0138c684ea 100644 (file)
@@ -16,9 +16,9 @@
 #define _DEBUG_AGENT_H_\r
 \r
 #include <Register/LocalApic.h>\r
-\r
 #include <Guid/DebugAgentGuid.h>\r
-\r
+#include <Guid/VectorHandoffTable.h>\r
+#include <Ppi/VectorHandoffInfo.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/ResetSystemLib.h>\r
@@ -41,6 +41,7 @@
 #include "DebugMp.h"\r
 #include "DebugTimer.h"\r
 #include "ArchDebugSupport.h"\r
+#include "DebugException.h"\r
 \r
 //\r
 // These macros may be already defined in DebugAgentLib.h\r
@@ -50,8 +51,8 @@
 #define DEBUG_AGENT_INIT_DXE_UNLOAD             11\r
 #define DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64    12\r
 \r
-#define DEBUG_INT1_VECTOR               1\r
-#define DEBUG_INT3_VECTOR               3\r
+#define DEBUG_INT1_VECTOR               DEBUG_EXCEPT_DEBUG\r
+#define DEBUG_INT3_VECTOR               DEBUG_EXCEPT_BREAKPOINT\r
 #define DEBUG_TIMER_VECTOR              32\r
 #define DEBUG_MAILBOX_VECTOR            33\r
 \r
@@ -67,8 +68,9 @@
 extern UINTN  Exception0Handle;\r
 extern UINTN  TimerInterruptHandle;\r
 extern UINT16 ExceptionStubHeaderSize;\r
-\r
 extern BOOLEAN mSkipBreakpoint;\r
+extern EFI_VECTOR_HANDOFF_INFO mVectorHandoffInfoDebugAgent[];\r
+extern UINTN                   mVectorHandoffInfoCount;\r
 \r
 //\r
 // CPU exception information issued by debug agent\r
index e05317aaf84cd238793223a4ee97126382d3b783..284939126f7d02009096fdeb9be7704a44b495fd 100644 (file)
@@ -27,114 +27,137 @@ ASM_GLOBAL ASM_PFX(ExceptionStubHeaderSize)
 ASM_GLOBAL ASM_PFX(TimerInterruptHandle)\r
 ASM_GLOBAL ASM_PFX(CommonEntry)\r
 \r
+.macro  AGENT_HANDLER_SIGNATURE\r
+  .byte 0x41, 0x47, 0x54, 0x48   # AGENT_HANDLER_SIGNATURE     SIGNATURE_32('A','G','T','H')\r
+.endm\r
+\r
 .data\r
 \r
 ASM_PFX(ExceptionStubHeaderSize):  .word     ASM_PFX(Exception1Handle) - ASM_PFX(Exception0Handle)\r
 \r
 .text\r
 \r
-.byte 0x41, 0x47, 0x54, 0x48  # AGENT_HANDLER_SIGNATURE     SIGNATURE_32('A','G','T','H')\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception0Handle):\r
    cli\r
    pushl %eax\r
    mov   $0, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception1Handle):\r
    cli\r
    pushl %eax\r
    mov   $1, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception2Handle):\r
    cli\r
    pushl %eax\r
    mov   $2, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception3Handle):\r
    cli\r
    pushl %eax\r
    mov   $3, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception4Handle):\r
    cli\r
    pushl %eax\r
    mov   $4, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception5Handle):\r
    cli\r
    pushl %eax\r
    mov   $5, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception6Handle):\r
    cli\r
    pushl %eax\r
    mov   $6, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception7Handle):\r
    cli\r
    pushl %eax\r
    mov   $7, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception8Handle):\r
    cli\r
    pushl %eax\r
    mov   $8, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception9Handle):\r
    cli\r
    pushl %eax\r
    mov   $9, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception10Handle):\r
    cli\r
    pushl %eax\r
    mov   $10, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception11Handle):\r
    cli\r
    pushl %eax\r
    mov   $11, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception12Handle):\r
    cli\r
    pushl %eax\r
    mov   $12, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception13Handle):\r
    cli\r
    pushl %eax\r
    mov   $13, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception14Handle):\r
    cli\r
    pushl %eax\r
    mov   $14, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception15Handle):\r
    cli\r
    pushl %eax\r
    mov   $15, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception16Handle):\r
    cli\r
    pushl %eax\r
    mov   $16, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception17Handle):\r
    cli\r
    pushl %eax\r
    mov   $17, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception18Handle):\r
    cli\r
    pushl %eax\r
    mov   $18, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception19Handle):\r
    cli\r
    pushl %eax\r
    mov   $19, %eax\r
    jmp   ASM_PFX(CommonEntry)\r
-\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(TimerInterruptHandle):\r
    cli\r
    pushl %eax\r
index c80a33ba6c877bd27cbe975f8e471b5ad32695c3..9b219fc07d57789dad9cb7c99ee1dba23b19c609 100644 (file)
@@ -32,6 +32,10 @@ InterruptProcess                 PROTO   C
 \r
 public    Exception0Handle, TimerInterruptHandle, ExceptionStubHeaderSize\r
 \r
+AGENT_HANDLER_SIGNATURE  MACRO\r
+  db   41h, 47h, 54h, 48h       ; SIGNATURE_32('A','G','T','H')\r
+ENDM\r
+\r
 .data\r
 \r
 ExceptionStubHeaderSize   DW    Exception1Handle - Exception0Handle\r
@@ -39,108 +43,127 @@ CommonEntryAddr           DD    CommonEntry
 \r
 .code\r
 \r
-db   41h, 47h, 54h, 48h  ; AGENT_HANDLER_SIGNATURE     SIGNATURE_32('A','G','T','H')\r
+AGENT_HANDLER_SIGNATURE\r
 Exception0Handle:\r
     cli\r
     push    eax\r
     mov     eax, 0\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception1Handle:\r
     cli\r
     push    eax\r
     mov     eax, 1\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception2Handle:\r
     cli\r
     push    eax\r
     mov     eax, 2\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception3Handle:\r
     cli\r
     push    eax\r
     mov     eax, 3\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception4Handle:\r
     cli\r
     push    eax\r
     mov     eax, 4\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception5Handle:\r
     cli\r
     push    eax\r
     mov     eax, 5\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception6Handle:\r
     cli\r
     push    eax\r
     mov     eax, 6\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception7Handle:\r
     cli\r
     push    eax\r
     mov     eax, 7\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception8Handle:\r
     cli\r
     push    eax\r
     mov     eax, 8\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception9Handle:\r
     cli\r
     push    eax\r
     mov     eax, 9\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception10Handle:\r
     cli\r
     push    eax\r
     mov     eax, 10\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception11Handle:\r
     cli\r
     push    eax\r
     mov     eax, 11\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception12Handle:\r
     cli\r
     push    eax\r
     mov     eax, 12\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception13Handle:\r
     cli\r
     push    eax\r
     mov     eax, 13\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception14Handle:\r
     cli\r
     push    eax\r
     mov     eax, 14\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception15Handle:\r
     cli\r
     push    eax\r
     mov     eax, 15\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception16Handle:\r
     cli\r
     push    eax\r
     mov     eax, 16\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception17Handle:\r
     cli\r
     push    eax\r
     mov     eax, 17\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception18Handle:\r
     cli\r
     push    eax\r
     mov     eax, 18\r
     jmp     dword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception19Handle:\r
     cli\r
     push    eax\r
     mov     eax, 19\r
     jmp     dword ptr [CommonEntryAddr]\r
-\r
+AGENT_HANDLER_SIGNATURE\r
 TimerInterruptHandle:\r
     cli\r
     push    eax\r
index e7c3ed74640d8dd3b1de5c6328277169b6dc6799..b742b67dba18bacdd23ec00b2551e3df12c9add1 100644 (file)
@@ -28,6 +28,10 @@ ASM_GLOBAL ASM_PFX(ExceptionStubHeaderSize)
 ASM_GLOBAL ASM_PFX(TimerInterruptHandle)\r
 ASM_GLOBAL ASM_PFX(CommonEntry)\r
 \r
+.macro  AGENT_HANDLER_SIGNATURE\r
+  .byte 0x41, 0x47, 0x54, 0x48   # AGENT_HANDLER_SIGNATURE     SIGNATURE_32('A','G','T','H')\r
+.endm\r
+\r
 .data
 \r
 ASM_PFX(ExceptionStubHeaderSize):  .word     ASM_PFX(Exception1Handle) - ASM_PFX(Exception0Handle)
@@ -35,108 +39,127 @@ ASM_PFX(ExceptionStubHeaderSize):  .word     ASM_PFX(Exception1Handle) - ASM_PFX
 \r
 .text\r
 \r
-.byte 0x41, 0x47, 0x54, 0x48  # AGENT_HANDLER_SIGNATURE     SIGNATURE_32('A','G','T','H')\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception0Handle):\r
    cli\r
    pushq %rcx\r
    mov   $0, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception1Handle):\r
    cli\r
    pushq %rcx\r
    mov   $1, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception2Handle):\r
    cli\r
    pushq %rcx\r
    mov   $2, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception3Handle):\r
    cli\r
    pushq %rcx\r
    mov   $3, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception4Handle):\r
    cli\r
    pushq %rcx\r
    mov   $4, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception5Handle):\r
    cli\r
    pushq %rcx\r
    mov   $5, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception6Handle):\r
    cli\r
    pushq %rcx\r
    mov   $6, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception7Handle):\r
    cli\r
    pushq %rcx\r
    mov   $7, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception8Handle):\r
    cli\r
    pushq %rcx\r
    mov   $8, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception9Handle):\r
    cli\r
    pushq %rcx\r
    mov   $9, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception10Handle):\r
    cli\r
    pushq %rcx\r
    mov   $10, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception11Handle):\r
    cli\r
    pushq %rcx\r
    mov   $11, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception12Handle):\r
    cli\r
    pushq %rcx\r
    mov   $12, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception13Handle):\r
    cli\r
    pushq %rcx\r
    mov   $13, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception14Handle):\r
    cli\r
    pushq %rcx\r
    mov   $14, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception15Handle):\r
    cli\r
    pushq %rcx\r
    mov   $15, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception16Handle):\r
    cli\r
    pushq %rcx\r
    mov   $16, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception17Handle):\r
    cli\r
    pushq %rcx\r
    mov   $17, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception18Handle):\r
    cli\r
    pushq %rcx\r
    mov   $18, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(Exception19Handle):\r
    cli\r
    pushq %rcx\r
    mov   $19, %rcx\r
    jmp   ASM_PFX(CommonEntry)\r
-\r
+AGENT_HANDLER_SIGNATURE\r
 ASM_PFX(TimerInterruptHandle):\r
    cli\r
    pushq %rcx\r
index 23abcc7621c7ddecfa61e7ebed49d8653f0a5409..cf8c5f0194718305c53817c197fa75bd73e47deb 100644 (file)
@@ -28,113 +28,136 @@ data SEGMENT
 \r
 public          Exception0Handle, TimerInterruptHandle, ExceptionStubHeaderSize\r
 \r
+AGENT_HANDLER_SIGNATURE  MACRO\r
+  db   41h, 47h, 54h, 48h       ; SIGNATURE_32('A','G','T','H')\r
+ENDM\r
+\r
 ExceptionStubHeaderSize        dw      Exception1Handle - Exception0Handle ;\r
 CommonEntryAddr                dq      CommonEntry ;\r
 \r
 .code\r
 \r
-db   41h, 47h, 54h, 48h  ; AGENT_HANDLER_SIGNATURE     SIGNATURE_32('A','G','T','H')\r
+AGENT_HANDLER_SIGNATURE\r
 Exception0Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 0\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE        \r
 Exception1Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 1\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception2Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 2\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception3Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 3\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception4Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 4\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception5Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 5\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception6Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 6\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception7Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 7\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception8Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 8\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception9Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 9\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception10Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 10\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception11Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 11\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception12Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 12\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception13Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 13\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception14Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 14\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception15Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 15\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception16Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 16\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception17Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 17\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception18Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 18\r
     jmp     qword ptr [CommonEntryAddr]\r
+AGENT_HANDLER_SIGNATURE\r
 Exception19Handle:\r
     cli\r
     push    rcx\r
     mov     rcx, 19\r
     jmp     qword ptr [CommonEntryAddr]\r
-\r
+AGENT_HANDLER_SIGNATURE\r
 TimerInterruptHandle:\r
     cli\r
     push    rcx\r
index d560b5235993e18a9070a910816537ac09fccc64..71130d8aaaa424f1155aa52e0031dbeeb2e86ad8 100644 (file)
@@ -57,6 +57,32 @@ InternalConstructorWorker (
   BOOLEAN                     DebugTimerInterruptState;\r
   DEBUG_AGENT_MAILBOX         *Mailbox;\r
   DEBUG_AGENT_MAILBOX         *NewMailbox;\r
+  EFI_HOB_GUID_TYPE           *GuidHob;\r
+  EFI_VECTOR_HANDOFF_INFO     *VectorHandoffInfo;\r
+\r
+  //\r
+  // Check persisted vector handoff info\r
+  //\r
+  Status = EFI_SUCCESS;\r
+  GuidHob = GetFirstGuidHob (&gEfiVectorHandoffInfoPpiGuid);\r
+  if (GuidHob != NULL && !mDxeCoreFlag) {\r
+    //\r
+    // Check if configuration table is installed or not if GUIDed HOB existed,\r
+    // only when Debug Agent is not linked by DXE Core\r
+    //\r
+    Status = EfiGetSystemConfigurationTable (&gEfiVectorHandoffTableGuid, (VOID **) &VectorHandoffInfo);\r
+  }\r
+  if (GuidHob == NULL || Status != EFI_SUCCESS) {\r
+    //\r
+    // Install configuration table for persisted vector handoff info if GUIDed HOB cannot be found or\r
+    // configuration table does not exist\r
+    //\r
+    Status = gBS->InstallConfigurationTable (&gEfiVectorHandoffTableGuid, (VOID *) &mVectorHandoffInfoDebugAgent[0]);\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "DebugAgent: Cannot install configuration table for persisted vector handoff info!\n"));\r
+      CpuDeadLoop ();\r
+    }\r
+  }\r
 \r
   //\r
   // Install EFI Serial IO protocol on debug port\r
@@ -70,7 +96,10 @@ InternalConstructorWorker (
                   EFI_SIZE_TO_PAGES (sizeof(DEBUG_AGENT_MAILBOX) + PcdGet16(PcdDebugPortHandleBufferSize)),\r
                   &Address\r
                   );\r
-  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_ERROR, "DebugAgent: Cannot install configuration table for mailbox!\n"));\r
+    CpuDeadLoop ();\r
+  }\r
 \r
   DebugTimerInterruptState = SaveAndSetDebugTimerInterrupt (FALSE);\r
 \r
@@ -91,7 +120,10 @@ InternalConstructorWorker (
   DebugTimerInterruptState = SaveAndSetDebugTimerInterrupt (DebugTimerInterruptState);\r
 \r
   Status = gBS->InstallConfigurationTable (&gEfiDebugAgentGuid, (VOID *) mMailboxPointer);\r
-  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status)) {\r
+    DEBUG ((EFI_D_ERROR, "DebugAgent: Failed to install configuration for mailbox!\n"));\r
+    CpuDeadLoop ();\r
+  }\r
 }\r
 \r
 /**\r
@@ -233,9 +265,16 @@ SetupDebugAgentEnviroment (
   AsmReadIdtr ((IA32_DESCRIPTOR *) &Idtr);\r
   IdtEntryCount = (UINT16) ((Idtr.Limit + 1) / sizeof (IA32_IDT_GATE_DESCRIPTOR));\r
   if (IdtEntryCount < 33) {\r
+    ZeroMem (&mIdtEntryTable, sizeof (IA32_IDT_GATE_DESCRIPTOR) * 33);\r
+    //\r
+    // Copy original IDT table into new one\r
+    //\r
+    CopyMem (&mIdtEntryTable, (VOID *) Idtr.Base, Idtr.Limit + 1);\r
+    //\r
+    // Load new IDT table\r
+    //\r
     Idtr.Limit = (UINT16) (sizeof (IA32_IDT_GATE_DESCRIPTOR) * 33 - 1);\r
     Idtr.Base  = (UINTN) &mIdtEntryTable;\r
-    ZeroMem (&mIdtEntryTable, Idtr.Limit + 1);\r
     AsmWriteIdtr ((IA32_DESCRIPTOR *) &Idtr);\r
   }\r
 \r
index cc9b48191daadcf3f2a25220f2012efbc1c0028a..e5a510d4b38a402bd9d564ab828bb21a67145a00 100644 (file)
 [Guids]\r
   gEfiDebugAgentGuid                            ## PRODUCES ## Configuration Table\r
   gEfiDebugAgentGuid                            ## CONSUMES ## HOB\r
-\r
+  gEfiVectorHandoffTableGuid                    ## SOMETIMES_PRODUCES ## Configuration Table\r
+  \r
+[Ppis]\r
+  gEfiVectorHandoffInfoPpiGuid                  ## UNDEFINED\r
+  \r
 [Protocols]\r
   gEfiSerialIoProtocolGuid                      ## PRODUCES\r
   gEfiDevicePathProtocolGuid                    ## PRODUCES \r
index d036880c1d53dbcfeefc196b7d4bc89a62eb50b3..0388807697081ceab0e228beaad0866727810694 100644 (file)
 \r
 BOOLEAN  mSkipBreakpoint = FALSE;\r
 \r
+\r
+EFI_PEI_VECTOR_HANDOFF_INFO_PPI mVectorHandoffInfoPpi = {\r
+  &mVectorHandoffInfoDebugAgent[0]\r
+};\r
+\r
+//\r
+// Ppis to be installed\r
+//\r
+EFI_PEI_PPI_DESCRIPTOR           mVectorHandoffInfoPpiList[] = { \r
+  {\r
+    (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+    &gEfiVectorHandoffInfoPpiGuid,\r
+    &mVectorHandoffInfoPpi\r
+  }\r
+};\r
+\r
 EFI_PEI_NOTIFY_DESCRIPTOR mMemoryDiscoveredNotifyList[1] = {\r
   {\r
     (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
@@ -408,7 +424,14 @@ InitializeDebugAgent (
       //\r
       TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);\r
     }\r
-\r
+    //\r
+    // Install Vector Handoff Info PPI to persist vectors used by Debug Agent\r
+    //\r
+    Status = PeiServicesInstallPpi (&mVectorHandoffInfoPpiList[0]);\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "DebugAgent: Failed to install Vector Handoff Info PPI!\n"));\r
+      CpuDeadLoop ();\r
+    }\r
     //\r
     // Fix up Debug Port handle address and mailbox address\r
     //\r
@@ -437,7 +460,10 @@ InitializeDebugAgent (
                  EFI_SIZE_TO_PAGES (sizeof(DEBUG_AGENT_MAILBOX) + PcdGet16(PcdDebugPortHandleBufferSize)),\r
                  &Address\r
                  );\r
-      ASSERT_EFI_ERROR (Status);\r
+      if (EFI_ERROR (Status)) {\r
+        DEBUG ((EFI_D_ERROR, "DebugAgent: Failed to allocate pages!\n"));\r
+        CpuDeadLoop ();\r
+      }\r
       NewMailbox = (DEBUG_AGENT_MAILBOX *) (UINTN) Address;\r
       //\r
       // Copy Mailbox and Debug Port Handle buffer to new location in ACPI NVS memory, because original Mailbox\r
@@ -477,6 +503,14 @@ InitializeDebugAgent (
       break;\r
     }\r
     //\r
+    // Install Vector Handoff Info PPI to persist vectors used by Debug Agent\r
+    //\r
+    Status = PeiServicesInstallPpi (&mVectorHandoffInfoPpiList[0]);\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "DebugAgent: Failed to install Vector Handoff Info PPI!\n"));\r
+      CpuDeadLoop ();\r
+    }\r
+    //\r
     // Set up IDT entries\r
     //\r
     InitializeDebugIdt ();\r
@@ -505,7 +539,10 @@ InitializeDebugAgent (
     // If memery has been ready, the callback funtion will be invoked immediately\r
     //\r
     Status = PeiServicesNotifyPpi (&mMemoryDiscoveredNotifyList[0]);\r
-    ASSERT_EFI_ERROR (Status);\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "DebugAgent: Failed to register memory discovered callback function!\n"));\r
+      CpuDeadLoop ();\r
+    }\r
     //\r
     // Set HOB check flag if memory has not been ready yet\r
     //\r
index b81fc16d17a62eda3758964ca0c22900f0f13d19..5204abca525d30b19582bcd88049780250f0bb33 100644 (file)
@@ -77,6 +77,7 @@
 \r
 [Ppis]\r
   gEfiPeiMemoryDiscoveredPpiGuid\r
+  gEfiVectorHandoffInfoPpiGuid                  ## PRODUCES\r
 \r
 [Guids]\r
   gEfiDebugAgentGuid                            ## PRODUCES ## HOB\r
index 145fee0fa5d188bbbd89717a021fec9fefb1b3e9..651737e5e7b2195b745851b247402f930898dc44 100644 (file)
@@ -192,6 +192,19 @@ InitializeDebugAgent (
 \r
   switch (InitFlag) {\r
   case DEBUG_AGENT_INIT_SMM:\r
+    //\r
+    // Install configuration table for persisted vector handoff info\r
+    //\r
+    Status = gSmst->SmmInstallConfigurationTable (\r
+                      gSmst,\r
+                      &gEfiVectorHandoffTableGuid,\r
+                      (VOID *) &mVectorHandoffInfoDebugAgent[0],\r
+                      sizeof (EFI_VECTOR_HANDOFF_INFO) * mVectorHandoffInfoCount\r
+                      );\r
+    if (EFI_ERROR (Status)) {\r
+      DEBUG ((EFI_D_ERROR, "DebugAgent: Cannot install configuration table for persisted vector handoff info!\n"));\r
+      CpuDeadLoop ();\r
+    }\r
     //\r
     // Check if Debug Agent initialized in DXE phase\r
     //\r
@@ -210,7 +223,7 @@ InitializeDebugAgent (
       break;\r
     }\r
     //\r
-    // Debug Agent was not initialized before, uset the local mailbox.\r
+    // Debug Agent was not initialized before, use the local mailbox.\r
     //\r
     ZeroMem (&mLocalMailbox, sizeof (DEBUG_AGENT_MAILBOX));\r
     Mailbox = &mLocalMailbox;\r
index ccb55f830d38419e21a3ec2af9900a43d75b79d3..f30a892e2106bbf852a0ed8014d767bf462e537f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Header file for Smm Debug Agent Library instance.\r
 \r
-  Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -18,6 +18,7 @@
 #include <PiDxe.h>\r
 \r
 #include <Library/UefiLib.h>\r
+#include <Library/SmmServicesTableLib.h>\r
 \r
 #include "DebugAgent.h"\r
 \r
index 9ed314d407c47fbf1590d583cc92e4564ee06719..2878c3189f91c4c05b7b1fc2136cb1b4d29e7403 100644 (file)
   PrintLib\r
   PeCoffExtraActionLib\r
   PeCoffGetEntryPointLib\r
+  SmmServicesTableLib\r
 \r
 [Guids]\r
   gEfiDebugAgentGuid                            ## CONSUMES ## Configuration Table\r
+  gEfiVectorHandoffTableGuid                    ## SOMETIMES_PRODUCES ## Configuration Table\r
 \r
 [Pcd]\r
   gEfiMdePkgTokenSpaceGuid.PcdFSBClock                                             ## CONSUMES\r
index b2d4c37a9d646c602fd13f5785b75cc11395731d..ccf3fb1842acfe85ab68df4e282feb22d3737d0b 100644 (file)
@@ -18,6 +18,7 @@
   Read IDT entry to check if IDT entries are setup by Debug Agent.\r
 \r
   @param[in]  IdtDescriptor      Pointer to IDT Descriptor.\r
+  @param[in]  InterruptType      Interrupt type.\r
 \r
   @retval  TRUE     IDT entries were setup by Debug Agent.\r
   @retval  FALSE    IDT entries were not setuo by Debug Agent.\r
@@ -25,7 +26,8 @@
 **/\r
 BOOLEAN \r
 CheckDebugAgentHandler (\r
-  IN  IA32_DESCRIPTOR            *IdtDescriptor\r
+  IN  IA32_DESCRIPTOR            *IdtDescriptor,\r
+  IN  UINTN                      InterruptType\r
   )\r
 {\r
   IA32_IDT_GATE_DESCRIPTOR   *IdtEntry;\r
@@ -36,8 +38,9 @@ CheckDebugAgentHandler (
     return FALSE;\r
   }\r
 \r
-  InterruptHandler = IdtEntry[0].Bits.OffsetLow + (IdtEntry[0].Bits.OffsetHigh << 16);\r
-  if (InterruptHandler >= 4 &&  *(UINT32 *)(InterruptHandler - 4) == AGENT_HANDLER_SIGNATURE) {\r
+  InterruptHandler = IdtEntry[InterruptType].Bits.OffsetLow +\r
+                    (IdtEntry[InterruptType].Bits.OffsetHigh << 16);\r
+  if (InterruptHandler >= sizeof (UINT32) &&  *(UINT32 *)(InterruptHandler - sizeof (UINT32)) == AGENT_HANDLER_SIGNATURE) {\r
     return TRUE;\r
   } else {\r
     return FALSE;\r
index c28d7930a30afd3aa662133222f17e8327c946a4..9bf76bfb2219fa294ac0f50522c4c330d89a15d6 100644 (file)
@@ -80,18 +80,21 @@ PeCoffLoaderExtraActionCommon (
   IdtEntryHooked  = FALSE;\r
   LoadImageMethod = PcdGet8 (PcdDebugLoadImageMethod);\r
   AsmReadIdtr (&IdtDescriptor);\r
-  if (!CheckDebugAgentHandler (&IdtDescriptor)) {\r
-    if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3) {\r
+  if (LoadImageMethod == DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3) {\r
+    if (!CheckDebugAgentHandler (&IdtDescriptor, SOFT_INT_VECTOR_NUM)) {\r
       //\r
       // Do not trigger INT3 if Debug Agent did not setup IDT entries.\r
       //\r
       return;\r
     }\r
-    //\r
-    // Save and update IDT entry for INT1\r
-    //\r
-    SaveAndUpdateIdtEntry1 (&IdtDescriptor, &OriginalIdtEntry);\r
-    IdtEntryHooked = TRUE;\r
+  } else {\r
+    if (!CheckDebugAgentHandler (&IdtDescriptor, IO_HW_BREAKPOINT_VECTOR_NUM)) {\r
+      //\r
+      // Save and update IDT entry for INT1\r
+      //\r
+      SaveAndUpdateIdtEntry1 (&IdtDescriptor, &OriginalIdtEntry);\r
+      IdtEntryHooked = TRUE;\r
+    }\r
   }\r
   \r
   //\r
index 36aebf16d1a302d0cfd41c8a655ad0d0e67d09a4..3f919287e80c5549e8718f60e08ee027492a3d39 100644 (file)
 #define DEBUG_LOAD_IMAGE_METHOD_IO_HW_BREAKPOINT    1\r
 #define DEBUG_LOAD_IMAGE_METHOD_SOFT_INT3           2\r
 \r
+#define IO_HW_BREAKPOINT_VECTOR_NUM                 1\r
+#define SOFT_INT_VECTOR_NUM                         3\r
+\r
 extern UINTN  AsmInterruptHandle;\r
 \r
 /**\r
   Read IDT entry to check if IDT entries are setup by Debug Agent.\r
 \r
   @param[in]  IdtDescriptor      Pointer to IDT Descriptor.\r
+  @param[in]  InterruptType      Interrupt type.\r
 \r
   @retval  TRUE     IDT entries were setup by Debug Agent.\r
   @retval  FALSE    IDT entries were not setuo by Debug Agent.\r
@@ -41,7 +45,8 @@ extern UINTN  AsmInterruptHandle;
 **/\r
 BOOLEAN \r
 CheckDebugAgentHandler (\r
-  IN  IA32_DESCRIPTOR            *IdtDescriptor\r
+  IN  IA32_DESCRIPTOR            *IdtDescriptor,\r
+  IN  UINTN                      InterruptType\r
   );\r
 \r
 /**\r
index c9041de765c7e9f621c559bba2683b563957df36..5431187d0674c6eda59f8e17b67e13bd9c8cef34 100644 (file)
@@ -18,6 +18,7 @@
   Read IDT entry to check if IDT entries are setup by Debug Agent.\r
 \r
   @param[in]  IdtDescriptor      Pointer to IDT Descriptor.\r
+  @param[in]  InterruptType      Interrupt type.\r
 \r
   @retval  TRUE     IDT entries were setup by Debug Agent.\r
   @retval  FALSE    IDT entries were not setuo by Debug Agent.\r
@@ -25,7 +26,8 @@
 **/\r
 BOOLEAN \r
 CheckDebugAgentHandler (\r
-  IN  IA32_DESCRIPTOR            *IdtDescriptor\r
+  IN  IA32_DESCRIPTOR            *IdtDescriptor,\r
+  IN  UINTN                      InterruptType\r
   )\r
 {\r
   IA32_IDT_GATE_DESCRIPTOR   *IdtEntry;\r
@@ -36,9 +38,10 @@ CheckDebugAgentHandler (
     return FALSE;\r
   }\r
 \r
-  InterruptHandler = IdtEntry[0].Bits.OffsetLow + (((UINTN)IdtEntry[0].Bits.OffsetHigh) << 16) + \r
-                     (((UINTN)IdtEntry[0].Bits.OffsetUpper) << 32);\r
-  if (InterruptHandler >= 4 &&  *(UINT32 *)(InterruptHandler - 4) == AGENT_HANDLER_SIGNATURE) {\r
+  InterruptHandler = IdtEntry[InterruptType].Bits.OffsetLow +\r
+                    (((UINTN)IdtEntry[InterruptType].Bits.OffsetHigh) << 16) + \r
+                    (((UINTN)IdtEntry[InterruptType].Bits.OffsetUpper) << 32);\r
+  if (InterruptHandler >= sizeof (UINT32) &&  *(UINT32 *)(InterruptHandler - sizeof (UINT32)) == AGENT_HANDLER_SIGNATURE) {\r
     return TRUE;\r
   } else {\r
     return FALSE;\r