TianoCore EDK2 master
Loading...
Searching...
No Matches
ClockModulation.c
Go to the documentation of this file.
1
9#include "CpuCommonFeatures.h"
10
11typedef struct {
12 CPUID_THERMAL_POWER_MANAGEMENT_EAX ThermalPowerManagementEax;
15
25VOID *
26EFIAPI
28 IN UINTN NumberOfProcessors
29 )
30{
31 UINT32 *ConfigData;
32
33 ConfigData = AllocateZeroPool (sizeof (CLOCK_MODULATION_CONFIG_DATA) * NumberOfProcessors);
34 ASSERT (ConfigData != NULL);
35 return ConfigData;
36}
37
54BOOLEAN
55EFIAPI
57 IN UINTN ProcessorNumber,
59 IN VOID *ConfigData OPTIONAL
60 )
61{
62 CLOCK_MODULATION_CONFIG_DATA *CmConfigData;
63
64 if (CpuInfo->CpuIdVersionInfoEdx.Bits.ACPI == 1) {
65 CmConfigData = (CLOCK_MODULATION_CONFIG_DATA *)ConfigData;
66 ASSERT (CmConfigData != NULL);
67 AsmCpuid (
69 &CmConfigData[ProcessorNumber].ThermalPowerManagementEax.Uint32,
70 NULL,
71 NULL,
72 NULL
73 );
74 CmConfigData[ProcessorNumber].ClockModulation.Uint64 = AsmReadMsr64 (MSR_IA32_CLOCK_MODULATION);
75 return TRUE;
76 }
77
78 return FALSE;
79}
80
98RETURN_STATUS
99EFIAPI
101 IN UINTN ProcessorNumber,
103 IN VOID *ConfigData OPTIONAL,
104 IN BOOLEAN State
105 )
106{
107 CLOCK_MODULATION_CONFIG_DATA *CmConfigData;
108 MSR_IA32_CLOCK_MODULATION_REGISTER *ClockModulation;
109
110 CmConfigData = (CLOCK_MODULATION_CONFIG_DATA *)ConfigData;
111 ASSERT (CmConfigData != NULL);
112 ClockModulation = &CmConfigData[ProcessorNumber].ClockModulation;
113
114 if (State) {
115 ClockModulation->Bits.OnDemandClockModulationEnable = 1;
116 ClockModulation->Bits.OnDemandClockModulationDutyCycle = PcdGet8 (PcdCpuClockModulationDutyCycle) >> 1;
117 if (CmConfigData[ProcessorNumber].ThermalPowerManagementEax.Bits.ECMD == 1) {
118 ClockModulation->Bits.ExtendedOnDemandClockModulationDutyCycle = PcdGet8 (PcdCpuClockModulationDutyCycle) & BIT0;
119 }
120 } else {
121 ClockModulation->Bits.OnDemandClockModulationEnable = 0;
122 }
123
125 ProcessorNumber,
126 Msr,
128 ClockModulation->Uint64
129 );
130
131 return RETURN_SUCCESS;
132}
UINT64 UINTN
RETURN_STATUS EFIAPI ClockModulationInitialize(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL, IN BOOLEAN State)
VOID *EFIAPI ClockModulationGetConfigData(IN UINTN NumberOfProcessors)
BOOLEAN EFIAPI ClockModulationSupport(IN UINTN ProcessorNumber, IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo, IN VOID *ConfigData OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
UINT64 EFIAPI AsmReadMsr64(IN UINT32 Index)
Definition: GccInlinePriv.c:60
#define NULL
Definition: Base.h:319
#define RETURN_SUCCESS
Definition: Base.h:1066
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define MSR_IA32_CLOCK_MODULATION
#define CPUID_THERMAL_POWER_MANAGEMENT
Definition: Cpuid.h:1114
UINT32 EFIAPI AsmCpuid(IN UINT32 Index, OUT UINT32 *RegisterEax OPTIONAL, OUT UINT32 *RegisterEbx OPTIONAL, OUT UINT32 *RegisterEcx OPTIONAL, OUT UINT32 *RegisterEdx OPTIONAL)
Definition: CpuId.c:36
#define PcdGet8(TokenName)
Definition: PcdLib.h:336
#define CPU_REGISTER_TABLE_WRITE64(ProcessorNumber, RegisterType, Index, Value)
struct MSR_IA32_CLOCK_MODULATION_REGISTER::@638 Bits