]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/RegisterCpuFeaturesLib: Optimize PCD
authorEric Dong <eric.dong@intel.com>
Tue, 12 Feb 2019 07:22:48 +0000 (15:22 +0800)
committerEric Dong <eric.dong@intel.com>
Thu, 4 Apr 2019 06:11:01 +0000 (14:11 +0800)
PcdCpuFeaturesUserConfiguration.

Merge PcdCpuFeaturesUserConfiguration into PcdCpuFeaturesSetting.
Use PcdCpuFeaturesSetting as input for the user input feature setting
Use PcdCpuFeaturesSetting as output for the final CPU feature setting

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1375

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
UefiCpuPkg/Library/RegisterCpuFeaturesLib/DxeRegisterCpuFeaturesLib.inf
UefiCpuPkg/Library/RegisterCpuFeaturesLib/PeiRegisterCpuFeaturesLib.inf
UefiCpuPkg/Library/RegisterCpuFeaturesLib/RegisterCpuFeatures.h
UefiCpuPkg/UefiCpuPkg.dec

index bae92b89a655cd817d81b98045547cddce7e8e82..9ce68302762850b3402a0b550c427f0ce683ee64 100644 (file)
@@ -21,16 +21,21 @@ CHAR16 *mRegisterTypeStr[] = {L"MSR", L"CR", L"MMIO", L"CACHE", L"SEMAP", L"INVA
   Worker function to save PcdCpuFeaturesCapability.\r
 \r
   @param[in]  SupportedFeatureMask  The pointer to CPU feature bits mask buffer\r
+  @param[in]  FeatureMaskSize       CPU feature bits mask buffer size.\r
+\r
 **/\r
 VOID\r
 SetCapabilityPcd (\r
-  IN UINT8               *SupportedFeatureMask\r
+  IN UINT8               *SupportedFeatureMask,\r
+  IN UINT32              FeatureMaskSize\r
   )\r
 {\r
   EFI_STATUS             Status;\r
   UINTN                  BitMaskSize;\r
 \r
   BitMaskSize = PcdGetSize (PcdCpuFeaturesCapability);\r
+  ASSERT (FeatureMaskSize == BitMaskSize);\r
+\r
   Status = PcdSetPtrS (PcdCpuFeaturesCapability, &BitMaskSize, SupportedFeatureMask);\r
   ASSERT_EFI_ERROR (Status);\r
 }\r
@@ -53,48 +58,6 @@ SetSettingPcd (
   ASSERT_EFI_ERROR (Status);\r
 }\r
 \r
-/**\r
-  Worker function to get PcdCpuFeaturesSupport.\r
-\r
-  @return  The pointer to CPU feature bits mask buffer.\r
-**/\r
-UINT8 *\r
-GetSupportPcd (\r
-  VOID\r
-  )\r
-{\r
-  UINT8                  *SupportBitMask;\r
-\r
-  SupportBitMask = AllocateCopyPool (\r
-          PcdGetSize (PcdCpuFeaturesSupport),\r
-          PcdGetPtr (PcdCpuFeaturesSupport)\r
-          );\r
-  ASSERT (SupportBitMask != NULL);\r
-\r
-  return SupportBitMask;\r
-}\r
-\r
-/**\r
-  Worker function to get PcdCpuFeaturesUserConfiguration.\r
-\r
-  @return  The pointer to CPU feature bits mask buffer.\r
-**/\r
-UINT8 *\r
-GetConfigurationPcd (\r
-  VOID\r
-  )\r
-{\r
-  UINT8                  *SupportBitMask;\r
-\r
-  SupportBitMask = AllocateCopyPool (\r
-          PcdGetSize (PcdCpuFeaturesUserConfiguration),\r
-          PcdGetPtr (PcdCpuFeaturesUserConfiguration)\r
-          );\r
-  ASSERT (SupportBitMask != NULL);\r
-\r
-  return SupportBitMask;\r
-}\r
-\r
 /**\r
   Collects CPU type and feature information.\r
 \r
@@ -287,7 +250,6 @@ CpuInitDataInitialize (
   // Get support and configuration PCDs\r
   //\r
   CpuFeaturesData->SupportPcd       = GetSupportPcd ();\r
-  CpuFeaturesData->ConfigurationPcd = GetConfigurationPcd ();\r
 }\r
 \r
 /**\r
@@ -323,14 +285,14 @@ SupportedMaskOr (
 **/\r
 VOID\r
 SupportedMaskAnd (\r
-  IN UINT8               *SupportedFeatureMask,\r
-  IN UINT8               *AndFeatureBitMask\r
+  IN       UINT8               *SupportedFeatureMask,\r
+  IN CONST UINT8               *AndFeatureBitMask\r
   )\r
 {\r
   UINTN                  Index;\r
   UINTN                  BitMaskSize;\r
   UINT8                  *Data1;\r
-  UINT8                  *Data2;\r
+  CONST UINT8            *Data2;\r
 \r
   BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);\r
   Data1 = SupportedFeatureMask;\r
@@ -610,16 +572,9 @@ AnalysisProcessorFeatures (
   //\r
   // Calculate the last setting\r
   //\r
-\r
   CpuFeaturesData->SettingPcd = AllocateCopyPool (CpuFeaturesData->BitMaskSize, CpuFeaturesData->CapabilityPcd);\r
   ASSERT (CpuFeaturesData->SettingPcd != NULL);\r
-  SupportedMaskAnd (CpuFeaturesData->SettingPcd, CpuFeaturesData->ConfigurationPcd);\r
-\r
-  //\r
-  // Save PCDs and display CPU PCDs\r
-  //\r
-  SetCapabilityPcd (CpuFeaturesData->CapabilityPcd);\r
-  SetSettingPcd (CpuFeaturesData->SettingPcd);\r
+  SupportedMaskAnd (CpuFeaturesData->SettingPcd, PcdGetPtr (PcdCpuFeaturesSetting));\r
 \r
   //\r
   // Dump the last CPU feature list\r
@@ -643,14 +598,20 @@ AnalysisProcessorFeatures (
     }\r
     DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSupport:\n"));\r
     DumpCpuFeatureMask (CpuFeaturesData->SupportPcd);\r
-    DEBUG ((DEBUG_INFO, "PcdCpuFeaturesUserConfiguration:\n"));\r
-    DumpCpuFeatureMask (CpuFeaturesData->ConfigurationPcd);\r
     DEBUG ((DEBUG_INFO, "PcdCpuFeaturesCapability:\n"));\r
     DumpCpuFeatureMask (CpuFeaturesData->CapabilityPcd);\r
-    DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSetting:\n"));\r
+    DEBUG ((DEBUG_INFO, "Origin PcdCpuFeaturesSetting:\n"));\r
+    DumpCpuFeatureMask (PcdGetPtr (PcdCpuFeaturesSetting));\r
+    DEBUG ((DEBUG_INFO, "Final PcdCpuFeaturesSetting:\n"));\r
     DumpCpuFeatureMask (CpuFeaturesData->SettingPcd);\r
   );\r
 \r
+  //\r
+  // Save PCDs and display CPU PCDs\r
+  //\r
+  SetCapabilityPcd (CpuFeaturesData->CapabilityPcd, CpuFeaturesData->BitMaskSize);\r
+  SetSettingPcd (CpuFeaturesData->SettingPcd);\r
+\r
   for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) {\r
     CpuInitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber];\r
     Entry = GetFirstNode (&CpuFeaturesData->FeatureList);\r
