]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
SourceLevelDebugPkg: Fix typos in comments
[mirror_edk2.git] / SourceLevelDebugPkg / Library / DebugAgent / SecPeiDebugAgent / SecPeiDebugAgentLib.c
index ea757423d13f9c1244cee5c7793e75a9315873b8..128c69f60cb24901724c6b642a1cb46b90047e98 100644 (file)
@@ -343,7 +343,7 @@ DebugAgentCallbackMemoryDiscoveredPpi (
   function and pass it into InitializeDebugAgent(). InitializeDebugAgent() is\r
   responsible to invoke the passing-in function at the end of InitializeDebugAgent().\r
 \r
-  If the parameter Function is not NULL, Debug Agent Libary instance will invoke it by\r
+  If the parameter Function is not NULL, Debug Agent Library instance will invoke it by\r
   passing in the Context to be its parameter.\r
 \r
   If Function() is NULL, Debug Agent Library instance will return after setup debug\r
@@ -376,8 +376,12 @@ InitializeDebugAgent (
   UINT64                           *MailboxLocationPointer;\r
   EFI_PHYSICAL_ADDRESS             Address;\r
   UINT32                           DebugTimerFrequency;\r
+  BOOLEAN                          CpuInterruptState;\r
 \r
-  DisableInterrupts ();\r
+  //\r
+  // Disable interrupts and save current interrupt state\r
+  //\r
+  CpuInterruptState = SaveAndDisableInterrupts();\r
 \r
   switch (InitFlag) {\r
 \r
@@ -611,15 +615,22 @@ InitializeDebugAgent (
     break;\r
   }\r
 \r
-  //\r
-  // Enable Debug Timer interrupt\r
-  //\r
-  SaveAndSetDebugTimerInterrupt (TRUE);\r
-  //\r
-  // Enable CPU interrupts so debug timer interrupts can be delivered\r
-  //\r
-  EnableInterrupts ();\r
-\r
+  if (InitFlag == DEBUG_AGENT_INIT_POSTMEM_SEC) {\r
+    //\r
+    // Restore CPU Interrupt state and keep debug timer interrupt state as is\r
+    // in DEBUG_AGENT_INIT_POSTMEM_SEC case\r
+    //\r
+    SetInterruptState (CpuInterruptState);\r
+  } else {\r
+    //\r
+    // Enable Debug Timer interrupt\r
+    //\r
+    SaveAndSetDebugTimerInterrupt (TRUE);\r
+    //\r
+    // Enable CPU interrupts so debug timer interrupts can be delivered\r
+    //\r
+    EnableInterrupts ();\r
+  }\r
   //\r
   // If Function is not NULL, invoke it always whatever debug agent was initialized sucesssfully or not.\r
   //\r
@@ -637,10 +648,10 @@ InitializeDebugAgent (
 /**\r
   Caller provided function to be invoked at the end of DebugPortInitialize().\r
 \r
-  Refer to the descrption for DebugPortInitialize() for more details.\r
+  Refer to the description for DebugPortInitialize() for more details.\r
 \r
   @param[in] Context           The first input argument of DebugPortInitialize().\r
-  @param[in] DebugPortHandle   Debug port handle created by Debug Communication Libary.\r
+  @param[in] DebugPortHandle   Debug port handle created by Debug Communication Library.\r
 \r
 **/\r
 VOID\r