UefiCpuPkg/MpInitLib: Enable x2APIC mode on BSP/APs

If x2APIC flag is set, enable x2APIC mode on all APs and BSP. Before we wakeup
APs to enable x2APIC mode, we should wait all APs have finished initialization.

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-21 00:29:49 +08:00
parent 03434dffb7
commit fe627769c9
1 changed files with 32 additions and 0 deletions

View File

@ -216,6 +216,20 @@ GetApLoopMode (
return ApLoopMode;
}
/**
Enable x2APIC mode on APs.
@param[in, out] Buffer Pointer to private data buffer.
**/
VOID
EFIAPI
ApFuncEnableX2Apic (
IN OUT VOID *Buffer
)
{
SetApicMode (LOCAL_APIC_MODE_X2APIC);
}
/**
Do sync on APs.
@ -299,6 +313,24 @@ CollectProcessorCount (
CpuPause ();
}
if (CpuMpData->X2ApicEnable) {
DEBUG ((DEBUG_INFO, "Force x2APIC mode!\n"));
//
// Wakeup all APs to enable x2APIC mode
//
WakeUpAP (CpuMpData, TRUE, 0, ApFuncEnableX2Apic, NULL);
//
// Wait for all known APs finished
//
while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) {
CpuPause ();
}
//
// Enable x2APIC on BSP
//
SetApicMode (LOCAL_APIC_MODE_X2APIC);
}
DEBUG ((DEBUG_INFO, "APIC MODE is %d\n", GetApicMode ()));
DEBUG ((DEBUG_INFO, "MpInitLib: Find %d processors in system.\n", CpuMpData->CpuCount));
return CpuMpData->CpuCount;