]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MpInitLib/MpLib.h
UefiCpuPkg/MpInitLib: Skip reading PlatformId on AMD processors.
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / MpLib.h
old mode 100644 (file)
new mode 100755 (executable)
index 56b0df6..0c89f8a
@@ -1,7 +1,9 @@
 /** @file\r
   Common header file for MP Initialize Library.\r
 \r
-  Copyright (c) 2016 - 2019, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2020, AMD Inc. All rights reserved.<BR>\r
+\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -12,6 +14,7 @@
 #include <PiPei.h>\r
 \r
 #include <Register/Intel/Cpuid.h>\r
+#include <Register/Amd/Cpuid.h>\r
 #include <Register/Intel/Msr.h>\r
 #include <Register/Intel/LocalApic.h>\r
 #include <Register/Intel/Microcode.h>\r
@@ -29,6 +32,8 @@
 #include <Library/MtrrLib.h>\r
 #include <Library/HobLib.h>\r
 \r
+#include <Guid/MicrocodePatchHob.h>\r
+\r
 #define WAKEUP_AP_SIGNAL SIGNATURE_32 ('S', 'T', 'A', 'P')\r
 \r
 #define CPU_INIT_MP_LIB_HOB_GUID \\r
@@ -54,7 +59,6 @@
 typedef struct {\r
   UINTN    Address;\r
   UINTN    Size;\r
-  UINTN    AlignedSize;\r
 } MICROCODE_PATCH_INFO;\r
 \r
 //\r
@@ -138,6 +142,7 @@ typedef struct {
   EFI_EVENT                      WaitEvent;\r
   UINT32                         ProcessorSignature;\r
   UINT8                          PlatformId;\r
+  UINT64                         MicrocodeEntryAddr;\r
 } CPU_AP_DATA;\r
 \r
 //\r
@@ -262,11 +267,6 @@ struct _CPU_MP_DATA {
   UINT64                         MicrocodePatchAddress;\r
   UINT64                         MicrocodePatchRegionSize;\r
 \r
-  UINT32                         ProcessorSignature;\r
-  UINT32                         ProcessorFlags;\r
-  UINT64                         MicrocodeDataAddress;\r
-  UINT32                         MicrocodeRevision;\r
-\r
   //\r
   // Whether need to use Init-Sipi-Sipi to wake up the APs.\r
   // Two cases need to set this value to TRUE. One is in HLT\r
@@ -580,25 +580,48 @@ CheckAndUpdateApsStatus (
 /**\r
   Detect whether specified processor can find matching microcode patch and load it.\r
 \r
-  @param[in]  CpuMpData    The pointer to CPU MP Data structure.\r
-  @param[in]  IsBspCallIn  Indicate whether the caller is BSP or not.\r
+  @param[in]  CpuMpData        The pointer to CPU MP Data structure.\r
+  @param[in]  ProcessorNumber  The handle number of the processor. The range is\r
+                               from 0 to the total number of logical processors\r
+                               minus 1.\r
 **/\r
 VOID\r
 MicrocodeDetect (\r
   IN CPU_MP_DATA             *CpuMpData,\r
-  IN BOOLEAN                 IsBspCallIn\r
+  IN UINTN                   ProcessorNumber\r
   );\r
 \r
 /**\r
-  Load the required microcode patches data into memory.\r
+  Shadow the required microcode patches data into memory.\r
 \r
   @param[in, out]  CpuMpData    The pointer to CPU MP Data structure.\r
 **/\r
 VOID\r
-LoadMicrocodePatch (\r
+ShadowMicrocodeUpdatePatch (\r
   IN OUT CPU_MP_DATA             *CpuMpData\r
   );\r
 \r
+/**\r
+  Get the cached microcode patch base address and size from the microcode patch\r
+  information cache HOB.\r
+\r
+  @param[out] Address       Base address of the microcode patches data.\r
+                            It will be updated if the microcode patch\r
+                            information cache HOB is found.\r
+  @param[out] RegionSize    Size of the microcode patches data.\r
+                            It will be updated if the microcode patch\r
+                            information cache HOB is found.\r
+\r
+  @retval  TRUE     The microcode patch information cache HOB is found.\r
+  @retval  FALSE    The microcode patch information cache HOB is not found.\r
+\r
+**/\r
+BOOLEAN\r
+GetMicrocodePatchInfoFromHob (\r
+  UINT64                         *Address,\r
+  UINT64                         *RegionSize\r
+  );\r
+\r
 /**\r
   Detect whether Mwait-monitor feature is supported.\r
 \r
@@ -619,5 +642,36 @@ EnableDebugAgent (
   VOID\r
   );\r
 \r
+/**\r
+  Find the current Processor number by APIC ID.\r
+\r
+  @param[in]  CpuMpData         Pointer to PEI CPU MP Data\r
+  @param[out] ProcessorNumber   Return the pocessor number found\r
+\r
+  @retval EFI_SUCCESS          ProcessorNumber is found and returned.\r
+  @retval EFI_NOT_FOUND        ProcessorNumber is not found.\r
+**/\r
+EFI_STATUS\r
+GetProcessorNumber (\r
+  IN CPU_MP_DATA               *CpuMpData,\r
+  OUT UINTN                    *ProcessorNumber\r
+  );\r
+\r
+/**\r
+  This funtion will try to invoke platform specific microcode shadow logic to\r
+  relocate microcode update patches into memory.\r
+\r
+  @param[in] CpuMpData  The pointer to CPU MP Data structure.\r
+\r
+  @retval EFI_SUCCESS              Shadow microcode success.\r
+  @retval EFI_OUT_OF_RESOURCES     No enough resource to complete the operation.\r
+  @retval EFI_UNSUPPORTED          Can't find platform specific microcode shadow\r
+                                   PPI/Protocol.\r
+**/\r
+EFI_STATUS\r
+PlatformShadowMicrocode (\r
+  IN OUT CPU_MP_DATA             *CpuMpData\r
+  );\r
+\r
 #endif\r
 \r