index 362e0c6cd13cdcd4391a53e53dec97a44a756433..a3c74660910fb21ed0645ae8107ade5a81f50bf9 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Register CPU Features Library DXE instance.\r
 #\r
-#  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution.  The full text of the license may be found at\r
@@ -56,9 +56,8 @@
 [Pcd]\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress                        ## CONSUMES\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport                      ## CONSUMES\r
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration            ## CONSUMES\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability                   ## PRODUCES\r
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting                      ## PRODUCES\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting                      ## PRODUCES ## CONSUMES\r
 \r
 [Depex]\r
   gEfiMpServiceProtocolGuid AND gEdkiiCpuFeaturesSetDoneGuid\r
index fdfef982930ef760aff7ef531b7fb9117ace3dcb..c4d7ff12fa78912feec3aecdcf68e580cfb3ac95 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Register CPU Features Library PEI instance.\r
 #\r
-#  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #  which accompanies this distribution.  The full text of the license may be found at\r
@@ -56,9 +56,8 @@
 [Pcd]\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuS3DataAddress                        ## CONSUMES\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSupport                      ## CONSUMES\r
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration            ## CONSUMES\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability                   ## PRODUCES\r
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting                      ## PRODUCES\r
+  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting                      ## CONSUMES ## PRODUCES\r
 \r
 [Depex]\r
   gEfiPeiMpServicesPpiGuid AND gEdkiiCpuFeaturesSetDoneGuid\r
index 21dd5773a637c4449999354ea8affcb853d0e6ca..83d6d7f81e7f6189763e2f1c824db334faf4ec66 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   CPU Register Table Library definitions.\r
 \r
-  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -83,7 +83,6 @@ typedef struct {
   CPU_FEATURES_INIT_ORDER  *InitOrder;\r
   UINT8                    *SupportPcd;\r
   UINT8                    *CapabilityPcd;\r
-  UINT8                    *ConfigurationPcd;\r
   UINT8                    *SettingPcd;\r
 \r
   UINT32                   NumberOfCpus;\r
index d51f3de1142434c1b59d1adda53b7c320e282724..2b03e0a8a0f72654f3b03fe64bdad958adffb90a 100644 (file)
   # @Prompt SMM CPU Synchronization Method.\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuSmmSyncMode|0x00|UINT8|0x60000014\r
 \r
-  ## Specifies user's desired settings for enabling/disabling processor features.\r
-  # @Prompt User settings for enabling/disabling processor features.\r
-  gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesUserConfiguration|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}|VOID*|0x00000017\r
-\r
   ## Specifies the On-demand clock modulation duty cycle when ACPI feature is enabled.\r
   # @Prompt The encoded values for target duty cycle modulation.\r
   # @ValidRange  0x80000001 | 0 - 15\r
   # @ValidList   0x80000001 | 0\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesCapability|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}|VOID*|0x00000018\r
 \r
-  ## Specifies actual settings for processor features, each bit corresponding to a specific feature.\r
-  # @Prompt Actual processor feature settings.\r
+  ## As input, specifies user's desired settings for enabling/disabling processor features.\r
+  ## As output, specifies actual settings for processor features, each bit corresponding to a specific feature.\r
+  # @Prompt As input, specifies user's desired processor feature settings. As output, specifies actual processor feature settings.\r
   # @ValidList   0x80000001 | 0\r
   gUefiCpuPkgTokenSpaceGuid.PcdCpuFeaturesSetting|{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}|VOID*|0x00000019\r
 \r