]>
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 |
0acd8697 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
80c4b236 JF |
6 | \r |
7 | **/\r | |
8 | \r | |
9 | #include "CpuCommonFeatures.h"\r | |
10 | \r | |
11 | /**\r | |
12 | Detects if Clock Modulation feature supported on current processor.\r | |
13 | \r | |
14 | @param[in] ProcessorNumber The index of the CPU executing this function.\r | |
15 | @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r | |
16 | structure for the CPU executing this function.\r | |
17 | @param[in] ConfigData A pointer to the configuration buffer returned\r | |
18 | by CPU_FEATURE_GET_CONFIG_DATA. NULL if\r | |
19 | CPU_FEATURE_GET_CONFIG_DATA was not provided in\r | |
20 | RegisterCpuFeature().\r | |
21 | \r | |
22 | @retval TRUE Clock Modulation feature is supported.\r | |
23 | @retval FALSE Clock Modulation feature is not supported.\r | |
24 | \r | |
25 | @note This service could be called by BSP/APs.\r | |
26 | **/\r | |
27 | BOOLEAN\r | |
28 | EFIAPI\r | |
29 | ClockModulationSupport (\r | |
30 | IN UINTN ProcessorNumber,\r | |
31 | IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,\r | |
32 | IN VOID *ConfigData OPTIONAL\r | |
33 | )\r | |
34 | {\r | |
35 | return (CpuInfo->CpuIdVersionInfoEdx.Bits.ACPI == 1);\r | |
36 | }\r | |
37 | \r | |
38 | /**\r | |
39 | Initializes Clock Modulation feature to specific state.\r | |
40 | \r | |
41 | @param[in] ProcessorNumber The index of the CPU executing this function.\r | |
42 | @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION\r | |
43 | structure for the CPU executing this function.\r | |
44 | @param[in] ConfigData A pointer to the configuration buffer returned\r | |
45 | by CPU_FEATURE_GET_CONFIG_DATA. NULL if\r | |
46 | CPU_FEATURE_GET_CONFIG_DATA was not provided in\r | |
47 | RegisterCpuFeature().\r | |
48 | @param[in] State If TRUE, then the Clock Modulation feature must be enabled.\r | |
49 | If FALSE, then the Clock Modulation feature must be disabled.\r | |
50 | \r | |
51 | @retval RETURN_SUCCESS Clock Modulation feature is initialized.\r | |
52 | \r | |
53 | @note This service could be called by BSP only.\r | |
54 | **/\r | |
55 | RETURN_STATUS\r | |
56 | EFIAPI\r | |
57 | ClockModulationInitialize (\r | |
58 | IN UINTN ProcessorNumber,\r | |
59 | IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,\r | |
60 | IN VOID *ConfigData, OPTIONAL\r | |
61 | IN BOOLEAN State\r | |
62 | )\r | |
63 | {\r | |
0c8b8802 RN |
64 | CPUID_THERMAL_POWER_MANAGEMENT_EAX ThermalPowerManagementEax;\r |
65 | AsmCpuid (CPUID_THERMAL_POWER_MANAGEMENT, &ThermalPowerManagementEax.Uint32, NULL, NULL, NULL);\r | |
66 | \r | |
67 | CPU_REGISTER_TABLE_WRITE_FIELD (\r | |
68 | ProcessorNumber,\r | |
69 | Msr,\r | |
70 | MSR_IA32_CLOCK_MODULATION,\r | |
71 | MSR_IA32_CLOCK_MODULATION_REGISTER,\r | |
72 | Bits.OnDemandClockModulationDutyCycle,\r | |
73 | PcdGet8 (PcdCpuClockModulationDutyCycle) >> 1\r | |
74 | );\r | |
75 | if (ThermalPowerManagementEax.Bits.ECMD == 1) {\r | |
80c4b236 JF |
76 | CPU_REGISTER_TABLE_WRITE_FIELD (\r |
77 | ProcessorNumber,\r | |
78 | Msr,\r | |
79 | MSR_IA32_CLOCK_MODULATION,\r | |
80 | MSR_IA32_CLOCK_MODULATION_REGISTER,\r | |
0c8b8802 RN |
81 | Bits.ExtendedOnDemandClockModulationDutyCycle,\r |
82 | PcdGet8 (PcdCpuClockModulationDutyCycle) & BIT0\r | |
80c4b236 JF |
83 | );\r |
84 | }\r | |
0c8b8802 RN |
85 | CPU_REGISTER_TABLE_WRITE_FIELD (\r |
86 | ProcessorNumber,\r | |
87 | Msr,\r | |
88 | MSR_IA32_CLOCK_MODULATION,\r | |
89 | MSR_IA32_CLOCK_MODULATION_REGISTER,\r | |
90 | Bits.OnDemandClockModulationEnable,\r | |
91 | (State) ? 1 : 0\r | |
92 | );\r | |
80c4b236 JF |
93 | return RETURN_SUCCESS;\r |
94 | }\r |