C1e.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /** @file
  2. C1E 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 C1E 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 C1E feature is supported.
  17. @retval FALSE C1E feature is not supported.
  18. @note This service could be called by BSP/APs.
  19. **/
  20. BOOLEAN
  21. EFIAPI
  22. C1eSupport (
  23. IN UINTN ProcessorNumber,
  24. IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
  25. IN VOID *ConfigData OPTIONAL
  26. )
  27. {
  28. return IS_NEHALEM_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel);
  29. }
  30. /**
  31. Initializes C1E feature to specific state.
  32. @param[in] ProcessorNumber The index of the CPU executing this function.
  33. @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
  34. structure for the CPU executing this function.
  35. @param[in] ConfigData A pointer to the configuration buffer returned
  36. by CPU_FEATURE_GET_CONFIG_DATA. NULL if
  37. CPU_FEATURE_GET_CONFIG_DATA was not provided in
  38. RegisterCpuFeature().
  39. @param[in] State If TRUE, then the C1E feature must be enabled.
  40. If FALSE, then the C1E feature must be disabled.
  41. @retval RETURN_SUCCESS C1E feature is initialized.
  42. @note This service could be called by BSP only.
  43. **/
  44. RETURN_STATUS
  45. EFIAPI
  46. C1eInitialize (
  47. IN UINTN ProcessorNumber,
  48. IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
  49. IN VOID *ConfigData OPTIONAL,
  50. IN BOOLEAN State
  51. )
  52. {
  53. //
  54. // The scope of C1EEnable bit in the MSR_NEHALEM_POWER_CTL is Package, only program
  55. // MSR_NEHALEM_POWER_CTL once for each package.
  56. //
  57. if ((CpuInfo->First.Thread == 0) || (CpuInfo->First.Core == 0)) {
  58. return RETURN_SUCCESS;
  59. }
  60. CPU_REGISTER_TABLE_WRITE_FIELD (
  61. ProcessorNumber,
  62. Msr,
  63. MSR_NEHALEM_POWER_CTL,
  64. MSR_NEHALEM_POWER_CTL_REGISTER,
  65. Bits.C1EEnable,
  66. (State) ? 1 : 0
  67. );
  68. return RETURN_SUCCESS;
  69. }