diff options
author | Ray Ni <ray.ni@intel.com> | 2023-04-14 17:19:37 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-08-28 17:46:17 +0000 |
commit | 94f68d0b56a36d84e038751f9cd907c2cf637626 (patch) | |
tree | 163ef73ed580d4e31b73c74f87ea6a667413762f /UefiCpuPkg | |
parent | 84e7b74c8c643c59ee32d4da769f48a3c8c277a4 (diff) | |
download | edk2-94f68d0b56a36d84e038751f9cd907c2cf637626.zip edk2-94f68d0b56a36d84e038751f9cd907c2cf637626.tar.gz edk2-94f68d0b56a36d84e038751f9cd907c2cf637626.tar.bz2 |
UefiCpuPkg/MpInitLib: Separate X2APIC enabling to subfunction
It's very confusing that auto X2 APIC enabling and APIC ID sorting
are all performed inside CollectProcessorCount().
The change is to separate the X2 APIC enabling to AutoEnableX2Apic()
and call that from MpInitLibInitialize().
SortApicId() is called from MpInitLibInitialize() as well.
Signed-off-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'UefiCpuPkg')
-rw-r--r-- | UefiCpuPkg/Library/MpInitLib/MpLib.c | 65 |
1 files changed, 42 insertions, 23 deletions
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c index 4088e76..e708b3f 100644 --- a/UefiCpuPkg/Library/MpInitLib/MpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c @@ -502,33 +502,20 @@ GetProcessorNumber ( }
/**
- This function will get CPU count in the system.
+ Enable x2APIC mode if
+ 1. Number of CPU is greater than 255; or
+ 2. There are any logical processors reporting an Initial APIC ID of 255 or greater.
@param[in] CpuMpData Pointer to PEI CPU MP Data
-
- @return CPU count detected
**/
-UINTN
-CollectProcessorCount (
+VOID
+AutoEnableX2Apic (
IN CPU_MP_DATA *CpuMpData
)
{
+ BOOLEAN X2Apic;
UINTN Index;
CPU_INFO_IN_HOB *CpuInfoInHob;
- BOOLEAN X2Apic;
-
- //
- // Send 1st broadcast IPI to APs to wakeup APs
- //
- CpuMpData->InitFlag = ApInitConfig;
- WakeUpAP (CpuMpData, TRUE, 0, NULL, NULL, TRUE);
- CpuMpData->InitFlag = ApInitDone;
- //
- // When InitFlag == ApInitConfig, WakeUpAP () guarantees all APs are checked in.
- // FinishedCount is the number of check-in APs.
- //
- CpuMpData->CpuCount = CpuMpData->FinishedCount + 1;
- ASSERT (CpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
//
// Enable x2APIC mode if
@@ -577,12 +564,32 @@ CollectProcessorCount ( }
DEBUG ((DEBUG_INFO, "APIC MODE is %d\n", GetApicMode ()));
+}
+
+/**
+ 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
+ )
+{
//
- // Sort BSP/Aps by CPU APIC ID in ascending order
+ // Send 1st broadcast IPI to APs to wakeup APs
//
- SortApicId (CpuMpData);
-
- DEBUG ((DEBUG_INFO, "MpInitLib: Find %d processors in system.\n", CpuMpData->CpuCount));
+ CpuMpData->InitFlag = ApInitConfig;
+ WakeUpAP (CpuMpData, TRUE, 0, NULL, NULL, TRUE);
+ CpuMpData->InitFlag = ApInitDone;
+ //
+ // When InitFlag == ApInitConfig, WakeUpAP () guarantees all APs are checked in.
+ // FinishedCount is the number of check-in APs.
+ //
+ CpuMpData->CpuCount = CpuMpData->FinishedCount + 1;
+ ASSERT (CpuMpData->CpuCount <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber));
return CpuMpData->CpuCount;
}
@@ -2226,6 +2233,18 @@ MpInitLibInitialize ( // Wakeup all APs and calculate the processor count in system
//
CollectProcessorCount (CpuMpData);
+
+ //
+ // Enable X2APIC if needed.
+ //
+ AutoEnableX2Apic (CpuMpData);
+
+ //
+ // Sort BSP/Aps by CPU APIC ID in ascending order
+ //
+ SortApicId (CpuMpData);
+
+ DEBUG ((DEBUG_INFO, "MpInitLib: Find %d processors in system.\n", CpuMpData->CpuCount));
}
} else {
//
|