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
This commit is contained in:
Jeff Fan 2013-12-04 07:07:10 +00:00 committed by vanjeff
parent 32e817c995
commit 5ab7f883fb
2 changed files with 34 additions and 25 deletions

View File

@ -402,6 +402,7 @@ InitializeDebugAgent (
InitializeDebugTimer (); InitializeDebugTimer ();
Phase2Context.InitFlag = InitFlag;
Phase2Context.Context = Context; Phase2Context.Context = Context;
Phase2Context.Function = Function; Phase2Context.Function = Function;
DebugPortInitialize ((VOID *) &Phase2Context, InitializeDebugAgentPhase2); DebugPortInitialize ((VOID *) &Phase2Context, InitializeDebugAgentPhase2);
@ -487,14 +488,13 @@ InitializeDebugAgent (
// Update IDT entry to save the location saved mailbox pointer // Update IDT entry to save the location saved mailbox pointer
// //
SetLocationSavedMailboxPointerInIdtEntry (MailboxLocationPointer); SetLocationSavedMailboxPointerInIdtEntry (MailboxLocationPointer);
//
// Enable CPU interrupts so debug timer interrupts can be delivered
//
EnableInterrupts ();
break; break;
case DEBUG_AGENT_INIT_PEI: 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 // Check if Debug Agent has initialized before
// //
@ -550,6 +550,7 @@ InitializeDebugAgent (
SetDebugFlag (DEBUG_AGENT_FLAG_CHECK_MAILBOX_IN_HOB, 1); SetDebugFlag (DEBUG_AGENT_FLAG_CHECK_MAILBOX_IN_HOB, 1);
} }
Phase2Context.InitFlag = InitFlag;
Phase2Context.Context = Context; Phase2Context.Context = Context;
Phase2Context.Function = Function; Phase2Context.Function = Function;
DebugPortInitialize ((VOID *) &Phase2Context, InitializeDebugAgentPhase2); DebugPortInitialize ((VOID *) &Phase2Context, InitializeDebugAgentPhase2);
@ -598,6 +599,9 @@ InitializeDebugAgent (
break; break;
} }
//
// Enable CPU interrupts so debug timer interrupts can be delivered
//
EnableInterrupts (); EnableInterrupts ();
// //
@ -606,6 +610,12 @@ InitializeDebugAgent (
if (Function != NULL) { if (Function != NULL) {
Function (Context); 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 (); MailboxLocation = GetLocationSavedMailboxPointerInIdtEntry ();
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation); Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocation);
BufferSize = PcdGet16(PcdDebugPortHandleBufferSize); BufferSize = PcdGet16(PcdDebugPortHandleBufferSize);
if (Phase2Context->Function == NULL && DebugPortHandle != NULL && BufferSize != 0) { if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PEI) {
NewDebugPortHandle = (UINT64)(UINTN)AllocateCopyPool (BufferSize, DebugPortHandle); NewDebugPortHandle = (UINT64)(UINTN)AllocateCopyPool (BufferSize, DebugPortHandle);
} else { } else {
NewDebugPortHandle = (UINT64)(UINTN)DebugPortHandle; NewDebugPortHandle = (UINT64)(UINTN)DebugPortHandle;
@ -647,6 +657,7 @@ InitializeDebugAgentPhase2 (
// //
TriggerSoftInterrupt (SYSTEM_RESET_SIGNATURE); TriggerSoftInterrupt (SYSTEM_RESET_SIGNATURE);
if (Phase2Context->InitFlag == DEBUG_AGENT_INIT_PREMEM_SEC) {
// //
// If Temporary RAM region is below 128 MB, then send message to // If Temporary RAM region is below 128 MB, then send message to
// host to disable low memory filtering. // host to disable low memory filtering.
@ -656,16 +667,13 @@ InitializeDebugAgentPhase2 (
SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1); SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);
TriggerSoftInterrupt (MEMORY_READY_SIGNATURE); TriggerSoftInterrupt (MEMORY_READY_SIGNATURE);
} }
// //
// Enable CPU interrupts so debug timer interrupts can be delivered // Enable CPU interrupts so debug timer interrupts can be delivered
// //
EnableInterrupts (); EnableInterrupts ();
// //
// Call continuation function if it is not NULL. // Call continuation function if it is not NULL.
// //
if (Phase2Context->Function != NULL) {
Phase2Context->Function (Phase2Context->Context); Phase2Context->Function (Phase2Context->Context);
} }
} }

View File

@ -22,6 +22,7 @@
#include "DebugAgent.h" #include "DebugAgent.h"
typedef struct { typedef struct {
UINT32 InitFlag;
VOID *Context; VOID *Context;
DEBUG_AGENT_CONTINUE Function; DEBUG_AGENT_CONTINUE Function;
} DEBUG_AGENT_PHASE2_CONTEXT; } DEBUG_AGENT_PHASE2_CONTEXT;