]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MpInitLib: Implementation of MpInitLibEnableDisableAP()
authorJeff Fan <jeff.fan@intel.com>
Thu, 21 Jul 2016 13:23:05 +0000 (21:23 +0800)
committerJeff Fan <jeff.fan@intel.com>
Wed, 17 Aug 2016 12:02:17 +0000 (20:02 +0800)
v4:
  1. Simply the internal function MpInitLibEnableDisableAP()'s function
     header due to it is duplicated with MpInitLibEnableDisableAP().
v3:
  1. Use CamelCase for mCheckAllAPsEvent, mStopCheckAllApsStatus.

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>
UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
UefiCpuPkg/Library/MpInitLib/MpLib.c
UefiCpuPkg/Library/MpInitLib/MpLib.h
UefiCpuPkg/Library/MpInitLib/PeiMpLib.c

index 785653be8f6e4708b0f2be2a70609dbac72143cc..988920fc0701449892c6a24c85981cae83d650e0 100644 (file)
@@ -454,5 +454,23 @@ MpInitLibEnableDisableAP (
   IN  UINT32                    *HealthFlag OPTIONAL\r
   )\r
 {\r
-  return EFI_UNSUPPORTED;\r
+  EFI_STATUS     Status;\r
+  BOOLEAN        TempStopCheckState;\r
+\r
+  TempStopCheckState = FALSE;\r
+  //\r
+  // temporarily stop checkAllAPsStatus for initialize parameters.\r
+  //\r
+  if (!mStopCheckAllApsStatus) {\r
+    mStopCheckAllApsStatus = TRUE;\r
+    TempStopCheckState     = TRUE;\r
+  }\r
+\r
+  Status = EnableDisableApWorker (ProcessorNumber, EnableAP, HealthFlag);\r
+\r
+  if (TempStopCheckState) {\r
+    mStopCheckAllApsStatus = FALSE;\r
+  }\r
+\r
+  return Status;\r
 }\r
index 8ae08f4d5d5f050bf89cda7be0fc614e566f62cc..3a266e9607d4884ded4dc86bd28123a0f50b393c 100644 (file)
@@ -1238,6 +1238,62 @@ SwitchBSPWorker (
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  Worker function to let the caller enable or disable an AP from this point onward.\r
+  This service may only be called from the BSP.\r
+\r
+  @param[in] ProcessorNumber   The handle number of AP.\r
+  @param[in] EnableAP          Specifies the new state for the processor for\r
+                               enabled, FALSE for disabled.\r
+  @param[in] HealthFlag        If not NULL, a pointer to a value that specifies\r
+                               the new health status of the AP.\r
+\r
+  @retval EFI_SUCCESS          The specified AP was enabled or disabled successfully.\r
+  @retval others               Failed to Enable/Disable AP.\r
+\r
+**/\r
+EFI_STATUS\r
+EnableDisableApWorker (\r
+  IN  UINTN                     ProcessorNumber,\r
+  IN  BOOLEAN                   EnableAP,\r
+  IN  UINT32                    *HealthFlag OPTIONAL\r
+  )\r
+{\r
+  CPU_MP_DATA               *CpuMpData;\r
+  UINTN                     CallerNumber;\r
+\r
+  CpuMpData = GetCpuMpData ();\r
+\r
+  //\r
+  // Check whether caller processor is BSP\r
+  //\r
+  MpInitLibWhoAmI (&CallerNumber);\r
+  if (CallerNumber != CpuMpData->BspNumber) {\r
+    return EFI_DEVICE_ERROR;\r
+  }\r
+\r
+  if (ProcessorNumber == CpuMpData->BspNumber) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  if (ProcessorNumber >= CpuMpData->CpuCount) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+\r
+  if (!EnableAP) {\r
+    SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateDisabled);\r
+  } else {\r
+    SetApState (&CpuMpData->CpuData[ProcessorNumber], CpuStateIdle);\r
+  }\r
+\r
+  if (HealthFlag != NULL) {\r
+    CpuMpData->CpuData[ProcessorNumber].CpuHealthy =\r
+          (BOOLEAN) ((*HealthFlag & PROCESSOR_HEALTH_STATUS_BIT) != 0);\r
+  }\r
+\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
index bfc7fb72e0124cdee4279d658b661b3d982874c5..f8b172f414e48e9f30773878e8b71099c3f8dff8 100644 (file)
@@ -364,6 +364,27 @@ SwitchBSPWorker (
   IN BOOLEAN                   EnableOldBSP\r
   );\r
 \r
+/**\r
+  Worker function to let the caller enable or disable an AP from this point onward.\r
+  This service may only be called from the BSP.\r
+\r
+  @param[in] ProcessorNumber   The handle number of AP.\r
+  @param[in] EnableAP          Specifies the new state for the processor for\r
+                               enabled, FALSE for disabled.\r
+  @param[in] HealthFlag        If not NULL, a pointer to a value that specifies\r
+                               the new health status of the AP.\r
+\r
+  @retval EFI_SUCCESS          The specified AP was enabled or disabled successfully.\r
+  @retval others               Failed to Enable/Disable AP.\r
+\r
+**/\r
+EFI_STATUS\r
+EnableDisableApWorker (\r
+  IN  UINTN                     ProcessorNumber,\r
+  IN  BOOLEAN                   EnableAP,\r
+  IN  UINT32                    *HealthFlag OPTIONAL\r
+  );\r
+\r
 /**\r
   Get pointer to CPU MP Data structure from GUIDed HOB.\r
 \r
index cdec0108c54b06482d1990496bd0bbb49c3a9a74..fe585bdce8c4ea7216be4f0ecab81aa15a7cc337 100644 (file)
@@ -604,7 +604,7 @@ MpInitLibEnableDisableAP (
   IN  UINT32                    *HealthFlag OPTIONAL\r
   )\r
 {\r
-  return EFI_UNSUPPORTED;\r
+  return EnableDisableApWorker (ProcessorNumber, EnableAP, HealthFlag);\r
 }\r
 \r
 \r