]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add InitFlag member in DEBUG_AGENT_PHASE2_CONTEXT to pass into InitializeDebugAgentPh...
authorJeff Fan <jeff.fan@intel.com>
Wed, 4 Dec 2013 07:07:10 +0000 (07:07 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 4 Dec 2013 07:07:10 +0000 (07:07 +0000)
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@14929 6f19259b-4bc3-4df7-8a09-765794883524

SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.h

index 0388807697081ceab0e228beaad0866727810694..a3f91d3358085b667037cae5e5579c08026e7c90 100644 (file)
@@ -402,6 +402,7 @@ InitializeDebugAgent (
 \r
     InitializeDebugTimer ();\r
 \r
+    Phase2Context.InitFlag = InitFlag;\r
     Phase2Context.Context  = Context;\r
     Phase2Context.Function = Function;\r
     DebugPortInitialize ((VOID *) &Phase2Context, InitializeDebugAgentPhase2);\r
@@ -487,14 +488,13 @@ InitializeDebugAgent (
     // Update IDT entry to save the location saved mailbox pointer\r
     //\r
     SetLocationSavedMailboxPointerInIdtEntry (MailboxLocationPointer);\r
-    //\r
-    // Enable CPU interrupts so debug timer interrupts can be delivered\r
-    //\r
-    EnableInterrupts ();\r
-\r
     break;\r
 \r
   case DEBUG_AGENT_INIT_PEI:\r
+    if (Context == NULL) {\r
+      DEBUG ((EFI_D_ERROR, "DebugAgent: Input parameter Context cannot be NULL!\n"));\r
+      CpuDeadLoop ();\r
+    }\r
     //\r
     // Check if Debug Agent has initialized before\r
     //\r
@@ -550,6 +550,7 @@ InitializeDebugAgent (
       SetDebugFlag (DEBUG_AGENT_FLAG_CHECK_MAILBOX_IN_HOB, 1);\r
     }\r
 \r
+    Phase2Context.InitFlag = InitFlag;\r
     Phase2Context.Context  = Context;\r
     Phase2Context.Function = Function;\r
     DebugPortInitialize ((VOID *) &Phase2Context, InitializeDebugAgentPhase2);\r
@@ -598,6 +599,9 @@ InitializeDebugAgent (
     break;\r
   }\r
 \r
+  //\r
+  // Enable CPU interrupts so debug timer interrupts can be delivered\r
+  //\r
   EnableInterrupts ();\r
 \r
   //\r
@@ -606,6 +610,12 @@ InitializeDebugAgent (
   if (Function != NULL) {\r
     Function (Context);\r
   }\r
+  //\r
+  // Set return status for DEBUG_AGENT_INIT_PEI\r
+  //\r
+  if (InitFlag == DEBUG_AGENT_INIT_PEI) {\r
+    *(EFI_STATUS *)Context = EFI_SUCCESS;\r
+  }\r
 }\r
 \r
 /**\r
@@ -635,7 +645,7 @@ InitializeDebugAgentPhase2 (
   MailboxLocation = GetLocationSavedMailboxPointerInIdtEntry ();\r
   Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);\r
   BufferSize = PcdGet16(PcdDebugPortHandleBufferSize);\r
-  if (Phase2Context->Function == NULL && DebugPortHandle != NULL && BufferSize != 0) {\r
+  if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PEI) {\r
     NewDebugPortHandle = (UINT64)(UINTN)AllocateCopyPool (BufferSize, DebugPortHandle);\r
   } else {\r
     NewDebugPortHandle = (UINT64)(UINTN)DebugPortHandle;\r
@@ -647,25 +657,23 @@ InitializeDebugAgentPhase2 (
   //\r
   TriggerSoftInterrupt (SYSTEM_RESET_SIGNATURE);\r
 \r
-  //\r
-  // If Temporary RAM region is below 128 MB, then send message to \r
-  // host to disable low memory filtering.\r
-  //\r
-  SecCoreData = (EFI_SEC_PEI_HAND_OFF *)Phase2Context->Context;\r
-  if ((UINTN)SecCoreData->TemporaryRamBase < BASE_128MB && IsHostAttached ()) {\r
-    SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);\r
-    TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);\r
-  }\r
-\r
-  //\r
-  // Enable CPU interrupts so debug timer interrupts can be delivered\r
-  //\r
-  EnableInterrupts ();\r
-\r
-  //\r
-  // Call continuation function if it is not NULL.\r
-  //\r
-  if (Phase2Context->Function != NULL) {\r
+  if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PREMEM_SEC) {\r
+    //\r
+    // If Temporary RAM region is below 128 MB, then send message to \r
+    // host to disable low memory filtering.\r
+    //\r
+    SecCoreData = (EFI_SEC_PEI_HAND_OFF *)Phase2Context->Context;\r
+    if ((UINTN)SecCoreData->TemporaryRamBase < BASE_128MB && IsHostAttached ()) {\r
+      SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);\r
+      TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);\r
+    }\r
+    //\r
+    // Enable CPU interrupts so debug timer interrupts can be delivered\r
+    //\r
+    EnableInterrupts ();\r
+    //\r
+    // Call continuation function if it is not NULL.\r
+    //\r
     Phase2Context->Function (Phase2Context->Context);\r
   }\r
 }\r
index 68bfbf7cab12f4f38354acd3c7c1c061f7ef1a10..a0687fa173a166319239b35924cc9cc10ef5c214 100644 (file)
@@ -22,6 +22,7 @@
 #include "DebugAgent.h"\r
 \r
 typedef struct {\r
+  UINT32                  InitFlag;\r
   VOID                    *Context;\r
   DEBUG_AGENT_CONTINUE    Function;\r
 } DEBUG_AGENT_PHASE2_CONTEXT;\r