/** * Enable Application Power Management (APM) * * @param[in] EntryPoint Timepoint designator. * @param[in] PlatformConfig Contains the runtime modifiable feature input data. * @param[in] StdHeader Config Handle for library, services. * * @retval AGESA_SUCCESS Always succeeds. * */ AGESA_STATUS InitializeApmFeature ( IN UINT64 EntryPoint, IN PLATFORM_CONFIGURATION *PlatformConfig, IN AMD_CONFIG_PARAMS *StdHeader ) { APM_FAMILY_SERVICES *FamilyServices; IDS_HDT_CONSOLE (CPU_TRACE, " APM mode is enabled\n"); GetFeatureServicesOfCurrentCore (&ApmFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader); if ((EntryPoint & CPU_FEAT_AFTER_POST_MTRR_SYNC) != 0) { FamilyServices->ProgramApmWeights (FamilyServices, StdHeader); } else if ((EntryPoint & CPU_FEAT_AFTER_RESUME_MTRR_SYNC) != 0) { if (!CheckPspPlatformSecureEnable ()) { FamilyServices->ProgramApmWeights (FamilyServices, StdHeader); } } else { FamilyServices->EnableApm (FamilyServices, StdHeader); } return AGESA_SUCCESS; }
/** * Get the number of P-State to support * * @param[in,out] StdHeader The Pointer of AMD_CONFIG_PARAMS. * * @retval num The number of P-State to support. * **/ UINT8 IdsGetNumPstatesFamCommon ( IN OUT AMD_CONFIG_PARAMS *StdHeader ) { UINT8 pstatesnum; UINT8 i; UINT8 IgnoredByte; UINT32 Ignored; BOOLEAN PStateEnabled; UINT32 TempVar_c; PSTATE_CPU_FAMILY_SERVICES *FamilyServices; pstatesnum = 0; GetFeatureServicesOfCurrentCore (&PstateFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader); ASSERT (FamilyServices != NULL); FamilyServices->GetPstateMaxState (FamilyServices, &TempVar_c, &IgnoredByte, StdHeader); for (i = 0; i <= TempVar_c; i++) { // Check if PState is enabled FamilyServices->GetPstateRegisterInfo ( FamilyServices, (UINT32) i, &PStateEnabled, &Ignored, &Ignored, &Ignored, StdHeader); if (PStateEnabled) { pstatesnum++; } } return pstatesnum; }
/** * Should hardware C1e be enabled * * @param[in] PlatformConfig Contains the runtime modifiable feature input data. * @param[in] StdHeader Config Handle for library, services. * * @retval TRUE HW C1e is supported. * @retval FALSE HW C1e cannot be enabled. * */ BOOLEAN STATIC IsHwC1eFeatureEnabled ( IN PLATFORM_CONFIGURATION *PlatformConfig, IN AMD_CONFIG_PARAMS *StdHeader ) { BOOLEAN IsEnabled; AP_MAILBOXES ApMailboxes; HW_C1E_FAMILY_SERVICES *FamilyServices; ASSERT (PlatformConfig->C1eMode < MaxC1eMode); IsEnabled = FALSE; if (PlatformConfig->C1eMode == C1eModeHardware) { ASSERT (PlatformConfig->C1ePlatformData < 0x10000); ASSERT (PlatformConfig->C1ePlatformData != 0); if ((PlatformConfig->C1ePlatformData != 0) && (PlatformConfig->C1ePlatformData < 0xFFFE)) { if (GetNumberOfProcessors (StdHeader) == 1) { GetApMailbox (&ApMailboxes.ApMailInfo.Info, StdHeader); if (ApMailboxes.ApMailInfo.Fields.ModuleType == 0) { GetFeatureServicesOfCurrentCore (&HwC1eFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader); if (FamilyServices != NULL) { IsEnabled = FamilyServices->IsHwC1eSupported (FamilyServices, StdHeader); } } } } } return IsEnabled; }
/** * Should software C1e be enabled * * @param[in] PlatformConfig Contains the runtime modifiable feature input data. * @param[in] StdHeader Config Handle for library, services. * * @retval TRUE SW C1e is supported. * @retval FALSE SW C1e not supported. * */ BOOLEAN STATIC IsSwC1eFeatureEnabled ( IN PLATFORM_CONFIGURATION *PlatformConfig, IN AMD_CONFIG_PARAMS *StdHeader ) { BOOLEAN IsEnabled; AP_MAILBOXES ApMailboxes; SW_C1E_FAMILY_SERVICES *SwFamilyServices; ASSERT (PlatformConfig->C1eMode < MaxC1eMode); IsEnabled = FALSE; // Check whether software C1e is enabled only if hardware C1e is not supported or if the platform specifically // uses C1eModeSoftwareDeprecated. if ((PlatformConfig->C1eMode == C1eModeSoftwareDeprecated) || ((PlatformConfig->C1eMode == C1eModeHardwareSoftwareDeprecated) && (!IsFeatureEnabled (HardwareC1e, PlatformConfig, StdHeader)))) { ASSERT ((PlatformConfig->C1ePlatformData1 < 0x10000) && (PlatformConfig->C1ePlatformData1 != 0)); ASSERT (PlatformConfig->C1ePlatformData2 < 0x100); if ((PlatformConfig->C1ePlatformData1 != 0) && (PlatformConfig->C1ePlatformData1 < 0xFFFE) && (PlatformConfig->C1ePlatformData2 < 0xFF)) { if (!IsNonCoherentHt1 (StdHeader)) { if (GetNumberOfProcessors (StdHeader) == 1) { GetApMailbox (&ApMailboxes.ApMailInfo.Info, StdHeader); if (ApMailboxes.ApMailInfo.Fields.ModuleType == 0) { GetFeatureServicesOfCurrentCore (&SwC1eFamilyServiceTable, &SwFamilyServices, StdHeader); if (SwFamilyServices != NULL) { IsEnabled = SwFamilyServices->IsSwC1eSupported (SwFamilyServices, StdHeader); } } } } } } return IsEnabled; }
/** * AP task to enable APM * * @param[in] StdHeader Config Handle for library, services. * */ VOID EnableApmOnSocket ( IN AMD_CONFIG_PARAMS *StdHeader ) { APM_FAMILY_SERVICES *FamilyServices; GetFeatureServicesOfCurrentCore (&ApmFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader); FamilyServices->EnableApmOnSocket (FamilyServices, StdHeader); }
/** *--------------------------------------------------------------------------------------- * * CorePstateRegModify * * Description: * This function will setting the Pstate MSR to each APs base on Pstate Buffer. * Note: This function should be called for every core in the system. * * Parameters: * @param[in,out] *CpuAmdPState * @param[in] *StdHeader * * @retval VOID * *--------------------------------------------------------------------------------------- **/ VOID CorePstateRegModify ( IN VOID *CpuAmdPState, IN AMD_CONFIG_PARAMS *StdHeader ) { PSTATE_CPU_FAMILY_SERVICES *FamilySpecificServices; FamilySpecificServices = NULL; GetFeatureServicesOfCurrentCore (&PstateFamilyServiceTable, (CONST VOID **)&FamilySpecificServices, StdHeader); ASSERT (FamilySpecificServices != NULL) FamilySpecificServices->SetPStateLevelReg (FamilySpecificServices, (S_CPU_AMD_PSTATE *) CpuAmdPState, StdHeader); }
/** * 'Local' core 0 task to enable low power P-state * * @param[in] PlatformConfig Contains the runtime modifiable feature input data. * @param[in] StdHeader Config Handle for library, services. * */ VOID STATIC EnableLowPwrPstateOnCore ( IN VOID *PlatformConfig, IN AMD_CONFIG_PARAMS *StdHeader ) { LOW_PWR_PSTATE_FAMILY_SERVICES *FamilyServices; GetFeatureServicesOfCurrentCore (&LowPwrPstateFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader); FamilyServices->EnableLowPwrPstate (FamilyServices, PlatformConfig, StdHeader); }
/** * MMIO map manager * * @param[in] AmdAddMmioParams Pointer to a data structure containing the parameter information. * * @retval AGESA_STATUS AGESA_ERROR - The requested range could not be added because there are not * enough mapping resources. * AGESA_UNSUPPORTED - not support on currect processor * AGESA_BOUNDS_CHK - One or more input parameters are invalid. For example, the * TargetAddress does not correspond to any device in the system. * AGESA_SUCCESS - Adding MMIO map succeeds * */ AGESA_STATUS AmdAddMmioMapping ( IN AMD_ADD_MMIO_PARAMS AmdAddMmioParams ) { MMIO_MAP_FAMILY_SERVICES *FamilyServices; GetFeatureServicesOfCurrentCore (&MmioMapFamilyServiceTable, (CONST VOID **)&FamilyServices, &(AmdAddMmioParams.StdHeader)); if (FamilyServices != NULL) { return (FamilyServices->addingMmioMap (FamilyServices, AmdAddMmioParams)); } else { return AGESA_UNSUPPORTED; } }
/** * AP task to enable Pstate HPC mode * * @param[in] PlatformConfig Contains the runtime modifiable feature input data. * @param[in] StdHeader Config Handle for library, services. * */ VOID STATIC EnablePstateHpcModeOnAps ( IN VOID *PlatformConfig, IN AMD_CONFIG_PARAMS *StdHeader ) { PSTATE_HPC_MODE_FAMILY_SERVICES *FamilyServices; GetFeatureServicesOfCurrentCore (&PstateHpcModeFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader); FamilyServices->EnablePstateHpcMode (FamilyServices, PlatformConfig, StdHeader); }
/** * 'Local' core 0 task to enable Cache Flush On Halt on it's socket. * * @param[in] EntryPoint Timepoint designator. * @param[in] StdHeader Config Handle for library, services. * @param[in] CpuEarlyParams Service parameters. * */ VOID STATIC EnableCacheFlushOnHaltOnSocket ( IN VOID *EntryPoint, IN AMD_CONFIG_PARAMS *StdHeader, IN AMD_CPU_EARLY_PARAMS *CpuEarlyParams ) { CPU_CFOH_FAMILY_SERVICES *FamilyServices; GetFeatureServicesOfCurrentCore (&CacheFlushOnHaltFamilyServiceTable, (const VOID **)&FamilyServices, StdHeader); if (FamilyServices != NULL) { FamilyServices->SetCacheFlushOnHaltRegister (FamilyServices, *((UINT64 *) EntryPoint), &CpuEarlyParams->PlatformConfig, StdHeader); } }
/** * * InitializeCacheFlushOnHaltFeature * * Enable Cpu Cache Flush On Halt Function * * @param[in] EntryPoint Timepoint designator. * @param[in] PlatformConfig Contains the runtime modifiable feature input data. * @param[in,out] StdHeader Pointer to AMD_CONFIG_PARAMS struct. * * @return AGESA_SUCCESS. */ AGESA_STATUS InitializeCacheFlushOnHaltFeature ( IN UINT64 EntryPoint, IN PLATFORM_CONFIGURATION *PlatformConfig, IN OUT AMD_CONFIG_PARAMS *StdHeader ) { CPU_CFOH_FAMILY_SERVICES *FamilyServices; GetFeatureServicesOfCurrentCore (&CacheFlushOnHaltFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader); if (FamilyServices != NULL) { FamilyServices->SetCacheFlushOnHaltRegister (FamilyServices, EntryPoint, PlatformConfig, StdHeader); } return AGESA_SUCCESS; }
/** * 'Local' core 0 task to enable message-based C1e on it's socket. * * @param[in] EntryPoint Timepoint designator. * @param[in] StdHeader Config Handle for library, services. * @param[in] CpuEarlyParams Service parameters. * */ VOID STATIC EnableMsgC1eOnSocket ( IN VOID *EntryPoint, IN AMD_CONFIG_PARAMS *StdHeader, IN AMD_CPU_EARLY_PARAMS *CpuEarlyParams ) { MSG_BASED_C1E_FAMILY_SERVICES *FamilyServices; GetFeatureServicesOfCurrentCore (&MsgBasedC1eFamilyServiceTable, (const VOID **)&FamilyServices, StdHeader); FamilyServices->InitializeMsgBasedC1e (FamilyServices, *((UINT64 *) EntryPoint), &CpuEarlyParams->PlatformConfig, StdHeader); }
/** * 'Local' core 0 task to enable IO Cstate on it's socket. * * @param[in] EntryPoint Timepoint designator. * @param[in] StdHeader Config Handle for library, services. * @param[in] CpuEarlyParams Service parameters. * */ VOID STATIC EnableIoCstateOnSocket ( IN VOID *EntryPoint, IN AMD_CONFIG_PARAMS *StdHeader, IN AMD_CPU_EARLY_PARAMS *CpuEarlyParams ) { IO_CSTATE_FAMILY_SERVICES *FamilyServices; GetFeatureServicesOfCurrentCore (&IoCstateFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader); FamilyServices->InitializeIoCstate (FamilyServices, *((UINT64 *) EntryPoint), &CpuEarlyParams->PlatformConfig, StdHeader); }
/** * 'Local' core 0 task to enable low power P-state * * @param[in] EntryPoint Timepoint designator. * @param[in] StdHeader Config Handle for library, services. * @param[in] CpuEarlyParams Service parameters. * */ VOID STATIC EnableLowPwrPstateOnSocket ( IN VOID *EntryPoint, IN AMD_CONFIG_PARAMS *StdHeader, IN AMD_CPU_EARLY_PARAMS *CpuEarlyParams ) { LOW_PWR_PSTATE_FAMILY_SERVICES *FamilyServices; GetFeatureServicesOfCurrentCore (&LowPwrPstateFamilyServiceTable, (const VOID **)&FamilyServices, StdHeader); FamilyServices->EnableLowPwrPstate (FamilyServices, &CpuEarlyParams->PlatformConfig, *((UINT64 *) EntryPoint), StdHeader); }
/** * AP task to enable PSI * * @param[in] EntryPoint Timepoint designator. * @param[in] StdHeader Config Handle for library, services. * @param[in] CpuEarlyParams Service parameters. * */ UINT32 STATIC EnablePsiOnSocket ( IN VOID *EntryPoint, IN AMD_CONFIG_PARAMS *StdHeader, IN AMD_CPU_EARLY_PARAMS *CpuEarlyParams ) { AGESA_STATUS CalledStatus; PSI_FAMILY_SERVICES *PsiFamilyServices; CalledStatus = AGESA_UNSUPPORTED; GetFeatureServicesOfCurrentCore (&PsiFamilyServiceTable, (CONST VOID **)&PsiFamilyServices, StdHeader); if (PsiFamilyServices != NULL) { CalledStatus = PsiFamilyServices->EnablePsiOnSocket (PsiFamilyServices, *((UINT64 *) EntryPoint), &CpuEarlyParams->PlatformConfig, StdHeader); } return (UINT32) CalledStatus; }
/** * * Enable all the caches on current core. * * @param[in] ApExeParams Handle to config for library and services. * * @retval AGESA_SUCCESS Always succeeds. * */ AGESA_STATUS EnableAllCaches ( IN AP_EXE_PARAMS *ApExeParams ) { UINT32 CR0Data; L3_FEATURE_FAMILY_SERVICES *FamilyServices; // Enable cache through CR0. LibAmdReadCpuReg (0, &CR0Data); CR0Data &= ~(0x60000000); LibAmdWriteCpuReg (0, CR0Data); GetFeatureServicesOfCurrentCore (&L3FeatureFamilyServiceTable, (const VOID **) &FamilyServices, &ApExeParams->StdHeader); FamilyServices->HookEnableCache (FamilyServices, &ApExeParams->StdHeader); return AGESA_SUCCESS; }
/** * 'Local' core 0 task to enable C6 on it's socket. * * @param[in] EntryPoint Timepoint designator. * @param[in] StdHeader Config Handle for library, services. * @param[in] CpuEarlyParams Service parameters. * */ VOID STATIC EnableC6OnSocket ( IN VOID *EntryPoint, IN AMD_CONFIG_PARAMS *StdHeader, IN AMD_CPU_EARLY_PARAMS *CpuEarlyParams ) { C6_FAMILY_SERVICES *FamilyServices; IDS_HDT_CONSOLE (CPU_TRACE, " C6 is enabled\n"); GetFeatureServicesOfCurrentCore (&C6FamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader); FamilyServices->InitializeC6 (FamilyServices, *((UINT64 *) EntryPoint), &CpuEarlyParams->PlatformConfig, StdHeader); }
/** * Should Application Power Management (APM) be enabled * * @param[in] PlatformConfig Contains the runtime modifiable feature input data. * @param[in] StdHeader Config Handle for library, services. * * @retval TRUE APM is supported. * @retval FALSE APM cannot be enabled. * */ BOOLEAN IsApmFeatureEnabled ( IN PLATFORM_CONFIGURATION *PlatformConfig, IN AMD_CONFIG_PARAMS *StdHeader ) { BOOLEAN IsEnabled; APM_FAMILY_SERVICES *FamilyServices; IsEnabled = FALSE; GetFeatureServicesOfCurrentCore (&ApmFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader); if (FamilyServices != NULL) { if (FamilyServices->IsApmSupported (FamilyServices, PlatformConfig, StdHeader)) { IsEnabled = TRUE; } } return IsEnabled; }
/** * Determines the rate at which the executing core's time stamp counter is * incrementing. * * @CpuServiceMethod{::F_CPU_GET_TSC_RATE}. * * @param[in] FamilySpecificServices The current Family Specific Services. * @param[out] FrequencyInMHz TSC actual frequency. * @param[in] StdHeader Header for library and services. * * @return The most severe status of all called services */ AGESA_STATUS F14GetTscRate ( IN CPU_SPECIFIC_SERVICES *FamilySpecificServices, OUT UINT32 *FrequencyInMHz, IN AMD_CONFIG_PARAMS *StdHeader ) { UINT64 MsrReg; PSTATE_CPU_FAMILY_SERVICES *FamilyServices; FamilyServices = NULL; GetFeatureServicesOfCurrentCore (&PstateFamilyServiceTable, (const VOID **)&FamilyServices, StdHeader); ASSERT (FamilyServices != NULL); LibAmdMsrRead (0xC0010015, &MsrReg, StdHeader); if ((MsrReg & 0x01000000) != 0) { return (FamilyServices->GetPstateFrequency (FamilyServices, 0, FrequencyInMHz, StdHeader)); } else { return (FamilySpecificServices->GetCurrentNbFrequency (FamilySpecificServices, FrequencyInMHz, StdHeader)); } }
/** * * Disable all the caches on current core. * * @param[in] ApExeParams Handle to config for library and services. * * @retval AGESA_SUCCESS Always succeeds. * */ AGESA_STATUS DisableAllCaches ( IN AP_EXE_PARAMS *ApExeParams ) { UINT32 CR0Data; L3_FEATURE_FAMILY_SERVICES *FamilyServices; // Disable cache through CR0. LibAmdReadCpuReg (0, &CR0Data); CR0Data |= (0x60000000); LibAmdWriteCpuReg (0, CR0Data); // Execute wbinvd LibAmdWriteBackInvalidateCache (); GetFeatureServicesOfCurrentCore (&L3FeatureFamilyServiceTable, (const VOID **) &FamilyServices, &ApExeParams->StdHeader); FamilyServices->HookDisableCache (FamilyServices, *(BOOLEAN *) ApExeParams->RelatedDataBlock, &ApExeParams->StdHeader); return AGESA_SUCCESS; }
/** * Enable Software C1e * * @param[in] EntryPoint Timepoint designator. * @param[in] PlatformConfig Contains the runtime modifiable feature input data. * @param[in] StdHeader Config Handle for library, services. * * @return The most severe status of any family specific service. * */ AGESA_STATUS STATIC InitializeSwC1eFeature ( IN UINT64 EntryPoint, IN PLATFORM_CONFIGURATION *PlatformConfig, IN AMD_CONFIG_PARAMS *StdHeader ) { AGESA_STATUS AgesaStatus; SW_C1E_FAMILY_SERVICES *FamilyServices; AgesaStatus = AGESA_SUCCESS; IDS_HDT_CONSOLE (CPU_TRACE, " SW C1e is enabled\n"); if (IsWarmReset (StdHeader)) { GetFeatureServicesOfCurrentCore (&SwC1eFamilyServiceTable, &FamilyServices, StdHeader); AgesaStatus = FamilyServices->InitializeSwC1e (FamilyServices, EntryPoint, PlatformConfig, StdHeader); } return AgesaStatus; }
/** * Enable Hardware C1e * * @param[in] EntryPoint Timepoint designator. * @param[in] PlatformConfig Contains the runtime modifiable feature input data. * @param[in] StdHeader Config Handle for library, services. * * @return The most severe status of any family specific service. * */ AGESA_STATUS STATIC InitializeHwC1eFeature ( IN UINT64 EntryPoint, IN PLATFORM_CONFIGURATION *PlatformConfig, IN AMD_CONFIG_PARAMS *StdHeader ) { AGESA_STATUS CalledStatus; AGESA_STATUS AgesaStatus; HW_C1E_FAMILY_SERVICES *FamilyServices; AgesaStatus = AGESA_SUCCESS; if (IsWarmReset (StdHeader)) { GetFeatureServicesOfCurrentCore (&HwC1eFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader); CalledStatus = FamilyServices->InitializeHwC1e (FamilyServices, EntryPoint, PlatformConfig, StdHeader); if (CalledStatus > AgesaStatus) { AgesaStatus = CalledStatus; } } return AgesaStatus; }
/** * Should Connected Standby be enabled * * @param[in] PlatformConfig Contains the runtime modifiable feature input data. * @param[in] StdHeader Config Handle for library, services. * * @retval TRUE Connected Standby is supported. * @retval FALSE Connected Standby cannot be enabled. * */ BOOLEAN STATIC IsConnectedStandbyFeatureEnabled ( IN PLATFORM_CONFIGURATION *PlatformConfig, IN AMD_CONFIG_PARAMS *StdHeader ) { BOOLEAN IsEnabled; CONNECTED_STANDBY_FAMILY_SERVICES *FamilyServices; IsEnabled = FALSE; ASSERT (PlatformConfig->CfgPlatformConnectedStandbyMode < MaxConnectedStandbyMode); if (PlatformConfig->CfgPlatformConnectedStandbyMode == ConnectedStandbyAuto) { GetFeatureServicesOfCurrentCore (&ConnectedStandyFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader); if (FamilyServices != NULL) { if (FamilyServices->IsConnectedStandbySupported (FamilyServices, PlatformConfig, StdHeader)) { IsEnabled = TRUE; } } } return IsEnabled; }
/** * Enable connected standby * * @param[in] EntryPoint Timepoint designator. * @param[in] PlatformConfig Contains the runtime modifiable feature input data. * @param[in] StdHeader Config Handle for library, services. * * @retval AGESA_SUCCESS Always succeeds. * */ AGESA_STATUS STATIC InitializeConnectedStandbyFeature ( IN UINT64 EntryPoint, IN PLATFORM_CONFIGURATION *PlatformConfig, IN AMD_CONFIG_PARAMS *StdHeader ) { AGESA_STATUS CalledStatus; CONNECTED_STANDBY_FAMILY_SERVICES *FamilyServices; CalledStatus = AGESA_SUCCESS; IDS_HDT_CONSOLE (CPU_TRACE, " Connected Standby is enabled\n"); GetFeatureServicesOfCurrentCore (&ConnectedStandyFamilyServiceTable, (CONST VOID **)&FamilyServices, StdHeader); if (FamilyServices != NULL) { if ((EntryPoint & CPU_FEAT_AFTER_PM_INIT) != 0) { CalledStatus = FamilyServices->EnableConnectedStandby (FamilyServices, PlatformConfig, EntryPoint, StdHeader); } } return CalledStatus; }