summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/PCD
diff options
context:
space:
mode:
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2009-02-26 06:39:56 +0000
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>2009-02-26 06:39:56 +0000
commit746be876f107eeb5782b417d1699337b2b1e96ca (patch)
tree0bfb2f37ab26ffad8010662ced24d746753e73f6 /MdeModulePkg/Universal/PCD
parent18efbdff45c86fc041df8c1df53675289e27f3e2 (diff)
downloadedk2-platforms-746be876f107eeb5782b417d1699337b2b1e96ca.tar.xz
If variable does not exist for a HII PCD, a new NV variable need to be created.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7705 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Universal/PCD')
-rw-r--r--MdeModulePkg/Universal/PCD/Dxe/Service.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/MdeModulePkg/Universal/PCD/Dxe/Service.c b/MdeModulePkg/Universal/PCD/Dxe/Service.c
index 9c497e9606..bfc17e734c 100644
--- a/MdeModulePkg/Universal/PCD/Dxe/Service.c
+++ b/MdeModulePkg/Universal/PCD/Dxe/Service.c
@@ -978,6 +978,9 @@ SetHiiVariable (
Size = 0;
+ //
+ // Try to get original variable size information.
+ //
Status = gRT->GetVariable (
(UINT16 *)VariableName,
VariableGuid,
@@ -987,7 +990,10 @@ SetHiiVariable (
);
if (Status == EFI_BUFFER_TOO_SMALL) {
-
+ //
+ // Patch new PCD's value to offset in given HII variable.
+ //
+
Buffer = AllocatePool (Size);
ASSERT (Buffer != NULL);
@@ -1015,12 +1021,33 @@ SetHiiVariable (
FreePool (Buffer);
return Status;
- }
+ } else if (Status == EFI_NOT_FOUND) {
+ //
+ // If variable does not exist, a new variable need to be created.
+ //
+
+ Size = Offset + DataSize;
+
+ Buffer = AllocateZeroPool (Size);
+ ASSERT (Buffer != NULL);
+
+ CopyMem ((UINT8 *)Buffer + Offset, Data, DataSize);
+
+ Status = gRT->SetVariable (
+ VariableName,
+ VariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
+ Size,
+ Buffer
+ );
+
+ FreePool (Buffer);
+ return Status;
+ }
//
- // If we drop to here, we don't have a Variable entry in
- // the variable service yet. So, we will save the data
- // in the PCD Database's volatile area.
+ // If we drop to here, the value is failed to be written in to variable area
+ // So, we will save the data in the PCD Database's volatile area.
//
return Status;
}