summaryrefslogtreecommitdiff
path: root/Core/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
diff options
context:
space:
mode:
Diffstat (limited to 'Core/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c')
-rw-r--r--Core/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c86
1 files changed, 27 insertions, 59 deletions
diff --git a/Core/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/Core/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index b393244e05..8099ee6888 100644
--- a/Core/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/Core/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -1,7 +1,7 @@
/** @file
MP initialize support functions for DXE phase.
- Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2016 - 2018, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -75,72 +75,41 @@ SaveCpuMpData (
}
/**
- Allocate reset vector buffer.
+ Get available system memory below 1MB by specified size.
- @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;
+ @param[in] WakeupBufferSize Wakeup buffer size required
- if (CpuMpData->SaveRestoreFlag) {
- BackupAndPrepareWakeupBuffer (CpuMpData);
- } else {
- 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.
+ @retval other Return wakeup buffer address below 1MB.
+ @retval -1 Cannot find free memory below 1MB.
**/
-VOID
-FreeResetVector (
- IN CPU_MP_DATA *CpuMpData
+UINTN
+GetWakeupBuffer (
+ IN UINTN WakeupBufferSize
)
{
- EFI_STATUS Status;
- UINTN ApResetVectorSize;
-
- if (CpuMpData->SaveRestoreFlag) {
- RestoreWakeupBuffer (CpuMpData);
- } else {
- ApResetVectorSize = CpuMpData->AddressMap.RendezvousFunnelSize +
- sizeof (MP_CPU_EXCHANGE_INFO);
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS StartAddress;
+
+ StartAddress = BASE_1MB;
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiBootServicesData,
+ EFI_SIZE_TO_PAGES (WakeupBufferSize),
+ &StartAddress
+ );
+ ASSERT_EFI_ERROR (Status);
+ if (!EFI_ERROR (Status)) {
Status = gBS->FreePages(
- (EFI_PHYSICAL_ADDRESS)CpuMpData->WakeupBuffer,
- EFI_SIZE_TO_PAGES (ApResetVectorSize)
+ StartAddress,
+ EFI_SIZE_TO_PAGES (WakeupBufferSize)
);
ASSERT_EFI_ERROR (Status);
+ DEBUG ((DEBUG_INFO, "WakeupBufferStart = %x, WakeupBufferSize = %x\n",
+ (UINTN) StartAddress, WakeupBufferSize));
+ } else {
+ StartAddress = (EFI_PHYSICAL_ADDRESS) -1;
}
+ return (UINTN) StartAddress;
}
/**
@@ -299,7 +268,6 @@ MpInitChangeApLoopCallback (
CPU_MP_DATA *CpuMpData;
CpuMpData = GetCpuMpData ();
- CpuMpData->SaveRestoreFlag = TRUE;
CpuMpData->PmCodeSegment = GetProtectedModeCS ();
CpuMpData->ApLoopMode = PcdGet8 (PcdCpuApLoopMode);
mNumberToFinish = CpuMpData->CpuCount - 1;