VOID *mApStackStart = 0;\r
\r
EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = {\r
- NULL, // GetNumberOfProcessors,\r
+ GetNumberOfProcessors,\r
NULL, // GetProcessorInfo,\r
NULL, // StartupAllAPs,\r
NULL, // StartupThisAP,\r
WhoAmI\r
};\r
\r
+/**\r
+ Check whether caller processor is BSP.\r
+\r
+ @retval TRUE the caller is BSP\r
+ @retval FALSE the caller is AP\r
+\r
+**/\r
+BOOLEAN\r
+IsBSP (\r
+ VOID\r
+ )\r
+{\r
+ UINTN CpuIndex;\r
+ CPU_DATA_BLOCK *CpuData;\r
+\r
+ CpuData = NULL;\r
+\r
+ WhoAmI (&mMpServicesTemplate, &CpuIndex);\r
+ CpuData = &mMpSystemData.CpuDatas[CpuIndex];\r
+\r
+ return CpuData->Info.StatusFlag & PROCESSOR_AS_BSP_BIT ? TRUE : FALSE;\r
+}\r
+\r
+/**\r
+ This service retrieves the number of logical processor in the platform\r
+ and the number of those logical processors that are enabled on this boot.\r
+ This service may only be called from the BSP.\r
+\r
+ This function is used to retrieve the following information:\r
+ - The number of logical processors that are present in the system.\r
+ - The number of enabled logical processors in the system at the instant\r
+ this call is made.\r
+\r
+ Because MP Service Protocol provides services to enable and disable processors\r
+ dynamically, the number of enabled logical processors may vary during the\r
+ course of a boot session.\r
+\r
+ If this service is called from an AP, then EFI_DEVICE_ERROR is returned.\r
+ If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then\r
+ EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors\r
+ is returned in NumberOfProcessors, the number of currently enabled processor\r
+ is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.\r
+\r
+ @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL\r
+ instance.\r
+ @param[out] NumberOfProcessors Pointer to the total number of logical\r
+ processors in the system, including the BSP\r
+ and disabled APs.\r
+ @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical\r
+ processors that exist in system, including\r
+ the BSP.\r
+\r
+ @retval EFI_SUCCESS The number of logical processors and enabled\r
+ logical processors was retrieved.\r
+ @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
+ @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.\r
+ @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetNumberOfProcessors (\r
+ IN EFI_MP_SERVICES_PROTOCOL *This,\r
+ OUT UINTN *NumberOfProcessors,\r
+ OUT UINTN *NumberOfEnabledProcessors\r
+ )\r
+{\r
+ if ((NumberOfProcessors == NULL) || (NumberOfEnabledProcessors == NULL)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+\r
+ if (!IsBSP ()) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
+\r
+ *NumberOfProcessors = mMpSystemData.NumberOfProcessors;\r
+ *NumberOfEnabledProcessors = mMpSystemData.NumberOfEnabledProcessors;\r
+ return EFI_SUCCESS;\r
+}\r
+\r
/**\r
This return the handle number for the calling processor. This service may be\r
called from the BSP and APs.\r
IN UINTN ProcessorNumber\r
);\r
\r
+/**\r
+ This service retrieves the number of logical processor in the platform\r
+ and the number of those logical processors that are enabled on this boot.\r
+ This service may only be called from the BSP.\r
+\r
+ This function is used to retrieve the following information:\r
+ - The number of logical processors that are present in the system.\r
+ - The number of enabled logical processors in the system at the instant\r
+ this call is made.\r
+\r
+ Because MP Service Protocol provides services to enable and disable processors\r
+ dynamically, the number of enabled logical processors may vary during the\r
+ course of a boot session.\r
+\r
+ If this service is called from an AP, then EFI_DEVICE_ERROR is returned.\r
+ If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then\r
+ EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors\r
+ is returned in NumberOfProcessors, the number of currently enabled processor\r
+ is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.\r
+\r
+ @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL\r
+ instance.\r
+ @param[out] NumberOfProcessors Pointer to the total number of logical\r
+ processors in the system, including the BSP\r
+ and disabled APs.\r
+ @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical\r
+ processors that exist in system, including\r
+ the BSP.\r
+\r
+ @retval EFI_SUCCESS The number of logical processors and enabled\r
+ logical processors was retrieved.\r
+ @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
+ @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.\r
+ @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+GetNumberOfProcessors (\r
+ IN EFI_MP_SERVICES_PROTOCOL *This,\r
+ OUT UINTN *NumberOfProcessors,\r
+ OUT UINTN *NumberOfEnabledProcessors\r
+ );\r
+\r
/**\r
This return the handle number for the calling processor. This service may be\r
called from the BSP and APs.\r