]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/Library/CpuCommonFeaturesLib/PendingBreak.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / UefiCpuPkg / Library / CpuCommonFeaturesLib / PendingBreak.c
1 /** @file
2 Pending Break feature.
3
4 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #include "CpuCommonFeatures.h"
10
11 /**
12 Detects if Pending Break feature supported on current processor.
13
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
20 RegisterCpuFeature().
21
22 @retval TRUE Pending Break feature is supported.
23 @retval FALSE Pending Break feature is not supported.
24
25 @note This service could be called by BSP/APs.
26 **/
27 BOOLEAN
28 EFIAPI
29 PendingBreakSupport (
30 IN UINTN ProcessorNumber,
31 IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
32 IN VOID *ConfigData OPTIONAL
33 )
34 {
35 if (IS_ATOM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
36 IS_CORE2_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
37 IS_CORE_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
38 IS_PENTIUM_4_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
39 IS_PENTIUM_M_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel))
40 {
41 return (CpuInfo->CpuIdVersionInfoEdx.Bits.PBE == 1);
42 }
43
44 return FALSE;
45 }
46
47 /**
48 Initializes Pending Break feature to specific state.
49
50 @param[in] ProcessorNumber The index of the CPU executing this function.
51 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
52 structure for the CPU executing this function.
53 @param[in] ConfigData A pointer to the configuration buffer returned
54 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
55 CPU_FEATURE_GET_CONFIG_DATA was not provided in
56 RegisterCpuFeature().
57 @param[in] State If TRUE, then the Pending Break feature must be enabled.
58 If FALSE, then the Pending Break feature must be disabled.
59
60 @retval RETURN_SUCCESS Pending Break feature is initialized.
61
62 @note This service could be called by BSP only.
63 **/
64 RETURN_STATUS
65 EFIAPI
66 PendingBreakInitialize (
67 IN UINTN ProcessorNumber,
68 IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
69 IN VOID *ConfigData OPTIONAL,
70 IN BOOLEAN State
71 )
72 {
73 //
74 // The scope of the MSR_ATOM_IA32_MISC_ENABLE is core for below processor type, only program
75 // MSR_ATOM_IA32_MISC_ENABLE for thread 0 in each core.
76 //
77 // Support function has check the processer type for this feature, no need to check again
78 // here.
79 //
80 if (CpuInfo->ProcessorInfo.Location.Thread != 0) {
81 return RETURN_SUCCESS;
82 }
83
84 //
85 // ATOM, CORE2, CORE, PENTIUM_4 and IS_PENTIUM_M_PROCESSOR have the same MSR index,
86 // Simply use MSR_ATOM_IA32_MISC_ENABLE here
87 //
88 CPU_REGISTER_TABLE_WRITE_FIELD (
89 ProcessorNumber,
90 Msr,
91 MSR_ATOM_IA32_MISC_ENABLE,
92 MSR_ATOM_IA32_MISC_ENABLE_REGISTER,
93 Bits.FERR,
94 (State) ? 1 : 0
95 );
96 return RETURN_SUCCESS;
97 }