\r
mov esi, ebx\r
\r
+ ; Increment the number of APs executing here as early as possible\r
+ ; This is decremented in C code when AP is finished executing\r
+ mov edi, esi\r
+ add edi, NumApsExecutingLocation\r
+ lock inc dword [edi]\r
+\r
mov edi, esi\r
add edi, EnableExecuteDisableLocation\r
cmp byte [edi], 0\r
// AP finished executing C code\r
//\r
InterlockedIncrement ((UINT32 *) &CpuMpData->FinishedCount);\r
+ InterlockedDecrement ((UINT32 *) &CpuMpData->MpCpuExchangeInfo->NumApsExecuting);\r
\r
//\r
// Place AP is specified loop mode\r
\r
ExchangeInfo->CFunction = (UINTN) ApWakeupFunction;\r
ExchangeInfo->ApIndex = 0;\r
+ ExchangeInfo->NumApsExecuting = 0;\r
ExchangeInfo->InitFlag = (UINTN) CpuMpData->InitFlag;\r
ExchangeInfo->CpuInfo = (CPU_INFO_IN_HOB *) (UINTN) CpuMpData->CpuInfoInHob;\r
ExchangeInfo->CpuMpData = CpuMpData;\r
}\r
if (CpuMpData->InitFlag == ApInitConfig) {\r
//\r
- // Wait for all potential APs waken up in one specified period\r
+ // Wait for one potential AP waken up in one specified period\r
//\r
- TimedWaitForApFinish (\r
- CpuMpData,\r
- PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1,\r
- PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds)\r
- );\r
+ if (CpuMpData->CpuCount == 0) {\r
+ TimedWaitForApFinish (\r
+ CpuMpData,\r
+ PcdGet32 (PcdCpuMaxLogicalProcessorNumber) - 1,\r
+ PcdGet32 (PcdCpuApInitTimeOutInMicroSeconds)\r
+ );\r
+ }\r
+\r
+ while (CpuMpData->MpCpuExchangeInfo->NumApsExecuting != 0) {\r
+ CpuPause();\r
+ }\r
} else {\r
//\r
// Wait all APs waken up if this is not the 1st broadcast of SIPI\r
UINTN Cr3;\r
UINTN InitFlag;\r
CPU_INFO_IN_HOB *CpuInfo;\r
+ UINTN NumApsExecuting;\r
CPU_MP_DATA *CpuMpData;\r
UINTN InitializeFloatingPointUnitsAddress;\r
} MP_CPU_EXCHANGE_INFO;\r
Cr3Location equ LockLocation + 64h\r
InitFlagLocation equ LockLocation + 6Ch\r
CpuInfoLocation equ LockLocation + 74h\r
-InitializeFloatingPointUnitsAddress equ LockLocation + 84h\r
+NumApsExecutingLocation equ LockLocation + 7Ch\r
+InitializeFloatingPointUnitsAddress equ LockLocation + 8Ch\r
\r
cmp qword [edi], 1 ; ApInitConfig\r
jnz GetApicId\r
\r
+ ; Increment the number of APs executing here as early as possible\r
+ ; This is decremented in C code when AP is finished executing\r
+ mov edi, esi\r
+ add edi, NumApsExecutingLocation\r
+ lock inc dword [edi]\r
+\r
; AP init\r
mov edi, esi\r
add edi, LockLocation\r