]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.c
SourceLevelDebugPkg: Refine casting expression result to bigger size
[mirror_edk2.git] / SourceLevelDebugPkg / Library / DebugAgent / DxeDebugAgent / DxeDebugAgentLib.c
index aaf342e0ba85f9d3bb952e4a2a3d68e3a89824be..c74a1f6be3fb097277a24111e9a7ace3581dfa40 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Debug Agent library implementition for Dxe Core and Dxr modules.\r
 \r
-  Copyright (c) 2010 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2010 - 2017, 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
@@ -365,8 +365,19 @@ InitializeDebugAgent (
   IA32_DESCRIPTOR              IdtDescriptor;\r
   IA32_DESCRIPTOR              *Ia32Idtr;\r
   IA32_IDT_ENTRY               *Ia32IdtEntry;\r
+  BOOLEAN                      PeriodicMode;\r
+  UINTN                        TimerCycle;\r
 \r
   if (InitFlag == DEBUG_AGENT_INIT_DXE_AP) {\r
+    //\r
+    // Check if CPU APIC Timer is working, otherwise initialize it.\r
+    //\r
+    InitializeLocalApicSoftwareEnable (TRUE);\r
+    GetApicTimerState (NULL, &PeriodicMode, NULL);\r
+    TimerCycle = GetApicTimerInitCount ();\r
+    if (!PeriodicMode || TimerCycle == 0) {\r
+      InitializeDebugTimer (NULL, FALSE);\r
+    }\r
     //\r
     // Invoked by AP, enable interrupt to let AP could receive IPI from other processors\r
     //\r
@@ -428,6 +439,10 @@ InitializeDebugAgent (
     //\r
     InternalConstructorWorker ();\r
     //\r
+    // Enable Debug Timer interrupt\r
+    //\r
+    SaveAndSetDebugTimerInterrupt (TRUE);\r
+    //\r
     // Enable interrupt to receive Debug Timer interrupt\r
     //\r
     EnableInterrupts ();\r
@@ -482,6 +497,10 @@ InitializeDebugAgent (
     //\r
     SetupDebugAgentEnvironment (Mailbox);\r
     //\r
+    // Enable Debug Timer interrupt\r
+    //\r
+    SaveAndSetDebugTimerInterrupt (TRUE);\r
+    //\r
     // Enable interrupt to receive Debug Timer interrupt\r
     //\r
     EnableInterrupts ();\r
@@ -493,8 +512,8 @@ InitializeDebugAgent (
     if (Context != NULL) {\r
       Ia32Idtr =  (IA32_DESCRIPTOR *) Context;\r
       Ia32IdtEntry = (IA32_IDT_ENTRY *)(Ia32Idtr->Base);\r
-      MailboxLocation = (UINT64 *) (UINTN) (Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetLow +\r
-                                           (Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetHigh << 16));\r
+      MailboxLocation = (UINT64 *) ((UINTN) Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetLow +\r
+                                   ((UINTN) Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetHigh << 16));\r
       Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);\r
       VerifyMailboxChecksum (Mailbox);\r
     }\r