X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=UefiCpuPkg%2FCpuMpPei%2FCpuMpPei.c;h=ef1c2812e2bf7f0ca620ecde61102bdd0e9592ad;hp=f38b3961961c3a2288b3b08354610e0cba05aef2;hb=4da1ebf3b3c22ec3e09cef3fe5d1da6f40895e6d;hpb=587d204ccda4b507be4f9f42e8c9d226fd755be0 diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c index f38b396196..ef1c2812e2 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c @@ -1,7 +1,7 @@ /** @file CPU PEI Module installs CPU Multiple Processor PPI. - Copyright (c) 2015, Intel Corporation. All rights reserved.
+ Copyright (c) 2015 - 2016, Intel Corporation. All rights reserved.
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 @@ -355,10 +355,6 @@ ApCFunction ( } } ApStartupSignalBuffer = PeiCpuMpData->CpuData[ProcessorNumber].StartupApSignal; - // - // Clear AP start-up signal - // - *ApStartupSignalBuffer = 0; while (TRUE) { DisableInterrupts (); if (PeiCpuMpData->ApLoopMode == ApInMwaitLoop) { @@ -387,12 +383,44 @@ ApCFunction ( // otherwise place AP in loop again // if (*ApStartupSignalBuffer == WAKEUP_AP_SIGNAL) { + // + // Clear AP start-up signal when AP waken up + // + InterlockedCompareExchange32 ( + (UINT32 *)ApStartupSignalBuffer, + WAKEUP_AP_SIGNAL, + 0 + ); break; } } } } +/** + Write AP start-up signal to wakeup AP. + + @param ApStartupSignalBuffer Pointer to AP wakeup signal +**/ +VOID +WriteStartupSignal ( + IN volatile UINT32 *ApStartupSignalBuffer + ) +{ + *ApStartupSignalBuffer = WAKEUP_AP_SIGNAL; + // + // If AP is waken up, StartupApSignal should be cleared. + // Otherwise, write StartupApSignal again till AP waken up. + // + while (InterlockedCompareExchange32 ( + (UINT32 *)ApStartupSignalBuffer, + WAKEUP_AP_SIGNAL, + WAKEUP_AP_SIGNAL + ) != 0) { + CpuPause (); + } +} + /** This function will be called by BSP to wakeup AP. @@ -462,11 +490,11 @@ WakeUpAP ( if (Broadcast) { for (Index = 0; Index < PeiCpuMpData->CpuCount; Index++) { if (Index != PeiCpuMpData->BspNumber) { - *(PeiCpuMpData->CpuData[Index].StartupApSignal) = WAKEUP_AP_SIGNAL; + WriteStartupSignal (PeiCpuMpData->CpuData[Index].StartupApSignal); } } } else { - *(PeiCpuMpData->CpuData[ProcessorNumber].StartupApSignal) = WAKEUP_AP_SIGNAL; + WriteStartupSignal (PeiCpuMpData->CpuData[ProcessorNumber].StartupApSignal); } } else { ASSERT (FALSE);