]>
Commit | Line | Data |
---|---|---|
80c4b236 JF |
1 | /** @file\r |
2 | Clock Modulation feature.\r | |
3 | \r | |
0c8b8802 | 4 | Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>\r |
80c4b236 JF |
5 | This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | **/\r | |
14 | \r | |
15 | #include "CpuCommonFeatures.h"\r | |
16 | \r | |
17 | /**\r | |
18 | Detects if Clock Modulation feature supported on current processor.\r | |
19 | \r | |
20 | @param[in] ProcessorNumber The index of the CPU executing this function.\r | |
21 | @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r | |
22 | structure for the CPU executing this function.\r | |
23 | @param[in] ConfigData A pointer to the configuration buffer returned\r | |
24 | by CPU_FEATURE_GET_CONFIG_DATA. NULL if\r | |
25 | CPU_FEATURE_GET_CONFIG_DATA was not provided in\r | |
26 | RegisterCpuFeature().\r | |
27 | \r | |
28 | @retval TRUE Clock Modulation feature is supported.\r | |
29 | @retval FALSE Clock Modulation feature is not supported.\r | |
30 | \r | |
31 | @note This service could be called by BSP/APs.\r | |
32 | **/\r | |
33 | BOOLEAN\r | |
34 | EFIAPI\r | |
35 | ClockModulationSupport (\r | |
36 | IN UINTN ProcessorNumber,\r | |
37 | IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,\r | |
38 | IN VOID *ConfigData OPTIONAL\r | |
39 | )\r | |
40 | {\r | |
41 | return (CpuInfo->CpuIdVersionInfoEdx.Bits.ACPI == 1);\r | |
42 | }\r | |
43 | \r | |
44 | /**\r | |
45 | Initializes Clock Modulation feature to specific state.\r | |
46 | \r | |
47 | @param[in] ProcessorNumber The index of the CPU executing this function.\r | |
48 | @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r | |
49 | structure for the CPU executing this function.\r | |
50 | @param[in] ConfigData A pointer to the configuration buffer returned\r | |
51 | by CPU_FEATURE_GET_CONFIG_DATA. NULL if\r | |
52 | CPU_FEATURE_GET_CONFIG_DATA was not provided in\r | |
53 | RegisterCpuFeature().\r | |
54 | @param[in] State If TRUE, then the Clock Modulation feature must be enabled.\r | |
55 | If FALSE, then the Clock Modulation feature must be disabled.\r | |
56 | \r | |
57 | @retval RETURN_SUCCESS Clock Modulation feature is initialized.\r | |
58 | \r | |
59 | @note This service could be called by BSP only.\r | |
60 | **/\r | |
61 | RETURN_STATUS\r | |
62 | EFIAPI\r | |
63 | ClockModulationInitialize (\r | |
64 | IN UINTN ProcessorNumber,\r | |
65 | IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,\r | |
66 | IN VOID *ConfigData, OPTIONAL\r | |
67 | IN BOOLEAN State\r | |
68 | )\r | |
69 | {\r | |
0c8b8802 RN |
70 | CPUID_THERMAL_POWER_MANAGEMENT_EAX ThermalPowerManagementEax;\r |
71 | AsmCpuid (CPUID_THERMAL_POWER_MANAGEMENT, &ThermalPowerManagementEax.Uint32, NULL, NULL, NULL);\r | |
72 | \r | |
73 | CPU_REGISTER_TABLE_WRITE_FIELD (\r | |
74 | ProcessorNumber,\r | |
75 | Msr,\r | |
76 | MSR_IA32_CLOCK_MODULATION,\r | |
77 | MSR_IA32_CLOCK_MODULATION_REGISTER,\r | |
78 | Bits.OnDemandClockModulationDutyCycle,\r | |
79 | PcdGet8 (PcdCpuClockModulationDutyCycle) >> 1\r | |
80 | );\r | |
81 | if (ThermalPowerManagementEax.Bits.ECMD == 1) {\r | |
80c4b236 JF |
82 | CPU_REGISTER_TABLE_WRITE_FIELD (\r |
83 | ProcessorNumber,\r | |
84 | Msr,\r | |
85 | MSR_IA32_CLOCK_MODULATION,\r | |
86 | MSR_IA32_CLOCK_MODULATION_REGISTER,\r | |
0c8b8802 RN |
87 | Bits.ExtendedOnDemandClockModulationDutyCycle,\r |
88 | PcdGet8 (PcdCpuClockModulationDutyCycle) & BIT0\r | |
80c4b236 JF |
89 | );\r |
90 | }\r | |
0c8b8802 RN |
91 | CPU_REGISTER_TABLE_WRITE_FIELD (\r |
92 | ProcessorNumber,\r | |
93 | Msr,\r | |
94 | MSR_IA32_CLOCK_MODULATION,\r | |
95 | MSR_IA32_CLOCK_MODULATION_REGISTER,\r | |
96 | Bits.OnDemandClockModulationEnable,\r | |
97 | (State) ? 1 : 0\r | |
98 | );\r | |
80c4b236 JF |
99 | return RETURN_SUCCESS;\r |
100 | }\r |