]> git.proxmox.com Git - mirror_edk2.git/commitdiff
SourceLevelDebugPkg/DxeDebugAgent: Initialize Local APIC Timer early
authorJeff Fan <jeff.fan@intel.com>
Mon, 18 May 2015 01:18:42 +0000 (01:18 +0000)
committervanjeff <vanjeff@Edk2>
Mon, 18 May 2015 01:18:42 +0000 (01:18 +0000)
Now Debug Agent library uses Local APIC Timer to implement time-out mechanism.
But it does not initialize Local APIC Timer before transfer data with HOST.
This fix is to move Local APIC Timer initialization to
SetupDebugAgentEnvironment().
This fix also updates function header and fixed one typo of
SetupDebugAgentEnvironment() name.

Contributed-under: TianoCore Contribution Agreement 1.0
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@17457 6f19259b-4bc3-4df7-8a09-765794883524

SourceLevelDebugPkg/Library/DebugAgent/DxeDebugAgent/DxeDebugAgentLib.c

index 601c5e8bedea0703cc0b6b032d4397dfe6d5d7c9..f1cb7d5601b2e74f74cf4e6f14092c7dd0c8d188 100644 (file)
@@ -235,19 +235,24 @@ GetDebugPortHandle (
 }\r
 \r
 /**\r
 }\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
 \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
   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
 \r
   if (mMultiProcessorDebugSupport) {\r
     InitializeSpinLock (&mDebugMpContext.MpContextSpinLock);\r
@@ -298,6 +303,11 @@ SetupDebugAgentEnviroment (
     mMailboxPointer = &mMailbox;\r
   }\r
 \r
     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
   //\r
   // Initialize debug communication port\r
   //\r
@@ -326,7 +336,7 @@ SetupDebugAgentEnviroment (
 /**\r
   Initialize debug agent.\r
 \r
 /**\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
 \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
   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
 \r
   if (InitFlag == DEBUG_AGENT_INIT_DXE_AP) {\r
     //\r
@@ -410,14 +419,9 @@ InitializeDebugAgent (
       Mailbox = GetMailboxFromHob (HobList);\r
     }\r
     //\r
       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
     //\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
     //\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
     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
     //\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
     //\r
     // Enable interrupt to receive Debug Timer interrupt\r
     //\r
@@ -533,9 +532,9 @@ InitializeDebugAgent (
     //\r
     mMailboxPointer = Mailbox;\r
     //\r
     //\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
     //\r
-    SetupDebugAgentEnviroment (Mailbox);\r
+    SetupDebugAgentEnvironment (Mailbox);\r
     //\r
     // Disable interrupt\r
     //\r
     //\r
     // Disable interrupt\r
     //\r