mirror of
https://gitlab.com/qemu-project/edk2.git
synced 2025-06-29 04:33:04 +08:00
UefiCpuPkg/MpInitLib: Implementation of MpInitLibGetNumberOfProcessors()
Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
This commit is contained in:
@ -956,6 +956,7 @@ MpInitLibWhoAmI (
|
|||||||
{
|
{
|
||||||
return EFI_UNSUPPORTED;
|
return EFI_UNSUPPORTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Retrieves the number of logical processor in the platform and the number of
|
Retrieves the number of logical processor in the platform and the number of
|
||||||
those logical processors that are enabled on this boot. This service may only
|
those logical processors that are enabled on this boot. This service may only
|
||||||
@ -983,9 +984,45 @@ MpInitLibGetNumberOfProcessors (
|
|||||||
OUT UINTN *NumberOfEnabledProcessors OPTIONAL
|
OUT UINTN *NumberOfEnabledProcessors OPTIONAL
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
return EFI_UNSUPPORTED;
|
CPU_MP_DATA *CpuMpData;
|
||||||
|
UINTN CallerNumber;
|
||||||
|
UINTN ProcessorNumber;
|
||||||
|
UINTN EnabledProcessorNumber;
|
||||||
|
UINTN Index;
|
||||||
|
|
||||||
|
CpuMpData = GetCpuMpData ();
|
||||||
|
|
||||||
|
if ((NumberOfProcessors == NULL) && (NumberOfEnabledProcessors == NULL)) {
|
||||||
|
return EFI_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check whether caller processor is BSP
|
||||||
|
//
|
||||||
|
MpInitLibWhoAmI (&CallerNumber);
|
||||||
|
if (CallerNumber != CpuMpData->BspNumber) {
|
||||||
|
return EFI_DEVICE_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
|
ProcessorNumber = CpuMpData->CpuCount;
|
||||||
|
EnabledProcessorNumber = 0;
|
||||||
|
for (Index = 0; Index < ProcessorNumber; Index++) {
|
||||||
|
if (GetApState (&CpuMpData->CpuData[Index]) != CpuStateDisabled) {
|
||||||
|
EnabledProcessorNumber ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NumberOfProcessors != NULL) {
|
||||||
|
*NumberOfProcessors = ProcessorNumber;
|
||||||
|
}
|
||||||
|
if (NumberOfEnabledProcessors != NULL) {
|
||||||
|
*NumberOfEnabledProcessors = EnabledProcessorNumber;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Get pointer to CPU MP Data structure from GUIDed HOB.
|
Get pointer to CPU MP Data structure from GUIDed HOB.
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user