EmulatorPkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the EmulatorPkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
committed by
mergify[bot]
parent
e7108d0e96
commit
a550d468a6
@ -37,13 +37,11 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "CpuDriver.h"
|
||||
|
||||
|
||||
MP_SYSTEM_DATA gMPSystem;
|
||||
EMU_THREAD_THUNK_PROTOCOL *gThread = NULL;
|
||||
EFI_EVENT gReadToBootEvent;
|
||||
BOOLEAN gReadToBoot = FALSE;
|
||||
UINTN gPollInterval;
|
||||
|
||||
MP_SYSTEM_DATA gMPSystem;
|
||||
EMU_THREAD_THUNK_PROTOCOL *gThread = NULL;
|
||||
EFI_EVENT gReadToBootEvent;
|
||||
BOOLEAN gReadToBoot = FALSE;
|
||||
UINTN gPollInterval;
|
||||
|
||||
BOOLEAN
|
||||
IsBSP (
|
||||
@ -61,7 +59,6 @@ IsBSP (
|
||||
return (gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) != 0;
|
||||
}
|
||||
|
||||
|
||||
VOID
|
||||
SetApProcedure (
|
||||
IN PROCESSOR_DATA_BLOCK *Processor,
|
||||
@ -70,15 +67,14 @@ SetApProcedure (
|
||||
)
|
||||
{
|
||||
gThread->MutexLock (Processor->ProcedureLock);
|
||||
Processor->Parameter = ProcedureArgument;
|
||||
Processor->Procedure = Procedure;
|
||||
Processor->Parameter = ProcedureArgument;
|
||||
Processor->Procedure = Procedure;
|
||||
gThread->MutexUnlock (Processor->ProcedureLock);
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
GetNextBlockedNumber (
|
||||
OUT UINTN *NextNumber
|
||||
OUT UINTN *NextNumber
|
||||
)
|
||||
{
|
||||
UINTN Number;
|
||||
@ -116,16 +112,17 @@ GetNextBlockedNumber (
|
||||
**/
|
||||
UINTN
|
||||
CalculateAndStallInterval (
|
||||
IN UINTN Timeout
|
||||
IN UINTN Timeout
|
||||
)
|
||||
{
|
||||
UINTN StallTime;
|
||||
UINTN StallTime;
|
||||
|
||||
if (Timeout < gPollInterval && Timeout != 0) {
|
||||
if ((Timeout < gPollInterval) && (Timeout != 0)) {
|
||||
StallTime = Timeout;
|
||||
} else {
|
||||
StallTime = gPollInterval;
|
||||
}
|
||||
|
||||
gBS->Stall (StallTime);
|
||||
|
||||
return StallTime;
|
||||
@ -188,8 +185,6 @@ CpuMpServicesGetNumberOfProcessors (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Gets detailed MP-related information on the requested processor at the
|
||||
instant this call is made. This service may only be called from the BSP.
|
||||
@ -240,7 +235,6 @@ CpuMpServicesGetProcessorInfo (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This service executes a caller provided function on all enabled APs. APs can
|
||||
run either simultaneously or one at a time in sequence. This service supports
|
||||
@ -397,7 +391,6 @@ CpuMpServicesStartupAllAps (
|
||||
PROCESSOR_STATE ProcessorState;
|
||||
UINTN Timeout;
|
||||
|
||||
|
||||
if (!IsBSP ()) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
@ -425,12 +418,14 @@ CpuMpServicesStartupAllAps (
|
||||
// Skip Disabled processors
|
||||
continue;
|
||||
}
|
||||
gThread->MutexLock(ProcessorData->StateLock);
|
||||
|
||||
gThread->MutexLock (ProcessorData->StateLock);
|
||||
if (ProcessorData->State != CPU_STATE_IDLE) {
|
||||
gThread->MutexUnlock (ProcessorData->StateLock);
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
gThread->MutexUnlock(ProcessorData->StateLock);
|
||||
|
||||
gThread->MutexUnlock (ProcessorData->StateLock);
|
||||
}
|
||||
|
||||
if (FailedCpuList != NULL) {
|
||||
@ -438,19 +433,20 @@ CpuMpServicesStartupAllAps (
|
||||
if (gMPSystem.FailedList == NULL) {
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
SetMemN (gMPSystem.FailedList, (gMPSystem.NumberOfProcessors + 1) * sizeof (UINTN), END_OF_CPU_LIST);
|
||||
gMPSystem.FailedListIndex = 0;
|
||||
*FailedCpuList = gMPSystem.FailedList;
|
||||
*FailedCpuList = gMPSystem.FailedList;
|
||||
}
|
||||
|
||||
Timeout = TimeoutInMicroseconds;
|
||||
|
||||
ProcessorData = NULL;
|
||||
ProcessorData = NULL;
|
||||
|
||||
gMPSystem.FinishCount = 0;
|
||||
gMPSystem.StartCount = 0;
|
||||
gMPSystem.SingleThread = SingleThread;
|
||||
APInitialState = CPU_STATE_READY;
|
||||
gMPSystem.FinishCount = 0;
|
||||
gMPSystem.StartCount = 0;
|
||||
gMPSystem.SingleThread = SingleThread;
|
||||
APInitialState = CPU_STATE_READY;
|
||||
|
||||
for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) {
|
||||
ProcessorData = &gMPSystem.ProcessorData[Number];
|
||||
@ -472,7 +468,7 @@ CpuMpServicesStartupAllAps (
|
||||
// state 1 by 1, until the previous 1 finished its task
|
||||
// if not "SingleThread", all APs are put to ready state from the beginning
|
||||
//
|
||||
gThread->MutexLock(ProcessorData->StateLock);
|
||||
gThread->MutexLock (ProcessorData->StateLock);
|
||||
ASSERT (ProcessorData->State == CPU_STATE_IDLE);
|
||||
ProcessorData->State = APInitialState;
|
||||
gThread->MutexUnlock (ProcessorData->StateLock);
|
||||
@ -487,7 +483,7 @@ CpuMpServicesStartupAllAps (
|
||||
for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) {
|
||||
ProcessorData = &gMPSystem.ProcessorData[Number];
|
||||
if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {
|
||||
// Skip BSP
|
||||
// Skip BSP
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -513,20 +509,19 @@ CpuMpServicesStartupAllAps (
|
||||
gMPSystem.WaitEvent = WaitEvent;
|
||||
gMPSystem.Timeout = TimeoutInMicroseconds;
|
||||
gMPSystem.TimeoutActive = (BOOLEAN)(TimeoutInMicroseconds != 0);
|
||||
Status = gBS->SetTimer (
|
||||
gMPSystem.CheckAllAPsEvent,
|
||||
TimerPeriodic,
|
||||
gPollInterval
|
||||
);
|
||||
Status = gBS->SetTimer (
|
||||
gMPSystem.CheckAllAPsEvent,
|
||||
TimerPeriodic,
|
||||
gPollInterval
|
||||
);
|
||||
return Status;
|
||||
|
||||
}
|
||||
|
||||
while (TRUE) {
|
||||
for (Number = 0; Number < gMPSystem.NumberOfProcessors; Number++) {
|
||||
ProcessorData = &gMPSystem.ProcessorData[Number];
|
||||
if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {
|
||||
// Skip BSP
|
||||
// Skip BSP
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -540,29 +535,29 @@ CpuMpServicesStartupAllAps (
|
||||
gThread->MutexUnlock (ProcessorData->StateLock);
|
||||
|
||||
switch (ProcessorState) {
|
||||
case CPU_STATE_READY:
|
||||
SetApProcedure (ProcessorData, Procedure, ProcedureArgument);
|
||||
break;
|
||||
case CPU_STATE_READY:
|
||||
SetApProcedure (ProcessorData, Procedure, ProcedureArgument);
|
||||
break;
|
||||
|
||||
case CPU_STATE_FINISHED:
|
||||
gMPSystem.FinishCount++;
|
||||
if (SingleThread) {
|
||||
Status = GetNextBlockedNumber (&NextNumber);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
gThread->MutexLock (gMPSystem.ProcessorData[NextNumber].StateLock);
|
||||
gMPSystem.ProcessorData[NextNumber].State = CPU_STATE_READY;
|
||||
gThread->MutexUnlock (gMPSystem.ProcessorData[NextNumber].StateLock);
|
||||
case CPU_STATE_FINISHED:
|
||||
gMPSystem.FinishCount++;
|
||||
if (SingleThread) {
|
||||
Status = GetNextBlockedNumber (&NextNumber);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
gThread->MutexLock (gMPSystem.ProcessorData[NextNumber].StateLock);
|
||||
gMPSystem.ProcessorData[NextNumber].State = CPU_STATE_READY;
|
||||
gThread->MutexUnlock (gMPSystem.ProcessorData[NextNumber].StateLock);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gThread->MutexLock (ProcessorData->StateLock);
|
||||
ProcessorData->State = CPU_STATE_IDLE;
|
||||
gThread->MutexUnlock (ProcessorData->StateLock);
|
||||
gThread->MutexLock (ProcessorData->StateLock);
|
||||
ProcessorData->State = CPU_STATE_IDLE;
|
||||
gThread->MutexUnlock (ProcessorData->StateLock);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -590,7 +585,6 @@ Done:
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This service lets the caller get one enabled AP to execute a caller-provided
|
||||
function. The caller can request the BSP to either wait for the completion
|
||||
@ -689,7 +683,7 @@ CpuMpServicesStartupThisAP (
|
||||
OUT BOOLEAN *Finished OPTIONAL
|
||||
)
|
||||
{
|
||||
UINTN Timeout;
|
||||
UINTN Timeout;
|
||||
|
||||
if (!IsBSP ()) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
@ -711,12 +705,13 @@ CpuMpServicesStartupThisAP (
|
||||
return EFI_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
gThread->MutexLock(gMPSystem.ProcessorData[ProcessorNumber].StateLock);
|
||||
gThread->MutexLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
|
||||
if (gMPSystem.ProcessorData[ProcessorNumber].State != CPU_STATE_IDLE) {
|
||||
gThread->MutexUnlock(gMPSystem.ProcessorData[ProcessorNumber].StateLock);
|
||||
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
gThread->MutexUnlock(gMPSystem.ProcessorData[ProcessorNumber].StateLock);
|
||||
|
||||
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
|
||||
|
||||
if ((WaitEvent != NULL) && gReadToBoot) {
|
||||
return EFI_UNSUPPORTED;
|
||||
@ -724,8 +719,8 @@ CpuMpServicesStartupThisAP (
|
||||
|
||||
Timeout = TimeoutInMicroseconds;
|
||||
|
||||
gMPSystem.StartCount = 1;
|
||||
gMPSystem.FinishCount = 0;
|
||||
gMPSystem.StartCount = 1;
|
||||
gMPSystem.FinishCount = 0;
|
||||
|
||||
SetApProcedure (&gMPSystem.ProcessorData[ProcessorNumber], Procedure, ProcedureArgument);
|
||||
|
||||
@ -759,10 +754,8 @@ CpuMpServicesStartupThisAP (
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This service switches the requested AP to be the BSP from that point onward.
|
||||
This service changes the BSP for all purposes. This call can only be performed
|
||||
@ -806,7 +799,7 @@ CpuMpServicesSwitchBSP (
|
||||
IN BOOLEAN EnableOldBSP
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index;
|
||||
|
||||
if (!IsBSP ()) {
|
||||
return EFI_DEVICE_ERROR;
|
||||
@ -829,6 +822,7 @@ CpuMpServicesSwitchBSP (
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT (Index != gMPSystem.NumberOfProcessors);
|
||||
|
||||
gThread->MutexLock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
|
||||
@ -836,6 +830,7 @@ CpuMpServicesSwitchBSP (
|
||||
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
|
||||
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
|
||||
|
||||
// Skip for now as we need switch a bunch of stack stuff around and it's complex
|
||||
@ -843,7 +838,6 @@ CpuMpServicesSwitchBSP (
|
||||
return EFI_NOT_READY;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This service lets the caller enable or disable an AP from this point onward.
|
||||
This service may only be called from the BSP.
|
||||
@ -911,17 +905,20 @@ CpuMpServicesEnableDisableAP (
|
||||
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
|
||||
return EFI_UNSUPPORTED;
|
||||
}
|
||||
|
||||
gThread->MutexUnlock (gMPSystem.ProcessorData[ProcessorNumber].StateLock);
|
||||
|
||||
if (EnableAP) {
|
||||
if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == 0 ) {
|
||||
gMPSystem.NumberOfEnabledProcessors++;
|
||||
}
|
||||
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= PROCESSOR_ENABLED_BIT;
|
||||
} else {
|
||||
if ((gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag & PROCESSOR_ENABLED_BIT) == PROCESSOR_ENABLED_BIT ) {
|
||||
gMPSystem.NumberOfEnabledProcessors--;
|
||||
}
|
||||
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag &= ~PROCESSOR_ENABLED_BIT;
|
||||
}
|
||||
|
||||
@ -933,7 +930,6 @@ CpuMpServicesEnableDisableAP (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
This return the handle number for the calling processor. This service may be
|
||||
called from the BSP and APs.
|
||||
@ -983,8 +979,6 @@ CpuMpServicesWhoAmI (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = {
|
||||
CpuMpServicesGetNumberOfProcessors,
|
||||
CpuMpServicesGetProcessorInfo,
|
||||
@ -995,8 +989,6 @@ EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = {
|
||||
CpuMpServicesWhoAmI
|
||||
};
|
||||
|
||||
|
||||
|
||||
/*++
|
||||
If timeout occurs in StartupAllAps(), a timer is set, which invokes this
|
||||
procedure periodically to check whether all APs have finished.
|
||||
@ -1006,8 +998,8 @@ EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = {
|
||||
VOID
|
||||
EFIAPI
|
||||
CpuCheckAllAPsStatus (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
UINTN ProcessorNumber;
|
||||
@ -1026,7 +1018,7 @@ CpuCheckAllAPsStatus (
|
||||
for (ProcessorNumber = 0; ProcessorNumber < gMPSystem.NumberOfProcessors; ProcessorNumber++) {
|
||||
ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber];
|
||||
if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {
|
||||
// Skip BSP
|
||||
// Skip BSP
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1041,39 +1033,40 @@ CpuCheckAllAPsStatus (
|
||||
// So, try lock it. If we can get it, cool, do our thing.
|
||||
// otherwise, just dump out & try again on the next iteration.
|
||||
Status = gThread->MutexTryLock (ProcessorData->StateLock);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessorState = ProcessorData->State;
|
||||
gThread->MutexUnlock (ProcessorData->StateLock);
|
||||
|
||||
switch (ProcessorState) {
|
||||
case CPU_STATE_FINISHED:
|
||||
if (gMPSystem.SingleThread) {
|
||||
Status = GetNextBlockedNumber (&NextNumber);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
NextData = &gMPSystem.ProcessorData[NextNumber];
|
||||
case CPU_STATE_FINISHED:
|
||||
if (gMPSystem.SingleThread) {
|
||||
Status = GetNextBlockedNumber (&NextNumber);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
NextData = &gMPSystem.ProcessorData[NextNumber];
|
||||
|
||||
gThread->MutexLock (NextData->StateLock);
|
||||
NextData->State = CPU_STATE_READY;
|
||||
gThread->MutexUnlock (NextData->StateLock);
|
||||
gThread->MutexLock (NextData->StateLock);
|
||||
NextData->State = CPU_STATE_READY;
|
||||
gThread->MutexUnlock (NextData->StateLock);
|
||||
|
||||
SetApProcedure (NextData, gMPSystem.Procedure, gMPSystem.ProcedureArgument);
|
||||
SetApProcedure (NextData, gMPSystem.Procedure, gMPSystem.ProcedureArgument);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gThread->MutexLock (ProcessorData->StateLock);
|
||||
ProcessorData->State = CPU_STATE_IDLE;
|
||||
gThread->MutexUnlock (ProcessorData->StateLock);
|
||||
gMPSystem.FinishCount++;
|
||||
break;
|
||||
gThread->MutexLock (ProcessorData->StateLock);
|
||||
ProcessorData->State = CPU_STATE_IDLE;
|
||||
gThread->MutexUnlock (ProcessorData->StateLock);
|
||||
gMPSystem.FinishCount++;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (gMPSystem.TimeoutActive && gMPSystem.Timeout == 0) {
|
||||
if (gMPSystem.TimeoutActive && (gMPSystem.Timeout == 0)) {
|
||||
//
|
||||
// Timeout
|
||||
//
|
||||
@ -1081,7 +1074,7 @@ CpuCheckAllAPsStatus (
|
||||
for (ProcessorNumber = 0; ProcessorNumber < gMPSystem.NumberOfProcessors; ProcessorNumber++) {
|
||||
ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber];
|
||||
if ((ProcessorData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {
|
||||
// Skip BSP
|
||||
// Skip BSP
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1092,9 +1085,10 @@ CpuCheckAllAPsStatus (
|
||||
|
||||
// Mark the
|
||||
Status = gThread->MutexTryLock (ProcessorData->StateLock);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessorState = ProcessorData->State;
|
||||
gThread->MutexUnlock (ProcessorData->StateLock);
|
||||
|
||||
@ -1104,17 +1098,20 @@ CpuCheckAllAPsStatus (
|
||||
if (gMPSystem.FailedList[Cpu] == END_OF_CPU_LIST) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (gMPSystem.FailedList[ProcessorNumber] == Cpu) {
|
||||
Found = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!Found) {
|
||||
gMPSystem.FailedList[gMPSystem.FailedListIndex++] = Cpu;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Force terminal exit
|
||||
gMPSystem.FinishCount = gMPSystem.StartCount;
|
||||
}
|
||||
@ -1138,21 +1135,21 @@ CpuCheckAllAPsStatus (
|
||||
|
||||
Status = gBS->SignalEvent (gMPSystem.WaitEvent);
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
VOID
|
||||
EFIAPI
|
||||
CpuCheckThisAPStatus (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
PROCESSOR_DATA_BLOCK *ProcessorData;
|
||||
PROCESSOR_STATE ProcessorState;
|
||||
|
||||
ProcessorData = (PROCESSOR_DATA_BLOCK *) Context;
|
||||
ProcessorData = (PROCESSOR_DATA_BLOCK *)Context;
|
||||
|
||||
//
|
||||
// This is an Interrupt Service routine.
|
||||
@ -1162,9 +1159,10 @@ CpuCheckThisAPStatus (
|
||||
// otherwise, just dump out & try again on the next iteration.
|
||||
//
|
||||
Status = gThread->MutexTryLock (ProcessorData->StateLock);
|
||||
if (EFI_ERROR(Status)) {
|
||||
if (EFI_ERROR (Status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessorState = ProcessorData->State;
|
||||
gThread->MutexUnlock (ProcessorData->StateLock);
|
||||
|
||||
@ -1180,10 +1178,9 @@ CpuCheckThisAPStatus (
|
||||
gThread->MutexUnlock (ProcessorData->StateLock);
|
||||
}
|
||||
|
||||
return ;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/*++
|
||||
This function is called by all processors (both BSP and AP) once and collects MP related data
|
||||
|
||||
@ -1195,25 +1192,25 @@ CpuCheckThisAPStatus (
|
||||
--*/
|
||||
EFI_STATUS
|
||||
FillInProcessorInformation (
|
||||
IN BOOLEAN BSP,
|
||||
IN UINTN ProcessorNumber
|
||||
IN BOOLEAN BSP,
|
||||
IN UINTN ProcessorNumber
|
||||
)
|
||||
{
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Info.ProcessorId = gThread->Self ();
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag = PROCESSOR_ENABLED_BIT | PROCESSOR_HEALTH_STATUS_BIT;
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Info.ProcessorId = gThread->Self ();
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag = PROCESSOR_ENABLED_BIT | PROCESSOR_HEALTH_STATUS_BIT;
|
||||
if (BSP) {
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Info.StatusFlag |= PROCESSOR_AS_BSP_BIT;
|
||||
}
|
||||
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Package = (UINT32) ProcessorNumber;
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Package = (UINT32)ProcessorNumber;
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Core = 0;
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Info.Location.Thread = 0;
|
||||
gMPSystem.ProcessorData[ProcessorNumber].State = BSP ? CPU_STATE_BUSY : CPU_STATE_IDLE;
|
||||
gMPSystem.ProcessorData[ProcessorNumber].State = BSP ? CPU_STATE_BUSY : CPU_STATE_IDLE;
|
||||
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Procedure = NULL;
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Parameter = NULL;
|
||||
gMPSystem.ProcessorData[ProcessorNumber].StateLock = gThread->MutexInit ();
|
||||
gMPSystem.ProcessorData[ProcessorNumber].ProcedureLock = gThread->MutexInit ();
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Procedure = NULL;
|
||||
gMPSystem.ProcessorData[ProcessorNumber].Parameter = NULL;
|
||||
gMPSystem.ProcessorData[ProcessorNumber].StateLock = gThread->MutexInit ();
|
||||
gMPSystem.ProcessorData[ProcessorNumber].ProcedureLock = gThread->MutexInit ();
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@ -1230,7 +1227,7 @@ CpuDriverApIdolLoop (
|
||||
PROCESSOR_DATA_BLOCK *ProcessorData;
|
||||
|
||||
ProcessorNumber = (UINTN)Context;
|
||||
ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber];
|
||||
ProcessorData = &gMPSystem.ProcessorData[ProcessorNumber];
|
||||
|
||||
ProcessorData->Info.ProcessorId = gThread->Self ();
|
||||
|
||||
@ -1267,15 +1264,13 @@ CpuDriverApIdolLoop (
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
InitializeMpSystemData (
|
||||
IN UINTN NumberOfProcessors
|
||||
IN UINTN NumberOfProcessors
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Clear the data structure area first.
|
||||
@ -1285,8 +1280,8 @@ InitializeMpSystemData (
|
||||
//
|
||||
// First BSP fills and inits all known values, including it's own records.
|
||||
//
|
||||
gMPSystem.NumberOfProcessors = NumberOfProcessors;
|
||||
gMPSystem.NumberOfEnabledProcessors = NumberOfProcessors;
|
||||
gMPSystem.NumberOfProcessors = NumberOfProcessors;
|
||||
gMPSystem.NumberOfEnabledProcessors = NumberOfProcessors;
|
||||
|
||||
gMPSystem.ProcessorData = AllocateZeroPool (gMPSystem.NumberOfProcessors * sizeof (PROCESSOR_DATA_BLOCK));
|
||||
ASSERT (gMPSystem.ProcessorData != NULL);
|
||||
@ -1302,10 +1297,9 @@ InitializeMpSystemData (
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
|
||||
for (Index = 0; Index < gMPSystem.NumberOfProcessors; Index++) {
|
||||
if ((gMPSystem.ProcessorData[Index].Info.StatusFlag & PROCESSOR_AS_BSP_BIT) == PROCESSOR_AS_BSP_BIT) {
|
||||
// Skip BSP
|
||||
// Skip BSP
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1318,21 +1312,18 @@ InitializeMpSystemData (
|
||||
(VOID *)Index
|
||||
);
|
||||
|
||||
|
||||
Status = gBS->CreateEvent (
|
||||
EVT_TIMER | EVT_NOTIFY_SIGNAL,
|
||||
TPL_CALLBACK,
|
||||
CpuCheckThisAPStatus,
|
||||
(VOID *) &gMPSystem.ProcessorData[Index],
|
||||
&gMPSystem.ProcessorData[Index].CheckThisAPEvent
|
||||
);
|
||||
EVT_TIMER | EVT_NOTIFY_SIGNAL,
|
||||
TPL_CALLBACK,
|
||||
CpuCheckThisAPStatus,
|
||||
(VOID *)&gMPSystem.ProcessorData[Index],
|
||||
&gMPSystem.ProcessorData[Index].CheckThisAPEvent
|
||||
);
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Invoke a notification event
|
||||
|
||||
@ -1344,32 +1335,30 @@ InitializeMpSystemData (
|
||||
VOID
|
||||
EFIAPI
|
||||
CpuReadToBootFunction (
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
IN EFI_EVENT Event,
|
||||
IN VOID *Context
|
||||
)
|
||||
{
|
||||
gReadToBoot = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EFI_STATUS
|
||||
CpuMpServicesInit (
|
||||
OUT UINTN *MaxCpus
|
||||
OUT UINTN *MaxCpus
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE Handle;
|
||||
EMU_IO_THUNK_PROTOCOL *IoThunk;
|
||||
EFI_STATUS Status;
|
||||
EFI_HANDLE Handle;
|
||||
EMU_IO_THUNK_PROTOCOL *IoThunk;
|
||||
|
||||
*MaxCpus = 1; // BSP
|
||||
IoThunk = GetIoThunkInstance (&gEmuThreadThunkProtocolGuid, 0);
|
||||
IoThunk = GetIoThunkInstance (&gEmuThreadThunkProtocolGuid, 0);
|
||||
if (IoThunk != NULL) {
|
||||
Status = IoThunk->Open (IoThunk);
|
||||
if (!EFI_ERROR (Status)) {
|
||||
if (IoThunk->ConfigString != NULL) {
|
||||
*MaxCpus += StrDecimalToUintn (IoThunk->ConfigString);
|
||||
gThread = IoThunk->Interface;
|
||||
gThread = IoThunk->Interface;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1379,9 +1368,9 @@ CpuMpServicesInit (
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
gPollInterval = (UINTN) PcdGet64 (PcdEmuMpServicesPollingInterval);
|
||||
gPollInterval = (UINTN)PcdGet64 (PcdEmuMpServicesPollingInterval);
|
||||
|
||||
Status = InitializeMpSystemData (*MaxCpus);
|
||||
Status = InitializeMpSystemData (*MaxCpus);
|
||||
if (EFI_ERROR (Status)) {
|
||||
return Status;
|
||||
}
|
||||
@ -1395,10 +1384,9 @@ CpuMpServicesInit (
|
||||
Handle = NULL;
|
||||
Status = gBS->InstallMultipleProtocolInterfaces (
|
||||
&Handle,
|
||||
&gEfiMpServiceProtocolGuid, &mMpServicesTemplate,
|
||||
&gEfiMpServiceProtocolGuid,
|
||||
&mMpServicesTemplate,
|
||||
NULL
|
||||
);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user