]> git.proxmox.com Git - mirror_edk2.git/commitdiff
If variable does not exist for a HII PCD, a new NV variable need to be created.
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 26 Feb 2009 06:39:56 +0000 (06:39 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Thu, 26 Feb 2009 06:39:56 +0000 (06:39 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7705 6f19259b-4bc3-4df7-8a09-765794883524

MdeModulePkg/Universal/PCD/Dxe/Service.c

index 9c497e960631f2d1885c555db1f9a276ba5afccc..bfc17e734c5b49272a82b881f7df9dd32453ee26 100644 (file)
@@ -978,6 +978,9 @@ SetHiiVariable (
 \r
   Size = 0;\r
 \r
+  //\r
+  // Try to get original variable size information.\r
+  //\r
   Status = gRT->GetVariable (\r
     (UINT16 *)VariableName,\r
     VariableGuid,\r
@@ -987,7 +990,10 @@ SetHiiVariable (
     );\r
 \r
   if (Status == EFI_BUFFER_TOO_SMALL) {\r
-\r
+    //\r
+    // Patch new PCD's value to offset in given HII variable.\r
+    //\r
+    \r
     Buffer = AllocatePool (Size);\r
 \r
     ASSERT (Buffer != NULL);\r
@@ -1015,12 +1021,33 @@ SetHiiVariable (
     FreePool (Buffer);\r
     return Status;\r
 \r
-  } \r
+  } else if (Status == EFI_NOT_FOUND) {\r
+    //\r
+    // If variable does not exist, a new variable need to be created.\r
+    //\r
+    \r
+    Size = Offset + DataSize;\r
+    \r
+    Buffer = AllocateZeroPool (Size);\r
+    ASSERT (Buffer != NULL);\r
+    \r
+    CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);\r
+    \r
+    Status = gRT->SetVariable (\r
+              VariableName,\r
+              VariableGuid,\r
+              EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
+              Size,\r
+              Buffer\r
+              );\r
+\r
+    FreePool (Buffer);\r
+    return Status;    \r
+  }\r
   \r
   //\r
-  // If we drop to here, we don't have a Variable entry in\r
-  // the variable service yet. So, we will save the data\r
-  // in the PCD Database's volatile area.\r
+  // If we drop to here, the value is failed to be written in to variable area\r
+  // So, we will save the data in the PCD Database's volatile area.\r
   //\r
   return Status;\r
 }\r