UefiCpuPkg/MpInitLib: Allocate AP reset vector buffer under 1MB

In PeiMpInitLib, searching unallocated memory under in
EFI_HOB_TYPE_RESOURCE_DESCRIPTOR hobs to find the memory under 1MB for AP reset
vector. After End of PEI event triggered, we need to restore original the buffer
contents to avoid crash the OS on S3 boot.
In DxeMpInitLib, allocate the memory under 1MB for AP reset vector.

Add helper functions AllocateResetVector()/FreeResetVector() used by WakeupAp().

v3:
  1. Move SetTimer() from Patch #17 to Patch 16.

Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Feng Tian <feng.tian@intel.com>
Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
Tested-by: Michael Kinney <michael.d.kinney@intel.com>
This commit is contained in:
Jeff Fan
2016-07-24 22:19:09 +08:00
parent 963788618b
commit ed66e0e3f4
3 changed files with 325 additions and 0 deletions

View File

@ -52,6 +52,65 @@ SaveCpuMpData (
}
/**
Allocate reset vector buffer.
@param[in, out] CpuMpData The pointer to CPU MP Data structure.
**/
VOID
AllocateResetVector (
IN OUT CPU_MP_DATA *CpuMpData
)
{
EFI_STATUS Status;
UINTN ApResetVectorSize;
EFI_PHYSICAL_ADDRESS StartAddress;
ApResetVectorSize = CpuMpData->AddressMap.RendezvousFunnelSize +
sizeof (MP_CPU_EXCHANGE_INFO);
StartAddress = BASE_1MB;
Status = gBS->AllocatePages (
AllocateMaxAddress,
EfiACPIMemoryNVS,
EFI_SIZE_TO_PAGES (ApResetVectorSize),
&StartAddress
);
ASSERT_EFI_ERROR (Status);
CpuMpData->WakeupBuffer = (UINTN) StartAddress;
CpuMpData->MpCpuExchangeInfo = (MP_CPU_EXCHANGE_INFO *) (UINTN)
(CpuMpData->WakeupBuffer + CpuMpData->AddressMap.RendezvousFunnelSize);
//
// copy AP reset code in it
//
CopyMem (
(VOID *) CpuMpData->WakeupBuffer,
(VOID *) CpuMpData->AddressMap.RendezvousFunnelAddress,
CpuMpData->AddressMap.RendezvousFunnelSize
);
}
/**
Free AP reset vector buffer.
@param[in] CpuMpData The pointer to CPU MP Data structure.
**/
VOID
FreeResetVector (
IN CPU_MP_DATA *CpuMpData
)
{
EFI_STATUS Status;
UINTN ApResetVectorSize;
ApResetVectorSize = CpuMpData->AddressMap.RendezvousFunnelSize +
sizeof (MP_CPU_EXCHANGE_INFO);
Status = gBS->FreePages(
(EFI_PHYSICAL_ADDRESS)CpuMpData->WakeupBuffer,
EFI_SIZE_TO_PAGES (ApResetVectorSize)
);
ASSERT_EFI_ERROR (Status);
}
/**
Checks APs status and updates APs status if needed.
@ -88,6 +147,7 @@ CheckApsStatus (
CheckAndUpdateApsStatus ();
}
}
/**
Initialize global data for MP support.