[edk2-devel] [RFC PATCH v3 40/43] UefiCpuPkg/MpInitLib: Add MP finalization interface to MpInitLib

Lendacky, Thomas thomas.lendacky at amd.com
Wed Nov 20 21:32:46 UTC 2019


BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2198

Provide an MP finalization function that can be called from the CPU
protocol finalization function.

Cc: Eric Dong <eric.dong at intel.com>
Cc: Ray Ni <ray.ni at intel.com>
Cc: Laszlo Ersek <lersek at redhat.com>
Signed-off-by: Tom Lendacky <thomas.lendacky at amd.com>
---
 UefiCpuPkg/Include/Library/MpInitLib.h  | 14 ++++++++++++++
 UefiCpuPkg/Library/MpInitLib/MpLib.h    | 11 +++++++++++
 UefiCpuPkg/Library/MpInitLib/DxeMpLib.c | 18 ++++++++++++++++++
 UefiCpuPkg/Library/MpInitLib/MpLib.c    | 23 +++++++++++++++++++++++
 UefiCpuPkg/Library/MpInitLib/PeiMpLib.c | 16 ++++++++++++++++
 5 files changed, 82 insertions(+)

diff --git a/UefiCpuPkg/Include/Library/MpInitLib.h b/UefiCpuPkg/Include/Library/MpInitLib.h
index 31eb227f1209..f9beeefca78e 100644
--- a/UefiCpuPkg/Include/Library/MpInitLib.h
+++ b/UefiCpuPkg/Include/Library/MpInitLib.h
@@ -378,4 +378,18 @@ MpInitLibStartupAllCPUs (
   IN  VOID                      *ProcedureArgument      OPTIONAL
   );
 
+/**
+  This service allows users of MpLib to make any finalization changes
+  before transferring control out of UEFI
+
+  @retval  EFI_SUCCESS           MP initialization succeeds.
+  @retval  Others                MP initialization fails.
+
+**/
+EFI_STATUS
+EFIAPI
+MpLibFinalize (
+  VOID
+  );
+
 #endif
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpInitLib/MpLib.h
index 445ec2e950a9..22cf798c017d 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
@@ -655,5 +655,16 @@ EnableDebugAgent (
   VOID
   );
 
+/**
+  Perform MpLib finalization before transferring control out of UEFI
+
+  @param[in] CpuMpData  The pointer to CPU MP Data structure.
+
+**/
+EFI_STATUS
+MpFinalize (
+  IN CPU_MP_DATA   *CpuMpData
+  );
+
 #endif
 
diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
index 8df5b6d919e6..16603ef3f20e 100644
--- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
@@ -884,3 +884,21 @@ MpInitLibEnableDisableAP (
 
   return Status;
 }
+
+/**
+  MP finalization
+
+  @param[in] CpuMpData  The pointer to CPU MP Data structure.
+**/
+EFI_STATUS
+MpFinalize (
+  IN CPU_MP_DATA   *CpuMpData
+  )
+{
+  //
+  // DXE phase will do this transition, but just return EFI_SUCCESS for now.
+  //
+  return EFI_SUCCESS;
+}
+
+
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.c b/UefiCpuPkg/Library/MpInitLib/MpLib.c
index 817fbe85dd7d..63df349b0c92 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.c
@@ -1800,6 +1800,29 @@ CheckAllAPs (
   return EFI_NOT_READY;
 }
 
+/**
+  MP finalization
+
+  This service allows users of MpLib to make any finalization changes
+  before transferring control out of UEFI.
+
+  This service must be invoked before exiting boot services.
+
+  @retval  EFI_SUCCESS           MP finalization succeeds.
+
+**/
+EFI_STATUS
+EFIAPI
+MpLibFinalize (
+  VOID
+  )
+{
+  CPU_MP_DATA              *CpuMpData;
+
+  CpuMpData = GetCpuMpData ();
+  return MpFinalize (CpuMpData);
+}
+
 /**
   MP Initialize Library initialization.
 
diff --git a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
index 56956a615b6b..793d26b1bf12 100644
--- a/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
+++ b/UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
@@ -604,4 +604,20 @@ MpInitLibEnableDisableAP (
   return EnableDisableApWorker (ProcessorNumber, EnableAP, HealthFlag);
 }
 
+/**
+  MP finalization
+
+  @param[in] CpuMpData  The pointer to CPU MP Data structure.
+**/
+EFI_STATUS
+MpFinalize (
+  IN CPU_MP_DATA   *CpuMpData
+  )
+{
+  //
+  // PEI phase shouldn't do such a transition. So simply return EFI_SUCCESS.
+  //
+  return EFI_SUCCESS;
+}
+
 
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#50980): https://edk2.groups.io/g/devel/message/50980
Mute This Topic: https://groups.io/mt/60984620/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list