]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
UefiCpuPkg: Clean up source files
[mirror_edk2.git] / UefiCpuPkg / Library / RegisterCpuFeaturesLib / CpuFeaturesInitialize.c
index 474aea31e950e715c9cd00a7f5f5be57de0ab8bb..ba3fb3250fccef850f6dd0f50a7a74693db58f63 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   CPU Features Initialize functions.\r
 \r
-  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2017 - 2018, 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,17 +56,17 @@ SetSettingPcd (
   @return  The pointer to CPU feature bits mask buffer.\r
 **/\r
 UINT8 *\r
-GetSupportPcds (\r
+GetSupportPcd (\r
   VOID\r
   )\r
 {\r
-  UINTN                  BitMaskSize;\r
   UINT8                  *SupportBitMask;\r
 \r
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesSupport);\r
-  SupportBitMask = AllocateZeroPool (BitMaskSize);\r
+  SupportBitMask = AllocateCopyPool (\r
+          PcdGetSize (PcdCpuFeaturesSupport),\r
+          PcdGetPtr (PcdCpuFeaturesSupport)\r
+          );\r
   ASSERT (SupportBitMask != NULL);\r
-  SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesSupport);\r
 \r
   return SupportBitMask;\r
 }\r
@@ -77,17 +77,17 @@ GetSupportPcds (
   @return  The pointer to CPU feature bits mask buffer.\r
 **/\r
 UINT8 *\r
-GetConfigurationPcds (\r
+GetConfigurationPcd (\r
   VOID\r
   )\r
 {\r
-  UINTN                  BitMaskSize;\r
   UINT8                  *SupportBitMask;\r
 \r
-  BitMaskSize = PcdGetSize (PcdCpuFeaturesUserConfiguration);\r
-  SupportBitMask = AllocateZeroPool (BitMaskSize);\r
+  SupportBitMask = AllocateCopyPool (\r
+          PcdGetSize (PcdCpuFeaturesUserConfiguration),\r
+          PcdGetPtr (PcdCpuFeaturesUserConfiguration)\r
+          );\r
   ASSERT (SupportBitMask != NULL);\r
-  SupportBitMask = (UINT8 *) PcdGetPtr (PcdCpuFeaturesUserConfiguration);\r
 \r
   return SupportBitMask;\r
 }\r
@@ -149,7 +149,6 @@ CpuInitDataInitialize (
   CpuFeaturesData = GetCpuFeaturesData ();\r
   CpuFeaturesData->InitOrder = AllocateZeroPool (sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus);\r
   ASSERT (CpuFeaturesData->InitOrder != NULL);\r
-  CpuFeaturesData->BitMaskSize = (UINT32) PcdGetSize (PcdCpuFeaturesSupport);\r
 \r
   //\r
   // Collect CPU Features information\r
@@ -180,8 +179,8 @@ CpuInitDataInitialize (
   //\r
   // Get support and configuration PCDs\r
   //\r
-  CpuFeaturesData->SupportPcds       = GetSupportPcds ();\r
-  CpuFeaturesData->ConfigurationPcds = GetConfigurationPcds ();\r
+  CpuFeaturesData->SupportPcd       = GetSupportPcd ();\r
+  CpuFeaturesData->ConfigurationPcd = GetConfigurationPcd ();\r
 }\r
 \r
 /**\r
@@ -321,7 +320,7 @@ CollectProcessorData (
   Entry = GetFirstNode (&CpuFeaturesData->FeatureList);\r
   while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) {\r
     CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry);\r
-    if (IsBitMaskMatch (CpuFeaturesData->SupportPcds, CpuFeature->FeatureMask)) {\r
+    if (IsBitMaskMatch (CpuFeaturesData->SupportPcd, CpuFeature->FeatureMask)) {\r
       if (CpuFeature->SupportFunc == NULL) {\r
         //\r
         // If SupportFunc is NULL, then the feature is supported.\r
@@ -444,29 +443,29 @@ AnalysisProcessorFeatures (
   CPU_FEATURES_DATA                    *CpuFeaturesData;\r
 \r
   CpuFeaturesData = GetCpuFeaturesData ();\r
-  CpuFeaturesData->CapabilityPcds = AllocatePool (CpuFeaturesData->BitMaskSize);\r
-  ASSERT (CpuFeaturesData->CapabilityPcds != NULL);\r
-  SetMem (CpuFeaturesData->CapabilityPcds, CpuFeaturesData->BitMaskSize, 0xFF);\r
+  CpuFeaturesData->CapabilityPcd = AllocatePool (CpuFeaturesData->BitMaskSize);\r
+  ASSERT (CpuFeaturesData->CapabilityPcd != NULL);\r
+  SetMem (CpuFeaturesData->CapabilityPcd, CpuFeaturesData->BitMaskSize, 0xFF);\r
   for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) {\r
     CpuInitOrder = &CpuFeaturesData->InitOrder[ProcessorNumber];\r
     //\r
     // Calculate the last capability on all processors\r
     //\r
-    SupportedMaskAnd (CpuFeaturesData->CapabilityPcds, CpuInitOrder->FeaturesSupportedMask);\r
+    SupportedMaskAnd (CpuFeaturesData->CapabilityPcd, CpuInitOrder->FeaturesSupportedMask);\r
   }\r
   //\r
   // Calculate the last setting\r
   //\r
 \r
-  CpuFeaturesData->SettingPcds = AllocateCopyPool (CpuFeaturesData->BitMaskSize, CpuFeaturesData->CapabilityPcds);\r
-  ASSERT (CpuFeaturesData->SettingPcds != NULL);\r
-  SupportedMaskAnd (CpuFeaturesData->SettingPcds, CpuFeaturesData->ConfigurationPcds);\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->CapabilityPcds);\r
-  SetSettingPcd (CpuFeaturesData->SettingPcds);\r
+  SetCapabilityPcd (CpuFeaturesData->CapabilityPcd);\r
+  SetSettingPcd (CpuFeaturesData->SettingPcd);\r
 \r
   //\r
   // Dump the last CPU feature list\r
@@ -476,8 +475,8 @@ AnalysisProcessorFeatures (
     Entry = GetFirstNode (&CpuFeaturesData->FeatureList);\r
     while (!IsNull (&CpuFeaturesData->FeatureList, Entry)) {\r
       CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry);\r
-      if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->CapabilityPcds)) {\r
-        if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->SettingPcds)) {\r
+      if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->CapabilityPcd)) {\r
+        if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->SettingPcd)) {\r
           DEBUG ((DEBUG_INFO, "[Enable   ] "));\r
         } else {\r
           DEBUG ((DEBUG_INFO, "[Disable  ] "));\r
@@ -489,13 +488,13 @@ AnalysisProcessorFeatures (
       Entry = Entry->ForwardLink;\r
     }\r
     DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSupport:\n"));\r
-    DumpCpuFeatureMask (CpuFeaturesData->SupportPcds);\r
+    DumpCpuFeatureMask (CpuFeaturesData->SupportPcd);\r
     DEBUG ((DEBUG_INFO, "PcdCpuFeaturesUserConfiguration:\n"));\r
-    DumpCpuFeatureMask (CpuFeaturesData->ConfigurationPcds);\r
+    DumpCpuFeatureMask (CpuFeaturesData->ConfigurationPcd);\r
     DEBUG ((DEBUG_INFO, "PcdCpuFeaturesCapability:\n"));\r
-    DumpCpuFeatureMask (CpuFeaturesData->CapabilityPcds);\r
+    DumpCpuFeatureMask (CpuFeaturesData->CapabilityPcd);\r
     DEBUG ((DEBUG_INFO, "PcdCpuFeaturesSetting:\n"));\r
-    DumpCpuFeatureMask (CpuFeaturesData->SettingPcds);\r
+    DumpCpuFeatureMask (CpuFeaturesData->SettingPcd);\r
   );\r
 \r
   for (ProcessorNumber = 0; ProcessorNumber < NumberOfCpus; ProcessorNumber++) {\r
@@ -506,7 +505,7 @@ AnalysisProcessorFeatures (
       // Insert each feature into processor's order list\r
       //\r
       CpuFeature = CPU_FEATURE_ENTRY_FROM_LINK (Entry);\r
-      if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->CapabilityPcds)) {\r
+      if (IsBitMaskMatch (CpuFeature->FeatureMask, CpuFeaturesData->CapabilityPcd)) {\r
         CpuFeatureInOrder = AllocateCopyPool (sizeof (CPU_FEATURES_ENTRY), CpuFeature);\r
         ASSERT (CpuFeatureInOrder != NULL);\r
         InsertTailList (&CpuInitOrder->OrderList, &CpuFeatureInOrder->Link);\r
@@ -520,13 +519,13 @@ AnalysisProcessorFeatures (
     Entry = GetFirstNode (&CpuInitOrder->OrderList);\r
     while (!IsNull (&CpuInitOrder->OrderList, Entry)) {\r
       CpuFeatureInOrder = CPU_FEATURE_ENTRY_FROM_LINK (Entry);\r
-      if (IsBitMaskMatch (CpuFeatureInOrder->FeatureMask, CpuFeaturesData->SettingPcds)) {\r
+      if (IsBitMaskMatch (CpuFeatureInOrder->FeatureMask, CpuFeaturesData->SettingPcd)) {\r
         Status = CpuFeatureInOrder->InitializeFunc (ProcessorNumber, CpuInfo, CpuFeatureInOrder->ConfigData, TRUE);\r
         if (EFI_ERROR (Status)) {\r
           //\r
           // Clean the CpuFeatureInOrder->FeatureMask in setting PCD.\r
           //\r
-          SupportedMaskCleanBit (CpuFeaturesData->SettingPcds, CpuFeatureInOrder->FeatureMask);\r
+          SupportedMaskCleanBit (CpuFeaturesData->SettingPcd, CpuFeatureInOrder->FeatureMask);\r
           if (CpuFeatureInOrder->FeatureName != NULL) {\r
             DEBUG ((DEBUG_WARN, "Warning :: Failed to enable Feature: Name = %a.\n", CpuFeatureInOrder->FeatureName));\r
           } else {\r
@@ -553,7 +552,7 @@ AnalysisProcessorFeatures (
     // again during initialize the features.\r
     //\r
     DEBUG ((DEBUG_INFO, "Dump final value for PcdCpuFeaturesSetting:\n"));\r
-    DumpCpuFeatureMask (CpuFeaturesData->SettingPcds);\r
+    DumpCpuFeatureMask (CpuFeaturesData->SettingPcd);\r
 \r
     //\r
     // Dump the RegisterTable\r