4 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include "CpuCommonFeatures.h"
12 Detects if MONITOR/MWAIT feature supported on current processor.
14 @param[in] ProcessorNumber The index of the CPU executing this function.
15 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
16 structure for the CPU executing this function.
17 @param[in] ConfigData A pointer to the configuration buffer returned
18 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
19 CPU_FEATURE_GET_CONFIG_DATA was not provided in
22 @retval TRUE MONITOR/MWAIT feature is supported.
23 @retval FALSE MONITOR/MWAIT feature is not supported.
25 @note This service could be called by BSP/APs.
30 IN UINTN ProcessorNumber
,
31 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
32 IN VOID
*ConfigData OPTIONAL
35 return (CpuInfo
->CpuIdVersionInfoEcx
.Bits
.MONITOR
== 1);
39 Initializes MONITOR/MWAIT feature to specific state.
41 @param[in] ProcessorNumber The index of the CPU executing this function.
42 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
43 structure for the CPU executing this function.
44 @param[in] ConfigData A pointer to the configuration buffer returned
45 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
46 CPU_FEATURE_GET_CONFIG_DATA was not provided in
48 @param[in] State If TRUE, then the MONITOR/MWAIT feature must be enabled.
49 If FALSE, then the MONITOR/MWAIT feature must be disabled.
51 @retval RETURN_SUCCESS MONITOR/MWAIT feature is initialized.
53 @note This service could be called by BSP only.
57 MonitorMwaitInitialize (
58 IN UINTN ProcessorNumber
,
59 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
60 IN VOID
*ConfigData
, OPTIONAL
65 // The scope of the MSR_IA32_MISC_ENABLE is core for below processor type, only program
66 // MSR_IA32_MISC_ENABLE for thread 0 in each core.
68 if (IS_CORE2_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
) ||
69 IS_ATOM_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
) ||
70 IS_GOLDMONT_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
) ||
71 IS_SILVERMONT_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
) ||
72 IS_PENTIUM_4_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
) ||
73 IS_CORE_PROCESSOR (CpuInfo
->DisplayFamily
, CpuInfo
->DisplayModel
)) {
74 if (CpuInfo
->ProcessorInfo
.Location
.Thread
!= 0) {
75 return RETURN_SUCCESS
;
79 CPU_REGISTER_TABLE_WRITE_FIELD (
83 MSR_IA32_MISC_ENABLE_REGISTER
,
87 return RETURN_SUCCESS
;