]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.c
SourceLevelDebugPkg/DxeDebugAgent: Initialize Local APIC Timer early
[mirror_edk2.git] / SourceLevelDebugPkg / Library / DebugAgent / DxeDebugAgent / DxeDebugAgentLib.c
index 601c5e8bedea0703cc0b6b032d4397dfe6d5d7c9..f1cb7d5601b2e74f74cf4e6f14092c7dd0c8d188 100644 (file)
@@ -235,19 +235,24 @@ GetDebugPortHandle (
 }\r
 \r
 /**\r
-  Worker function to setup IDT table and initialize the IDT entries.\r
+  Worker function to set up Debug Agent environment.\r
+\r
+  This function will set up IDT table and initialize the IDT entries and \r
+  initialize CPU LOCAL APIC timer.\r
+  It also tries to connect HOST if Debug Agent was not initialized before.\r
 \r
   @param[in] Mailbox        Pointer to Mailbox.\r
 \r
 **/\r
 VOID\r
-SetupDebugAgentEnviroment (\r
+SetupDebugAgentEnvironment (\r
   IN DEBUG_AGENT_MAILBOX       *Mailbox\r
   )\r
 {\r
   IA32_DESCRIPTOR              Idtr;\r
   UINT16                       IdtEntryCount;\r
   UINT64                       DebugPortHandle;\r
+  UINT32                       DebugTimerFrequency;\r
 \r
   if (mMultiProcessorDebugSupport) {\r
     InitializeSpinLock (&mDebugMpContext.MpContextSpinLock);\r
@@ -298,6 +303,11 @@ SetupDebugAgentEnviroment (
     mMailboxPointer = &mMailbox;\r
   }\r
 \r
+  //\r
+  // Initialize Debug Timer hardware and save its initial count and frequency\r
+  //\r
+  mDebugMpContext.DebugTimerInitCount = InitializeDebugTimer (&DebugTimerFrequency);\r
+  UpdateMailboxContent (mMailboxPointer, DEBUG_MAILBOX_DEBUG_TIMER_FREQUENCY, DebugTimerFrequency);\r
   //\r
   // Initialize debug communication port\r
   //\r
@@ -326,7 +336,7 @@ SetupDebugAgentEnviroment (
 /**\r
   Initialize debug agent.\r
 \r
-  This function is used to set up debug enviroment for DXE phase.\r
+  This function is used to set up debug environment for DXE phase.\r
 \r
   If this function is called by DXE Core, Context must be the pointer\r
   to HOB list which will be used to get GUIDed HOB. It will enable\r
@@ -355,7 +365,6 @@ InitializeDebugAgent (
   IA32_DESCRIPTOR              IdtDescriptor;\r
   IA32_DESCRIPTOR              *Ia32Idtr;\r
   IA32_IDT_ENTRY               *Ia32IdtEntry;\r
-  UINT32                       DebugTimerFrequency;\r
 \r
   if (InitFlag == DEBUG_AGENT_INIT_DXE_AP) {\r
     //\r
@@ -410,14 +419,9 @@ InitializeDebugAgent (
       Mailbox = GetMailboxFromHob (HobList);\r
     }\r
     //\r
-    // Set up IDT table and prepare for IDT entries\r
+    // Set up Debug Agent Environment and try to connect HOST if required\r
     //\r
-    SetupDebugAgentEnviroment (Mailbox);\r
-    //\r
-    // Initialize Debug Timer hardware and save its initial count and frequency\r
-    //\r
-    mDebugMpContext.DebugTimerInitCount = InitializeDebugTimer (&DebugTimerFrequency);\r
-    UpdateMailboxContent (mMailboxPointer, DEBUG_MAILBOX_DEBUG_TIMER_FREQUENCY, DebugTimerFrequency);\r
+    SetupDebugAgentEnvironment (Mailbox);\r
     //\r
     // For DEBUG_AGENT_INIT_S3, needn't to install configuration table and EFI Serial IO protocol\r
     // For DEBUG_AGENT_INIT_DXE_CORE, InternalConstructorWorker() will invoked in Constructor()\r
@@ -503,14 +507,9 @@ InitializeDebugAgent (
     HobList = Context;\r
     Mailbox = GetMailboxFromHob (HobList);\r
     //\r
-    // Set up IDT table and prepare for IDT entries\r
-    //\r
-    SetupDebugAgentEnviroment (Mailbox);\r
-    //\r
-    // Initialize Debug Timer hardware and save its initial count and frequency\r
+    // Set up Debug Agent Environment and try to connect HOST if required\r
     //\r
-    mDebugMpContext.DebugTimerInitCount = InitializeDebugTimer (&DebugTimerFrequency);\r
-    UpdateMailboxContent (mMailboxPointer, DEBUG_MAILBOX_DEBUG_TIMER_FREQUENCY, DebugTimerFrequency);\r
+    SetupDebugAgentEnvironment (Mailbox);\r
     //\r
     // Enable interrupt to receive Debug Timer interrupt\r
     //\r
@@ -533,9 +532,9 @@ InitializeDebugAgent (
     //\r
     mMailboxPointer = Mailbox;\r
     //\r
-    // Set up IDT table and prepare for IDT entries\r
+    // Set up Debug Agent Environment and try to connect HOST if required\r
     //\r
-    SetupDebugAgentEnviroment (Mailbox);\r
+    SetupDebugAgentEnvironment (Mailbox);\r
     //\r
     // Disable interrupt\r
     //\r