]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/PCD/Pei/Pcd.c
MdeModulePkg PCD: Update PCD database structure definition to match BaseTools
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Pei / Pcd.c
index a9ee051263752732b78673db3bb1e9d4e3636998..7a486b7d1d0503be801f5b948b158e210e6f0735 100644 (file)
@@ -1,7 +1,7 @@
 /** @file \r
   All Pcd Ppi services are implemented here.\r
   \r
-Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2016, 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
@@ -146,10 +146,9 @@ PcdPeimInit (
   IN CONST EFI_PEI_SERVICES     **PeiServices\r
   )\r
 {\r
-  EFI_STATUS        Status;\r
-  PEI_PCD_DATABASE  *DataBase;\r
+  EFI_STATUS Status;\r
 \r
-  DataBase = BuildPcdDatabase (FileHandle);\r
+  BuildPcdDatabase (FileHandle);\r
 \r
   //\r
   // Install PCD_PPI and EFI_PEI_PCD_PPI.\r
@@ -158,15 +157,10 @@ PcdPeimInit (
   ASSERT_EFI_ERROR (Status);\r
 \r
   //\r
-  // Only install PcdInfo PPI when the feature is enabled and PCD info content is present. \r
+  // Install GET_PCD_INFO_PPI and EFI_GET_PCD_INFO_PPI.\r
   //\r
-  if (FeaturePcdGet (PcdPcdInfoGeneration) && (DataBase->PcdNameTableOffset != 0)) {\r
-    //\r
-    // Install GET_PCD_INFO_PPI and EFI_GET_PCD_INFO_PPI.\r
-    //\r
-    Status = PeiServicesInstallPpi (&mPpiList2[0]);\r
-    ASSERT_EFI_ERROR (Status);\r
-  }\r
+  Status = PeiServicesInstallPpi (&mPpiList2[0]);\r
+  ASSERT_EFI_ERROR (Status);\r
 \r
   return Status;\r
 }\r
@@ -232,10 +226,7 @@ PeiGetPcdInfoGetSku (
   VOID\r
   )\r
 {\r
-  if (!FeaturePcdGet (PcdPcdInfoGeneration)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-  return GetPcdDatabase()->SystemSkuId;\r
+  return (UINTN) GetPcdDatabase()->SystemSkuId;\r
 }\r
 \r
 /**\r
@@ -248,7 +239,7 @@ PeiGetPcdInfoGetSku (
   or multiple values, where each value is associated with a specific SKU Id. Items with multiple, \r
   SKU-specific values are called SKU enabled. \r
   \r
-  The SKU Id of zero is reserved as a default. The valid SkuId range is 1 to 255.  \r
+  The SKU Id of zero is reserved as a default.\r
   For tokens that are not SKU enabled, the system ignores any set SKU Id and works with the \r
   single value for that token. For SKU-enabled tokens, the system will use the SKU Id set by the \r
   last call to SetSku(). If no SKU Id is set or the currently set SKU Id isn't valid for the specified token, \r
@@ -265,9 +256,24 @@ PeiPcdSetSku (
   IN  UINTN                  SkuId\r
   )\r
 {\r
+  PEI_PCD_DATABASE  *PeiPcdDb;\r
+  SKU_ID            *SkuIdTable;\r
+  UINTN             Index;\r
+\r
+  PeiPcdDb = GetPcdDatabase();\r
+  SkuIdTable = (SKU_ID *) ((UINT8 *) PeiPcdDb + PeiPcdDb->SkuIdTableOffset);\r
+  for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
+    if (SkuId == SkuIdTable[Index + 1]) {\r
+      PeiPcdDb->SystemSkuId = (SKU_ID) SkuId;\r
+      return;\r
+    }\r
+  }\r
 \r
-  GetPcdDatabase()->SystemSkuId = (SKU_ID) SkuId;\r
-\r
+  //\r
+  // Invalid input SkuId, the default SKU Id will be used for the system.\r
+  //\r
+  DEBUG ((EFI_D_INFO, "PcdPei - Invalid input SkuId, the default SKU Id will be used.\n"));\r
+  PeiPcdDb->SystemSkuId = (SKU_ID) 0;\r
   return;\r
 }\r
 \r