Revision: 14929
          http://sourceforge.net/p/edk2/code/14929
Author:   vanjeff
Date:     2013-12-04 07:07:10 +0000 (Wed, 04 Dec 2013)
Log Message:
-----------
Add InitFlag member in DEBUG_AGENT_PHASE2_CONTEXT to pass into 
InitializeDebugAgentPhase2().

Signed-off-by: Jeff Fan <[email protected]>
Reviewed-by: Ruiyu Ni <[email protected]>

Modified Paths:
--------------
    
trunk/edk2/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
    
trunk/edk2/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.h

Modified: 
trunk/edk2/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
===================================================================
--- 
trunk/edk2/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
    2013-12-03 07:10:56 UTC (rev 14928)
+++ 
trunk/edk2/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
    2013-12-04 07:07:10 UTC (rev 14929)
@@ -402,6 +402,7 @@
 
     InitializeDebugTimer ();
 
+    Phase2Context.InitFlag = InitFlag;
     Phase2Context.Context  = Context;
     Phase2Context.Function = Function;
     DebugPortInitialize ((VOID *) &Phase2Context, InitializeDebugAgentPhase2);
@@ -487,14 +488,13 @@
     // Update IDT entry to save the location saved mailbox pointer
     //
     SetLocationSavedMailboxPointerInIdtEntry (MailboxLocationPointer);
-    //
-    // Enable CPU interrupts so debug timer interrupts can be delivered
-    //
-    EnableInterrupts ();
-
     break;
 
   case DEBUG_AGENT_INIT_PEI:
+    if (Context == NULL) {
+      DEBUG ((EFI_D_ERROR, "DebugAgent: Input parameter Context cannot be 
NULL!\n"));
+      CpuDeadLoop ();
+    }
     //
     // Check if Debug Agent has initialized before
     //
@@ -550,6 +550,7 @@
       SetDebugFlag (DEBUG_AGENT_FLAG_CHECK_MAILBOX_IN_HOB, 1);
     }
 
+    Phase2Context.InitFlag = InitFlag;
     Phase2Context.Context  = Context;
     Phase2Context.Function = Function;
     DebugPortInitialize ((VOID *) &Phase2Context, InitializeDebugAgentPhase2);
@@ -598,6 +599,9 @@
     break;
   }
 
+  //
+  // Enable CPU interrupts so debug timer interrupts can be delivered
+  //
   EnableInterrupts ();
 
   //
@@ -606,6 +610,12 @@
   if (Function != NULL) {
     Function (Context);
   }
+  //
+  // Set return status for DEBUG_AGENT_INIT_PEI
+  //
+  if (InitFlag == DEBUG_AGENT_INIT_PEI) {
+    *(EFI_STATUS *)Context = EFI_SUCCESS;
+  }
 }
 
 /**
@@ -635,7 +645,7 @@
   MailboxLocation = GetLocationSavedMailboxPointerInIdtEntry ();
   Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
   BufferSize = PcdGet16(PcdDebugPortHandleBufferSize);
-  if (Phase2Context->Function == NULL && DebugPortHandle != NULL && BufferSize 
!= 0) {
+  if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PEI) {
     NewDebugPortHandle = (UINT64)(UINTN)AllocateCopyPool (BufferSize, 
DebugPortHandle);
   } else {
     NewDebugPortHandle = (UINT64)(UINTN)DebugPortHandle;
@@ -647,25 +657,23 @@
   //
   TriggerSoftInterrupt (SYSTEM_RESET_SIGNATURE);
 
-  //
-  // If Temporary RAM region is below 128 MB, then send message to 
-  // host to disable low memory filtering.
-  //
-  SecCoreData = (EFI_SEC_PEI_HAND_OFF *)Phase2Context->Context;
-  if ((UINTN)SecCoreData->TemporaryRamBase < BASE_128MB && IsHostAttached ()) {
-    SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);
-    TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
-  }
-
-  //
-  // Enable CPU interrupts so debug timer interrupts can be delivered
-  //
-  EnableInterrupts ();
-
-  //
-  // Call continuation function if it is not NULL.
-  //
-  if (Phase2Context->Function != NULL) {
+  if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PREMEM_SEC) {
+    //
+    // If Temporary RAM region is below 128 MB, then send message to 
+    // host to disable low memory filtering.
+    //
+    SecCoreData = (EFI_SEC_PEI_HAND_OFF *)Phase2Context->Context;
+    if ((UINTN)SecCoreData->TemporaryRamBase < BASE_128MB && IsHostAttached 
()) {
+      SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);
+      TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
+    }
+    //
+    // Enable CPU interrupts so debug timer interrupts can be delivered
+    //
+    EnableInterrupts ();
+    //
+    // Call continuation function if it is not NULL.
+    //
     Phase2Context->Function (Phase2Context->Context);
   }
 }

Modified: 
trunk/edk2/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.h
===================================================================
--- 
trunk/edk2/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.h
    2013-12-03 07:10:56 UTC (rev 14928)
+++ 
trunk/edk2/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.h
    2013-12-04 07:07:10 UTC (rev 14929)
@@ -22,6 +22,7 @@
 #include "DebugAgent.h"
 
 typedef struct {
+  UINT32                  InitFlag;
   VOID                    *Context;
   DEBUG_AGENT_CONTINUE    Function;
 } DEBUG_AGENT_PHASE2_CONTEXT;

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to