\r
InitializeDebugTimer ();\r
\r
+ Phase2Context.InitFlag = InitFlag;\r
Phase2Context.Context = Context;\r
Phase2Context.Function = Function;\r
DebugPortInitialize ((VOID *) &Phase2Context, InitializeDebugAgentPhase2);\r
// 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
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
break;\r
}\r
\r
+ //\r
+ // Enable CPU interrupts so debug timer interrupts can be delivered\r
+ //\r
EnableInterrupts ();\r
\r
//\r
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
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
//\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