summaryrefslogtreecommitdiff
path: root/SourceLevelDebugPkg
diff options
context:
space:
mode:
authorLiming Gao <liming.gao@intel.com>2013-11-15 02:05:15 +0000
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>2013-11-15 02:05:15 +0000
commit4d0da5fb769cb38a215daa1e42d46400c59f9711 (patch)
tree54ffa7711aa90693f8408bf0858203f6f7658c6c /SourceLevelDebugPkg
parent0f9ebb321638e9142ab3bdcc19000c49bb83b9ba (diff)
downloadedk2-platforms-4d0da5fb769cb38a215daa1e42d46400c59f9711.tar.xz
Add support for PI1.2.1 TempRam Done PPI.
Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jeff Fan <jeff.fan@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@14848 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'SourceLevelDebugPkg')
-rw-r--r--SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c59
1 files changed, 46 insertions, 13 deletions
diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
index c253fa59a3..d036880c1d 100644
--- a/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
+++ b/SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c
@@ -348,6 +348,7 @@ InitializeDebugAgent (
)
{
DEBUG_AGENT_MAILBOX *Mailbox;
+ DEBUG_AGENT_MAILBOX *NewMailbox;
DEBUG_AGENT_MAILBOX MailboxInStack;
DEBUG_AGENT_PHASE2_CONTEXT Phase2Context;
DEBUG_AGENT_CONTEXT_POSTMEM_SEC *DebugAgentContext;
@@ -357,6 +358,7 @@ InitializeDebugAgent (
UINT64 DebugPortHandle;
UINT64 MailboxLocation;
UINT64 *MailboxLocationPointer;
+ EFI_PHYSICAL_ADDRESS Address;
DisableInterrupts ();
@@ -411,19 +413,50 @@ InitializeDebugAgent (
// Fix up Debug Port handle address and mailbox address
//
DebugAgentContext = (DEBUG_AGENT_CONTEXT_POSTMEM_SEC *) Context;
- DebugPortHandle = (UINT64)(UINT32)(Mailbox->DebugPortHandle + DebugAgentContext->StackMigrateOffset);
- UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, DebugPortHandle);
- Mailbox = (DEBUG_AGENT_MAILBOX *) ((UINTN) Mailbox + DebugAgentContext->StackMigrateOffset);
- MailboxLocation = (UINT64)(UINTN)Mailbox;
- //
- // Build mailbox location in HOB and fix-up its address
- //
- MailboxLocationPointer = BuildGuidDataHob (
- &gEfiDebugAgentGuid,
- &MailboxLocation,
- sizeof (UINT64)
- );
- MailboxLocationPointer = (UINT64 *) ((UINTN) MailboxLocationPointer + DebugAgentContext->HeapMigrateOffset);
+ if (DebugAgentContext != NULL) {
+ DebugPortHandle = (UINT64)(UINT32)(Mailbox->DebugPortHandle + DebugAgentContext->StackMigrateOffset);
+ UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, DebugPortHandle);
+ Mailbox = (DEBUG_AGENT_MAILBOX *) ((UINTN) Mailbox + DebugAgentContext->StackMigrateOffset);
+ MailboxLocation = (UINT64)(UINTN)Mailbox;
+ //
+ // Build mailbox location in HOB and fix-up its address
+ //
+ MailboxLocationPointer = BuildGuidDataHob (
+ &gEfiDebugAgentGuid,
+ &MailboxLocation,
+ sizeof (UINT64)
+ );
+ MailboxLocationPointer = (UINT64 *) ((UINTN) MailboxLocationPointer + DebugAgentContext->HeapMigrateOffset);
+ } else {
+ //
+ // DebugAgentContext is NULL. Then, Mailbox can directly be copied into memory.
+ // Allocate ACPI NVS memory for new Mailbox and Debug Port Handle buffer
+ //
+ Status = PeiServicesAllocatePages (
+ EfiACPIMemoryNVS,
+ EFI_SIZE_TO_PAGES (sizeof(DEBUG_AGENT_MAILBOX) + PcdGet16(PcdDebugPortHandleBufferSize)),
+ &Address
+ );
+ ASSERT_EFI_ERROR (Status);
+ 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
+ // reallocates the HOB.
+ //
+ CopyMem (NewMailbox, Mailbox, sizeof (DEBUG_AGENT_MAILBOX));
+ CopyMem (NewMailbox + 1, (VOID *)(UINTN)Mailbox->DebugPortHandle, PcdGet16(PcdDebugPortHandleBufferSize));
+ UpdateMailboxContent (NewMailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, (UINT64)(UINTN)(NewMailbox + 1));
+ MailboxLocation = (UINT64)(UINTN)NewMailbox;
+ //
+ // Build mailbox location in HOB
+ //
+ MailboxLocationPointer = BuildGuidDataHob (
+ &gEfiDebugAgentGuid,
+ &MailboxLocation,
+ sizeof (UINT64)
+ );
+ }
//
// Update IDT entry to save the location saved mailbox pointer
//