X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=UefiCpuPkg%2FCpuMpPei%2FCpuMpPei.c;fp=UefiCpuPkg%2FCpuMpPei%2FCpuMpPei.c;h=b5f8887007e42366c7275116f7faf3c9e71be5c5;hp=4a453c657092a3bc094e925aa4356f4dcad91c7b;hb=a1a4c7a467d12db1c4652fda504ada4f368c1e26;hpb=ee78341e266d5442670c373c8ba33c75b5b04d3f diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c index 4a453c6570..b5f8887007 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c @@ -28,6 +28,7 @@ GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = { @param PeiCpuMpData Pointer to PEI CPU MP Data **/ +STATIC VOID SortApicId ( IN PEI_CPU_MP_DATA *PeiCpuMpData @@ -84,6 +85,7 @@ SortApicId ( @param Buffer Pointer to private data buffer. **/ +STATIC VOID EFIAPI ApFuncEnableX2Apic ( @@ -100,6 +102,7 @@ ApFuncEnableX2Apic ( @return The AP loop mode. **/ +STATIC UINT8 GetApLoopMode ( OUT UINT16 *MonitorFilterSize @@ -170,6 +173,7 @@ GetMpHobData ( @param VolatileRegisters Returns buffer saved the volatile resisters **/ +STATIC VOID SaveVolatileRegisters ( OUT CPU_VOLATILE_REGISTERS *VolatileRegisters @@ -203,6 +207,7 @@ SaveVolatileRegisters ( @param IsRestoreDr TRUE: Restore DRx if supported FALSE: Do not restore DRx **/ +STATIC VOID RestoreVolatileRegisters ( IN CPU_VOLATILE_REGISTERS *VolatileRegisters, @@ -232,12 +237,42 @@ RestoreVolatileRegisters ( } } +/** + Find the current Processor number by APIC ID. + + @param PeiCpuMpData Pointer to PEI CPU MP Data + @param ProcessorNumber Return the pocessor number found + + @retval EFI_SUCCESS ProcessorNumber is found and returned. + @retval EFI_NOT_FOUND ProcessorNumber is not found. +**/ +STATIC +EFI_STATUS +GetProcessorNumber ( + IN PEI_CPU_MP_DATA *PeiCpuMpData, + OUT UINTN *ProcessorNumber + ) +{ + UINTN TotalProcessorNumber; + UINTN Index; + + TotalProcessorNumber = PeiCpuMpData->CpuCount; + for (Index = 0; Index < TotalProcessorNumber; Index ++) { + if (PeiCpuMpData->CpuData[Index].ApicId == GetInitialApicId ()) { + *ProcessorNumber = Index; + return EFI_SUCCESS; + } + } + return EFI_NOT_FOUND; +} + /** This function will be called from AP reset code if BSP uses WakeUpAP. @param ExchangeInfo Pointer to the MP exchange info buffer @param NumApsExecuting Number of current executing AP **/ +STATIC VOID EFIAPI ApCFunction ( @@ -407,6 +442,7 @@ WriteStartupSignal ( @param Procedure The function to be invoked by AP @param ProcedureArgument The argument to be passed into AP function **/ +STATIC VOID WakeUpAP ( IN PEI_CPU_MP_DATA *PeiCpuMpData, @@ -487,6 +523,7 @@ WakeUpAP ( @retval other Return wakeup buffer address below 1MB. @retval -1 Cannot find free memory below 1MB. **/ +STATIC UINTN GetWakeupBuffer ( IN UINTN WakeupBufferSize @@ -556,6 +593,7 @@ GetWakeupBuffer ( @param PeiCpuMpData Pointer to PEI CPU MP Data **/ +STATIC VOID BackupAndPrepareWakeupBuffer( IN PEI_CPU_MP_DATA *PeiCpuMpData @@ -578,6 +616,7 @@ BackupAndPrepareWakeupBuffer( @param PeiCpuMpData Pointer to PEI CPU MP Data **/ +STATIC VOID RestoreWakeupBuffer( IN PEI_CPU_MP_DATA *PeiCpuMpData @@ -760,6 +799,7 @@ PrepareAPStartupVector ( @retval EFI_SUCCESS When everything is OK. **/ +STATIC EFI_STATUS EFIAPI CpuMpEndOfPeiCallback ( @@ -829,8 +869,7 @@ CpuMpPeimInit ( IN CONST EFI_PEI_SERVICES **PeiServices ) { - EFI_STATUS Status; - PEI_CPU_MP_DATA *PeiCpuMpData; + EFI_STATUS Status; EFI_VECTOR_HANDOFF_INFO *VectorInfo; EFI_PEI_VECTOR_HANDOFF_INFO_PPI *VectorHandoffInfoPpi; @@ -849,31 +888,18 @@ CpuMpPeimInit ( } Status = InitializeCpuExceptionHandlers (VectorInfo); ASSERT_EFI_ERROR (Status); + // - // Get wakeup buffer and copy AP reset code in it - // - PeiCpuMpData = PrepareAPStartupVector (); - // - // Count processor number and collect processor information - // - CountProcessorNumber (PeiCpuMpData); - // - // Build location of PEI CPU MP DATA buffer in HOB + // Wakeup APs to do initialization // - BuildGuidDataHob ( - &gEfiCallerIdGuid, - (VOID *)&PeiCpuMpData, - sizeof(UINT64) - ); + Status = MpInitLibInitialize (); + ASSERT_EFI_ERROR (Status); + // // Update and publish CPU BIST information // - CollectBistDataFromPpi (PeiServices, PeiCpuMpData); - // - // register an event for EndOfPei - // - Status = PeiServicesNotifyPpi (&mNotifyList); - ASSERT_EFI_ERROR (Status); + CollectBistDataFromPpi (PeiServices); + // // Install CPU MP PPI //