VARIABLE_STORE_HEADER *VariableStoreHeader;\r
UINTN CacheOffset;\r
\r
- if (CacheVariable->Volatile) {\r
+ if ((mVariableModuleGlobal->FvbInstance == NULL) && ((Attributes & EFI_VARIABLE_NON_VOLATILE) != 0)) {\r
+ //\r
+ // The FVB protocol is not ready. Trying to update NV variable prior to the installation\r
+ // of EFI_VARIABLE_WRITE_ARCH_PROTOCOL.\r
+ //\r
+ return EFI_NOT_AVAILABLE_YET; \r
+ }\r
+\r
+ if ((CacheVariable->CurrPtr == NULL) || CacheVariable->Volatile) {\r
Variable = CacheVariable;\r
} else {\r
- if (mVariableModuleGlobal->FvbInstance == NULL) {\r
- //\r
- // Trying to update NV variable prior to the installation of EFI_VARIABLE_WRITE_ARCH_PROTOCOL\r
- //\r
- return EFI_NOT_AVAILABLE_YET;\r
- }\r
- \r
//\r
+ // Update/Delete existing NV variable.\r
// CacheVariable points to the variable in the memory copy of Flash area\r
// Now let Variable points to the same variable in Flash area.\r
//\r
Variable = &NvVariable; \r
Variable->StartPtr = GetStartPointer (VariableStoreHeader);\r
Variable->EndPtr = GetEndPointer (VariableStoreHeader);\r
- if (CacheVariable->CurrPtr == NULL) {\r
- Variable->CurrPtr = NULL;\r
- } else {\r
- Variable->CurrPtr = (VARIABLE_HEADER *)((UINTN)Variable->StartPtr + ((UINTN)CacheVariable->CurrPtr - (UINTN)CacheVariable->StartPtr));\r
- }\r
- Variable->Volatile = FALSE;\r
- }\r
- \r
- Fvb = mVariableModuleGlobal->FvbInstance;\r
- Reclaimed = FALSE;\r
+ Variable->CurrPtr = (VARIABLE_HEADER *)((UINTN)Variable->StartPtr + ((UINTN)CacheVariable->CurrPtr - (UINTN)CacheVariable->StartPtr));\r
+ Variable->Volatile = FALSE;\r
+ } \r
+\r
+ Fvb = mVariableModuleGlobal->FvbInstance;\r
+ Reclaimed = FALSE;\r
\r
if (Variable->CurrPtr != NULL) {\r
//\r