EmulatorPkg/MpService: fix wrong unsigned to signed variable transition

Because TimeoutInMicrosecsond is a unsigned value, converting it to
signed value will cause the data region changed. so this patch fix
that.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16415 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Chen Fan 2014-11-21 22:46:26 +00:00 committed by jljusten
parent a99b5e629b
commit ca186b1d4f
1 changed files with 31 additions and 10 deletions

View File

@ -111,8 +111,31 @@ GetNextBlockedNumber (
return EFI_NOT_FOUND; return EFI_NOT_FOUND;
} }
/**
* Calculated and stalled the interval time by BSP to check whether
* the APs have finished.
*
* @param[in] Timeout The time limit in microseconds for
* APs to return from Procedure.
*
* @retval StallTime Time of execution stall.
**/
UINTN
CalculateAndStallInterval (
IN UINTN Timeout
)
{
UINTN StallTime;
if (Timeout < gPollInterval && Timeout != 0) {
StallTime = Timeout;
} else {
StallTime = gPollInterval;
}
gBS->Stall (StallTime);
return StallTime;
}
/** /**
This service retrieves the number of logical processor in the platform This service retrieves the number of logical processor in the platform
@ -378,7 +401,7 @@ CpuMpServicesStartupAllAps (
UINTN NextNumber; UINTN NextNumber;
PROCESSOR_STATE APInitialState; PROCESSOR_STATE APInitialState;
PROCESSOR_STATE ProcessorState; PROCESSOR_STATE ProcessorState;
INTN Timeout; UINTN Timeout;
if (!IsBSP ()) { if (!IsBSP ()) {
@ -540,13 +563,12 @@ CpuMpServicesStartupAllAps (
goto Done; goto Done;
} }
if ((TimeoutInMicroseconds != 0) && (Timeout < 0)) { if ((TimeoutInMicroseconds != 0) && (Timeout == 0)) {
Status = EFI_TIMEOUT; Status = EFI_TIMEOUT;
goto Done; goto Done;
} }
gBS->Stall (gPollInterval); Timeout -= CalculateAndStallInterval (Timeout);
Timeout -= gPollInterval;
} }
Done: Done:
@ -659,7 +681,7 @@ CpuMpServicesStartupThisAP (
OUT BOOLEAN *Finished OPTIONAL OUT BOOLEAN *Finished OPTIONAL
) )
{ {
INTN Timeout; UINTN Timeout;
if (!IsBSP ()) { if (!IsBSP ()) {
return EFI_DEVICE_ERROR; return EFI_DEVICE_ERROR;
@ -717,12 +739,11 @@ CpuMpServicesStartupThisAP (
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock); gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
if ((TimeoutInMicroseconds != 0) && (Timeout < 0)) { if ((TimeoutInMicroseconds != 0) && (Timeout == 0)) {
return EFI_TIMEOUT; return EFI_TIMEOUT;
} }
gBS->Stall (gPollInterval); Timeout -= CalculateAndStallInterval (Timeout);
Timeout -= gPollInterval;
} }
return EFI_SUCCESS; return EFI_SUCCESS;
@ -987,7 +1008,7 @@ CpuCheckAllAPsStatus (
BOOLEAN Found; BOOLEAN Found;
if (gMPSystem.TimeoutActive) { if (gMPSystem.TimeoutActive) {
gMPSystem.Timeout -= gPollInterval; gMPSystem.Timeout -= CalculateAndStallInterval (gMPSystem.Timeout);
} }
for (ProcessorNumber = 0; ProcessorNumber < gMPSystem.NumberOfProcessors; ProcessorNumber++) { for (ProcessorNumber = 0; ProcessorNumber < gMPSystem.NumberOfProcessors; ProcessorNumber++) {
@ -1040,7 +1061,7 @@ CpuCheckAllAPsStatus (
} }
} }
if (gMPSystem.TimeoutActive && gMPSystem.Timeout < 0) { if (gMPSystem.TimeoutActive && gMPSystem.Timeout == 0) {
// //
// Timeout // Timeout
// //