FastStrings.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /** @file
  2. Fast-Strings 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. Initializes Fast-Strings feature to specific state.
  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. @param[in] State If TRUE, then the Fast-Strings feature must be enabled.
  17. If FALSE, then the Fast-Strings feature must be disabled.
  18. @retval RETURN_SUCCESS Fast-Strings feature is initialized.
  19. @note This service could be called by BSP only.
  20. **/
  21. RETURN_STATUS
  22. EFIAPI
  23. FastStringsInitialize (
  24. IN UINTN ProcessorNumber,
  25. IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
  26. IN VOID *ConfigData OPTIONAL,
  27. IN BOOLEAN State
  28. )
  29. {
  30. //
  31. // The scope of FastStrings bit in the MSR_IA32_MISC_ENABLE is core for below processor type, only program
  32. // MSR_IA32_MISC_ENABLE for thread 0 in each core.
  33. //
  34. if (IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
  35. IS_GOLDMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
  36. IS_PENTIUM_4_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel))
  37. {
  38. if (CpuInfo->ProcessorInfo.Location.Thread != 0) {
  39. return RETURN_SUCCESS;
  40. }
  41. }
  42. CPU_REGISTER_TABLE_WRITE_FIELD (
  43. ProcessorNumber,
  44. Msr,
  45. MSR_IA32_MISC_ENABLE,
  46. MSR_IA32_MISC_ENABLE_REGISTER,
  47. Bits.FastStrings,
  48. (State) ? 1 : 0
  49. );
  50. return RETURN_SUCCESS;
  51. }