summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Fan <jeff.fan@intel.com>2013-12-04 07:07:10 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2013-12-04 07:07:10 +0000
commit5ab7f883fb46f23114951d644d457eb854b8e977 (patch)
tree787284d3e111a7053c9f73aa47b212dbfc59b1eb
parent32e817c9952a957af17de359e6636e4e674caebf (diff)
downloadedk2-platforms-5ab7f883fb46f23114951d644d457eb854b8e977.tar.xz
Add InitFlag member in DEBUG_AGENT_PHASE2_CONTEXT to pass into InitializeDebugAgentPhase2().
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
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c58
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.h1
2 files changed, 34 insertions, 25 deletions
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
index 0388807697..a3f91d3358 100644
--- a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
+++ b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
@@ -402,6 +402,7 @@ InitializeDebugAgent (
InitializeDebugTimer ();
+ Phase2Context.InitFlag = InitFlag;
Phase2Context.Context = Context;
Phase2Context.Function = Function;
DebugPortInitialize ((VOID *) &Phase2Context, InitializeDebugAgentPhase2);
@@ -487,14 +488,13 @@ InitializeDebugAgent (
// 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 @@ InitializeDebugAgent (
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 @@ InitializeDebugAgent (
break;
}
+ //
+ // Enable CPU interrupts so debug timer interrupts can be delivered
+ //
EnableInterrupts ();
//
@@ -606,6 +610,12 @@ InitializeDebugAgent (
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 @@ InitializeDebugAgentPhase2 (
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 @@ InitializeDebugAgentPhase2 (
//
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);
}
}
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.h b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.h
index 68bfbf7cab..a0687fa173 100644
--- a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.h
+++ b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.h
@@ -22,6 +22,7 @@
#include "DebugAgent.h"
typedef struct {
+ UINT32 InitFlag;
VOID *Context;
DEBUG_AGENT_CONTINUE Function;
} DEBUG_AGENT_PHASE2_CONTEXT;