summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Fan <jeff.fan@intel.com>2016-07-21 00:28:45 +0800
committerJeff Fan <jeff.fan@intel.com>2016-08-17 20:01:40 +0800
commit03434dffb7050c168579de92991194cc2f2b0721 (patch)
treeda9219eecdbe316d5ae6e423c652ffcf86add41d
parent96f5920d1d009fd2897f230e8bb49fe3f9a48aa0 (diff)
downloadedk2-platforms-03434dffb7050c168579de92991194cc2f2b0721.tar.xz
UefiCpuPkg/MpInitLib: Send INIT-SIPI-SIPI to get processor count
CollectProcessorCount() will send the 1st INIT-SIPI-SIPI to get processor count in system. 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>
-rw-r--r--UefiCpuPkg/Library/MpInitLib/MpLib.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index de169e6850..8f7cf43a7c 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -268,6 +268,42 @@ GetProcessorNumber (
return EFI_NOT_FOUND;
}
+/**
+ This function will get CPU count in the system.
+
+ @param[in] CpuMpData Pointer to PEI CPU MP Data
+
+ @return CPU count detected
+**/
+UINTN
+CollectProcessorCount (
+ IN CPU_MP_DATA *CpuMpData
+ )
+{
+ //
+ // Send 1st broadcast IPI to APs to wakeup APs
+ //
+ CpuMpData->InitFlag = ApInitConfig;
+ CpuMpData->X2ApicEnable = FALSE;
+ WakeUpAP (CpuMpData, TRUE, 0, NULL, NULL);
+ //
+ // Wait for AP task to complete and then exit.
+ //
+ MicroSecondDelay (PcdGet32(PcdCpuApInitTimeOutInMicroSeconds));
+ CpuMpData->InitFlag = ApInitDone;
+ ASSERT (CpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
+ //
+ // Wait for all APs finished the initialization
+ //
+ while (CpuMpData->FinishedCount < (CpuMpData->CpuCount - 1)) {
+ CpuPause ();
+ }
+
+ DEBUG ((DEBUG_INFO, "MpInitLib: Find %d processors in system.\n", CpuMpData->CpuCount));
+
+ return CpuMpData->CpuCount;
+}
+
/*
Initialize CPU AP Data when AP is wakeup at the first time.
@@ -705,6 +741,10 @@ MpInitLibInitialize (
//
+ // Wakeup all APs and calculate the processor count in system
+ //
+ CollectProcessorCount (CpuMpData);
+ //
// Initialize global data for MP support
//
InitMpGlobalData (CpuMpData);