mirror of https://github.com/acidanthera/audk.git
Allocate ACPImemoryNVS type memory to save mailbox and debug port handle buffer since original allocated pool memory may be marked as free by DXE Core.
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@14285 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
8908e764fe
commit
dca18202a1
|
@ -244,8 +244,12 @@ DebugAgentCallbackMemoryDiscoveredPpi (
|
||||||
IN VOID *Ppi
|
IN VOID *Ppi
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
DEBUG_AGENT_MAILBOX *Mailbox;
|
DEBUG_AGENT_MAILBOX *Mailbox;
|
||||||
BOOLEAN InterruptStatus;
|
BOOLEAN InterruptStatus;
|
||||||
|
EFI_PHYSICAL_ADDRESS Memory;
|
||||||
|
DEBUG_AGENT_MAILBOX *NewMailbox;
|
||||||
|
UINT64 *MailboxLocationInHob;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Save and disable original interrupt status
|
// Save and disable original interrupt status
|
||||||
|
@ -253,14 +257,38 @@ DebugAgentCallbackMemoryDiscoveredPpi (
|
||||||
InterruptStatus = SaveAndDisableInterrupts ();
|
InterruptStatus = SaveAndDisableInterrupts ();
|
||||||
|
|
||||||
//
|
//
|
||||||
// Set physical memory ready flag
|
// 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)),
|
||||||
|
&Memory
|
||||||
|
);
|
||||||
|
ASSERT_EFI_ERROR (Status);
|
||||||
|
NewMailbox = (DEBUG_AGENT_MAILBOX *) (UINTN) Memory;
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
//
|
//
|
||||||
Mailbox = GetMailboxPointer ();
|
Mailbox = GetMailboxPointer ();
|
||||||
|
CopyMem (NewMailbox, Mailbox, sizeof (DEBUG_AGENT_MAILBOX));
|
||||||
|
CopyMem (NewMailbox + 1, (VOID *)(UINTN)Mailbox->DebugPortHandle, PcdGet16(PcdDebugPortHandleBufferSize));
|
||||||
|
//
|
||||||
|
// Update Mailbox Location pointer in GUIDed HOB and IDT entry with new one
|
||||||
|
//
|
||||||
|
MailboxLocationInHob = GetMailboxLocationFromHob ();
|
||||||
|
*MailboxLocationInHob = (UINT64)(UINTN)NewMailbox;
|
||||||
|
SetLocationSavedMailboxPointerInIdtEntry (MailboxLocationInHob);
|
||||||
|
//
|
||||||
|
// Update Debug Port Handle in new Mailbox
|
||||||
|
//
|
||||||
|
UpdateMailboxContent (NewMailbox, DEBUG_MAILBOX_DEBUG_PORT_HANDLE_INDEX, (UINT64)(UINTN)(NewMailbox + 1));
|
||||||
|
//
|
||||||
|
// Set physical memory ready flag
|
||||||
|
//
|
||||||
SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);
|
SetDebugFlag (DEBUG_AGENT_FLAG_MEMORY_READY, 1);
|
||||||
|
|
||||||
//
|
|
||||||
// Memory has been ready
|
|
||||||
//
|
|
||||||
if (IsHostAttached ()) {
|
if (IsHostAttached ()) {
|
||||||
//
|
//
|
||||||
// Trigger one software interrupt to inform HOST
|
// Trigger one software interrupt to inform HOST
|
||||||
|
|
Loading…
Reference in New Issue