]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/CpuMpPei/CpuMpPei.c
UefiCpuPkg/CpuMpPei: Build one GUIDed HOB to save CPU MP Data
[mirror_edk2.git] / UefiCpuPkg / CpuMpPei / CpuMpPei.c
index a2f25b94050f012c65a1c65afbfd63e1c02f6840..ae98c38639838dedd67f44f75c5a4691fd872569 100644 (file)
@@ -94,6 +94,31 @@ SortApicId (
     }
   }
 }
+
+/**
+  Get CPU MP Data pointer from the Guided HOB.
+
+  @return  Pointer to Pointer to PEI CPU MP Data
+**/
+PEI_CPU_MP_DATA *
+GetMpHobData (
+  VOID
+  )
+{
+  EFI_HOB_GUID_TYPE       *GuidHob;
+  VOID                    *DataInHob;
+  PEI_CPU_MP_DATA         *CpuMpData;
+
+  CpuMpData = NULL;
+  GuidHob = GetFirstGuidHob (&gEfiCallerIdGuid);
+  if (GuidHob != NULL) {
+    DataInHob = GET_GUID_HOB_DATA (GuidHob);
+    CpuMpData = (PEI_CPU_MP_DATA *)(*(UINTN *)DataInHob);
+  }
+  ASSERT (CpuMpData != NULL);
+  return CpuMpData;
+}
+
 /**
   This function will be called from AP reset code if BSP uses WakeUpAP.
 
@@ -118,6 +143,11 @@ ApCFunction (
     BistData = *(UINTN *) (PeiCpuMpData->Buffer + NumApsExecuting * PeiCpuMpData->CpuApStackSize - sizeof (UINTN));
     PeiCpuMpData->CpuData[NumApsExecuting].ApicId        = GetInitialApicId ();
     PeiCpuMpData->CpuData[NumApsExecuting].Health.Uint32 = (UINT32) BistData;
+    //
+    // Sync BSP's Mtrr table to all wakeup APs and load microcode on APs.
+    //
+    MtrrSetAllMtrrs (&PeiCpuMpData->MtrrTable);
+    MicrocodeDetect ();
   }
 
   //
@@ -284,7 +314,14 @@ CountProcessorNumber (
   IN PEI_CPU_MP_DATA            *PeiCpuMpData
   )
 {
-
+  //
+  // Load Microcode on BSP
+  //
+  MicrocodeDetect ();
+  //
+  // Store BSP's MTRR setting
+  //
+  MtrrGetAllMtrrs (&PeiCpuMpData->MtrrTable);
   //
   // Send broadcast IPI to APs to wakeup APs
   //
@@ -401,6 +438,14 @@ CpuMpPeimInit (
   // Count processor number and collect processor information
   //
   ProcessorCount = CountProcessorNumber (PeiCpuMpData);
+  //
+  // Build location of PEI CPU MP DATA buffer in HOB
+  //
+  BuildGuidDataHob (
+    &gEfiCallerIdGuid,
+    (VOID *)&PeiCpuMpData,
+    sizeof(UINT64)
+    );
 
   return EFI_SUCCESS;
 }