]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/PCD/Dxe/Pcd.c
MdeModulePkg PCD: Allow SkuId to be changed only once
[mirror_edk2.git] / MdeModulePkg / Universal / PCD / Dxe / Pcd.c
index 1bb9098c04cf2fe118e4006a39ddc1889ded10ea..9d710bbf1fb7e72d62dbf345e9c026ae7d0f7941 100644 (file)
@@ -3,7 +3,7 @@
   produce the implementation of native PCD protocol and EFI_PCD_PROTOCOL defined in\r
   PI 1.4a Vol3.\r
 \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, 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
@@ -272,19 +272,38 @@ DxePcdSetSku (
   SKU_ID    *SkuIdTable;\r
   UINTN     Index;\r
 \r
+  if (SkuId == mPcdDatabase.DxeDb->SystemSkuId) {\r
+    //\r
+    // The input SKU Id is equal to current SKU Id, return directly.\r
+    //\r
+    return;\r
+  }\r
+\r
+  if (mPcdDatabase.DxeDb->SystemSkuId != (SKU_ID) 0) {\r
+    DEBUG ((DEBUG_ERROR, "PcdDxe - The SKU Id could be changed only once."));\r
+    DEBUG ((\r
+      DEBUG_ERROR,\r
+      "PcdDxe - The SKU Id was set to 0x%lx already, it could not be set to 0x%lx any more.",\r
+      mPcdDatabase.DxeDb->SystemSkuId,\r
+      (SKU_ID) SkuId\r
+      ));\r
+    ASSERT (FALSE);\r
+    return;\r
+  }\r
+\r
   SkuIdTable = (SKU_ID *) ((UINT8 *) mPcdDatabase.DxeDb + mPcdDatabase.DxeDb->SkuIdTableOffset);\r
   for (Index = 0; Index < SkuIdTable[0]; Index++) {\r
     if (SkuId == SkuIdTable[Index + 1]) {\r
+      DEBUG ((EFI_D_INFO, "PcdDxe - Set current SKU Id to 0x%lx.\n", (SKU_ID) SkuId));\r
       mPcdDatabase.DxeDb->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, "PcdDxe - Invalid input SkuId, the default SKU Id will be used.\n"));\r
-  mPcdDatabase.DxeDb->SystemSkuId = (SKU_ID) 0;\r
+  DEBUG ((EFI_D_INFO, "PcdDxe - Invalid input SkuId, the default SKU Id will be still used.\n"));\r
   return;\r
 }\r
 \r