]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add support for PI1.2.1 TempRam Done PPI.
authorLiming Gao <liming.gao@intel.com>
Fri, 15 Nov 2013 02:05:15 +0000 (02:05 +0000)
committerlgao4 <lgao4@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 15 Nov 2013 02:05:15 +0000 (02:05 +0000)
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

SourceLevelDebugPkg/Library/DebugAgent/SecPeiDebugAgent/SecPeiDebugAgentLib.c

index c253fa59a37a3dad67764bb2422dda37ee1643c3..d036880c1d53dbcfeefc196b7d4bc89a62eb50b3 100644 (file)
@@ -348,6 +348,7 @@ InitializeDebugAgent (
   )\r
 {\r
   DEBUG_AGENT_MAILBOX              *Mailbox;\r
+  DEBUG_AGENT_MAILBOX              *NewMailbox;\r
   DEBUG_AGENT_MAILBOX              MailboxInStack;\r
   DEBUG_AGENT_PHASE2_CONTEXT       Phase2Context;\r
   DEBUG_AGENT_CONTEXT_POSTMEM_SEC  *DebugAgentContext;\r
@@ -357,6 +358,7 @@ InitializeDebugAgent (
   UINT64                           DebugPortHandle;\r
   UINT64                           MailboxLocation;\r
   UINT64                           *MailboxLocationPointer;\r
+  EFI_PHYSICAL_ADDRESS             Address; \r
   \r
   DisableInterrupts ();\r
 \r
@@ -411,19 +413,50 @@ InitializeDebugAgent (
     // Fix up Debug Port handle address and mailbox address\r
     //\r
     DebugAgentContext = (DEBUG_AGENT_CONTEXT_POSTMEM_SEC *) Context;\r
-    DebugPortHandle = (UINT64)(UINT32)(Mailbox->DebugPortHandle + DebugAgentContext->StackMigrateOffset);\r
-    UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, DebugPortHandle);\r
-    Mailbox = (DEBUG_AGENT_MAILBOX *) ((UINTN) Mailbox + DebugAgentContext->StackMigrateOffset);\r
-    MailboxLocation = (UINT64)(UINTN)Mailbox;\r
-    //\r
-    // Build mailbox location in HOB and fix-up its address\r
-    //\r
-    MailboxLocationPointer = BuildGuidDataHob (\r
-                               &gEfiDebugAgentGuid,\r
-                               &MailboxLocation,\r
-                               sizeof (UINT64)\r
-                               );\r
-    MailboxLocationPointer = (UINT64 *) ((UINTN) MailboxLocationPointer + DebugAgentContext->HeapMigrateOffset);\r
+    if (DebugAgentContext != NULL) {\r
+      DebugPortHandle = (UINT64)(UINT32)(Mailbox->DebugPortHandle + DebugAgentContext->StackMigrateOffset);\r
+      UpdateMailboxContent (Mailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, DebugPortHandle);\r
+      Mailbox = (DEBUG_AGENT_MAILBOX *) ((UINTN) Mailbox + DebugAgentContext->StackMigrateOffset);\r
+      MailboxLocation = (UINT64)(UINTN)Mailbox;\r
+      //\r
+      // Build mailbox location in HOB and fix-up its address\r
+      //\r
+      MailboxLocationPointer = BuildGuidDataHob (\r
+                                 &gEfiDebugAgentGuid,\r
+                                 &MailboxLocation,\r
+                                 sizeof (UINT64)\r
+                                 );\r
+      MailboxLocationPointer = (UINT64 *) ((UINTN) MailboxLocationPointer + DebugAgentContext->HeapMigrateOffset);\r
+    } else {\r
+      //\r
+      // DebugAgentContext is NULL. Then, Mailbox can directly be copied into memory.\r
+      // Allocate ACPI NVS memory for new Mailbox and Debug Port Handle buffer\r
+      //\r
+      Status = PeiServicesAllocatePages (\r
+                 EfiACPIMemoryNVS,\r
+                 EFI_SIZE_TO_PAGES (sizeof(DEBUG_AGENT_MAILBOX) + PcdGet16(PcdDebugPortHandleBufferSize)),\r
+                 &Address\r
+                 );\r
+      ASSERT_EFI_ERROR (Status);\r
+      NewMailbox = (DEBUG_AGENT_MAILBOX *) (UINTN) Address;\r
+      //\r
+      // Copy Mailbox and Debug Port Handle buffer to new location in ACPI NVS memory, because original Mailbox\r
+      // and Debug Port Handle buffer in the allocated pool that may be marked as free by DXE Core after DXE Core\r
+      // reallocates the HOB.\r
+      //\r
+      CopyMem (NewMailbox, Mailbox, sizeof (DEBUG_AGENT_MAILBOX));\r
+      CopyMem (NewMailbox + 1, (VOID *)(UINTN)Mailbox->DebugPortHandle, PcdGet16(PcdDebugPortHandleBufferSize));\r
+      UpdateMailboxContent (NewMailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, (UINT64)(UINTN)(NewMailbox + 1));\r
+      MailboxLocation = (UINT64)(UINTN)NewMailbox;\r
+      //\r
+      // Build mailbox location in HOB\r
+      //\r
+      MailboxLocationPointer = BuildGuidDataHob (\r
+                                 &gEfiDebugAgentGuid,\r
+                                 &MailboxLocation,\r
+                                 sizeof (UINT64)\r
+                                 );\r
+    }\r
     //\r
     // Update IDT entry to save the location saved mailbox pointer\r
     //\r