OpenCoreNvram: Do not overwrite present variables
@@ -42,6 +42,7 @@ OcLoadNvramSupport (
OC_ASSOC *VariableMap;
UINT8 *VariableData;
UINT32 VariableSize;
+ UINTN OriginalVariableSize;
for (GuidIndex = 0; GuidIndex < Config->Nvram.Block.Count; ++GuidIndex) {
//
@@ -109,6 +110,24 @@ OcLoadNvramSupport (
continue;
}
+ OriginalVariableSize = 0;
+ Status = gRT->GetVariable (
+ UnicodeVariableName,
+ &VariableGuid,
+ NULL,
+ &OriginalVariableSize,
+ NULL
+ );
+
+ DEBUG ((
+ DEBUG_INFO,
+ "OC: Getting NVRAM %g:%a - %r (will skip on too small)\n",
+ &VariableGuid,
+ AsciiVariableGuid,
+ Status
+ ));
+
+ if (Status != EFI_BUFFER_TOO_SMALL) {
Status = gRT->SetVariable (
UnicodeVariableName,
&VariableGuid,
@@ -123,6 +142,7 @@ OcLoadNvramSupport (
AsciiVariableGuid,
Status
));
+ }
FreePool (UnicodeVariableName);
}
