]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/Library/CpuCommonFeaturesLib/FastStrings.c
2682093c2393335ae18092d5e3713d165ad43290
[mirror_edk2.git] / UefiCpuPkg / Library / CpuCommonFeaturesLib / FastStrings.c
1 /** @file
2 Fast-Strings feature.
3
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
9
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.
12
13 **/
14
15 #include "CpuCommonFeatures.h"
16
17 /**
18 Initializes Fast-Strings feature to specific state.
19
20 @param[in] ProcessorNumber The index of the CPU executing this function.
21 @param[in] CpuInfo A pointer to the REGISTER_CPU_FEATURE_INFORMATION
22 structure for the CPU executing this function.
23 @param[in] ConfigData A pointer to the configuration buffer returned
24 by CPU_FEATURE_GET_CONFIG_DATA. NULL if
25 CPU_FEATURE_GET_CONFIG_DATA was not provided in
26 RegisterCpuFeature().
27 @param[in] State If TRUE, then the Fast-Strings feature must be enabled.
28 If FALSE, then the Fast-Strings feature must be disabled.
29
30 @retval RETURN_SUCCESS Fast-Strings feature is initialized.
31
32 @note This service could be called by BSP only.
33 **/
34 RETURN_STATUS
35 EFIAPI
36 FastStringsInitialize (
37 IN UINTN ProcessorNumber,
38 IN REGISTER_CPU_FEATURE_INFORMATION *CpuInfo,
39 IN VOID *ConfigData, OPTIONAL
40 IN BOOLEAN State
41 )
42 {
43 //
44 // The scope of FastStrings bit in the MSR_IA32_MISC_ENABLE is core for below processor type, only program
45 // MSR_IA32_MISC_ENABLE for thread 0 in each core.
46 //
47 if (IS_SILVERMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
48 IS_GOLDMONT_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel) ||
49 IS_PENTIUM_4_PROCESSOR (CpuInfo->DisplayFamily, CpuInfo->DisplayModel)) {
50 if (CpuInfo->ProcessorInfo.Location.Thread != 0) {
51 return RETURN_SUCCESS;
52 }
53 }
54
55 CPU_REGISTER_TABLE_WRITE_FIELD (
56 ProcessorNumber,
57 Msr,
58 MSR_IA32_MISC_ENABLE,
59 MSR_IA32_MISC_ENABLE_REGISTER,
60 Bits.FastStrings,
61 (State) ? 1 : 0
62 );
63 return RETURN_SUCCESS;
64 }