2 Local machine check exception feature.
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
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.
15 #include "CpuCommonFeatures.h"
18 Detects if Local machine check exception feature supported on current
21 @param[in] ProcessorNumber The index of the CPU executing this function.
22 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
23 structure for the CPU executing this function.
24 @param[in] ConfigData A pointer to the configuration buffer returned
25 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
26 CPU_FEATURE_GET_CONFIG_DATA was not provided in
29 @retval TRUE Local machine check exception feature is supported.
30 @retval FALSE Local machine check exception feature is not supported.
32 @note This service could be called by BSP/APs.
37 IN UINTN ProcessorNumber
,
38 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
39 IN VOID
*ConfigData OPTIONAL
42 MSR_IA32_MCG_CAP_REGISTER McgCap
;
44 if (!McaSupport (ProcessorNumber
, CpuInfo
, ConfigData
)) {
48 McgCap
.Uint64
= AsmReadMsr64 (MSR_IA32_MCG_CAP
);
49 if (ProcessorNumber
== 0) {
50 DEBUG ((EFI_D_INFO
, "LMCE eanble = %x\n", (BOOLEAN
) (McgCap
.Bits
.MCG_LMCE_P
!= 0)));
52 return (BOOLEAN
) (McgCap
.Bits
.MCG_LMCE_P
!= 0);
56 Initializes Local machine check exception feature to specific state.
58 @param[in] ProcessorNumber The index of the CPU executing this function.
59 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
60 structure for the CPU executing this function.
61 @param[in] ConfigData A pointer to the configuration buffer returned
62 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
63 CPU_FEATURE_GET_CONFIG_DATA was not provided in
65 @param[in] State If TRUE, then the Local machine check exception
66 feature must be enabled.
67 If FALSE, then the Local machine check exception
68 feature must be disabled.
70 @retval RETURN_SUCCESS Local machine check exception feature is initialized.
76 IN UINTN ProcessorNumber
,
77 IN REGISTER_CPU_FEATURE_INFORMATION
*CpuInfo
,
78 IN VOID
*ConfigData
, OPTIONAL
82 MSR_IA32_FEATURE_CONTROL_REGISTER
*MsrRegister
;
84 ASSERT (ConfigData
!= NULL
);
85 MsrRegister
= (MSR_IA32_FEATURE_CONTROL_REGISTER
*) ConfigData
;
86 if (MsrRegister
[ProcessorNumber
].Bits
.Lock
== 0) {
87 CPU_REGISTER_TABLE_WRITE_FIELD (
90 MSR_IA32_FEATURE_CONTROL
,
91 MSR_IA32_FEATURE_CONTROL_REGISTER
,
96 return RETURN_SUCCESS
;