]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/PCD/Pei/Pcd.c
MdeModulePkg PCD: Allow SkuId to be changed only once
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Pei / Pcd.c
index 668860b61c6ccb3590a51002e578451731c76779..a3f7337ceca3b6665f8563d2a2b83c418eff10a0 100644 (file)
@@ -1,7 +1,7 @@
 /** @file \r
   All Pcd Ppi services are implemented here.\r
   \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -262,19 +262,39 @@ PeiPcdSetSku (
   UINTN             Index;\r
 \r
   PeiPcdDb = GetPcdDatabase();\r
+\r
+  if (SkuId == PeiPcdDb->SystemSkuId) {\r
+    //\r
+    // The input SKU Id is equal to current SKU Id, return directly.\r
+    //\r
+    return;\r
+  }\r
+\r
+  if (PeiPcdDb->SystemSkuId != (SKU_ID) 0) {\r
+    DEBUG ((DEBUG_ERROR, "PcdPei - The SKU Id could be changed only once."));\r
+    DEBUG ((\r
+      DEBUG_ERROR,\r
+      "PcdPei - The SKU Id was set to 0x%lx already, it could not be set to 0x%lx any more.",\r
+      PeiPcdDb->SystemSkuId,\r
+      (SKU_ID) SkuId\r
+      ));\r
+    ASSERT (FALSE);\r
+    return;\r
+  }\r
+\r
   SkuIdTable = (SKU_ID *) ((UINT8 *) PeiPcdDb + PeiPcdDb->SkuIdTableOffset);\r
   for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
     if (SkuId == SkuIdTable[Index + 1]) {\r
+      DEBUG ((EFI_D_INFO, "PcdPei - Set current SKU Id to 0x%lx.\n", (SKU_ID) SkuId));\r
       PeiPcdDb->SystemSkuId = (SKU_ID) SkuId;\r
       return;\r
     }\r
   }\r
 \r
   //\r
-  // Invalid input SkuId, the default SKU Id will be used for the system.\r
+  // Invalid input SkuId, the default SKU Id will be still 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
+  DEBUG ((EFI_D_INFO, "PcdPei - Invalid input SkuId, the default SKU Id will be still used.\n"));\r
   return;\r
 }\r
 \r