summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/PCD
diff options
context:
space:
mode:
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;
}