]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/Library/CpuCommonFeaturesLib/Eist.c
f30117d2c510a004759b02dd32281031c9b2bc7e
[mirror_edk2.git] / UefiCpuPkg / Library / CpuCommonFeaturesLib / Eist.c
1 /** @file
2 Enhanced Intel SpeedStep feature.
3
4 Copyright (c) 2017, 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 Enhanced Intel SpeedStep 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 Enhanced Intel SpeedStep feature is supported.
29 @retval FALSE Enhanced Intel SpeedStep feature is not supported.
30
31 @note This service could be called by BSP/APs.
32 **/
33 BOOLEAN
34 EFIAPI
35 EistSupport (
36 IN UINTN ProcessorNumber,
37 IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
38 IN VOID *ConfigData OPTIONAL
39 )
40 {
41 return (CpuInfo->CpuIdVersionInfoEcx.Bits.EIST == 1);
42 }
43
44 /**
45 Initializes Enhanced Intel SpeedStep 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 Enhanced Intel SpeedStep feature
55 must be enabled.
56 If FALSE, then the Enhanced Intel SpeedStep feature
57 must be disabled.
58
59 @retval RETURN_SUCCESS Enhanced Intel SpeedStep feature is initialized.
60
61 @note This service could be called by BSP only.
62 **/
63 RETURN_STATUS
64 EFIAPI
65 EistInitialize (
66 IN UINTN ProcessorNumber,
67 IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
68 IN VOID *ConfigData, OPTIONAL
69 IN BOOLEAN State
70 )
71 {
72 //
73 // The scope of the MSR_IA32_MISC_ENABLE is core for below processor type, only program
74 // MSR_IA32_MISC_ENABLE for thread 0 in each core.
75 //
76 if (IS_ATOM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
77 IS_CORE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
78 IS_CORE2_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {
79 if (CpuInfo->ProcessorInfo.Location.Thread != 0) {
80 return RETURN_SUCCESS;
81 }
82 }
83
84 CPU_REGISTER_TABLE_WRITE_FIELD (
85 ProcessorNumber,
86 Msr,
87 MSR_IA32_MISC_ENABLE,
88 MSR_IA32_MISC_ENABLE_REGISTER,
89 Bits.EIST,
90 (State) ? 1 : 0
91 );
92 return RETURN_SUCCESS;
93 }