summaryrefslogtreecommitdiff
path: root/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2013-04-20 03:34:16 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2013-04-20 03:34:16 +0000
commit0a48876599712cdc3cbbed1d73313d1142d3cb08 (patch)
tree78e6257437ca9b53fed5a821d9dde8d006b3d911 /SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
parent58df7da72b74dde1d8f66bc6e11e62b98f25916b (diff)
downloadedk2-platforms-0a48876599712cdc3cbbed1d73313d1142d3cb08.tar.xz
1. Add CPU arch type in Mailbox, debug agent will not access HOB if CPU arch changed.
2. Updated DxeDebugAgentLib instance to copy DebugPortHandler buffer into allocated ACPIMemoryNVS besides the mailbox. 3. Remove deprecated SendingPacket from mailbox. Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14302 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c')
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
index 828407304f..0132942dea 100644
--- a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
+++ b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
@@ -174,19 +174,22 @@ GetMailboxPointer (
MailboxLocationInIdt = GetLocationSavedMailboxPointerInIdtEntry ();
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocationInIdt);
//
- // Check if mailbox was setup in PEI firstly, cannot used GetDebugFlag() to
- // get CheckMailboxInHob flag to avoid GetMailboxPointer() nesting.
+ // Cannot used GetDebugFlag() to get Debug Flag to avoid GetMailboxPointer() nested
//
- if (Mailbox->DebugFlag.Bits.CheckMailboxInHob != 1) {
- //
- // If mailbox in IDT entry has already been the final one
+ if (Mailbox->DebugFlag.Bits.CheckMailboxInHob != 1 ||
+ Mailbox->DebugFlag.Bits.InitArch != DEBUG_ARCH_SYMBOL) {
//
+ // If mailbox was setup in SEC or the current CPU arch is different from the init arch
+ // Debug Agent initialized, return the mailbox from IDT entry directly.
+ // Otherwise, we need to check the mailbox location saved in GUIDed HOB further.
+ //
return Mailbox;
}
MailboxLocationInHob = GetMailboxLocationFromHob ();
//
- // Compare mailbox in IDT enry with mailbox in HOB
+ // Compare mailbox in IDT enry with mailbox in HOB,
+ // need to fix mailbox location if HOB moved by PEI CORE
//
if (MailboxLocationInHob != MailboxLocationInIdt && MailboxLocationInHob != NULL) {
Mailbox = (DEBUG_AGENT_MAILBOX *)(UINTN)(*MailboxLocationInHob);
@@ -247,7 +250,7 @@ DebugAgentCallbackMemoryDiscoveredPpi (
EFI_STATUS Status;
DEBUG_AGENT_MAILBOX *Mailbox;
BOOLEAN InterruptStatus;
- EFI_PHYSICAL_ADDRESS Memory;
+ EFI_PHYSICAL_ADDRESS Address;
DEBUG_AGENT_MAILBOX *NewMailbox;
UINT64 *MailboxLocationInHob;
@@ -262,10 +265,10 @@ DebugAgentCallbackMemoryDiscoveredPpi (
Status = PeiServicesAllocatePages (
EfiACPIMemoryNVS,
EFI_SIZE_TO_PAGES (sizeof(DEBUG_AGENT_MAILBOX) + PcdGet16(PcdDebugPortHandleBufferSize)),
- &Memory
+ &Address
);
ASSERT_EFI_ERROR (Status);
- NewMailbox = (DEBUG_AGENT_MAILBOX *) (UINTN) Memory;
+ NewMailbox = (DEBUG_AGENT_MAILBOX *) (UINTN) Address;
//
// Copy Mailbox and Debug Port Handle buffer to new location in ACPI NVS memory, because original Mailbox
// and Debug Port Handle buffer in the allocated pool that may be marked as free by DXE Core after DXE Core
@@ -369,7 +372,14 @@ InitializeDebugAgent (
// Get and save debug port handle and set the length of memory block.
//
SetLocationSavedMailboxPointerInIdtEntry (&MailboxLocation);
+ //
+ // Force error message could be printed during the first shakehand between Target/HOST.
+ //
SetDebugFlag (DEBUG_AGENT_FLAG_PRINT_ERROR_LEVEL, DEBUG_AGENT_ERROR);
+ //
+ // Save init arch type when debug agent initialized
+ //
+ SetDebugFlag (DEBUG_AGENT_FLAG_INIT_ARCH, sizeof (UINTN) / 4);
InitializeDebugTimer ();
@@ -453,6 +463,10 @@ InitializeDebugAgent (
//
SetLocationSavedMailboxPointerInIdtEntry (MailboxLocationPointer);
//
+ // Save init arch type when debug agent initialized
+ //
+ SetDebugFlag (DEBUG_AGENT_FLAG_INIT_ARCH, DEBUG_ARCH_SYMBOL);
+ //
// Register for a callback once memory has been initialized.
// If memery has been ready, the callback funtion will be invoked immediately
//
@@ -483,6 +497,9 @@ InitializeDebugAgent (
MailboxLocationPointer = (UINT64 *) (UINTN) (Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetLow +
(Ia32IdtEntry[DEBUG_MAILBOX_VECTOR].Bits.OffsetHigh << 16));
Mailbox = (DEBUG_AGENT_MAILBOX *) (UINTN)(*MailboxLocationPointer);
+ //
+ // Mailbox should valid and setup before executing thunk code
+ //
VerifyMailboxChecksum (Mailbox);
DebugPortHandle = (UINT64) (UINTN)DebugPortInitialize ((VOID *)(UINTN)Mailbox->DebugPortHandle, NULL);
@@ -508,7 +525,6 @@ InitializeDebugAgent (
DEBUG ((EFI_D_ERROR, "Debug Agent: The InitFlag value is not allowed!\n"));
CpuDeadLoop ();
break;
-
}
EnableInterrupts ();