VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/UefiCpuPkg/Library/CpuCommonFeaturesLib/ClockModulation.c@ 77662

Last change on this file since 77662 was 77662, checked in by vboxsync, 6 years ago

EFI: First step in UDK2018 merge. Does not build yet.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette