]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/Ia32/ArchDebugSupport.c
SourceLevelDebugPkg/DebugAgent: Support IA32 processors without DE or FXSAVE/FXRESTOR
[mirror_edk2.git] / SourceLevelDebugPkg / Library / DebugAgent / DebugAgentCommon / Ia32 / ArchDebugSupport.c
index 9bd8fca6b6e361b53e2d1d0e0e8967daf8588721..1aef63f206fd33a5ee109f297d0f856f510d2636 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Supporting functions for IA32 architecture.\r
 \r
-  Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2015, 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
@@ -28,6 +28,7 @@ InitializeDebugIdt (
   IA32_DESCRIPTOR            IdtDescriptor;\r
   UINTN                      Index;\r
   UINT16                     CodeSegment;\r
+  UINT32                     RegEdx;\r
 \r
   AsmReadIdtr (&IdtDescriptor);\r
 \r
@@ -59,9 +60,13 @@ InitializeDebugIdt (
   IdtEntry[DEBUG_TIMER_VECTOR].Bits.GateType   = IA32_IDT_GATE_TYPE_INTERRUPT_32;\r
   \r
   //\r
+  // If the CPU supports Debug Extensions(CPUID:01 EDX:BIT2), then \r
   // Set DE flag in CR4 to enable IO breakpoint\r
   //\r
-  AsmWriteCr4 (AsmReadCr4 () | BIT3);\r
+  AsmCpuid (1, NULL, NULL, NULL, &RegEdx);\r
+  if ((RegEdx & BIT2) != 0) {\r
+    AsmWriteCr4 (AsmReadCr4 () | BIT3);\r
+  }\r
 }\r
 \r
 /**\r