PendingBreak.c 3.5 KB

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